Purchase.vue 67 KB

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