addDialog.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  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="80%"
  10. @close="cancel"
  11. >
  12. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  13. <headerTitle title="合同信息"></headerTitle>
  14. <el-row>
  15. <el-col :span="12">
  16. <el-form-item
  17. label="合同类型"
  18. prop="type"
  19. style="margin-bottom: 22px"
  20. >
  21. <!-- <DictSelection
  22. dictName="合同类型"
  23. clearable
  24. v-model="form.type"
  25. @itemChange="dictChange"
  26. :disabled="create"
  27. >
  28. </DictSelection> -->
  29. <el-select
  30. v-model="form.type"
  31. placeholder="请选择"
  32. style="width: 100%"
  33. @change="dictChange"
  34. >
  35. <el-option
  36. v-for="item in contractBookTypeList"
  37. :key="item.code"
  38. :label="item.name"
  39. :value="item.code"
  40. >
  41. </el-option>
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item
  45. label="来源类型"
  46. style="margin-bottom: 22px"
  47. v-if="form.type"
  48. >
  49. <el-select
  50. v-model="form.sourceType"
  51. placeholder="请选择"
  52. style="width: 100%"
  53. clearable
  54. @change="sourceTypeChange(form.type)"
  55. >
  56. <el-option
  57. v-if="item.parentId == form.type"
  58. v-for="item in sourceTypeList"
  59. :key="item.code"
  60. :label="item.name"
  61. :value="item.code"
  62. >
  63. </el-option>
  64. </el-select>
  65. </el-form-item>
  66. <el-form-item
  67. label="核价单"
  68. prop="sourceName"
  69. style="margin-bottom: 22px"
  70. v-if="form.sourceType == 2"
  71. >
  72. <el-input
  73. clearable
  74. v-model="form.sourceName"
  75. @click.native="handInquiry"
  76. placeholder="请输入"
  77. />
  78. </el-form-item>
  79. <el-form-item
  80. label="报价单"
  81. prop="sourceName"
  82. style="margin-bottom: 22px"
  83. v-if="form.sourceType == 1"
  84. >
  85. <el-input
  86. clearable
  87. v-model="form.sourceName"
  88. @click.native="handQuotation"
  89. placeholder="请输入"
  90. />
  91. </el-form-item>
  92. <el-form-item
  93. label="采购计划"
  94. prop="sourceName"
  95. style="margin-bottom: 22px"
  96. v-if="form.sourceType == 3"
  97. >
  98. <el-input
  99. clearable
  100. v-model="form.sourceName"
  101. @click.native="handPlan"
  102. placeholder="请输入"
  103. />
  104. </el-form-item>
  105. <el-form-item
  106. label="商机名称"
  107. prop="sourceName"
  108. style="margin-bottom: 22px"
  109. v-if="form.sourceType == 4"
  110. >
  111. <el-input
  112. clearable
  113. v-model="form.sourceName"
  114. @click.native="handOpportunity"
  115. placeholder="请输入"
  116. />
  117. </el-form-item>
  118. <el-form-item
  119. label="合同名称"
  120. prop="contractName"
  121. style="margin-bottom: 22px"
  122. >
  123. <el-input
  124. clearable
  125. v-model="form.contractName"
  126. placeholder="请输入"
  127. />
  128. </el-form-item>
  129. <el-form-item
  130. label="合同编号"
  131. prop="contractNumber"
  132. style="margin-bottom: 22px"
  133. >
  134. <el-input
  135. clearable
  136. v-model="form.contractNumber"
  137. placeholder="请输入"
  138. />
  139. </el-form-item>
  140. <el-form-item prop="contractFile" label="合同附件">
  141. <fileUpload
  142. v-model="form.contractFile"
  143. module="main"
  144. :showLib="false"
  145. :limit="10"
  146. />
  147. </el-form-item>
  148. </el-col>
  149. <el-col :span="12">
  150. <el-form-item
  151. label="合同分类"
  152. prop="categoryId"
  153. style="margin-bottom: 22px; width: 340px"
  154. >
  155. <!-- <ele-tree-select
  156. :data="categoryTreeList"
  157. v-model="form.categoryId"
  158. valueKey="id"
  159. labelKey="name"
  160. placeholder="请选择"
  161. default-expand-all
  162. /> -->
  163. <el-select
  164. v-model="form.categoryId"
  165. placeholder="请选择"
  166. style="width: 100%"
  167. >
  168. <el-option
  169. v-for="item in categoryList"
  170. :key="item.id"
  171. :label="item.name"
  172. :value="item.id"
  173. >
  174. </el-option>
  175. </el-select>
  176. </el-form-item>
  177. <el-form-item
  178. label="签订日期"
  179. prop="contractStartDate"
  180. style="margin-bottom: 22px"
  181. >
  182. <el-date-picker
  183. v-model="form.contractStartDate"
  184. @change="setDeliveryDays"
  185. type="date"
  186. placeholder="选择日期"
  187. >
  188. </el-date-picker>
  189. </el-form-item>
  190. <el-form-item
  191. label="结束日期"
  192. prop="contractEndDate"
  193. style="margin-bottom: 22px"
  194. >
  195. <el-date-picker
  196. v-model="form.contractEndDate"
  197. type="date"
  198. placeholder="选择日期"
  199. >
  200. </el-date-picker>
  201. </el-form-item>
  202. <el-form-item
  203. label="结算方式"
  204. prop="settlementMode"
  205. style="margin-bottom: 22px"
  206. >
  207. <!-- <el-select v-model="form.receiptPaymentType" placeholder="请选择">
  208. <el-option
  209. v-for="item in paymentTypeOptions"
  210. :key="item.id"
  211. :label="item.name"
  212. :value="item.id"
  213. >
  214. </el-option>
  215. </el-select> -->
  216. <DictSelection
  217. dictName="结算方式"
  218. clearable
  219. v-model="form.settlementMode"
  220. style="width: 220px"
  221. >
  222. </DictSelection>
  223. </el-form-item>
  224. <el-form-item
  225. label="计价方式"
  226. prop="pricingWay"
  227. style="margin-bottom: 22px"
  228. >
  229. <el-radio-group v-model="form.pricingWay" @change="changePricingWay">
  230. <el-radio v-for="item in pricingWayList" :label="item.id">{{ item.name }}</el-radio>
  231. </el-radio-group>
  232. </el-form-item>
  233. </el-col>
  234. </el-row>
  235. <headerTitle title="基本信息"></headerTitle>
  236. <el-row>
  237. <el-col :span="12">
  238. <el-form-item
  239. label="甲方名称"
  240. prop="partaName"
  241. style="margin-bottom: 22px"
  242. >
  243. <template v-if="form.type == '2'">
  244. <el-input
  245. clearable
  246. v-model="form.partaName"
  247. placeholder="请输入"
  248. v-if="enterprisePage.length <= 1"
  249. />
  250. <el-select
  251. v-if="enterprisePage.length > 1"
  252. style="width: 100%"
  253. v-model="form.partaName"
  254. placeholder="请选择"
  255. @change="getEnterprise(1)"
  256. >
  257. <el-option
  258. v-for="item in enterprisePage"
  259. :key="item.id"
  260. :label="item.name"
  261. :value="item.name"
  262. >
  263. </el-option>
  264. </el-select>
  265. </template>
  266. <template v-else>
  267. <el-input
  268. clearable
  269. v-model="form.partaName"
  270. @click.native="handParent"
  271. placeholder="请选择"
  272. />
  273. </template>
  274. </el-form-item>
  275. <el-form-item
  276. label="甲方统一社会信用代码"
  277. prop="partaUnifiedSocialCreditCode"
  278. label-width="160px"
  279. style="margin-bottom: 22px"
  280. >
  281. <el-input
  282. clearable
  283. v-model="form.partaUnifiedSocialCreditCode"
  284. placeholder="请输入"
  285. />
  286. </el-form-item>
  287. <el-form-item
  288. label="甲方联系人"
  289. prop="partaLinkName"
  290. style="margin-bottom: 22px"
  291. >
  292. <template v-if="form.type == '2'">
  293. <el-input
  294. clearable
  295. v-model="form.partaLinkName"
  296. @click.native="handHead"
  297. placeholder="请选择"
  298. />
  299. </template>
  300. <template v-else>
  301. <el-select
  302. v-model="form.partaLinkName"
  303. placeholder="请选择"
  304. @change="onchangeLink"
  305. @focus="selectFocus"
  306. >
  307. <el-option
  308. v-for="item in linkNameOptions"
  309. :key="item.id"
  310. :label="item.linkName"
  311. :value="item.id"
  312. >
  313. </el-option>
  314. </el-select>
  315. </template>
  316. </el-form-item>
  317. <el-form-item
  318. label="甲方电话"
  319. prop="partaTel"
  320. style="margin-bottom: 22px"
  321. >
  322. <el-input
  323. clearable
  324. :maxlength="20"
  325. v-model="form.partaTel"
  326. placeholder="请输入"
  327. />
  328. </el-form-item>
  329. <el-form-item
  330. label="甲方传真"
  331. prop="partaFax"
  332. style="margin-bottom: 22px"
  333. >
  334. <el-input clearable v-model="form.partaFax" placeholder="请输入"/>
  335. </el-form-item>
  336. <el-form-item
  337. label=" 甲方Email"
  338. prop="partaEmail"
  339. style="margin-bottom: 22px"
  340. >
  341. <el-input
  342. clearable
  343. v-model="form.partaEmail"
  344. placeholder="请输入"
  345. />
  346. </el-form-item>
  347. <el-form-item
  348. label="甲方地址"
  349. prop="partaAddress"
  350. style="margin-bottom: 22px"
  351. >
  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
  362. label="乙方名称"
  363. prop="partbName"
  364. style="margin-bottom: 22px"
  365. >
  366. <el-input
  367. clearable
  368. v-model="form.partbName"
  369. @click.native="handSupplier"
  370. placeholder="请输入"
  371. />
  372. </el-form-item>
  373. </template>
  374. <template v-else>
  375. <el-form-item
  376. label="乙方名称"
  377. prop="partbName"
  378. style="margin-bottom: 22px"
  379. >
  380. <el-input
  381. clearable
  382. v-model="form.partbName"
  383. placeholder="请输入"
  384. v-if="enterprisePage.length <= 1"
  385. />
  386. <el-select
  387. v-if="enterprisePage.length > 1"
  388. style="width: 100%"
  389. v-model="form.partbName"
  390. placeholder="请选择"
  391. @change="getEnterprise(1)"
  392. >
  393. <el-option
  394. v-for="item in enterprisePage"
  395. :key="item.id"
  396. :label="item.name"
  397. :value="item.name"
  398. >
  399. </el-option>
  400. </el-select>
  401. </el-form-item>
  402. </template>
  403. <el-form-item
  404. label="乙方统一社会信用代码"
  405. prop="partbUnifiedSocialCreditCode"
  406. label-width="160px"
  407. style="margin-bottom: 22px"
  408. >
  409. <el-input
  410. clearable
  411. v-model="form.partbUnifiedSocialCreditCode"
  412. placeholder="请输入"
  413. />
  414. </el-form-item>
  415. <el-form-item
  416. label="乙方联系人"
  417. prop="partbLinkName"
  418. style="margin-bottom: 22px"
  419. >
  420. <template v-if="form.type == '2'">
  421. <el-select
  422. v-model="form.partbLinkName"
  423. placeholder="请选择"
  424. @change="onchangeLink"
  425. @focus="selectFocus"
  426. >
  427. <el-option
  428. v-for="item in linkNameOptions"
  429. :key="item.id"
  430. :label="item.linkName"
  431. :value="item.id"
  432. >
  433. </el-option>
  434. </el-select>
  435. </template>
  436. <template v-else>
  437. <el-input
  438. clearable
  439. v-model="form.partbLinkName"
  440. @click.native="handHead"
  441. placeholder="请输入"
  442. />
  443. </template>
  444. </el-form-item>
  445. <el-form-item prop="partbTel" label="乙方联系电话">
  446. <el-input clearable v-model="form.partbTel" placeholder="请输入"/>
  447. </el-form-item>
  448. <el-form-item prop="partbFax" label="乙方传真">
  449. <el-input clearable v-model="form.partbFax" placeholder="请输入"/>
  450. </el-form-item>
  451. <el-form-item
  452. label="乙方Email"
  453. prop="partbEmail"
  454. style="margin-bottom: 22px"
  455. >
  456. <el-input
  457. clearable
  458. v-model="form.partbEmail"
  459. placeholder="请输入"
  460. />
  461. </el-form-item>
  462. <el-form-item
  463. label="乙方地址"
  464. prop="partbAddress"
  465. style="margin-bottom: 22px"
  466. >
  467. <el-input
  468. clearable
  469. v-model="form.partbAddress"
  470. placeholder="请输入"
  471. />
  472. </el-form-item>
  473. </el-col>
  474. </el-row>
  475. <headerTitle title="产品清单" style="margin-top: 30px"></headerTitle>
  476. <inventoryTable
  477. ref="inventoryTable"
  478. :contractStartDate="this.form.contractStartDate"
  479. :isCustomerMark="false"
  480. :isDiscountTotalPrice="true"
  481. :contractBookType="form.type"
  482. :pricingWay='form.pricingWay'
  483. ></inventoryTable>
  484. <headerTitle
  485. :title="form.type == '2' ? '付款方式' : '收款方式'"
  486. style="margin-top: 30px"
  487. ></headerTitle>
  488. <paymentList ref="paymentListTable"/>
  489. </el-form>
  490. <div slot="footer" class="footer">
  491. <el-button type="primary" @click="save">保存</el-button>
  492. <el-button type="primary" @click="save('sub')">提交</el-button>
  493. <el-button @click="cancel">返回</el-button>
  494. </div>
  495. <parentList ref="parentRef" @changeParent="changeParent"></parentList>
  496. <inquiryManageList
  497. ref="inquiryManageRef"
  498. @changeInquiryManageList="changeInquiryManageList"
  499. ></inquiryManageList>
  500. <inquiryList
  501. ref="inquiryListRef"
  502. @changeParent="changeInquiryList"
  503. ></inquiryList>
  504. <quotationList
  505. ref="quotationListRef"
  506. @changeParent="changeInquiryList"
  507. ></quotationList>
  508. <supplierList
  509. ref="supplierListRef"
  510. :classType="2"
  511. @changeParent="changeSupplier"
  512. ></supplierList>
  513. <head-list ref="headRef" @changeParent="changePersonel"></head-list>
  514. <!-- 商机 -->
  515. <opportunity-dialog :opportunityDialogFlag.sync="opportunityDialogFlag" v-if="opportunityDialogFlag"
  516. ref="opportunityDialogRef" @changeParent="getOpportunityDetail"></opportunity-dialog>
  517. </ele-modal>
  518. </template>
  519. <script>
  520. import {emailReg, phoneReg, numberReg} from 'ele-admin';
  521. import {acceptUnpackoptions} from '@/enum/dict';
  522. import inventoryTable from './inventoryTable.vue';
  523. import inquiryList from './inquiryList.vue';
  524. import quotationList from './quotationList.vue';
  525. import fileUpload from '@/components/upload/fileUpload';
  526. import dictMixins from '@/mixins/dictMixins';
  527. import parentList from '@/views/saleManage/contact/components/parentList.vue';
  528. import {
  529. getDetail,
  530. UpdateInformation,
  531. addInformation,
  532. submit
  533. } from '@/api/contractManage/contractBook';
  534. import {contactDetail} from '@/api/saleManage/contact';
  535. import {getDetail as getOpportunityInfo} from '@/api/saleManage/businessOpportunity';
  536. import {getcontactlink} from '@/api/saleManage/businessFollow';
  537. import headList from '@/views/saleManage/businessOpportunity/components/headList.vue';
  538. import supplierList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  539. import paymentList from './paymentList.vue';
  540. import {copyObj} from '@/utils/util';
  541. import {enterprisePage} from '@/api/contractManage/contractBook';
  542. import inquiryManageList from "@/views/purchasingManage/inquiryManage/components/inquiryManage-list.vue";
  543. import {getplanDetail} from "@/api/purchasingManage/purchasePlanManage";
  544. import opportunityDialog from "@/views/financialManage/feeManage/feeApplication/opportunityDialog.vue";
  545. import {getOpportunityDetail} from "@/api/saleManage/businessOpportunity";
  546. export default {
  547. props: {
  548. categoryTreeList: Array
  549. },
  550. mixins: [dictMixins],
  551. components: {
  552. opportunityDialog,
  553. inquiryManageList,
  554. fileUpload,
  555. headList,
  556. paymentList,
  557. inventoryTable,
  558. supplierList,
  559. parentList,
  560. inquiryList,
  561. quotationList
  562. },
  563. data() {
  564. let formDef = {
  565. id: '',
  566. contractEndDate: '',
  567. contractFile: [],
  568. contractName: '',
  569. contractNumber: '',
  570. contractStartDate: '',
  571. opportunityId: '',
  572. categoryName: '',
  573. categoryId: '',
  574. sourceId: '',
  575. sourceType: '',
  576. sourceName: '',
  577. partaUnifiedSocialCreditCode: '',
  578. partbUnifiedSocialCreditCode: '',
  579. partaAddress: '',
  580. partaEmail: '',
  581. partaFax: '',
  582. partaId: '',
  583. partaLinkId: '',
  584. partaLinkName: '',
  585. partaName: '',
  586. partaTel: '',
  587. partbAddress: '',
  588. partbEmail: '',
  589. partbFax: '',
  590. partbId: '',
  591. partbLinkId: '',
  592. partbLinkName: '',
  593. partbName: '',
  594. partbTel: '',
  595. settlementModeName: '结算方式',
  596. settlementMode: '4',
  597. pricingWay: 1,
  598. totalPrice: null,
  599. type: '', //1=销售合同 2=采购合同
  600. typeName: ''
  601. };
  602. return {
  603. payWayOptions: [],
  604. delDetailIds: [],
  605. paymentTypeOptions: [
  606. {id: 1, name: '固定'},
  607. {id: 2, name: '分期'}
  608. ],
  609. pricingWayList: [
  610. {id: 1, name: '按数量计价'},
  611. {id: 2, name: '按重量计价'}
  612. ],
  613. contractBookTypeList: [],
  614. sourceTypeList: [
  615. {
  616. code: 1,
  617. name: '报价单',
  618. parentId: '1',
  619. },
  620. {
  621. code: 2,
  622. name: '核价单',
  623. parentId: '2',
  624. },
  625. {
  626. code: 3,
  627. name: '采购计划',
  628. parentId: '2',
  629. },
  630. {
  631. code: 4,
  632. name: '商机',
  633. parentId: '1',
  634. },
  635. ],
  636. categoryList: [],
  637. linkNameOptions: [],
  638. acceptUnpackoptions,
  639. visible: false,
  640. opportunityDialogFlag: false,
  641. title: '',
  642. row: {},
  643. activeName: 'base',
  644. formDef,
  645. form: copyObj(formDef),
  646. // removeBankList: [],
  647. // removeLinkList: [],
  648. tableBankData: [],
  649. tableLinkData: [],
  650. rules: {
  651. type: [
  652. {required: true, message: '请选择合同类型', trigger: 'change'}
  653. ],
  654. settlementMode: [
  655. {required: true, message: '请选择合结算方式', trigger: 'change'}
  656. ],
  657. categoryId: [
  658. {required: true, message: '请选择合同分类', trigger: 'change'}
  659. ],
  660. contractNumber: [
  661. {required: true, message: '请输入自带编号', trigger: 'change'}
  662. ],
  663. contractName: [
  664. {required: true, message: '请输入合同名称', trigger: 'blur'}
  665. ],
  666. partaName: [
  667. {required: true, message: '请选择甲方名称', trigger: 'change'}
  668. ],
  669. partaLinkName: [
  670. {required: true, message: '请选择甲方联系人', trigger: 'change'}
  671. ],
  672. acceptUnpack: [
  673. {required: true, message: '请选择是否接受', trigger: 'change'}
  674. ],
  675. partaTel: [
  676. {
  677. required: true,
  678. pattern: numberReg,
  679. message: '请输入甲方联系电话',
  680. trigger: 'blur'
  681. }
  682. ],
  683. deliveryDate: [
  684. {required: true, message: '请选择交货日期', trigger: 'change'}
  685. ],
  686. partbName: [
  687. {required: true, message: '请输入乙方名称', trigger: 'change'}
  688. ],
  689. partbLinkName: [
  690. {required: true, message: '请输入乙方联系人', trigger: 'change'}
  691. ],
  692. partbTel: [
  693. {
  694. required: true,
  695. pattern: numberReg,
  696. message: '请输入乙方联系电话',
  697. trigger: 'blur'
  698. }
  699. ],
  700. partaEmail: [
  701. {pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur'}
  702. ],
  703. contractStartDate: [
  704. {required: true, message: '请选择签订日期', trigger: 'change'}
  705. ],
  706. contractEndDate: [
  707. {validator: this.validateEndDate, trigger: 'blur'}
  708. ]
  709. },
  710. enterprise: {
  711. address: '',
  712. unifiedSocialCreditCode: '',
  713. tel: '',
  714. name: ''
  715. },
  716. // 提交状态
  717. loading: false,
  718. // 是否是修改
  719. isUpdate: false,
  720. enterprisePage: [],
  721. create: false,
  722. businessId: ''
  723. };
  724. },
  725. created() {
  726. enterprisePage({
  727. pageNum: 1,
  728. size: 200
  729. }).then((res) => {
  730. this.enterprisePage = [];
  731. this.enterprisePage.push(...res.list);
  732. this.getEnterprise();
  733. });
  734. },
  735. methods: {
  736. //开始日期验证
  737. validateStartDate(rule, value, callback) {
  738. if (this.form.contractEndDate && value > this.form.contractEndDate) {
  739. callback(new Error('开始日期不能大于结束日期'));
  740. } else {
  741. callback();
  742. }
  743. },
  744. //结束日期验证
  745. validateEndDate(rule, value, callback) {
  746. if (
  747. this.form.contractEndDate &&
  748. this.form.contractStartDate &&
  749. value < this.form.contractStartDate
  750. ) {
  751. callback(new Error('结束日期不能小于开始日期'));
  752. } else {
  753. callback();
  754. }
  755. },
  756. //选择供应商
  757. changeSupplier(obj) {
  758. this.form = Object.assign({}, this.form, {
  759. partbId: obj.id,
  760. partbName: obj.name,
  761. partbAddress: obj.addressName + obj.address,
  762. partbLinkId: '',
  763. partbLinkName: '',
  764. partbEmail: '',
  765. partbTel: ''
  766. });
  767. this.getLinkInfo(obj.id);
  768. },
  769. //获取详情
  770. async getDetailData(id) {
  771. this.businessId = id;
  772. this.loading = true;
  773. const data = await getDetail(id);
  774. this.loading = false;
  775. if (data) {
  776. this.$nextTick(() => {
  777. let {contractVO} = data;
  778. this.dictChange(contractVO.type, 'init');
  779. this.form = contractVO;
  780. this.$refs.inventoryTable &&
  781. this.$refs.inventoryTable.putTableValue(data);
  782. this.$refs.paymentListTable &&
  783. this.$refs.paymentListTable.putTableValue(
  784. data.receiptPaymentList
  785. );
  786. this.getLinkInfo(
  787. contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
  788. );
  789. });
  790. }
  791. },
  792. //签订日期 更新
  793. setDeliveryDays() {
  794. this.$refs.inventoryTable.setDeliveryDays('', '', '', true);
  795. },
  796. //更新联系人数据
  797. async getLinkInfo(contactId) {
  798. const data = await getcontactlink({contactId});
  799. if (data && data?.length) {
  800. this.linkNameOptions = data;
  801. }
  802. },
  803. selectFocus() {
  804. if (this.linkNameOptions.length === 0) {
  805. return this.$message.error('请先选择名称');
  806. }
  807. },
  808. //选择合同类型
  809. dictChange(val, type) {
  810. this.categoryList = copyObj(
  811. this.contractBookTypeList.find((item) => item.code == val).children
  812. );
  813. if (type == 'init') {
  814. return;
  815. }
  816. let typeName = ''
  817. if (val) typeName = this.contractBookTypeList.find(item => item.code == val)?.name || ''
  818. this.form = Object.assign({}, this.form, {
  819. typeName: typeName || val.dictValue,
  820. contractName: '',
  821. sourceType: '',
  822. sourceId: '',
  823. sourceName: '',
  824. partaAddress: '',
  825. partaEmail: '',
  826. partaFax: '',
  827. partaId: '',
  828. partaLinkId: '',
  829. partaLinkName: '',
  830. partaName: '',
  831. partaTel: '',
  832. partbAddress: '',
  833. partbEmail: '',
  834. partbFax: '',
  835. partbId: '',
  836. partbLinkId: '',
  837. partbLinkName: '',
  838. partbName: '',
  839. partbTel: '',
  840. partaUnifiedSocialCreditCode: '',
  841. partbUnifiedSocialCreditCode: '',
  842. categoryName: '',
  843. categoryId: ''
  844. });
  845. this.getEnterprise();
  846. this.changePersonel();
  847. },
  848. //选择来源类型
  849. sourceTypeChange(val, type) {
  850. this.form = Object.assign({}, this.form, {
  851. contractName: '',
  852. sourceId: '',
  853. sourceName: '',
  854. partaAddress: '',
  855. partaEmail: '',
  856. partaFax: '',
  857. partaId: '',
  858. partaLinkId: '',
  859. partaLinkName: '',
  860. partaName: '',
  861. partaTel: '',
  862. partbAddress: '',
  863. partbEmail: '',
  864. partbFax: '',
  865. partbId: '',
  866. partbLinkId: '',
  867. partbLinkName: '',
  868. partbName: '',
  869. partbTel: '',
  870. partaUnifiedSocialCreditCode: '',
  871. partbUnifiedSocialCreditCode: '',
  872. // categoryName: '',
  873. // categoryId: ''
  874. });
  875. this.getEnterprise();
  876. this.changePersonel();
  877. },
  878. getEnterprise(type) {
  879. let key = this.form.type == '1' || !this.form.type ? 'partb' : 'parta';
  880. let keyArr = [
  881. key + 'Name',
  882. key + 'UnifiedSocialCreditCode',
  883. key + 'Fax',
  884. key + 'Address'
  885. ];
  886. if (type === 1) {
  887. let data = this.enterprisePage.find(
  888. (item) => item.name == this.form[keyArr[0]]
  889. );
  890. this.form[keyArr[0]] = data.name;
  891. this.form[keyArr[1]] = data.unifiedSocialCreditCode;
  892. this.form[keyArr[2]] = data.fax;
  893. this.form[keyArr[3]] = data.address;
  894. return;
  895. }
  896. if (this.enterprisePage.length > 0) {
  897. this.form[keyArr[0]] =
  898. this.form[keyArr[0]] || this.enterprisePage[0].name;
  899. this.form[keyArr[1]] =
  900. this.form[keyArr[1]] ||
  901. this.enterprisePage[0].unifiedSocialCreditCode;
  902. this.form[keyArr[2]] =
  903. this.form[keyArr[2]] || this.enterprisePage[0].fax;
  904. this.form[keyArr[3]] =
  905. this.form[keyArr[3]] || this.enterprisePage[0].address;
  906. }
  907. },
  908. //选择合同分类
  909. // treeChange(val) {
  910. // //这里eladmin组件有bug,要手动验证下
  911. // this.$set(this.form, 'categoryId', val);
  912. // this.$refs.form.validateField('categoryId');
  913. // },
  914. //选择下拉框
  915. onchangeLink(selectedOptions) {
  916. if (this.form.type == '2') {
  917. const option = this.linkNameOptions.find(
  918. (opt) => opt.id === selectedOptions
  919. );
  920. this.form = Object.assign({}, this.form, {
  921. partbEmail: option?.email,
  922. partbLinkName: option?.linkName || '',
  923. partbTel: option?.mobilePhone || option?.phone || '',
  924. partbLinkId: option?.id
  925. });
  926. } else {
  927. const option = this.linkNameOptions.find(
  928. (opt) => opt.id === selectedOptions
  929. );
  930. this.form = Object.assign({}, this.form, {
  931. partaEmail: option?.email,
  932. partaLinkName: option?.linkName || '',
  933. partaTel: option?.mobilePhone || option?.phone || '',
  934. partaLinkId: option?.id
  935. });
  936. }
  937. },
  938. handHead(title) {
  939. if (this.form.type == '2') {
  940. let item = {
  941. id: this.form.partaLinkId
  942. };
  943. this.$refs.headRef.open(item);
  944. } else {
  945. let item = {
  946. id: this.form.partbLinkId
  947. };
  948. this.$refs.headRef.open(item);
  949. }
  950. },
  951. //选择乙方人和采购合同下的甲方人回调
  952. changePersonel(obj, index, title) {
  953. if (!obj) {
  954. obj = this.$store.getters.user.info;
  955. obj.id = obj.userId;
  956. }
  957. if (this.form.type == '2') {
  958. this.$set(this.form, 'partaLinkId', obj.id);
  959. this.$set(this.form, 'partaLinkName', obj.name);
  960. this.$set(this.form, 'partaTel', obj.phone);
  961. this.$set(this.form, 'partaEmail', obj.email);
  962. } else {
  963. this.$set(this.form, 'partbLinkId', obj.id);
  964. this.$set(this.form, 'partbLinkName', obj.name);
  965. this.$set(this.form, 'partbTel', obj.phone);
  966. this.$set(this.form, 'partbEmail', obj.email);
  967. }
  968. },
  969. //选择客户回调
  970. changeParent(obj) {
  971. console.log(obj, 'obj');
  972. this.form = Object.assign({}, this.form, {
  973. partaId: obj.id,
  974. partaName: obj.name,
  975. partaAddress: obj.addressName + obj.address,
  976. partaLinkId: '',
  977. partaLinkName: '',
  978. partaEmail: '',
  979. partaTel: '',
  980. //contractName: obj.name,
  981. partaUnifiedSocialCreditCode: obj.unifiedSocialCreditCode
  982. });
  983. this.getLinkInfo(obj.id);
  984. },
  985. //选择采购合同的乙方
  986. handSupplier() {
  987. let item = {
  988. id: this.form.partbId
  989. };
  990. this.$refs.supplierListRef.open(item);
  991. },
  992. handParent() {
  993. let item = {
  994. id: this.form.contactId
  995. };
  996. this.$refs.parentRef.open(item);
  997. },
  998. async open(type, row, create = false) {
  999. this.title = type === 'add' ? '新增' : '修改';
  1000. this.row = row;
  1001. this.visible = true;
  1002. this.create = create;
  1003. this.contractBookTypeList = copyObj(this.categoryTreeList[0].children);
  1004. if (type == 'add') {
  1005. let userInfo = this.$store.getters.user.info;
  1006. this.isUpdate = false;
  1007. userInfo.id = userInfo.userId;
  1008. this.changePersonel();
  1009. this.form.contractStartDate = new Date()
  1010. if (row?.contractVO?.type) {
  1011. this.dictChange(row.contractVO.type, 'init');
  1012. }
  1013. this.$nextTick(() => {
  1014. this.$refs.paymentListTable.defaultList()
  1015. })
  1016. if (create) {
  1017. this.create = create;
  1018. //核价单生成的合同
  1019. this.$nextTick(() => {
  1020. this.setValue(row);
  1021. });
  1022. }
  1023. } else {
  1024. this.isUpdate = true;
  1025. this.getDetailData(row.id);
  1026. }
  1027. },
  1028. //赋值
  1029. setValue(row) {
  1030. let {contractVO} = row;
  1031. contractVO = {
  1032. ...contractVO,
  1033. categoryId: contractVO.categoryId || this.form.categoryId,
  1034. categoryName: contractVO.categoryName || this.form.categoryName,
  1035. contractStartDate: contractVO.contractStartDate || this.form.contractStartDate,
  1036. contractEndDate: contractVO.contractEndDate || this.form.contractEndDate,
  1037. pricingWay: 1,
  1038. }
  1039. this.form = contractVO;
  1040. this.$refs.inventoryTable &&
  1041. this.$refs.inventoryTable.putTableValue(row);
  1042. this.$refs.paymentListTable &&
  1043. this.$refs.paymentListTable.putTableValue(row.receiptPaymentList);
  1044. this.getEnterprise();
  1045. this.getLinkInfo(
  1046. contractVO.type == '2' ? contractVO.partbId : contractVO.partaId
  1047. );
  1048. },
  1049. //切换计费方式重新算费用
  1050. changePricingWay() {
  1051. this.$refs.inventoryTable.getTotalPrice()
  1052. },
  1053. salesmanChange(val, info) {
  1054. this.otherForm.salesmanName = info.name;
  1055. },
  1056. ifChiefChange(value, idx) {
  1057. if (value === 1) {
  1058. this.tableLinkData.forEach((e) => (e.ifChief = 0));
  1059. this.tableLinkData[idx].ifChief = 1;
  1060. }
  1061. },
  1062. // getValidate() {
  1063. // return new Promise((resolve, reject) => {
  1064. // this.$refs.form.validate((valid) => {
  1065. // if (!valid) {
  1066. // reject(false);
  1067. // } else {
  1068. // resolve(true);
  1069. // }
  1070. // });
  1071. // });
  1072. // },
  1073. getValidate() {
  1074. return Promise.all([
  1075. new Promise((resolve, reject) => {
  1076. this.$refs.form.validate((valid) => {
  1077. if (!valid) {
  1078. reject(false);
  1079. } else {
  1080. resolve(true);
  1081. }
  1082. });
  1083. }),
  1084. new Promise((resolve, reject) => {
  1085. this.$refs.inventoryTable.validateForm((valid) => {
  1086. if (!valid) {
  1087. reject(false);
  1088. } else {
  1089. resolve(true);
  1090. }
  1091. });
  1092. }),
  1093. new Promise((resolve, reject) => {
  1094. this.$refs.paymentListTable.validateForm((valid) => {
  1095. if (!valid) {
  1096. reject(false);
  1097. } else {
  1098. resolve(true);
  1099. }
  1100. });
  1101. })
  1102. ]);
  1103. },
  1104. async save(type) {
  1105. try {
  1106. await this.getValidate();
  1107. // 表单验证通过,执行保存操作
  1108. this.loading = true;
  1109. if (!this.isUpdate) {
  1110. delete this.form.id;
  1111. }
  1112. let [totalPrice, discountTotalPrice] = this.$refs.inventoryTable.getPrice();
  1113. this.form.totalPrice = totalPrice;
  1114. this.form.discountTotalPrice = discountTotalPrice;
  1115. if (this.form.categoryId) {
  1116. this.form.categoryName = this.findNameById(
  1117. this.categoryTreeList,
  1118. this.form.categoryId
  1119. );
  1120. }
  1121. this.form.settlementModeName = this.getDictValue(
  1122. '结算方式',
  1123. this.form.settlementMode
  1124. );
  1125. let commitData = Object.assign(
  1126. {},
  1127. {
  1128. contract: this.form,
  1129. productList: this.$refs.inventoryTable.getTableValue(),
  1130. receiptPaymentList: this.$refs.paymentListTable.getTableValue()
  1131. }
  1132. );
  1133. if (this.isUpdate) {
  1134. UpdateInformation(commitData)
  1135. .then((res) => {
  1136. this.loading = false;
  1137. this.$message.success('修改成功');
  1138. if (type === 'sub') {
  1139. this.contractBookSubmit(res);
  1140. return;
  1141. }
  1142. this.cancel();
  1143. this.$emit('done');
  1144. })
  1145. .catch((e) => {
  1146. //this.loading = false;
  1147. });
  1148. } else {
  1149. addInformation(commitData)
  1150. .then((res) => {
  1151. this.loading = false;
  1152. this.$message.success('新增成功');
  1153. if (type === 'sub') {
  1154. this.contractBookSubmit(res);
  1155. return;
  1156. }
  1157. this.cancel();
  1158. this.$emit('done');
  1159. })
  1160. .catch((e) => {
  1161. //this.loading = false;
  1162. });
  1163. }
  1164. } catch (error) {
  1165. console.log(error);
  1166. // 表单验证未通过,不执行保存操作
  1167. }
  1168. },
  1169. contractBookSubmit(res) {
  1170. submit({
  1171. businessId: this.businessId || res,
  1172. businessType: this.form.type
  1173. // productionSupervisorId
  1174. }).then((res) => {
  1175. this.cancel();
  1176. this.$emit('done');
  1177. });
  1178. },
  1179. handInquiry(e) {
  1180. if (e.target.nodeName == "I") {
  1181. this.$set(this.form, 'sourceName', '');
  1182. this.$set(this.form, 'sourceId', '');
  1183. return
  1184. }
  1185. this.$refs.inquiryListRef.open();
  1186. },
  1187. handQuotation(e) {
  1188. if (e.target.nodeName == "I") {
  1189. this.$set(this.form, 'sourceName', '');
  1190. this.$set(this.form, 'sourceId', '');
  1191. return
  1192. }
  1193. this.$refs.quotationListRef.open();
  1194. },
  1195. async changeInquiryList({data, sourceCode}) {
  1196. this.setValue(data);
  1197. this.$set(this.form, 'sourceName', sourceCode);
  1198. this.$set(this.form, 'sourceId', data.id);
  1199. let contactId = this.form.type == 2 ? data.contractVO.partbId : data.contractVO.partaId
  1200. let {base} = await contactDetail(contactId)
  1201. this.$set(this.form, 'contractName', base.simpleName);
  1202. },
  1203. //选择采购计划
  1204. handPlan(e) {
  1205. if (e.target.nodeName == "I") {
  1206. this.$set(this.form, 'sourceName', '');
  1207. this.$set(this.form, 'sourceId', '');
  1208. return
  1209. }
  1210. this.$refs.inquiryManageRef.open();
  1211. },
  1212. //选择采购计划回调
  1213. async changeInquiryManageList(data) {
  1214. let info = await this.getPlanInfo(data.id)
  1215. let cusInfo = {}
  1216. // if (info.detailList.length) cusInfo = await this.getCusInfo(info.detailList[0]?.supplierId ?? '');
  1217. this.$set(this.form, 'sourceName', data.planName);
  1218. this.$set(this.form, 'sourceId', data.id);
  1219. // this.$set(this.form, 'contractName', cusInfo?.base?.simpleName);
  1220. let form = {
  1221. contractVO: {
  1222. ...this.form,
  1223. // partbName: cusInfo.base.name,
  1224. // partbId: cusInfo.base.id,
  1225. // partbUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
  1226. // partbAddress: cusInfo.base.addressName + cusInfo.base.address,
  1227. // partbLinkName: cusInfo.linkList[0]?.linkName,
  1228. // partbLinkId: cusInfo.linkList[0]?.id,
  1229. // partbTel: cusInfo.linkList[0]?.mobilePhone,
  1230. },
  1231. productList: info.detailList || []
  1232. }
  1233. this.setValue(form);
  1234. // await this.getLinkInfo(cusInfo.base.id)
  1235. },
  1236. //获取计划详情
  1237. async getPlanInfo(id) {
  1238. return Promise.resolve(await getplanDetail(id))
  1239. },
  1240. //获取客户详情
  1241. async getCusInfo(id = '') {
  1242. if (!id) return
  1243. return Promise.resolve(await contactDetail(id))
  1244. },
  1245. //选择商机
  1246. handOpportunity(e) {
  1247. if (e.target.nodeName == "I") {
  1248. this.$set(this.form, 'sourceName', '');
  1249. this.$set(this.form, 'sourceId', '');
  1250. return
  1251. }
  1252. this.opportunityDialogFlag = true
  1253. this.$nextTick(() => {
  1254. let item = {
  1255. id: this.form.sourceId
  1256. }
  1257. this.$refs.opportunityDialogRef.init(item)
  1258. })
  1259. },
  1260. //获取商机信息
  1261. async getOpportunityDetail(row) {
  1262. this.$set(this.form, 'sourceName', row.name);
  1263. this.$set(this.form, 'sourceId', row.id);
  1264. let cusInfo = await this.getCusInfo(row?.contactId ?? '');
  1265. let info = await this.getOpportunityDetailData(row?.id ?? '');
  1266. await this.getLinkInfo(cusInfo.base.id)
  1267. let totalPrice = info.productList.reduce((num, cur) => {
  1268. return num + Number(cur.totalPrice);
  1269. }, 0)
  1270. info.productList.forEach((item) => {
  1271. item.discountSinglePrice = item.discountSinglePrice || item.singlePrice
  1272. item.discountTotalPrice = item.discountTotalPrice || item.totalPrice
  1273. })
  1274. let discountTotalPrice = info.productList.reduce((num, cur) => {
  1275. return num + Number(cur.discountTotalPrice);
  1276. }, 0)
  1277. let form = {
  1278. contractVO: {
  1279. ...this.form,
  1280. partaName: cusInfo.base.name,
  1281. partaId: cusInfo.base.id,
  1282. partaUnifiedSocialCreditCode: cusInfo.base.unifiedSocialCreditCode,
  1283. partaAddress: cusInfo.base.addressName + cusInfo.base.address,
  1284. partaLinkName: cusInfo.linkList[0]?.linkName,
  1285. partaLinkId: cusInfo.linkList[0]?.id,
  1286. partaTel: cusInfo.linkList[0]?.mobilePhone,
  1287. totalPrice: totalPrice,
  1288. discountTotalPrice: discountTotalPrice,
  1289. },
  1290. productList: info.productList || []
  1291. }
  1292. this.setValue(form);
  1293. },
  1294. //获取商机详情
  1295. async getOpportunityDetailData(id) {
  1296. return Promise.resolve(await getOpportunityInfo(id))
  1297. },
  1298. cancel() {
  1299. this.$nextTick(() => {
  1300. this.activeName = 'base';
  1301. // 关闭后,销毁所有的表单数据
  1302. this.$refs['otherForm'] && this.$refs['otherForm'].resetFields();
  1303. this.$refs['formRef'] && this.$refs['formRef'].resetFields();
  1304. this.form = copyObj(this.formDef);
  1305. this.$store.commit('concact/setDiscountAmount', 0);
  1306. this.visible = false;
  1307. });
  1308. },
  1309. //查找合同分类对应name
  1310. findNameById(tree, targetId) {
  1311. for (let i = 0; i < tree.length; i++) {
  1312. const node = tree[i];
  1313. if (node.id === targetId) {
  1314. return node.name;
  1315. }
  1316. if (node.children && node.children.length > 0) {
  1317. const name = this.findNameById(node.children, targetId);
  1318. if (name) {
  1319. return name;
  1320. }
  1321. }
  1322. }
  1323. return null;
  1324. }
  1325. }
  1326. };
  1327. </script>
  1328. <style scoped lang="scss">
  1329. .TotalAmount {
  1330. font-size: 16px;
  1331. padding-right: 30px;
  1332. }
  1333. </style>