addDialog.vue 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898
  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. @change="getListCode"
  196. >
  197. <el-option
  198. v-for="item in categoryList"
  199. :key="item.id"
  200. :label="item.name"
  201. :value="item.id"
  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="form.type == '1'"
  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. categoryTreeList: Array,
  625. contactData: {
  626. type: Object,
  627. default: () => {
  628. return {};
  629. }
  630. },
  631. curNodeData: {
  632. type: Object,
  633. default: () => {
  634. return {};
  635. }
  636. },
  637. businessOpportunityData: {
  638. type: Object,
  639. default: () => {
  640. return {};
  641. }
  642. }
  643. },
  644. mixins: [dictMixins],
  645. components: {
  646. processSubmitDialog,
  647. generateContractsDialog1,
  648. returnOrderDialog,
  649. opportunityDialog,
  650. inquiryManageList,
  651. fileUpload,
  652. headList,
  653. paymentList,
  654. inventoryTable,
  655. supplierList,
  656. parentList,
  657. inquiryList,
  658. quotationList,
  659. fileMain,
  660. inventoryTable1,
  661. personSelect
  662. },
  663. data() {
  664. let formDef = {
  665. id: '',
  666. contractEndDate: '',
  667. contractFile: [],
  668. contractName: '',
  669. contractNumber: '',
  670. contractStartDate: '',
  671. opportunityId: '',
  672. categoryName: '',
  673. categoryId: '',
  674. sourceId: '',
  675. sourceType: '',
  676. sourceName: '',
  677. partaUnifiedSocialCreditCode: '',
  678. partbUnifiedSocialCreditCode: '',
  679. partaAddress: '',
  680. partaEmail: '',
  681. partaFax: '',
  682. partaId: '',
  683. partaLinkId: '',
  684. partaLinkName: '',
  685. partaName: '',
  686. partaTel: '',
  687. partbAddress: '',
  688. partbEmail: '',
  689. partbFax: '',
  690. partbId: '',
  691. partbLinkId: '',
  692. partbLinkName: '',
  693. partbName: '',
  694. partbTel: '',
  695. settlementModeName: '结算方式',
  696. settlementMode: '4',
  697. pricingWay: 1,
  698. customerMark: '',
  699. requireSourceType: '',
  700. requireSourceTypeName: '',
  701. totalPrice: null,
  702. isFirstProcess: 0,
  703. requireDeptId: '',
  704. requireUserId: '',
  705. requireUserName: '',
  706. requireDeptName: '',
  707. type: '', //1=销售合同 2=采购合同
  708. typeName: '',
  709. fileId: [] //附件集合
  710. };
  711. return {
  712. fullscreen: false,
  713. requirementSourceType,
  714. cacheKeyUrl: 'eos-contractManage-contractBook-inventoryTabl',
  715. activeName: '1',
  716. payWayOptions: [],
  717. delDetailIds: [],
  718. paymentTypeOptions: [
  719. { id: 1, name: '固定' },
  720. { id: 2, name: '分期' }
  721. ],
  722. pricingWayList: [
  723. { id: 1, name: '按数量计价' },
  724. { id: 2, name: '按重量计价' }
  725. ],
  726. processList: [
  727. {
  728. label: '是',
  729. value: 1
  730. },
  731. {
  732. label: '否',
  733. value: 0
  734. }
  735. ],
  736. contractBookTypeList: [],
  737. sourceTypeList: [
  738. {
  739. code: 1,
  740. name: '报价单',
  741. parentId: '1'
  742. },
  743. {
  744. code: 2,
  745. name: '核价单',
  746. parentId: '2'
  747. },
  748. {
  749. code: 3,
  750. name: '采购计划',
  751. parentId: '2'
  752. },
  753. {
  754. code: 4,
  755. name: '商机',
  756. parentId: '1'
  757. },
  758. {
  759. code: 5,
  760. name: '退货单',
  761. parentId: '1'
  762. }
  763. ],
  764. categoryList: [],
  765. linkNameOptions: [],
  766. acceptUnpackoptions,
  767. visible: false,
  768. processSubmitDialogFlag: false,
  769. opportunityDialogFlag: false,
  770. returnOrderDialogFlag: false,
  771. generateContractsDialogFlag1: false,
  772. title: '',
  773. row: {},
  774. formDef,
  775. form: copyObj(formDef),
  776. // removeBankList: [],
  777. // removeLinkList: [],
  778. tableBankData: [],
  779. tableLinkData: [],
  780. rules: {
  781. type: [
  782. { required: true, message: '请选择合同类型', trigger: 'change' }
  783. ],
  784. HJQD: [
  785. { required: true, message: '请选择核价清单', trigger: 'change' }
  786. ],
  787. settlementMode: [
  788. { required: true, message: '请选择合结算方式', trigger: 'change' }
  789. ],
  790. categoryId: [
  791. { required: true, message: '请选择合同分类', trigger: 'change' }
  792. ],
  793. contractNumber: [
  794. { required: true, message: '请输入自带编号', trigger: 'change' }
  795. ],
  796. contractName: [
  797. { required: true, message: '请输入合同名称', trigger: 'blur' }
  798. ],
  799. partaName: [
  800. { required: true, message: '请选择甲方名称', trigger: 'change' }
  801. ],
  802. partaLinkName: [
  803. { required: true, message: '请选择甲方联系人', trigger: 'change' }
  804. ],
  805. acceptUnpack: [
  806. { required: true, message: '请选择是否接受', trigger: 'change' }
  807. ],
  808. partaTel: [
  809. {
  810. required: true,
  811. pattern: telReg,
  812. message: '请输入甲方联系电话',
  813. trigger: 'blur'
  814. }
  815. ],
  816. deliveryDate: [
  817. { required: true, message: '请选择交货日期', trigger: 'change' }
  818. ],
  819. partbName: [
  820. { required: true, message: '请输入乙方名称', trigger: 'change' }
  821. ],
  822. partbLinkName: [
  823. { required: true, message: '请输入乙方联系人', trigger: 'change' }
  824. ],
  825. partbTel: [
  826. {
  827. required: true,
  828. pattern: telReg,
  829. message: '请输入乙方联系电话',
  830. trigger: 'blur'
  831. }
  832. ],
  833. partaEmail: [
  834. { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
  835. ],
  836. contractStartDate: [
  837. { required: true, message: '请选择签订日期', trigger: 'change' }
  838. ],
  839. contractEndDate: [
  840. { validator: this.validateEndDate, trigger: 'blur' }
  841. ]
  842. },
  843. enterprise: {
  844. address: '',
  845. unifiedSocialCreditCode: '',
  846. tel: '',
  847. name: ''
  848. },
  849. // 提交状态
  850. loading: false,
  851. // 是否是修改
  852. isUpdate: false,
  853. enterprisePage: [],
  854. create: false,
  855. source: '',
  856. businessId: '',
  857. groupTreeData: [],
  858. // 组织机构平铺数据
  859. groupData: []
  860. };
  861. },
  862. created() {
  863. this.getGroupAll();
  864. enterprisePage({
  865. pageNum: 1,
  866. size: 200
  867. }).then((res) => {
  868. this.enterprisePage = [];
  869. this.enterprisePage.push(...res.list);
  870. this.getEnterprise();
  871. });
  872. },
  873. methods: {
  874. setDiscountTotalPrice(val) {
  875. this.form.discountTotalPrice = val;
  876. this.$nextTick(() => {
  877. this.$refs.paymentListTable.setDiscountAmount(val);
  878. });
  879. },
  880. // 获取公司数据
  881. getGroupAll() {
  882. listOrganizations().then((list) => {
  883. this.groupData = list;
  884. this.groupTreeData = this.$util.toTreeData({
  885. data: list,
  886. idField: 'id',
  887. parentIdField: 'parentId'
  888. });
  889. });
  890. },
  891. // 选择负责人部门
  892. change_principalDep(id) {
  893. const info = this.groupData.find((e) => e.id == id);
  894. this.form.requireDeptName = info.name;
  895. this.form.requireUserId = '';
  896. this.form.requireUserName = '';
  897. // 根据部门获取人员
  898. this.$nextTick(() => {});
  899. this.getrequireUser(id);
  900. },
  901. getrequireUser(groupId) {
  902. if (groupId) {
  903. this.$refs.directorRef.getList({ groupId });
  904. }
  905. },
  906. //开始日期验证
  907. validateStartDate(rule, value, callback) {
  908. if (this.form.contractEndDate && value > this.form.contractEndDate) {
  909. callback(new Error('开始日期不能大于结束日期'));
  910. } else {
  911. callback();
  912. }
  913. },
  914. //结束日期验证
  915. validateEndDate(rule, value, callback) {
  916. if (
  917. this.form.contractEndDate &&
  918. this.form.contractStartDate &&
  919. value < this.form.contractStartDate
  920. ) {
  921. callback(new Error('结束日期不能小于开始日期'));
  922. } else {
  923. callback();
  924. }
  925. },
  926. //选择供应商
  927. async changeSupplier(obj) {
  928. if (!obj.id) {
  929. return;
  930. }
  931. const { base, other } = await contactDetail(obj.id);
  932. this.form = Object.assign({}, this.form, {
  933. partbId: base.id,
  934. partbName: base.name,
  935. partbAddress: other.addressName
  936. ? other.addressName + other.address
  937. : base.addressName + other.address,
  938. partbLinkId: '',
  939. partbLinkName: '',
  940. partbEmail: '',
  941. partbTel: '',
  942. partbUnifiedSocialCreditCode: obj.unifiedSocialCreditCode,
  943. customerMark: base.serialNo
  944. });
  945. await this.getLinkInfo(obj.id);
  946. this.$nextTick(() => {
  947. this.setProductInfo();
  948. let firstLink =
  949. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  950. this.form = Object.assign({}, this.form, {
  951. partbLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  952. partbLinkName:
  953. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  954. partbTel:
  955. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  956. });
  957. });
  958. },
  959. //获取编码list
  960. async getListCode() {
  961. let categoryData = this.categoryList.find(
  962. (item) => item.id == this.form.categoryId
  963. );
  964. let list = await listCode(categoryData.code);
  965. if (list?.length > 0) {
  966. this.$set(this.form, 'contractNumber', await getCode(list[0]?.id));
  967. } else {
  968. this.$set(this.form, 'contractNumber', '');
  969. }
  970. },
  971. //获取详情
  972. async getDetailData(id) {
  973. this.businessId = id;
  974. this.loading = true;
  975. const data = await getDetail(id);
  976. let { contractVO } = data;
  977. this.form = contractVO;
  978. this.loading = false;
  979. if (data) {
  980. this.form.HJQD = this.form.partbName;
  981. this.$nextTick(() => {
  982. this.dictChange(contractVO.type, 'init');
  983. this.getrequireUser(contractVO.requireDeptId);
  984. // if (this.form.fileId) {
  985. // this.form.fileId = JSON.parse(this.form.fileId);
  986. // }
  987. this.$refs.inventoryTable &&
  988. this.$refs.inventoryTable.putTableValue(data);
  989. this.$refs.paymentListTable &&
  990. this.$refs.paymentListTable.putTableValue(
  991. data.receiptPaymentList
  992. );
  993. this.$refs.paymentListTable &&
  994. this.$refs.paymentListTable.setDiscountAmount(
  995. contractVO.discountTotalPrice
  996. );
  997. this.$refs.rawDetailListRef &&
  998. this.$refs.rawDetailListRef.putTableValueNew(contractVO.rawList); //原料
  999. this.$refs.outputDetailListRef &&
  1000. this.$refs.outputDetailListRef.putTableValueNew(
  1001. contractVO.outputList
  1002. );
  1003. this.getLinkInfo(
  1004. contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
  1005. );
  1006. });
  1007. }
  1008. },
  1009. //签订日期 更新
  1010. setDeliveryDays() {
  1011. this.$refs.inventoryTable.setDeliveryDays('', '', '', true);
  1012. },
  1013. //更新联系人数据
  1014. async getLinkInfo(contactId) {
  1015. const data = await getcontactlink({ contactId });
  1016. if (data && data?.length) {
  1017. this.linkNameOptions = data;
  1018. }
  1019. },
  1020. handleHJQD() {
  1021. if (!this.form.sourceId) return this.$message.warning('请先选择核价单');
  1022. this.generateContractsDialogFlag1 = true;
  1023. this.$nextTick(() => {
  1024. this.$refs.generateContractsDialogRef.open({
  1025. id: this.form.sourceId
  1026. });
  1027. });
  1028. },
  1029. //选择合同类型
  1030. dictChange(val, type) {
  1031. this.categoryList = copyObj(
  1032. this.contractBookTypeList.find((item) => item.code == val).children
  1033. );
  1034. if (type == 'init') {
  1035. return;
  1036. }
  1037. let typeName = '';
  1038. if (val)
  1039. typeName =
  1040. this.contractBookTypeList.find((item) => item.code == val)?.name ||
  1041. '';
  1042. this.form = Object.assign({}, this.form, {
  1043. typeName: typeName || val.dictValue,
  1044. contractName: '',
  1045. sourceType: '',
  1046. sourceId: '',
  1047. sourceName: '',
  1048. partaAddress: '',
  1049. partaEmail: '',
  1050. partaFax: '',
  1051. partaId: '',
  1052. partaLinkId: '',
  1053. partaLinkName: '',
  1054. partaName: '',
  1055. partaTel: '',
  1056. partbAddress: '',
  1057. partbEmail: '',
  1058. partbFax: '',
  1059. partbId: '',
  1060. partbLinkId: '',
  1061. partbLinkName: '',
  1062. partbName: '',
  1063. partbTel: '',
  1064. partaUnifiedSocialCreditCode: '',
  1065. partbUnifiedSocialCreditCode: '',
  1066. categoryName: '',
  1067. categoryId: ''
  1068. });
  1069. this.getEnterprise();
  1070. this.changePersonel();
  1071. },
  1072. //选择来源类型
  1073. sourceTypeChange(val, type) {
  1074. if (this.contactData.id) {
  1075. return;
  1076. }
  1077. this.form = Object.assign({}, this.form, {
  1078. contractName: '',
  1079. sourceId: '',
  1080. sourceName: '',
  1081. partaAddress: '',
  1082. partaEmail: '',
  1083. partaFax: '',
  1084. partaId: '',
  1085. partaLinkId: '',
  1086. partaLinkName: '',
  1087. partaName: '',
  1088. partaTel: '',
  1089. partbAddress: '',
  1090. partbEmail: '',
  1091. partbFax: '',
  1092. partbId: '',
  1093. partbLinkId: '',
  1094. partbLinkName: '',
  1095. partbName: '',
  1096. partbTel: '',
  1097. partaUnifiedSocialCreditCode: '',
  1098. partbUnifiedSocialCreditCode: ''
  1099. // categoryName: '',
  1100. // categoryId: ''
  1101. });
  1102. this.getEnterprise();
  1103. this.changePersonel();
  1104. },
  1105. getEnterprise(type) {
  1106. let key = this.form.type == '1' || !this.form.type ? 'partb' : 'parta';
  1107. let keyArr = [
  1108. key + 'Name',
  1109. key + 'UnifiedSocialCreditCode',
  1110. key + 'Fax',
  1111. key + 'Address'
  1112. ];
  1113. if (type === 1) {
  1114. let data = this.enterprisePage.find(
  1115. (item) => item.name == this.form[keyArr[0]]
  1116. );
  1117. this.form[keyArr[0]] = data.name;
  1118. this.form[keyArr[1]] = data.unifiedSocialCreditCode;
  1119. this.form[keyArr[2]] = data.fax;
  1120. this.form[keyArr[3]] = data.address;
  1121. return;
  1122. }
  1123. if (this.enterprisePage.length > 0) {
  1124. this.form[keyArr[0]] =
  1125. this.form[keyArr[0]] || this.enterprisePage[0].name;
  1126. this.form[keyArr[1]] =
  1127. this.form[keyArr[1]] ||
  1128. this.enterprisePage[0].unifiedSocialCreditCode;
  1129. this.form[keyArr[2]] =
  1130. this.form[keyArr[2]] || this.enterprisePage[0].fax;
  1131. this.form[keyArr[3]] =
  1132. this.form[keyArr[3]] || this.enterprisePage[0].address;
  1133. }
  1134. },
  1135. //选择合同分类
  1136. // treeChange(val) {
  1137. // //这里eladmin组件有bug,要手动验证下
  1138. // this.$set(this.form, 'categoryId', val);
  1139. // this.$refs.form.validateField('categoryId');
  1140. // },
  1141. //选择下拉框
  1142. onchangeLink(selectedOptions) {
  1143. if (this.form.type == '2') {
  1144. const option = this.linkNameOptions.find(
  1145. (opt) => opt.id === selectedOptions
  1146. );
  1147. this.form = Object.assign({}, this.form, {
  1148. partbEmail: option?.email,
  1149. partbLinkName: option?.linkName || '',
  1150. partbTel: option?.mobilePhone || option?.phone || '',
  1151. partbLinkId: option?.id
  1152. });
  1153. } else {
  1154. const option = this.linkNameOptions.find(
  1155. (opt) => opt.id === selectedOptions
  1156. );
  1157. this.form = Object.assign({}, this.form, {
  1158. partaEmail: option?.email,
  1159. partaLinkName: option?.linkName || '',
  1160. partaTel: option?.mobilePhone || option?.phone || '',
  1161. partaLinkId: option?.id
  1162. });
  1163. }
  1164. },
  1165. handHead(title) {
  1166. if (this.form.type == '2') {
  1167. let item = {
  1168. id: this.form.partaLinkId
  1169. };
  1170. this.$refs.headRef.open(item);
  1171. } else {
  1172. let item = {
  1173. id: this.form.partbLinkId
  1174. };
  1175. this.$refs.headRef.open(item);
  1176. }
  1177. },
  1178. //选择乙方人和采购合同下的甲方人回调
  1179. changePersonel(obj, index, title) {
  1180. if (!obj) {
  1181. obj = this.$store.getters.user.info;
  1182. obj.id = obj.userId;
  1183. }
  1184. if (this.form.type == '2') {
  1185. this.$set(this.form, 'partaLinkId', obj.id);
  1186. this.$set(this.form, 'partaLinkName', obj.name);
  1187. this.$set(this.form, 'partaTel', obj.phone);
  1188. this.$set(this.form, 'partaEmail', obj.email);
  1189. } else {
  1190. this.$set(this.form, 'partbLinkId', obj.id);
  1191. this.$set(this.form, 'partbLinkName', obj.name);
  1192. this.$set(this.form, 'partbTel', obj.phone);
  1193. this.$set(this.form, 'partbEmail', obj.email);
  1194. }
  1195. },
  1196. //选择客户回调
  1197. async changeParent(obj) {
  1198. if (!obj.id) {
  1199. return;
  1200. }
  1201. const { base, other } = await contactDetail(obj.id);
  1202. this.form = Object.assign({}, this.form, {
  1203. partaId: base.id,
  1204. partaName: base.name,
  1205. partaAddress: other.addressName
  1206. ? other.addressName + other.address
  1207. : base.addressName + other.address,
  1208. partaLinkId: '',
  1209. partaLinkName: '',
  1210. partaEmail: '',
  1211. partaTel: '',
  1212. customerMark: base.serialNo,
  1213. partaUnifiedSocialCreditCode: base.unifiedSocialCreditCode
  1214. });
  1215. await this.getLinkInfo(obj.id);
  1216. this.$nextTick(() => {
  1217. this.setProductInfo();
  1218. let firstLink =
  1219. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1220. this.form = Object.assign({}, this.form, {
  1221. partaLinkId: firstLink.id || this.linkNameOptions[0]?.id,
  1222. partaLinkName:
  1223. firstLink.linkName || this.linkNameOptions[0]?.linkName,
  1224. partaTel:
  1225. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1226. });
  1227. });
  1228. },
  1229. setProductInfo() {
  1230. if (this.$refs.inventoryTable && this.$refs.inventoryTable.form) {
  1231. this.$refs.inventoryTable?.form?.datasource.forEach((item, index) => {
  1232. if (this.form.type == 1) {
  1233. this.$set(
  1234. this.$refs.inventoryTable?.form?.datasource[index],
  1235. 'customerMark',
  1236. item.customerMark || this.form.customerMark
  1237. );
  1238. } else {
  1239. this.$set(
  1240. this.$refs.inventoryTable?.form?.datasource[index],
  1241. 'customerMark',
  1242. item.customerMark || this.form.customerMark
  1243. );
  1244. }
  1245. });
  1246. }
  1247. },
  1248. //选择采购合同的乙方
  1249. handSupplier() {
  1250. let item = {
  1251. id: this.form.partbId
  1252. };
  1253. this.$refs.supplierListRef.open(item);
  1254. },
  1255. handParent() {
  1256. let item = {
  1257. id: this.form.contactId
  1258. };
  1259. this.$refs.parentRef.open(item);
  1260. },
  1261. async open(type, row, create = false, source) {
  1262. this.title = type === 'add' ? '新增' : '修改';
  1263. this.activeName = '1';
  1264. this.row = row;
  1265. this.visible = true;
  1266. this.create = create;
  1267. this.source = source;
  1268. this.contractBookTypeList = copyObj(this.categoryTreeList[0].children);
  1269. if (type == 'add') {
  1270. let userInfo = this.$store.getters.user.info;
  1271. this.isUpdate = false;
  1272. userInfo.id = userInfo.userId;
  1273. this.changePersonel();
  1274. this.form.contractStartDate = new Date();
  1275. if (row?.contractVO?.type) {
  1276. this.dictChange(row.contractVO.type, 'init');
  1277. }
  1278. if (this.contactData.id) {
  1279. this.form.type = '1';
  1280. this.dictChange('1');
  1281. this.changeParent(this.contactData);
  1282. }
  1283. if (this.businessOpportunityData.id) {
  1284. this.form.type = '1';
  1285. this.dictChange('1');
  1286. this.form.sourceType = 4;
  1287. this.getOpportunityDetail(this.businessOpportunityData);
  1288. }
  1289. this.$nextTick(() => {
  1290. this.$refs.paymentListTable.defaultList();
  1291. });
  1292. if (this.curNodeData?.id) {
  1293. this.form.type =
  1294. this.curNodeData.parentCode || this.curNodeData.code;
  1295. this.dictChange(this.form.type);
  1296. if (this.curNodeData.parentCode) {
  1297. this.form.categoryId = this.curNodeData.id;
  1298. await this.getListCode();
  1299. }
  1300. }
  1301. if (create) {
  1302. this.create = create;
  1303. //核价单生成的合同
  1304. this.$nextTick(async () => {
  1305. this.setValue(row);
  1306. if (source == 'inquiryManage') {
  1307. console.log(row, 'row');
  1308. //核价单是否生成过合同
  1309. this.$nextTick(() => {
  1310. this.$refs.rawDetailListRef &&
  1311. this.$refs.rawDetailListRef.putTableValueNew(
  1312. row.contractVO?.rawList
  1313. ); //原料
  1314. this.$refs.outputDetailListRef &&
  1315. this.$refs.outputDetailListRef.putTableValueNew(
  1316. row.contractVO?.outputList
  1317. );
  1318. });
  1319. let res = await isHasGeneratedContractPI({
  1320. inquiryIds: [row.contractVO.sourceId],
  1321. supplierId: row.contractVO.partbId
  1322. });
  1323. if (res.result) this.$message.warning(res.message);
  1324. this.$refs.inventoryTable.discountInputByOrder(
  1325. row.contractVO.discountTotalPrice
  1326. );
  1327. }
  1328. if (source == 'quotation') {
  1329. //报价单是否生成过合同
  1330. let res = await BJisHasGeneratedContractAPI(
  1331. row.contractVO.sourceId
  1332. );
  1333. if (res) this.$message.warning('该报价单已生成过合同,请注意');
  1334. }
  1335. });
  1336. }
  1337. } else {
  1338. this.isUpdate = true;
  1339. await this.getDetailData(row.id);
  1340. }
  1341. },
  1342. //赋值
  1343. async setValue(row) {
  1344. let { contractVO } = row;
  1345. contractVO = {
  1346. ...contractVO,
  1347. categoryId: contractVO.categoryId || this.form.categoryId,
  1348. categoryName: contractVO.categoryName || this.form.categoryName,
  1349. contractStartDate:
  1350. contractVO.contractStartDate || this.form.contractStartDate,
  1351. contractEndDate:
  1352. contractVO.contractEndDate || this.form.contractEndDate,
  1353. pricingWay: 1
  1354. };
  1355. this.form = contractVO;
  1356. this.form.HJQD = this.form.partbName;
  1357. this.$refs.inventoryTable &&
  1358. this.$refs.inventoryTable.putTableValue(row);
  1359. this.$refs.paymentListTable &&
  1360. this.$refs.paymentListTable.putTableValue(row.receiptPaymentList);
  1361. this.$refs.paymentListTable &&
  1362. this.$refs.paymentListTable.setDiscountAmount(
  1363. contractVO.discountTotalPrice
  1364. );
  1365. this.getEnterprise();
  1366. await this.getLinkInfo(
  1367. contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
  1368. );
  1369. this.$nextTick(() => {
  1370. this.getrequireUser(contractVO.requireDeptId);
  1371. let firstLink =
  1372. this.linkNameOptions.find((item) => item.ifChief == 1) || {};
  1373. let LinkId = [1, 4, 5].includes(this.form.sourceType)
  1374. ? 'partaLinkId'
  1375. : 'partbLinkId';
  1376. let LinkName = [1, 4, 5].includes(this.form.sourceType)
  1377. ? 'partaLinkName'
  1378. : 'partbLinkName';
  1379. let Tel = [1, 4, 5].includes(this.form.sourceType)
  1380. ? 'partaTel'
  1381. : 'partbTel';
  1382. this.$set(
  1383. this.form,
  1384. LinkId,
  1385. firstLink.id || this.linkNameOptions[0]?.id
  1386. );
  1387. this.$set(
  1388. this.form,
  1389. LinkName,
  1390. firstLink.linkName || this.linkNameOptions[0]?.linkName
  1391. );
  1392. this.$set(
  1393. this.form,
  1394. Tel,
  1395. firstLink.mobilePhone || this.linkNameOptions[0]?.mobilePhone
  1396. );
  1397. this.changePersonel();
  1398. if (contractVO.type == 1) {
  1399. this.changeParent({ id: contractVO.partaId });
  1400. } else {
  1401. this.changeSupplier({ id: contractVO.partbId });
  1402. }
  1403. });
  1404. },
  1405. salesmanChange(val, info) {
  1406. this.otherForm.salesmanName = info.name;
  1407. },
  1408. ifChiefChange(value, idx) {
  1409. if (value === 1) {
  1410. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  1411. this.tableLinkData[idx].ifChief = 1;
  1412. }
  1413. },
  1414. // getValidate() {
  1415. // return new Promise((resolve, reject) => {
  1416. // this.$refs.form.validate((valid) => {
  1417. // if (!valid) {
  1418. // reject(false);
  1419. // } else {
  1420. // resolve(true);
  1421. // }
  1422. // });
  1423. // });
  1424. // },
  1425. getValidate() {
  1426. return Promise.all([
  1427. new Promise((resolve, reject) => {
  1428. this.$refs.form.validate((valid) => {
  1429. if (!valid) {
  1430. reject(false);
  1431. } else {
  1432. resolve(true);
  1433. }
  1434. });
  1435. }),
  1436. new Promise((resolve, reject) => {
  1437. this.$refs.inventoryTable.validateForm((valid) => {
  1438. if (!valid) {
  1439. reject(false);
  1440. } else {
  1441. resolve(true);
  1442. }
  1443. });
  1444. }),
  1445. new Promise((resolve, reject) => {
  1446. this.$refs.paymentListTable.validateForm((valid) => {
  1447. if (!valid) {
  1448. reject(false);
  1449. } else {
  1450. resolve(true);
  1451. }
  1452. });
  1453. })
  1454. ]);
  1455. },
  1456. async save(type) {
  1457. try {
  1458. await this.getValidate();
  1459. let isTemporary = [];
  1460. // 表单验证通过,执行保存操作
  1461. this.loading = true;
  1462. if (!this.isUpdate) {
  1463. delete this.form.id;
  1464. }
  1465. let [totalPrice, discountTotalPrice] =
  1466. this.$refs.inventoryTable.getPrice();
  1467. this.form.totalPrice = totalPrice;
  1468. this.form.discountTotalPrice = discountTotalPrice;
  1469. if (this.form.categoryId) {
  1470. this.form.categoryName = this.findNameById(
  1471. this.categoryTreeList,
  1472. this.form.categoryId
  1473. );
  1474. }
  1475. this.form.settlementModeName = this.getDictValue(
  1476. '结算方式',
  1477. this.form.settlementMode
  1478. );
  1479. this.form.requireSourceTypeName = this.requirementSourceType.find(
  1480. (item) => item.value == this.form.requireSourceType
  1481. )?.label;
  1482. // if (this.form.fileId) {
  1483. // this.form.fileId = JSON.stringify(this.form.fileId);
  1484. // } else {
  1485. // this.form.fileId = '[]';
  1486. // }
  1487. const rawDetailList =
  1488. (this.$refs.rawDetailListRef &&
  1489. this.$refs.rawDetailListRef.getTableValue()) ||
  1490. [];
  1491. const outputDetailList =
  1492. (this.$refs.outputDetailListRef &&
  1493. this.$refs.outputDetailListRef.getTableValue()) ||
  1494. [];
  1495. let commitData = Object.assign(
  1496. {},
  1497. {
  1498. contract: this.form,
  1499. productList: [
  1500. ...this.$refs.inventoryTable.getTableValue(),
  1501. ...rawDetailList,
  1502. ...outputDetailList
  1503. ],
  1504. receiptPaymentList: this.$refs.paymentListTable.getTableValue()
  1505. }
  1506. );
  1507. // commitData.productList.forEach((item) => {
  1508. // if (!item.productCode) {
  1509. // isTemporary.push(item.productName);
  1510. // }
  1511. // });
  1512. // if (isTemporary.length > 0) {
  1513. // this.$message.error(
  1514. // isTemporary.toString() +
  1515. // '是临时产品,无法创建合同,请先去主数据维护!'
  1516. // );
  1517. // return;
  1518. // }
  1519. let relationId =
  1520. this.form.type == 1 ? this.form.partaId : this.form.partbId;
  1521. if (this.isUpdate) {
  1522. UpdateInformation(commitData)
  1523. .then((res) => {
  1524. this.loading = false;
  1525. this.$message.success('修改成功');
  1526. updateRelationStatus([relationId]);
  1527. if (type === 'sub') {
  1528. this.contractBookSubmit(res);
  1529. return;
  1530. }
  1531. this.cancel();
  1532. this.$emit('done');
  1533. })
  1534. .catch((e) => {
  1535. //this.loading = false;
  1536. });
  1537. } else {
  1538. addInformation(commitData)
  1539. .then((res) => {
  1540. this.loading = false;
  1541. this.$message.success('新增成功');
  1542. updateRelationStatus([relationId]);
  1543. if (type === 'sub') {
  1544. this.contractBookSubmit(res);
  1545. return;
  1546. }
  1547. this.cancel();
  1548. this.$emit('done');
  1549. })
  1550. .catch((e) => {
  1551. //this.loading = false;
  1552. });
  1553. }
  1554. } catch (error) {
  1555. console.log(error);
  1556. // 表单验证未通过,不执行保存操作
  1557. }
  1558. },
  1559. async contractBookSubmit(res) {
  1560. const data = await getDetail(this.businessId || res);
  1561. this.processSubmitDialogFlag = true;
  1562. let key =
  1563. data.contractVO.type == 1
  1564. ? 'sales_contract_approve'
  1565. : 'contract_approve_2';
  1566. this.$nextTick(() => {
  1567. let params = {
  1568. businessId: data.contractVO.id,
  1569. businessKey: key,
  1570. formCreateUserId: data.contractVO.createUserId,
  1571. variables: {
  1572. businessType: data.contractVO.categoryName,
  1573. businessName: data.contractVO.contractName,
  1574. businessCode: data.contractVO.contractNumber
  1575. }
  1576. // callBackMethodType : '1',
  1577. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  1578. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  1579. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  1580. // miniHandle : '',
  1581. // miniView : '',
  1582. };
  1583. this.$refs.processSubmitDialogRef.init(params);
  1584. });
  1585. // submit({
  1586. // businessId: this.businessId || res,
  1587. // businessType: this.form.type
  1588. // // productionSupervisorId
  1589. // }).then((res) => {
  1590. // this.cancel();
  1591. // this.$emit('done');
  1592. // });
  1593. },
  1594. reload() {
  1595. this.cancel();
  1596. this.$emit('done');
  1597. },
  1598. handInquiry(e) {
  1599. if (e.target.nodeName == 'I') {
  1600. this.$set(this.form, 'sourceName', '');
  1601. this.$set(this.form, 'sourceId', '');
  1602. return;
  1603. }
  1604. this.$refs.inquiryListRef.open();
  1605. },
  1606. handQuotation(e) {
  1607. if (e.target.nodeName == 'I') {
  1608. this.$set(this.form, 'sourceName', '');
  1609. this.$set(this.form, 'sourceId', '');
  1610. return;
  1611. }
  1612. this.$refs.quotationListRef.open();
  1613. },
  1614. //核价单
  1615. async changeInquiryList({ data, sourceId, sourceName }) {
  1616. console.log(sourceId, sourceName);
  1617. this.$set(this.form, 'sourceName', sourceName);
  1618. this.$set(this.form, 'sourceId', sourceId);
  1619. this.$set(this.form, 'HJQD', '');
  1620. if (!data) return;
  1621. console.log(data);
  1622. this.$nextTick(() => {
  1623. this.$refs.rawDetailListRef &&
  1624. this.$refs.rawDetailListRef.putTableValueNew(data.rawList); //原料
  1625. this.$refs.outputDetailListRef &&
  1626. this.$refs.outputDetailListRef.putTableValueNew(data.outputList);
  1627. });
  1628. this.setValue(data);
  1629. },
  1630. //核价清单
  1631. async changeInquiryDetailList({ data }) {
  1632. if (!data) return;
  1633. this.setValue(data);
  1634. let contactId =
  1635. this.form.type == 2
  1636. ? data.contractVO.partbId
  1637. : data.contractVO.partaId;
  1638. let { base } = await contactDetail(contactId);
  1639. this.$set(this.form, 'contractName', base.simpleName);
  1640. },
  1641. //报价单
  1642. async changeQuotationList({ data, sourceCode, sourceName }) {
  1643. this.setValue(data);
  1644. this.$set(this.form, 'sourceName', sourceCode);
  1645. this.$set(this.form, 'sourceId', data.contractVO.sourceId);
  1646. },
  1647. //选择采购计划
  1648. handPlan(e) {
  1649. if (e.target.nodeName == 'I') {
  1650. this.$set(this.form, 'sourceName', '');
  1651. this.$set(this.form, 'sourceId', '');
  1652. return;
  1653. }
  1654. this.$refs.inquiryManageRef.open();
  1655. },
  1656. //选择采购计划回调
  1657. async changeInquiryManageList(data) {
  1658. let info = await this.getPlanInfo(data.id);
  1659. let cusInfo = {};
  1660. // if (info.detailList.length) cusInfo = await this.getCusInfo(info.detailList[0]?.supplierId ?? '');
  1661. this.$set(this.form, 'sourceName', data.planName);
  1662. this.$set(this.form, 'contractName', data.planName);
  1663. this.$set(this.form, 'sourceId', data.id);
  1664. this.$set(this.form, 'requireDeptId', data.requireDeptId);
  1665. this.$set(this.form, 'requireUserId', data.requireUserId);
  1666. this.$set(this.form, 'requireDeptName', data.requireDeptName);
  1667. this.$set(this.form, 'requireUserName', data.requireUserName);
  1668. // this.getrequireUser(data.requireDeptId)
  1669. this.form.isFirstProcess = info.isFirstProcess;
  1670. this.$nextTick(() => {
  1671. this.$refs.rawDetailListRef &&
  1672. this.$refs.rawDetailListRef.putTableValueNew(info.rawDetailList); //原料
  1673. this.$refs.outputDetailListRef &&
  1674. this.$refs.outputDetailListRef.putTableValueNew(
  1675. info.outputDetailList
  1676. );
  1677. });
  1678. // this.$set(this.form, 'contractName', cusInfo?.base?.simpleName);
  1679. let form = {
  1680. contractVO: {
  1681. ...this.form,
  1682. requireSourceType: info.sourceType,
  1683. requireSourceTypeName: info.sourceTypeName
  1684. },
  1685. productList: info.detailList || []
  1686. };
  1687. this.setValue(form);
  1688. // await this.getLinkInfo(cusInfo.base.id)
  1689. },
  1690. //获取计划详情
  1691. async getPlanInfo(id) {
  1692. return Promise.resolve(await getplanDetail(id));
  1693. },
  1694. //获取客户详情
  1695. async getCusInfo(id = '') {
  1696. if (!id) return;
  1697. return Promise.resolve(await contactDetail(id));
  1698. },
  1699. //选择商机
  1700. handOpportunity(e) {
  1701. if (e.target.nodeName == 'I') {
  1702. this.$set(this.form, 'sourceName', '');
  1703. this.$set(this.form, 'sourceId', '');
  1704. return;
  1705. }
  1706. this.opportunityDialogFlag = true;
  1707. this.$nextTick(() => {
  1708. let item = {
  1709. id: this.form.sourceId
  1710. };
  1711. this.$refs.opportunityDialogRef.init(item);
  1712. });
  1713. },
  1714. //获取商机信息
  1715. async getOpportunityDetail(row) {
  1716. let res = await SJisHasGeneratedContractAPI(row.id);
  1717. if (res) this.$message.warning('该商机已生成过合同,请注意');
  1718. this.$set(this.form, 'sourceName', row.name);
  1719. this.$set(this.form, 'sourceId', row.id);
  1720. let cusInfo = await this.getCusInfo(row?.contactId ?? '');
  1721. let info = await this.getOpportunityDetailData(row?.id ?? '');
  1722. await this.getLinkInfo(cusInfo.base.id);
  1723. let totalPrice = info.productList.reduce((num, cur) => {
  1724. return num + Number(cur.totalPrice);
  1725. }, 0);
  1726. info.productList.forEach((item) => {
  1727. item.discountSinglePrice =
  1728. item.discountSinglePrice || item.singlePrice;
  1729. item.discountTotalPrice = item.discountTotalPrice || item.totalPrice;
  1730. });
  1731. let discountTotalPrice = info.productList.reduce((num, cur) => {
  1732. return num + Number(cur.discountTotalPrice);
  1733. }, 0);
  1734. let form = {
  1735. contractVO: {
  1736. ...this.form,
  1737. partaName: cusInfo.base.name,
  1738. partaId: cusInfo.base.id,
  1739. partaUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
  1740. partaAddress: cusInfo.base.addressName + cusInfo.base.address,
  1741. partaLinkName: cusInfo.linkList[0]?.linkName,
  1742. partaLinkId: cusInfo.linkList[0]?.id,
  1743. partaTel: cusInfo.linkList[0]?.mobilePhone,
  1744. totalPrice: totalPrice,
  1745. discountTotalPrice: discountTotalPrice
  1746. },
  1747. productList: info.productList || []
  1748. };
  1749. this.setValue(form);
  1750. this.$set(this.form, 'contractName', row.name);
  1751. },
  1752. //获取商机详情
  1753. async getOpportunityDetailData(id) {
  1754. return Promise.resolve(await getOpportunityInfo(id));
  1755. },
  1756. cancel() {
  1757. this.$nextTick(() => {
  1758. this.activeName = 'base';
  1759. // 关闭后,销毁所有的表单数据
  1760. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  1761. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  1762. this.form = copyObj(this.formDef);
  1763. this.$store.commit('concact/setDiscountAmount', 0);
  1764. this.visible = false;
  1765. });
  1766. },
  1767. //选择退货单
  1768. handReturnOrder(e) {
  1769. if (e.target.nodeName == 'I') {
  1770. this.$set(this.form, 'sourceName', '');
  1771. this.$set(this.form, 'sourceId', '');
  1772. return;
  1773. }
  1774. this.returnOrderDialogFlag = true;
  1775. // this.$nextTick(() => {
  1776. // this.$refs.returnOrderDialogRef.init()
  1777. // })
  1778. },
  1779. //退货单
  1780. async getReturnOrderInfo(row) {
  1781. this.$set(this.form, 'sourceName', row.returnNo);
  1782. this.$set(this.form, 'sourceId', row.id);
  1783. let cusInfo = await this.getCusInfo(row?.contactId ?? '');
  1784. let info = await this.getReturnOrderDetail(row?.id ?? '');
  1785. await this.getLinkInfo(cusInfo.base.id);
  1786. let totalPrice = info?.productList.reduce((num, cur) => {
  1787. return num + Number(cur.totalPrice);
  1788. }, 0);
  1789. info?.redressProductList.forEach((item) => {
  1790. item.discountSinglePrice =
  1791. item.discountSinglePrice || item.singlePrice;
  1792. item.discountTotalPrice = item.discountTotalPrice || item.totalPrice;
  1793. });
  1794. let discountTotalPrice = info?.redressProductList.reduce((num, cur) => {
  1795. return num + Number(cur.discountTotalPrice);
  1796. }, 0);
  1797. let form = {
  1798. contractVO: {
  1799. ...this.form,
  1800. partaName: cusInfo.base.name,
  1801. partaId: cusInfo.base.id,
  1802. partaUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
  1803. partaAddress: cusInfo.base.addressName + cusInfo.base.address,
  1804. partaLinkName: cusInfo.linkList[0]?.linkName,
  1805. partaLinkId: cusInfo.linkList[0]?.id,
  1806. partaTel: cusInfo.linkList[0]?.mobilePhone,
  1807. totalPrice: totalPrice,
  1808. discountTotalPrice: discountTotalPrice
  1809. },
  1810. productList: info.redressProductList || []
  1811. };
  1812. this.setValue(form);
  1813. },
  1814. //获取退货单详情
  1815. async getReturnOrderDetail(id) {
  1816. return Promise.resolve(await getReturnSaleOrderrecordDetail(id));
  1817. },
  1818. //查找合同分类对应name
  1819. findNameById(tree, targetId) {
  1820. for (let i = 0; i < tree.length; i++) {
  1821. const node = tree[i];
  1822. if (node.id === targetId) {
  1823. return node.name;
  1824. }
  1825. if (node.children && node.children.length > 0) {
  1826. const name = this.findNameById(node.children, targetId);
  1827. if (name) {
  1828. return name;
  1829. }
  1830. }
  1831. }
  1832. return null;
  1833. }
  1834. }
  1835. };
  1836. </script>
  1837. <style scoped lang="scss">
  1838. .TotalAmount {
  1839. font-size: 16px;
  1840. padding-right: 30px;
  1841. }
  1842. </style>