addDialogNew.vue 82 KB

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