supplierGoodsListDialog.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="supplierGoodsListDialogFlag"
  6. title="供货列表"
  7. :close-on-click-modal="false"
  8. append-to-body
  9. width="70%"
  10. :before-close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <ele-pro-table
  15. ref="supplyRef"
  16. :columns="supplyColumns"
  17. :need-page="false"
  18. :selection.sync="selection"
  19. :datasource="supplyList"
  20. :toolkit="[]"
  21. height="350px"
  22. >
  23. <template v-slot:toolbar>
  24. <el-button type="primary" @click="handSelectSupply">新增</el-button>
  25. </template>
  26. <!-- 操作栏 -->
  27. <template v-slot:action="scope">
  28. <el-popconfirm
  29. class="ele-action"
  30. title="确定要删除此物品吗?"
  31. @confirm="handleRemoveSupply(scope.$index)"
  32. >
  33. <template v-slot:reference>
  34. <el-link type="danger" :underline="false" icon="el-icon-delete">
  35. 删除
  36. </el-link>
  37. </template>
  38. </el-popconfirm>
  39. </template>
  40. </ele-pro-table>
  41. <div slot="footer" class="footer">
  42. <el-button type="primary" size="small" @click="selected">选择</el-button>
  43. <el-button @click="cancel">返回</el-button>
  44. </div>
  45. <product-list
  46. ref="productListRef"
  47. :data="supplyList"
  48. @changeParent="getSupplyList"
  49. ></product-list>
  50. </ele-modal>
  51. </template>
  52. <script>
  53. import { contactDetail, contactUpdate } from '@/api/saleManage/contact';
  54. import { getInventoryTotalAPI } from '@/api/wms';
  55. import productList from '@/BIZComponents/product-list.vue';
  56. import { lbjtList } from '@/enum/dict.js';
  57. export default {
  58. name: 'generateContractsDialog',
  59. props: {
  60. supplierGoodsListDialogFlag: {
  61. type: Boolean,
  62. default: false
  63. }
  64. },
  65. components: {
  66. productList
  67. },
  68. data() {
  69. return {
  70. supplyList: [],
  71. selection: [],
  72. form: {},
  73. supplyColumns: [
  74. {
  75. label: '选择',
  76. width: 45,
  77. type: 'selection',
  78. columnKey: 'selection',
  79. align: 'center'
  80. },
  81. {
  82. columnKey: 'index',
  83. type: 'index',
  84. width: 50,
  85. align: 'center',
  86. showOverflowTooltip: true,
  87. label: '序号'
  88. },
  89. {
  90. prop: 'productCode',
  91. label: '编码',
  92. align: 'center',
  93. showOverflowTooltip: true,
  94. minWidth: 110
  95. },
  96. {
  97. prop: 'productName',
  98. label: '名称',
  99. align: 'center',
  100. showOverflowTooltip: true,
  101. minWidth: 110
  102. },
  103. {
  104. prop: 'imgCode',
  105. align: 'center',
  106. label: '图号/件号',
  107. showOverflowTooltip: true,
  108. minWidth: 110
  109. },
  110. {
  111. prop: 'produceType',
  112. align: 'center',
  113. label: '属性类型',
  114. showOverflowTooltip: true,
  115. minWidth: 110,
  116. formatter: (row, column) => {
  117. if(row.produceType){
  118. return row.produceType.map(item=>{
  119. return lbjtList[item]
  120. }).toString()
  121. }
  122. }
  123. },
  124. // {
  125. // prop: 'approvalNumber',
  126. // align: 'center',
  127. // label: '批准文号',
  128. // showOverflowTooltip: true,
  129. // minWidth: 110
  130. // },
  131. {
  132. prop: 'packingSpecification',
  133. align: 'center',
  134. label: '包装规格',
  135. showOverflowTooltip: true,
  136. minWidth: 110
  137. },
  138. {
  139. prop: 'brandNum',
  140. align: 'center',
  141. label: '牌号',
  142. showOverflowTooltip: true
  143. },
  144. {
  145. prop: 'modelType',
  146. label: '型号',
  147. align: 'center',
  148. showOverflowTooltip: true
  149. },
  150. {
  151. prop: 'specification',
  152. label: '规格',
  153. align: 'center',
  154. showOverflowTooltip: true
  155. },
  156. {
  157. prop: 'measuringUnit',
  158. label: '计量单位',
  159. showOverflowTooltip: true,
  160. align: 'center',
  161. minWidth: 90
  162. },
  163. {
  164. action: 'action',
  165. slot: 'action',
  166. label: '操作',
  167. align: 'center',
  168. width: 130
  169. }
  170. // {
  171. // prop: 'weightUnit',
  172. // label: '重量单位',
  173. // showOverflowTooltip: true,
  174. // align: 'center',
  175. // minWidth: 90
  176. // },
  177. //
  178. // {
  179. // prop: 'roughWeight',
  180. // label: '毛重',
  181. // showOverflowTooltip: true,
  182. // align: 'center',
  183. // minWidth: 90
  184. // },
  185. //
  186. // {
  187. // prop: 'netWeight',
  188. // label: '净重',
  189. // showOverflowTooltip: true,
  190. // align: 'center',
  191. // minWidth: 90
  192. // },
  193. //
  194. // {
  195. // prop: 'packingUnit',
  196. // align: 'center',
  197. // label: '包装单位',
  198. // showOverflowTooltip: true
  199. // },
  200. // {
  201. // prop: 'categoryLevelPath',
  202. // label: '分类',
  203. // align: 'center',
  204. // showOverflowTooltip: true
  205. // },
  206. ]
  207. };
  208. },
  209. methods: {
  210. async open(id) {
  211. this.form = await contactDetail(id);
  212. this.supplyList = this.form.productList || [];
  213. },
  214. //选择产品
  215. handSelectSupply() {
  216. this.$refs.productListRef.open(this.supplyList, -1);
  217. },
  218. getSupplyList(obj) {
  219. obj.forEach((item, index) => {
  220. let params = {};
  221. this.$set(params, 'contactId', this.form?.base?.id);
  222. this.$set(params, 'productId', item.id);
  223. this.$set(params, 'categoryName', item.name);
  224. this.$set(params, 'productCategoryId', item.categoryLevelId);
  225. this.$set(params, 'productBrand', item.brandNum);
  226. this.$set(params, 'productCategoryName', item.categoryLevelPath);
  227. this.$set(params, 'productCode', item.code);
  228. this.$set(params, 'productName', item.name);
  229. this.$set(params, 'modelType', item.modelType);
  230. this.$set(params, 'availableCountBase', item.availableCountBase);
  231. this.$set(params, 'measuringUnit', item.measuringUnit);
  232. this.$set(params, 'specification', item.specification);
  233. this.$set(params, 'weightUnit', item.weightUnit);
  234. this.$set(params, 'imgCode', item.imgCode);
  235. this.$set(params, 'produceType', item.componentAttribute);
  236. this.$set(params, 'approvalNumber', item.approvalNumber);
  237. this.$set(params, 'packingSpecification', item.packingSpecification);
  238. if (item.purchaseOrigins?.length) {
  239. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  240. }
  241. this.$set(params, 'provenance', item.purchaseOrigins || []);
  242. this.supplyList.push(params);
  243. });
  244. this.contactUpdate()
  245. this.$forceUpdate();
  246. },
  247. //删除供货产品
  248. handleRemoveSupply(index) {
  249. this.supplyList.splice(index, 1);
  250. this.contactUpdate()
  251. },
  252. contactUpdate() {
  253. this.form.productList = this.supplyList;
  254. const data = {
  255. ...this.form
  256. };
  257. contactUpdate(data);
  258. },
  259. async selected() {
  260. if (!this.selection.length) {
  261. return this.$message.warning('请至少选择一条数据');
  262. }
  263. let codeList = [];
  264. let list = this.selection;
  265. //获取仓库库存
  266. if (this.isGetInventoryTotal) {
  267. codeList = list.map((item) => item.code);
  268. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  269. list.forEach((item) => {
  270. let find =
  271. inventoryTotalList.find((key) => key.code == item.code) || {};
  272. item.availableCountBase = find.availableCountBase;
  273. });
  274. }
  275. this.$emit('changeParent', list);
  276. this.cancel();
  277. },
  278. cancel() {
  279. this.$emit('update:supplierGoodsListDialogFlag', false);
  280. }
  281. }
  282. };
  283. </script>
  284. <style scoped lang="scss"></style>