index.vue 9.7 KB

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