Purchase.vue 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <byForm
  4. :formConfig="formConfig"
  5. :formOption="formOption"
  6. v-model="formData.data"
  7. :rules="rules"
  8. ref="submit"
  9. >
  10. <template #buyer>
  11. <div style="width: 100%">
  12. <el-form-item prop="buyCorporationId">
  13. <el-select
  14. v-model="formData.data.buyCorporationId"
  15. style="width: 100%"
  16. @change="changeBuyCorporation"
  17. >
  18. <el-option
  19. v-for="item in corporationList"
  20. :key="item.value"
  21. :label="item.label"
  22. :value="item.value"
  23. />
  24. </el-select>
  25. </el-form-item>
  26. <el-row style="margin-top: 20px; width: 100%">
  27. <el-col :span="8">
  28. <el-form-item label="地址" prop="buyCountryName">
  29. <el-input
  30. v-model="formData.data.buyCountryName"
  31. placeholder="请输入国家"
  32. @change="changeAddress"
  33. />
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="8">
  37. <el-form-item label=" " prop="buyProvinceName">
  38. <el-input
  39. v-model="formData.data.buyProvinceName"
  40. placeholder="请输入省/州"
  41. @change="changeAddress"
  42. />
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="8">
  46. <el-form-item label=" " prop="buyCityName">
  47. <el-input
  48. v-model="formData.data.buyCityName"
  49. placeholder="请输入城市"
  50. @change="changeAddress"
  51. />
  52. </el-form-item>
  53. </el-col>
  54. </el-row>
  55. <el-row style="margin-top: 20px; width: 100%">
  56. <el-col :span="24">
  57. <el-form-item prop="buyAddress">
  58. <el-input
  59. v-model="formData.data.buyAddress"
  60. type="textarea"
  61. @change="changeAddress"
  62. />
  63. </el-form-item>
  64. </el-col>
  65. </el-row>
  66. <el-row style="margin-top: 20px; width: 100%">
  67. <el-col :span="8">
  68. <el-form-item label="联系人" prop="buyContactName">
  69. <el-input
  70. v-model="formData.data.buyContactName"
  71. placeholder="请输入联系人"
  72. />
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="16">
  76. <el-form-item label=" " prop="buyContactNumber">
  77. <el-input
  78. v-model="formData.data.buyContactNumber"
  79. placeholder="请输入联系人电话"
  80. />
  81. </el-form-item>
  82. </el-col>
  83. </el-row>
  84. </div>
  85. </template>
  86. <template #seller>
  87. <div style="width: 100%">
  88. <div style="width: 100%">
  89. <el-form-item prop="sellCorporationId">
  90. <el-select
  91. v-model="formData.data.sellCorporationId"
  92. style="width: 100%"
  93. filterable
  94. remote
  95. reserve-keyword
  96. placeholder="请输入关键字"
  97. remote-show-suffix
  98. :remote-method="remoteMethod"
  99. :loading="loadingSearch"
  100. @input="remoteMethod"
  101. @change="changeSupplier"
  102. v-if="
  103. [30].includes(route.query.processType) ||
  104. !route.query.processType
  105. "
  106. >
  107. <el-option
  108. v-for="item in supplierList"
  109. :key="item.value"
  110. :label="item.label"
  111. :value="item.value"
  112. />
  113. </el-select>
  114. <el-select
  115. v-model="formData.data.sellCorporationName"
  116. disabled
  117. v-else
  118. style="width: 100%"
  119. >
  120. </el-select>
  121. </el-form-item>
  122. <el-row style="margin-top: 20px; width: 100%">
  123. <el-col :span="6">
  124. <el-form-item label="地址" prop="countryId">
  125. <el-select
  126. v-model="formData.data.countryId"
  127. placeholder="国家"
  128. filterable
  129. @change="(val) => changeSellAddress(val, '20')"
  130. >
  131. <el-option
  132. v-for="item in countryData"
  133. :label="item.chineseName"
  134. :value="item.id"
  135. >
  136. </el-option>
  137. </el-select>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="6">
  141. <el-form-item label=" " prop="provinceName">
  142. <selectCity
  143. placeholder="省/洲"
  144. @change="(val) => changeSellAddress(val, '30')"
  145. addressId="provinceId"
  146. addressName="provinceName"
  147. v-model="formData.data"
  148. :data="provinceData"
  149. >
  150. </selectCity>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="6">
  154. <el-form-item label=" " prop="cityName">
  155. <selectCity
  156. placeholder="城市"
  157. addressId="cityId"
  158. addressName="cityName"
  159. v-model="formData.data"
  160. :data="cityData"
  161. @change="changeAddress"
  162. >
  163. </selectCity>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="6">
  167. <el-form-item label=" " prop="sellPostalCode">
  168. <el-input
  169. v-model="formData.data.sellPostalCode"
  170. placeholder="请输入邮编"
  171. />
  172. </el-form-item>
  173. </el-col>
  174. </el-row>
  175. <el-row style="margin-top: 20px; width: 100%">
  176. <el-col :span="24">
  177. <el-form-item prop="sellAddress">
  178. <el-input
  179. v-model="formData.data.sellAddress"
  180. type="textarea"
  181. @change="changeAddress"
  182. />
  183. </el-form-item>
  184. </el-col>
  185. </el-row>
  186. <el-row style="margin-top: 20px; width: 100%">
  187. <el-col :span="8">
  188. <el-form-item label="联系人" prop="sellContactName">
  189. <el-input
  190. v-model="formData.data.sellContactName"
  191. placeholder="请输入联系人"
  192. />
  193. </el-form-item>
  194. </el-col>
  195. <el-col :span="16">
  196. <el-form-item label=" " prop="sellContactNumber">
  197. <el-input
  198. v-model="formData.data.sellContactNumber"
  199. placeholder="请输入联系人电话"
  200. />
  201. </el-form-item>
  202. </el-col>
  203. </el-row>
  204. </div>
  205. </div>
  206. </template>
  207. <template #payment>
  208. <div style="width: 100%">
  209. <el-row style="margin-top: 20px; width: 100%">
  210. <el-col :span="6">
  211. <el-form-item label="付款方式" prop="paymentMethod">
  212. <el-select
  213. v-model="formData.data.paymentMethod"
  214. placeholder="请选择付款方式"
  215. style="width: 100%"
  216. >
  217. <el-option
  218. v-for="item in fundsPaymentMethod"
  219. :key="item.value"
  220. :label="item.label"
  221. :value="item.value"
  222. />
  223. </el-select>
  224. </el-form-item>
  225. </el-col>
  226. <el-col :span="6">
  227. <el-form-item label="发票类型" prop="invoiceType">
  228. <el-select
  229. v-model="formData.data.invoiceType"
  230. placeholder="请选择发票类型"
  231. style="width: 100%"
  232. >
  233. <el-option
  234. v-for="item in invoiceType"
  235. :key="item.value"
  236. :label="item.label"
  237. :value="item.value"
  238. />
  239. </el-select>
  240. </el-form-item>
  241. </el-col>
  242. </el-row>
  243. </div>
  244. </template>
  245. <template #delivery>
  246. <div style="width: 100%">
  247. <el-row style="margin-top: 20px; width: 100%">
  248. <el-col :span="12">
  249. <el-form-item label="交货类型" prop="deliveryType">
  250. <el-radio-group
  251. v-model="formData.data.deliveryType"
  252. @change="changeAddress"
  253. >
  254. <el-radio
  255. v-for="(item, index) in deliveryType"
  256. :key="index"
  257. :label="item.value"
  258. border
  259. >{{ item.label }}</el-radio
  260. >
  261. </el-radio-group>
  262. </el-form-item>
  263. </el-col>
  264. </el-row>
  265. <el-row style="margin-top: 20px; width: 100%">
  266. <el-col :span="12">
  267. <el-form-item label="详细地址" prop="address">
  268. <el-input
  269. v-model="formData.data.address"
  270. :rows="2"
  271. type="textarea"
  272. placeholder="请输入详细地址"
  273. />
  274. </el-form-item>
  275. </el-col>
  276. </el-row>
  277. <el-row style="margin-top: 20px; width: 100%">
  278. <el-col :span="6">
  279. <el-form-item label="交付日期" prop="deliveryTime">
  280. <el-date-picker
  281. v-model="formData.data.deliveryTime"
  282. type="date"
  283. placeholder="请选择交付日期"
  284. value-format="YYYY-MM-DD"
  285. />
  286. </el-form-item>
  287. </el-col>
  288. <el-col :span="6">
  289. <el-form-item label="质保期 (天)" prop="warranty">
  290. <el-input-number
  291. onmousewheel="return false;"
  292. v-model="formData.data.warranty"
  293. placeholder="请输入质保期"
  294. style="width: 100%"
  295. :precision="0"
  296. :controls="false"
  297. :min="0"
  298. />
  299. </el-form-item>
  300. </el-col>
  301. </el-row>
  302. </div>
  303. </template>
  304. <template #commodity>
  305. <div
  306. style="width: 100%"
  307. v-if="
  308. formData.data.purchaseProductList &&
  309. formData.data.purchaseProductList.length > 0
  310. "
  311. >
  312. <div
  313. :style="
  314. index !== formData.data.purchaseProductList.length - 1
  315. ? 'margin-bottom: 20px'
  316. : ''
  317. "
  318. v-for="(item, index) in formData.data.purchaseProductList"
  319. :key="item.dataResourceId"
  320. >
  321. <div
  322. style="
  323. border: 1px solid #ccc;
  324. padding: 20px 10px 0 10px;
  325. width: 100%;
  326. "
  327. >
  328. <el-row
  329. style="
  330. width: 100%;
  331. font-weight: 700;
  332. background: #eee;
  333. padding: 10px 0px;
  334. "
  335. :gutter="5"
  336. type="flex"
  337. align="middle"
  338. >
  339. <el-col :span="1" style="text-align: center">
  340. <img
  341. v-if="item.fileUrl"
  342. :src="item.fileUrl"
  343. class="pic"
  344. style="width: 30px; height: 30px"
  345. @click="onPicture(item.fileUrl)"
  346. />
  347. </el-col>
  348. <el-col :span="4">
  349. <span>产品名称: {{ item.productName }}</span>
  350. </el-col>
  351. <el-col :span="4">
  352. <span>尺寸: {{ item.productModel }}</span>
  353. </el-col>
  354. <el-col :span="3"> </el-col>
  355. <el-col :span="2">
  356. <span>数量: {{ item.quantity }}</span>
  357. </el-col>
  358. <el-col :span="3">
  359. <span>单价: {{ item.price }}</span>
  360. </el-col>
  361. <el-col :span="3">
  362. <span>金额小计: {{ item.amount }}</span>
  363. </el-col>
  364. <el-col :span="2">
  365. <el-button
  366. type="primary"
  367. text
  368. @click="handleHandover(item, index)"
  369. >编辑备注</el-button
  370. >
  371. </el-col>
  372. <el-col :span="2">
  373. <el-button type="primary" text @click="handleMaterial(index)"
  374. >添加配件</el-button
  375. >
  376. </el-col>
  377. </el-row>
  378. <el-collapse
  379. v-model="item.activeName"
  380. class="hideCollapse"
  381. accordion
  382. >
  383. <el-collapse-item title="" :name="true">
  384. <div style="padding: 0 40px">
  385. <el-table
  386. :data="item.purchaseProductMountingsList"
  387. style="width: 100%"
  388. >
  389. <el-table-column label="图片" align="center" width="80">
  390. <template #default="{ row }">
  391. <img
  392. v-if="row.fileUrl"
  393. :src="row.fileUrl"
  394. class="pic"
  395. @click="onPicture(row.fileUrl)"
  396. />
  397. </template>
  398. </el-table-column>
  399. <el-table-column label="类型" align="center" width="80">
  400. <template #default="{ row }">
  401. <div>
  402. {{ dictValueLabel(row.productType, productType) }}
  403. </div>
  404. </template>
  405. </el-table-column>
  406. <el-table-column
  407. label="产品名称"
  408. prop="productName"
  409. min-width="180"
  410. />
  411. <el-table-column
  412. label="尺寸"
  413. prop="productModel"
  414. min-width="140"
  415. />
  416. <el-table-column label="单价" width="140">
  417. <template #default="{ row, $index }">
  418. <div style="width: 100%" class="removePadding">
  419. <el-form-item
  420. :prop="
  421. 'purchaseProductList.' +
  422. index +
  423. '.purchaseProductMountingsList.' +
  424. $index +
  425. '.price'
  426. "
  427. :rules="rules.price"
  428. :inline-message="true"
  429. @change="
  430. () => {
  431. return changeProductMaterial(index, $index);
  432. }
  433. "
  434. >
  435. <el-input-number
  436. onmousewheel="return false;"
  437. v-model="row.price"
  438. placeholder="请输入单价"
  439. :precision="2"
  440. :controls="false"
  441. :min="0"
  442. />
  443. </el-form-item>
  444. </div>
  445. </template>
  446. </el-table-column>
  447. <el-table-column label="数量" width="140">
  448. <template #default="{ row, $index }">
  449. <div style="width: 100%" class="removePadding">
  450. <el-form-item
  451. :prop="
  452. 'purchaseProductList.' +
  453. index +
  454. '.purchaseProductMountingsList.' +
  455. $index +
  456. '.quantity'
  457. "
  458. :rules="rules.quantity"
  459. :inline-message="true"
  460. @change="
  461. () => {
  462. return changeProductMaterial(index, $index);
  463. }
  464. "
  465. >
  466. <el-input-number
  467. onmousewheel="return false;"
  468. v-model="row.quantity"
  469. placeholder="请输入数量"
  470. :precision="0"
  471. :controls="false"
  472. :min="0"
  473. />
  474. </el-form-item>
  475. </div>
  476. </template>
  477. </el-table-column>
  478. <el-table-column label="金额" prop="amount" width="100" />
  479. <el-table-column
  480. label="操作"
  481. align="center"
  482. width="80"
  483. fixed="right"
  484. >
  485. <template #default="{ $index }">
  486. <el-button
  487. type="primary"
  488. v-if="$index !== 0"
  489. link
  490. @click="handleRemove(index, $index)"
  491. >删除</el-button
  492. >
  493. </template>
  494. </el-table-column>
  495. </el-table>
  496. </div>
  497. </el-collapse-item>
  498. </el-collapse>
  499. <div style="text-align: center; margin-top: -18px">
  500. <el-button
  501. type="primary"
  502. @click="item.activeName = !item.activeName"
  503. style="margin-bottom: -28px; background: #fff"
  504. text
  505. >
  506. <span v-if="item.activeName">
  507. <span style="vertical-align: middle">收起明细</span>
  508. <el-icon
  509. style="
  510. margin-left: 8px;
  511. transform: rotate(-90deg);
  512. vertical-align: middle;
  513. "
  514. ><DArrowRight
  515. /></el-icon>
  516. </span>
  517. <span v-else>
  518. <span style="vertical-align: middle">查看明细</span>
  519. <el-icon
  520. style="
  521. margin-left: 8px;
  522. transform: rotate(90deg);
  523. vertical-align: middle;
  524. "
  525. ><DArrowRight
  526. /></el-icon>
  527. </span>
  528. </el-button>
  529. </div>
  530. </div>
  531. </div>
  532. </div>
  533. </template>
  534. <template #otherCharge>
  535. <div style="width: 100%">
  536. <el-button type="primary" @click="clickAdd()">添加行</el-button>
  537. <el-table
  538. :data="formData.data.purchaseProjectList"
  539. style="width: 100%; margin-top: 16px"
  540. >
  541. <el-table-column label="收费项目" width="220">
  542. <template #default="{ row, $index }">
  543. <div style="width: 100%">
  544. <el-form-item
  545. :prop="'purchaseProjectList.' + $index + '.payName'"
  546. :rules="rules.payName"
  547. :inline-message="true"
  548. >
  549. <el-autocomplete
  550. v-model="row.payName"
  551. :fetch-suggestions="querySearch"
  552. clearable
  553. class="inline-input w-50"
  554. placeholder="请输入收费项目"
  555. />
  556. </el-form-item>
  557. </div>
  558. </template>
  559. </el-table-column>
  560. <el-table-column label="备注">
  561. <template #default="{ row, $index }">
  562. <div style="width: 100%">
  563. <el-form-item
  564. :prop="'purchaseProjectList.' + $index + '.remark'"
  565. >
  566. <el-input v-model="row.remark" placeholder="请输入备注" />
  567. </el-form-item>
  568. </div>
  569. </template>
  570. </el-table-column>
  571. <el-table-column label="金额" width="130">
  572. <template #default="{ row, $index }">
  573. <div style="width: 100%">
  574. <el-form-item
  575. :prop="'purchaseProjectList.' + $index + '.amount'"
  576. :rules="rules.amount"
  577. :inline-message="true"
  578. class="shrinkPadding"
  579. @change="changeProject"
  580. >
  581. <el-input-number
  582. onmousewheel="return false;"
  583. v-model="row.amount"
  584. placeholder="请输入金额"
  585. style="width: 100%"
  586. :precision="2"
  587. :controls="false"
  588. :min="0"
  589. />
  590. </el-form-item>
  591. </div>
  592. </template>
  593. </el-table-column>
  594. <el-table-column
  595. label="操作"
  596. width="60"
  597. align="center"
  598. fixed="right"
  599. >
  600. <template #default="{ $index }">
  601. <el-button type="primary" link @click="handleDelete($index)"
  602. >删除</el-button
  603. >
  604. </template>
  605. </el-table-column>
  606. </el-table>
  607. </div>
  608. </template>
  609. <template #offerMoney>
  610. <div style="width: 100%; display: flex">
  611. <div style="width: calc(100% - 190px)"></div>
  612. <div style="width: 130px; padding: 0 12px">
  613. <el-form-item
  614. label="合同总金额"
  615. prop="amount"
  616. class="shrinkPadding"
  617. >
  618. <el-input
  619. v-model="formData.data.amount"
  620. placeholder="合同总金额"
  621. disabled
  622. />
  623. </el-form-item>
  624. </div>
  625. </div>
  626. </template>
  627. <template #contractClause>
  628. <div style="width: 100%">
  629. <el-row style="margin-top: 20px; width: 100%">
  630. <el-col :span="8">
  631. <el-form-item label="合同模板" prop="contractTemplateId">
  632. <el-select
  633. v-model="formData.data.contractTemplateId"
  634. style="width: 100%"
  635. @change="changeContractTemplate"
  636. >
  637. <el-option
  638. v-for="item in templateList"
  639. :key="item.value"
  640. :label="item.label"
  641. :value="item.value"
  642. />
  643. </el-select>
  644. </el-form-item>
  645. </el-col>
  646. </el-row>
  647. <div style="margin-top: 20px; width: 100%">
  648. <el-form-item label="条款内容" prop="remark">
  649. <!-- <div v-if="judgeStatus()">
  650. <div v-html="getHtmlVal(formData.data.remark)"></div>
  651. </div> -->
  652. <Editor
  653. style="width: 100%"
  654. :value="formData.data.remark"
  655. @updateValue="updateContent"
  656. :readOnly="judgeStatus()"
  657. ref="remarkEditor"
  658. />
  659. </el-form-item>
  660. </div>
  661. </div>
  662. </template>
  663. <template #shipment>
  664. <div style="width: 100%">
  665. <el-table
  666. :data="formData.data.purchaseArrivalList"
  667. style="width: 100%; margin-top: 16px"
  668. >
  669. <el-table-column prop="productCode" label="商品编码" width="120" />
  670. <el-table-column prop="productName" label="商品名称" />
  671. <el-table-column label="到货日期" width="220">
  672. <template #default="{ row, $index }">
  673. <div style="width: 100%">
  674. <el-form-item
  675. :prop="'purchaseArrivalList.' + $index + '.arrivalTime'"
  676. :rules="rules.arrivalTime"
  677. :inline-message="true"
  678. >
  679. <el-date-picker
  680. v-model="row.arrivalTime"
  681. type="date"
  682. placeholder="请选择到货日期"
  683. value-format="YYYY-MM-DD"
  684. />
  685. </el-form-item>
  686. </div>
  687. </template>
  688. </el-table-column>
  689. <el-table-column label="到货数量" width="160">
  690. <template #default="{ row, $index }">
  691. <div style="width: 100%">
  692. <el-form-item
  693. :prop="'purchaseArrivalList.' + $index + '.quantity'"
  694. :inline-message="true"
  695. >
  696. <el-input-number
  697. onmousewheel="return false;"
  698. v-model="row.quantity"
  699. placeholder="请输入到货数量"
  700. style="width: 100%"
  701. :precision="0"
  702. :controls="false"
  703. :min="0"
  704. />
  705. </el-form-item>
  706. </div>
  707. </template>
  708. </el-table-column>
  709. <el-table-column
  710. align="center"
  711. label="操作"
  712. width="120"
  713. fixed="right"
  714. >
  715. <template #default="{ row, $index }">
  716. <el-button type="primary" link @click="clickSplit(row)"
  717. >拆分</el-button
  718. >
  719. <el-button type="primary" link @click="clickDelete($index)"
  720. >删除</el-button
  721. >
  722. </template>
  723. </el-table-column>
  724. </el-table>
  725. </div>
  726. </template>
  727. </byForm>
  728. <el-dialog
  729. v-if="openMaterialCompany"
  730. v-model="openMaterialCompany"
  731. title="公司产品库"
  732. width="90%"
  733. append-to-body
  734. >
  735. <ProductMaterial
  736. :selectStatus="true"
  737. @selectMaterial="selectMaterial"
  738. ></ProductMaterial>
  739. </el-dialog>
  740. <el-dialog
  741. title="备注"
  742. v-if="openHandover"
  743. v-model="openHandover"
  744. width="800"
  745. >
  746. <byForm
  747. :formConfig="formHandoverConfig"
  748. :formOption="formOption"
  749. v-model="productRow.data"
  750. >
  751. <template #file>
  752. <div style="width: 100%">
  753. <el-upload
  754. v-model:fileList="fileList"
  755. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  756. :data="uploadData"
  757. multiple
  758. :before-upload="uploadFile"
  759. :on-success="handleSuccess"
  760. :on-preview="onPreviewFile"
  761. >
  762. <el-button>选择</el-button>
  763. </el-upload>
  764. </div>
  765. </template>
  766. <template #remark>
  767. <div style="width: 100%">
  768. <Editor
  769. :value="productRow.data.remark"
  770. @updateValue="updateHandover"
  771. />
  772. </div>
  773. </template>
  774. </byForm>
  775. <template #footer>
  776. <el-button @click="openHandover = false" size="large">取 消</el-button>
  777. <el-button type="primary" @click="submitHandoverForm()" size="large"
  778. >确 定</el-button
  779. >
  780. </template>
  781. </el-dialog>
  782. </div>
  783. </template>
  784. <script setup>
  785. import byForm from "@/components/byForm/index";
  786. import ProductMaterial from "@/views/product/material/index";
  787. import { ElMessage } from "element-plus";
  788. import selectCity from "@/components/selectCity/index.vue";
  789. import Editor from "@/components/Editor/index.vue";
  790. import { useRoute } from "vue-router";
  791. const route = useRoute();
  792. const { proxy } = getCurrentInstance();
  793. const invoiceType = ref([]);
  794. const fundsPaymentMethod = ref([]);
  795. const templateList = ref([]);
  796. const corporationList = ref([]);
  797. const supplierList = ref([]);
  798. const countryData = ref([]);
  799. const provinceData = ref([]);
  800. const cityData = ref([]);
  801. const openMaterialCompany = ref(false);
  802. const formData = reactive({
  803. data: {
  804. deliveryType: "1",
  805. remark: "",
  806. amount: undefined,
  807. purchaseArrivalList: [],
  808. purchaseProductList: [],
  809. purchaseProjectList: [],
  810. },
  811. });
  812. const submit = ref(null);
  813. const deliveryType = ref([
  814. {
  815. label: "买方地址",
  816. value: "1",
  817. },
  818. {
  819. label: "工厂交付",
  820. value: "2",
  821. },
  822. {
  823. label: "其他",
  824. value: "3",
  825. },
  826. ]);
  827. const productType = ref([
  828. {
  829. label: "产品",
  830. value: 1,
  831. },
  832. {
  833. label: "物料",
  834. value: 2,
  835. },
  836. ]);
  837. const judgeStatus = () => {
  838. if (route.query.processType == 20 || route.query.processType == 10) {
  839. return true;
  840. }
  841. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  842. let data = props.queryData.recordList.filter(
  843. (item) => item.status === 2 && item.nodeType !== 1
  844. );
  845. if (data && data.length > 0) {
  846. return true;
  847. }
  848. }
  849. return false;
  850. };
  851. const formOption = reactive({
  852. inline: true,
  853. labelWidth: 100,
  854. itemWidth: 100,
  855. rules: [],
  856. disabled: false,
  857. });
  858. const formConfig = computed(() => {
  859. return [
  860. {
  861. type: "slot",
  862. slotName: "buyer",
  863. label: "买方信息",
  864. itemWidth: 50,
  865. },
  866. {
  867. type: "slot",
  868. slotName: "seller",
  869. label: "卖方信息",
  870. itemWidth: 50,
  871. },
  872. {
  873. type: "slot",
  874. slotName: "payment",
  875. label: "付款信息",
  876. },
  877. {
  878. type: "slot",
  879. slotName: "delivery",
  880. label: "交付信息",
  881. },
  882. {
  883. type: "slot",
  884. slotName: "commodity",
  885. label: "采购明细",
  886. },
  887. {
  888. type: "slot",
  889. slotName: "otherCharge",
  890. label: "其他收费项目",
  891. },
  892. {
  893. type: "slot",
  894. slotName: "offerMoney",
  895. },
  896. {
  897. type: "slot",
  898. slotName: "contractClause",
  899. label: "合同条款",
  900. },
  901. {
  902. type: "slot",
  903. slotName: "shipment",
  904. label: "到货要求",
  905. },
  906. ];
  907. });
  908. const rules = ref({
  909. buyCorporationId: [
  910. { required: true, message: "请选择买方公司", trigger: "change" },
  911. ],
  912. sellCorporationId: [
  913. { required: true, message: "请选择卖方公司", trigger: "change" },
  914. ],
  915. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  916. sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  917. buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  918. sellContactName: [
  919. { required: true, message: "请输入联系人", trigger: "blur" },
  920. ],
  921. sellContactNumber: [
  922. { required: true, message: "请输入联系电话", trigger: "blur" },
  923. ],
  924. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  925. price: [{ required: true, message: "请输入单价", trigger: "blur" }],
  926. amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  927. payName: [
  928. { required: true, message: "请输入收费项目", trigger: ["change", "blur"] },
  929. ],
  930. warranty: [{ required: true, message: "请输入质保期", trigger: "blur" }],
  931. deliveryType: [
  932. { required: true, message: "请选择交货类型", trigger: "change" },
  933. ],
  934. address: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
  935. deliveryTime: [
  936. { required: true, message: "请选择交付日期", trigger: "change" },
  937. ],
  938. paymentMethod: [
  939. { required: true, message: "请选择付款方式", trigger: "change" },
  940. ],
  941. invoiceType: [
  942. { required: true, message: "请选择发票类型", trigger: "change" },
  943. ],
  944. contractTemplateId: [
  945. { required: true, message: "请选择合同模板", trigger: "change" },
  946. ],
  947. remark: [{ required: true, message: "请输入条款内容", trigger: "change" }],
  948. });
  949. const getDict = () => {
  950. proxy.getDictOne(["invoice_type", "funds_payment_method"]).then((res) => {
  951. invoiceType.value = res["invoice_type"].map((x) => ({
  952. label: x.dictValue,
  953. value: x.dictKey,
  954. }));
  955. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  956. label: x.dictValue,
  957. value: x.dictKey,
  958. }));
  959. });
  960. proxy
  961. .post("/contractTemplate/page", { pageNum: 1, pageSize: 999 })
  962. .then((res) => {
  963. templateList.value = res.rows.map((item) => {
  964. return {
  965. ...item,
  966. label: item.templateName,
  967. value: item.id,
  968. };
  969. });
  970. });
  971. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  972. corporationList.value = res.rows.map((item) => {
  973. return {
  974. ...item,
  975. label: item.name,
  976. value: item.id,
  977. };
  978. });
  979. });
  980. proxy.post("/supplierInfo/page", { pageNum: 1, pageSize: 50 }).then((res) => {
  981. supplierList.value = res.rows.map((item) => {
  982. return {
  983. ...item,
  984. label: item.name,
  985. value: item.id,
  986. };
  987. });
  988. });
  989. };
  990. getDict();
  991. const getCityData = (id, type, isChange) => {
  992. return proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  993. if (type === "20") {
  994. provinceData.value = res;
  995. if (isChange) {
  996. formData.data.provinceId = "";
  997. formData.data.provinceName = "";
  998. formData.data.cityId = "";
  999. formData.data.cityName = "";
  1000. }
  1001. } else if (type === "30") {
  1002. cityData.value = res;
  1003. if (isChange) {
  1004. formData.data.cityId = "";
  1005. formData.data.cityName = "";
  1006. }
  1007. } else {
  1008. countryData.value = res;
  1009. }
  1010. });
  1011. };
  1012. getCityData("0");
  1013. const changeBuyCorporation = (val) => {
  1014. formData.data.buyCountryName = "";
  1015. formData.data.buyProvinceName = "";
  1016. formData.data.buyCityName = "";
  1017. formData.data.buyAddress = "";
  1018. if (val) {
  1019. proxy.post("/corporation/detail", { id: val }).then((res) => {
  1020. formData.data.buyAddress = res.address;
  1021. Promise.all([
  1022. getBuyCountryName(res.countryId),
  1023. getBuyProvinceName(res.provinceId, res.countryId),
  1024. getBuyCityName(res.cityId, res.provinceId),
  1025. ]).then(() => {
  1026. changeAddress();
  1027. });
  1028. });
  1029. }
  1030. };
  1031. const changeAddress = () => {
  1032. if (formData.data.deliveryType === "1") {
  1033. let buyCountryName = "";
  1034. if (formData.data.buyCountryName) {
  1035. buyCountryName = formData.data.buyCountryName;
  1036. }
  1037. let buyProvinceName = "";
  1038. if (formData.data.buyProvinceName) {
  1039. buyProvinceName = formData.data.buyProvinceName;
  1040. }
  1041. let buyCityName = "";
  1042. if (formData.data.buyCityName) {
  1043. buyCityName = formData.data.buyCityName;
  1044. }
  1045. let buyAddress = "";
  1046. if (formData.data.buyAddress) {
  1047. buyAddress = formData.data.buyAddress;
  1048. }
  1049. formData.data.address =
  1050. buyCountryName +
  1051. ", " +
  1052. buyProvinceName +
  1053. ", " +
  1054. buyCityName +
  1055. "," +
  1056. buyAddress;
  1057. } else if (formData.data.deliveryType === "2") {
  1058. let countryName = "";
  1059. if (formData.data.countryId) {
  1060. let data = countryData.value.filter(
  1061. (item) => item.id === formData.data.countryId
  1062. );
  1063. if (data && data.length > 0) countryName = data[0].chineseName;
  1064. }
  1065. let provinceName = "";
  1066. if (formData.data.provinceId) {
  1067. let data = provinceData.value.filter(
  1068. (item) => item.id === formData.data.provinceId
  1069. );
  1070. if (data && data.length > 0) provinceName = data[0].name;
  1071. } else {
  1072. if (formData.data.provinceName) {
  1073. provinceName = formData.data.provinceName;
  1074. }
  1075. }
  1076. let cityName = "";
  1077. if (formData.data.cityId) {
  1078. let data = cityData.value.filter(
  1079. (item) => item.id === formData.data.cityId
  1080. );
  1081. if (data && data.length > 0) cityName = data[0].name;
  1082. } else {
  1083. if (formData.data.cityName) {
  1084. cityName = formData.data.cityName;
  1085. }
  1086. }
  1087. let sellAddress = "";
  1088. if (formData.data.sellAddress) {
  1089. sellAddress = formData.data.sellAddress;
  1090. }
  1091. formData.data.address =
  1092. countryName + ", " + provinceName + ", " + cityName + "," + sellAddress;
  1093. } else if (formData.data.deliveryType === "3") {
  1094. formData.data.address = "";
  1095. }
  1096. };
  1097. const changeSellAddress = (val, index) => {
  1098. Promise.all([getCityData(val, index, true)]).then(() => {
  1099. changeAddress();
  1100. });
  1101. };
  1102. const getBuyCountryName = (val) => {
  1103. return proxy
  1104. .post("/customizeArea/list", { parentId: "0" })
  1105. .then((resCountry) => {
  1106. let buyCountryData = resCountry.filter((item) => item.id === val);
  1107. if (buyCountryData && buyCountryData.length > 0) {
  1108. formData.data.buyCountryName = buyCountryData[0].chineseName;
  1109. } else {
  1110. formData.data.buyCountryName = "";
  1111. }
  1112. });
  1113. };
  1114. const getBuyProvinceName = (val, countryId) => {
  1115. if (val) {
  1116. return proxy
  1117. .post("/customizeArea/list", { parentId: countryId })
  1118. .then((resProvince) => {
  1119. let buyProvinceData = resProvince.filter((item) => item.id === val);
  1120. if (buyProvinceData && buyProvinceData.length > 0) {
  1121. formData.data.buyProvinceName = buyProvinceData[0].name;
  1122. } else {
  1123. formData.data.buyProvinceName = "";
  1124. }
  1125. });
  1126. } else {
  1127. formData.data.buyProvinceName = "";
  1128. return;
  1129. }
  1130. };
  1131. const getBuyCityName = (val, provinceId) => {
  1132. if (val) {
  1133. return proxy
  1134. .post("/customizeArea/list", { parentId: provinceId })
  1135. .then((resCity) => {
  1136. let buyCityData = resCity.filter((item) => item.id === val);
  1137. if (buyCityData && buyCityData.length > 0) {
  1138. formData.data.buyCityName = buyCityData[0].name;
  1139. } else {
  1140. formData.data.buyCityName = "";
  1141. }
  1142. });
  1143. } else {
  1144. formData.data.buyCityName = "";
  1145. return;
  1146. }
  1147. };
  1148. const changeSupplier = (val) => {
  1149. formData.data.countryId = "";
  1150. formData.data.provinceId = "";
  1151. formData.data.cityId = "";
  1152. formData.data.sellPostalCode = "";
  1153. formData.data.sellAddress = "";
  1154. formData.data.sellContactName = "";
  1155. formData.data.sellContactNumber = "";
  1156. if (val) {
  1157. let data = supplierList.value.filter((item) => item.id === val);
  1158. if (data && data.length > 0) {
  1159. formData.data.countryId = data[0].countryId;
  1160. formData.data.provinceId = data[0].provinceId;
  1161. formData.data.cityId = data[0].cityId;
  1162. formData.data.sellAddress = data[0].areaDetail;
  1163. formData.data.sellContactName = data[0].contactPerson;
  1164. formData.data.sellContactNumber = data[0].contactNumber;
  1165. if (formData.data.provinceId) {
  1166. Promise.all([
  1167. getCityData(formData.data.countryId, "20"),
  1168. getCityData(formData.data.provinceId, "30"),
  1169. ]).then(() => {
  1170. changeAddress();
  1171. });
  1172. } else {
  1173. Promise.all([getCityData(formData.data.countryId, "20")]).then(() => {
  1174. changeAddress();
  1175. });
  1176. }
  1177. }
  1178. const ids = formData.data.purchaseProductList.map((x) => x.productId);
  1179. getAuxiliaryData(val, ids);
  1180. }
  1181. };
  1182. const onPicture = (path) => {
  1183. window.open(path, "_blank");
  1184. };
  1185. const changeProject = () => {
  1186. nextTick(() => {
  1187. calculationAllAmount();
  1188. });
  1189. };
  1190. const calculationAllAmount = () => {
  1191. let amount = 0;
  1192. if (
  1193. formData.data.purchaseProductList &&
  1194. formData.data.purchaseProductList.length > 0
  1195. ) {
  1196. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1197. if (formData.data.purchaseProductList[i].amount) {
  1198. amount = Number(
  1199. parseFloat(
  1200. Number(amount) + Number(formData.data.purchaseProductList[i].amount)
  1201. ).toFixed(2)
  1202. );
  1203. }
  1204. }
  1205. }
  1206. if (
  1207. formData.data.purchaseProjectList &&
  1208. formData.data.purchaseProjectList.length > 0
  1209. ) {
  1210. for (let i = 0; i < formData.data.purchaseProjectList.length; i++) {
  1211. if (formData.data.purchaseProjectList[i].amount) {
  1212. amount = Number(
  1213. parseFloat(
  1214. Number(amount) + Number(formData.data.purchaseProjectList[i].amount)
  1215. ).toFixed(2)
  1216. );
  1217. }
  1218. }
  1219. }
  1220. formData.data.amount = amount;
  1221. };
  1222. const calculationProductAmount = (index) => {
  1223. if (
  1224. formData.data.purchaseProductList &&
  1225. formData.data.purchaseProductList.length > 0 &&
  1226. formData.data.purchaseProductList[index].purchaseProductMountingsList &&
  1227. formData.data.purchaseProductList[index].purchaseProductMountingsList
  1228. .length > 0
  1229. ) {
  1230. let amount = 0;
  1231. for (
  1232. let i = 0;
  1233. i <
  1234. formData.data.purchaseProductList[index].purchaseProductMountingsList
  1235. .length;
  1236. i++
  1237. ) {
  1238. if (
  1239. formData.data.purchaseProductList[index].purchaseProductMountingsList[i]
  1240. .amount
  1241. ) {
  1242. amount = Number(
  1243. parseFloat(
  1244. Number(amount) +
  1245. Number(
  1246. formData.data.purchaseProductList[index]
  1247. .purchaseProductMountingsList[i].amount
  1248. )
  1249. ).toFixed(2)
  1250. );
  1251. }
  1252. }
  1253. formData.data.purchaseProductList[index].amount = amount;
  1254. let price = 0;
  1255. if (formData.data.purchaseProductList[index].quantity && amount) {
  1256. price = Number(
  1257. parseFloat(
  1258. Number(amount) /
  1259. Number(formData.data.purchaseProductList[index].quantity)
  1260. ).toFixed(4)
  1261. );
  1262. }
  1263. formData.data.purchaseProductList[index].price = price;
  1264. }
  1265. nextTick(() => {
  1266. calculationAllAmount();
  1267. });
  1268. };
  1269. const changeProductMaterial = (index, indexTwo) => {
  1270. nextTick(() => {
  1271. if (
  1272. formData.data.purchaseProductList &&
  1273. formData.data.purchaseProductList.length > 0 &&
  1274. formData.data.purchaseProductList[index].purchaseProductMountingsList &&
  1275. formData.data.purchaseProductList[index].purchaseProductMountingsList
  1276. .length > 0
  1277. ) {
  1278. if (
  1279. indexTwo === 0 &&
  1280. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1281. indexTwo
  1282. ].quantity
  1283. ) {
  1284. formData.data.purchaseProductList[index].quantity =
  1285. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1286. indexTwo
  1287. ].quantity;
  1288. }
  1289. if (
  1290. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1291. indexTwo
  1292. ].quantity &&
  1293. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1294. indexTwo
  1295. ].price
  1296. ) {
  1297. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1298. indexTwo
  1299. ].amount = Number(
  1300. parseFloat(
  1301. Number(
  1302. formData.data.purchaseProductList[index]
  1303. .purchaseProductMountingsList[indexTwo].quantity
  1304. ) *
  1305. Number(
  1306. formData.data.purchaseProductList[index]
  1307. .purchaseProductMountingsList[indexTwo].price
  1308. )
  1309. ).toFixed(2)
  1310. );
  1311. } else {
  1312. formData.data.purchaseProductList[index].purchaseProductMountingsList[
  1313. indexTwo
  1314. ].amount = 0;
  1315. }
  1316. }
  1317. nextTick(() => {
  1318. calculationProductAmount(index);
  1319. });
  1320. });
  1321. };
  1322. const handleRemove = async (index, indexTwo) => {
  1323. await formData.data.purchaseProductList[
  1324. index
  1325. ].purchaseProductMountingsList.splice(indexTwo, 1);
  1326. nextTick(() => {
  1327. calculationProductAmount(index);
  1328. });
  1329. };
  1330. const clickAdd = () => {
  1331. if (
  1332. formData.data.purchaseProjectList &&
  1333. formData.data.purchaseProjectList.length > 0
  1334. ) {
  1335. formData.data.purchaseProjectList.push({
  1336. payName: "",
  1337. amount: undefined,
  1338. remark: "",
  1339. });
  1340. } else {
  1341. formData.data.purchaseProjectList = [
  1342. { payName: "", amount: undefined, remark: "" },
  1343. ];
  1344. }
  1345. };
  1346. const handleDelete = async (index) => {
  1347. await formData.data.purchaseProjectList.splice(index, 1);
  1348. nextTick(() => {
  1349. calculationAllAmount();
  1350. });
  1351. };
  1352. const querySearch = (queryString, callback) => {
  1353. proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
  1354. if (res.rows && res.rows.length > 0) {
  1355. res.rows = res.rows.map((item) => {
  1356. return {
  1357. ...item,
  1358. value: item.payName,
  1359. };
  1360. });
  1361. callback(res.rows);
  1362. } else {
  1363. callback([]);
  1364. }
  1365. });
  1366. };
  1367. const handleSubmit = async () => {
  1368. let status = await submit.value.handleSubmit(() => {});
  1369. if (status) {
  1370. // 合同交接单不可大于待采购数量
  1371. if (route.query.type == 1) {
  1372. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1373. const ele = formData.data.purchaseProductList[i];
  1374. for (let j = 0; j < ele.purchaseProductMountingsList.length; j++) {
  1375. const jele = ele.purchaseProductMountingsList[j];
  1376. if (j == 0) {
  1377. if (Number(jele.quantity) > Number(jele.oldQuantity)) {
  1378. ElMessage("采购数量不能大于待采购数量");
  1379. return false;
  1380. }
  1381. }
  1382. }
  1383. }
  1384. }
  1385. if (
  1386. formData.data.purchaseArrivalList &&
  1387. formData.data.purchaseArrivalList.length > 0
  1388. ) {
  1389. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1390. let data = formData.data.purchaseArrivalList.filter(
  1391. (item) =>
  1392. item.productId === formData.data.purchaseProductList[i].productId
  1393. );
  1394. if (data && data.length > 0) {
  1395. let quantity = 0;
  1396. for (let j = 0; j < data.length; j++) {
  1397. quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
  1398. }
  1399. if (quantity > formData.data.purchaseProductList[i].quantity) {
  1400. ElMessage("到货数量不能大于采购数量");
  1401. return false;
  1402. }
  1403. }
  1404. }
  1405. }
  1406. return true;
  1407. } else {
  1408. setTimeout(() => {
  1409. const errorDiv = document.getElementsByClassName("is-error");
  1410. errorDiv[0].scrollIntoView();
  1411. }, 0);
  1412. }
  1413. return status;
  1414. };
  1415. // 接收父组件的传值
  1416. const props = defineProps({
  1417. queryData: Object,
  1418. });
  1419. watch(
  1420. props.queryData,
  1421. () => {
  1422. formOption.disabled = judgeStatus();
  1423. return;
  1424. if (
  1425. props.queryData &&
  1426. ["10", "20", "30"].includes(route.query.processType)
  1427. ) {
  1428. for (var text in props.queryData) {
  1429. formData.data[text] = props.queryData[text];
  1430. }
  1431. if (formData.data.countryId) {
  1432. getCityData(formData.data.countryId, "20");
  1433. }
  1434. if (formData.data.provinceId) {
  1435. getCityData(formData.data.provinceId, "30");
  1436. }
  1437. const ids = formData.data.purchaseProductList.map((x) => x.productId);
  1438. if (formData.data.sellCorporationId && ids.length > 0) {
  1439. getAuxiliaryData(formData.data.sellCorporationId, ids);
  1440. }
  1441. }
  1442. },
  1443. {
  1444. deep: true,
  1445. }
  1446. );
  1447. const getFormData = () => {
  1448. return proxy.deepClone(formData.data);
  1449. };
  1450. // 向父组件暴露
  1451. defineExpose({
  1452. getFormData,
  1453. handleSubmit,
  1454. });
  1455. const getAssociationData = (type, id) => {
  1456. if (type && id) {
  1457. if (type == 1) {
  1458. auxiliaryData.value[0].label = "关联销售合同";
  1459. proxy.post("/contract/detail", { id }).then((res) => {
  1460. contractData.value = [
  1461. {
  1462. contractCode: res.code,
  1463. claimTime: res.createTime,
  1464. },
  1465. ];
  1466. getAuxiliaryData();
  1467. });
  1468. } else if (type == 2) {
  1469. auxiliaryData.value[0].label = "关联样品单";
  1470. proxy.post("/sample/detail", { id }).then((res) => {
  1471. contractData.value = [
  1472. {
  1473. contractCode: res.code,
  1474. claimTime: res.createTime,
  1475. },
  1476. ];
  1477. getAuxiliaryData();
  1478. });
  1479. }
  1480. }
  1481. };
  1482. onMounted(() => {
  1483. if (route.query && route.query.type && route.query.submitType === "10") {
  1484. getAssociationData(route.query.type, route.query.dataResourceId);
  1485. }
  1486. if (props.queryData.ids) {
  1487. proxy.post("/delivery/page", { ids: props.queryData.ids }).then((res) => {
  1488. formData.data.dataResource = props.queryData.type;
  1489. formData.data.dataResourceId = route.query.dataResourceId;
  1490. if (res.rows && res.rows.length > 0) {
  1491. formData.data.purchaseProductList = res.rows.map((item) => {
  1492. return {
  1493. productId: item.productId,
  1494. contractId: item.contractId,
  1495. productName: item.productName,
  1496. productModel: item.productModel,
  1497. quantity: item.expendQuantity,
  1498. oldQuantity: item.expendQuantity,
  1499. price: "",
  1500. amount: "",
  1501. remark: "",
  1502. json: "",
  1503. fileUrl: "",
  1504. dataResource: props.queryData.type,
  1505. dataResourceId: item.id,
  1506. purchaseProductMountingsList: [
  1507. {
  1508. productId: item.productId,
  1509. productType: 1,
  1510. productName: item.productName,
  1511. productModel: item.productModel,
  1512. quantity: item.expendQuantity,
  1513. oldQuantity: item.expendQuantity,
  1514. price: undefined,
  1515. amount: "",
  1516. remark: "",
  1517. json: "",
  1518. fileUrl: "",
  1519. activeName: true,
  1520. },
  1521. ],
  1522. fileList: [],
  1523. };
  1524. });
  1525. formData.data.purchaseArrivalList = res.rows.map((item) => {
  1526. return {
  1527. productCode: item.productCode,
  1528. productId: item.productId,
  1529. productName: item.productName,
  1530. arrivalTime: "",
  1531. quantity: undefined,
  1532. };
  1533. });
  1534. let fileIds = formData.data.purchaseProductList.map(
  1535. (item) => item.productId
  1536. );
  1537. proxy
  1538. .post("/fileInfo/getList", { businessIdList: fileIds })
  1539. .then((resFile) => {
  1540. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1541. if (
  1542. resFile[formData.data.purchaseProductList[i].productId] &&
  1543. resFile[formData.data.purchaseProductList[i].productId].length >
  1544. 0
  1545. ) {
  1546. formData.data.purchaseProductList[i].fileUrl =
  1547. resFile[
  1548. formData.data.purchaseProductList[i].productId
  1549. ][0].fileUrl;
  1550. formData.data.purchaseProductList[
  1551. i
  1552. ].purchaseProductMountingsList[0].fileUrl =
  1553. resFile[
  1554. formData.data.purchaseProductList[i].productId
  1555. ][0].fileUrl;
  1556. }
  1557. }
  1558. });
  1559. } else {
  1560. formData.data.purchaseProductList = [];
  1561. }
  1562. });
  1563. }
  1564. formOption.disabled = judgeStatus();
  1565. if (route.query && route.query.processType) {
  1566. let businessId = route.query.businessId;
  1567. proxy.post("/ehsdPurchase/detail", { id: businessId }).then((res) => {
  1568. res.purchaseProductList = res.ehsdPurchaseProductList || [];
  1569. if (!res.fileList) {
  1570. res.fileList = [];
  1571. }
  1572. res.countryId = res.sellCountryId;
  1573. res.provinceId = res.sellProvinceId;
  1574. res.cityId = res.sellCityId;
  1575. for (const key in res) {
  1576. formData.data[key] = res[key];
  1577. }
  1578. remarkEditor.value.changeHtml(formData.data.remark);
  1579. // 回显关联销售合同
  1580. if (route.query && route.query.submitType === "10") {
  1581. getAssociationData(
  1582. formData.data.dataResource,
  1583. formData.data.dataResourceId
  1584. );
  1585. }
  1586. proxy
  1587. .post("/fileInfo/getList", {
  1588. businessIdList: [businessId],
  1589. })
  1590. .then((fileObj) => {
  1591. if (fileObj[businessId]) {
  1592. formData.data.fileList = fileObj[businessId]
  1593. .filter((x) => x.businessType === "1")
  1594. .map((x) => ({ raw: x, name: x.fileName, url: x.fileUrl }));
  1595. formData.data.packageFileList = fileObj[businessId]
  1596. .filter((x) => x.businessType === "2")
  1597. .map((x) => ({ raw: x, name: x.fileName, url: x.fileUrl }));
  1598. }
  1599. });
  1600. if (
  1601. formData.data.purchaseProductList &&
  1602. formData.data.purchaseProductList.length > 0
  1603. ) {
  1604. let ids = formData.data.purchaseProductList.map((x) => x.productId);
  1605. getAuxiliaryData(formData.data.sellCorporationId, ids);
  1606. proxy
  1607. .post("/fileInfo/getList", {
  1608. businessIdList: ids,
  1609. })
  1610. .then((fileObj) => {
  1611. for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
  1612. const e = formData.data.purchaseProductList[i];
  1613. e.activeName = true;
  1614. for (const key in fileObj) {
  1615. if (e.productId === key) {
  1616. e.fileList = fileObj[key] || [];
  1617. if (e.fileList && e.fileList.length > 0) {
  1618. e.fileUrl = e.fileList[0].fileUrl;
  1619. }
  1620. }
  1621. }
  1622. }
  1623. });
  1624. }
  1625. if (formData.data.countryId) {
  1626. getCityData(formData.data.countryId, "20");
  1627. }
  1628. if (formData.data.provinceId) {
  1629. getCityData(formData.data.provinceId, "30");
  1630. }
  1631. });
  1632. }
  1633. });
  1634. const clickSplit = (item) => {
  1635. formData.data.purchaseArrivalList.push({
  1636. productCode: item.code,
  1637. productId: item.productId,
  1638. productName: item.productName,
  1639. arrivalTime: "",
  1640. remark: "",
  1641. quantity: undefined,
  1642. });
  1643. };
  1644. const clickDelete = (index) => {
  1645. formData.data.purchaseArrivalList.splice(index, 1);
  1646. };
  1647. const updateContent = (val) => {
  1648. formData.data.remark = val;
  1649. };
  1650. const remarkEditor = ref(null);
  1651. const changeContractTemplate = (val) => {
  1652. if (val) {
  1653. proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
  1654. remarkEditor.value.changeHtml(res.templateContent);
  1655. });
  1656. }
  1657. };
  1658. const productRow = reactive({
  1659. data: {
  1660. productName: "",
  1661. remark: "",
  1662. },
  1663. });
  1664. const productIndex = ref(0);
  1665. const openHandover = ref(false);
  1666. const fileList = ref([]);
  1667. const uploadData = ref({});
  1668. const formHandoverConfig = computed(() => {
  1669. return [
  1670. {
  1671. type: "title",
  1672. title: "产品信息",
  1673. label: "",
  1674. },
  1675. {
  1676. type: "input",
  1677. prop: "productName",
  1678. label: "产品名称",
  1679. itemType: "text",
  1680. disabled: true,
  1681. },
  1682. {
  1683. type: "input",
  1684. prop: "productModel",
  1685. label: "规格型号",
  1686. itemType: "text",
  1687. disabled: true,
  1688. },
  1689. {
  1690. type: "slot",
  1691. prop: "file",
  1692. slotName: "file",
  1693. label: "上传附件",
  1694. },
  1695. {
  1696. type: "slot",
  1697. slotName: "remark",
  1698. label: "备注",
  1699. },
  1700. ];
  1701. });
  1702. const handleHandover = (row, index) => {
  1703. productRow.data = {
  1704. productName: row.productName,
  1705. remark: row.remark,
  1706. };
  1707. if (row.fileList && row.fileList.length > 0) {
  1708. fileList.value = row.fileList.map((item) => {
  1709. return {
  1710. raw: item,
  1711. name: item.fileName,
  1712. url: item.fileUrl,
  1713. };
  1714. });
  1715. } else {
  1716. fileList.value = [];
  1717. }
  1718. productIndex.value = index;
  1719. openHandover.value = true;
  1720. };
  1721. const handleMaterial = (index) => {
  1722. productIndex.value = index;
  1723. openMaterialCompany.value = true;
  1724. };
  1725. const uploadFile = async (file) => {
  1726. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1727. uploadData.value = res.uploadBody;
  1728. file.id = res.id;
  1729. file.fileName = res.fileName;
  1730. file.fileUrl = res.fileUrl;
  1731. file.uploadState = true;
  1732. return true;
  1733. };
  1734. const handleSuccess = (any, UploadFile) => {
  1735. UploadFile.raw.uploadState = false;
  1736. };
  1737. const onPreviewFile = (file) => {
  1738. window.open(file.raw.fileUrl, "_blank");
  1739. };
  1740. const updateHandover = (val) => {
  1741. productRow.data.remark = val;
  1742. };
  1743. const submitHandoverForm = () => {
  1744. if (fileList.value && fileList.value.length > 0) {
  1745. for (let i = 0; i < fileList.value.length; i++) {
  1746. if (fileList.value[i].raw.uploadState) {
  1747. ElMessage("文件上传中,请稍后提交");
  1748. return;
  1749. }
  1750. }
  1751. formData.data.purchaseProductList[productIndex.value].fileList =
  1752. fileList.value.map((item) => {
  1753. return {
  1754. id: item.raw.id,
  1755. fileName: item.raw.fileName,
  1756. fileUrl: item.raw.fileUrl,
  1757. uploadState: item.raw.uploadState,
  1758. };
  1759. });
  1760. } else {
  1761. formData.data.purchaseProductList[productIndex.value].fileList = [];
  1762. }
  1763. formData.data.purchaseProductList[productIndex.value].remark =
  1764. productRow.data.remark;
  1765. openHandover.value = false;
  1766. };
  1767. const selectMaterial = (goods) => {
  1768. if (goods && goods.id) {
  1769. let data = formData.data.purchaseProductList[
  1770. productIndex.value
  1771. ].purchaseProductMountingsList.filter(
  1772. (item) => item.productId === goods.id
  1773. );
  1774. // if (data && data.length > 0) {
  1775. // return ElMessage("该物料已添加");
  1776. // }
  1777. let fileUrl = "";
  1778. if (goods.fileList && goods.fileList.length > 0) {
  1779. fileUrl = goods.fileList[0].fileUrl;
  1780. }
  1781. formData.data.purchaseProductList[
  1782. productIndex.value
  1783. ].purchaseProductMountingsList.push({
  1784. productId: goods.id,
  1785. productType: 2,
  1786. productName: goods.name,
  1787. productModel: goods.spec,
  1788. quantity: undefined,
  1789. price: undefined,
  1790. amount: "",
  1791. remark: "",
  1792. json: "",
  1793. fileUrl: fileUrl,
  1794. activeName: true,
  1795. });
  1796. ElMessage({
  1797. message: "添加成功!",
  1798. type: "success",
  1799. });
  1800. } else {
  1801. return ElMessage("选择错误");
  1802. }
  1803. };
  1804. const getStyle = (text) => {
  1805. if (text) {
  1806. return text.replace(/\n|\r\n/g, "<br>");
  1807. } else {
  1808. return "";
  1809. }
  1810. };
  1811. const emit = defineEmits(["auxiliaryChange"]);
  1812. let auxiliaryData = ref([
  1813. {
  1814. label: "关联销售合同",
  1815. data: [],
  1816. },
  1817. {
  1818. label: "供应商最近采购",
  1819. data: [],
  1820. },
  1821. {
  1822. label: "产品价格",
  1823. data: [],
  1824. },
  1825. ]);
  1826. const auxiliaryChange = (data) => {
  1827. emit("auxiliaryChange", data);
  1828. };
  1829. const contractData = ref([]);
  1830. const getAuxiliaryData = (supplyId, productIdList) => {
  1831. if (supplyId && productIdList.length > 0) {
  1832. proxy
  1833. .post("/subscribe/decisionAid", {
  1834. supplyId: supplyId,
  1835. productIdList: productIdList,
  1836. })
  1837. .then((res) => {
  1838. // 供应商最近采购
  1839. const recentlyArr = [
  1840. {
  1841. label: "合同编号",
  1842. value: "",
  1843. fn: () => {},
  1844. num: 1,
  1845. },
  1846. {
  1847. label: "下单日期",
  1848. value: "",
  1849. num: 1,
  1850. },
  1851. {
  1852. label: "合同金额",
  1853. value: "",
  1854. num: 1,
  1855. },
  1856. ];
  1857. auxiliaryData.value[1].data = res.purchaseList.map((x, index) => {
  1858. return recentlyArr.map((y, sonIndex) => {
  1859. let obj = { ...y };
  1860. let value = "";
  1861. if (sonIndex === 0) {
  1862. value = x.code;
  1863. } else if (sonIndex === 1) {
  1864. value = x.createTime;
  1865. } else {
  1866. value = x.currency + " " + proxy.moneyFormat(x.amount, 2);
  1867. }
  1868. obj.value = value;
  1869. return obj;
  1870. });
  1871. });
  1872. // 产品价格
  1873. const arrConfig = [
  1874. {
  1875. label: "产品名称",
  1876. value: "",
  1877. num: 1,
  1878. },
  1879. {
  1880. label: "最近价格",
  1881. value: "",
  1882. num: 1,
  1883. },
  1884. {
  1885. label: "历史最高",
  1886. value: "",
  1887. num: 1,
  1888. },
  1889. {
  1890. label: "历史最低",
  1891. value: "",
  1892. num: 1,
  1893. },
  1894. ];
  1895. auxiliaryData.value[2].data = res.productPriceList.map((x, index) => {
  1896. return arrConfig.map((y, sonIndex) => {
  1897. let obj = { ...y };
  1898. let value = "";
  1899. if (sonIndex === 0) {
  1900. value = x.name;
  1901. } else if (sonIndex === 1) {
  1902. value = x.lastPrice;
  1903. } else if (sonIndex === 2) {
  1904. value = x.maxPrice;
  1905. } else {
  1906. value = x.minPrice;
  1907. }
  1908. obj.value = value;
  1909. return obj;
  1910. });
  1911. });
  1912. auxiliaryChange(auxiliaryData.value);
  1913. });
  1914. } else {
  1915. let arrConfig = [
  1916. {
  1917. label: "合同编号",
  1918. value: "",
  1919. fn: () => {},
  1920. num: 1,
  1921. },
  1922. {
  1923. label: "下单日期",
  1924. value: "",
  1925. num: 1,
  1926. },
  1927. ];
  1928. auxiliaryData.value[0].data = contractData.value.map((x, index) => {
  1929. return arrConfig.map((y, sonIndex) => {
  1930. let obj = { ...y };
  1931. let value = "";
  1932. if (sonIndex === 0) {
  1933. value = contractData.value[index].contractCode;
  1934. } else if (sonIndex === 1) {
  1935. value = contractData.value[index].claimTime;
  1936. }
  1937. obj.value = value;
  1938. return obj;
  1939. });
  1940. });
  1941. auxiliaryChange(auxiliaryData.value);
  1942. }
  1943. };
  1944. const getHtmlVal = (val) => {
  1945. if (val) {
  1946. return val.replace(/<p>/g, "<div>").replace(/<\/p>/g, "</div>");
  1947. }
  1948. return "";
  1949. };
  1950. const loadingSearch = ref(false);
  1951. const remoteMethod = (keyword) => {
  1952. if (keyword && typeof keyword === "string") {
  1953. loadingSearch.value = true;
  1954. proxy.post("/supplierInfo/page", { keyword }).then((res) => {
  1955. supplierList.value = res.rows.map((item) => {
  1956. return {
  1957. ...item,
  1958. label: item.name,
  1959. value: item.id,
  1960. };
  1961. });
  1962. loadingSearch.value = false;
  1963. });
  1964. }
  1965. return;
  1966. };
  1967. </script>
  1968. <style lang="scss" scoped>
  1969. ::v-deep(.el-input-number .el-input__inner) {
  1970. text-align: left;
  1971. }
  1972. .pic {
  1973. object-fit: contain;
  1974. width: 50px;
  1975. height: 50px;
  1976. cursor: pointer;
  1977. vertical-align: middle;
  1978. }
  1979. .shrinkPadding {
  1980. padding-right: 0 !important;
  1981. }
  1982. .hideCollapse {
  1983. margin-top: -28px;
  1984. border: 0 !important;
  1985. }
  1986. ::v-deep(.el-collapse-item__arrow) {
  1987. display: none !important;
  1988. }
  1989. ::v-deep(.el-collapse-item__wrap) {
  1990. border: 0 !important;
  1991. }
  1992. ::v-deep(.el-collapse-item__header) {
  1993. border: 0 !important;
  1994. }
  1995. ::v-deep(.el-collapse-item__content) {
  1996. padding-bottom: 8px !important;
  1997. }
  1998. .pic {
  1999. object-fit: contain;
  2000. width: 50px;
  2001. height: 50px;
  2002. cursor: pointer;
  2003. vertical-align: middle;
  2004. }
  2005. ::v-deep(.removePadding) {
  2006. .el-form-item {
  2007. padding-right: 0 !important;
  2008. }
  2009. }
  2010. </style>