index.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. highlight-current-row
  10. :selectConfig="selectConfig"
  11. :table-events="{
  12. //element talbe事件都能传
  13. }"
  14. :action-list="[]"
  15. @get-list="getList"
  16. @moreSearch="() => (dialogVisibleThree = true)"
  17. >
  18. <template #contractCode="{ item }">
  19. <div
  20. style="cursor: pointer; color: #409eff"
  21. @click="handleClickContractCode(item)"
  22. >
  23. {{ item.contractCode }}
  24. </div>
  25. </template>
  26. <template #arrivalStatus="{ item }">
  27. <span
  28. style="cursor: pointer; color: #409eff"
  29. @click="handleClickArrivalStatus(item)"
  30. >
  31. {{ dictValueLabel(item.arrivalStatus, arrivalStatus) }}
  32. </span>
  33. <span v-if="item.isTransit == 1">(有在途)</span>
  34. </template>
  35. <template #btn="{ item }">
  36. <div>
  37. <el-button
  38. type="primary"
  39. v-if="item.purchaseStatus == 30"
  40. link
  41. @click="handleReturnGoods(item)"
  42. >退货</el-button
  43. >
  44. <el-button
  45. type="primary"
  46. link
  47. v-if="item.purchaseStatus == 30 && item.purchaseStatus != 99"
  48. @click="handleArrival(item, 'add')"
  49. >发货登记</el-button
  50. >
  51. <el-button
  52. type="primary"
  53. link
  54. v-if="item.purchaseStatus == 30 && item.purchaseStatus != 99"
  55. @click="handleArrival(item, 'edit')"
  56. >到货通知</el-button
  57. >
  58. <el-button
  59. type="primary"
  60. link
  61. v-if="
  62. item.purchaseStatus == 10 ||
  63. (item.purchaseStatus == 30 && item.arrivalStatus == 0)
  64. "
  65. @click="handleEdit(item, 88)"
  66. >作废</el-button
  67. >
  68. <el-button
  69. type="primary"
  70. link
  71. v-if="item.purchaseStatus == 30"
  72. @click="handleEdit(item, 99)"
  73. >结束</el-button
  74. >
  75. </div>
  76. </template>
  77. </byTable>
  78. </div>
  79. <el-dialog
  80. :title="modalType === 'add' ? '发货登记' : '到货通知'"
  81. v-model="dialogVisible"
  82. width="80%"
  83. destroy-on-close
  84. >
  85. <byForm
  86. :formConfig="formConfig"
  87. :formOption="formOption"
  88. v-model="formData.data"
  89. :rules="rules"
  90. ref="byform"
  91. v-loading="submitLoading"
  92. >
  93. <template #detailSlot>
  94. <div style="width: 100%">
  95. <el-table
  96. :data="
  97. modalType === 'add'
  98. ? formData.data.deliverGoodsDetailsList
  99. : formData.data.arrivalDetailList
  100. "
  101. >
  102. <el-table-column
  103. prop="productDefinition"
  104. label="物品类型"
  105. :formatter="
  106. (row) =>
  107. row.productDefinition == 1
  108. ? '产品'
  109. : row.productDefinition == 2
  110. ? '物料'
  111. : ''
  112. "
  113. />
  114. <el-table-column prop="productCode" label="物品编码" />
  115. <el-table-column prop="productName" label="物品名称" />
  116. <el-table-column prop="productSpec" label="规格型号" />
  117. <el-table-column
  118. prop="productUnit"
  119. label="单位"
  120. :formatter="
  121. (row) => dictValueLabel(row.productUnit, productUnit)
  122. "
  123. />
  124. <el-table-column prop="count" label="采购数量" />
  125. <el-table-column
  126. prop="alreadyDeliverGoodsQuantity"
  127. label="累计发货"
  128. v-if="modalType === 'add'"
  129. />
  130. <el-table-column
  131. prop="deliverGoodsQuantity"
  132. label="本次发货"
  133. min-width="150"
  134. v-if="modalType === 'add'"
  135. >
  136. <template #default="{ row, $index }">
  137. <el-form-item
  138. :prop="
  139. 'deliverGoodsDetailsList.' +
  140. $index +
  141. '.deliverGoodsQuantity'
  142. "
  143. :rules="rules.deliverGoodsQuantity"
  144. :inline-message="true"
  145. >
  146. <el-input-number
  147. v-model="row.deliverGoodsQuantity"
  148. :precision="2"
  149. :controls="false"
  150. :min="0"
  151. onmousewheel="return false;"
  152. />
  153. </el-form-item>
  154. </template>
  155. </el-table-column>
  156. <el-table-column
  157. prop="transitQuantity"
  158. label="剩余在途"
  159. v-if="modalType === 'edit'"
  160. />
  161. <el-table-column
  162. prop="deliverGoodsQuantity"
  163. label="本次到货"
  164. min-width="150"
  165. v-if="modalType === 'edit'"
  166. >
  167. <template #default="{ row, $index }">
  168. <el-form-item
  169. :prop="
  170. 'arrivalDetailList.' + $index + '.deliverGoodsQuantity'
  171. "
  172. :rules="rules.deliverGoodsQuantity"
  173. :inline-message="true"
  174. >
  175. <el-input-number
  176. v-model="row.deliverGoodsQuantity"
  177. :precision="2"
  178. :controls="false"
  179. :min="0"
  180. onmousewheel="return false;"
  181. />
  182. </el-form-item>
  183. </template>
  184. </el-table-column>
  185. </el-table>
  186. </div>
  187. </template>
  188. </byForm>
  189. <template #footer>
  190. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  191. <el-button
  192. type="primary"
  193. @click="submitForm()"
  194. size="large"
  195. :loading="submitLoading"
  196. >
  197. 确 定
  198. </el-button>
  199. </template>
  200. </el-dialog>
  201. <el-dialog
  202. :title="'到货详情'"
  203. v-model="dialogVisibleOne"
  204. width="80%"
  205. destroy-on-close
  206. >
  207. <byForm
  208. :formConfig="formConfigOne"
  209. :formOption="formOption"
  210. v-model="formData.dataOne"
  211. :rules="rules"
  212. ref="byformOne"
  213. >
  214. <template #detailSlot>
  215. <div style="width: 100%">
  216. <el-table :data="formData.dataOne.purchaseDetailVoList">
  217. <el-table-column prop="productCustomCode" label="物品编码" />
  218. <el-table-column prop="productName" label="物品名称" />
  219. <el-table-column prop="count" label="采购数量" />
  220. <el-table-column prop="deliverGoodsQuantity" label="已发货">
  221. <template #default="{ row }">
  222. <div>
  223. <el-popover
  224. placement="bottom-start"
  225. title="发货详情"
  226. :width="500"
  227. trigger="hover"
  228. >
  229. <div default>
  230. <el-table :data="row.deliverGoodsDetailList">
  231. <el-table-column
  232. label="发货时间"
  233. prop="createTime"
  234. width="155"
  235. />
  236. <el-table-column
  237. label="物流单号"
  238. prop="logisticsCode"
  239. />
  240. <el-table-column
  241. label="数量"
  242. prop="deliverGoodsQuantity"
  243. width="100"
  244. />
  245. </el-table>
  246. </div>
  247. <template #reference>
  248. <div style="cursor: pointer; color: #0084ff">
  249. {{ row.deliverGoodsQuantity }}
  250. </div>
  251. </template>
  252. </el-popover>
  253. </div>
  254. </template>
  255. </el-table-column>
  256. <!-- <el-table-column prop="arrivalQuantity" label="已到货">
  257. <template #default="{ row }">
  258. <div>
  259. <el-popover
  260. placement="bottom-start"
  261. title="到货详情"
  262. :width="500"
  263. trigger="hover"
  264. >
  265. <div default>
  266. <el-table :data="row.arrivalDetailList">
  267. <el-table-column
  268. label="到货时间"
  269. prop="createTime"
  270. width="155"
  271. />
  272. <el-table-column
  273. label="物流单号"
  274. prop="logisticsCode"
  275. />
  276. <el-table-column
  277. label="数量"
  278. prop="count"
  279. width="100"
  280. />
  281. </el-table>
  282. </div>
  283. <template #reference>
  284. <div style="cursor: pointer; color: #0084ff">
  285. {{ row.arrivalQuantity }}
  286. </div>
  287. </template>
  288. </el-popover>
  289. </div>
  290. </template>
  291. </el-table-column> -->
  292. <el-table-column prop="receiptQuantity" label="已入库">
  293. <template #default="{ row }">
  294. <div>
  295. <el-popover
  296. placement="bottom-start"
  297. title="入库详情"
  298. :width="500"
  299. trigger="hover"
  300. >
  301. <div default>
  302. <el-table :data="row.receiptList">
  303. <el-table-column
  304. label="入库时间"
  305. prop="createTime"
  306. width="155"
  307. />
  308. <el-table-column
  309. label="入库单号"
  310. prop="logisticsCode"
  311. />
  312. <el-table-column
  313. label="数量"
  314. prop="quantity"
  315. width="100"
  316. />
  317. </el-table>
  318. </div>
  319. <template #reference>
  320. <div style="cursor: pointer; color: #0084ff">
  321. {{ row.receiptQuantity }}
  322. </div>
  323. </template>
  324. </el-popover>
  325. </div>
  326. </template>
  327. </el-table-column>
  328. <el-table-column prop="purchaseBackQuantity" label="退货">
  329. <template #default="{ row }">
  330. <div>
  331. <el-popover
  332. placement="bottom-start"
  333. title="退货详情"
  334. :width="500"
  335. trigger="hover"
  336. >
  337. <div default>
  338. <el-table :data="row.purchaseBackDetailsList">
  339. <el-table-column label="申请时间" prop="createTime" />
  340. <el-table-column label="申请数量" prop="quantity" />
  341. <el-table-column
  342. label="已退数量"
  343. prop="returnedQuantity"
  344. />
  345. </el-table>
  346. </div>
  347. <template #reference>
  348. <div style="cursor: pointer; color: #0084ff">
  349. {{ row.purchaseBackQuantity }}
  350. </div>
  351. </template>
  352. </el-popover>
  353. </div>
  354. </template>
  355. </el-table-column>
  356. <el-table-column prop="qualityQuantity" label="已质检数量" />
  357. <el-table-column prop="noQualifiedCount" label="不合格数量" />
  358. </el-table>
  359. </div>
  360. </template>
  361. </byForm>
  362. <template #footer>
  363. <el-button @click="dialogVisibleOne = false" size="large"
  364. >取 消</el-button
  365. >
  366. </template>
  367. </el-dialog>
  368. <el-dialog
  369. :title="'采购退货'"
  370. v-model="dialogVisibleTwo"
  371. width="60%"
  372. destroy-on-close
  373. >
  374. <byForm
  375. :formConfig="formConfigTwo"
  376. :formOption="formOption"
  377. v-model="formData.dataTwo"
  378. :rules="rulesTwo"
  379. ref="byformTwo"
  380. v-loading="loadingTwo"
  381. >
  382. <template #detailSlot>
  383. <div style="width: 100%">
  384. <el-table :data="formData.dataTwo.purchaseBackDetailsList">
  385. <el-table-column
  386. prop="subscribeCode"
  387. label="申购单号"
  388. width="110"
  389. />
  390. <el-table-column
  391. prop="planArrivalTime"
  392. label="要求到货时间"
  393. width="160"
  394. />
  395. <el-table-column
  396. prop="productCustomCode"
  397. label="物品编码"
  398. width="110"
  399. />
  400. <el-table-column
  401. prop="productName"
  402. label="物品名称"
  403. width="160"
  404. />
  405. <el-table-column
  406. prop="productUnit"
  407. label="物品单位"
  408. width="80"
  409. :formatter="
  410. (row) => dictValueLabel(row.productUnit, productUnit)
  411. "
  412. />
  413. <el-table-column
  414. prop="price"
  415. label="单价"
  416. width="60"
  417. :formatter="
  418. (row) => dictValueLabel(row.productUnit, productUnit)
  419. "
  420. />
  421. <el-table-column prop="count" label="采购数量" width="100" />
  422. <el-table-column
  423. prop="defectiveQuantity"
  424. label="次品数量"
  425. width="100"
  426. />
  427. <el-table-column
  428. prop="quantity"
  429. label="退货数量"
  430. min-width="150"
  431. fixed="right"
  432. >
  433. <template #default="{ row, $index }">
  434. <el-form-item
  435. :prop="'purchaseBackDetailsList.' + $index + '.quantity'"
  436. :rules="rulesTwo.quantity"
  437. :inline-message="true"
  438. >
  439. <el-input-number
  440. v-model="row.quantity"
  441. :precision="0"
  442. :controls="false"
  443. :min="0"
  444. onmousewheel="return false;"
  445. />
  446. </el-form-item>
  447. </template>
  448. </el-table-column>
  449. </el-table>
  450. </div>
  451. </template>
  452. <template #countryId>
  453. <div>
  454. <el-select
  455. v-model="formData.dataTwo.countryId"
  456. placeholder="国家"
  457. @change="(val) => getCityData(val, '20', true)"
  458. style="width: 100%"
  459. >
  460. <el-option
  461. v-for="item in countryData"
  462. :label="item.chineseName"
  463. :value="item.id"
  464. >
  465. </el-option>
  466. </el-select>
  467. </div>
  468. </template>
  469. <template #provinceId>
  470. <div style="width: 100%">
  471. <selectCity
  472. placeholder="省/洲"
  473. @change="(val) => getCityData(val, '30', true)"
  474. addressId="provinceId"
  475. addressName="provinceName"
  476. v-model="formData.dataTwo"
  477. :data="provinceData"
  478. >
  479. </selectCity>
  480. </div>
  481. </template>
  482. <template #cityId>
  483. <div style="width: 100%">
  484. <selectCity
  485. placeholder="城市"
  486. addressId="cityId"
  487. addressName="cityName"
  488. v-model="formData.dataTwo"
  489. :data="cityData"
  490. >
  491. </selectCity>
  492. </div>
  493. </template>
  494. </byForm>
  495. <template #footer>
  496. <el-button @click="dialogVisibleTwo = false" size="large"
  497. >取 消</el-button
  498. >
  499. <el-button
  500. type="primary"
  501. @click="submitFormTwo()"
  502. size="large"
  503. :loading="loadingTwo"
  504. >
  505. 确 定
  506. </el-button>
  507. </template>
  508. </el-dialog>
  509. <el-dialog
  510. :title="'高级检索'"
  511. v-model="dialogVisibleThree"
  512. width="500px"
  513. destroy-on-close
  514. >
  515. <el-form
  516. :model="sourceList.pagination"
  517. label-width="100px"
  518. label-position="top"
  519. >
  520. <el-form-item label="采购单号">
  521. <el-input
  522. v-model="sourceList.pagination.contractCode"
  523. placeholder="请输入"
  524. />
  525. </el-form-item>
  526. <el-form-item label="供应商">
  527. <el-select
  528. v-model="sourceList.pagination.supplyId"
  529. placeholder="请选择"
  530. style="width: 100%"
  531. >
  532. <el-option
  533. v-for="item in supplierData"
  534. :label="item.name"
  535. :value="item.id"
  536. >
  537. </el-option>
  538. </el-select>
  539. </el-form-item>
  540. <el-form-item label="收货仓库">
  541. <el-select
  542. v-model="sourceList.pagination.receiptWarehouseId"
  543. placeholder="请选择"
  544. style="width: 100%"
  545. >
  546. <el-option
  547. v-for="item in warehouseList"
  548. :label="item.label"
  549. :value="item.value"
  550. >
  551. </el-option>
  552. </el-select>
  553. </el-form-item>
  554. <el-form-item label="采购金额">
  555. <el-row>
  556. <el-col :span="8">
  557. <el-input-number
  558. v-model="sourceList.pagination.startAmount"
  559. placeholder="请输入"
  560. :controls="false"
  561. :min="1"
  562. :precision="2"
  563. style="width: 100%"
  564. onmousewheel="return false;"
  565. />
  566. </el-col>
  567. <el-col :span="2" style="text-align: center"> 到 </el-col>
  568. <el-col :span="8">
  569. <el-input-number
  570. v-model="sourceList.pagination.endAmount"
  571. placeholder="请输入"
  572. :controls="false"
  573. :min="1"
  574. :precision="2"
  575. style="width: 100%"
  576. onmousewheel="return false;"
  577. />
  578. </el-col>
  579. </el-row>
  580. </el-form-item>
  581. <el-form-item label="采购人">
  582. <el-select
  583. v-model="sourceList.pagination.purchaseUserId"
  584. placeholder="请选择"
  585. style="width: 100%"
  586. >
  587. <el-option
  588. v-for="item in userList"
  589. :label="item.label"
  590. :value="item.value"
  591. >
  592. </el-option>
  593. </el-select>
  594. </el-form-item>
  595. <el-form-item label="采购时间">
  596. <!-- <el-date-picker
  597. v-model="sourceList.pagination.arr"
  598. type="datetimerange"
  599. range-separator="到"
  600. start-placeholder="请选择"
  601. end-placeholder="请选择"
  602. /> -->
  603. <el-date-picker
  604. v-model="sourceList.pagination.arr"
  605. type="daterange"
  606. range-separator="到"
  607. start-placeholder="请选择"
  608. end-placeholder="请选择"
  609. value-format="YYYY-MM-DD HH:mm:ss"
  610. />
  611. </el-form-item>
  612. <el-row>
  613. <el-col :span="7">
  614. <el-form-item label="采购状态">
  615. <el-select
  616. v-model="sourceList.pagination.purchaseStatus"
  617. placeholder="请选择"
  618. style="width: 100%"
  619. >
  620. <el-option
  621. v-for="item in statusData"
  622. :label="item.label"
  623. :value="item.value"
  624. >
  625. </el-option>
  626. </el-select>
  627. </el-form-item>
  628. </el-col>
  629. <el-col :span="1"></el-col>
  630. <el-col :span="7">
  631. <el-form-item label="到货状态">
  632. <el-select
  633. v-model="sourceList.pagination.arrivalStatus"
  634. placeholder="请选择"
  635. style="width: 100%"
  636. >
  637. <el-option
  638. v-for="item in arrivalStatus"
  639. :label="item.label"
  640. :value="item.value"
  641. >
  642. </el-option>
  643. </el-select>
  644. </el-form-item>
  645. </el-col>
  646. <el-col :span="1"></el-col>
  647. <el-col :span="7">
  648. <el-form-item label="付款状态">
  649. <el-select
  650. v-model="sourceList.pagination.payStatus"
  651. placeholder="请选择"
  652. style="width: 100%"
  653. >
  654. <el-option
  655. v-for="item in paymentStatus"
  656. :label="item.label"
  657. :value="item.value"
  658. >
  659. </el-option>
  660. </el-select>
  661. </el-form-item>
  662. </el-col>
  663. </el-row>
  664. </el-form>
  665. <template #footer>
  666. <el-button @click="handleReset" size="large">重置</el-button>
  667. <el-button @click="handleQuery" type="primary" size="large"
  668. >搜索</el-button
  669. >
  670. </template>
  671. </el-dialog>
  672. <!-- <el-drawer v-model="dialogVisibleThree" direction="rtl">
  673. <template #header>
  674. <h4>高级检索</h4>
  675. </template>
  676. <template #default>
  677. <byForm
  678. :formConfig="formConfig"
  679. :formOption="ListOption"
  680. v-model="sourceList.pagination"
  681. >
  682. <template #slot> 可自定义所需功能 </template>
  683. </byForm>
  684. </template>
  685. <template #footer>
  686. <div style="flex: auto">
  687. <el-button @click="handleReset" size="large">重置</el-button>
  688. <el-button @click="handleQuery" type="primary" size="large"
  689. >搜索</el-button
  690. >
  691. </div>
  692. </template>
  693. </el-drawer> -->
  694. </div>
  695. </template>
  696. <script setup>
  697. import { ElMessage, ElMessageBox } from "element-plus";
  698. import byTable from "@/components/byTable/index";
  699. import byForm from "@/components/byForm/index";
  700. import { computed } from "vue";
  701. import selectCity from "@/components/selectCity/index.vue";
  702. import useUserStore from "@/store/modules/user";
  703. const loading = ref(false);
  704. const loadingTwo = ref(false);
  705. const submitLoading = ref(false);
  706. const sourceList = ref({
  707. data: [],
  708. pagination: {
  709. total: 3,
  710. pageNum: 1,
  711. pageSize: 10,
  712. arr: [],
  713. },
  714. });
  715. const dialogVisible = ref(false);
  716. const dialogVisibleOne = ref(false);
  717. const dialogVisibleTwo = ref(false);
  718. const dialogVisibleThree = ref(false);
  719. const modalType = ref("add");
  720. let rules = ref({
  721. deliverGoodsId: [
  722. { required: true, message: "请选择快递单号", trigger: "change" },
  723. ],
  724. logisticsCompanyCode: [
  725. { required: true, message: "请选择物流公司", trigger: "change" },
  726. ],
  727. code: [{ required: true, message: "请输入物流/快递单号", trigger: "blur" }],
  728. deliverGoodsQuantity: [
  729. { required: true, message: "请输入本次发货", trigger: "blur" },
  730. ],
  731. aa: [{ required: true, message: "请输入退货数量", trigger: "blur" }],
  732. });
  733. let rulesTwo = ref({
  734. contacts: [{ required: true, message: "请输入收件人", trigger: "blur" }],
  735. phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
  736. countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
  737. quantity: [{ required: true, message: "请输入退货数量", trigger: "blur" }],
  738. detailedAddress: [
  739. { required: true, message: "请输入详细地址", trigger: "blur" },
  740. ],
  741. });
  742. const { proxy } = getCurrentInstance();
  743. const arrivalStatus = [
  744. {
  745. label: "未到货",
  746. value: "0",
  747. },
  748. {
  749. label: "部分到货",
  750. value: "10",
  751. },
  752. {
  753. label: "已到货",
  754. value: "20",
  755. },
  756. ];
  757. const statusData = ref([
  758. {
  759. label: "审批中",
  760. value: "10",
  761. },
  762. {
  763. label: "驳回",
  764. value: "20",
  765. },
  766. {
  767. label: "已采购",
  768. value: "30",
  769. },
  770. {
  771. label: "结束",
  772. value: "99",
  773. },
  774. {
  775. label: "已作废",
  776. value: "88",
  777. },
  778. ]);
  779. const paymentStatus = ref([
  780. {
  781. label: "未付款",
  782. value: "0",
  783. },
  784. {
  785. label: "部分付款",
  786. value: "10",
  787. },
  788. {
  789. label: "已付款",
  790. value: "20",
  791. },
  792. ]);
  793. const selectConfig = reactive([
  794. {
  795. label: "采购状态",
  796. prop: "purchaseStatus",
  797. data: statusData.value,
  798. },
  799. {
  800. label: "到货状态",
  801. prop: "arrivalStatus",
  802. data: arrivalStatus,
  803. },
  804. {
  805. label: "付款状态",
  806. prop: "payStatus",
  807. data: paymentStatus.value,
  808. },
  809. ]);
  810. const config = computed(() => {
  811. return [
  812. {
  813. attrs: {
  814. label: "采购单号",
  815. prop: "contractCode",
  816. slot: "contractCode",
  817. },
  818. },
  819. {
  820. attrs: {
  821. label: "供应商",
  822. prop: "supplyName",
  823. width: 180,
  824. },
  825. },
  826. {
  827. attrs: {
  828. label: "收货仓库",
  829. prop: "receiptWarehouseName",
  830. },
  831. },
  832. {
  833. attrs: {
  834. label: "采购金额",
  835. prop: "amount",
  836. },
  837. render(amount) {
  838. return proxy.moneyFormat(amount, 2);
  839. },
  840. },
  841. {
  842. attrs: {
  843. label: "采购人",
  844. prop: "purchaseName",
  845. width: 150,
  846. },
  847. },
  848. {
  849. attrs: {
  850. label: "采购时间",
  851. prop: "createTime",
  852. width: 160,
  853. },
  854. },
  855. {
  856. attrs: {
  857. label: "采购状态",
  858. prop: "purchaseStatus",
  859. },
  860. render(status) {
  861. const current = statusData.value.find((x) => x.value == status);
  862. if (current) return current.label;
  863. },
  864. },
  865. {
  866. attrs: {
  867. label: "到货状态",
  868. prop: "arrivalStatus",
  869. slot: "arrivalStatus",
  870. },
  871. },
  872. {
  873. attrs: {
  874. label: "付款状态",
  875. prop: "payStatus",
  876. },
  877. render(status) {
  878. return proxy.dictValueLabel(status, paymentStatus.value);
  879. },
  880. },
  881. {
  882. attrs: {
  883. label: "操作",
  884. slot: "btn",
  885. width: "260",
  886. align: "center",
  887. fixed: "right",
  888. },
  889. },
  890. ];
  891. });
  892. let formData = reactive({
  893. data: {},
  894. dataOne: {},
  895. dataTwo: {},
  896. });
  897. const formOption = reactive({
  898. inline: true,
  899. labelWidth: 100,
  900. itemWidth: 100,
  901. });
  902. const byform = ref(null);
  903. const byformTwo = ref(null);
  904. let formConfig = reactive([]);
  905. let formConfigOne = computed(() => [
  906. {
  907. type: "title",
  908. title: "基础信息",
  909. },
  910. {
  911. type: "input",
  912. prop: "supplyName",
  913. label: "供应商",
  914. disabled: true,
  915. itemWidth: 50,
  916. },
  917. {
  918. type: "input",
  919. prop: "purchaseCode",
  920. label: "采购单号",
  921. disabled: true,
  922. itemWidth: 50,
  923. },
  924. {
  925. type: "title",
  926. title: "采购明细",
  927. },
  928. {
  929. type: "slot",
  930. slotName: "detailSlot",
  931. label: "",
  932. },
  933. ]);
  934. let formConfigTwo = computed(() => [
  935. {
  936. type: "title",
  937. title: "基础信息",
  938. },
  939. {
  940. type: "input",
  941. prop: "supplyName",
  942. label: "供应商",
  943. disabled: true,
  944. itemWidth: 50,
  945. },
  946. {
  947. type: "input",
  948. prop: "purchaseCode",
  949. label: "采购单号",
  950. disabled: true,
  951. itemWidth: 50,
  952. },
  953. {
  954. type: "title",
  955. title: "采购明细",
  956. },
  957. {
  958. type: "slot",
  959. slotName: "detailSlot",
  960. label: "",
  961. },
  962. {
  963. type: "title",
  964. title: "收货信息",
  965. },
  966. {
  967. type: "input",
  968. prop: "contacts",
  969. label: "收件人",
  970. itemWidth: 20,
  971. placeholder: "收件人",
  972. },
  973. {
  974. type: "input",
  975. prop: "phone",
  976. label: " ",
  977. itemWidth: 80,
  978. placeholder: "联系电话",
  979. style: {
  980. width: "30%",
  981. },
  982. },
  983. {
  984. type: "slot",
  985. slotName: "countryId",
  986. prop: "countryId",
  987. label: "收件地址",
  988. itemWidth: 33.33,
  989. },
  990. {
  991. type: "slot",
  992. slotName: "provinceId",
  993. label: " ",
  994. itemWidth: 33.33,
  995. },
  996. {
  997. type: "slot",
  998. slotName: "cityId",
  999. prop: "cityId",
  1000. label: " ",
  1001. itemWidth: 33.33,
  1002. },
  1003. {
  1004. type: "input",
  1005. itemType: "textarea",
  1006. prop: "detailedAddress",
  1007. },
  1008. ]);
  1009. const logisticsData = ref([]);
  1010. const getLogisticsData = (row) => {
  1011. proxy.post("/companyInfo/list", { pageNum: 1, pageSize: 999 }).then((res) => {
  1012. logisticsData.value = res.reverse();
  1013. logisticsData.value = logisticsData.value.map((x) => ({
  1014. label: x.name,
  1015. value: x.code,
  1016. }));
  1017. });
  1018. };
  1019. const configData = computed(() => [
  1020. [
  1021. {
  1022. type: "title",
  1023. title: "基础信息",
  1024. },
  1025. {
  1026. type: "input",
  1027. prop: "supplyName",
  1028. label: "供应商",
  1029. disabled: true,
  1030. itemWidth: 50,
  1031. },
  1032. {
  1033. type: "input",
  1034. prop: "purchaseCode",
  1035. label: "采购单号",
  1036. disabled: true,
  1037. itemWidth: 50,
  1038. },
  1039. {
  1040. type: "select",
  1041. label: "物流信息",
  1042. prop: "logisticsCompanyCode",
  1043. filterable: true,
  1044. data: logisticsData.value,
  1045. itemWidth: 50,
  1046. style: {
  1047. width: "100%",
  1048. },
  1049. },
  1050. {
  1051. type: "input",
  1052. label: " ",
  1053. prop: "code",
  1054. placeholder: "物流/快递单号",
  1055. itemWidth: 50,
  1056. },
  1057. {
  1058. type: "title",
  1059. title: "发货明细",
  1060. },
  1061. {
  1062. type: "slot",
  1063. slotName: "detailSlot",
  1064. label: "",
  1065. },
  1066. ],
  1067. [
  1068. {
  1069. type: "title",
  1070. title: "基础信息",
  1071. },
  1072. {
  1073. type: "input",
  1074. prop: "supplyName",
  1075. label: "供应商",
  1076. disabled: true,
  1077. itemWidth: 50,
  1078. },
  1079. {
  1080. type: "input",
  1081. prop: "purchaseCode",
  1082. label: "采购单号",
  1083. disabled: true,
  1084. itemWidth: 50,
  1085. },
  1086. {
  1087. type: "select",
  1088. label: "物流/快递单号",
  1089. prop: "deliverGoodsId",
  1090. itemWidth: 50,
  1091. style: {
  1092. width: "100%",
  1093. },
  1094. },
  1095. {
  1096. type: "title",
  1097. title: "发货明细",
  1098. },
  1099. {
  1100. type: "slot",
  1101. slotName: "detailSlot",
  1102. label: "",
  1103. },
  1104. ],
  1105. ]);
  1106. const deliverData = ref([]);
  1107. const getList = async (req) => {
  1108. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  1109. loading.value = true;
  1110. proxy
  1111. .post("/purchase/pageByWdly", sourceList.value.pagination)
  1112. .then((message) => {
  1113. sourceList.value.data = message.rows.map((x) => ({
  1114. ...x,
  1115. ...JSON.parse(x.victoriatouristJson),
  1116. }));
  1117. sourceList.value.pagination.total = message.total;
  1118. setTimeout(() => {
  1119. loading.value = false;
  1120. }, 200);
  1121. });
  1122. };
  1123. const submitForm = () => {
  1124. byform.value.handleSubmit((valid) => {
  1125. if (modalType.value === "add") {
  1126. const list = formData.data.deliverGoodsDetailsList;
  1127. const total = list.reduce(
  1128. (total, x) => (total += Number(x.deliverGoodsQuantity)),
  1129. 0
  1130. );
  1131. if (!(total > 0)) {
  1132. return ElMessage({
  1133. message: `本次发货不能为0!`,
  1134. type: "info",
  1135. });
  1136. }
  1137. // for (let i = 0; i < list.length; i++) {
  1138. // const e = list[i];
  1139. // if (
  1140. // Number(e.alreadyDeliverGoodsQuantity) +
  1141. // Number(e.deliverGoodsQuantity) >
  1142. // Number(e.count)
  1143. // ) {
  1144. // return ElMessage({
  1145. // message: `本次发货加累计发货不可大于采购数量!`,
  1146. // type: "info",
  1147. // });
  1148. // }
  1149. // }
  1150. submitLoading.value = true;
  1151. formData.data.deliverGoodsDetailsList = list.map((x) => ({
  1152. purchaseDetailId: x.purchaseDetailId,
  1153. deliverGoodsQuantity: x.deliverGoodsQuantity,
  1154. }));
  1155. proxy.post("/deliverGoods/add", formData.data).then((res) => {
  1156. ElMessage({
  1157. message: `操作成功!`,
  1158. type: "success",
  1159. });
  1160. dialogVisible.value = false;
  1161. submitLoading.value = false;
  1162. getList();
  1163. });
  1164. } else if (modalType.value === "edit") {
  1165. submitLoading.value = true;
  1166. formData.data.arrivalDetailList = formData.data.arrivalDetailList.map(
  1167. (x) => ({
  1168. bussinessId: x.bussinessId,
  1169. purchaseDetailId: x.purchaseDetailId,
  1170. deliverGoodsDetailsId: x.deliverGoodsDetailsId,
  1171. count: x.deliverGoodsQuantity,
  1172. })
  1173. );
  1174. const victoriatouristJson = {
  1175. deliverGoodsId: formData.data.deliverGoodsId,
  1176. logisticsCompanyCode: formData.data.logisticsCompanyCode,
  1177. code: formData.data.code,
  1178. };
  1179. formData.data.victoriatouristJson = JSON.stringify(victoriatouristJson);
  1180. proxy.post("/arrival/addByWdly", formData.data).then((res) => {
  1181. ElMessage({
  1182. message: `操作成功!`,
  1183. type: "success",
  1184. });
  1185. dialogVisible.value = false;
  1186. submitLoading.value = false;
  1187. getList();
  1188. });
  1189. }
  1190. });
  1191. };
  1192. const submitFormTwo = () => {
  1193. byformTwo.value.handleSubmit((valid) => {
  1194. loadingTwo.value = true;
  1195. let submitData = { ...formData.dataTwo };
  1196. submitData.purchaseBackDetailsList = submitData.purchaseBackDetailsList.map(
  1197. (x) => ({
  1198. purchaseDetailsId: x.id,
  1199. productId: x.bussinessId,
  1200. quantity: x.quantity,
  1201. })
  1202. );
  1203. proxy.post("/purchaseBack/add", submitData).then(
  1204. (res) => {
  1205. ElMessage({
  1206. message: `操作成功!`,
  1207. type: "success",
  1208. });
  1209. dialogVisibleTwo.value = false;
  1210. loadingTwo.value = false;
  1211. getList();
  1212. },
  1213. (err) => {
  1214. loadingTwo.value = false;
  1215. }
  1216. );
  1217. });
  1218. };
  1219. const getDtl = (row) => {
  1220. modalType.value = "edit";
  1221. proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
  1222. formData.data = res;
  1223. dialogVisible.value = true;
  1224. });
  1225. };
  1226. const handleEdit = (row, status) => {
  1227. let purchaseStatusName = status == 88 ? "作废" : "结束";
  1228. const data = { ...row, purchaseStatus: status };
  1229. // 弹窗提示是否删除
  1230. ElMessageBox.confirm(
  1231. `此操作将${purchaseStatusName}该数据, 是否继续?`,
  1232. "提示",
  1233. {
  1234. confirmButtonText: "确定",
  1235. cancelButtonText: "取消",
  1236. type: "warning",
  1237. }
  1238. ).then(() => {
  1239. // 删除
  1240. proxy.post("/purchase/edit", data).then((res) => {
  1241. ElMessage({
  1242. message: `${purchaseStatusName}成功`,
  1243. type: "success",
  1244. });
  1245. getList();
  1246. });
  1247. });
  1248. };
  1249. const handleArrival = (row, type) => {
  1250. modalType.value = type;
  1251. if (type === "add") {
  1252. formConfig = configData.value[0];
  1253. proxy.post("/deliverGoodsDetails/detail", { id: row.id }).then((res) => {
  1254. formData.data = {
  1255. purchaseId: row.id,
  1256. supplyName: row.supplyName,
  1257. purchaseCode: row.contractCode,
  1258. supplyId: res.supplyId,
  1259. code: "",
  1260. logisticsCompanyCode: "",
  1261. deliverGoodsDetailsList: res.map((x) => ({
  1262. ...x,
  1263. purchaseDetailId: x.id,
  1264. alreadyDeliverGoodsQuantity: x.deliverGoodsQuantity,
  1265. deliverGoodsQuantity:
  1266. Number(x.count) - Number(x.deliverGoodsQuantity),
  1267. })),
  1268. };
  1269. dialogVisible.value = true;
  1270. });
  1271. } else if (type === "edit") {
  1272. formConfig = configData.value[1];
  1273. proxy.post("/deliverGoods/list", { id: row.id }).then((res) => {
  1274. deliverData.value = res;
  1275. formConfig[3].data = res.map((x) => ({
  1276. ...x,
  1277. label: x.code,
  1278. value: x.id,
  1279. }));
  1280. formData.data = {
  1281. purchaseId: row.id,
  1282. supplyName: row.supplyName,
  1283. purchaseCode: row.contractCode,
  1284. supplyId: row.supplyId,
  1285. code: "",
  1286. logisticsCompanyCode: "",
  1287. deliverGoodsId: "",
  1288. arrivalDetailList: [],
  1289. };
  1290. dialogVisible.value = true;
  1291. });
  1292. }
  1293. };
  1294. watch(
  1295. () => formData.data.deliverGoodsId,
  1296. (val) => {
  1297. if (val) {
  1298. const current = deliverData.value.find((x) => x.id === val);
  1299. formData.data.logisticsCompanyCode = current
  1300. ? current.logisticsCompanyCode
  1301. : "";
  1302. formData.data.code = current ? current.code : "";
  1303. proxy.post("/deliverGoods/detail", { id: val }).then((res) => {
  1304. formData.data.arrivalDetailList = res.map((x) => ({
  1305. count: x.count,
  1306. productName: x.name,
  1307. productSpec: x.spec,
  1308. productUnit: x.unit,
  1309. productType: x.type,
  1310. productCode: x.code,
  1311. bussinessId: x.productId,
  1312. purchaseDetailId: x.purchaseDetailId,
  1313. deliverGoodsDetailsId: x.id,
  1314. transitQuantity: x.transitQuantity,
  1315. deliverGoodsQuantity: x.deliverGoodsQuantity,
  1316. productDefinition: x.definition,
  1317. }));
  1318. });
  1319. }
  1320. }
  1321. );
  1322. const handleClickContractCode = (row) => {
  1323. proxy.$router.push({
  1324. path: "/platform_manage/process/processApproval",
  1325. query: {
  1326. flowKey: row.processInstanceId,
  1327. id: row.flowId,
  1328. businessId: row.id,
  1329. processType: 20,
  1330. },
  1331. });
  1332. };
  1333. const handleClickArrivalStatus = (row) => {
  1334. proxy
  1335. .post("/deliverGoods/arrivalDetail", { purchaseId: row.id })
  1336. .then((res) => {
  1337. formData.dataOne = {
  1338. supplyName: row.supplyName,
  1339. purchaseCode: row.contractCode,
  1340. purchaseDetailVoList: res.purchaseDetailVoList,
  1341. };
  1342. dialogVisibleOne.value = true;
  1343. });
  1344. };
  1345. const handleReturnGoods = (row) => {
  1346. proxy.post("/purchase/detail", { id: row.id }).then((res) => {
  1347. formData.dataTwo = {
  1348. purchaseId: row.id,
  1349. supplyName: row.supplyName,
  1350. purchaseCode: row.contractCode,
  1351. countryId: "44",
  1352. purchaseBackDetailsList: res.purchaseDetailList.map((x) => ({
  1353. ...x,
  1354. planArrivalTime: res.planArrivalTime,
  1355. subscribeCode: res.subscribeCode,
  1356. })),
  1357. };
  1358. getCityData(formData.dataTwo.countryId, "20");
  1359. dialogVisibleTwo.value = true;
  1360. });
  1361. };
  1362. const countryData = ref([]);
  1363. const provinceData = ref([]);
  1364. const cityData = ref([]);
  1365. const getCityData = (id, type, flag) => {
  1366. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  1367. if (type === "20") {
  1368. provinceData.value = res;
  1369. if (flag) {
  1370. formData.data.provinceId = "";
  1371. formData.data.provinceName = "";
  1372. formData.data.cityId = "";
  1373. formData.data.cityName = "";
  1374. }
  1375. } else if (type === "30") {
  1376. cityData.value = res;
  1377. if (flag) {
  1378. formData.data.cityId = "";
  1379. formData.data.cityName = "";
  1380. }
  1381. } else {
  1382. countryData.value = res;
  1383. }
  1384. });
  1385. };
  1386. const productUnit = ref([]);
  1387. const supplierData = ref([]);
  1388. const warehouseList = ref([]);
  1389. const userList = ref([]);
  1390. const getDict = () => {
  1391. proxy.getDictOne(["unit"]).then((res) => {
  1392. productUnit.value = res["unit"].map((x) => ({
  1393. label: x.dictValue,
  1394. value: x.dictKey,
  1395. }));
  1396. });
  1397. proxy
  1398. .post("/supplierInfo/page", { pageNum: 1, pageSize: 9999 })
  1399. .then((res) => {
  1400. supplierData.value = res.rows;
  1401. });
  1402. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  1403. if (res.rows && res.rows.length > 0) {
  1404. warehouseList.value = res.rows.map((item) => {
  1405. return {
  1406. label: item.name,
  1407. value: item.id,
  1408. };
  1409. });
  1410. }
  1411. });
  1412. proxy
  1413. .get("/tenantUser/list", {
  1414. pageNum: 1,
  1415. pageSize: 10000,
  1416. tenantId: useUserStore().user.tenantId,
  1417. })
  1418. .then((res) => {
  1419. userList.value = res.rows.map((item) => {
  1420. return {
  1421. label: item.nickName,
  1422. value: item.userId,
  1423. };
  1424. });
  1425. });
  1426. };
  1427. getCityData("0");
  1428. getList();
  1429. getLogisticsData();
  1430. getDict();
  1431. const handleQuery = () => {
  1432. if (
  1433. sourceList.value.pagination.arr &&
  1434. sourceList.value.pagination.arr.length > 1
  1435. ) {
  1436. sourceList.value.pagination.purchaseStartTime =
  1437. sourceList.value.pagination.arr[0];
  1438. sourceList.value.pagination.purchaseEndTime =
  1439. sourceList.value.pagination.arr[1];
  1440. }
  1441. dialogVisibleThree.value = false;
  1442. getList();
  1443. };
  1444. const handleReset = () => {
  1445. sourceList.value.pagination = {
  1446. pageNum: sourceList.value.pagination.pageNum,
  1447. pageSize: sourceList.value.pagination.pageSize,
  1448. arr: [],
  1449. };
  1450. handleQuery();
  1451. };
  1452. </script>
  1453. <style lang="scss" scoped>
  1454. .tenant {
  1455. padding: 20px;
  1456. }
  1457. </style>