supplierGoodsListDialog.vue 8.3 KB

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