addDialog.vue 69 KB

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