addDialog.vue 82 KB

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