index.vue 9.2 KB

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