addDialog.vue 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810
  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. append-to-body
  11. :fullscreen="fullscreen"
  12. @close="cancel"
  13. >
  14. <template slot="title">
  15. <modalTitle
  16. :title="title"
  17. @setFullscreen="fullscreen = !fullscreen"
  18. ></modalTitle>
  19. </template>
  20. <el-form
  21. ref="form"
  22. :model="form"
  23. :rules="rules"
  24. class="el-form-box"
  25. label-width="120px"
  26. >
  27. <headerTitle title="合同信息"></headerTitle>
  28. <el-row>
  29. <el-col :span="12">
  30. <el-form-item label="合同类型" prop="type">
  31. <!-- <DictSelection
  32. dictName="合同类型"
  33. clearable
  34. v-model="form.type"
  35. @itemChange="dictChange"
  36. :disabled="create"
  37. >
  38. </DictSelection> -->
  39. <el-select
  40. v-model="form.type"
  41. placeholder="请选择"
  42. style="width: 100%"
  43. @change="dictChange"
  44. :disabled="!!contactData?.id || !!businessOpportunityData.id"
  45. >
  46. <el-option
  47. v-for="item in contractBookTypeList"
  48. :key="item.code"
  49. :label="item.name"
  50. :value="item.code"
  51. >
  52. </el-option>
  53. </el-select>
  54. </el-form-item>
  55. <el-form-item label="来源类型" v-if="form.type">
  56. <el-select
  57. v-model="form.sourceType"
  58. placeholder="请选择"
  59. style="width: 100%"
  60. :disabled="!!businessOpportunityData.id"
  61. clearable
  62. @change="sourceTypeChange(form.type)"
  63. >
  64. <el-option
  65. v-if="item.parentId == form.type"
  66. v-for="item in sourceTypeList"
  67. :key="item.code"
  68. :label="item.name"
  69. :value="item.code"
  70. >
  71. </el-option>
  72. </el-select>
  73. </el-form-item>
  74. <!-- <el-form-item
  75. prop="remark"
  76. label="是否首工序"
  77. v-if="form.categoryId == '1752993827954225153'"
  78. >
  79. <el-radio-group v-model="form.isFirstProcess">
  80. <el-radio v-for="item in processList" :label="item.value">{{
  81. item.label
  82. }}</el-radio>
  83. </el-radio-group>
  84. </el-form-item> -->
  85. <el-form-item
  86. label="核价单"
  87. prop="sourceName"
  88. v-if="form.sourceType == 2"
  89. >
  90. <el-input
  91. clearable
  92. v-model="form.sourceName"
  93. @click.native="handInquiry"
  94. placeholder="请输入"
  95. />
  96. </el-form-item>
  97. <el-form-item
  98. label="报价单"
  99. prop="sourceName"
  100. v-if="form.sourceType == 1"
  101. >
  102. <el-input
  103. clearable
  104. v-model="form.sourceName"
  105. @click.native="handQuotation"
  106. placeholder="请输入"
  107. />
  108. </el-form-item>
  109. <el-form-item
  110. label="采购计划"
  111. prop="sourceName"
  112. v-if="form.sourceType == 3"
  113. >
  114. <el-input
  115. clearable
  116. v-model="form.sourceName"
  117. @click.native="handPlan"
  118. placeholder="请输入"
  119. />
  120. </el-form-item>
  121. <el-form-item
  122. label="商机名称"
  123. prop="sourceName"
  124. v-if="form.sourceType == 4"
  125. >
  126. <el-input
  127. clearable
  128. :disabled="!!businessOpportunityData.id"
  129. v-model="form.sourceName"
  130. @click.native="handOpportunity"
  131. placeholder="请输入"
  132. />
  133. </el-form-item>
  134. <el-form-item
  135. label="退货单"
  136. prop="sourceName"
  137. v-if="form.sourceType == 5"
  138. >
  139. <el-input
  140. clearable
  141. v-model="form.sourceName"
  142. @click.native="handReturnOrder"
  143. placeholder="请输入"
  144. />
  145. </el-form-item>
  146. <el-form-item
  147. label="需求类型"
  148. prop="requireSourceType"
  149. v-if="form.type == 2"
  150. style="margin-bottom: 22px"
  151. >
  152. <DictSelection
  153. dictName="需求类型"
  154. v-if="form.type == 2"
  155. clearable
  156. v-model="form.requireSourceType"
  157. :disabled="!!form.sourceName"
  158. >
  159. </DictSelection>
  160. </el-form-item>
  161. <el-form-item label="合同名称" prop="contractName">
  162. <el-input
  163. clearable
  164. v-model="form.contractName"
  165. placeholder="请输入"
  166. />
  167. </el-form-item>
  168. <el-form-item label="合同编号" prop="contractNumber">
  169. <el-input
  170. clearable
  171. v-model="form.contractNumber"
  172. placeholder="请输入"
  173. />
  174. </el-form-item>
  175. <el-form-item prop="contractFile" label="合同附件">
  176. <fileMain v-model="form.fileId"></fileMain>
  177. <!-- <fileUpload
  178. v-model="form.contractFile"
  179. module="main"
  180. :showLib="false"
  181. :limit="10"
  182. /> -->
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="12">
  186. <el-form-item label="合同分类" prop="categoryId" style="width: 100%">
  187. <el-select
  188. v-model="form.categoryId"
  189. placeholder="请选择"
  190. style="width: 100%"
  191. >
  192. <el-option
  193. v-for="item in categoryList"
  194. :key="item.id"
  195. :label="item.name"
  196. :value="item.id"
  197. >
  198. </el-option>
  199. </el-select>
  200. </el-form-item>
  201. <el-form-item label="结算方式" prop="settlementMode">
  202. <DictSelection
  203. dictName="结算方式"
  204. clearable
  205. v-model="form.settlementMode"
  206. style="width: 100%"
  207. >
  208. </DictSelection>
  209. </el-form-item>
  210. <el-form-item
  211. label="核价清单"
  212. prop="HJQD"
  213. v-if="form.sourceType == 2"
  214. >
  215. <el-input
  216. readonly
  217. v-model="form.HJQD"
  218. @click.native="handleHJQD"
  219. ></el-input>
  220. </el-form-item>
  221. <el-form-item label="签订日期" prop="contractStartDate">
  222. <el-date-picker
  223. v-model="form.contractStartDate"
  224. @change="setDeliveryDays"
  225. type="date"
  226. placeholder="选择日期"
  227. style="width: 100%"
  228. >
  229. </el-date-picker>
  230. </el-form-item>
  231. <el-form-item label="结束日期" prop="contractEndDate">
  232. <el-date-picker
  233. v-model="form.contractEndDate"
  234. type="date"
  235. placeholder="选择日期"
  236. style="width: 100%"
  237. >
  238. </el-date-picker>
  239. </el-form-item>
  240. </el-col>
  241. </el-row>
  242. <headerTitle title="基本信息"></headerTitle>
  243. <el-row>
  244. <el-col :span="12">
  245. <el-form-item label="甲方名称" prop="partaName">
  246. <template v-if="form.type == '2'">
  247. <el-input
  248. clearable
  249. v-model="form.partaName"
  250. placeholder="请输入"
  251. v-if="enterprisePage.length <= 1"
  252. />
  253. <el-select
  254. v-if="enterprisePage.length > 1"
  255. style="width: 100%"
  256. v-model="form.partaName"
  257. placeholder="请选择"
  258. @change="getEnterprise(1)"
  259. >
  260. <el-option
  261. v-for="item in enterprisePage"
  262. :key="item.id"
  263. :label="item.name"
  264. :value="item.name"
  265. >
  266. </el-option>
  267. </el-select>
  268. </template>
  269. <template v-else>
  270. <el-input
  271. clearable
  272. v-model="form.partaName"
  273. @click.native="handParent"
  274. placeholder="请选择"
  275. :disabled="!!contactData?.id || !!businessOpportunityData.id"
  276. />
  277. </template>
  278. </el-form-item>
  279. <el-form-item
  280. label="甲方统一社会信用代码"
  281. prop="partaUnifiedSocialCreditCode"
  282. class="form_item_label"
  283. >
  284. <el-input
  285. clearable
  286. v-model="form.partaUnifiedSocialCreditCode"
  287. placeholder="请输入"
  288. />
  289. </el-form-item>
  290. <el-form-item label="甲方联系人" prop="partaLinkName">
  291. <template v-if="form.type == '2'">
  292. <el-input
  293. clearable
  294. v-model="form.partaLinkName"
  295. @click.native="handHead"
  296. placeholder="请选择"
  297. />
  298. </template>
  299. <template v-else>
  300. <el-select
  301. v-model="form.partaLinkName"
  302. placeholder="请选择"
  303. @change="onchangeLink"
  304. @focus="selectFocus"
  305. style="width: 100%"
  306. >
  307. <el-option
  308. v-for="item in linkNameOptions"
  309. :key="item.id"
  310. :label="item.linkName"
  311. :value="item.id"
  312. >
  313. </el-option>
  314. </el-select>
  315. </template>
  316. </el-form-item>
  317. <el-form-item label="甲方电话" prop="partaTel">
  318. <el-input
  319. clearable
  320. :maxlength="20"
  321. v-model="form.partaTel"
  322. placeholder="请输入"
  323. />
  324. </el-form-item>
  325. <el-form-item label="甲方传真" prop="partaFax">
  326. <el-input clearable v-model="form.partaFax" placeholder="请输入" />
  327. </el-form-item>
  328. <el-form-item label=" 甲方Email" prop="partaEmail">
  329. <el-input
  330. clearable
  331. v-model="form.partaEmail"
  332. placeholder="请输入"
  333. />
  334. </el-form-item>
  335. <el-form-item label="甲方地址" prop="partaAddress">
  336. <el-input
  337. clearable
  338. v-model="form.partaAddress"
  339. placeholder="请输入"
  340. />
  341. </el-form-item>
  342. </el-col>
  343. <el-col :span="12">
  344. <template v-if="form.type == '2'">
  345. <el-form-item label="乙方名称" prop="partbName">
  346. <el-input
  347. clearable
  348. v-model="form.partbName"
  349. @click.native="handSupplier"
  350. placeholder="请输入"
  351. />
  352. </el-form-item>
  353. </template>
  354. <template v-else>
  355. <el-form-item label="乙方名称" prop="partbName">
  356. <el-input
  357. clearable
  358. v-model="form.partbName"
  359. placeholder="请输入"
  360. v-if="enterprisePage.length <= 1"
  361. />
  362. <el-select
  363. v-if="enterprisePage.length > 1"
  364. style="width: 100%"
  365. v-model="form.partbName"
  366. placeholder="请选择"
  367. @change="getEnterprise(1)"
  368. >
  369. <el-option
  370. v-for="item in enterprisePage"
  371. :key="item.id"
  372. :label="item.name"
  373. :value="item.name"
  374. >
  375. </el-option>
  376. </el-select>
  377. </el-form-item>
  378. </template>
  379. <el-form-item
  380. label="乙方统一社会信用代码"
  381. prop="partbUnifiedSocialCreditCode"
  382. class="form_item_label"
  383. >
  384. <el-input
  385. clearable
  386. v-model="form.partbUnifiedSocialCreditCode"
  387. placeholder="请输入"
  388. />
  389. </el-form-item>
  390. <el-form-item label="乙方联系人" prop="partbLinkName">
  391. <template v-if="form.type == '2'">
  392. <el-select
  393. style="width: 100%"
  394. v-model="form.partbLinkName"
  395. placeholder="请选择"
  396. @change="onchangeLink"
  397. @focus="selectFocus"
  398. >
  399. <el-option
  400. v-for="item in linkNameOptions"
  401. :key="item.id"
  402. :label="item.linkName"
  403. :value="item.id"
  404. >
  405. </el-option>
  406. </el-select>
  407. </template>
  408. <template v-else>
  409. <el-input
  410. clearable
  411. v-model="form.partbLinkName"
  412. @click.native="handHead"
  413. placeholder="请输入"
  414. />
  415. </template>
  416. </el-form-item>
  417. <el-form-item prop="partbTel" label="乙方联系电话">
  418. <el-input clearable v-model="form.partbTel" placeholder="请输入" />
  419. </el-form-item>
  420. <el-form-item prop="partbFax" label="乙方传真">
  421. <el-input clearable v-model="form.partbFax" placeholder="请输入" />
  422. </el-form-item>
  423. <el-form-item label="乙方Email" prop="partbEmail">
  424. <el-input
  425. clearable
  426. v-model="form.partbEmail"
  427. placeholder="请输入"
  428. />
  429. </el-form-item>
  430. <el-form-item label="乙方地址" prop="partbAddress">
  431. <el-input
  432. clearable
  433. v-model="form.partbAddress"
  434. placeholder="请输入"
  435. />
  436. </el-form-item>
  437. </el-col>
  438. </el-row>
  439. <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
  440. <el-tab-pane label="物品清单" name="1">
  441. <inventoryTable1
  442. ref="inventoryTable"
  443. :contractStartDate="this.form.contractStartDate"
  444. :isCustomerMark="form.type == '1'"
  445. :isSupplierMark="form.type == '2'"
  446. :customerMark="form.customerMark"
  447. :isDiscountTotalPrice="true"
  448. :contractBookType="form.type"
  449. :pricingWay="form.pricingWay"
  450. :isChangeCount="false"
  451. @setDiscountTotalPrice="setDiscountTotalPrice"
  452. :isTemporary="true"
  453. ></inventoryTable1>
  454. </el-tab-pane>
  455. <el-tab-pane
  456. label="带料清单"
  457. name="2"
  458. v-if="form.categoryId == '1752993827954225153'"
  459. >
  460. <inventoryTable
  461. ref="rawDetailListRef"
  462. :detailType="1"
  463. :contractStartDate="this.form.contractStartDate"
  464. :isCustomerMark="form.type == '1'"
  465. :customerMark="form.customerMark"
  466. :isDiscountTotalPrice="true"
  467. :contractBookType="form.type"
  468. :pricingWay="form.pricingWay"
  469. ></inventoryTable>
  470. </el-tab-pane>
  471. <el-tab-pane
  472. label="产出清单"
  473. name="3"
  474. v-if="form.categoryId == '1752993827954225153'"
  475. >
  476. <inventoryTable
  477. ref="outputDetailListRef"
  478. :detailType="2"
  479. :contractStartDate="this.form.contractStartDate"
  480. :isCustomerMark="form.type == '1'"
  481. :customerMark="form.customerMark"
  482. :isDiscountTotalPrice="true"
  483. :contractBookType="form.type"
  484. :pricingWay="form.pricingWay"
  485. ></inventoryTable>
  486. </el-tab-pane>
  487. </el-tabs>
  488. <!-- <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle> -->
  489. <!-- <inventoryTable
  490. ref="inventoryTable"
  491. :contractStartDate="this.form.contractStartDate"
  492. :isCustomerMark="form.type == '1'"
  493. :customerMark="form.customerMark"
  494. :isDiscountTotalPrice="true"
  495. :contractBookType="form.type"
  496. :pricingWay="form.pricingWay"
  497. ></inventoryTable> -->
  498. <headerTitle
  499. :title="form.type == '2' ? '付款方式' : '收款方式'"
  500. style="margin-top: 30px"
  501. ></headerTitle>
  502. <paymentList ref="paymentListTable" />
  503. </el-form>
  504. <div slot="footer" class="footer">
  505. <el-button type="primary" @click="save" v-click-once>保存</el-button>
  506. <el-button
  507. type="primary"
  508. v-if="isNeed_process_is_close"
  509. @click="save('sub')"
  510. >提交</el-button
  511. >
  512. <el-button @click="cancel">返回</el-button>
  513. </div>
  514. <parentList ref="parentRef" @changeParent="changeParent"></parentList>
  515. <inquiryManageList
  516. generatedType="contract"
  517. ref="inquiryManageRef"
  518. @changeInquiryManageList="changeInquiryManageList"
  519. ></inquiryManageList>
  520. <inquiryList
  521. ref="inquiryListRef"
  522. @changeParent="changeInquiryList"
  523. ></inquiryList>
  524. <quotationList
  525. ref="quotationListRef"
  526. @changeParent="changeQuotationList"
  527. :contactData="contactData"
  528. :businessOpportunityData="businessOpportunityData"
  529. ></quotationList>
  530. <supplierList
  531. ref="supplierListRef"
  532. :classType="2"
  533. @changeParent="changeSupplier"
  534. ></supplierList>
  535. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  536. <!-- 商机 -->
  537. <opportunity-dialog
  538. :opportunityDialogFlag.sync="opportunityDialogFlag"
  539. v-if="opportunityDialogFlag"
  540. ref="opportunityDialogRef"
  541. :contactData="contactData"
  542. @changeParent="getOpportunityDetail"
  543. ></opportunity-dialog>
  544. <!-- 退货 -->
  545. <return-order-dialog
  546. :returnOrderDialogFlag.sync="returnOrderDialogFlag"
  547. :contactData="contactData"
  548. v-if="returnOrderDialogFlag"
  549. @changeParent="getReturnOrderInfo"
  550. >
  551. </return-order-dialog>
  552. <generate-contracts-dialog1
  553. :isContractBook="true"
  554. v-if="generateContractsDialogFlag1"
  555. ref="generateContractsDialogRef"
  556. :generate-contracts-dialog-flag1.sync="generateContractsDialogFlag1"
  557. @changeParent="changeInquiryDetailList"
  558. ></generate-contracts-dialog1>
  559. <process-submit-dialog
  560. api-fun-name="contractStatusAPI"
  561. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  562. v-if="processSubmitDialogFlag"
  563. ref="processSubmitDialogRef"
  564. @reload="reload"
  565. ></process-submit-dialog>
  566. </ele-modal>
  567. </template>
  568. <script>
  569. import modalTitle from '@/BIZComponents/modalTitle.vue';
  570. import { emailReg, telReg } from 'ele-admin';
  571. import { acceptUnpackoptions } from '@/enum/dict';
  572. import inventoryTable from './inventoryTable.vue';
  573. import inventoryTable1 from '@/BIZComponents//inventoryTable.vue';
  574. import inquiryList from './inquiryList.vue';
  575. import quotationList from './quotationList.vue';
  576. import fileMain from '@/components/addDoc/index';
  577. import fileUpload from '@/components/upload/fileUpload';
  578. import dictMixins from '@/mixins/dictMixins';
  579. import parentList from '@/views/saleManage/contact/components/parentList.vue';
  580. import {
  581. getDetail,
  582. UpdateInformation,
  583. addInformation,
  584. submit
  585. } from '@/api/contractManage/contractBook';
  586. import {
  587. contactDetail,
  588. updateRelationStatus
  589. } from '@/api/saleManage/contact';
  590. import { getDetail as getOpportunityInfo } from '@/api/saleManage/businessOpportunity';
  591. import { isHasGeneratedContractAPI as BJisHasGeneratedContractAPI } from '@/api/saleManage/quotation';
  592. import { isHasGeneratedContractAPI as SJisHasGeneratedContractAPI } from '@/api/saleManage/businessOpportunity';
  593. import { getcontactlink } from '@/api/saleManage/businessFollow';
  594. import headList from '@/BIZComponents/user-select/user-select.vue';
  595. import supplierList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  596. import paymentList from './paymentList.vue';
  597. import { copyObj } from '@/utils/util';
  598. import { enterprisePage } from '@/api/contractManage/contractBook';
  599. import inquiryManageList from '@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue';
  600. import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
  601. import opportunityDialog from '@/views/financialManage/components/opportunityDialog.vue';
  602. import { getOpportunityDetail } from '@/api/saleManage/businessOpportunity';
  603. import { isHasGeneratedContractPI } from '@/api/purchasingManage/inquiryManage';
  604. import returnOrderDialog from '@/views/saleManage/saleOrder/customerReturnOrder/returnOrderDialog.vue';
  605. import {
  606. getReturnSaleOrderrecordDetail,
  607. saleReturnGetByIdAPI
  608. } from '@/api/saleManage/returnGoods';
  609. import generateContractsDialog1 from './generateContractsDialog1.vue';
  610. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  611. export default {
  612. props: {
  613. categoryTreeList: Array,
  614. contactData: {
  615. type: Object,
  616. default: () => {
  617. return {};
  618. }
  619. },
  620. businessOpportunityData: {
  621. type: Object,
  622. default: () => {
  623. return {};
  624. }
  625. }
  626. },
  627. mixins: [dictMixins],
  628. components: {
  629. processSubmitDialog,
  630. generateContractsDialog1,
  631. returnOrderDialog,
  632. opportunityDialog,
  633. inquiryManageList,
  634. fileUpload,
  635. headList,
  636. paymentList,
  637. inventoryTable,
  638. supplierList,
  639. parentList,
  640. inquiryList,
  641. quotationList,
  642. fileMain,
  643. modalTitle,
  644. inventoryTable1
  645. },
  646. data() {
  647. let formDef = {
  648. id: '',
  649. contractEndDate: '',
  650. contractFile: [],
  651. contractName: '',
  652. contractNumber: '',
  653. contractStartDate: '',
  654. opportunityId: '',
  655. categoryName: '',
  656. categoryId: '',
  657. sourceId: '',
  658. sourceType: '',
  659. sourceName: '',
  660. partaUnifiedSocialCreditCode: '',
  661. partbUnifiedSocialCreditCode: '',
  662. partaAddress: '',
  663. partaEmail: '',
  664. partaFax: '',
  665. partaId: '',
  666. partaLinkId: '',
  667. partaLinkName: '',
  668. partaName: '',
  669. partaTel: '',
  670. partbAddress: '',
  671. partbEmail: '',
  672. partbFax: '',
  673. partbId: '',
  674. partbLinkId: '',
  675. partbLinkName: '',
  676. partbName: '',
  677. partbTel: '',
  678. settlementModeName: '结算方式',
  679. settlementMode: '4',
  680. pricingWay: 1,
  681. customerMark: '',
  682. requireSourceType:'',
  683. requireSourceTypeName:'',
  684. totalPrice: null,
  685. isFirstProcess: 0,
  686. type: '', //1=销售合同 2=采购合同
  687. typeName: '',
  688. fileId: [] //附件集合
  689. };
  690. return {
  691. fullscreen: false,
  692. activeName: '1',
  693. payWayOptions: [],
  694. delDetailIds: [],
  695. paymentTypeOptions: [
  696. { id: 1, name: '固定' },
  697. { id: 2, name: '分期' }
  698. ],
  699. pricingWayList: [
  700. { id: 1, name: '按数量计价' },
  701. { id: 2, name: '按重量计价' }
  702. ],
  703. processList: [
  704. {
  705. label: '是',
  706. value: 1
  707. },
  708. {
  709. label: '否',
  710. value: 0
  711. }
  712. ],
  713. contractBookTypeList: [],
  714. sourceTypeList: [
  715. {
  716. code: 1,
  717. name: '报价单',
  718. parentId: '1'
  719. },
  720. {
  721. code: 2,
  722. name: '核价单',
  723. parentId: '2'
  724. },
  725. {
  726. code: 3,
  727. name: '采购计划',
  728. parentId: '2'
  729. },
  730. {
  731. code: 4,
  732. name: '商机',
  733. parentId: '1'
  734. },
  735. {
  736. code: 5,
  737. name: '退货单',
  738. parentId: '1'
  739. }
  740. ],
  741. categoryList: [],
  742. linkNameOptions: [],
  743. acceptUnpackoptions,
  744. visible: false,
  745. processSubmitDialogFlag: false,
  746. opportunityDialogFlag: false,
  747. returnOrderDialogFlag: false,
  748. generateContractsDialogFlag1: false,
  749. title: '',
  750. row: {},
  751. formDef,
  752. form: copyObj(formDef),
  753. // removeBankList: [],
  754. // removeLinkList: [],
  755. tableBankData: [],
  756. tableLinkData: [],
  757. rules: {
  758. type: [
  759. { required: true, message: '请选择合同类型', trigger: 'change' }
  760. ],
  761. HJQD: [
  762. { required: true, message: '请选择核价清单', trigger: 'change' }
  763. ],
  764. settlementMode: [
  765. { required: true, message: '请选择合结算方式', trigger: 'change' }
  766. ],
  767. categoryId: [
  768. { required: true, message: '请选择合同分类', trigger: 'change' }
  769. ],
  770. contractNumber: [
  771. { required: true, message: '请输入自带编号', trigger: 'change' }
  772. ],
  773. contractName: [
  774. { required: true, message: '请输入合同名称', trigger: 'blur' }
  775. ],
  776. partaName: [
  777. { required: true, message: '请选择甲方名称', trigger: 'change' }
  778. ],
  779. partaLinkName: [
  780. { required: true, message: '请选择甲方联系人', trigger: 'change' }
  781. ],
  782. acceptUnpack: [
  783. { required: true, message: '请选择是否接受', trigger: 'change' }
  784. ],
  785. partaTel: [
  786. {
  787. required: true,
  788. pattern: telReg,
  789. message: '请输入甲方联系电话',
  790. trigger: 'blur'
  791. }
  792. ],
  793. deliveryDate: [
  794. { required: true, message: '请选择交货日期', trigger: 'change' }
  795. ],
  796. partbName: [
  797. { required: true, message: '请输入乙方名称', trigger: 'change' }
  798. ],
  799. partbLinkName: [
  800. { required: true, message: '请输入乙方联系人', trigger: 'change' }
  801. ],
  802. partbTel: [
  803. {
  804. required: true,
  805. pattern: telReg,
  806. message: '请输入乙方联系电话',
  807. trigger: 'blur'
  808. }
  809. ],
  810. partaEmail: [
  811. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  812. ],
  813. contractStartDate: [
  814. { required: true, message: '请选择签订日期', trigger: 'change' }
  815. ],
  816. contractEndDate: [
  817. { validator: this.validateEndDate, trigger: 'blur' }
  818. ]
  819. },
  820. enterprise: {
  821. address: '',
  822. unifiedSocialCreditCode: '',
  823. tel: '',
  824. name: ''
  825. },
  826. // 提交状态
  827. loading: false,
  828. // 是否是修改
  829. isUpdate: false,
  830. enterprisePage: [],
  831. create: false,
  832. source: '',
  833. businessId: ''
  834. };
  835. },
  836. created() {
  837. enterprisePage({
  838. pageNum: 1,
  839. size: 200
  840. }).then((res) => {
  841. this.enterprisePage = [];
  842. this.enterprisePage.push(...res.list);
  843. this.getEnterprise();
  844. });
  845. },
  846. methods: {
  847. setDiscountTotalPrice(val) {
  848. this.form.discountTotalPrice = val;
  849. this.$nextTick(() => {
  850. this.$refs.paymentListTable.setDiscountAmount(val);
  851. });
  852. },
  853. //开始日期验证
  854. validateStartDate(rule, value, callback) {
  855. if (this.form.contractEndDate && value > this.form.contractEndDate) {
  856. callback(new Error('开始日期不能大于结束日期'));
  857. } else {
  858. callback();
  859. }
  860. },
  861. //结束日期验证
  862. validateEndDate(rule, value, callback) {
  863. if (
  864. this.form.contractEndDate &&
  865. this.form.contractStartDate &&
  866. value < this.form.contractStartDate
  867. ) {
  868. callback(new Error('结束日期不能小于开始日期'));
  869. } else {
  870. callback();
  871. }
  872. },
  873. //选择供应商
  874. async changeSupplier(obj) {
  875. if (!obj.id) {
  876. return;
  877. }
  878. const { base, other } = await contactDetail(obj.id);
  879. this.form = Object.assign({}, this.form, {
  880. partbId: base.id,
  881. partbName: base.name,
  882. partbAddress: other.addressName
  883. ? other.addressName + other.address
  884. : base.addressName + other.address,
  885. partbLinkId: '',
  886. partbLinkName: '',
  887. partbEmail: '',
  888. partbTel: '',
  889. partbUnifiedSocialCreditCode: obj.unifiedSocialCreditCode,
  890. customerMark: base.serialNo
  891. });
  892. await this.getLinkInfo(obj.id);
  893. this.$nextTick(() => {
  894. this.setProductInfo();
  895. let firstLink =
  896. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  897. this.form = Object.assign({}, this.form, {
  898. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  899. partbLinkName:
  900. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  901. partbTel:
  902. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  903. });
  904. });
  905. },
  906. //获取详情
  907. async getDetailData(id) {
  908. this.businessId = id;
  909. this.loading = true;
  910. const data = await getDetail(id);
  911. let { contractVO } = data;
  912. this.form = contractVO;
  913. this.loading = false;
  914. if (data) {
  915. this.form.HJQD = this.form.partbName;
  916. this.$nextTick(() => {
  917. this.dictChange(contractVO.type, 'init');
  918. // if (this.form.fileId) {
  919. // this.form.fileId = JSON.parse(this.form.fileId);
  920. // }
  921. this.$refs.inventoryTable &&
  922. this.$refs.inventoryTable.putTableValue(data);
  923. this.$refs.paymentListTable &&
  924. this.$refs.paymentListTable.putTableValue(
  925. data.receiptPaymentList
  926. );
  927. this.$refs.paymentListTable &&
  928. this.$refs.paymentListTable.setDiscountAmount(
  929. contractVO.discountTotalPrice
  930. );
  931. this.$refs.rawDetailListRef &&
  932. this.$refs.rawDetailListRef.putTableValueNew(contractVO.rawList); //原料
  933. this.$refs.outputDetailListRef &&
  934. this.$refs.outputDetailListRef.putTableValueNew(
  935. contractVO.outputList
  936. );
  937. this.getLinkInfo(
  938. contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
  939. );
  940. });
  941. }
  942. },
  943. //签订日期 更新
  944. setDeliveryDays() {
  945. this.$refs.inventoryTable.setDeliveryDays('', '', '', true);
  946. },
  947. //更新联系人数据
  948. async getLinkInfo(contactId) {
  949. const data = await getcontactlink({ contactId });
  950. if (data && data?.length) {
  951. this.linkNameOptions = data;
  952. }
  953. },
  954. handleHJQD() {
  955. if (!this.form.sourceId) return this.$message.warning('请先选择核价单');
  956. this.generateContractsDialogFlag1 = true;
  957. this.$nextTick(() => {
  958. this.$refs.generateContractsDialogRef.open({
  959. id: this.form.sourceId
  960. });
  961. });
  962. },
  963. selectFocus() {
  964. if (this.linkNameOptions.length === 0) {
  965. return this.$message.warning('请先选择名称');
  966. }
  967. },
  968. //选择合同类型
  969. dictChange(val, type) {
  970. this.categoryList = copyObj(
  971. this.contractBookTypeList.find((item) => item.code == val).children
  972. );
  973. if (type == 'init') {
  974. return;
  975. }
  976. let typeName = '';
  977. if (val)
  978. typeName =
  979. this.contractBookTypeList.find((item) => item.code == val)?.name ||
  980. '';
  981. this.form = Object.assign({}, this.form, {
  982. typeName: typeName || val.dictValue,
  983. contractName: '',
  984. sourceType: '',
  985. sourceId: '',
  986. sourceName: '',
  987. partaAddress: '',
  988. partaEmail: '',
  989. partaFax: '',
  990. partaId: '',
  991. partaLinkId: '',
  992. partaLinkName: '',
  993. partaName: '',
  994. partaTel: '',
  995. partbAddress: '',
  996. partbEmail: '',
  997. partbFax: '',
  998. partbId: '',
  999. partbLinkId: '',
  1000. partbLinkName: '',
  1001. partbName: '',
  1002. partbTel: '',
  1003. partaUnifiedSocialCreditCode: '',
  1004. partbUnifiedSocialCreditCode: '',
  1005. categoryName: '',
  1006. categoryId: ''
  1007. });
  1008. this.getEnterprise();
  1009. this.changePersonel();
  1010. },
  1011. //选择来源类型
  1012. sourceTypeChange(val, type) {
  1013. if (this.contactData.id) {
  1014. return;
  1015. }
  1016. this.form = Object.assign({}, this.form, {
  1017. contractName: '',
  1018. sourceId: '',
  1019. sourceName: '',
  1020. partaAddress: '',
  1021. partaEmail: '',
  1022. partaFax: '',
  1023. partaId: '',
  1024. partaLinkId: '',
  1025. partaLinkName: '',
  1026. partaName: '',
  1027. partaTel: '',
  1028. partbAddress: '',
  1029. partbEmail: '',
  1030. partbFax: '',
  1031. partbId: '',
  1032. partbLinkId: '',
  1033. partbLinkName: '',
  1034. partbName: '',
  1035. partbTel: '',
  1036. partaUnifiedSocialCreditCode: '',
  1037. partbUnifiedSocialCreditCode: ''
  1038. // categoryName: '',
  1039. // categoryId: ''
  1040. });
  1041. this.getEnterprise();
  1042. this.changePersonel();
  1043. },
  1044. getEnterprise(type) {
  1045. let key = this.form.type == '1' || !this.form.type ? 'partb' : 'parta';
  1046. let keyArr = [
  1047. key + 'Name',
  1048. key + 'UnifiedSocialCreditCode',
  1049. key + 'Fax',
  1050. key + 'Address'
  1051. ];
  1052. if (type === 1) {
  1053. let data = this.enterprisePage.find(
  1054. (item) => item.name == this.form[keyArr[0]]
  1055. );
  1056. this.form[keyArr[0]] = data.name;
  1057. this.form[keyArr[1]] = data.unifiedSocialCreditCode;
  1058. this.form[keyArr[2]] = data.fax;
  1059. this.form[keyArr[3]] = data.address;
  1060. return;
  1061. }
  1062. if (this.enterprisePage.length > 0) {
  1063. this.form[keyArr[0]] =
  1064. this.form[keyArr[0]] || this.enterprisePage[0].name;
  1065. this.form[keyArr[1]] =
  1066. this.form[keyArr[1]] ||
  1067. this.enterprisePage[0].unifiedSocialCreditCode;
  1068. this.form[keyArr[2]] =
  1069. this.form[keyArr[2]] || this.enterprisePage[0].fax;
  1070. this.form[keyArr[3]] =
  1071. this.form[keyArr[3]] || this.enterprisePage[0].address;
  1072. }
  1073. },
  1074. //选择合同分类
  1075. // treeChange(val) {
  1076. // //这里eladmin组件有bug,要手动验证下
  1077. // this.$set(this.form, 'categoryId', val);
  1078. // this.$refs.form.validateField('categoryId');
  1079. // },
  1080. //选择下拉框
  1081. onchangeLink(selectedOptions) {
  1082. if (this.form.type == '2') {
  1083. const option = this.linkNameOptions.find(
  1084. (opt) => opt.id === selectedOptions
  1085. );
  1086. this.form = Object.assign({}, this.form, {
  1087. partbEmail: option?.email,
  1088. partbLinkName: option?.linkName || '',
  1089. partbTel: option?.mobilePhone || option?.phone || '',
  1090. partbLinkId: option?.id
  1091. });
  1092. } else {
  1093. const option = this.linkNameOptions.find(
  1094. (opt) => opt.id === selectedOptions
  1095. );
  1096. this.form = Object.assign({}, this.form, {
  1097. partaEmail: option?.email,
  1098. partaLinkName: option?.linkName || '',
  1099. partaTel: option?.mobilePhone || option?.phone || '',
  1100. partaLinkId: option?.id
  1101. });
  1102. }
  1103. },
  1104. handHead(title) {
  1105. if (this.form.type == '2') {
  1106. let item = {
  1107. id: this.form.partaLinkId
  1108. };
  1109. this.$refs.headRef.open(item);
  1110. } else {
  1111. let item = {
  1112. id: this.form.partbLinkId
  1113. };
  1114. this.$refs.headRef.open(item);
  1115. }
  1116. },
  1117. //选择乙方人和采购合同下的甲方人回调
  1118. changePersonel(obj, index, title) {
  1119. if (!obj) {
  1120. obj = this.$store.getters.user.info;
  1121. obj.id = obj.userId;
  1122. }
  1123. if (this.form.type == '2') {
  1124. this.$set(this.form, 'partaLinkId', obj.id);
  1125. this.$set(this.form, 'partaLinkName', obj.name);
  1126. this.$set(this.form, 'partaTel', obj.phone);
  1127. this.$set(this.form, 'partaEmail', obj.email);
  1128. } else {
  1129. this.$set(this.form, 'partbLinkId', obj.id);
  1130. this.$set(this.form, 'partbLinkName', obj.name);
  1131. this.$set(this.form, 'partbTel', obj.phone);
  1132. this.$set(this.form, 'partbEmail', obj.email);
  1133. }
  1134. },
  1135. //选择客户回调
  1136. async changeParent(obj) {
  1137. if (!obj.id) {
  1138. return;
  1139. }
  1140. const { base, other } = await contactDetail(obj.id);
  1141. this.form = Object.assign({}, this.form, {
  1142. partaId: base.id,
  1143. partaName: base.name,
  1144. partaAddress: other.addressName
  1145. ? other.addressName + other.address
  1146. : base.addressName + other.address,
  1147. partaLinkId: '',
  1148. partaLinkName: '',
  1149. partaEmail: '',
  1150. partaTel: '',
  1151. customerMark: base.serialNo,
  1152. partaUnifiedSocialCreditCode: base.unifiedSocialCreditCode
  1153. });
  1154. await this.getLinkInfo(obj.id);
  1155. this.$nextTick(() => {
  1156. this.setProductInfo();
  1157. let firstLink =
  1158. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1159. this.form = Object.assign({}, this.form, {
  1160. partaLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  1161. partaLinkName:
  1162. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  1163. partaTel:
  1164. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1165. });
  1166. });
  1167. },
  1168. setProductInfo() {
  1169. if (this.$refs.inventoryTable && this.$refs.inventoryTable.form) {
  1170. this.$refs.inventoryTable?.form?.datasource.forEach((item, index) => {
  1171. if (this.form.type == 1) {
  1172. this.$set(
  1173. this.$refs.inventoryTable?.form?.datasource[index],
  1174. 'customerMark',
  1175. item.customerMark || this.form.customerMark
  1176. );
  1177. } else {
  1178. this.$set(
  1179. this.$refs.inventoryTable?.form?.datasource[index],
  1180. 'customerMark',
  1181. item.customerMark || this.form.customerMark
  1182. );
  1183. }
  1184. });
  1185. }
  1186. },
  1187. //选择采购合同的乙方
  1188. handSupplier() {
  1189. let item = {
  1190. id: this.form.partbId
  1191. };
  1192. this.$refs.supplierListRef.open(item);
  1193. },
  1194. handParent() {
  1195. let item = {
  1196. id: this.form.contactId
  1197. };
  1198. this.$refs.parentRef.open(item);
  1199. },
  1200. async open(type, row, create = false, source) {
  1201. this.title = type === 'add' ? '新增' : '修改';
  1202. this.activeName = '1';
  1203. this.row = row;
  1204. this.visible = true;
  1205. this.create = create;
  1206. this.source = source;
  1207. this.contractBookTypeList = copyObj(this.categoryTreeList[0].children);
  1208. if (type == 'add') {
  1209. let userInfo = this.$store.getters.user.info;
  1210. this.isUpdate = false;
  1211. userInfo.id = userInfo.userId;
  1212. this.changePersonel();
  1213. this.form.contractStartDate = new Date();
  1214. if (row?.contractVO?.type) {
  1215. this.dictChange(row.contractVO.type, 'init');
  1216. }
  1217. if (this.contactData.id) {
  1218. this.form.type = '1';
  1219. this.dictChange('1');
  1220. this.changeParent(this.contactData);
  1221. }
  1222. if (this.businessOpportunityData.id) {
  1223. this.form.type = '1';
  1224. this.dictChange('1');
  1225. this.form.sourceType = 4;
  1226. this.getOpportunityDetail(this.businessOpportunityData);
  1227. }
  1228. this.$nextTick(() => {
  1229. this.$refs.paymentListTable.defaultList();
  1230. });
  1231. if (create) {
  1232. this.create = create;
  1233. //核价单生成的合同
  1234. this.$nextTick(async () => {
  1235. this.setValue(row);
  1236. if (source == 'inquiryManage') {
  1237. console.log(row, 'row');
  1238. //核价单是否生成过合同
  1239. this.$nextTick(() => {
  1240. this.$refs.rawDetailListRef &&
  1241. this.$refs.rawDetailListRef.putTableValueNew(
  1242. row.contractVO?.rawList
  1243. ); //原料
  1244. this.$refs.outputDetailListRef &&
  1245. this.$refs.outputDetailListRef.putTableValueNew(
  1246. row.contractVO?.outputList
  1247. );
  1248. });
  1249. let res = await isHasGeneratedContractPI({
  1250. inquiryIds: [row.contractVO.sourceId],
  1251. supplierId: row.contractVO.partbId
  1252. });
  1253. if (res.result) this.$message.warning(res.message);
  1254. this.$refs.inventoryTable.discountInputByOrder(
  1255. row.contractVO.discountTotalPrice
  1256. );
  1257. }
  1258. if (source == 'quotation') {
  1259. //报价单是否生成过合同
  1260. let res = await BJisHasGeneratedContractAPI(
  1261. row.contractVO.sourceId
  1262. );
  1263. if (res) this.$message.warning('该报价单已生成过合同,请注意');
  1264. }
  1265. });
  1266. }
  1267. } else {
  1268. this.isUpdate = true;
  1269. await this.getDetailData(row.id);
  1270. }
  1271. },
  1272. //赋值
  1273. async setValue(row) {
  1274. let { contractVO } = row;
  1275. contractVO = {
  1276. ...contractVO,
  1277. categoryId: contractVO.categoryId || this.form.categoryId,
  1278. categoryName: contractVO.categoryName || this.form.categoryName,
  1279. contractStartDate:
  1280. contractVO.contractStartDate || this.form.contractStartDate,
  1281. contractEndDate:
  1282. contractVO.contractEndDate || this.form.contractEndDate,
  1283. pricingWay: 1
  1284. };
  1285. this.form = contractVO;
  1286. this.form.HJQD = this.form.partbName;
  1287. this.$refs.inventoryTable &&
  1288. this.$refs.inventoryTable.putTableValue(row);
  1289. this.$refs.paymentListTable &&
  1290. this.$refs.paymentListTable.putTableValue(row.receiptPaymentList);
  1291. this.$refs.paymentListTable &&
  1292. this.$refs.paymentListTable.setDiscountAmount(
  1293. contractVO.discountTotalPrice
  1294. );
  1295. this.getEnterprise();
  1296. await this.getLinkInfo(
  1297. contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
  1298. );
  1299. this.$nextTick(() => {
  1300. let firstLink =
  1301. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1302. let LinkId = [1, 4, 5].includes(this.form.sourceType)
  1303. ? 'partaLinkId'
  1304. : 'partbLinkId';
  1305. let LinkName = [1, 4, 5].includes(this.form.sourceType)
  1306. ? 'partaLinkName'
  1307. : 'partbLinkName';
  1308. let Tel = [1, 4, 5].includes(this.form.sourceType)
  1309. ? 'partaTel'
  1310. : 'partbTel';
  1311. this.$set(
  1312. this.form,
  1313. LinkId,
  1314. firstLink.id || this.linkNameOptions[0]?.id
  1315. );
  1316. this.$set(
  1317. this.form,
  1318. LinkName,
  1319. firstLink.linkName || this.linkNameOptions[0]?.linkName
  1320. );
  1321. this.$set(
  1322. this.form,
  1323. Tel,
  1324. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1325. );
  1326. this.changePersonel();
  1327. if (contractVO.type == 1) {
  1328. this.changeParent({ id: contractVO.partaId });
  1329. } else {
  1330. this.changeSupplier({ id: contractVO.partbId });
  1331. }
  1332. });
  1333. },
  1334. salesmanChange(val, info) {
  1335. this.otherForm.salesmanName = info.name;
  1336. },
  1337. ifChiefChange(value, idx) {
  1338. if (value === 1) {
  1339. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  1340. this.tableLinkData[idx].ifChief = 1;
  1341. }
  1342. },
  1343. // getValidate() {
  1344. // return new Promise((resolve, reject) => {
  1345. // this.$refs.form.validate((valid) => {
  1346. // if (!valid) {
  1347. // reject(false);
  1348. // } else {
  1349. // resolve(true);
  1350. // }
  1351. // });
  1352. // });
  1353. // },
  1354. getValidate() {
  1355. return Promise.all([
  1356. new Promise((resolve, reject) => {
  1357. this.$refs.form.validate((valid) => {
  1358. if (!valid) {
  1359. reject(false);
  1360. } else {
  1361. resolve(true);
  1362. }
  1363. });
  1364. }),
  1365. new Promise((resolve, reject) => {
  1366. this.$refs.inventoryTable.validateForm((valid) => {
  1367. if (!valid) {
  1368. reject(false);
  1369. } else {
  1370. resolve(true);
  1371. }
  1372. });
  1373. }),
  1374. new Promise((resolve, reject) => {
  1375. this.$refs.paymentListTable.validateForm((valid) => {
  1376. if (!valid) {
  1377. reject(false);
  1378. } else {
  1379. resolve(true);
  1380. }
  1381. });
  1382. })
  1383. ]);
  1384. },
  1385. async save(type) {
  1386. try {
  1387. await this.getValidate();
  1388. let isTemporary = [];
  1389. // 表单验证通过,执行保存操作
  1390. this.loading = true;
  1391. if (!this.isUpdate) {
  1392. delete this.form.id;
  1393. }
  1394. let [totalPrice, discountTotalPrice] =
  1395. this.$refs.inventoryTable.getPrice();
  1396. this.form.totalPrice = totalPrice;
  1397. this.form.discountTotalPrice = discountTotalPrice;
  1398. if (this.form.categoryId) {
  1399. this.form.categoryName = this.findNameById(
  1400. this.categoryTreeList,
  1401. this.form.categoryId
  1402. );
  1403. }
  1404. this.form.settlementModeName = this.getDictValue(
  1405. '结算方式',
  1406. this.form.settlementMode
  1407. );
  1408. // if (this.form.fileId) {
  1409. // this.form.fileId = JSON.stringify(this.form.fileId);
  1410. // } else {
  1411. // this.form.fileId = '[]';
  1412. // }
  1413. const rawDetailList =
  1414. (this.$refs.rawDetailListRef &&
  1415. this.$refs.rawDetailListRef.getTableValue()) ||
  1416. [];
  1417. const outputDetailList =
  1418. (this.$refs.outputDetailListRef &&
  1419. this.$refs.outputDetailListRef.getTableValue()) ||
  1420. [];
  1421. let commitData = Object.assign(
  1422. {},
  1423. {
  1424. contract: this.form,
  1425. productList: [
  1426. ...this.$refs.inventoryTable.getTableValue(),
  1427. ...rawDetailList,
  1428. ...outputDetailList
  1429. ],
  1430. receiptPaymentList: this.$refs.paymentListTable.getTableValue()
  1431. }
  1432. );
  1433. // commitData.productList.forEach((item) => {
  1434. // if (!item.productCode) {
  1435. // isTemporary.push(item.productName);
  1436. // }
  1437. // });
  1438. // if (isTemporary.length > 0) {
  1439. // this.$message.error(
  1440. // isTemporary.toString() +
  1441. // '是临时产品,无法创建合同,请先去主数据维护!'
  1442. // );
  1443. // return;
  1444. // }
  1445. let relationId =
  1446. this.form.type == 1 ? this.form.partaId : this.form.partbId;
  1447. if (this.isUpdate) {
  1448. UpdateInformation(commitData)
  1449. .then((res) => {
  1450. this.loading = false;
  1451. this.$message.success('修改成功');
  1452. updateRelationStatus([relationId]);
  1453. if (type === 'sub') {
  1454. this.contractBookSubmit(res);
  1455. return;
  1456. }
  1457. this.cancel();
  1458. this.$emit('done');
  1459. })
  1460. .catch((e) => {
  1461. //this.loading = false;
  1462. });
  1463. } else {
  1464. addInformation(commitData)
  1465. .then((res) => {
  1466. this.loading = false;
  1467. this.$message.success('新增成功');
  1468. updateRelationStatus([relationId]);
  1469. if (type === 'sub') {
  1470. this.contractBookSubmit(res);
  1471. return;
  1472. }
  1473. this.cancel();
  1474. this.$emit('done');
  1475. })
  1476. .catch((e) => {
  1477. //this.loading = false;
  1478. });
  1479. }
  1480. } catch (error) {
  1481. console.log(error);
  1482. // 表单验证未通过,不执行保存操作
  1483. }
  1484. },
  1485. async contractBookSubmit(res) {
  1486. const data = await getDetail(this.businessId || res);
  1487. this.processSubmitDialogFlag = true;
  1488. let key =
  1489. data.contractVO.type == 1
  1490. ? 'sales_contract_approve'
  1491. : 'contract_approve_2';
  1492. this.$nextTick(() => {
  1493. let params = {
  1494. businessId: data.contractVO.id,
  1495. businessKey: key,
  1496. formCreateUserId: data.contractVO.createUserId,
  1497. variables: {
  1498. businessType: data.contractVO.type,
  1499. businessCode: data.contractVO.contractNo
  1500. }
  1501. // callBackMethodType : '1',
  1502. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  1503. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  1504. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  1505. // miniHandle : '',
  1506. // miniView : '',
  1507. };
  1508. this.$refs.processSubmitDialogRef.init(params);
  1509. });
  1510. // submit({
  1511. // businessId: this.businessId || res,
  1512. // businessType: this.form.type
  1513. // // productionSupervisorId
  1514. // }).then((res) => {
  1515. // this.cancel();
  1516. // this.$emit('done');
  1517. // });
  1518. },
  1519. reload() {
  1520. this.cancel();
  1521. this.$emit('done');
  1522. },
  1523. handInquiry(e) {
  1524. if (e.target.nodeName == 'I') {
  1525. this.$set(this.form, 'sourceName', '');
  1526. this.$set(this.form, 'sourceId', '');
  1527. return;
  1528. }
  1529. this.$refs.inquiryListRef.open();
  1530. },
  1531. handQuotation(e) {
  1532. if (e.target.nodeName == 'I') {
  1533. this.$set(this.form, 'sourceName', '');
  1534. this.$set(this.form, 'sourceId', '');
  1535. return;
  1536. }
  1537. this.$refs.quotationListRef.open();
  1538. },
  1539. //核价单
  1540. async changeInquiryList({ data, sourceId, sourceName }) {
  1541. console.log(sourceId, sourceName);
  1542. this.$set(this.form, 'sourceName', sourceName);
  1543. this.$set(this.form, 'sourceId', sourceId);
  1544. this.$set(this.form, 'HJQD', '');
  1545. if (!data) return;
  1546. console.log(data);
  1547. this.$nextTick(() => {
  1548. this.$refs.rawDetailListRef &&
  1549. this.$refs.rawDetailListRef.putTableValueNew(data.rawList); //原料
  1550. this.$refs.outputDetailListRef &&
  1551. this.$refs.outputDetailListRef.putTableValueNew(data.outputList);
  1552. });
  1553. this.setValue(data);
  1554. },
  1555. //核价清单
  1556. async changeInquiryDetailList({ data }) {
  1557. if (!data) return;
  1558. this.setValue(data);
  1559. let contactId =
  1560. this.form.type == 2
  1561. ? data.contractVO.partbId
  1562. : data.contractVO.partaId;
  1563. let { base } = await contactDetail(contactId);
  1564. this.$set(this.form, 'contractName', base.simpleName);
  1565. },
  1566. //报价单
  1567. async changeQuotationList({ data, sourceCode, sourceName }) {
  1568. this.setValue(data);
  1569. this.$set(this.form, 'sourceName', sourceCode);
  1570. this.$set(this.form, 'sourceId', data.contractVO.sourceId);
  1571. },
  1572. //选择采购计划
  1573. handPlan(e) {
  1574. if (e.target.nodeName == 'I') {
  1575. this.$set(this.form, 'sourceName', '');
  1576. this.$set(this.form, 'sourceId', '');
  1577. return;
  1578. }
  1579. this.$refs.inquiryManageRef.open();
  1580. },
  1581. //选择采购计划回调
  1582. async changeInquiryManageList(data) {
  1583. let info = await this.getPlanInfo(data.id);
  1584. let cusInfo = {};
  1585. // if (info.detailList.length) cusInfo = await this.getCusInfo(info.detailList[0]?.supplierId ?? '');
  1586. this.$set(this.form, 'sourceName', data.planName);
  1587. this.$set(this.form, 'contractName', data.planName);
  1588. this.$set(this.form, 'sourceId', data.id);
  1589. this.form.isFirstProcess = info.isFirstProcess;
  1590. this.$nextTick(() => {
  1591. this.$refs.rawDetailListRef &&
  1592. this.$refs.rawDetailListRef.putTableValueNew(info.rawDetailList); //原料
  1593. this.$refs.outputDetailListRef &&
  1594. this.$refs.outputDetailListRef.putTableValueNew(
  1595. info.outputDetailList
  1596. );
  1597. });
  1598. // this.$set(this.form, 'contractName', cusInfo?.base?.simpleName);
  1599. let form = {
  1600. contractVO: {
  1601. ...this.form,
  1602. requireSourceType: info.sourceType,
  1603. requireSourceTypeName: info.sourceTypeName
  1604. },
  1605. productList: info.detailList || []
  1606. };
  1607. this.setValue(form);
  1608. // await this.getLinkInfo(cusInfo.base.id)
  1609. },
  1610. //获取计划详情
  1611. async getPlanInfo(id) {
  1612. return Promise.resolve(await getplanDetail(id));
  1613. },
  1614. //获取客户详情
  1615. async getCusInfo(id = '') {
  1616. if (!id) return;
  1617. return Promise.resolve(await contactDetail(id));
  1618. },
  1619. //选择商机
  1620. handOpportunity(e) {
  1621. if (e.target.nodeName == 'I') {
  1622. this.$set(this.form, 'sourceName', '');
  1623. this.$set(this.form, 'sourceId', '');
  1624. return;
  1625. }
  1626. this.opportunityDialogFlag = true;
  1627. this.$nextTick(() => {
  1628. let item = {
  1629. id: this.form.sourceId
  1630. };
  1631. this.$refs.opportunityDialogRef.init(item);
  1632. });
  1633. },
  1634. //获取商机信息
  1635. async getOpportunityDetail(row) {
  1636. let res = await SJisHasGeneratedContractAPI(row.id);
  1637. if (res) this.$message.warning('该商机已生成过合同,请注意');
  1638. this.$set(this.form, 'sourceName', row.name);
  1639. this.$set(this.form, 'sourceId', row.id);
  1640. let cusInfo = await this.getCusInfo(row?.contactId ?? '');
  1641. let info = await this.getOpportunityDetailData(row?.id ?? '');
  1642. await this.getLinkInfo(cusInfo.base.id);
  1643. let totalPrice = info.productList.reduce((num, cur) => {
  1644. return num + Number(cur.totalPrice);
  1645. }, 0);
  1646. info.productList.forEach((item) => {
  1647. item.discountSinglePrice =
  1648. item.discountSinglePrice || item.singlePrice;
  1649. item.discountTotalPrice = item.discountTotalPrice || item.totalPrice;
  1650. });
  1651. let discountTotalPrice = info.productList.reduce((num, cur) => {
  1652. return num + Number(cur.discountTotalPrice);
  1653. }, 0);
  1654. let form = {
  1655. contractVO: {
  1656. ...this.form,
  1657. partaName: cusInfo.base.name,
  1658. partaId: cusInfo.base.id,
  1659. partaUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
  1660. partaAddress: cusInfo.base.addressName + cusInfo.base.address,
  1661. partaLinkName: cusInfo.linkList[0]?.linkName,
  1662. partaLinkId: cusInfo.linkList[0]?.id,
  1663. partaTel: cusInfo.linkList[0]?.mobilePhone,
  1664. totalPrice: totalPrice,
  1665. discountTotalPrice: discountTotalPrice
  1666. },
  1667. productList: info.productList || []
  1668. };
  1669. this.setValue(form);
  1670. this.$set(this.form, 'contractName', row.name);
  1671. },
  1672. //获取商机详情
  1673. async getOpportunityDetailData(id) {
  1674. return Promise.resolve(await getOpportunityInfo(id));
  1675. },
  1676. cancel() {
  1677. this.$nextTick(() => {
  1678. this.activeName = 'base';
  1679. // 关闭后,销毁所有的表单数据
  1680. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  1681. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  1682. this.form = copyObj(this.formDef);
  1683. this.$store.commit('concact/setDiscountAmount', 0);
  1684. this.visible = false;
  1685. });
  1686. },
  1687. //选择退货单
  1688. handReturnOrder(e) {
  1689. if (e.target.nodeName == 'I') {
  1690. this.$set(this.form, 'sourceName', '');
  1691. this.$set(this.form, 'sourceId', '');
  1692. return;
  1693. }
  1694. this.returnOrderDialogFlag = true;
  1695. // this.$nextTick(() => {
  1696. // this.$refs.returnOrderDialogRef.init()
  1697. // })
  1698. },
  1699. //退货单
  1700. async getReturnOrderInfo(row) {
  1701. this.$set(this.form, 'sourceName', row.returnNo);
  1702. this.$set(this.form, 'sourceId', row.id);
  1703. let cusInfo = await this.getCusInfo(row?.contactId ?? '');
  1704. let info = await this.getReturnOrderDetail(row?.id ?? '');
  1705. await this.getLinkInfo(cusInfo.base.id);
  1706. let totalPrice = info?.productList.reduce((num, cur) => {
  1707. return num + Number(cur.totalPrice);
  1708. }, 0);
  1709. info?.redressProductList.forEach((item) => {
  1710. item.discountSinglePrice =
  1711. item.discountSinglePrice || item.singlePrice;
  1712. item.discountTotalPrice = item.discountTotalPrice || item.totalPrice;
  1713. });
  1714. let discountTotalPrice = info?.redressProductList.reduce((num, cur) => {
  1715. return num + Number(cur.discountTotalPrice);
  1716. }, 0);
  1717. let form = {
  1718. contractVO: {
  1719. ...this.form,
  1720. partaName: cusInfo.base.name,
  1721. partaId: cusInfo.base.id,
  1722. partaUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
  1723. partaAddress: cusInfo.base.addressName + cusInfo.base.address,
  1724. partaLinkName: cusInfo.linkList[0]?.linkName,
  1725. partaLinkId: cusInfo.linkList[0]?.id,
  1726. partaTel: cusInfo.linkList[0]?.mobilePhone,
  1727. totalPrice: totalPrice,
  1728. discountTotalPrice: discountTotalPrice
  1729. },
  1730. productList: info.redressProductList || []
  1731. };
  1732. this.setValue(form);
  1733. },
  1734. //获取退货单详情
  1735. async getReturnOrderDetail(id) {
  1736. return Promise.resolve(await getReturnSaleOrderrecordDetail(id));
  1737. },
  1738. //查找合同分类对应name
  1739. findNameById(tree, targetId) {
  1740. for (let i = 0; i < tree.length; i++) {
  1741. const node = tree[i];
  1742. if (node.id === targetId) {
  1743. return node.name;
  1744. }
  1745. if (node.children && node.children.length > 0) {
  1746. const name = this.findNameById(node.children, targetId);
  1747. if (name) {
  1748. return name;
  1749. }
  1750. }
  1751. }
  1752. return null;
  1753. }
  1754. }
  1755. };
  1756. </script>
  1757. <style scoped lang="scss">
  1758. .TotalAmount {
  1759. font-size: 16px;
  1760. padding-right: 30px;
  1761. }
  1762. </style>