orderSearch.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <!-- 订单搜索 -->
  3. <view>
  4. <u-navbar title="" autoBack placeholder>
  5. <view class="u-nav-slot nav_center" slot="center">
  6. <view style="width: calc(100% - 90rpx);">
  7. <u-search v-model="keyword" :focus="true" shape="square" placeholder="请输入运单号搜索" @custom="searchBank"
  8. @search="searchBank" @clear="clear"></u-search>
  9. </view>
  10. </view>
  11. </u-navbar>
  12. <view v-if="orderList.length > 0">
  13. <x-orderManagement ref="order" :orderList="orderList" @sendOrders="sendOrders"
  14. @operateSuccessfully="operateSuccessfully" @proofRenewal="proofRenewal"
  15. :key="keyId"></x-orderManagement>
  16. </view>
  17. <u-empty mode="search" marginTop="50" v-else></u-empty>
  18. <u-popup :show="sendShow" closeable round="8" :closeOnClickOverlay="false" @close="close">
  19. <view class="card_send">
  20. <view class="send_title">派单</view>
  21. <view class="card_input_send">
  22. <view class="incubator_title"><span>*</span>保温箱</view>
  23. <view class="card_search_gray frame" @click="focus(false)">
  24. <span v-if="incubator.name">{{incubator.name}}</span>
  25. <span class="title_gray" v-else>请选择保温箱</span>
  26. <u-icon name="arrow-down" color="#c8c9cc" size="18"></u-icon>
  27. </view>
  28. </view>
  29. <view class="card_input_send">
  30. <view class="incubator_title"><span>*</span>冰排编号</view>
  31. <u-input placeholder="请输入冰排编号" border="surround" v-model="iceNumber" @blur="iceRaftBlur">
  32. <template slot="suffix">
  33. <u-icon name="scan" size="24" @click="sweep"></u-icon>
  34. </template>
  35. </u-input>
  36. <view class="add_card center_in" @click="addIce">
  37. <u-icon name="plus" size="18"></u-icon>
  38. </view>
  39. </view>
  40. <view class="card_frequency">
  41. <view class="card_high space_between">
  42. <view class="card_frequency_title">已扫冰排编号</view>
  43. <view class="card_bottle">已扫<span>{{iceList.length}}</span></view>
  44. </view>
  45. <scroll-view :scroll-top="scrollTop" scroll-y="true" class="swept_card">
  46. <view class="scrollView" style="width: 100%;" v-if="iceList.length > 0">
  47. <view class="item_coding" v-for="(item,index) in iceList" :key="index">
  48. <view style="display: flex;align-items: center;">
  49. <view class="num_index">{{index + 1}}</view>
  50. <view class="title_coding">{{item}}</view>
  51. </view>
  52. <u-icon name="close-circle-fill" color="#c0c4cc" size="20"
  53. @click="removeWaybill(item)"></u-icon>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. </view>
  58. <view style="width: 100%;height: 120rpx;"></view>
  59. <view class="card_btn">
  60. <u-button type="primary" text="确定" @click="confirm"></u-button>
  61. </view>
  62. </view>
  63. </u-popup>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return {
  70. keyword: '',
  71. loadingMore: true,
  72. orderList: [],
  73. incubator: {
  74. id: null,
  75. name: '',
  76. },
  77. sendShow: false,
  78. iceNumber: '',
  79. iceList: [],
  80. scrollTop: null,
  81. keyId: 0,
  82. waybillId: null,
  83. }
  84. },
  85. beforeDestroy() {
  86. // console.log('页面销毁')
  87. this.getempty()
  88. },
  89. onShow() {
  90. let incubator = uni.getStorageSync('incubatorValue')
  91. if (incubator) {
  92. this.incubator.id = incubator.id
  93. this.incubator.name = incubator.name
  94. }
  95. },
  96. methods: {
  97. getempty() {
  98. this.iceList = []
  99. this.incubator.id = ''
  100. this.incubator.name = ''
  101. this.iceNumber = ''
  102. uni.removeStorageSync('incubatorValue');
  103. this.hintTitle = '请选择保温箱'
  104. this.sendShow = false
  105. this.incubatorMore = true
  106. this.thermostatList = []
  107. },
  108. searchBank(event) {
  109. this.orderList = []
  110. this.loadingMore = true;
  111. this.$api.get('/api/waybill', {
  112. waybillNo: this.keyword,
  113. }).then(res => {
  114. if (res.code == 200) {
  115. const data = res.data.list
  116. if (this.loadingMore == true && data) {
  117. this.orderList = this.orderList.concat(data);
  118. }
  119. if (data.length < this.pageSize) {
  120. this.loadingMore = true
  121. } else {
  122. this.loadingMore = false
  123. }
  124. }
  125. }).catch(() => {
  126. this.loadingMore = true
  127. })
  128. },
  129. // 移除错误运单号
  130. removeWaybill(value) {
  131. if (this.iceNumber == value) {
  132. this.iceNumber = ''
  133. }
  134. const arr = deleteElementById(this.iceList, value)
  135. this.iceList = arr
  136. function deleteElementById(arr, key) {
  137. return arr.filter((item) => item !== key);
  138. }
  139. },
  140. // 添加冰排
  141. addIce() {
  142. if (this.iceNumber) {
  143. this.iceList.push(this.iceNumber)
  144. this.iceList = this.uniqueArray(this.iceList)
  145. this.$nextTick(() => {
  146. // 获取scroll-view的高度
  147. const query = uni.createSelectorQuery().in(this);
  148. query.select('.scrollView').boundingClientRect(data => {
  149. this.scrollTop = data.height;
  150. }).exec();
  151. });
  152. this.iceNumber = ''
  153. }
  154. },
  155. // 冰排失去焦点
  156. iceRaftBlur(value) {
  157. if (value) {
  158. this.iceList.push(value)
  159. this.iceList = this.uniqueArray(this.iceList)
  160. }
  161. },
  162. // 去重
  163. uniqueArray(arr) {
  164. return [...new Set(arr)];
  165. },
  166. // 确定派单
  167. confirm() {
  168. if (this.incubator.id) {
  169. if (this.iceList.length > 0) {
  170. const arr = []
  171. arr.push(this.waybillId)
  172. this.$api.post('/api/waybill/delivery', {
  173. waybillIds: arr,
  174. coolerBoxId: this.incubator.id,
  175. iceRaftCode: this.iceList,
  176. }).then(res => {
  177. if (res.code == 200) {
  178. uni.$u.toast(res.msg)
  179. this.sendShow = false
  180. this.tabClick()
  181. } else if (res.code == 2000) {
  182. let arrTitle = res.data
  183. let title = ' ,请将冰排' + arrTitle.toString() + '重新入库'
  184. uni.$u.toast(res.msg + title)
  185. this.sendShow = false
  186. this.tabClick()
  187. } else {
  188. uni.$u.toast(res.msg)
  189. }
  190. })
  191. } else {
  192. uni.$u.toast('请先扫描冰排')
  193. }
  194. } else {
  195. uni.$u.toast('请先选择保温箱')
  196. }
  197. },
  198. // tab运单
  199. tabClick(row) {
  200. this.keyId = row.index
  201. this.loadingMore = true
  202. this.orderList = []
  203. this.searchBank()
  204. this.getempty()
  205. },
  206. // 扫一扫
  207. sweep() {
  208. // 允许从相机和相册扫码
  209. uni.scanCode({
  210. scanType: ['barCode'],
  211. // scanType: ['qrCode'],
  212. autoZoom: false,
  213. success: (res) => {
  214. console.log(res);
  215. if (res.result) {
  216. let url = res.result;
  217. this.iceNumber = url
  218. this.iceList.push(url)
  219. function methods1(arr) {
  220. return Array.from(new Set(arr));
  221. }
  222. this.iceList = methods1(this.iceList)
  223. } else {
  224. console.log('请重新扫描');
  225. return false;
  226. }
  227. },
  228. fail: (res) => {
  229. console.log('未识别到二维码');
  230. }
  231. })
  232. },
  233. // 鼠标聚焦
  234. focus() {
  235. uni.navigateTo({
  236. url: '/pages/order/Incubator'
  237. });
  238. },
  239. // 派单
  240. sendOrders(value) {
  241. this.waybillId = value.id
  242. this.sendShow = true
  243. },
  244. // 重新获取列表
  245. operateSuccessfully() {
  246. this.orderList = []
  247. this.searchBank()
  248. },
  249. // 防拆更新
  250. proofRenewal() {
  251. this.orderList = []
  252. this.searchBank()
  253. },
  254. clear() {
  255. console.log(2)
  256. this.keyword = ''
  257. },
  258. close() {
  259. this.getempty()
  260. },
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. .nav_center {
  266. display: flex;
  267. align-items: center;
  268. justify-content: flex-end;
  269. padding-right: 30rpx;
  270. width: 100%;
  271. }
  272. .card_send {
  273. padding: 20rpx;
  274. min-height: 600rpx;
  275. }
  276. .send_title {
  277. text-align: center;
  278. margin: 10px;
  279. }
  280. .card_input_send {
  281. position: relative;
  282. display: flex;
  283. align-items: center;
  284. margin-bottom: 20rpx;
  285. }
  286. .incubator_title {
  287. width: 150rpx;
  288. margin-right: 10rpx;
  289. font-size: 30rpx;
  290. span {
  291. color: red;
  292. }
  293. }
  294. .add_card {
  295. margin-left: 10rpx;
  296. width: 50rpx;
  297. height: 46rpx;
  298. border-radius: 8rpx;
  299. padding: 6px 9px;
  300. border: 1px solid #dadbde;
  301. }
  302. .card_btn {
  303. position: absolute;
  304. bottom: 20rpx;
  305. left: 30rpx;
  306. right: 30rpx;
  307. padding: 20rpx 0rpx;
  308. }
  309. .scroll-view {
  310. transition: max-height 1s ease-out;
  311. max-height: 0;
  312. overflow: hidden;
  313. }
  314. .card_frequency {
  315. display: flex;
  316. flex-wrap: wrap;
  317. }
  318. .swept_card {
  319. padding: 0rpx 20rpx;
  320. width: calc(100% - 40rpx);
  321. max-height: 600rpx;
  322. // overflow-y: auto;
  323. }
  324. .card_high {
  325. margin-bottom: 20rpx;
  326. }
  327. .card_frequency_title {
  328. font-size: 32rpx;
  329. }
  330. .card_bottle {
  331. font-size: 30rpx;
  332. span {
  333. color: red;
  334. }
  335. }
  336. .item_coding {
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. width: 100%;
  341. padding: 20rpx 0rpx;
  342. }
  343. .num_index {
  344. font-size: 30rpx;
  345. margin-right: 10rpx;
  346. }
  347. .title_coding {
  348. font-size: 30rpx;
  349. }
  350. .card_search_gray {
  351. display: flex;
  352. flex-direction: row;
  353. align-items: center;
  354. justify-content: space-between;
  355. flex: 1;
  356. padding: 12rpx 18rpx;
  357. border-radius: 8rpx;
  358. line-height: 48rpx;
  359. }
  360. .title_gray {
  361. font-size: 30rpx;
  362. color: #c8c9cc;
  363. }
  364. // 伪元素1rpx边框
  365. .frame {
  366. position: relative; //重要
  367. }
  368. .frame::after {
  369. position: absolute;
  370. content: '';
  371. border: 2rpx solid #e7e6e4;
  372. border-radius: 16rpx;
  373. width: 200%;
  374. height: 200%;
  375. top: 0;
  376. left: 0;
  377. transform: scale(0.5);
  378. transform-origin: 0 0;
  379. pointer-events: none;
  380. /* 使伪元素不会阻止鼠标事件 */
  381. }
  382. </style>