itemSelect.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. }
  52. },
  53. onLoad({}) {},
  54. methods: {
  55. async getData(row) {
  56. this.listData = [];
  57. let params = {
  58. code: 'after_sales_product_list_source'
  59. };
  60. const res = await parameterGetByCode(params);
  61. if (res.value == '1') {
  62. this.getInfo(row);
  63. } else {
  64. this._getInfo(row.docNo);
  65. }
  66. },
  67. resetTable(){
  68. this.listData = [];
  69. },
  70. async _getInfo(sourceBizNo) {
  71. const dataArray = await getInfoBySourceBizNoAll(sourceBizNo);
  72. let res = {};
  73. if (dataArray && dataArray.length > 0) {
  74. res = JSON.parse(JSON.stringify(dataArray[0]));
  75. res['outInDetailList'] = [];
  76. dataArray.forEach((item) => {
  77. item.outInDetailList.forEach((val) => {
  78. res['outInDetailList'].push(val);
  79. });
  80. });
  81. }
  82. this.init(res);
  83. },
  84. init(res) {
  85. let productList = res?.outInDetailList?.map(
  86. (productItem, productIndex) => {
  87. return {
  88. ...productItem,
  89. outInDetailRecordRequestList: productItem.outInDetailRecordRequestList.map((
  90. packingItem) => {
  91. return {
  92. ...packingItem,
  93. categoryName: productItem.categoryName,
  94. categoryCode: productItem.categoryCode,
  95. categoryModel: productItem.categoryModel,
  96. produceTime: packingItem.produceTime || null,
  97. shipmentDate: res.createTime || null,
  98. guaranteePeriodDeadline: this.getTime(res.createTime)[0],
  99. warrantyStatus: this.getTime(res.createTime)[1]
  100. };
  101. })
  102. };
  103. }
  104. );
  105. // 获取包装维度数据
  106. const arr = [];
  107. for (const key in productList) {
  108. for (const k in productList[key].outInDetailRecordRequestList) {
  109. arr.push({
  110. ...productList[key].outInDetailRecordRequestList[k]
  111. });
  112. }
  113. }
  114. this.listData = arr;
  115. },
  116. async getInfo(row) {
  117. const res = await getSendSaleOrderrecordDetailSplit(row.id);
  118. let list = res.productList.map((el) => {
  119. el.categoryCode = el.productCode;
  120. el.categoryName = el.productName;
  121. el.categoryModel = el.modelType;
  122. el.measureQuantity = el.totalCount;
  123. el.barcodes = el.carCode;
  124. el.packingSpecification = el.specification;
  125. el.shipmentDate = row.createTime || null;
  126. (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
  127. (el.warrantyStatus = this.getTime(row.createTime)[1]);
  128. return el;
  129. });
  130. this.listData = list;
  131. },
  132. async selectVal(e, val, index) {
  133. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  134. this.listData.forEach((item, i) => {
  135. if (item.id != val.id) {
  136. this.$set(this.listData[i], 'checked', false)
  137. }
  138. })
  139. let data = val.checked ? val : {};
  140. this.$emit('getDetails', data);
  141. },
  142. getTime(createTime) {
  143. let date = new Date(createTime);
  144. date.setMonth(date.getMonth() + 13); // 月份加13月
  145. let time = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
  146. let warrantyStatus =
  147. new Date(time).getTime() > new Date().getTime() ? 0 : 1;
  148. return [time, warrantyStatus];
  149. }
  150. },
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. @import './invoice.scss';
  155. .u-reset-button {
  156. position: absolute;
  157. right: 10rpx;
  158. top: 20rpx;
  159. width: 160rpx;
  160. }
  161. </style>