supplierGoodsListDialog.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. @header-dragend="handleHeaderDragend">
  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. import tabMixins from '@/mixins/tableColumnsMixin';
  58. export default {
  59. mixins: [tabMixins],
  60. name: 'generateContractsDialog',
  61. props: {
  62. supplierGoodsListDialogFlag: {
  63. type: Boolean,
  64. default: false
  65. }
  66. },
  67. components: {
  68. productList
  69. },
  70. data() {
  71. return {
  72. cacheKeyUrl: 'views_purchasingManage_purchaseOrder_components_supplierGoodsListDialog',
  73. supplyList: [],
  74. selection: [],
  75. form: {},
  76. supplyColumnsRaw: [
  77. {
  78. label: '选择',
  79. width: 45,
  80. type: 'selection',
  81. columnKey: 'selection',
  82. align: 'center'
  83. },
  84. {
  85. columnKey: 'index',
  86. type: 'index',
  87. width: 50,
  88. align: 'center',
  89. showOverflowTooltip: true,
  90. label: '序号'
  91. },
  92. {
  93. prop: 'productCode',
  94. label: '编码',
  95. align: 'center',
  96. showOverflowTooltip: true,
  97. minWidth: 110
  98. },
  99. {
  100. prop: 'productName',
  101. label: '名称',
  102. align: 'center',
  103. showOverflowTooltip: true,
  104. minWidth: 110
  105. },
  106. {
  107. prop: 'imgCode',
  108. align: 'center',
  109. label: '图号/件号',
  110. showOverflowTooltip: true,
  111. minWidth: 110
  112. },
  113. {
  114. prop: 'produceType',
  115. align: 'center',
  116. label: '属性类型',
  117. showOverflowTooltip: true,
  118. minWidth: 110,
  119. formatter: (row, column) => {
  120. if(row.produceType){
  121. return row.produceType.map(item=>{
  122. return lbjtList[item]
  123. }).toString()
  124. }
  125. }
  126. },
  127. // {
  128. // prop: 'approvalNumber',
  129. // align: 'center',
  130. // label: '批准文号',
  131. // showOverflowTooltip: true,
  132. // minWidth: 110
  133. // },
  134. {
  135. prop: 'packingSpecification',
  136. align: 'center',
  137. label: '包装规格',
  138. showOverflowTooltip: true,
  139. minWidth: 110
  140. },
  141. {
  142. prop: 'brandNum',
  143. align: 'center',
  144. label: '牌号',
  145. showOverflowTooltip: true
  146. },
  147. {
  148. prop: 'modelType',
  149. label: '型号',
  150. align: 'center',
  151. showOverflowTooltip: true
  152. },
  153. {
  154. prop: 'specification',
  155. label: '规格',
  156. align: 'center',
  157. showOverflowTooltip: true
  158. },
  159. {
  160. prop: 'measuringUnit',
  161. label: '计量单位',
  162. showOverflowTooltip: true,
  163. align: 'center',
  164. minWidth: 90
  165. },
  166. {
  167. action: 'action',
  168. slot: 'action',
  169. label: '操作',
  170. align: 'center',
  171. width: 130
  172. }
  173. // {
  174. // prop: 'weightUnit',
  175. // label: '重量单位',
  176. // showOverflowTooltip: true,
  177. // align: 'center',
  178. // minWidth: 90
  179. // },
  180. //
  181. // {
  182. // prop: 'roughWeight',
  183. // label: '毛重',
  184. // showOverflowTooltip: true,
  185. // align: 'center',
  186. // minWidth: 90
  187. // },
  188. //
  189. // {
  190. // prop: 'netWeight',
  191. // label: '净重',
  192. // showOverflowTooltip: true,
  193. // align: 'center',
  194. // minWidth: 90
  195. // },
  196. //
  197. // {
  198. // prop: 'packingUnit',
  199. // align: 'center',
  200. // label: '包装单位',
  201. // showOverflowTooltip: true
  202. // },
  203. // {
  204. // prop: 'categoryLevelPath',
  205. // label: '分类',
  206. // align: 'center',
  207. // showOverflowTooltip: true
  208. // },
  209. ]
  210. };
  211. },
  212. computed: {
  213. // 标准 mixin 列宽持久化:包成 computed 让 applyColumnWidth 应用缓存列宽
  214. supplyColumns() {
  215. this.columnsVersion;
  216. return this.applyColumnWidth(this.supplyColumnsRaw);
  217. },
  218. },
  219. methods: {
  220. async open(id) {
  221. this.form = await contactDetail(id);
  222. this.supplyList = this.form.productList || [];
  223. },
  224. //选择产品
  225. handSelectSupply() {
  226. this.$refs.productListRef.open(this.supplyList, -1);
  227. },
  228. getSupplyList(obj) {
  229. obj.forEach((item, index) => {
  230. let params = {};
  231. this.$set(params, 'contactId', this.form?.base?.id);
  232. this.$set(params, 'productId', item.id);
  233. this.$set(params, 'categoryName', item.name);
  234. this.$set(params, 'productCategoryId', item.categoryLevelId);
  235. this.$set(params, 'productBrand', item.brandNum);
  236. this.$set(params, 'productCategoryName', item.categoryLevelPath);
  237. this.$set(params, 'productCode', item.code);
  238. this.$set(params, 'productName', item.name);
  239. this.$set(params, 'modelType', item.modelType);
  240. this.$set(params, 'availableCountBase', item.availableCountBase);
  241. this.$set(params, 'measuringUnit', item.measuringUnit);
  242. this.$set(params, 'specification', item.specification);
  243. this.$set(params, 'weightUnit', item.weightUnit);
  244. this.$set(params, 'imgCode', item.imgCode);
  245. this.$set(params, 'produceType', item.componentAttribute);
  246. this.$set(params, 'approvalNumber', item.approvalNumber);
  247. this.$set(params, 'packingSpecification', item.packingSpecification);
  248. if (item.purchaseOrigins?.length) {
  249. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  250. }
  251. this.$set(params, 'provenance', item.purchaseOrigins || []);
  252. this.supplyList.push(params);
  253. });
  254. this.contactUpdate()
  255. this.$forceUpdate();
  256. },
  257. //删除供货产品
  258. handleRemoveSupply(index) {
  259. this.supplyList.splice(index, 1);
  260. this.contactUpdate()
  261. },
  262. contactUpdate() {
  263. this.form.productList = this.supplyList;
  264. const data = {
  265. ...this.form
  266. };
  267. contactUpdate(data);
  268. },
  269. async selected() {
  270. if (!this.selection.length) {
  271. return this.$message.warning('请至少选择一条数据');
  272. }
  273. let codeList = [];
  274. let list = this.selection;
  275. //获取仓库库存
  276. if (this.isGetInventoryTotal) {
  277. codeList = list.map((item) => item.code);
  278. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  279. list.forEach((item) => {
  280. let find =
  281. inventoryTotalList.find((key) => key.code == item.code) || {};
  282. item.availableCountBase = find.availableCountBase;
  283. });
  284. }
  285. this.$emit('changeParent', list);
  286. this.cancel();
  287. },
  288. cancel() {
  289. this.$emit('update:supplierGoodsListDialogFlag', false);
  290. }
  291. }
  292. };
  293. </script>
  294. <style scoped lang="scss"></style>