index.vue 9.6 KB

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