addDialogNew.vue 81 KB

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