addDialog.vue 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. v-if="visible"
  6. :visible.sync="visible"
  7. :title="title"
  8. :close-on-click-modal="false"
  9. width="70%"
  10. @close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <el-form
  15. ref="form"
  16. :model="form"
  17. :rules="rules"
  18. class="el-form-box"
  19. label-width="120px"
  20. >
  21. <headerTitle title="订单信息"></headerTitle>
  22. <el-row>
  23. <el-col :span="12">
  24. <el-form-item label="订单类型" prop="sourceType">
  25. <el-select
  26. v-model="form.sourceType"
  27. placeholder="请选择"
  28. style="width: 100%"
  29. @change="sourceTypeChange"
  30. :disabled="isFlag"
  31. clearable
  32. >
  33. <el-option
  34. v-for="item in requirementSourceType"
  35. :key="item.value"
  36. :label="item.label"
  37. :value="item.value"
  38. >
  39. </el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="来源类型" prop="relationType">
  43. <el-select
  44. v-model="form.relationType"
  45. filterable
  46. clearable
  47. style="width: 100%"
  48. @change="handleChangeRelationType"
  49. >
  50. <el-option :value="1" label="采购需求单"></el-option>
  51. <el-option :value="2" label="采购计划单"></el-option>
  52. <el-option :value="3" label="采购核价单"></el-option>
  53. <el-option :value="4" label="采购合同"></el-option>
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item
  57. prop="outsourceScene"
  58. label="委外场景"
  59. v-if="
  60. orderSourceType.includes(form.sourceType) && form.outsourceScene
  61. "
  62. >
  63. <el-select
  64. v-model="form.outsourceScene"
  65. disabled
  66. style="width: 100%"
  67. >
  68. <el-option
  69. :value="item.value"
  70. :label="item.label"
  71. v-for="item in outsourceSceneList"
  72. :key="item.value"
  73. >
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item
  78. v-if="form.relationType == 1"
  79. label="采购需求单"
  80. prop="relationName"
  81. >
  82. <el-input
  83. @click.native="handPurchaseNeed"
  84. v-model="form.relationName"
  85. placeholder="请选择"
  86. ></el-input>
  87. </el-form-item>
  88. <el-form-item
  89. v-if="form.relationType == 2"
  90. label="采购计划单"
  91. prop="relationName"
  92. >
  93. <el-input
  94. @click.native="handPurchasePlan"
  95. v-model="form.relationName"
  96. placeholder="请选择"
  97. ></el-input>
  98. </el-form-item>
  99. <el-form-item
  100. v-if="form.relationType == 3"
  101. label="采购核价单"
  102. prop="relationName"
  103. >
  104. <el-input
  105. @click.native="handInquiry"
  106. v-model="form.relationName"
  107. placeholder="请选择"
  108. ></el-input>
  109. </el-form-item>
  110. <el-form-item
  111. v-if="form.relationType == 4"
  112. label="选择合同"
  113. prop="contractName"
  114. >
  115. <el-input
  116. clearable
  117. v-model="form.contractName"
  118. @click.native="handleContractBtn"
  119. @clear="clearContrcat"
  120. placeholder="请输入"
  121. />
  122. </el-form-item>
  123. <el-form-item label="需求部门" prop="requireDeptId">
  124. <ele-tree-select
  125. clearable
  126. :data="groupTreeData"
  127. v-model="form.requireDeptId"
  128. valueKey="id"
  129. labelKey="name"
  130. placeholder="请选择"
  131. @change="change_principalDep"
  132. default-expand-all
  133. />
  134. </el-form-item>
  135. <el-form-item prop="orderFiles" label="附件">
  136. <fileMain v-model="form.orderFiles"></fileMain>
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="12">
  140. <el-form-item label="项目名称" prop="projectName">
  141. <el-input
  142. clearable
  143. v-model="form.projectName"
  144. placeholder="请输入"
  145. />
  146. </el-form-item>
  147. <el-form-item label="结算方式" prop="settlementMode">
  148. <DictSelection
  149. dictName="结算方式"
  150. clearable
  151. @itemChange="settlementModeChange"
  152. v-model="form.settlementMode"
  153. >
  154. </DictSelection>
  155. </el-form-item>
  156. <el-form-item label="需求人" prop="requireUserId">
  157. <personSelect
  158. ref="directorRef"
  159. v-model="form.requireUserId"
  160. @selfChange="salesmanChange"
  161. :init="false"
  162. />
  163. </el-form-item>
  164. </el-col>
  165. </el-row>
  166. <headerTitle title="基本信息"></headerTitle>
  167. <el-row>
  168. <el-col :span="12">
  169. <el-form-item label="采购方名称" prop="partaName">
  170. <el-select
  171. style="width: 100%"
  172. v-model="form.partaName"
  173. placeholder="请选择"
  174. @change="getEnterprise()"
  175. >
  176. <el-option
  177. v-for="item in enterprisePage"
  178. :key="item.id"
  179. :label="item.name"
  180. :value="item.name"
  181. >
  182. </el-option>
  183. </el-select>
  184. </el-form-item>
  185. <el-form-item
  186. label="采购方统一社会信用代码"
  187. class="form_item_label"
  188. prop="partaUnifiedSocialCreditCode"
  189. >
  190. <el-input
  191. clearable
  192. v-model="form.partaUnifiedSocialCreditCode"
  193. placeholder="请输入"
  194. />
  195. </el-form-item>
  196. <el-form-item label="采购方联系人" prop="partaLinkName">
  197. <el-input
  198. clearable
  199. v-model="form.partaLinkName"
  200. @click.native="handHead"
  201. placeholder="请输入"
  202. />
  203. </el-form-item>
  204. <el-form-item label="采购方电话" prop="partaTel">
  205. <el-input
  206. clearable
  207. :maxlength="20"
  208. v-model="form.partaTel"
  209. placeholder="请输入"
  210. />
  211. </el-form-item>
  212. <el-form-item label="采购方传真" prop="partaFax">
  213. <el-input clearable v-model="form.partaFax" placeholder="请输入" />
  214. </el-form-item>
  215. <el-form-item label=" 采购方Email" prop="partaEmail">
  216. <el-input
  217. clearable
  218. v-model="form.partaEmail"
  219. placeholder="请输入"
  220. />
  221. </el-form-item>
  222. <el-form-item label="采购方地址" prop="partaAddress">
  223. <el-input
  224. clearable
  225. v-model="form.partaAddress"
  226. placeholder="请输入"
  227. />
  228. </el-form-item>
  229. </el-col>
  230. <el-col :span="12">
  231. <el-form-item label="供应商名称" prop="partbName">
  232. <el-row>
  233. <el-col :span="form.partbName ? 19 : 24">
  234. <el-input
  235. clearable
  236. v-model="form.partbName"
  237. @click.native="handParent"
  238. :disabled="!!form.contractId"
  239. placeholder="请选择"
  240. >
  241. </el-input>
  242. </el-col>
  243. <el-col :span="5">
  244. <el-button
  245. v-if="form.partbName"
  246. style="color: #fff; background: #1890ff"
  247. @click.native="handleGoodsList"
  248. >供货列表
  249. </el-button>
  250. </el-col>
  251. </el-row>
  252. </el-form-item>
  253. <el-form-item
  254. label="供应商统一社会信用代码"
  255. prop="partbUnifiedSocialCreditCode"
  256. class="form_item_label"
  257. >
  258. <el-input
  259. clearable
  260. v-model="form.partbUnifiedSocialCreditCode"
  261. placeholder="请输入"
  262. />
  263. </el-form-item>
  264. <el-form-item label="供应商联系人" prop="partbLinkName">
  265. <el-select
  266. style="width: 100%"
  267. v-model="form.partbLinkName"
  268. placeholder="请选择"
  269. @change="onchangeLink"
  270. >
  271. <el-option
  272. v-for="item in linkNameOptions"
  273. :key="item.id"
  274. :label="item.linkName"
  275. :value="item.id"
  276. >
  277. </el-option>
  278. </el-select>
  279. </el-form-item>
  280. <el-form-item prop="partbTel" label="供应商联系电话">
  281. <el-input clearable v-model="form.partbTel" placeholder="请输入" />
  282. </el-form-item>
  283. <el-form-item prop="partbFax" label="供应商传真">
  284. <el-input clearable v-model="form.partbFax" placeholder="请输入" />
  285. </el-form-item>
  286. <el-form-item label="供应商Email" prop="partbEmail">
  287. <el-input
  288. clearable
  289. v-model="form.partbEmail"
  290. placeholder="请输入"
  291. />
  292. </el-form-item>
  293. <el-form-item label="供应商地址" prop="partbAddress">
  294. <el-input
  295. clearable
  296. v-model="form.partbAddress"
  297. placeholder="请输入"
  298. />
  299. </el-form-item>
  300. </el-col>
  301. </el-row>
  302. <!-- <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle> -->
  303. <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
  304. <el-tab-pane label="物品清单" name="1">
  305. <inventoryTable
  306. ref="inventoryTable"
  307. @orderDiscountAmount="orderDiscountAmount"
  308. :pricingWay="form.pricingWay"
  309. :supplierMark="form.supplierMark"
  310. :is-show-supplier-mark="true"
  311. :isContractId="
  312. !!form.contractId && !OutValidate.includes(form.sourceType)
  313. "
  314. >
  315. </inventoryTable>
  316. </el-tab-pane>
  317. <el-tab-pane
  318. label="带料清单"
  319. name="2"
  320. v-if="orderSourceType.includes(form.sourceType)"
  321. >
  322. <inventoryTable
  323. ref="rawDetailListRef"
  324. :detailType="1"
  325. :pricingWay="form.pricingWay"
  326. :supplierMark="form.supplierMark"
  327. :is-show-supplier-mark="true"
  328. :isContractId="
  329. !!form.contractId && !OutValidate.includes(form.sourceType)
  330. "
  331. ></inventoryTable>
  332. </el-tab-pane>
  333. <el-tab-pane
  334. label="产出清单"
  335. name="3"
  336. v-if="orderSourceType.includes(form.sourceType)"
  337. >
  338. <inventoryTable
  339. ref="outputDetailListRef"
  340. :detailType="2"
  341. :pricingWay="form.pricingWay"
  342. :supplierMark="form.supplierMark"
  343. :is-show-supplier-mark="true"
  344. :isContractId="
  345. !!form.contractId && !OutValidate.includes(form.sourceType)
  346. "
  347. ></inventoryTable>
  348. </el-tab-pane>
  349. </el-tabs>
  350. <el-row style="margin-top: 20px">
  351. <el-col :span="12">
  352. <el-form-item label="总金额" prop="totalAmount">
  353. {{ allcountAmount || 0 }}元
  354. </el-form-item>
  355. <el-form-item label="备注" prop="remark">
  356. <el-input
  357. clearable
  358. type="textarea"
  359. v-model="form.remark"
  360. placeholder="请输入"
  361. />
  362. </el-form-item>
  363. <!-- <el-form-item
  364. label="收货地址"
  365. prop="receiveAddress"
  366. >
  367. <el-input
  368. clearable
  369. type="textarea"
  370. v-model="form.receiveAddress"
  371. placeholder="请输入"
  372. />
  373. </el-form-item> -->
  374. </el-col>
  375. <el-col :span="12">
  376. <el-form-item label="优惠后总金额" prop="payAmount">
  377. <el-input
  378. clearable
  379. v-model="form.payAmount"
  380. :disabled="
  381. (!!form.contractId && !OutValidate.includes(form.sourceType)) ||
  382. !allcountAmount
  383. "
  384. type="number"
  385. @blur="discountInput"
  386. placeholder="请输入"
  387. >
  388. <template slot="append">元</template>
  389. </el-input>
  390. </el-form-item>
  391. </el-col>
  392. </el-row>
  393. </el-form>
  394. <div slot="footer" class="footer">
  395. <el-button type="primary" @click="save" v-click-once>保存</el-button>
  396. <el-button type="primary" @click="save('sub')" v-click-once
  397. >提交</el-button
  398. >
  399. <el-button @click="cancel">返回</el-button>
  400. </div>
  401. <parentList
  402. ref="parentRef"
  403. @changeParent="changeParent"
  404. :classType="2"
  405. ></parentList>
  406. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  407. <contractListDialog
  408. :hasGeneratedOrder="
  409. this.OutValidate.includes(this.form.sourceType) ? 3 : 0
  410. "
  411. ref="selectContractRef"
  412. @changeParent="changeContract"
  413. :type="2"
  414. :sourceType="form.sourceType"
  415. ></contractListDialog>
  416. <inquiryManageList
  417. ref="inquiryManageRef"
  418. @changeInquiryManageList="changeInquiryManageList"
  419. ></inquiryManageList>
  420. <process-submit-dialog
  421. :isNotNeedProcess="false"
  422. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  423. v-if="processSubmitDialogFlag"
  424. ref="processSubmitDialogRef"
  425. @reload="reload"
  426. ></process-submit-dialog>
  427. <purchaseNeedList
  428. ref="purchaseNeedList"
  429. @changeParent="changePurchaseNeedList"
  430. ></purchaseNeedList>
  431. <inquiryList
  432. ref="inquiryListRef"
  433. @changeParent="changeInquiryList"
  434. ></inquiryList>
  435. <supplier-goods-list-dialog
  436. @changeParent="changeValue"
  437. :supplier-goods-list-dialog-flag.sync="supplierGoodsListDialogFlag"
  438. v-if="supplierGoodsListDialogFlag"
  439. ref="supplierGoodsListDialogRef"
  440. ></supplier-goods-list-dialog>
  441. <planTableList
  442. ref="planTableListRef"
  443. @success="putTableValue"
  444. @contractSuccess="contractSuccess"
  445. ></planTableList>
  446. </ele-modal>
  447. </template>
  448. <script>
  449. import { emailReg, telReg } from 'ele-admin';
  450. import inventoryTable from './inventoryTable.vue';
  451. import planTableList from './planTableList.vue';
  452. import fileUpload from '@/components/upload/fileUpload';
  453. import dictMixins from '@/mixins/dictMixins';
  454. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  455. import personSelect from '@/components/CommomSelect/person-select.vue';
  456. import parentList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  457. import {
  458. enterprisePage,
  459. getDetail,
  460. updateContractStatus
  461. } from '@/api/contractManage/contractBook';
  462. import supplierGoodsListDialog from '@/views/purchasingManage/purchaseOrder/components/supplierGoodsListDialog.vue';
  463. import {
  464. addInformation,
  465. getProductsBySource,
  466. getPurchaseinquiryAPI,
  467. getpurchaseorderDetail,
  468. getPurchasePlanByContractIdAPI,
  469. UpdateInformation
  470. } from '@/api/purchasingManage/purchaseOrder';
  471. import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
  472. import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
  473. import { getcontactlink } from '@/api/saleManage/businessFollow';
  474. import headList from '@/BIZComponents/user-select/user-select.vue';
  475. import contractListDialog from '@/views/saleManage/saleOrder/components/contractListDialog.vue';
  476. import { listOrganizations } from '@/api/system/organization';
  477. import { copyObj } from '@/utils/util';
  478. import inquiryManageList from '@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue';
  479. // import fileMain from '@/components/addDoc/index.vue';
  480. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  481. import purchaseNeedList from '@/views/purchasingManage/purchasePlanManage/components/purchaseNeed-list.vue';
  482. import inquiryList from './inquiryList.vue';
  483. import {
  484. contactDetail,
  485. updateRelationStatus
  486. } from '@/api/saleManage/contact';
  487. import {
  488. requirementSourceType,
  489. acceptUnpackoptions,
  490. orderSourceType,
  491. outsourceSceneList
  492. } from '@/enum/dict.js';
  493. export default {
  494. mixins: [dictMixins],
  495. components: {
  496. inquiryList,
  497. purchaseNeedList,
  498. processSubmitDialog,
  499. // fileMain,
  500. inquiryManageList,
  501. fileUpload,
  502. headList,
  503. contractListDialog,
  504. inventoryTable,
  505. deptSelect,
  506. parentList,
  507. personSelect,
  508. supplierGoodsListDialog,
  509. planTableList
  510. },
  511. data() {
  512. let formDef = {
  513. id: '',
  514. contractId: '',
  515. relationType: '',
  516. relationName: '',
  517. orderFiles: [],
  518. contractName: '',
  519. deliveryDate: '',
  520. payAmount: '',
  521. projectName: '',
  522. projectId: '',
  523. receiveAddress: '',
  524. sourceType: '',
  525. sourceTypeName: '',
  526. pricingWay: 1,
  527. remark: '',
  528. saleType: '',
  529. saleTypeName: '',
  530. totalAmount: '',
  531. settlementMode: '4',
  532. settlementModeName: '分期付款',
  533. partaUnifiedSocialCreditCode: '',
  534. partbUnifiedSocialCreditCode: '',
  535. partaAddress: '',
  536. partaEmail: '',
  537. partaFax: '',
  538. partaId: '',
  539. partaLinkId: '',
  540. partaLinkName: '',
  541. partaName: '',
  542. partaTel: '',
  543. partbAddress: '',
  544. partbEmail: '',
  545. partbFax: '',
  546. partbId: '',
  547. partbLinkId: '',
  548. partbLinkName: '',
  549. partbName: '',
  550. partbTel: '',
  551. purchasePlanId: '',
  552. purchasePlanNo: '',
  553. purchasePlanName: '',
  554. isFirstProcess: 0
  555. };
  556. return {
  557. orderSourceType,
  558. outsourceSceneList,
  559. requirementSourceType,
  560. processList: [
  561. {
  562. label: '是',
  563. value: 1
  564. },
  565. {
  566. label: '否',
  567. value: 0
  568. }
  569. ],
  570. isFlag: false, //订单类型是否不可修改
  571. clearing: false, //是否清除合同
  572. payWayOptions: [],
  573. delDetailIds: [],
  574. linkNameOptions: [],
  575. acceptUnpackoptions,
  576. visible: false,
  577. fullscreen: false,
  578. processSubmitDialogFlag: false,
  579. supplierGoodsListDialogFlag: false,
  580. title: '',
  581. row: {},
  582. activeName: '1',
  583. pricingWayList: [
  584. { id: 1, name: '按数量计价' },
  585. { id: 2, name: '按重量计价' }
  586. ],
  587. formDef,
  588. form: copyObj(formDef),
  589. enterprisePage: [],
  590. tableBankData: [],
  591. tableLinkData: [],
  592. // 组织机构树形结构数据
  593. groupTreeData: [],
  594. groupData: [],
  595. OutValidate: ['3', '4'],
  596. // 提交状态
  597. loading: false,
  598. // 是否是修改
  599. isUpdate: false,
  600. businessId: '',
  601. winnerSuppleIds: ''
  602. };
  603. },
  604. computed: {
  605. allcountAmount() {
  606. return this.$store.state.order.allcountAmount;
  607. },
  608. rules() {
  609. return {
  610. deliveryDate: [
  611. { required: true, message: '请选择交货日期', trigger: 'change' }
  612. ],
  613. purchasePlanName: [
  614. {
  615. required: this.OutValidate.includes(this.form.sourceType),
  616. message: '请选择采购计划单',
  617. trigger: ['change', 'blur']
  618. }
  619. ],
  620. relationName: [
  621. {
  622. required: true,
  623. message: '请选择',
  624. trigger: ['change', 'blur']
  625. }
  626. ],
  627. contractName: [
  628. {
  629. required: true,
  630. message: '请选择合同',
  631. trigger: ['change', 'blur']
  632. }
  633. ],
  634. // purchaseType: [
  635. // {required: true, message: '请选择采购订单类型', trigger: 'change'}
  636. // ],
  637. settlementMode: [
  638. { required: true, message: '请选择结算方式', trigger: 'change' }
  639. ],
  640. partaName: [
  641. { required: true, message: '请选择供应商名称', trigger: 'change' }
  642. ],
  643. partaLinkName: [
  644. { required: true, message: '请选择供应商联系人', trigger: 'change' }
  645. ],
  646. acceptUnpack: [
  647. { required: true, message: '请选择是否接受', trigger: 'change' }
  648. ],
  649. sourceType: [
  650. { required: true, message: '请选择订单类型', trigger: 'change' }
  651. ],
  652. payAmount: [{ required: true, message: '请输入', trigger: 'blur' }],
  653. partbAddress: [
  654. { required: true, message: '请输入', trigger: 'blur' }
  655. ],
  656. partaTel: [
  657. {
  658. required: true,
  659. pattern: telReg,
  660. message: '请输入供应商联系电话',
  661. trigger: 'blur'
  662. }
  663. ],
  664. partbName: [
  665. { required: true, message: '请输入供采购方名称', trigger: 'change' }
  666. ],
  667. partbLinkName: [
  668. {
  669. required: true,
  670. message: '请输入供采购方联系人',
  671. trigger: 'change'
  672. }
  673. ],
  674. partbTel: [
  675. {
  676. required: true,
  677. pattern: telReg,
  678. message: '请输入供采购方联系电话',
  679. trigger: 'blur'
  680. }
  681. ],
  682. partaEmail: [
  683. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  684. ]
  685. };
  686. }
  687. },
  688. created() {
  689. this.getGroupAll();
  690. this.getEnterprisePage();
  691. this.changePersonel();
  692. },
  693. methods: {
  694. // 选择负责人部门
  695. change_principalDep(id) {
  696. const info = this.groupData.find((e) => e.id == id);
  697. this.form.requireDeptName = info.name;
  698. // this.form.requireUserId = '';
  699. // this.form.requireUserName = '';
  700. this.$set(this.form, 'requireUserId', '');
  701. this.$set(this.form, 'requireUserName', '');
  702. // 根据部门获取人员
  703. this.getrequireUser(id);
  704. },
  705. //选择采购需求
  706. handPurchaseNeed() {
  707. this.$refs.purchaseNeedList.open(
  708. this.form.relationCode,
  709. this.form.sourceType
  710. );
  711. },
  712. //选择采购需求回调
  713. async changePurchaseNeedList(data) {
  714. this.form.relationId = data.id;
  715. this.form.relationCode = data.requirementCode;
  716. this.form.relationName = data.requirementName;
  717. this.$set(this.form, 'relationName', data.requirementName);
  718. this.$set(this.form, 'relationId', data.id);
  719. this.$set(this.form, 'relationCode', data.requirementCode);
  720. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  721. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  722. this.$set(this.form, 'requireUserId', data.requireUserId);
  723. this.$set(this.form, 'requireUserName', data.requireUserName);
  724. this.getrequireUser(data.requireDeptId);
  725. let info = await getProductsBySource({
  726. relationId: this.form.relationId,
  727. relationType: this.form.relationType
  728. });
  729. let form = {
  730. contractVO: {
  731. ...this.form
  732. },
  733. productList: info.productList || []
  734. };
  735. this.$refs.inventoryTable &&
  736. this.$refs.inventoryTable.putTableValue(form.productList);
  737. },
  738. //选择采购计划
  739. handPurchasePlan() {
  740. this.$refs.inquiryManageRef.open(
  741. this.form.planCode,
  742. this.form.sourceType
  743. );
  744. },
  745. //选择采购计划回调
  746. async changeInquiryManageList(data) {
  747. this.form.purchasePlanId = data.id;
  748. this.form.purchasePlanNo = data.planCode;
  749. this.form.purchasePlanName = data.planName;
  750. this.form.relationId = data.id;
  751. this.form.relationCode = data.planCode;
  752. this.form.relationName = data.planName;
  753. this.form.requireDeptId = data.requireDeptId;
  754. this.form.requireDeptName = data.requireDeptName;
  755. this.form.requireUserId = data.requireUserId;
  756. this.form.requireUserName = data.requireUserName;
  757. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  758. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  759. this.$set(this.form, 'requireUserId', data.requireUserId);
  760. this.$set(this.form, 'requireUserName', data.requireUserName);
  761. this.getrequireUser(data.requireDeptId);
  762. // let cusInfo = {}
  763. this.$set(this.form, 'purchasePlanName', data.planName);
  764. this.$set(this.form, 'purchasePlanId', data.id);
  765. this.$set(this.form, 'purchasePlanNo', data.planCode);
  766. this.$set(this.form, 'relationName', data.planName);
  767. this.$set(this.form, 'relationId', data.id);
  768. this.$set(this.form, 'relationCode', data.planCode);
  769. const res = await getplanDetail(data.id);
  770. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  771. let info = await getProductsBySource({
  772. relationId: this.form.relationId,
  773. relationType: this.form.relationType
  774. });
  775. info['rawDetailList'] = info.rawList;
  776. info['outputDetailList'] = info.outputList;
  777. if (info.productList.lenght > 1) {
  778. this.$refs.planTableListRef.open(info);
  779. } else {
  780. this.$nextTick(() => {
  781. this.putTableValue(info);
  782. });
  783. }
  784. // let form = {
  785. // contractVO: {
  786. // ...this.form
  787. // },
  788. // productList: info.productList || []
  789. // }
  790. // const codeList = form.productList.map((item) => item.productCode);
  791. // let inventoryTotalList = await getInventoryTotalAPI(codeList);
  792. // form.productList.forEach((item) => {
  793. // let find =
  794. // inventoryTotalList.find((key) => key.code == item.productCode) || {};
  795. // item.availableCountBase = find.availableCountBase;
  796. // });
  797. // this.$refs.inventoryTable &&
  798. // this.$refs.inventoryTable.putTableValue(form.productList);
  799. },
  800. //选择核价单
  801. handInquiry(e) {
  802. this.$refs.inquiryListRef.open(this.form.sourceType);
  803. },
  804. //选择采购核价回调
  805. async changeInquiryList(data) {
  806. console.log(data, '=======');
  807. this.form.relationId = data.id;
  808. this.form.relationCode = data.inquiryCode;
  809. this.form.relationName = data.inquiryName;
  810. this.winnerSuppleIds = data.winnerSuppleIds;
  811. this.$set(this.form, 'relationName', data.inquiryName);
  812. this.$set(this.form, 'relationId', data.id);
  813. this.$set(this.form, 'relationCode', data.inquiryCode);
  814. const res = await getpurchaseinquiry(data.id);
  815. this.$set(this.form, 'isFirstProcess', res.isFirstProcess);
  816. let info = await getProductsBySource({
  817. relationId: this.form.relationId,
  818. relationType: this.form.relationType,
  819. supplierId: this.winnerSuppleIds
  820. });
  821. info['rawDetailList'] = info.rawList;
  822. info['outputDetailList'] = info.outputList;
  823. info.productList.forEach(item=>{
  824. item['discountSinglePrice']=item.singlePrice
  825. item['discountTotalPrice']=item.totalPrice
  826. })
  827. if (info.productList.lenght > 1) {
  828. this.$refs.planTableListRef.open(info);
  829. } else {
  830. this.$nextTick(() => {
  831. this.putTableValue(info);
  832. });
  833. }
  834. this.form = {
  835. ...this.form,
  836. partbId: info.partbId,
  837. partbName: info.partbName,
  838. partbAddress: info.partaAddress,
  839. partbLinkId: info.partaAddress,
  840. partbLinkName: info.partbLinkName,
  841. partbEmail: info.partbEmail,
  842. partbTel: info.partbTel
  843. };
  844. await this.getLinkInfo(info.partbId);
  845. this.$nextTick(() => {
  846. let firstLink =
  847. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  848. this.form = Object.assign({}, this.form, {
  849. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  850. partbLinkName:
  851. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  852. partbTel:
  853. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  854. });
  855. this.setProductInfo();
  856. });
  857. await this.changeParent({ id: info.partbId });
  858. },
  859. async putTableValue({ productList, rawDetailList, outputDetailList }) {
  860. let totalPrice = 0;
  861. productList.forEach((item) => {
  862. totalPrice += item.totalPrice;
  863. });
  864. this.$store.commit('order/setAllcountAmount', totalPrice);
  865. this.$set(this.form, 'totalPrice', totalPrice);
  866. if (this.form.relationType == 3) {
  867. this.$set(this.form, 'payAmount', totalPrice);
  868. }
  869. this.$refs.inventoryTable &&
  870. this.$refs.inventoryTable.putTableValue(productList);
  871. this.$refs.rawDetailListRef &&
  872. this.$refs.rawDetailListRef.putTableValue(rawDetailList); //原料
  873. this.$refs.outputDetailListRef &&
  874. this.$refs.outputDetailListRef.putTableValue(outputDetailList);
  875. },
  876. getrequireUser(groupId) {
  877. if (groupId) {
  878. this.$refs.directorRef.getList({ groupId });
  879. }
  880. },
  881. salesmanChange(val, info) {
  882. this.$set(this.form, 'requireUserId', val);
  883. this.$set(this.form, 'requireUserName', info.name);
  884. // this.form.requireUserName = info.name;
  885. },
  886. // 获取公司数据
  887. getGroupAll() {
  888. listOrganizations().then((list) => {
  889. this.groupData = list;
  890. this.groupTreeData = this.$util.toTreeData({
  891. data: list,
  892. idField: 'id',
  893. parentIdField: 'parentId'
  894. });
  895. });
  896. },
  897. discountInput() {
  898. this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
  899. },
  900. //产品清单修改单价或者数量重置优惠金额
  901. orderDiscountAmount(val = 0) {
  902. this.form.payAmount = val;
  903. //this.form.payAmount = undefined
  904. },
  905. //选择合同获取合同的详情
  906. async getDetailData(id) {
  907. this.loading = true;
  908. const data = await getDetail(id);
  909. let info = await getProductsBySource({
  910. relationId: this.form.relationId,
  911. relationType: this.form.relationType
  912. });
  913. this.loading = false;
  914. if (data) {
  915. // if (data.contractVO.sourceType == 3 && data.contractVO.sourceId) {
  916. // //获取需求部门
  917. // const res = await getplanDetail(data.contractVO.sourceId);
  918. // this.$nextTick(() => {
  919. // this.form.requireDeptId = res.requireDeptId;
  920. // this.form.requireDeptName = res.requireDeptName;
  921. // this.form.requireUserId = res.requireUserId;
  922. // this.form.requireUserName = res.requireUserName;
  923. // });
  924. // }
  925. this.$set(this.form, 'requireDeptId', data.contractVO?.requireDeptId);
  926. this.$set(
  927. this.form,
  928. 'requireDeptName',
  929. data.contractVO?.requireDeptName
  930. );
  931. this.$set(this.form, 'requireUserId', data.contractVO?.requireUserId);
  932. this.$set(
  933. this.form,
  934. 'requireUserName',
  935. data.contractVO?.requireUserName
  936. );
  937. this.getrequireUser(data.contractVO?.requireDeptId);
  938. this.$nextTick(() => {
  939. let { contractVO } = data;
  940. // this.form=contractVOform.receiveAddress
  941. let {
  942. partaAddress,
  943. partaEmail,
  944. partaFax,
  945. partaId,
  946. partaLinkId,
  947. partaLinkName,
  948. partaName,
  949. partaTel,
  950. partbAddress,
  951. partbEmail,
  952. partbFax,
  953. partbId,
  954. partbLinkId,
  955. partbLinkName,
  956. partbName,
  957. partbTel,
  958. totalPrice,
  959. discountTotalPrice,
  960. partaUnifiedSocialCreditCode,
  961. partbUnifiedSocialCreditCode,
  962. settlementMode,
  963. settlementModeName,
  964. pricingWay,
  965. isFirstProcess,
  966. requireSourceType,
  967. requireSourceTypeName
  968. } = contractVO;
  969. this.form = Object.assign({}, this.form, {
  970. partaAddress,
  971. partaEmail,
  972. partaFax,
  973. partaId,
  974. partaLinkId,
  975. partaLinkName,
  976. partaName,
  977. partaTel,
  978. partbAddress,
  979. partbEmail,
  980. partbFax,
  981. partbId,
  982. partbLinkId,
  983. partbLinkName,
  984. partbName,
  985. partbTel,
  986. totalPrice,
  987. settlementMode,
  988. settlementModeName,
  989. discountTotalPrice,
  990. partaUnifiedSocialCreditCode,
  991. partbUnifiedSocialCreditCode,
  992. pricingWay,
  993. totalAmount: totalPrice,
  994. payAmount: discountTotalPrice,
  995. receiveAddress: partaAddress,
  996. isFirstProcess,
  997. sourceType: requireSourceType || '1',
  998. sourceTypeName: requireSourceTypeName
  999. });
  1000. this.getLinkInfo(partaId);
  1001. if (info.productList.lenght > 1) {
  1002. this.$refs.planTableListRef.contractOpen(
  1003. info.productList,
  1004. contractVO.contractStartDate
  1005. );
  1006. } else {
  1007. this.contractSuccess({
  1008. productList: info.productList,
  1009. contractStartDate: contractVO.contractStartDate
  1010. });
  1011. }
  1012. this.$refs.rawDetailListRef &&
  1013. this.$refs.rawDetailListRef.putTableValue(contractVO.rawList); //原料
  1014. this.$refs.outputDetailListRef &&
  1015. this.$refs.outputDetailListRef.putTableValue(
  1016. contractVO.outputList
  1017. );
  1018. this.$store.commit('order/setAllcountAmount', totalPrice);
  1019. });
  1020. }
  1021. },
  1022. contractSuccess({ productList, contractStartDate }) {
  1023. this.$nextTick(() => {
  1024. this.$refs.inventoryTable &&
  1025. this.$refs.inventoryTable.putTableValue(
  1026. productList,
  1027. contractStartDate
  1028. );
  1029. });
  1030. },
  1031. //获取订单详情
  1032. async getpurchaseorderDetail(id) {
  1033. this.businessId = id;
  1034. this.loading = true;
  1035. const data = await getpurchaseorderDetail(id);
  1036. this.loading = false;
  1037. if (data) {
  1038. this.$nextTick(() => {
  1039. this.form = data;
  1040. this.$store.commit('order/setAllcountAmount', data.totalAmount);
  1041. this.$refs.inventoryTable &&
  1042. this.$refs.inventoryTable.putTableValue(data.productList);
  1043. this.$refs.rawDetailListRef &&
  1044. this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
  1045. this.$refs.outputDetailListRef &&
  1046. this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
  1047. this.getLinkInfo(data.partaId);
  1048. this.getrequireUser(this.form.requireDeptId);
  1049. this.$store.commit('order/setContractId', data.contractId);
  1050. });
  1051. }
  1052. },
  1053. //更新联系人数据
  1054. async getLinkInfo(contactId) {
  1055. const data = await getcontactlink({ contactId });
  1056. if (data && data?.length) {
  1057. this.linkNameOptions = data;
  1058. }
  1059. },
  1060. sourceTypeChange() {
  1061. this.valueChange();
  1062. },
  1063. handleChangeRelationType(val) {
  1064. this.valueChange();
  1065. },
  1066. valueChange() {
  1067. this.form.purchasePlanId = '';
  1068. this.form.purchasePlanNo = '';
  1069. this.form.purchasePlanName = '';
  1070. this.form.relationId = '';
  1071. this.form.relationCode = '';
  1072. this.form.relationName = '';
  1073. this.$nextTick(() => {
  1074. this.$refs.inventoryTable &&
  1075. this.$refs.inventoryTable.putTableValue([]);
  1076. });
  1077. },
  1078. //选择下拉框
  1079. onchangeLink(selectedOptions) {
  1080. const option = this.linkNameOptions.find(
  1081. (opt) => opt.id === selectedOptions
  1082. );
  1083. this.form = Object.assign({}, this.form, {
  1084. partbEmail: option?.email,
  1085. partbLinkName: option?.linkName || '',
  1086. partbTel: option?.mobilePhone || option?.phone || '',
  1087. partbLinkId: option?.id
  1088. });
  1089. },
  1090. handHead() {
  1091. let item = {
  1092. id: this.form.partaLinkId
  1093. };
  1094. this.$refs.headRef.open(item);
  1095. },
  1096. //选择供采购方人回调
  1097. changePersonel(obj) {
  1098. if (!obj) {
  1099. obj = this.$store.getters.user.info;
  1100. obj.id = obj.userId;
  1101. }
  1102. this.$set(this.form, 'partaLinkId', obj.id);
  1103. this.$set(this.form, 'partaLinkName', obj.name);
  1104. this.$set(this.form, 'partaTel', obj.phone);
  1105. this.$set(this.form, 'partaEmail', obj.email);
  1106. },
  1107. //选择供应商回调
  1108. async changeParent(obj) {
  1109. if (!obj.id) {
  1110. return;
  1111. }
  1112. const { base, other } = await contactDetail(obj.id);
  1113. this.form = Object.assign({}, this.form, {
  1114. partbId: base.id,
  1115. partbName: base.name,
  1116. partbAddress: other.addressName
  1117. ? other.addressName + other.address
  1118. : base.addressName + other.address,
  1119. partbLinkId: '',
  1120. partbLinkName: '',
  1121. partbEmail: '',
  1122. partbTel: '',
  1123. supplierMark: base.serialNo,
  1124. partbUnifiedSocialCreditCode: base.unifiedSocialCreditCode
  1125. });
  1126. await this.getLinkInfo(obj.id);
  1127. // this.form.productList=productList
  1128. this.$nextTick(() => {
  1129. let firstLink =
  1130. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1131. this.form = Object.assign({}, this.form, {
  1132. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  1133. partbLinkName:
  1134. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  1135. partbTel:
  1136. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1137. });
  1138. this.setProductInfo();
  1139. });
  1140. },
  1141. setProductInfo() {
  1142. this.$refs.inventoryTable.setCustomerMark(this.form.supplierMark);
  1143. },
  1144. //选择合同回调
  1145. async changeContract(obj) {
  1146. this.form = Object.assign({}, this.form, {
  1147. contractId: obj.id,
  1148. contractName: obj.contractName,
  1149. contractNo: obj.contractNo,
  1150. relationId: obj.id,
  1151. relationName: obj.contractName,
  1152. relationCode: obj.contractNo
  1153. });
  1154. await this.getPlanInfo(this.form.contractId);
  1155. await this.getDetailData(obj.id);
  1156. // //采购询价表
  1157. // if(obj.sourceType==2){
  1158. // obj.sourceId && this.getPurchaseinquiry(obj.sourceId);
  1159. // }
  1160. // //采购计划
  1161. // if(obj.sourceType==3){
  1162. // obj.sourceId && this.getPlanInfo(this.form.contractId);
  1163. // }
  1164. this.$store.commit('order/setContractId', obj.id);
  1165. //获取合同采购计划
  1166. },
  1167. async getPlanInfo(id) {
  1168. let res = await getPurchasePlanByContractIdAPI(id);
  1169. if (!res.data?.id) return;
  1170. this.form = Object.assign({}, this.form, {
  1171. purchasePlanId: res.data?.id,
  1172. purchasePlanName: res.data?.planName,
  1173. purchasePlanNo: res.data?.planCode,
  1174. sourceType: res.data?.sourceType,
  1175. sourceTypeName: res.data?.sourceTypeName
  1176. });
  1177. },
  1178. //选择合同弹框
  1179. handleContractBtn() {
  1180. if (this.clearing) return;
  1181. let item = {
  1182. id: this.form.contractId
  1183. };
  1184. this.$refs.selectContractRef.open(item, this.form.sourceType);
  1185. },
  1186. //清除合同
  1187. clearContrcat() {
  1188. this.clearing = true;
  1189. this.isFlag = false;
  1190. let {
  1191. sourceType,
  1192. sourceTypeName,
  1193. requireDeptId,
  1194. requireDeptName,
  1195. requireUserId,
  1196. requireUserName,
  1197. settlementMode,
  1198. settlementModeName,
  1199. id,
  1200. projectName,
  1201. saleType,
  1202. saleTypeName,
  1203. deliveryDate,
  1204. orderFiles,
  1205. remark
  1206. } = this.form;
  1207. this.form = Object.assign({}, copyObj(this.formDef), {
  1208. id,
  1209. projectName,
  1210. saleType,
  1211. saleTypeName,
  1212. deliveryDate,
  1213. orderFiles,
  1214. remark,
  1215. sourceType,
  1216. sourceTypeName,
  1217. requireDeptId,
  1218. requireDeptName,
  1219. requireUserId,
  1220. requireUserName,
  1221. settlementMode,
  1222. settlementModeName
  1223. });
  1224. this.$store.commit('order/setContractId', '');
  1225. this.$store.commit('order/setAllcountAmount', 0);
  1226. this.$refs.inventoryTable.putTableValue([]);
  1227. this.$refs.rawDetailListRef &&
  1228. this.$refs.rawDetailListRef.putTableValue([]);
  1229. this.$refs.outputDetailListRef &&
  1230. this.$refs.outputDetailListRef.putTableValue([]);
  1231. setTimeout(() => {
  1232. this.clearing = false;
  1233. }, 500);
  1234. },
  1235. handParent() {
  1236. if (this.form.contractId) {
  1237. return this.$message.error('选择了合同不能更改供应商名称');
  1238. }
  1239. let item = {
  1240. id: this.form.contactId
  1241. };
  1242. this.$refs.parentRef.open(item);
  1243. },
  1244. //通过合同获取订单类型
  1245. async getPurchaseinquiry(sourceId) {
  1246. let data = await getPurchaseinquiryAPI(sourceId);
  1247. this.isFlag = !!data.sourceType;
  1248. this.form = Object.assign({}, this.form, {
  1249. sourceType: data.sourceType,
  1250. sourceTypeName: data.sourceTypeName
  1251. });
  1252. },
  1253. //打开新增编辑弹框
  1254. async open(type, row, contactCategoryId) {
  1255. this.title = type === 'add' ? '新增' : '修改';
  1256. this.activeName = '1';
  1257. this.row = row;
  1258. this.visible = true;
  1259. if (this.enterprisePage.length == 0) {
  1260. await this.getEnterprisePage();
  1261. }
  1262. if (type == 'add') {
  1263. this.isUpdate = false;
  1264. if (this.enterprisePage.length > 0) {
  1265. this.form.partaName = this.enterprisePage[0]?.name;
  1266. this.form.partaUnifiedSocialCreditCode =
  1267. this.enterprisePage[0]?.unifiedSocialCreditCode;
  1268. this.form.partaFax = this.enterprisePage[0]?.fax;
  1269. this.form.partaAddress = this.enterprisePage[0]?.address;
  1270. }
  1271. } else {
  1272. this.isUpdate = true;
  1273. await this.getpurchaseorderDetail(row.id);
  1274. }
  1275. },
  1276. getEnterprisePage() {
  1277. enterprisePage({
  1278. pageNum: 1,
  1279. size: 100
  1280. }).then((res) => {
  1281. this.enterprisePage = [];
  1282. this.enterprisePage.push(...res.list);
  1283. });
  1284. },
  1285. getEnterprise() {
  1286. let data = this.enterprisePage.find(
  1287. (item) => item.name == this.form.quoteName
  1288. );
  1289. this.form.partaName = data.name;
  1290. this.form.partaUnifiedSocialCreditCode = data.unifiedSocialCreditCode;
  1291. this.form.partaFax = data.fax;
  1292. this.form.partaAddress = data.address;
  1293. },
  1294. //从合同页面新增订单
  1295. contractOpen(row) {
  1296. this.title = '新增';
  1297. this.visible = true;
  1298. this.isUpdate = false;
  1299. this.form.relationType = 4;
  1300. this.changeContract(row);
  1301. },
  1302. handleGoodsList() {
  1303. console.log(11111);
  1304. this.supplierGoodsListDialogFlag = true;
  1305. this.$nextTick(() => {
  1306. this.$refs.supplierGoodsListDialogRef.open(this.form.partbId);
  1307. });
  1308. },
  1309. changeValue(val = []) {
  1310. this.$refs.inventoryTable &&
  1311. this.$refs.inventoryTable.getGoodsListData(val);
  1312. },
  1313. settlementModeChange(info) {
  1314. this.form.settlementModeName = info.dictValue;
  1315. },
  1316. ifChiefChange(value, idx) {
  1317. if (value === 1) {
  1318. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  1319. this.tableLinkData[idx].ifChief = 1;
  1320. }
  1321. },
  1322. getValidate() {
  1323. return Promise.all([
  1324. new Promise((resolve, reject) => {
  1325. this.$refs.form.validate((valid) => {
  1326. if (!valid) {
  1327. reject(false);
  1328. } else {
  1329. resolve(true);
  1330. }
  1331. });
  1332. }),
  1333. new Promise((resolve, reject) => {
  1334. this.$refs.inventoryTable.validateForm((valid) => {
  1335. if (!valid) {
  1336. reject(false);
  1337. } else {
  1338. resolve(true);
  1339. }
  1340. });
  1341. })
  1342. ]);
  1343. },
  1344. async save(type) {
  1345. let is = false;
  1346. try {
  1347. await this.getValidate();
  1348. // 表单验证通过,执行保存操作
  1349. this.loading = true;
  1350. let isTemporary = [];
  1351. if (!this.isUpdate) {
  1352. delete this.form.id;
  1353. }
  1354. if (!this.form.contractId) {
  1355. this.form.totalAmount = this.allcountAmount;
  1356. }
  1357. const rawDetailList =
  1358. (this.$refs.rawDetailListRef &&
  1359. this.$refs.rawDetailListRef.getTableValue()) ||
  1360. [];
  1361. const outputDetailList =
  1362. (this.$refs.outputDetailListRef &&
  1363. this.$refs.outputDetailListRef.getTableValue()) ||
  1364. [];
  1365. const tabList =
  1366. (this.$refs.inventoryTable &&
  1367. this.$refs.inventoryTable.getTableValue()) ||
  1368. [];
  1369. tabList.forEach((v, i) => {
  1370. if (!v.productCode) {
  1371. isTemporary.push(v.productName);
  1372. }
  1373. tabList.forEach((v2, j) => {
  1374. if (
  1375. v.productCode == v2.productCode &&
  1376. v.taskId == v2.taskId &&
  1377. v.batchNo == v2.batchNo &&
  1378. i != j
  1379. ) {
  1380. is = true;
  1381. }
  1382. });
  1383. });
  1384. if (isTemporary.length > 0) {
  1385. this.$message.error(
  1386. isTemporary.toString() +
  1387. '是临时产品,无法创建订单,请先去主数据维护!'
  1388. );
  1389. return;
  1390. }
  1391. if (is) {
  1392. this.$message.error('同产品,工序、批次号不能完全一致!');
  1393. return;
  1394. }
  1395. let productList = [
  1396. ...tabList,
  1397. ...rawDetailList.map((item) => {
  1398. item.singlePrice = item.singlePrice || 0;
  1399. item.discountSinglePrice = item.discountSinglePrice || 0;
  1400. item.totalPrice = item.totalPrice || 0;
  1401. item.discountTotalPrice = item.discountTotalPrice || 0;
  1402. return item;
  1403. }),
  1404. ...outputDetailList.map((item) => {
  1405. item.singlePrice = item.singlePrice || 0;
  1406. item.discountSinglePrice = item.discountSinglePrice || 0;
  1407. item.discountTotalPrice = item.discountTotalPrice || 0;
  1408. item.totalPrice = item.totalPrice || 0;
  1409. return item;
  1410. })
  1411. ];
  1412. let commitData = Object.assign({}, this.form, {
  1413. productList,
  1414. // purchaseTypeName: this.getDictValue(
  1415. // '采购订单类型',
  1416. // this.form.purchaseType
  1417. // ),
  1418. sourceTypeName: this.requirementSourceType.find(
  1419. (val) => val.value == this.form.sourceType
  1420. )?.label
  1421. });
  1422. if (this.isUpdate) {
  1423. UpdateInformation(commitData)
  1424. .then((res) => {
  1425. this.loading = false;
  1426. this.$message.success('修改成功');
  1427. updateRelationStatus([this.form.partbId]);
  1428. if (this.form.contractId) {
  1429. updateContractStatus([this.form.contractId]);
  1430. }
  1431. if (type === 'sub') {
  1432. this.sub(res);
  1433. return;
  1434. }
  1435. this.cancel();
  1436. this.$emit('done');
  1437. })
  1438. .catch((e) => {
  1439. //this.loading = false;
  1440. });
  1441. } else {
  1442. addInformation(commitData)
  1443. .then((res) => {
  1444. this.loading = false;
  1445. this.$message.success('新增成功');
  1446. updateRelationStatus([this.form.partbId]);
  1447. if (type === 'sub') {
  1448. this.sub(res);
  1449. return;
  1450. }
  1451. this.cancel();
  1452. this.$emit('done');
  1453. })
  1454. .catch((e) => {
  1455. //this.loading = false;
  1456. });
  1457. }
  1458. } catch (error) {
  1459. console.log(error);
  1460. // 表单验证未通过,不执行保存操作
  1461. }
  1462. },
  1463. async sub(res) {
  1464. const data = await getpurchaseorderDetail(this.businessId || res);
  1465. this.processSubmitDialogFlag = true;
  1466. this.$nextTick(() => {
  1467. let params = {
  1468. businessId: data.id,
  1469. businessKey: 'purchase_order_approve',
  1470. formCreateUserId: data.createUserId,
  1471. variables: {
  1472. businessCode: data.orderNo,
  1473. businessName: data.partaName,
  1474. businessType: data.sourceTypeName
  1475. }
  1476. // callBackMethodType : '1',
  1477. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  1478. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  1479. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  1480. // miniHandle : '',
  1481. // miniView : '',
  1482. };
  1483. this.$refs.processSubmitDialogRef.init(params);
  1484. });
  1485. // submit({
  1486. // businessId: this.businessId || res
  1487. // }).then((res) => {
  1488. // this.cancel();
  1489. // this.$emit('done');
  1490. // });
  1491. },
  1492. reload() {
  1493. this.cancel();
  1494. this.$emit('done');
  1495. },
  1496. cancel() {
  1497. this.$nextTick(() => {
  1498. this.isFlag = false;
  1499. // 关闭后,销毁所有的表单数据
  1500. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  1501. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  1502. this.$store.commit('order/clearUserData');
  1503. this.form = copyObj(this.formDef);
  1504. this.visible = false;
  1505. });
  1506. },
  1507. //查找合同分类对应name
  1508. findNameById(tree, targetId) {
  1509. for (let i = 0; i < tree.length; i++) {
  1510. const node = tree[i];
  1511. if (node.id === targetId) {
  1512. return node.name;
  1513. }
  1514. if (node.children && node.children.length > 0) {
  1515. const name = this.findNameById(node.children, targetId);
  1516. if (name) {
  1517. return name;
  1518. }
  1519. }
  1520. }
  1521. return null;
  1522. }
  1523. }
  1524. };
  1525. </script>
  1526. <style scoped lang="scss">
  1527. .TotalAmount {
  1528. font-size: 16px;
  1529. padding-right: 30px;
  1530. }
  1531. </style>