itemSelect.vue 5.9 KB

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