itemSelect.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. getSaleOrderDetail
  37. } from '@/api/saleManage/saleorder/index.js'
  38. import {
  39. parameterGetByCode
  40. } from '@/api/mainData/index.js';
  41. import {
  42. getInfoBySourceBizNoAll
  43. } from "@/api/wms/index.js"
  44. import {
  45. getSendSaleOrderrecordDetailSplit
  46. } from "@/api/salesServiceManagement/demandList/index.js"
  47. const dayjs = require('dayjs');
  48. export default {
  49. data() {
  50. return {
  51. listData: [],
  52. sectionList: [],
  53. }
  54. },
  55. onLoad({}) {},
  56. methods: {
  57. async getData(row, associationType) {
  58. this.sectionList = [];
  59. this.listData = [];
  60. console.log(associationType)
  61. if (associationType === '1') {
  62. let params = {
  63. code: 'after_sales_product_list_source'
  64. };
  65. const res = await parameterGetByCode(params);
  66. if (res.value == '1') {
  67. this.getInfo(row);
  68. } else {
  69. this._getInfo(row.docNo);
  70. }
  71. } else {
  72. this.getSaleInfo(row)
  73. }
  74. },
  75. resetTable() {
  76. this.sectionList = [];
  77. this.listData = [];
  78. },
  79. async _getInfo(sourceBizNo) {
  80. const dataArray = await getInfoBySourceBizNoAll(sourceBizNo);
  81. let res = {};
  82. if (dataArray && dataArray.length > 0) {
  83. res = JSON.parse(JSON.stringify(dataArray[0]));
  84. res['outInDetailList'] = [];
  85. dataArray.forEach((item) => {
  86. item.outInDetailList.forEach((val) => {
  87. res['outInDetailList'].push(val);
  88. });
  89. });
  90. }
  91. this.init(res);
  92. },
  93. init(res) {
  94. let productList = res?.outInDetailList?.map(
  95. (productItem, productIndex) => {
  96. return {
  97. ...productItem,
  98. productCategoryName: productItem.categoryLevelPath,
  99. productBrand: productItem.brandNum,
  100. outInDetailRecordRequestList: productItem.outInDetailRecordRequestList.map((
  101. packingItem) => {
  102. return {
  103. ...packingItem,
  104. categoryName: productItem.categoryName,
  105. categoryCode: productItem.categoryCode,
  106. productCategoryName: productItem.categoryLevelPath,
  107. categoryModel: productItem.categoryModel,
  108. produceTime: packingItem.produceTime || null,
  109. shipmentDate: res.createTime || null,
  110. guaranteePeriodDeadline: this.getTime(res.createTime)[0],
  111. warrantyStatus: this.getTime(res.createTime)[1]
  112. };
  113. })
  114. };
  115. }
  116. );
  117. // 获取包装维度数据
  118. const arr = [];
  119. for (const key in productList) {
  120. if (productList[key].outInDetailRecordRequestList.length) {
  121. for (const k in productList[key].outInDetailRecordRequestList) {
  122. arr.push({
  123. ...productList[key].outInDetailRecordRequestList[k]
  124. });
  125. }
  126. } else {
  127. arr.push(productList[key])
  128. }
  129. }
  130. this.listData = arr;
  131. },
  132. async getInfo(row) {
  133. const res = await getSendSaleOrderrecordDetailSplit(row.id);
  134. let list = res.productList.map((el) => {
  135. el.categoryCode = el.productCode;
  136. el.categoryName = el.productName;
  137. el.categoryModel = el.modelType;
  138. el.measureQuantity = el.totalCount;
  139. el.barcodes = el.carCode;
  140. el.packingSpecification = el.specification;
  141. el.shipmentDate = row.createTime || null;
  142. (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
  143. (el.warrantyStatus = this.getTime(row.createTime)[1]);
  144. return el;
  145. });
  146. this.listData = list;
  147. },
  148. async getSaleInfo(row) {
  149. const res = await getSaleOrderDetail(row.id);
  150. let list = res.productList.map((el) => {
  151. el.categoryCode = el.productCode;
  152. el.categoryName = el.productName;
  153. el.categoryModel = el.modelType;
  154. el.measureQuantity = el.totalCount;
  155. el.barcodes = el.carCode;
  156. el.packingSpecification = el.specification;
  157. el.shipmentDate = row.createTime || null;
  158. (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
  159. (el.warrantyStatus = this.getTime(row.createTime)[1]);
  160. return el;
  161. });
  162. this.listData = list;
  163. },
  164. async selectVal(e, val, index) {
  165. // 添加进选中的数组
  166. if (e.detail.value.length && e.detail.value[0] === val.id) {
  167. this.sectionList.push(val)
  168. }
  169. if (!e.detail.value.length) {
  170. this.sectionList = this.sectionList.filter(item => item.id !== val.id)
  171. }
  172. // if()
  173. console.log(this.sectionList);
  174. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  175. // this.listData.forEach((item, i) => {
  176. // if (item.id != val.id) {
  177. // this.$set(this.listData[i], 'checked', false)
  178. // }
  179. // })
  180. // this.sectionList.push(val)
  181. // let data = val.checked ? val : {};
  182. this.$emit('getDetails', this.sectionList);
  183. },
  184. getTime(createTime) {
  185. let date = new Date(createTime);
  186. date.setMonth(date.getMonth() + 13); // 月份加13月
  187. let time = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
  188. let warrantyStatus =
  189. new Date(time).getTime() > new Date().getTime() ? 0 : 1;
  190. return [time, warrantyStatus];
  191. }
  192. },
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. @import './invoice.scss';
  197. .u-reset-button {
  198. position: absolute;
  199. right: 10rpx;
  200. top: 20rpx;
  201. width: 160rpx;
  202. }
  203. </style>