addDialog.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" :loading="loading">
  4. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  5. <headerTitle title="基本信息">
  6. <template slot-scope="right">
  7. <div
  8. style="
  9. padding-bottom: 10px;
  10. position: fixed;
  11. right: 0;
  12. width: 250px;
  13. background: #fff;
  14. z-index: 999;
  15. "
  16. >
  17. <el-button @click="cancel">返回</el-button>
  18. <el-button type="primary" @click="save">保存</el-button>
  19. <el-button
  20. type="primary"
  21. v-if="isNeed_process_is_close"
  22. @click="save('sub')"
  23. >提交</el-button
  24. >
  25. </div>
  26. </template>
  27. </headerTitle>
  28. <el-row>
  29. <el-col :span="8">
  30. <el-form-item label="采购计划单名称" prop="planCode">
  31. <el-input
  32. @click.native="handParent"
  33. v-model="form.planName"
  34. placeholder="请选择"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-form-item
  40. label="询价单名称"
  41. prop="inquiryName"
  42. style="margin-bottom: 22px"
  43. >
  44. <el-input v-model="form.inquiryName"></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="8">
  48. <el-form-item
  49. prop="remark"
  50. label="是否接受拆单"
  51. label-width="120px"
  52. >
  53. <el-select
  54. v-model="form.acceptUnpack"
  55. clearable
  56. style="width: 100%"
  57. disabled
  58. >
  59. <el-option
  60. v-for="item in acceptUnpackList"
  61. :key="item.value"
  62. :label="item.label"
  63. :value="item.value"
  64. >
  65. </el-option>
  66. </el-select>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="8">
  70. <el-form-item prop="remark" label="备注">
  71. <el-input
  72. type="textarea"
  73. resize="none"
  74. v-model="form.remark"
  75. :rows="2"
  76. placeholder="请输入"
  77. size="small"
  78. maxlength="200"
  79. ></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="8">
  83. <el-form-item prop="files" label="附件">
  84. <fileMain v-model="form.files" type="view"></fileMain>
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. </el-form>
  89. <headerTitle title="物品清单" style="margin-top: 15px"></headerTitle>
  90. <el-button
  91. type="primary"
  92. style="margin-bottom: 10px"
  93. @click="openSupplier"
  94. v-click-once
  95. >新增报价单</el-button
  96. >
  97. <el-button
  98. type="primary"
  99. style="margin-bottom: 10px"
  100. @click="supplierSelectAll"
  101. v-click-once
  102. >批量生成报价单</el-button
  103. >
  104. <inventoryTable
  105. ref="inventoryTable"
  106. @delList="delList"
  107. :acceptUnpack="form.acceptUnpack"
  108. @supplierSelect="supplierSelect"
  109. >
  110. </inventoryTable>
  111. <headerTitle title="报价清单" style="margin-top: 15px"></headerTitle>
  112. <inquiryManageList
  113. generatedType="inquiry"
  114. ref="inquiryManageRef"
  115. @changeInquiryManageList="changeInquiryManageList"
  116. @supplierManageChange="supplierManageChange"
  117. @supplierSelect="supplierSelect"
  118. ></inquiryManageList>
  119. <supplierManageDialog
  120. ref="supplierManageDialogRef"
  121. @supplierManageChange="supplierManageChange"
  122. ></supplierManageDialog>
  123. <inquiryTable
  124. @removeSupplier="removeSupplier"
  125. :ref="'inquiryTable' + item.supplierId"
  126. v-for="item in supplierList"
  127. :key="item.supplierId"
  128. style="margin-top: 15px"
  129. :obj="item"
  130. :isUpdate="isUpdate"
  131. @deliveryDateChange="deliveryDateChange"
  132. ></inquiryTable>
  133. <process-submit-dialog
  134. api-fun-name="purchaseinquiryStatusAPI"
  135. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  136. v-if="processSubmitDialogFlag"
  137. ref="processSubmitDialogRef"
  138. @reload="reload"
  139. ></process-submit-dialog>
  140. </el-card>
  141. </div>
  142. <!-- </ele-modal>-->
  143. </template>
  144. <script>
  145. import inventoryTable from './inventoryTable.vue';
  146. import inquiryTable from './inquiryTable.vue';
  147. import inquiryManageList from './inquiryManage-list.vue';
  148. import supplierManageDialog from './supplierManageDialog.vue';
  149. import fileUpload from '@/components/upload/fileUpload';
  150. import dictMixins from '@/mixins/dictMixins';
  151. import {
  152. getplanDetail,
  153. isHasGeneratedInquiryAPI
  154. } from '@/api/purchasingManage/purchasePlanManage';
  155. import {
  156. UpdateInformation,
  157. getpurchaseinquiry,
  158. addPurchaseinquiry,
  159. chooseWinner,
  160. submit
  161. } from '@/api/purchasingManage/inquiryManage';
  162. import { copyObj } from '@/utils/util';
  163. import { getFile } from '@/api/system/file';
  164. import {
  165. contactDetail,
  166. contactQueryByCategoryIdsAPI,
  167. updateRelationStatus
  168. } from '@/api/saleManage/contact';
  169. import { deepClone } from '@/utils';
  170. import {
  171. finishPageTab,
  172. getRouteTabKey,
  173. reloadPageTab,
  174. removePageTab
  175. } from '@/utils/page-tab-util';
  176. import _ from 'lodash';
  177. // import fileMain from '@/components/addDoc/index.vue';
  178. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  179. import { orderSourceType } from '@/enum/dict';
  180. export default {
  181. name: 'eomInquiryManageAddDialog',
  182. props: {
  183. categoryTreeList: Array
  184. },
  185. mixins: [dictMixins],
  186. components: {
  187. processSubmitDialog,
  188. // fileMain,
  189. fileUpload,
  190. inventoryTable,
  191. inquiryManageList,
  192. supplierManageDialog,
  193. inquiryTable
  194. },
  195. data() {
  196. let formDef = {
  197. id: '',
  198. planCode: null,
  199. planName: null,
  200. inquiryName: null,
  201. remark: null,
  202. planId: '',
  203. detailList: '',
  204. resultList: [],
  205. supplierName: '',
  206. files: [],
  207. acceptUnpack: '',
  208. isFirstProcess: 0
  209. };
  210. return {
  211. activeName: '1',
  212. businessId: '',
  213. visible: false,
  214. supplierVisible: false,
  215. processSubmitDialogFlag: false,
  216. title: '',
  217. supplierList: [],
  218. detailList: [],
  219. list: [],
  220. delDetailIds: [],
  221. supplierProducts: {},
  222. formDef,
  223. rawList: [],
  224. outputList: [],
  225. acceptUnpackList: [
  226. {
  227. label: '接受',
  228. value: 1
  229. },
  230. {
  231. label: '不接受',
  232. value: 0
  233. }
  234. ],
  235. form: copyObj(formDef),
  236. rules: {
  237. responsibleName: [
  238. { required: true, message: '请选择负责人', trigger: 'change' }
  239. ],
  240. requireDeptId: [
  241. { required: true, message: '请选择需求部门', trigger: 'change' }
  242. ],
  243. inquiryName: [
  244. { required: true, message: '请输入询价单名称', trigger: 'blur' }
  245. ]
  246. },
  247. // 提交状态
  248. loading: false,
  249. // 是否是修改
  250. isUpdate: false
  251. };
  252. },
  253. created() {
  254. this.requestDict('产地');
  255. this.requestDict('质保期单位');
  256. this.requestDict('生产类型');
  257. this.requestDict('结算方式');
  258. if (this.$route.query.id) {
  259. this.open(this.$route.query);
  260. }
  261. },
  262. methods: {
  263. openSupplier() {
  264. if (!this.form.planCode)
  265. return this.$message.warning('请先选择采购计划');
  266. if (!this.$refs.inventoryTable.selection.length)
  267. return this.$message.warning('请选择产品');
  268. this.$refs.supplierManageDialogRef.open();
  269. },
  270. //获取询价详情
  271. async getDetailData(id, type) {
  272. this.businessId = id;
  273. this.loading = true;
  274. let data = await getpurchaseinquiry(id);
  275. this.loading = false;
  276. if (data) {
  277. this.form = data;
  278. this.supplierList = data.supplierList;
  279. let categoryIds = [...data.detailList].map((item) => item.productId);
  280. let supplierObj = await contactQueryByCategoryIdsAPI({ categoryIds });
  281. [...data.detailList].forEach((item) => {
  282. item.supplierList = supplierObj[item.productId] || [];
  283. });
  284. this.list = orderSourceType.includes(this.form.sourceType) ? [...data.detailList, ...data.rawList, ...data.outputList] : [...data.detailList];
  285. this.rawList = data.rawList;
  286. this.outputList = data.outputList;
  287. this.$nextTick(() => {
  288. this.$refs.inventoryTable &&
  289. this.$refs.inventoryTable.putTableValue(data.detailList);
  290. });
  291. if (type == 'init') {
  292. await this.getplanData(data.planId, type);
  293. }
  294. // this.$nextTick(() => {
  295. // });
  296. }
  297. },
  298. deliveryDateChange(fn) {
  299. let data = this.$refs.inventoryTable.getTableValue() || [];
  300. fn(data);
  301. },
  302. //获取计划详情
  303. async getplanData(id, type) {
  304. this.loading = true;
  305. let data = await getplanDetail(id);
  306. this.rawList = data.rawDetailList;
  307. this.outputList = data.outputDetailList;
  308. this.supplierList = [];
  309. this.loading = false;
  310. if (data) {
  311. let categoryIds = [...data.detailList].map((item) => item.productId);
  312. let supplierObj = await contactQueryByCategoryIdsAPI({ categoryIds });
  313. [...data.detailList].forEach((item) => {
  314. if (item.arrivalWay == 2 && item.arrivalBatch.length > 0) {
  315. item.expectReceiveDate =
  316. item.arrivalBatch[item.arrivalBatch.length - 1].arriveDate;
  317. }
  318. item.supplierList = supplierObj[item.productId] || [];
  319. if (item.supplierList?.length) {
  320. item.supplierIds = item.supplierId
  321. ? [item.supplierId]
  322. : [item.supplierList[0].id];
  323. // this.supplierSelect(item);
  324. }
  325. });
  326. this.$set(this.form, 'acceptUnpack', data.acceptUnpack);
  327. this.form.planId = data.id;
  328. this.form.planCode = data.planCode;
  329. this.form.planName = data.planName;
  330. this.form.isFirstProcess = data.isFirstProcess;
  331. this.form.inquiryName = data.planName;
  332. this.form.sourceType = data.sourceType;
  333. // if (type == 'change') {
  334. // this.supplierList.forEach((item) => {
  335. // this.$refs['inquiryTable' + item.supplierId][0]&&this.$refs['inquiryTable' + item.supplierId][0].putTableValue(
  336. // data.detailList
  337. // );
  338. // });
  339. // }
  340. if (type == 'init') {
  341. return;
  342. }
  343. if(orderSourceType.includes(this.form.sourceType)){
  344. this.list = [
  345. ...data.detailList,
  346. ...data.rawDetailList,
  347. ...data.outputDetailList
  348. ];
  349. } else {
  350. this.list = [...data.detailList];
  351. }
  352. data.detailList.forEach((item) => {
  353. item.isWinner = 1;
  354. });
  355. this.$nextTick(() => {
  356. this.$refs.inventoryTable &&
  357. this.$refs.inventoryTable.putTableValue(data.detailList);
  358. // this.$refs.rawDetailListRef &&
  359. // this.$refs.rawDetailListRef.putTableValue(data.rawDetailList); //原料
  360. // this.$refs.outputDetailListRef &&
  361. // this.$refs.outputDetailListRef.putTableValue(
  362. // data.outputDetailList
  363. // );
  364. });
  365. }
  366. },
  367. async open({ type, id }) {
  368. this.title = type === 'add' ? '新增' : '修改';
  369. this.activeName = '1';
  370. this.visible = true;
  371. if (type == 'add') {
  372. this.isUpdate = false;
  373. if (id) {
  374. await this.getplanData(id);
  375. //是否生成过核价单
  376. let res = await isHasGeneratedInquiryAPI(id);
  377. if (res) this.$message.warning('该计划已生成过核价单,请注意。');
  378. }
  379. } else {
  380. this.isUpdate = true;
  381. await this.getDetailData(id);
  382. }
  383. // this.init(row.id);
  384. },
  385. getValidate() {
  386. let promises = [];
  387. this.supplierList.forEach((item) => {
  388. promises.push(
  389. new Promise((resolve, reject) => {
  390. this.$refs['inquiryTable' + item.supplierId][0].validateForm(
  391. (valid, errors) => {
  392. console.log(valid, errors);
  393. if (!valid) {
  394. // 解析错误信息
  395. let errorMessages = [];
  396. if (errors) {
  397. console.log('Errors structure:', errors);
  398. for (let field in errors) {
  399. if (errors[field]) {
  400. if (Array.isArray(errors[field])) {
  401. errors[field].forEach(error => {
  402. if (typeof error === 'string') {
  403. errorMessages.push(error);
  404. } else if (error && error.message) {
  405. errorMessages.push(error.message);
  406. } else {
  407. errorMessages.push(JSON.stringify(error));
  408. }
  409. });
  410. } else if (typeof errors[field] === 'string') {
  411. errorMessages.push(errors[field]);
  412. } else if (errors[field] && errors[field].message) {
  413. errorMessages.push(errors[field].message);
  414. } else {
  415. errorMessages.push(JSON.stringify(errors[field]));
  416. }
  417. }
  418. }
  419. }
  420. if (errorMessages.length > 0) {
  421. reject(`${item.supplierName}缺少必填项:${errorMessages.join(';')}`);
  422. } else {
  423. reject(`${item.supplierName} 的表单验证失败,请检查必填项`);
  424. }
  425. } else {
  426. resolve(true);
  427. }
  428. }
  429. );
  430. })
  431. );
  432. });
  433. return Promise.all([
  434. new Promise((resolve, reject) => {
  435. this.$refs.form.validate((valid, errors) => {
  436. if (!valid) {
  437. // 解析错误信息
  438. let errorMessages = [];
  439. if (errors) {
  440. console.log('Main form errors structure:', errors);
  441. for (let field in errors) {
  442. if (errors[field]) {
  443. if (Array.isArray(errors[field])) {
  444. errors[field].forEach(error => {
  445. if (typeof error === 'string') {
  446. errorMessages.push(error);
  447. } else if (error && error.message) {
  448. errorMessages.push(error.message);
  449. } else {
  450. errorMessages.push(JSON.stringify(error));
  451. }
  452. });
  453. } else if (typeof errors[field] === 'string') {
  454. errorMessages.push(errors[field]);
  455. } else if (errors[field] && errors[field].message) {
  456. errorMessages.push(errors[field].message);
  457. } else {
  458. errorMessages.push(JSON.stringify(errors[field]));
  459. }
  460. }
  461. }
  462. }
  463. if (errorMessages.length > 0) {
  464. reject(`${errorMessages.join(';')}`);
  465. } else {
  466. reject('主表单验证失败,请检查必填项');
  467. }
  468. } else {
  469. resolve(true);
  470. }
  471. });
  472. }),
  473. ...promises
  474. ]);
  475. },
  476. //计划删除
  477. delList(productCode) {
  478. this.supplierList.forEach((item) => {
  479. this.$refs['inquiryTable' + item.supplierId][0] &&
  480. this.$refs['inquiryTable' + item.supplierId][0].remove(productCode);
  481. });
  482. },
  483. removeSupplier(supplierId) {
  484. this.supplierList = this.supplierList.filter(
  485. (item) => item.supplierId != supplierId
  486. );
  487. // this.setIsInquiry()
  488. },
  489. //选择产品
  490. handParent() {
  491. this.$refs.inquiryManageRef.open(this.form.planCode);
  492. },
  493. changeInquiryManageList(data) {
  494. // this.form.planId = data.id;
  495. // this.form.planCode = data.planCode;
  496. this.getplanData(data.id, 'change');
  497. },
  498. supplierSelectAll() {
  499. if (!this.$refs.inventoryTable.selection.length)
  500. return this.$message.warning('请选择产品');
  501. this.$refs.inventoryTable.selection.forEach((item) => {
  502. this.supplierSelect(item);
  503. });
  504. },
  505. async supplierSelect(row) {
  506. console.log(row);
  507. // if (!row) {
  508. // this.$message.warning('请选择供应商');
  509. // return;
  510. // }
  511. let supplierIds = Object.keys(this.supplierProducts);
  512. const promises = [];
  513. row.supplierIds.forEach((item) => {
  514. if (!supplierIds.includes(item)) {
  515. promises.push(contactDetail(item));
  516. } else {
  517. this.productSetSupplier(this.supplierProducts[item], row);
  518. }
  519. });
  520. Promise.all(promises).then((results) => {
  521. results.forEach((data, index) => {
  522. this.supplierProducts[data.base.id] = data;
  523. this.productSetSupplier(this.supplierProducts[data.base.id], row);
  524. });
  525. });
  526. },
  527. setIsInquiry(supplierList) {
  528. this.$nextTick(() => {
  529. // this.supplierList.forEach((item) => {
  530. // supplierList.push(
  531. // this.$refs['inquiryTable' + item.supplierId][0].getTableValue()
  532. // );
  533. // });
  534. this.$refs.inventoryTable.setIsInquiry(supplierList);
  535. });
  536. },
  537. productSetSupplier(data, row) {
  538. let obj = deepClone(row);
  539. obj.supplierProductName = data.productList.find(
  540. (item) => item.productCode == row.productCode
  541. )?.productName;
  542. obj.supplierProductCode = data.productList.find(
  543. (item) => item.productCode == row.productCode
  544. )?.productCode;
  545. obj.supplierName = data.base.name;
  546. obj.reqTotalCount = obj.totalCount;
  547. let params = {
  548. ...data.base,
  549. supplierId: data.base.id,
  550. supplierName: data.base.name,
  551. supplierCode: data.base.code,
  552. files: [],
  553. preferentialPrice: '',
  554. settlementMode: '4',
  555. settlementModeName: '分期付款',
  556. taxRate: '',
  557. totalPrice: '',
  558. resultList: [obj]
  559. };
  560. let supplierIds = this.supplierList.map((item) => item.supplierId);
  561. let supplierIndex = supplierIds.indexOf(data.base.id);
  562. console.log(supplierIndex);
  563. if (supplierIndex == -1) {
  564. this.supplierList.push(params);
  565. } else {
  566. // let isHave = this.supplierList[supplierIndex].resultList.some(
  567. // (item) => item.productCode == obj.productCode
  568. // );
  569. // if (!isHave) {
  570. // putTableValue
  571. //this.supplierList[supplierIndex].resultList.push(obj)
  572. this.$set(this.supplierList[supplierIndex], 'resultList', [
  573. ...this.supplierList[supplierIndex].resultList,
  574. obj
  575. ]);
  576. this.$nextTick(() => {
  577. this.$refs['inquiryTable' + data.base.id][0]?.putTableValue(
  578. this.supplierList[supplierIndex].resultList
  579. );
  580. this.$refs['inquiryTable' + data.base.id][0]?.getSpanArr();
  581. });
  582. // }
  583. }
  584. },
  585. //供应商回调
  586. supplierManageChange(data) {
  587. let supplierIds = this.supplierList.map((item) => item.supplierId);
  588. data.forEach((item) => {
  589. item['files'] = [];
  590. item['supplierName'] = item.name;
  591. item['preferentialPrice'] = '';
  592. item['settlementMode'] = '4';
  593. item['settlementModeName'] = '分期付款';
  594. item['taxRate'] = '';
  595. item['totalPrice'] = '';
  596. item['resultList'] = copyObj(this.$refs.inventoryTable.selection);
  597. item['resultList'].forEach((val) => {
  598. item['deliveryDate'] = val.expectReceiveDate;
  599. val['remark'] = '';
  600. val.supplierName = item.name;
  601. val.supplierProductCode = val.productCode;
  602. val.supplierProductName = val.productName;
  603. val.reqTotalCount = val.totalCount;
  604. val.isWinner = 1;
  605. });
  606. let supplierIndex = supplierIds.indexOf(item.supplierId);
  607. if (supplierIndex == -1) {
  608. this.supplierList.push(item);
  609. } else {
  610. console.log(1);
  611. item['resultList'].forEach((val) => {
  612. let isHave = this.supplierList[supplierIndex].resultList.some(
  613. (i) => i.productCode == val.productCode
  614. );
  615. console.log(isHave, supplierIndex);
  616. // if (!isHave) {
  617. this.$set(this.supplierList[supplierIndex], 'resultList', [
  618. ...this.supplierList[supplierIndex].resultList,
  619. val
  620. ]);
  621. this.$refs['inquiryTable' + item.id][0]?.putTableValue(
  622. this.supplierList[supplierIndex].resultList
  623. );
  624. this.$nextTick(() => {
  625. this.$refs['inquiryTable' + item.id][0]?.getSpanArr();
  626. });
  627. // }
  628. });
  629. }
  630. });
  631. },
  632. async save(type) {
  633. try {
  634. await this.getValidate();
  635. let supplierList = [];
  636. this.supplierList.forEach((item) => {
  637. supplierList.push(
  638. this.$refs['inquiryTable' + item.supplierId][0].getTableValue()
  639. );
  640. });
  641. this.setIsInquiry(supplierList);
  642. let is = false;
  643. supplierList.forEach((item) => {
  644. item.resultList.forEach((val) => {
  645. val['technicalDrawings'] = [];
  646. if (val.minimumOrderQuantity > val.totalCount) {
  647. is = true;
  648. }
  649. });
  650. });
  651. if (is) {
  652. this.$message.warning('购买数量不能小于最低订购量!');
  653. return;
  654. }
  655. this.form.detailList = this.list;
  656. this.form.supplierList = supplierList;
  657. // let arr = this.form.supplierList.map(item => item.resultList).flat(2);
  658. // console.log(arr);
  659. // let a = _.groupBy(arr,'productName')
  660. // for (let key in a) {
  661. // console.log(key,a[key]);
  662. // if(a[key].some(item => item.isWinner ==='')) return this.$message.warning(key+'至少选择一家中标供应商')
  663. // }
  664. // console.log(a);
  665. // return
  666. // 表单验证通过,执行保存操作
  667. this.loading = true;
  668. if (this.$refs.inventoryTable.getTableValue().length == 0) {
  669. this.$message.warning('物品清单不能为空');
  670. return;
  671. }
  672. if (!this.isUpdate) {
  673. delete this.form.id;
  674. }
  675. console.log('orderSourceType~~~', orderSourceType, this.form.sourceType);
  676. this.form.supplierList.forEach((item) => {
  677. if (orderSourceType.includes(this.sourceType)) {
  678. item.resultList = [
  679. ...item.resultList,
  680. ...this.rawList,
  681. ...this.outputList
  682. ];
  683. }
  684. });
  685. let supplierIds = this.form.supplierList.map(
  686. (item) => item.supplierId
  687. );
  688. this.form.files = this.form.files || [];
  689. let API = this.isUpdate ? UpdateInformation : addPurchaseinquiry;
  690. API(this.form)
  691. .then((res) => {
  692. this.loading = false;
  693. this.$message.success('操作成功');
  694. updateRelationStatus(supplierIds);
  695. if (type === 'sub') {
  696. this.sub(res);
  697. return;
  698. }
  699. this.cancel();
  700. this.$emit('done');
  701. })
  702. .catch((e) => {
  703. //this.loading = false;
  704. });
  705. } catch (error) {
  706. console.log(error);
  707. // 表单验证未通过,显示错误提示
  708. if (typeof error === 'string') {
  709. this.$message.warning(error);
  710. } else {
  711. this.$message.warning('表单验证失败,请检查必填项');
  712. }
  713. // 表单验证未通过,不执行保存操作
  714. }
  715. },
  716. async sub(res) {
  717. let data = await getpurchaseinquiry(this.businessId || res);
  718. this.processSubmitDialogFlag = true;
  719. this.$nextTick(() => {
  720. let params = {
  721. businessId: data.id,
  722. businessKey: 'purchase_inquiry_approve',
  723. formCreateUserId: data.createUserId,
  724. variables: {
  725. businessCode: data.inquiryCode,
  726. businessName: data.inquiryName,
  727. businessType: '采购核价'
  728. }
  729. // callBackMethodType : '1',
  730. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  731. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  732. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  733. // miniHandle : '',
  734. // miniView : '',
  735. };
  736. this.$refs.processSubmitDialogRef.init(params);
  737. });
  738. // submit({
  739. // businessId: this.businessId || res
  740. // }).then((res) => {
  741. // this.cancel();
  742. // this.$emit('done');
  743. // });
  744. },
  745. reload() {
  746. this.cancel();
  747. this.$emit('done');
  748. },
  749. downloadFile(file) {
  750. getFile({ objectName: file.storePath }, file.name);
  751. },
  752. cancel() {
  753. reloadPageTab({ fullPath: '/inquiryManage' });
  754. removePageTab({
  755. key: '/purchasingManage/inquiryManage/components/addDialog'
  756. });
  757. }
  758. }
  759. };
  760. </script>
  761. <style scoped lang="scss">
  762. .TotalAmount {
  763. font-size: 16px;
  764. padding-right: 30px;
  765. }
  766. </style>