index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view class="uni-column container">
  3. <scroll-view class="scroll-container" scroll-y>
  4. <view v-for="(item, index) in listData" :key="index"
  5. :class="{'list-item':true,'selected':isSelected(item)}">
  6. <!-- @click="handleSelection(item,index)" -->
  7. <view class="title-container uni-row">
  8. <view class="title uni-row">
  9. <text class="label">{{ item['dictDataLabel'] }}</text>
  10. <text class="label code">{{ item['preDeptName'] }}</text>
  11. <text class="label code" style="margin-left: 16rpx;">→</text>
  12. <text class="label code" style="margin-left: 16rpx;">{{ item['deptName'] }}</text>
  13. </view>
  14. <view class="right-info uni-row">
  15. <view class="uni-row"><text class="label right" @click="handleDeleteTurnover(item)">删除</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="item-info uni-row"> <text class="label ">产品描述</text>
  20. <text class="label right" style="color: #000000;">{{ item['productDescription'] }}</text>
  21. </view>
  22. <view class="item-info uni-row"> <text class="label">批次</text>
  23. <text class="label right ">{{ item['lotCode'] }}</text>
  24. </view>
  25. <view class="item-info uni-row">
  26. <text class="label">箱数</text>
  27. <text class="label right">{{ item['carriers'] }}</text>
  28. </view>
  29. <view class="item-info uni-row">
  30. <text class="label">箱号</text>
  31. <text class="label right">{{ item['carrierName']}}</text>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. <view class="bottom uni-row">
  36. <button class="bottom-btn left-btn" @click="HandleScanCode">扫码添加</button>
  37. <button class="bottom-btn right-btn" @click="handleStartTurnover" :disabled="flag">确认周转</button>
  38. </view>
  39. <dialog-turnoverTask ref="turnoverTaskDialog" />
  40. </view>
  41. <dialog-turnoverTask ref="turnoverTask"></dialog-turnoverTask>
  42. <QrScanner v-if="showQrCodeReader" @decode="onDecodeHandler" @close="qrReaderClose" />
  43. </template>
  44. <script setup>
  45. import {
  46. ref
  47. } from 'vue'
  48. import {
  49. onLoad,
  50. } from '@dcloudio/uni-app'
  51. import {
  52. getDayworkItemByCarrierId,
  53. getDayworkItemByCarrierCode
  54. } from '@/api/business/dayWorkItem.js'
  55. import QrScanner from '../vueQrCode/index.vue'
  56. import {
  57. isTakeStock
  58. } from '@/api/business/taksStackLot.js'
  59. const active = ref(false)
  60. const selection = ref([])
  61. const turnoverTaskDialog = ref(null)
  62. const listData = ref([])
  63. const turnoverTask = ref(null)
  64. const flag = ref(false);
  65. const showQrCodeReader = ref(false);
  66. onLoad(() => {
  67. init();
  68. uni.$once('clearListData', () => {
  69. listData.value = [];
  70. })
  71. })
  72. function init() {
  73. flag.value = listData.value.length > 0 ? false : true;
  74. }
  75. /*
  76. function HandleScanCode() {
  77. // 引入原生插件
  78. const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  79. if (mpaasScanModule) {
  80. // 调用插件的 mpaasScan 方法
  81. mpaasScanModule.mpaasScan({
  82. // 扫码识别类型,参数可多选,qrCode、barCode,
  83. // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  84. scanType: ["qrCode", "barCode"],
  85. // 是否隐藏相册,默认false不隐藏
  86. hideAlbum: false,
  87. },
  88. (ret) => {
  89. let vehicleObj = JSON.parse(ret.resp_result);
  90. if (!vehicleObj.carrierId || vehicleObj.carrierId == "") {
  91. uni.showToast({
  92. icon: "none",
  93. title: "请扫载具码",
  94. duration: 1000
  95. })
  96. return;
  97. }
  98. getDayworkItemByCarrierId({
  99. carrierId: vehicleObj.carrierId,
  100. status: 4
  101. }).then(response => {
  102. console.log(response)
  103. for (let i = 0; i < listData.value.length; i++) {
  104. if (listData.value[i].lotCode === response.data[0].lotCode) {
  105. uni.showToast({
  106. icon: "none",
  107. title: "该批次已存在"
  108. })
  109. console.log("该批次已存在")
  110. return;
  111. }
  112. }
  113. for (let i = 0; i < response.data.length; i++) {
  114. listData.value.push(response.data[i]);
  115. }
  116. for (let i = 0; i < listData.value.length; i++) {
  117. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  118. }
  119. console.log(listData.value);
  120. init();
  121. })
  122. }
  123. );
  124. } else {
  125. getDayworkItemByCarrierId({
  126. carrierId: '1747500989324668942',
  127. status: 4
  128. }).then(response => {
  129. console.log(response)
  130. for (let i = 0; i < listData.value.length; i++) {
  131. if (listData.value[i].lotCode === response.data[0].lotCode) {
  132. uni.showToast({
  133. icon: "none",
  134. title: "该批次已存在"
  135. })
  136. console.log("该批次已存在")
  137. return;
  138. }
  139. }
  140. for (let i = 0; i < response.data.length; i++) {
  141. listData.value.push(response.data[i]);
  142. }
  143. for (let i = 0; i < listData.value.length; i++) {
  144. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  145. }
  146. console.log(listData.value);
  147. init();
  148. })
  149. }
  150. }
  151. */
  152. //H5扫码器回调
  153. function onDecodeHandler(data) {
  154. showQrCodeReader.value = false;
  155. let vehicleObj = {
  156. carrierCode: data
  157. };
  158. if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  159. uni.showToast({
  160. icon: "none",
  161. title: "请扫载具码",
  162. duration: 1000
  163. })
  164. return;
  165. }
  166. getDayworkItemByCarrierCode({
  167. carrierCode: vehicleObj.carrierCode,
  168. status: 4
  169. }).then(response => {
  170. console.log(response)
  171. for (let i = 0; i < listData.value.length; i++) {
  172. if (listData.value[i].lotCode === response.data[0].lotCode) {
  173. uni.showToast({
  174. icon: "none",
  175. title: "该批次已存在"
  176. })
  177. console.log("该批次已存在")
  178. return;
  179. }
  180. }
  181. for (let i = 0; i < response.data.length; i++) {
  182. listData.value.push(response.data[i]);
  183. }
  184. for (let i = 0; i < listData.value.length; i++) {
  185. listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  186. }
  187. console.log(listData.value);
  188. init();
  189. })
  190. }
  191. //H5扫码器关闭
  192. function qrReaderClose() {
  193. showQrCodeReader.value = false;
  194. }
  195. function HandleScanCode() {
  196. showQrCodeReader.value = true;
  197. // 引入原生插件
  198. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module");
  199. // if (mpaasScanModule) {
  200. // // 调用插件的 mpaasScan 方法
  201. // mpaasScanModule.mpaasScan({
  202. // // 扫码识别类型,参数可多选,qrCode、barCode,
  203. // // 如不设置,默认识别所有扫码类型,可能有些许影响识别效率
  204. // scanType: ["qrCode", "barCode"],
  205. // // 是否隐藏相册,默认false不隐藏
  206. // hideAlbum: false,
  207. // },
  208. // (ret) => {
  209. // let vehicleObj = {
  210. // carrierCode: ret.resp_result
  211. // };
  212. // if (!vehicleObj.carrierCode || vehicleObj.carrierCode == "") {
  213. // uni.showToast({
  214. // icon: "none",
  215. // title: "请扫载具码",
  216. // duration: 1000
  217. // })
  218. // return;
  219. // }
  220. // getDayworkItemByCarrierCode({
  221. // carrierCode: vehicleObj.carrierCode,
  222. // status: 4
  223. // }).then(response => {
  224. // console.log(response)
  225. // for (let i = 0; i < listData.value.length; i++) {
  226. // if (listData.value[i].lotCode === response.data[0].lotCode) {
  227. // uni.showToast({
  228. // icon: "none",
  229. // title: "该批次已存在"
  230. // })
  231. // console.log("该批次已存在")
  232. // return;
  233. // }
  234. // }
  235. // for (let i = 0; i < response.data.length; i++) {
  236. // listData.value.push(response.data[i]);
  237. // }
  238. // for (let i = 0; i < listData.value.length; i++) {
  239. // listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  240. // }
  241. // console.log(listData.value);
  242. // init();
  243. // })
  244. // }
  245. // );
  246. // } else {
  247. // getDayworkItemByCarrierCode({
  248. // carrierCode: '000828',
  249. // status: 4
  250. // }).then(response => {
  251. // console.log(response)
  252. // for (let i = 0; i < listData.value.length; i++) {
  253. // if (listData.value[i].lotCode === response.data[0].lotCode) {
  254. // uni.showToast({
  255. // icon: "none",
  256. // title: "该批次已存在"
  257. // })
  258. // console.log("该批次已存在")
  259. // return;
  260. // }
  261. // }
  262. // for (let i = 0; i < response.data.length; i++) {
  263. // listData.value.push(response.data[i]);
  264. // }
  265. // for (let i = 0; i < listData.value.length; i++) {
  266. // listData.value[i].carriers = listData.value[i].carrierName.split('、').length;
  267. // }
  268. // console.log(listData.value);
  269. // init();
  270. // })
  271. // }
  272. }
  273. function handleStartTurnover() {
  274. isTakeStock().then(response => {
  275. if (response.data) {
  276. uni.showToast({
  277. icon: 'none',
  278. title: '正在盘点,不能开始周转',
  279. duration: 2000
  280. })
  281. } else {
  282. // 调用子组件中的方法
  283. turnoverTask.value.open(listData.value);
  284. }
  285. })
  286. }
  287. function isSelected(item) {
  288. return selection.value.includes(item);
  289. }
  290. function handleSelection(item, index) {
  291. const buttonIndex = selection.value.findIndex(selectedItem => selectedItem === item);
  292. if (buttonIndex > -1) {
  293. selection.value.splice(buttonIndex, 1); // 取消选中
  294. } else {
  295. selection.value.push(item); // 选中
  296. }
  297. console.log(selection.value, "selection");
  298. }
  299. function handleDeleteTurnover(item) {
  300. uni.showModal({
  301. title: '提示', // 标题
  302. content: '是否删除此条周转', // 提示内容
  303. cancelText: "取消", // 取消按钮的文字
  304. confirmText: "确认", // 确认按钮的文字
  305. //点击确定之后执行的代码
  306. success(res) {
  307. if (res.confirm) {
  308. listData.value = listData.value.filter(it => it.carrierName != item.carrierName);
  309. uni.showToast({
  310. icon: 'none',
  311. title: '该箱子绑定的所有批次已删除',
  312. duration: 2000
  313. })
  314. }
  315. }
  316. });
  317. }
  318. </script>
  319. <style lang="scss">
  320. .container {
  321. height: 100%;
  322. background-color: #f5f5f5;
  323. position: absolute;
  324. top: 0;
  325. left: 0;
  326. right: 0;
  327. }
  328. .scroll-container {
  329. position: fixed;
  330. top: 54px;
  331. right: 0;
  332. bottom: 160rpx;
  333. left: 0;
  334. }
  335. .selected {
  336. border: 1px solid #1684fc;
  337. }
  338. .list-item {
  339. background-color: #fff;
  340. position: relative;
  341. padding: 16rpx;
  342. padding-bottom: 24rpx;
  343. margin: 0 24rpx;
  344. margin-bottom: 24rpx;
  345. border-radius: 8rpx;
  346. .title-container {
  347. justify-content: space-between;
  348. margin-top: 8rpx;
  349. margin-bottom: 16rpx;
  350. .title {
  351. height: 48rpx;
  352. align-items: center;
  353. .label {
  354. color: #1684fc;
  355. font-size: 32rpx;
  356. font-weight: bold;
  357. &.code {
  358. color: #000000;
  359. margin-left: 32rpx;
  360. }
  361. }
  362. }
  363. }
  364. .item-info {
  365. margin-bottom: 16rpx;
  366. .label {
  367. font-size: 28rpx;
  368. width: 152rpx;
  369. color: #808080;
  370. &.right {
  371. flex: 1;
  372. color: #808080;
  373. }
  374. }
  375. }
  376. .right-info {
  377. justify-content: flex-end;
  378. margin-top: 2rpx;
  379. .label {
  380. font-size: 28rpx;
  381. color: #ff0000;
  382. }
  383. }
  384. }
  385. .bottom {
  386. position: fixed;
  387. right: 0;
  388. bottom: 0;
  389. left: 0;
  390. height: 100rpx;
  391. padding: 16rpx 24rpx;
  392. align-items: center;
  393. background-color: #FFFFFF;
  394. justify-content: space-between;
  395. .bottom-btn {
  396. flex: 1;
  397. font-size: 28rpx;
  398. color: #FFFFFF;
  399. &.left-btn {
  400. background-color: #1684fc;
  401. }
  402. &.right-btn {
  403. background-color: rgb(255, 121, 1);
  404. margin-left: 24rpx;
  405. }
  406. }
  407. }
  408. </style>