addDialog.vue 58 KB

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