addDialog.vue 62 KB

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