index.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  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 inRransitData = ref([
  794. {
  795. label: "有",
  796. value: "1",
  797. },
  798. {
  799. label: "无",
  800. value: "0",
  801. },
  802. ]);
  803. const selectConfig = reactive([
  804. {
  805. label: "采购状态",
  806. prop: "purchaseStatus",
  807. data: statusData.value,
  808. },
  809. {
  810. label: "到货状态",
  811. prop: "arrivalStatus",
  812. data: arrivalStatus,
  813. },
  814. {
  815. label: "付款状态",
  816. prop: "payStatus",
  817. data: paymentStatus.value,
  818. },
  819. {
  820. label: "有无在途",
  821. prop: "isTransit",
  822. data: inRransitData.value,
  823. },
  824. ]);
  825. const config = computed(() => {
  826. return [
  827. {
  828. attrs: {
  829. label: "采购单号",
  830. prop: "contractCode",
  831. slot: "contractCode",
  832. },
  833. },
  834. {
  835. attrs: {
  836. label: "供应商",
  837. prop: "supplyName",
  838. width: 180,
  839. },
  840. },
  841. {
  842. attrs: {
  843. label: "收货仓库",
  844. prop: "receiptWarehouseName",
  845. },
  846. },
  847. {
  848. attrs: {
  849. label: "采购金额",
  850. prop: "amount",
  851. },
  852. render(amount) {
  853. return proxy.moneyFormat(amount, 2);
  854. },
  855. },
  856. {
  857. attrs: {
  858. label: "采购人",
  859. prop: "purchaseName",
  860. width: 150,
  861. },
  862. },
  863. {
  864. attrs: {
  865. label: "采购时间",
  866. prop: "createTime",
  867. width: 160,
  868. },
  869. },
  870. {
  871. attrs: {
  872. label: "采购状态",
  873. prop: "purchaseStatus",
  874. },
  875. render(status) {
  876. const current = statusData.value.find((x) => x.value == status);
  877. if (current) return current.label;
  878. },
  879. },
  880. {
  881. attrs: {
  882. label: "到货状态",
  883. prop: "arrivalStatus",
  884. slot: "arrivalStatus",
  885. },
  886. },
  887. {
  888. attrs: {
  889. label: "付款状态",
  890. prop: "payStatus",
  891. },
  892. render(status) {
  893. return proxy.dictValueLabel(status, paymentStatus.value);
  894. },
  895. },
  896. {
  897. attrs: {
  898. label: "操作",
  899. slot: "btn",
  900. width: "260",
  901. align: "center",
  902. fixed: "right",
  903. },
  904. },
  905. ];
  906. });
  907. let formData = reactive({
  908. data: {},
  909. dataOne: {},
  910. dataTwo: {},
  911. });
  912. const formOption = reactive({
  913. inline: true,
  914. labelWidth: 100,
  915. itemWidth: 100,
  916. });
  917. const byform = ref(null);
  918. const byformTwo = ref(null);
  919. let formConfig = reactive([]);
  920. let formConfigOne = computed(() => [
  921. {
  922. type: "title",
  923. title: "基础信息",
  924. },
  925. {
  926. type: "input",
  927. prop: "supplyName",
  928. label: "供应商",
  929. disabled: true,
  930. itemWidth: 50,
  931. },
  932. {
  933. type: "input",
  934. prop: "purchaseCode",
  935. label: "采购单号",
  936. disabled: true,
  937. itemWidth: 50,
  938. },
  939. {
  940. type: "title",
  941. title: "采购明细",
  942. },
  943. {
  944. type: "slot",
  945. slotName: "detailSlot",
  946. label: "",
  947. },
  948. ]);
  949. let formConfigTwo = computed(() => [
  950. {
  951. type: "title",
  952. title: "基础信息",
  953. },
  954. {
  955. type: "input",
  956. prop: "supplyName",
  957. label: "供应商",
  958. disabled: true,
  959. itemWidth: 50,
  960. },
  961. {
  962. type: "input",
  963. prop: "purchaseCode",
  964. label: "采购单号",
  965. disabled: true,
  966. itemWidth: 50,
  967. },
  968. {
  969. type: "title",
  970. title: "采购明细",
  971. },
  972. {
  973. type: "slot",
  974. slotName: "detailSlot",
  975. label: "",
  976. },
  977. {
  978. type: "title",
  979. title: "收货信息",
  980. },
  981. {
  982. type: "input",
  983. prop: "contacts",
  984. label: "收件人",
  985. itemWidth: 20,
  986. placeholder: "收件人",
  987. },
  988. {
  989. type: "input",
  990. prop: "phone",
  991. label: " ",
  992. itemWidth: 80,
  993. placeholder: "联系电话",
  994. style: {
  995. width: "30%",
  996. },
  997. },
  998. {
  999. type: "slot",
  1000. slotName: "countryId",
  1001. prop: "countryId",
  1002. label: "收件地址",
  1003. itemWidth: 33.33,
  1004. },
  1005. {
  1006. type: "slot",
  1007. slotName: "provinceId",
  1008. label: " ",
  1009. itemWidth: 33.33,
  1010. },
  1011. {
  1012. type: "slot",
  1013. slotName: "cityId",
  1014. prop: "cityId",
  1015. label: " ",
  1016. itemWidth: 33.33,
  1017. },
  1018. {
  1019. type: "input",
  1020. itemType: "textarea",
  1021. prop: "detailedAddress",
  1022. },
  1023. ]);
  1024. const logisticsData = ref([]);
  1025. const getLogisticsData = (row) => {
  1026. proxy.post("/companyInfo/list", { pageNum: 1, pageSize: 999 }).then((res) => {
  1027. logisticsData.value = res.reverse();
  1028. logisticsData.value = logisticsData.value.map((x) => ({
  1029. label: x.name,
  1030. value: x.code,
  1031. }));
  1032. });
  1033. };
  1034. const configData = computed(() => [
  1035. [
  1036. {
  1037. type: "title",
  1038. title: "基础信息",
  1039. },
  1040. {
  1041. type: "input",
  1042. prop: "supplyName",
  1043. label: "供应商",
  1044. disabled: true,
  1045. itemWidth: 50,
  1046. },
  1047. {
  1048. type: "input",
  1049. prop: "purchaseCode",
  1050. label: "采购单号",
  1051. disabled: true,
  1052. itemWidth: 50,
  1053. },
  1054. {
  1055. type: "select",
  1056. label: "物流信息",
  1057. prop: "logisticsCompanyCode",
  1058. filterable: true,
  1059. data: logisticsData.value,
  1060. itemWidth: 50,
  1061. style: {
  1062. width: "100%",
  1063. },
  1064. },
  1065. {
  1066. type: "input",
  1067. label: " ",
  1068. prop: "code",
  1069. placeholder: "物流/快递单号",
  1070. itemWidth: 50,
  1071. },
  1072. {
  1073. type: "title",
  1074. title: "发货明细",
  1075. },
  1076. {
  1077. type: "slot",
  1078. slotName: "detailSlot",
  1079. label: "",
  1080. },
  1081. ],
  1082. [
  1083. {
  1084. type: "title",
  1085. title: "基础信息",
  1086. },
  1087. {
  1088. type: "input",
  1089. prop: "supplyName",
  1090. label: "供应商",
  1091. disabled: true,
  1092. itemWidth: 50,
  1093. },
  1094. {
  1095. type: "input",
  1096. prop: "purchaseCode",
  1097. label: "采购单号",
  1098. disabled: true,
  1099. itemWidth: 50,
  1100. },
  1101. {
  1102. type: "select",
  1103. label: "物流/快递单号",
  1104. prop: "deliverGoodsId",
  1105. itemWidth: 50,
  1106. style: {
  1107. width: "100%",
  1108. },
  1109. },
  1110. {
  1111. type: "title",
  1112. title: "发货明细",
  1113. },
  1114. {
  1115. type: "slot",
  1116. slotName: "detailSlot",
  1117. label: "",
  1118. },
  1119. ],
  1120. ]);
  1121. const deliverData = ref([]);
  1122. const getList = async (req) => {
  1123. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  1124. loading.value = true;
  1125. proxy
  1126. .post("/purchase/pageByWdly", sourceList.value.pagination)
  1127. .then((message) => {
  1128. sourceList.value.data = message.rows.map((x) => ({
  1129. ...x,
  1130. ...JSON.parse(x.victoriatouristJson),
  1131. }));
  1132. sourceList.value.pagination.total = message.total;
  1133. setTimeout(() => {
  1134. loading.value = false;
  1135. }, 200);
  1136. });
  1137. };
  1138. const submitForm = () => {
  1139. byform.value.handleSubmit((valid) => {
  1140. if (modalType.value === "add") {
  1141. const list = formData.data.deliverGoodsDetailsList;
  1142. const total = list.reduce(
  1143. (total, x) => (total += Number(x.deliverGoodsQuantity)),
  1144. 0
  1145. );
  1146. if (!(total > 0)) {
  1147. return ElMessage({
  1148. message: `本次发货不能为0!`,
  1149. type: "info",
  1150. });
  1151. }
  1152. // for (let i = 0; i < list.length; i++) {
  1153. // const e = list[i];
  1154. // if (
  1155. // Number(e.alreadyDeliverGoodsQuantity) +
  1156. // Number(e.deliverGoodsQuantity) >
  1157. // Number(e.count)
  1158. // ) {
  1159. // return ElMessage({
  1160. // message: `本次发货加累计发货不可大于采购数量!`,
  1161. // type: "info",
  1162. // });
  1163. // }
  1164. // }
  1165. submitLoading.value = true;
  1166. formData.data.deliverGoodsDetailsList = list.map((x) => ({
  1167. purchaseDetailId: x.purchaseDetailId,
  1168. deliverGoodsQuantity: x.deliverGoodsQuantity,
  1169. }));
  1170. proxy.post("/deliverGoods/add", formData.data).then((res) => {
  1171. ElMessage({
  1172. message: `操作成功!`,
  1173. type: "success",
  1174. });
  1175. dialogVisible.value = false;
  1176. submitLoading.value = false;
  1177. getList();
  1178. });
  1179. } else if (modalType.value === "edit") {
  1180. submitLoading.value = true;
  1181. formData.data.arrivalDetailList = formData.data.arrivalDetailList.map(
  1182. (x) => ({
  1183. bussinessId: x.bussinessId,
  1184. purchaseDetailId: x.purchaseDetailId,
  1185. deliverGoodsDetailsId: x.deliverGoodsDetailsId,
  1186. count: x.deliverGoodsQuantity,
  1187. })
  1188. );
  1189. const victoriatouristJson = {
  1190. deliverGoodsId: formData.data.deliverGoodsId,
  1191. logisticsCompanyCode: formData.data.logisticsCompanyCode,
  1192. code: formData.data.code,
  1193. };
  1194. formData.data.victoriatouristJson = JSON.stringify(victoriatouristJson);
  1195. proxy.post("/arrival/addByWdly", formData.data).then((res) => {
  1196. ElMessage({
  1197. message: `操作成功!`,
  1198. type: "success",
  1199. });
  1200. dialogVisible.value = false;
  1201. submitLoading.value = false;
  1202. getList();
  1203. });
  1204. }
  1205. });
  1206. };
  1207. const submitFormTwo = () => {
  1208. byformTwo.value.handleSubmit((valid) => {
  1209. loadingTwo.value = true;
  1210. let submitData = { ...formData.dataTwo };
  1211. submitData.purchaseBackDetailsList = submitData.purchaseBackDetailsList.map(
  1212. (x) => ({
  1213. purchaseDetailsId: x.id,
  1214. productId: x.bussinessId,
  1215. quantity: x.quantity,
  1216. })
  1217. );
  1218. proxy.post("/purchaseBack/add", submitData).then(
  1219. (res) => {
  1220. ElMessage({
  1221. message: `操作成功!`,
  1222. type: "success",
  1223. });
  1224. dialogVisibleTwo.value = false;
  1225. loadingTwo.value = false;
  1226. getList();
  1227. },
  1228. (err) => {
  1229. loadingTwo.value = false;
  1230. }
  1231. );
  1232. });
  1233. };
  1234. const getDtl = (row) => {
  1235. modalType.value = "edit";
  1236. proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
  1237. formData.data = res;
  1238. dialogVisible.value = true;
  1239. });
  1240. };
  1241. const handleEdit = (row, status) => {
  1242. let purchaseStatusName = status == 88 ? "作废" : "结束";
  1243. const data = { ...row, purchaseStatus: status };
  1244. // 弹窗提示是否删除
  1245. ElMessageBox.confirm(
  1246. `此操作将${purchaseStatusName}该数据, 是否继续?`,
  1247. "提示",
  1248. {
  1249. confirmButtonText: "确定",
  1250. cancelButtonText: "取消",
  1251. type: "warning",
  1252. }
  1253. ).then(() => {
  1254. // 删除
  1255. proxy.post("/purchase/edit", data).then((res) => {
  1256. ElMessage({
  1257. message: `${purchaseStatusName}成功`,
  1258. type: "success",
  1259. });
  1260. getList();
  1261. });
  1262. });
  1263. };
  1264. const handleArrival = (row, type) => {
  1265. modalType.value = type;
  1266. if (type === "add") {
  1267. formConfig = configData.value[0];
  1268. proxy.post("/deliverGoodsDetails/detail", { id: row.id }).then((res) => {
  1269. formData.data = {
  1270. purchaseId: row.id,
  1271. supplyName: row.supplyName,
  1272. purchaseCode: row.contractCode,
  1273. supplyId: res.supplyId,
  1274. code: "",
  1275. logisticsCompanyCode: "",
  1276. deliverGoodsDetailsList: res.map((x) => ({
  1277. ...x,
  1278. purchaseDetailId: x.id,
  1279. alreadyDeliverGoodsQuantity: x.deliverGoodsQuantity,
  1280. deliverGoodsQuantity:
  1281. Number(x.count) - Number(x.deliverGoodsQuantity),
  1282. })),
  1283. };
  1284. dialogVisible.value = true;
  1285. });
  1286. } else if (type === "edit") {
  1287. formConfig = configData.value[1];
  1288. proxy.post("/deliverGoods/list", { id: row.id }).then((res) => {
  1289. deliverData.value = res;
  1290. formConfig[3].data = res.map((x) => ({
  1291. ...x,
  1292. label: x.code,
  1293. value: x.id,
  1294. }));
  1295. formData.data = {
  1296. purchaseId: row.id,
  1297. supplyName: row.supplyName,
  1298. purchaseCode: row.contractCode,
  1299. supplyId: row.supplyId,
  1300. code: "",
  1301. logisticsCompanyCode: "",
  1302. deliverGoodsId: "",
  1303. arrivalDetailList: [],
  1304. };
  1305. dialogVisible.value = true;
  1306. });
  1307. }
  1308. };
  1309. watch(
  1310. () => formData.data.deliverGoodsId,
  1311. (val) => {
  1312. if (val) {
  1313. const current = deliverData.value.find((x) => x.id === val);
  1314. formData.data.logisticsCompanyCode = current
  1315. ? current.logisticsCompanyCode
  1316. : "";
  1317. formData.data.code = current ? current.code : "";
  1318. proxy.post("/deliverGoods/detail", { id: val }).then((res) => {
  1319. formData.data.arrivalDetailList = res.map((x) => ({
  1320. count: x.count,
  1321. productName: x.name,
  1322. productSpec: x.spec,
  1323. productUnit: x.unit,
  1324. productType: x.type,
  1325. productCode: x.code,
  1326. bussinessId: x.productId,
  1327. purchaseDetailId: x.purchaseDetailId,
  1328. deliverGoodsDetailsId: x.id,
  1329. transitQuantity: x.transitQuantity,
  1330. deliverGoodsQuantity: x.deliverGoodsQuantity,
  1331. productDefinition: x.definition,
  1332. }));
  1333. });
  1334. }
  1335. }
  1336. );
  1337. const handleClickContractCode = (row) => {
  1338. proxy.$router.push({
  1339. path: "/platform_manage/process/processApproval",
  1340. query: {
  1341. flowKey: row.processInstanceId,
  1342. id: row.flowId,
  1343. businessId: row.id,
  1344. processType: 20,
  1345. },
  1346. });
  1347. };
  1348. const handleClickArrivalStatus = (row) => {
  1349. proxy
  1350. .post("/deliverGoods/arrivalDetail", { purchaseId: row.id })
  1351. .then((res) => {
  1352. formData.dataOne = {
  1353. supplyName: row.supplyName,
  1354. purchaseCode: row.contractCode,
  1355. purchaseDetailVoList: res.purchaseDetailVoList,
  1356. };
  1357. dialogVisibleOne.value = true;
  1358. });
  1359. };
  1360. const handleReturnGoods = (row) => {
  1361. proxy.post("/purchase/detail", { id: row.id }).then((res) => {
  1362. formData.dataTwo = {
  1363. purchaseId: row.id,
  1364. supplyName: row.supplyName,
  1365. purchaseCode: row.contractCode,
  1366. countryId: "44",
  1367. purchaseBackDetailsList: res.purchaseDetailList.map((x) => ({
  1368. ...x,
  1369. planArrivalTime: res.planArrivalTime,
  1370. subscribeCode: res.subscribeCode,
  1371. })),
  1372. };
  1373. getCityData(formData.dataTwo.countryId, "20");
  1374. dialogVisibleTwo.value = true;
  1375. });
  1376. };
  1377. const countryData = ref([]);
  1378. const provinceData = ref([]);
  1379. const cityData = ref([]);
  1380. const getCityData = (id, type, flag) => {
  1381. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  1382. if (type === "20") {
  1383. provinceData.value = res;
  1384. if (flag) {
  1385. formData.data.provinceId = "";
  1386. formData.data.provinceName = "";
  1387. formData.data.cityId = "";
  1388. formData.data.cityName = "";
  1389. }
  1390. } else if (type === "30") {
  1391. cityData.value = res;
  1392. if (flag) {
  1393. formData.data.cityId = "";
  1394. formData.data.cityName = "";
  1395. }
  1396. } else {
  1397. countryData.value = res;
  1398. }
  1399. });
  1400. };
  1401. const productUnit = ref([]);
  1402. const supplierData = ref([]);
  1403. const warehouseList = ref([]);
  1404. const userList = ref([]);
  1405. const getDict = () => {
  1406. proxy.getDictOne(["unit"]).then((res) => {
  1407. productUnit.value = res["unit"].map((x) => ({
  1408. label: x.dictValue,
  1409. value: x.dictKey,
  1410. }));
  1411. });
  1412. proxy
  1413. .post("/supplierInfo/page", { pageNum: 1, pageSize: 9999 })
  1414. .then((res) => {
  1415. supplierData.value = res.rows;
  1416. });
  1417. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  1418. if (res.rows && res.rows.length > 0) {
  1419. warehouseList.value = res.rows.map((item) => {
  1420. return {
  1421. label: item.name,
  1422. value: item.id,
  1423. };
  1424. });
  1425. }
  1426. });
  1427. proxy
  1428. .get("/tenantUser/list", {
  1429. pageNum: 1,
  1430. pageSize: 10000,
  1431. tenantId: useUserStore().user.tenantId,
  1432. })
  1433. .then((res) => {
  1434. userList.value = res.rows.map((item) => {
  1435. return {
  1436. label: item.nickName,
  1437. value: item.userId,
  1438. };
  1439. });
  1440. });
  1441. };
  1442. getCityData("0");
  1443. getList();
  1444. getLogisticsData();
  1445. getDict();
  1446. const handleQuery = () => {
  1447. if (
  1448. sourceList.value.pagination.arr &&
  1449. sourceList.value.pagination.arr.length > 1
  1450. ) {
  1451. sourceList.value.pagination.purchaseStartTime =
  1452. sourceList.value.pagination.arr[0];
  1453. sourceList.value.pagination.purchaseEndTime =
  1454. sourceList.value.pagination.arr[1];
  1455. }
  1456. dialogVisibleThree.value = false;
  1457. getList();
  1458. };
  1459. const handleReset = () => {
  1460. sourceList.value.pagination = {
  1461. pageNum: sourceList.value.pagination.pageNum,
  1462. pageSize: sourceList.value.pagination.pageSize,
  1463. arr: [],
  1464. };
  1465. handleQuery();
  1466. };
  1467. </script>
  1468. <style lang="scss" scoped>
  1469. .tenant {
  1470. padding: 20px;
  1471. }
  1472. </style>