itemSelect.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <u-list class="listContent">
  3. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  4. <label>
  5. <view class="listBox">
  6. <view class="listBox-sel">
  7. <checkbox :value="item.id" color="#fff" :disabled="item.disabled" :checked="item.checked" />
  8. </view>
  9. <view class="listBox-con">
  10. <view class="listBox-top">
  11. <view class="listBox-name">
  12. {{ item.categoryName }}
  13. </view>
  14. </view>
  15. <view class="listBox-bottom">
  16. <view>类型:{{ item.productCategoryName }}</view>
  17. <view>编码:{{ item.categoryCode }}</view>
  18. <view>牌号:{{ item.productBrand }}</view>
  19. <view>型号:{{ item.categoryModel }}</view>
  20. <view>规格:{{ item.packingSpecification }}</view>
  21. <view>批次号:{{ item.batchNo }}</view>
  22. <view>计量数量:{{ item.measureQuantity }}</view>
  23. <view>单价(元):{{ item.singlePrice }}</view>
  24. <view>发货条码/车架号:{{ item.barcodes }}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </label>
  29. </checkbox-group>
  30. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  31. </u-list>
  32. </template>
  33. <script>
  34. import {
  35. saleordersendrecord
  36. } from '@/api/saleManage/saleorder/index.js'
  37. import {
  38. parameterGetByCode
  39. } from '@/api/mainData/index.js';
  40. import {
  41. getInfoBySourceBizNoAll
  42. } from "@/api/wms/index.js"
  43. import {
  44. getSendSaleOrderrecordDetailSplit
  45. } from "@/api/salesServiceManagement/demandList/index.js"
  46. const dayjs = require('dayjs');
  47. export default {
  48. data() {
  49. return {
  50. listData: [],
  51. sectionList: []
  52. }
  53. },
  54. onLoad({}) {},
  55. methods: {
  56. async getData(row) {
  57. this.sectionList = [];
  58. this.listData = [];
  59. let params = {
  60. code: 'after_sales_product_list_source'
  61. };
  62. const res = await parameterGetByCode(params);
  63. if (res.value == '1') {
  64. this.getInfo(row);
  65. } else {
  66. this._getInfo(row.docNo);
  67. }
  68. },
  69. resetTable() {
  70. this.sectionList = [];
  71. this.listData = [];
  72. },
  73. async _getInfo(sourceBizNo) {
  74. const dataArray = await getInfoBySourceBizNoAll(sourceBizNo);
  75. let res = {};
  76. if (dataArray && dataArray.length > 0) {
  77. res = JSON.parse(JSON.stringify(dataArray[0]));
  78. res['outInDetailList'] = [];
  79. dataArray.forEach((item) => {
  80. item.outInDetailList.forEach((val) => {
  81. res['outInDetailList'].push(val);
  82. });
  83. });
  84. }
  85. this.init(res);
  86. },
  87. init(res) {
  88. let productList = res?.outInDetailList?.map(
  89. (productItem, productIndex) => {
  90. return {
  91. ...productItem,
  92. outInDetailRecordRequestList: productItem.outInDetailRecordRequestList.map((
  93. packingItem) => {
  94. return {
  95. ...packingItem,
  96. categoryName: productItem.categoryName,
  97. categoryCode: productItem.categoryCode,
  98. categoryModel: productItem.categoryModel,
  99. produceTime: packingItem.produceTime || null,
  100. shipmentDate: res.createTime || null,
  101. guaranteePeriodDeadline: this.getTime(res.createTime)[0],
  102. warrantyStatus: this.getTime(res.createTime)[1]
  103. };
  104. })
  105. };
  106. }
  107. );
  108. // 获取包装维度数据
  109. const arr = [];
  110. for (const key in productList) {
  111. for (const k in productList[key].outInDetailRecordRequestList) {
  112. arr.push({
  113. ...productList[key].outInDetailRecordRequestList[k]
  114. });
  115. }
  116. }
  117. this.listData = arr;
  118. },
  119. async getInfo(row) {
  120. const res = await getSendSaleOrderrecordDetailSplit(row.id);
  121. let list = res.productList.map((el) => {
  122. el.categoryCode = el.productCode;
  123. el.categoryName = el.productName;
  124. el.categoryModel = el.modelType;
  125. el.measureQuantity = el.totalCount;
  126. el.barcodes = el.carCode;
  127. el.packingSpecification = el.specification;
  128. el.shipmentDate = row.createTime || null;
  129. (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
  130. (el.warrantyStatus = this.getTime(row.createTime)[1]);
  131. return el;
  132. });
  133. this.listData = list;
  134. },
  135. async selectVal(e, val, index) {
  136. // 添加进选中的数组
  137. if (e.detail.value.length && e.detail.value[0] === val.id) {
  138. this.sectionList.push(val)
  139. }
  140. if (!e.detail.value.length) {
  141. this.sectionList = this.sectionList.filter(item => item.id !== val.id)
  142. }
  143. // if()
  144. console.log(this.sectionList);
  145. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  146. // this.listData.forEach((item, i) => {
  147. // if (item.id != val.id) {
  148. // this.$set(this.listData[i], 'checked', false)
  149. // }
  150. // })
  151. // this.sectionList.push(val)
  152. // let data = val.checked ? val : {};
  153. this.$emit('getDetails', this.sectionList);
  154. },
  155. getTime(createTime) {
  156. let date = new Date(createTime);
  157. date.setMonth(date.getMonth() + 13); // 月份加13月
  158. let time = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
  159. let warrantyStatus =
  160. new Date(time).getTime() > new Date().getTime() ? 0 : 1;
  161. return [time, warrantyStatus];
  162. }
  163. },
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. @import './invoice.scss';
  168. .u-reset-button {
  169. position: absolute;
  170. right: 10rpx;
  171. top: 20rpx;
  172. width: 160rpx;
  173. }
  174. </style>