addDialog.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  4. <headerTitle title="订单信息"></headerTitle>
  5. <el-row>
  6. <el-col :span="12">
  7. <el-form-item
  8. label="项目名称"
  9. prop="projectName"
  10. style="margin-bottom: 22px"
  11. >
  12. <el-input
  13. clearable
  14. v-model="form.projectName"
  15. placeholder="请输入"
  16. />
  17. </el-form-item>
  18. <el-form-item label="采购计划单名称" prop="planCode">
  19. <el-input
  20. @click.native="handPurchasePlan"
  21. v-model="form.purchasePlanName"
  22. placeholder="请选择"
  23. ></el-input>
  24. </el-form-item>
  25. <el-form-item
  26. label="订单类型"
  27. prop="sourceType"
  28. style="margin-bottom: 22px"
  29. >
  30. <DictSelection
  31. dictName="需求来源类型"
  32. clearable
  33. v-model="form.sourceType"
  34. :disabled="isFlag"
  35. >
  36. <!-- v-if="form.sourceType != 1" -->
  37. </DictSelection>
  38. </el-form-item>
  39. <el-form-item
  40. label="需求部门"
  41. prop="requireDeptId"
  42. style="margin-bottom: 22px"
  43. >
  44. <ele-tree-select
  45. clearable
  46. :data="groupTreeData"
  47. v-model="form.requireDeptId"
  48. valueKey="id"
  49. labelKey="name"
  50. placeholder="请选择"
  51. @change="change_principalDep"
  52. default-expand-all
  53. />
  54. </el-form-item>
  55. <!-- <el-form-item
  56. label="计价方式"
  57. prop="pricingWay"
  58. style="margin-bottom: 22px"
  59. >
  60. <el-radio-group
  61. v-model="form.pricingWay"
  62. @change="changePricingWay"
  63. :disabled="!!form.contractId"
  64. >
  65. <el-radio v-for="item in pricingWayList" :label="item.id">{{
  66. item.name
  67. }}</el-radio>
  68. </el-radio-group>
  69. </el-form-item> -->
  70. </el-col>
  71. <el-col :span="12">
  72. <el-form-item
  73. label="选择合同"
  74. prop="contractName"
  75. style="margin-bottom: 22px"
  76. >
  77. <el-input
  78. clearable
  79. v-model="form.contractName"
  80. @click.native="handleContractBtn"
  81. @clear="clearContrcat"
  82. placeholder="请输入"
  83. />
  84. </el-form-item>
  85. <el-form-item label="结算方式" prop="settlementMode">
  86. <DictSelection
  87. dictName="结算方式"
  88. clearable
  89. @itemChange="settlementModeChange"
  90. v-model="form.settlementMode"
  91. >
  92. </DictSelection>
  93. </el-form-item>
  94. <el-form-item label="需求人" prop="requireUserId">
  95. <personSelect
  96. ref="directorRef"
  97. v-model="form.requireUserId"
  98. @selfChange="salesmanChange"
  99. :init="false"
  100. />
  101. </el-form-item>
  102. <el-form-item prop="orderFiles" label="附件">
  103. <fileMain v-model="form.orderFiles"></fileMain>
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. <headerTitle title="基本信息"></headerTitle>
  108. <el-row>
  109. <el-col :span="12">
  110. <el-form-item
  111. label="采购方名称"
  112. prop="partaName"
  113. style="margin-bottom: 22px"
  114. >
  115. <el-input clearable v-model="form.partaName" placeholder="请输入" />
  116. </el-form-item>
  117. <el-form-item
  118. label="采购方统一社会信用代码"
  119. prop="partaUnifiedSocialCreditCode"
  120. label-width="180px"
  121. style="margin-bottom: 22px"
  122. >
  123. <el-input
  124. clearable
  125. v-model="form.partaUnifiedSocialCreditCode"
  126. placeholder="请输入"
  127. />
  128. </el-form-item>
  129. <el-form-item
  130. label="采购方联系人"
  131. prop="partaLinkName"
  132. style="margin-bottom: 22px"
  133. >
  134. <el-input
  135. clearable
  136. v-model="form.partaLinkName"
  137. @click.native="handHead"
  138. placeholder="请输入"
  139. />
  140. </el-form-item>
  141. <el-form-item
  142. label="采购方电话"
  143. prop="partaTel"
  144. style="margin-bottom: 22px"
  145. >
  146. <el-input
  147. clearable
  148. :maxlength="20"
  149. v-model="form.partaTel"
  150. placeholder="请输入"
  151. />
  152. </el-form-item>
  153. <el-form-item
  154. label="采购方传真"
  155. prop="partaFax"
  156. style="margin-bottom: 22px"
  157. >
  158. <el-input clearable v-model="form.partaFax" placeholder="请输入" />
  159. </el-form-item>
  160. <el-form-item
  161. label=" 采购方Email"
  162. prop="partaEmail"
  163. style="margin-bottom: 22px"
  164. >
  165. <el-input
  166. clearable
  167. v-model="form.partaEmail"
  168. placeholder="请输入"
  169. />
  170. </el-form-item>
  171. <el-form-item
  172. label="采购方地址"
  173. prop="partaAddress"
  174. style="margin-bottom: 22px"
  175. >
  176. <el-input
  177. clearable
  178. v-model="form.partaAddress"
  179. placeholder="请输入"
  180. />
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="12">
  184. <el-form-item
  185. label="供应商名称"
  186. prop="partbName"
  187. style="margin-bottom: 22px"
  188. >
  189. <el-input
  190. clearable
  191. v-model="form.partbName"
  192. @click.native="handParent"
  193. :disabled="!!form.contractId"
  194. placeholder="请选择"
  195. />
  196. </el-form-item>
  197. <el-form-item
  198. label="供应商统一社会信用代码"
  199. prop="partbUnifiedSocialCreditCode"
  200. label-width="170px"
  201. style="margin-bottom: 22px"
  202. >
  203. <el-input
  204. clearable
  205. v-model="form.partbUnifiedSocialCreditCode"
  206. placeholder="请输入"
  207. />
  208. </el-form-item>
  209. <el-form-item
  210. label="供应商联系人"
  211. prop="partbLinkName"
  212. style="margin-bottom: 22px"
  213. >
  214. <el-select
  215. v-model="form.partbLinkName"
  216. placeholder="请选择"
  217. @change="onchangeLink"
  218. @focus="selectFocus"
  219. >
  220. <el-option
  221. v-for="item in linkNameOptions"
  222. :key="item.id"
  223. :label="item.linkName"
  224. :value="item.id"
  225. >
  226. </el-option>
  227. </el-select>
  228. </el-form-item>
  229. <el-form-item prop="partbTel" label="供应商联系电话">
  230. <el-input clearable v-model="form.partbTel" placeholder="请输入" />
  231. </el-form-item>
  232. <el-form-item prop="partbFax" label="供应商传真">
  233. <el-input clearable v-model="form.partbFax" placeholder="请输入" />
  234. </el-form-item>
  235. <el-form-item
  236. label="供应商Email"
  237. prop="partbEmail"
  238. style="margin-bottom: 22px"
  239. >
  240. <el-input
  241. clearable
  242. v-model="form.partbEmail"
  243. placeholder="请输入"
  244. />
  245. </el-form-item>
  246. <el-form-item
  247. label="供应商地址"
  248. prop="partbAddress"
  249. style="margin-bottom: 22px"
  250. >
  251. <el-input
  252. clearable
  253. v-model="form.partbAddress"
  254. placeholder="请输入"
  255. />
  256. </el-form-item>
  257. </el-col>
  258. </el-row>
  259. <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
  260. <el-tab-pane label="物品清单" name="1">
  261. <inventoryTable
  262. ref="inventoryTable"
  263. @orderDiscountAmount="orderDiscountAmount"
  264. :pricingWay="form.pricingWay"
  265. :is-show-supplier-mark="true"
  266. :isContractId="!!form.contractId"
  267. >
  268. </inventoryTable>
  269. </el-tab-pane>
  270. <el-tab-pane
  271. label="带料清单"
  272. name="2"
  273. v-if="orderSourceType.includes(form.sourceType)"
  274. >
  275. <inventoryTable
  276. ref="rawDetailListRef"
  277. :pricingWay="form.pricingWay"
  278. :is-show-supplier-mark="true"
  279. :isContractId="!!form.contractId"
  280. :detailType="1"
  281. >
  282. </inventoryTable>
  283. </el-tab-pane>
  284. <el-tab-pane
  285. label="产出清单"
  286. name="2"
  287. v-if="orderSourceType.includes(form.sourceType)"
  288. >
  289. <inventoryTable
  290. ref="outputDetailListRef"
  291. :pricingWay="form.pricingWay"
  292. :is-show-supplier-mark="true"
  293. :isContractId="!!form.contractId"
  294. :detailType="2"
  295. >
  296. </inventoryTable>
  297. </el-tab-pane>
  298. </el-tabs>
  299. <el-row style="margin-top: 20px">
  300. <el-col :span="12">
  301. <el-form-item
  302. label="优惠总金额"
  303. prop="payAmount"
  304. style="margin-bottom: 22px"
  305. >
  306. <el-input
  307. clearable
  308. v-model="form.payAmount"
  309. :disabled="!!form.contractId || !allcountAmount"
  310. type="number"
  311. @blur="discountInput"
  312. placeholder="请输入"
  313. >
  314. <template slot="append">元</template>
  315. </el-input>
  316. </el-form-item>
  317. <el-form-item label="备注" prop="remark" style="margin-bottom: 22px">
  318. <el-input
  319. clearable
  320. type="textarea"
  321. v-model="form.remark"
  322. placeholder="请输入"
  323. />
  324. </el-form-item>
  325. <!-- <el-form-item
  326. label="收货地址"
  327. prop="receiveAddress"
  328. style="margin-bottom: 22px"
  329. >
  330. <el-input
  331. clearable
  332. type="textarea"
  333. v-model="form.receiveAddress"
  334. placeholder="请输入"
  335. />
  336. </el-form-item> -->
  337. </el-col>
  338. <el-col :span="12">
  339. <el-form-item
  340. label="总金额"
  341. prop="totalAmount"
  342. style="margin-bottom: 22px"
  343. >
  344. {{ allcountAmount || 0 }}元
  345. </el-form-item>
  346. </el-col>
  347. </el-row>
  348. </el-form>
  349. <parentList ref="parentRef" @changeParent="changeParent"></parentList>
  350. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  351. <contractListDialog
  352. ref="selectContractRef"
  353. @changeParent="changeContract"
  354. :type="2"
  355. ></contractListDialog>
  356. <inquiryManageList
  357. ref="inquiryManageRef"
  358. @changeInquiryManageList="changeInquiryManageList"
  359. ></inquiryManageList>
  360. </div>
  361. </template>
  362. <script>
  363. import { emailReg, numberReg } from 'ele-admin';
  364. import inventoryTable from './inventoryTable.vue';
  365. import fileUpload from '@/components/upload/fileUpload';
  366. import dictMixins from '@/mixins/dictMixins';
  367. import personSelect from '@/components/CommomSelect/person-select.vue';
  368. import parentList from '@/views/bpm/handleTask/components/quotation/parentList.vue';
  369. import { getDetail } from '@/api/bpm/components/contractManage/contractBook';
  370. import headList from '@/components/headList';
  371. import { getpurchaseorderDetail } from '@/api/bpm/components/purchasingManage/purchaseOrder';
  372. import { getcontactlink } from '@/api/bpm/components/saleManage/businessOpportunity.js';
  373. import contractListDialog from '@/views/bpm/handleTask/components/saleOrder/contractListDialog.vue';
  374. import { listOrganizations } from '@/api/system/organization';
  375. import { copyObj } from '@/utils/util';
  376. import { getpurchaseinquiry } from '@/api/bpm/components/purchasingManage/inquiryManage';
  377. import InquiryManageList from '@/views/bpm/handleTask/components/inquiryManage/inquiryManage-list.vue';
  378. import {
  379. getplanDetail,
  380. getPurchasePlanByContractIdAPI
  381. } from '@/api/bpm/components/purchasingManage/purchasePlanManage';
  382. import fileMain from '@/components/addDoc/index.vue';
  383. import { orderSourceType, outsourceSceneList } from '@/enum/dict';
  384. export default {
  385. mixins: [dictMixins],
  386. components: {
  387. fileMain,
  388. InquiryManageList,
  389. fileUpload,
  390. contractListDialog,
  391. inventoryTable,
  392. parentList,
  393. personSelect,
  394. headList
  395. },
  396. props: {
  397. businessId: {
  398. default: ''
  399. }
  400. },
  401. data() {
  402. let formDef = {
  403. id: '',
  404. contractId: '',
  405. orderFiles: [],
  406. contractName: '',
  407. deliveryDate: '',
  408. payAmount: '',
  409. projectName: '',
  410. projectId: '',
  411. receiveAddress: '',
  412. sourceType: '',
  413. sourceTypeName: '',
  414. pricingWay: 1,
  415. remark: '',
  416. saleType: '',
  417. saleTypeName: '',
  418. totalAmount: '',
  419. settlementMode: '',
  420. settlementModeName: '',
  421. partaUnifiedSocialCreditCode: '',
  422. partbUnifiedSocialCreditCode: '',
  423. partaAddress: '',
  424. partaEmail: '',
  425. partaFax: '',
  426. partaId: '',
  427. partaLinkId: '',
  428. partaLinkName: '',
  429. partaName: '',
  430. partaTel: '',
  431. partbAddress: '',
  432. partbEmail: '',
  433. partbFax: '',
  434. partbId: '',
  435. partbLinkId: '',
  436. partbLinkName: '',
  437. partbName: '',
  438. partbTel: '',
  439. purchasePlanId: '',
  440. purchasePlanNo: '',
  441. purchasePlanName: ''
  442. };
  443. return {
  444. orderSourceType,
  445. outsourceSceneList,
  446. clearing: false, //是否清除合同
  447. isFlag: false, //需求类型是否可以修改
  448. payWayOptions: [],
  449. delDetailIds: [],
  450. linkNameOptions: [],
  451. visible: false,
  452. title: '',
  453. row: {},
  454. activeName: 'base',
  455. pricingWayList: [
  456. { id: 1, name: '按数量计价' },
  457. { id: 2, name: '按重量计价' }
  458. ],
  459. formDef,
  460. form: copyObj(formDef),
  461. tableBankData: [],
  462. tableLinkData: [],
  463. // 组织机构树形结构数据
  464. groupTreeData: [],
  465. groupData: [],
  466. rules: {
  467. deliveryDate: [
  468. { required: true, message: '请选择交货日期', trigger: 'change' }
  469. ],
  470. // purchaseType: [
  471. // {required: true, message: '请选择采购订单类型', trigger: 'change'}
  472. // ],
  473. settlementMode: [
  474. { required: true, message: '请选择结算方式', trigger: 'change' }
  475. ],
  476. partaName: [
  477. { required: true, message: '请选择供应商名称', trigger: 'change' }
  478. ],
  479. partaLinkName: [
  480. { required: true, message: '请选择供应商联系人', trigger: 'change' }
  481. ],
  482. acceptUnpack: [
  483. { required: true, message: '请选择是否接受', trigger: 'change' }
  484. ],
  485. sourceType: [
  486. { required: true, message: '请选择需求类型', trigger: 'change' }
  487. ],
  488. partaTel: [
  489. {
  490. required: true,
  491. pattern: numberReg,
  492. message: '请输入供应商联系电话',
  493. trigger: 'blur'
  494. }
  495. ],
  496. partbName: [
  497. { required: true, message: '请输入供采购方名称', trigger: 'change' }
  498. ],
  499. partbLinkName: [
  500. {
  501. required: true,
  502. message: '请输入供采购方联系人',
  503. trigger: 'change'
  504. }
  505. ],
  506. partbTel: [
  507. {
  508. required: true,
  509. pattern: numberReg,
  510. message: '请输入供采购方联系电话',
  511. trigger: 'blur'
  512. }
  513. ],
  514. partaEmail: [
  515. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  516. ]
  517. },
  518. // 提交状态
  519. loading: false,
  520. // 是否是修改
  521. isUpdate: false
  522. };
  523. },
  524. computed: {
  525. allcountAmount() {
  526. return this.$store.state.order.allcountAmount;
  527. }
  528. },
  529. created() {
  530. this.getpurchaseorderDetail(this.businessId);
  531. this.getGroupAll();
  532. },
  533. methods: {
  534. // 选择负责人部门
  535. change_principalDep(id) {
  536. const info = this.groupData.find((e) => e.id == id);
  537. this.form.requireDeptName = info.name;
  538. // this.form.requireUserId = '';
  539. // this.form.requireUserName = '';
  540. this.$set(this.form, 'requireUserId', '');
  541. this.$set(this.form, 'requireUserName', '');
  542. // 根据部门获取人员
  543. this.getrequireUser(id);
  544. },
  545. //切换计价方式重新算费用
  546. changePricingWay() {
  547. this.$refs.inventoryTable.getTotalPrice();
  548. },
  549. //选择采购计划
  550. handPurchasePlan() {
  551. this.$refs.inquiryManageRef.open(this.form.planCode);
  552. },
  553. //选择采购计划回调
  554. async changeInquiryManageList(data) {
  555. this.form.purchasePlanId = data.id;
  556. this.form.purchasePlanNo = data.planCode;
  557. this.form.purchasePlanName = data.planName;
  558. let info = await getplanDetail(data.id);
  559. let cusInfo = {};
  560. this.$set(this.form, 'purchasePlanName', data.planName);
  561. this.$set(this.form, 'purchasePlanId', data.id);
  562. this.$set(this.form, 'purchasePlanNo', data.planCode);
  563. let form = {
  564. contractVO: {
  565. ...this.form
  566. },
  567. productList: info.detailList || []
  568. };
  569. this.$refs.inventoryTable &&
  570. this.$refs.inventoryTable.putTableValue(form.productList);
  571. await this.getLinkInfo(cusInfo.base.id);
  572. },
  573. // //选择需求来源类型
  574. // chaengSource(data) {
  575. // this.form.sourceType = data?.dictValue;
  576. // },
  577. getrequireUser(groupId) {
  578. if (groupId) {
  579. this.$refs.directorRef.getList({ groupId });
  580. }
  581. },
  582. salesmanChange(val, info) {
  583. this.$set(this.form, 'requireUserId', val);
  584. this.$set(this.form, 'requireUserName', info.name);
  585. // this.form.requireUserName = info.name;
  586. },
  587. // 获取公司数据
  588. getGroupAll() {
  589. listOrganizations().then((list) => {
  590. this.groupData = list;
  591. this.groupTreeData = this.$util.toTreeData({
  592. data: list,
  593. idField: 'id',
  594. parentIdField: 'parentId'
  595. });
  596. });
  597. },
  598. discountInput() {
  599. this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
  600. },
  601. //产品清单修改单价或者数量重置优惠金额
  602. orderDiscountAmount(val = 0) {
  603. this.form.payAmount = val;
  604. },
  605. //选择供应商
  606. changeSupplier(obj) {
  607. this.form = Object.assign({}, this.form, {
  608. partbId: obj.id,
  609. partbName: obj.name,
  610. partbAddress: obj.addressName + obj.address,
  611. partbLinkId: '',
  612. partbLinkName: '',
  613. partbEmail: '',
  614. partbTel: ''
  615. });
  616. this.getLinkInfo(obj.id);
  617. },
  618. //选择合同获取合同的详情
  619. async getDetailData(id) {
  620. this.loading = true;
  621. const data = await getDetail(id);
  622. this.loading = false;
  623. if (data) {
  624. this.$nextTick(() => {
  625. let { contractVO } = data;
  626. // this.form=contractVOform.receiveAddress
  627. let {
  628. partaAddress,
  629. partaEmail,
  630. partaFax,
  631. partaId,
  632. partaLinkId,
  633. partaLinkName,
  634. partaName,
  635. partaTel,
  636. partbAddress,
  637. partbEmail,
  638. partbFax,
  639. partbId,
  640. partbLinkId,
  641. partbLinkName,
  642. partbName,
  643. partbTel,
  644. totalPrice,
  645. discountTotalPrice,
  646. partaUnifiedSocialCreditCode,
  647. partbUnifiedSocialCreditCode,
  648. settlementMode,
  649. settlementModeName,
  650. pricingWay
  651. } = contractVO;
  652. this.form = Object.assign({}, this.form, {
  653. partaAddress,
  654. partaEmail,
  655. partaFax,
  656. partaId,
  657. partaLinkId,
  658. partaLinkName,
  659. partaName,
  660. partaTel,
  661. partbAddress,
  662. partbEmail,
  663. partbFax,
  664. partbId,
  665. partbLinkId,
  666. partbLinkName,
  667. partbName,
  668. partbTel,
  669. totalPrice,
  670. discountTotalPrice,
  671. partaUnifiedSocialCreditCode,
  672. partbUnifiedSocialCreditCode,
  673. pricingWay,
  674. totalAmount: totalPrice,
  675. payAmount: discountTotalPrice,
  676. receiveAddress: partaAddress,
  677. settlementMode,
  678. settlementModeName
  679. });
  680. this.getLinkInfo(partaId);
  681. this.$refs.inventoryTable &&
  682. this.$refs.inventoryTable.putTableValue(
  683. data.productList,
  684. contractVO.contractStartDate
  685. );
  686. this.$store.commit('order/setAllcountAmount', totalPrice);
  687. });
  688. }
  689. },
  690. //获取订单详情
  691. async getpurchaseorderDetail(id) {
  692. this.loading = true;
  693. const data = await getpurchaseorderDetail(id);
  694. this.loading = false;
  695. if (data) {
  696. this.$nextTick(() => {
  697. this.form = data;
  698. this.$refs.inventoryTable &&
  699. this.$refs.inventoryTable.putTableValue(data.productList);
  700. this.$refs.rawDetailListRef &&
  701. this.$refs.rawDetailListRef.putTableValue(data.rawDetailList); //原料
  702. this.$refs.outputDetailListRef &&
  703. this.$refs.outputDetailListRef.putTableValue(
  704. data.outputDetailList
  705. ); //产成品
  706. this.getLinkInfo(data.partaId);
  707. this.getrequireUser(this.form.requireDeptId);
  708. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  709. this.$store.commit('order/setContractId', data.contractId);
  710. });
  711. }
  712. },
  713. //更新联系人数据
  714. async getLinkInfo(contactId) {
  715. const data = await getcontactlink({ contactId });
  716. if (data && data?.length) {
  717. this.linkNameOptions = data;
  718. }
  719. },
  720. selectFocus() {
  721. if (this.linkNameOptions.length === 0) {
  722. return this.$message.error('请先选择名称');
  723. }
  724. },
  725. //选择下拉框
  726. onchangeLink(selectedOptions) {
  727. const option = this.linkNameOptions.find(
  728. (opt) => opt.id === selectedOptions
  729. );
  730. this.form = Object.assign({}, this.form, {
  731. partbEmail: option?.email,
  732. partbLinkName: option?.linkName || '',
  733. partbTel: option?.mobilePhone || option?.phone || '',
  734. partbLinkId: option?.id
  735. });
  736. },
  737. handHead() {
  738. let item = {
  739. id: this.form.partaLinkId
  740. };
  741. this.$refs.headRef.open(item);
  742. },
  743. //选择供采购方人回调
  744. changePersonel(obj) {
  745. this.$set(this.form, 'partaLinkId', obj.id);
  746. this.$set(this.form, 'partaLinkName', obj.name);
  747. this.$set(this.form, 'partaTel', obj.phone);
  748. this.$set(this.form, 'partaEmail', obj.email);
  749. },
  750. //选择供应商回调
  751. changeParent(obj) {
  752. this.form = Object.assign({}, this.form, {
  753. partbId: obj.id,
  754. partbName: obj.name,
  755. partbAddress: obj.addressName + obj.address,
  756. partbLinkId: '',
  757. partbLinkName: '',
  758. partbEmail: '',
  759. partbTel: ''
  760. });
  761. this.getLinkInfo(obj.id);
  762. },
  763. //选择合同回调
  764. changeContract(obj) {
  765. this.form = Object.assign({}, this.form, {
  766. contractId: obj.id,
  767. contractName: obj.contractName,
  768. contractNo: obj.contractNo
  769. });
  770. this.getDetailData(obj.id);
  771. // //采购询价表
  772. // this.getPurchaseinquiry(obj.sourceId);
  773. //获取合同采购计划
  774. this.getPlanInfo(this.form.contractId);
  775. this.$store.commit('order/setContractId', obj.id);
  776. },
  777. async getPlanInfo(id) {
  778. let res = await getPurchasePlanByContractIdAPI(id);
  779. this.form = Object.assign({}, this.form, {
  780. purchasePlanId: res.data?.id,
  781. purchasePlanName: res.data?.planName,
  782. purchasePlanNo: res.data?.planCode,
  783. sourceType: res.data?.sourceType,
  784. sourceTypeName: res.data?.sourceTypeName
  785. });
  786. },
  787. //选择合同弹框
  788. handleContractBtn() {
  789. if (this.clearing) return;
  790. let item = {
  791. id: this.form.contractId
  792. };
  793. this.$refs.selectContractRef.open(item);
  794. },
  795. //清除合同
  796. clearContrcat() {
  797. this.clearing = true;
  798. this.isFlag = false;
  799. let {
  800. id,
  801. projectName,
  802. saleType,
  803. saleTypeName,
  804. deliveryDate,
  805. orderFiles,
  806. remark
  807. } = this.form;
  808. this.form = Object.assign({}, copyObj(this.formDef), {
  809. id,
  810. projectName,
  811. saleType,
  812. saleTypeName,
  813. deliveryDate,
  814. orderFiles,
  815. remark
  816. });
  817. this.$store.commit('order/setContractId', '');
  818. this.$store.commit('order/setAllcountAmount', 0);
  819. this.$refs.inventoryTable.putTableValue([]);
  820. setTimeout(() => {
  821. this.clearing = false;
  822. }, 500);
  823. },
  824. handParent() {
  825. if (this.form.contractId) {
  826. return this.$message.error('选择了合同不能更改供应商名称');
  827. }
  828. let item = {
  829. id: this.form.contactId
  830. };
  831. this.$refs.parentRef.open(item);
  832. },
  833. settlementModeChange(info) {
  834. this.form.settlementModeName = info.dictValue;
  835. },
  836. ifChiefChange(value, idx) {
  837. if (value === 1) {
  838. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  839. this.tableLinkData[idx].ifChief = 1;
  840. }
  841. },
  842. getValidate() {
  843. return Promise.all([
  844. new Promise((resolve, reject) => {
  845. this.$refs.form.validate((valid) => {
  846. if (!valid) {
  847. reject(false);
  848. } else {
  849. resolve(true);
  850. }
  851. });
  852. }),
  853. new Promise((resolve, reject) => {
  854. this.$refs.inventoryTable.validateForm((valid) => {
  855. if (!valid) {
  856. reject(false);
  857. } else {
  858. resolve(true);
  859. }
  860. });
  861. })
  862. ]);
  863. },
  864. async getTableValue() {
  865. try {
  866. await this.getValidate();
  867. // 表单验证通过,执行保存操作
  868. this.loading = true;
  869. if (!this.form.contractId) {
  870. this.form.totalAmount = this.allcountAmount;
  871. }
  872. const rawDetailList =
  873. (this.$refs.rawDetailListRef &&
  874. this.$refs.rawDetailListRef.getTableValue()) ||
  875. [];
  876. const outputDetailList =
  877. (this.$refs.outputDetailListRef &&
  878. this.$refs.outputDetailListRef.getTableValue()) ||
  879. [];
  880. let commitData = Object.assign({}, this.form, {
  881. productList: [
  882. ...this.$refs.inventoryTable.getTableValue(),
  883. ...rawDetailList,
  884. ...outputDetailList
  885. ],
  886. // purchaseTypeName: this.getDictValue(
  887. // '采购订单类型',
  888. // this.form.purchaseType
  889. // ),
  890. sourceTypeName: this.getDictValue(
  891. '需求来源类型',
  892. this.form.sourceType
  893. )
  894. });
  895. return commitData;
  896. } catch (error) {
  897. console.log(error);
  898. // 表单验证未通过,不执行保存操作
  899. }
  900. },
  901. //查找合同分类对应name
  902. findNameById(tree, targetId) {
  903. for (let i = 0; i < tree.length; i++) {
  904. const node = tree[i];
  905. if (node.id === targetId) {
  906. return node.name;
  907. }
  908. if (node.children && node.children.length > 0) {
  909. const name = this.findNameById(node.children, targetId);
  910. if (name) {
  911. return name;
  912. }
  913. }
  914. }
  915. return null;
  916. }
  917. }
  918. };
  919. </script>
  920. <style scoped lang="scss">
  921. .TotalAmount {
  922. font-size: 16px;
  923. padding-right: 30px;
  924. }
  925. </style>