index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class='container'>
  3. <view class='content'>
  4. <view class='title uni-row'>
  5. <text>当前箱号</text>
  6. </view>
  7. <view
  8. :class="{ 'uni-row': true,'vehicleList':true,'totalBoxHeight':discardVehicleList.length == 0,'halfBoxHeight':discardVehicleList.length > 0}">
  9. <view class="vehicleNo uni-row" v-for="(item,index) in newBindList">
  10. <text>{{item.carrierCode}}</text>
  11. <text @click="handleDelVehicleNo(item,index)">×</text>
  12. </view>
  13. </view>
  14. <view v-if="discardVehicleList.length > 0"
  15. :class="{ 'disuseList': true, 'halfDisuseList':discardVehicleList.length > 0}">
  16. <view class="uni-row" style="align-items: center;justify-content: space-evenly;">
  17. <view>箱号</view>
  18. <view>是否废弃</view>
  19. <view>废弃原因</view>
  20. </view>
  21. <view class="vehicleNo uni-row" v-for="(item,index) in discardVehicleList"
  22. style="align-items: center;justify-content: space-around;">
  23. <view class="uni-row discardVehicleNo"><text>{{item.carrierCode}}</text>
  24. <text @click="handleDelDiscardVehicleList(item,index)">×</text>
  25. </view>
  26. <view class="uni-row">
  27. <switch color="#ff0000" style="transform:scale(0.7)" @change="handleSwitchChange(item)" />
  28. </view>
  29. <view class="uni-row" v-if="item.checked">
  30. <uni-easyinput v-if="item.inpShow" v-model="item.abandonmentReason" focus placeholder="请输入废箱原因"
  31. style="width: 240rpx;"></uni-easyinput>
  32. <uni-data-select v-else v-model="item.abandonmentReason" :localdata="abanonmentList"
  33. style="width: 240rpx;" :clear="false"
  34. @change="abandonmentReasonChange(item)"></uni-data-select>
  35. </view>
  36. <!-- 占空位用 -->
  37. <view class="uni-row" v-if="!item.checked">
  38. <view style="width: 240rpx;"></view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class='bottom uni-row'>
  44. <button class='bottom-btn left-btn' @click="handleScanCode">扫码</button>
  45. <button class='bottom-btn right-btn' type=primary @click="handleSubmit">提交</button>
  46. </view>
  47. </view>
  48. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  49. </template>
  50. <script setup>
  51. import {
  52. ref
  53. } from 'vue'
  54. import {
  55. onMounted,
  56. getCurrentInstance
  57. } from 'vue';
  58. import QrScanner from '../vueQrCode/index.vue'
  59. import {
  60. onLoad,
  61. onReady
  62. } from '@dcloudio/uni-app'
  63. import {
  64. getDictInfoByType
  65. } from '@/api/dict/dict.js'
  66. import {
  67. getDayworkCarrierList
  68. } from '@/api/business/dayworkCarrier.js'
  69. import {
  70. saveInspectionCarrier
  71. } from '@/api/business/processInspection.js'
  72. import {
  73. store
  74. } from '@/store/index.js'
  75. import {
  76. debounce
  77. } from '@/utils/common.js'
  78. import {
  79. addCarrierReject,
  80. checkCarrier,
  81. checkCarrierForInspection
  82. } from '@/api/business/carrier.js'
  83. const bindList = ref([])
  84. const newBindList = ref([])
  85. const discardVehicleList = ref([])
  86. const abanonmentList = ref([])
  87. const showQrCodeReader = ref(false);
  88. let dayWorkInfo = {};
  89. onMounted(() => {
  90. const instance = getCurrentInstance().proxy
  91. const eventChannel = instance.getOpenerEventChannel();
  92. eventChannel.on('outsourceFromOpenerPage', function(data) {
  93. dayWorkInfo = data.data.daywork
  94. console.log(data)
  95. console.log(dayWorkInfo)
  96. let reqParam = {
  97. dayworkId: data.data.dayworkId,
  98. processInspectionId: data.data.processInspectionId,
  99. isChanged: 0
  100. }
  101. init(reqParam);
  102. })
  103. })
  104. function init(data) {
  105. // console.log("data", data)
  106. getDayworkCarrierList(data).then(res => {
  107. // console.log(res)
  108. if (res.code == 200) {
  109. bindList.value = [...res.rows];
  110. newBindList.value = res.rows;
  111. // console.log("newBindList开始", newBindList);
  112. // console.log("res开始", res.rows);
  113. }
  114. })
  115. getDictInfoByType('reason_for_abandonment').then((res) => {
  116. for (var i = 0; i < res.data.length; i++) {
  117. abanonmentList.value[i] = {
  118. text: res.data[i].dictLabel,
  119. value: res.data[i].dictLabel
  120. }
  121. }
  122. })
  123. }
  124. function handleSwitchChange(item) {
  125. item.checked = !item.checked
  126. }
  127. function abandonmentReasonChange(item) {
  128. if (item.abandonmentReason == '其他原因') {
  129. item.inpShow = true;
  130. } else {
  131. item.inpShow = false;
  132. }
  133. }
  134. function handleDelVehicleNo(item, index) {
  135. if (bindList.value.some(carrier => carrier.carrierCode == item.carrierCode)) {
  136. // console.log(bindList.value)
  137. newBindList.value.splice(index, 1);
  138. let discardVehicleInfo = {
  139. carrierCode: item.carrierCode,
  140. checked: false,
  141. reason: '',
  142. carrierId: item.carrierId,
  143. isAbandoned: 1,
  144. operationDate: new Date()
  145. }
  146. discardVehicleList.value.push(discardVehicleInfo)
  147. } else {
  148. newBindList.value.splice(index, 1);
  149. }
  150. }
  151. function handleDelDiscardVehicleList(item, index) {
  152. discardVehicleList.value.splice(index, 1)
  153. newBindList.value.push(item)
  154. item.inpShow = false;
  155. }
  156. //H5扫码器回调
  157. function onDecodeHandler(data) {
  158. showQrCodeReader.value = false;
  159. let vehicleObj = {
  160. carrierCode: data
  161. };
  162. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  163. uni.showToast({
  164. icon: "none",
  165. title: "请扫载具码"
  166. })
  167. return;
  168. }
  169. const checkData = {
  170. ...dayWorkInfo,
  171. id: dayWorkInfo.dayworkId,
  172. dayworkCarriers: newBindList.value,
  173. newCarrierCode: vehicleObj.carrierCode
  174. }
  175. checkCarrierForInspection(checkData).then(response => {
  176. if (response.code == 200) {
  177. // newBindList.value.push(response.data);
  178. // 替换当前箱码
  179. newBindList.value = [
  180. response.data
  181. ]
  182. } else {
  183. uni.showToast({
  184. icon: 'none',
  185. title: response.msg
  186. })
  187. return;
  188. }
  189. }).catch(err => {
  190. uni.showToast({
  191. icon: 'none',
  192. title: '箱码检测检测错误' + err.message
  193. })
  194. })
  195. }
  196. //H5扫码器关闭
  197. function qrReaderClose() {
  198. showQrCodeReader.value = false;
  199. }
  200. function handleScanCode() {
  201. showQrCodeReader.value = true;
  202. // 引入原生插件
  203. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  204. // if (mpaasScanModule) {
  205. // // 调用插件的 mpaasScan 方法
  206. // mpaasScanModule.mpaasScan({
  207. // // 扫码识别类型,参数可多选,qrCode、barCode,
  208. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  209. // scanType: ["qrCode", "barCode"],
  210. // // 是否隐藏相册,默认false不隐藏
  211. // hideAlbum: false,
  212. // },
  213. // (ret) => {
  214. // let vehicleObj = {
  215. // carrierCode: ret.resp_result
  216. // };
  217. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  218. // uni.showToast({
  219. // icon: "none",
  220. // title: "请扫载具码"
  221. // })
  222. // return;
  223. // }
  224. // const checkData = {
  225. // ...dayWorkInfo,
  226. // id: dayWorkInfo.dayworkId,
  227. // dayworkCarriers: newBindList.value,
  228. // newCarrierCode: vehicleObj.carrierCode
  229. // }
  230. // checkCarrierForInspection(checkData).then(response => {
  231. // if (response.code == 200) {
  232. // // newBindList.value.push(response.data);
  233. // // 替换当前箱码
  234. // newBindList.value = [
  235. // response.data
  236. // ]
  237. // } else {
  238. // uni.showToast({
  239. // icon: 'none',
  240. // title: response.msg
  241. // })
  242. // return;
  243. // }
  244. // }).catch(err => {
  245. // uni.showToast({
  246. // icon: 'none',
  247. // title: '箱码检测检测错误' + err.message
  248. // })
  249. // })
  250. // }
  251. // );
  252. // } else {
  253. // const checkData = {
  254. // ...dayWorkInfo,
  255. // id: dayWorkInfo.dayworkId,
  256. // dayworkCarriers: newBindList.value,
  257. // newCarrierCode: '500002'
  258. // }
  259. // checkCarrierForInspection(checkData).then(response => {
  260. // if (response.code == 200) {
  261. // newBindList.value = [
  262. // response.data
  263. // ]
  264. // } else {
  265. // uni.showToast({
  266. // icon: 'none',
  267. // title: response.msg
  268. // })
  269. // return;
  270. // }
  271. // }).catch(err => {
  272. // uni.showToast({
  273. // icon: 'none',
  274. // title: '箱码检测检测错误' + err.message
  275. // })
  276. // })
  277. // }
  278. }
  279. function handleSubmit() {
  280. let carrierRejectList = []
  281. for (var i = 0; i < discardVehicleList.value.length; i++) {
  282. if (discardVehicleList.value[i].checked && discardVehicleList.value[i].abandonmentReason == "") {
  283. uni.showToast({
  284. icon: 'none',
  285. title: '第' + (i + 1) + '条未选择废弃原因'
  286. });
  287. return;
  288. }
  289. if (discardVehicleList.value[i].checked && discardVehicleList.value[i].abandonmentReason !== "") {
  290. carrierRejectList.push(discardVehicleList.value[i])
  291. }
  292. }
  293. // if (carrierRejectList.length > 0) {
  294. // addCarrierReject(carrierRejectList).then((response) => {
  295. // if (response.code == 200) {
  296. // uni.showToast({
  297. // icon: 'success',
  298. // title: '操作成功',
  299. // });
  300. // } else {
  301. // uni.showToast({
  302. // icon: 'none',
  303. // title: '添加失败',
  304. // });
  305. // }
  306. // })
  307. // }
  308. // console.log(dayWorkInfo)
  309. dayWorkInfo.dayworkCarriers = newBindList.value;
  310. dayWorkInfo.rejectCarrier = carrierRejectList
  311. console.log(dayWorkInfo)
  312. saveInspectionCarrier(dayWorkInfo).then(res => {
  313. if (res.code === 200) {
  314. uni.showToast({
  315. icon: 'success',
  316. title: '添加成功',
  317. });
  318. // uni.$emit('refreshProcessInspection')
  319. uni.navigateBack({
  320. delta: 1
  321. });
  322. } else {
  323. uni.showToast({
  324. icon: 'none',
  325. title: res.msg,
  326. duration: 2500
  327. });
  328. }
  329. })
  330. }
  331. </script>
  332. <style lang="scss">
  333. .container {
  334. height: 100%;
  335. background-color: #f5f5f5;
  336. position: absolute;
  337. top: 0;
  338. left: 0;
  339. right: 0;
  340. }
  341. .bottom {
  342. position: fixed;
  343. right: 0;
  344. bottom: 0;
  345. left: 0;
  346. height: 100rpx;
  347. padding: 16rpx 24rpx;
  348. align-items: center;
  349. background-color: #FFFFFF;
  350. justify-content: space-between;
  351. .bottom-btn {
  352. flex: 1;
  353. font-size: 28rpx;
  354. color: #FFFFFF;
  355. &.left-btn {
  356. background-color: rgba(0, 226, 166, 1);
  357. }
  358. &.right-btn {
  359. margin-left: 24rpx;
  360. }
  361. }
  362. }
  363. .content {
  364. position: fixed;
  365. width: 100%;
  366. height: calc(100% - 100rpx - 100rpx - 80rpx);
  367. background-color: rgba(255, 255, 255, 1);
  368. margin: 50rpx auto;
  369. padding-bottom: 50rpx;
  370. border-radius: 12rpx;
  371. .totalBoxHeight {
  372. height: calc(100% - 20rpx);
  373. }
  374. .halfBoxHeight {
  375. height: 480rpx;
  376. }
  377. .halfDisuseList {
  378. height: calc(100% - 480rpx - 20rpx);
  379. }
  380. .vehicleList {
  381. justify-content: baseline;
  382. align-content: flex-start;
  383. flex-wrap: wrap;
  384. width: 100%;
  385. //height: 480rpx;
  386. padding: 0 64rpx;
  387. overflow: auto;
  388. .vehicleNo {
  389. padding: 0 10rpx;
  390. margin: 10rpx;
  391. justify-content: space-between;
  392. align-items: center;
  393. width: 230rpx;
  394. height: 60rpx;
  395. border: 1px solid rgba(213, 213, 213, 1);
  396. border-radius: 6rpx;
  397. }
  398. }
  399. .disuseList {
  400. border-top: 2rpx solid #e1e1e1;
  401. //height: calc(100% - 480rpx - 20rpx);
  402. overflow: auto;
  403. width: 90%;
  404. margin: 0 auto;
  405. padding-top: 20rpx;
  406. }
  407. }
  408. .discardVehicleNo {
  409. padding: 0 10rpx;
  410. margin: 10rpx;
  411. justify-content: space-between;
  412. align-items: center;
  413. width: 150rpx;
  414. height: 60rpx;
  415. border: 1px solid rgba(213, 213, 213, 1);
  416. border-radius: 6rpx;
  417. }
  418. .title {
  419. margin: 30rpx auto;
  420. width: 30%;
  421. font-size: 36rpx;
  422. font-weight: bold;
  423. }
  424. // .btn {
  425. // position: fixed;
  426. // top: 940rpx;
  427. // left: 0;
  428. // right: 0;
  429. // }
  430. // .segment {
  431. // width: 280rpx;
  432. // height: 1rpx;
  433. // border: 1px solid rgba(187, 187, 187, 1);
  434. // }
  435. </style>