index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: selectRow,
  15. }"
  16. :action-list="[
  17. {
  18. text: '合并付款',
  19. disabled: selectData.length === 0,
  20. action: () => handlePayment(20),
  21. },
  22. ]"
  23. @get-list="getList"
  24. >
  25. <!-- {
  26. text: '导出Excel',
  27. disabled: false,
  28. action: () => deriveExcel(),
  29. }, -->
  30. <template #contractCode="{ item }">
  31. <div
  32. style="cursor: pointer; color: #409eff"
  33. @click="handleClickContractCode(item)"
  34. >
  35. {{ item.contractCode }}
  36. </div>
  37. </template>
  38. <template #payStatus="{ item }">
  39. <div
  40. style="cursor: pointer; color: #409eff"
  41. @click="handleClickPayStatus(item)"
  42. >
  43. {{ dictValueLabel(item.payStatus, paymentStatus) }}
  44. </div>
  45. </template>
  46. <template #btn="{ item }">
  47. <div>
  48. <el-button
  49. type="primary"
  50. v-if="item.payStatus != 0"
  51. link
  52. @click="handleRefund(item)"
  53. >退款</el-button
  54. >
  55. <el-button
  56. type="primary"
  57. link
  58. v-if="item.payStatus != 30"
  59. @click="handlePayment(10, item)"
  60. >付款</el-button
  61. >
  62. <el-button
  63. type="primary"
  64. link
  65. v-if="item.payStatus != 30"
  66. @click="handleEnd(item)"
  67. >结束</el-button
  68. >
  69. <el-button type="primary" link @click="handleClear(item)"
  70. >清空</el-button
  71. >
  72. </div>
  73. </template>
  74. </byTable>
  75. </div>
  76. <el-dialog
  77. :title="'付款'"
  78. v-model="dialogVisible"
  79. width="80%"
  80. v-loading="submitLoading"
  81. destroy-on-close
  82. :before-close="handleClose"
  83. >
  84. <byForm
  85. :formConfig="formConfig"
  86. :formOption="formOption"
  87. v-model="formData.data"
  88. :rules="rules"
  89. ref="byform"
  90. >
  91. <template #details>
  92. <div style="width: 100%">
  93. <el-table :data="formData.data.purchasePayRecordDetailList">
  94. <el-table-column prop="code" label="采购单号" />
  95. <el-table-column
  96. prop="isAgreement"
  97. label="是否合同"
  98. :formatter="(row) => (row.isAgreement == 1 ? '是' : '否')"
  99. />
  100. <el-table-column
  101. prop="paymentMethod"
  102. label="付款方式"
  103. :formatter="
  104. (row) => dictValueLabel(row.paymentMethod, fundsPaymentMethod)
  105. "
  106. />
  107. <el-table-column prop="remark" label="采购备注" />
  108. <el-table-column prop="waitAmount" label="采购金额" />
  109. <el-table-column prop="alreadyAmount" label="已付款金额" />
  110. <el-table-column prop="amount" label="付款金额" min-width="150">
  111. <template #default="{ row, $index }">
  112. <el-form-item
  113. :prop="'purchasePayRecordDetailList.' + $index + '.amount'"
  114. :rules="rules.amount"
  115. :inline-message="true"
  116. >
  117. <el-input-number
  118. v-model="row.amount"
  119. :precision="4"
  120. :controls="false"
  121. :min="0"
  122. onmousewheel="return false;"
  123. @change="handleChangeAmount"
  124. />
  125. </el-form-item>
  126. </template>
  127. </el-table-column>
  128. <el-table-column prop="remark" label="备注" min-width="150">
  129. <template #default="{ row, $index }">
  130. <el-form-item
  131. :prop="'purchasePayRecordDetailList.' + $index + '.remark'"
  132. :rules="rules.remark"
  133. :inline-message="true"
  134. >
  135. <el-input
  136. v-model="row.remark"
  137. placeholder="请输入"
  138. type="textarea"
  139. />
  140. </el-form-item>
  141. </template>
  142. </el-table-column>
  143. </el-table>
  144. </div>
  145. </template>
  146. <template #file>
  147. <div style="width: 100%">
  148. <el-upload
  149. v-model:fileList="formData.data.fileList"
  150. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  151. :data="uploadData"
  152. multiple
  153. :before-upload="uploadFile"
  154. :on-success="handleSuccess"
  155. :on-preview="onPreviewFile"
  156. >
  157. <el-button type="primary" plain>选择</el-button>
  158. </el-upload>
  159. </div>
  160. </template>
  161. </byForm>
  162. <template #footer>
  163. <el-button @click="handleClose" size="large">取 消</el-button>
  164. <el-button
  165. v-if="modalType == 'add'"
  166. type="primary"
  167. @click="submitForm('byform')"
  168. size="large"
  169. :loading="submitLoading"
  170. >
  171. 确 定
  172. </el-button>
  173. </template>
  174. </el-dialog>
  175. <el-dialog
  176. :title="'退款'"
  177. v-model="dialogVisibleTwo"
  178. width="800"
  179. v-loading="submitLoading"
  180. destroy-on-close
  181. >
  182. <byForm
  183. :formConfig="formConfigOne"
  184. :formOption="formOption"
  185. v-model="formData.dataOne"
  186. :rules="rulesOne"
  187. ref="byformOne"
  188. >
  189. </byForm>
  190. <template #footer>
  191. <el-button @click="dialogVisibleTwo = false" size="large"
  192. >取 消</el-button
  193. >
  194. <el-button
  195. type="primary"
  196. @click="submitFormOne()"
  197. size="large"
  198. :loading="submitLoading"
  199. >
  200. 确 定
  201. </el-button>
  202. </template>
  203. </el-dialog>
  204. <el-dialog
  205. v-model="dialogVisibleOne"
  206. title="交易记录"
  207. width="500"
  208. append-to-body
  209. destroy-on-close
  210. >
  211. <div>
  212. <el-timeline :reverse="false">
  213. <el-timeline-item
  214. placement="top"
  215. v-for="(activity, index) in activities"
  216. :key="index"
  217. >
  218. <div
  219. style="
  220. display: flex;
  221. justify-content: space-between;
  222. align-items: center;
  223. "
  224. >
  225. <div style="color: #909399">
  226. {{ activity.payUserName }}
  227. </div>
  228. <el-button type="primary" plain @click="handleGetDtl(activity)"
  229. >查看详情</el-button
  230. >
  231. </div>
  232. <div v-if="activity.type == '1'">
  233. <div style="margin-top: 5px">
  234. 类型: <span style="color: #8fe3a1">付款 </span>
  235. </div>
  236. <div style="margin-top: 5px">
  237. 付款账号:
  238. {{ dictValueLabel(activity.payAccount, accountData) }}
  239. </div>
  240. <div style="margin-top: 5px">
  241. 付款金额:{{ moneyFormat(activity.amount, 2) }}
  242. </div>
  243. <div style="margin-top: 5px">
  244. 付款时间: {{ activity.payDate }}
  245. </div>
  246. <div style="margin-top: 5px">
  247. 付款备注: {{ activity.remark }}
  248. </div>
  249. </div>
  250. <div v-if="activity.type == '2'">
  251. <div style="margin-top: 5px">
  252. 类型: <span style="color: #fc0000">退款</span>
  253. </div>
  254. <div style="margin-top: 5px">
  255. 退款账号:
  256. {{ dictValueLabel(activity.payAccount, accountData) }}
  257. </div>
  258. <div style="margin-top: 5px">
  259. 退款金额:{{ moneyFormat(activity.amount, 2) }}
  260. </div>
  261. <div style="margin-top: 5px">
  262. 退款时间: {{ activity.payDate }}
  263. </div>
  264. <div style="margin-top: 5px">
  265. 退款备注: {{ activity.remark }}
  266. </div>
  267. </div>
  268. <div
  269. style="width: 100%; margin-top: 5px"
  270. v-if="activity.fileList && activity.fileList.length > 0"
  271. >
  272. <div v-for="(item, index) in activity.fileList" :key="index">
  273. <div
  274. style="cursor: pointer; color: #409eff"
  275. @click="openFile(item)"
  276. >
  277. {{ item.fileName }}
  278. </div>
  279. </div>
  280. </div>
  281. </el-timeline-item>
  282. </el-timeline>
  283. </div>
  284. <template #footer>
  285. <el-button @click="dialogVisibleOne = false">关闭</el-button>
  286. </template>
  287. </el-dialog>
  288. <el-dialog
  289. :title="'到货详情'"
  290. v-model="dialogVisibleThree"
  291. width="80%"
  292. destroy-on-close
  293. >
  294. <byForm
  295. :formConfig="formConfigTwo"
  296. :formOption="formOption"
  297. v-model="formData.dataTwo"
  298. :rules="rules"
  299. ref="byformOne"
  300. >
  301. <template #detailSlot>
  302. <div style="width: 100%">
  303. <el-table :data="formData.dataTwo.purchaseDetailVoList">
  304. <el-table-column prop="productCustomCode" label="物品编码" />
  305. <el-table-column prop="productName" label="物品名称" />
  306. <el-table-column prop="count" label="采购数量" />
  307. <el-table-column prop="deliverGoodsQuantity" label="已发货">
  308. <template #default="{ row }">
  309. <div>
  310. <el-popover
  311. placement="bottom-start"
  312. title="发货详情"
  313. :width="500"
  314. trigger="hover"
  315. >
  316. <div default>
  317. <el-table :data="row.deliverGoodsDetailList">
  318. <el-table-column
  319. label="发货时间"
  320. prop="createTime"
  321. width="155"
  322. />
  323. <el-table-column
  324. label="物流单号"
  325. prop="logisticsCode"
  326. />
  327. <el-table-column
  328. label="数量"
  329. prop="deliverGoodsQuantity"
  330. width="100"
  331. />
  332. </el-table>
  333. </div>
  334. <template #reference>
  335. <div style="cursor: pointer; color: #0084ff">
  336. {{ row.deliverGoodsQuantity }}
  337. </div>
  338. </template>
  339. </el-popover>
  340. </div>
  341. </template>
  342. </el-table-column>
  343. <el-table-column prop="receiptQuantity" label="已入库">
  344. <template #default="{ row }">
  345. <div>
  346. <el-popover
  347. placement="bottom-start"
  348. title="入库详情"
  349. :width="500"
  350. trigger="hover"
  351. >
  352. <div default>
  353. <el-table :data="row.receiptList">
  354. <el-table-column
  355. label="入库时间"
  356. prop="createTime"
  357. width="155"
  358. />
  359. <el-table-column
  360. label="入库单号"
  361. prop="logisticsCode"
  362. />
  363. <el-table-column
  364. label="数量"
  365. prop="quantity"
  366. width="100"
  367. />
  368. </el-table>
  369. </div>
  370. <template #reference>
  371. <div style="cursor: pointer; color: #0084ff">
  372. {{ row.receiptQuantity }}
  373. </div>
  374. </template>
  375. </el-popover>
  376. </div>
  377. </template>
  378. </el-table-column>
  379. <el-table-column prop="purchaseBackQuantity" label="退货">
  380. <template #default="{ row }">
  381. <div>
  382. <el-popover
  383. placement="bottom-start"
  384. title="退货详情"
  385. :width="500"
  386. trigger="hover"
  387. >
  388. <div default>
  389. <el-table :data="row.purchaseBackDetailsList">
  390. <el-table-column label="申请时间" prop="createTime" />
  391. <el-table-column label="申请数量" prop="quantity" />
  392. <el-table-column
  393. label="已退数量"
  394. prop="returnedQuantity"
  395. />
  396. </el-table>
  397. </div>
  398. <template #reference>
  399. <div style="cursor: pointer; color: #0084ff">
  400. {{ row.purchaseBackQuantity }}
  401. </div>
  402. </template>
  403. </el-popover>
  404. </div>
  405. </template>
  406. </el-table-column>
  407. <el-table-column prop="qualityQuantity" label="已质检数量" />
  408. <el-table-column prop="noQualifiedCount" label="不合格数量" />
  409. </el-table>
  410. </div>
  411. </template>
  412. </byForm>
  413. <template #footer>
  414. <el-button @click="dialogVisibleThree = false" size="large"
  415. >取 消</el-button
  416. >
  417. </template>
  418. </el-dialog>
  419. </div>
  420. </template>
  421. <script setup>
  422. import { ElMessage, ElMessageBox } from "element-plus";
  423. import byTable from "@/components/byTable/index";
  424. import byForm from "@/components/byForm/index";
  425. const uploadData = ref({});
  426. const loading = ref(false);
  427. const submitLoading = ref(false);
  428. const sourceList = ref({
  429. data: [],
  430. pagination: {
  431. total: 3,
  432. pageNum: 1,
  433. pageSize: 10,
  434. type: "",
  435. keyword: "",
  436. purchaseStatus: "30,99",
  437. },
  438. });
  439. let dialogVisible = ref(false);
  440. let dialogVisibleOne = ref(false);
  441. let activities = ref([]);
  442. let modalType = ref("add");
  443. let rules = ref({
  444. amount: [{ required: true, message: "请输入付款金额", trigger: "blur" }],
  445. payDate: [{ required: true, message: "请选择付款时间", trigger: "change" }],
  446. payAccount: [
  447. { required: true, message: "请选择付款账号", trigger: "change" },
  448. ],
  449. });
  450. let rulesOne = ref({
  451. amount: [{ required: true, message: "请输入退款金额", trigger: "blur" }],
  452. refundDate: [
  453. { required: true, message: "请选择退款时间", trigger: "change" },
  454. ],
  455. refundAccount: [
  456. { required: true, message: "请选择退款账号", trigger: "change" },
  457. ],
  458. // remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
  459. });
  460. const { proxy } = getCurrentInstance();
  461. const arrivalStatus = ref([
  462. {
  463. label: "未到货",
  464. value: "0",
  465. },
  466. {
  467. label: "部分到货",
  468. value: "10",
  469. },
  470. {
  471. label: "已到货",
  472. value: "20",
  473. },
  474. ]);
  475. const paymentStatus = ref([
  476. {
  477. label: "未付款",
  478. value: "0",
  479. },
  480. {
  481. label: "部分付款",
  482. value: "10",
  483. },
  484. {
  485. label: "已付款",
  486. value: "20",
  487. },
  488. {
  489. label: "付款结束",
  490. value: "30",
  491. },
  492. ]);
  493. const alreadyPurchase = ref([]);
  494. const deptData = ref([]);
  495. const selectConfig = computed(() => [
  496. {
  497. label: "到货状态",
  498. prop: "arrivalStatus",
  499. data: arrivalStatus.value,
  500. },
  501. {
  502. label: "付款状态",
  503. prop: "payStatus",
  504. data: paymentStatus.value,
  505. },
  506. {
  507. label: "采购人",
  508. prop: "purchaseUserId",
  509. data: alreadyPurchase.value,
  510. },
  511. {
  512. label: "项目组",
  513. prop: "deptId",
  514. data: deptData.value,
  515. },
  516. ]);
  517. const config = computed(() => {
  518. return [
  519. {
  520. type: "selection",
  521. attrs: {
  522. checkAtt: "isCheck",
  523. },
  524. },
  525. {
  526. attrs: {
  527. label: "采购单号",
  528. slot: "contractCode",
  529. },
  530. },
  531. {
  532. attrs: {
  533. label: "供应商",
  534. prop: "supplyName",
  535. },
  536. },
  537. {
  538. attrs: {
  539. label: "收货仓库",
  540. prop: "receiptWarehouseName",
  541. },
  542. },
  543. {
  544. attrs: {
  545. label: "项目组",
  546. prop: "deptName",
  547. width: 150,
  548. },
  549. },
  550. {
  551. attrs: {
  552. label: "采购金额",
  553. prop: "amount",
  554. width: 100,
  555. },
  556. render(amount) {
  557. return proxy.moneyFormat(amount, 2);
  558. },
  559. },
  560. {
  561. attrs: {
  562. label: "已付款金额",
  563. prop: "paidAmount",
  564. width: 100,
  565. },
  566. render(paidAmount) {
  567. return proxy.moneyFormat(paidAmount, 2);
  568. },
  569. },
  570. {
  571. attrs: {
  572. label: "退款金额",
  573. prop: "refundAmount",
  574. width: 100,
  575. },
  576. render(refundAmount) {
  577. return proxy.moneyFormat(refundAmount, 2);
  578. },
  579. },
  580. {
  581. attrs: {
  582. label: "采购人",
  583. prop: "purchaseName",
  584. width: 150,
  585. },
  586. },
  587. {
  588. attrs: {
  589. label: "采购时间",
  590. prop: "createTime",
  591. width: 155,
  592. },
  593. },
  594. {
  595. attrs: {
  596. label: "到货状态",
  597. prop: "arrivalStatus",
  598. width: 100,
  599. },
  600. render(status) {
  601. return proxy.dictValueLabel(status, arrivalStatus.value);
  602. },
  603. },
  604. {
  605. attrs: {
  606. label: "付款状态",
  607. slot: "payStatus",
  608. width: 100,
  609. },
  610. },
  611. {
  612. attrs: {
  613. label: "操作",
  614. slot: "btn",
  615. width: "200",
  616. align: "center",
  617. fixed: "right",
  618. },
  619. },
  620. ];
  621. });
  622. let formData = reactive({
  623. data: {
  624. type: "1",
  625. },
  626. dataOne: {},
  627. dataTwo: {},
  628. });
  629. const formOption = reactive({
  630. disabled: false,
  631. inline: true,
  632. labelWidth: 100,
  633. itemWidth: 100,
  634. rules: [],
  635. });
  636. const byform = ref(null);
  637. let formConfig = computed(() => [
  638. {
  639. type: "input",
  640. prop: "supplyName",
  641. label: "供应商",
  642. disabled: true,
  643. },
  644. {
  645. type: "date",
  646. itemType: "datetime",
  647. prop: "payDate",
  648. label: "付款时间",
  649. format: "YYYY-MM-DD HH:mm:ss",
  650. itemWidth: 35,
  651. },
  652. {
  653. type: "select",
  654. prop: "payAccount",
  655. label: "付款账号",
  656. data: accountData.value,
  657. itemWidth: 50,
  658. },
  659. {
  660. type: "number",
  661. prop: "amount",
  662. label: "付款金额",
  663. precision: 4,
  664. min: 0,
  665. controls: false,
  666. disabled: true,
  667. },
  668. {
  669. type: "input",
  670. itemType: "textarea",
  671. prop: "remark",
  672. label: "备注",
  673. disabled: false,
  674. },
  675. {
  676. type: "slot",
  677. slotName: "file",
  678. label: "附件",
  679. },
  680. {
  681. type: "title",
  682. title: "付款明细",
  683. },
  684. {
  685. type: "slot",
  686. slotName: "details",
  687. label: "",
  688. },
  689. ]);
  690. const dialogVisibleTwo = ref(false);
  691. const dialogVisibleThree = ref(false);
  692. const byformOne = ref(null);
  693. let formConfigOne = computed(() => [
  694. {
  695. type: "input",
  696. prop: "supplyName",
  697. label: "供应商",
  698. disabled: true,
  699. },
  700. {
  701. type: "input",
  702. prop: "contractCode",
  703. label: "采购单号",
  704. disabled: true,
  705. itemWidth: 34,
  706. },
  707. {
  708. type: "date",
  709. itemType: "datetime",
  710. prop: "refundDate",
  711. label: "退款时间",
  712. format: "YYYY-MM-DD HH:mm:ss",
  713. itemWidth: 100,
  714. },
  715. {
  716. type: "select",
  717. prop: "refundAccount",
  718. label: "退款账号",
  719. data: accountData.value,
  720. itemWidth: 100,
  721. },
  722. {
  723. type: "number",
  724. prop: "amount",
  725. label: "退款金额",
  726. precision: 4,
  727. min: 1,
  728. controls: false,
  729. // disabled: true,
  730. },
  731. {
  732. type: "input",
  733. itemType: "textarea",
  734. prop: "remark",
  735. label: "备注",
  736. disabled: false,
  737. },
  738. ]);
  739. let formConfigTwo = computed(() => [
  740. {
  741. type: "title",
  742. title: "基础信息",
  743. },
  744. {
  745. type: "input",
  746. prop: "supplyName",
  747. label: "供应商",
  748. disabled: true,
  749. itemWidth: 50,
  750. },
  751. {
  752. type: "input",
  753. prop: "purchaseCode",
  754. label: "采购单号",
  755. disabled: true,
  756. itemWidth: 50,
  757. },
  758. {
  759. type: "title",
  760. title: "采购明细",
  761. },
  762. {
  763. type: "slot",
  764. slotName: "detailSlot",
  765. label: "",
  766. },
  767. ]);
  768. const getList = async (req) => {
  769. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  770. loading.value = true;
  771. proxy
  772. .post("/purchase/pageByWdly", sourceList.value.pagination)
  773. .then((res) => {
  774. sourceList.value.data = res.rows.map((x) => ({
  775. ...x,
  776. ...JSON.parse(x.victoriatouristJson),
  777. isCheck: true,
  778. }));
  779. sourceList.value.pagination.total = res.total;
  780. setTimeout(() => {
  781. loading.value = false;
  782. }, 200);
  783. });
  784. };
  785. const submitForm = () => {
  786. byform.value.handleSubmit((valid) => {
  787. const list = formData.data.purchasePayRecordDetailList;
  788. for (let i = 0; i < list.length; i++) {
  789. const e = list[i];
  790. if (Number(e.amount) + Number(e.alreadyAmount) > Number(e.waitAmount)) {
  791. return ElMessage({
  792. message: `本次付款加已付款金额不可大于采购金额`,
  793. type: "info",
  794. });
  795. }
  796. }
  797. // const total = list.reduce((total, x) => (total += Number(x.amount)), 0);
  798. // if (Number(formData.data.amount) != total) {
  799. // return ElMessage({
  800. // message: "本次付款合计必须等于上方的付款金额",
  801. // type: "info",
  802. // });
  803. // }
  804. formData.data.fileList = formData.data.fileList.map((item) => {
  805. return {
  806. id: item.raw.id,
  807. fileName: item.raw.fileName,
  808. fileUrl: item.raw.fileUrl,
  809. uploadState: item.raw.uploadState,
  810. };
  811. });
  812. proxy.post("/purchasePayRecord/add", formData.data).then(
  813. (res) => {
  814. ElMessage({
  815. message: "操作成功",
  816. type: "success",
  817. });
  818. handleClose();
  819. submitLoading.value = false;
  820. getList();
  821. },
  822. (err) => {
  823. submitLoading.value = false;
  824. }
  825. );
  826. });
  827. };
  828. const submitFormOne = () => {
  829. byformOne.value.handleSubmit((valid) => {
  830. submitLoading.value = true;
  831. proxy.post("/purchaseRefundRecord/add", formData.dataOne).then(
  832. (res) => {
  833. ElMessage({
  834. message: "操作成功",
  835. type: "success",
  836. });
  837. dialogVisibleTwo.value = false;
  838. submitLoading.value = false;
  839. getList();
  840. },
  841. (err) => {
  842. submitLoading.value = false;
  843. }
  844. );
  845. });
  846. };
  847. const selectData = ref([]);
  848. const selectRow = (data) => {
  849. if (data && data.length > 0) {
  850. selectData.value = data.map((x) => {
  851. if (x.victoriatouristJson) {
  852. let obj = JSON.parse(x.victoriatouristJson);
  853. if (obj.isAgreement) {
  854. x.isAgreement = obj.isAgreement;
  855. }
  856. if (obj.paymentMethod) {
  857. x.paymentMethod = obj.paymentMethod;
  858. }
  859. }
  860. return x;
  861. });
  862. } else {
  863. selectData.value = [];
  864. }
  865. };
  866. const handleClose = () => {
  867. selectData.value = [];
  868. dialogVisible.value = false;
  869. };
  870. watch(selectData, (newVal, oldVal) => {
  871. if (newVal.length == 0) {
  872. sourceList.value.data.forEach((x) => {
  873. x.isCheck = true;
  874. });
  875. } else if (newVal.length == 1) {
  876. const current = newVal[0];
  877. sourceList.value.data.forEach((x) => {
  878. if (x.supplyId !== current.supplyId) {
  879. x.isCheck = false;
  880. }
  881. });
  882. }
  883. });
  884. const handlePayment = (type, data) => {
  885. modalType.value = "add";
  886. formOption.disabled = false;
  887. if (type === 10) {
  888. selectData.value = [data];
  889. } else if (type === 20) {
  890. }
  891. formData.data = {
  892. type: "1",
  893. supplyName: selectData.value[0].supplyName,
  894. amount: "",
  895. payDate: "",
  896. purchasePayRecordDetailList: selectData.value.map((x) => ({
  897. purchaseId: x.id,
  898. code: x.contractCode,
  899. waitAmount: x.amount,
  900. alreadyAmount: x.paidAmount,
  901. amount: null,
  902. remark: "",
  903. isAgreement: x.isAgreement,
  904. paymentMethod: x.paymentMethod,
  905. remark: x.remark,
  906. })),
  907. fileList: [],
  908. };
  909. dialogVisible.value = true;
  910. };
  911. const handleRefund = (row) => {
  912. formOption.disabled = false;
  913. formData.dataOne = {
  914. type: "2",
  915. purchaseId: row.id,
  916. supplyName: row.supplyName,
  917. contractCode: row.contractCode,
  918. amount: "",
  919. refundDate: "",
  920. remark: "",
  921. };
  922. dialogVisibleTwo.value = true;
  923. };
  924. const currentRow = ref({});
  925. const handleClickPayStatus = (row) => {
  926. currentRow.value = row;
  927. proxy
  928. .post("/purchasePayRecordDetail/page", { purchaseId: row.id })
  929. .then((res) => {
  930. if (res && res.rows && res.rows.length > 0) {
  931. activities.value = res.rows;
  932. const idList = activities.value.map((x) => x.purchasePayRecordId);
  933. // 请求文件数据并回显
  934. if (idList.length > 0) {
  935. proxy
  936. .post("/fileInfo/getList", {
  937. businessIdList: idList,
  938. })
  939. .then((fileObj) => {
  940. if (fileObj) {
  941. for (let i = 0; i < activities.value.length; i++) {
  942. const e = activities.value[i];
  943. for (const key in fileObj) {
  944. if (e.purchasePayRecordId === key) {
  945. e.fileList = fileObj[key];
  946. }
  947. }
  948. }
  949. }
  950. });
  951. }
  952. dialogVisibleOne.value = true;
  953. } else {
  954. return ElMessage({
  955. message: `暂无付款记录`,
  956. type: "info",
  957. });
  958. }
  959. });
  960. };
  961. const handleEnd = (row) => {
  962. // 弹窗提示是否删除
  963. ElMessageBox.confirm("是否确认结束?", "提示", {
  964. confirmButtonText: "确定",
  965. cancelButtonText: "取消",
  966. type: "warning",
  967. }).then(() => {
  968. // 删除
  969. proxy
  970. .post("/purchase/edit", {
  971. ...row,
  972. payStatus: 30,
  973. })
  974. .then((res) => {
  975. ElMessage({
  976. message: "操作成功",
  977. type: "success",
  978. });
  979. getList();
  980. });
  981. });
  982. };
  983. const handleClear = (row) => {
  984. // 弹窗提示是否删除
  985. ElMessageBox.confirm("是否确认清空付款记录?", "提示", {
  986. confirmButtonText: "确定",
  987. cancelButtonText: "取消",
  988. type: "warning",
  989. }).then(() => {
  990. // 删除
  991. proxy
  992. .post("/purchasePayRecordDetail/empty", {
  993. purchaseId: row.id,
  994. })
  995. .then((res) => {
  996. ElMessage({
  997. message: "操作成功",
  998. type: "success",
  999. });
  1000. getList();
  1001. });
  1002. });
  1003. };
  1004. const handleChangeAmount = () => {
  1005. let amount = 0;
  1006. for (let i = 0; i < formData.data.purchasePayRecordDetailList.length; i++) {
  1007. const e = formData.data.purchasePayRecordDetailList[i];
  1008. amount += e.amount;
  1009. }
  1010. formData.data.amount = parseFloat(amount).toFixed(4);
  1011. };
  1012. const accountData = ref([]);
  1013. const fundsPaymentMethod = ref([]);
  1014. const getDict = () => {
  1015. proxy.get("/purchase/getPurchaseUserList").then((res) => {
  1016. alreadyPurchase.value = res.data.map((x) => ({
  1017. label: x.nickName,
  1018. value: x.userId,
  1019. }));
  1020. });
  1021. proxy.get("/purchase/getDepts").then((res) => {
  1022. deptData.value = res.data.map((x) => ({
  1023. ...x,
  1024. label: x.deptName,
  1025. value: x.deptId,
  1026. }));
  1027. });
  1028. proxy
  1029. .getDictOne(["purchase_payment_account", "funds_payment_method"])
  1030. .then((res) => {
  1031. accountData.value = res["purchase_payment_account"].map((x) => ({
  1032. label: x.dictValue,
  1033. value: x.dictKey,
  1034. }));
  1035. fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
  1036. label: x.dictValue,
  1037. value: x.dictKey,
  1038. }));
  1039. });
  1040. };
  1041. const handleClickContractCode = (row) => {
  1042. // proxy
  1043. // .post("/deliverGoods/arrivalDetail", { purchaseId: row.id })
  1044. // .then((res) => {
  1045. // formData.dataTwo = {
  1046. // supplyName: row.supplyName,
  1047. // purchaseCode: row.contractCode,
  1048. // purchaseDetailVoList: res.purchaseDetailVoList,
  1049. // };
  1050. // dialogVisibleThree.value = true;
  1051. // });
  1052. proxy.$router.push({
  1053. path: "/platform_manage/process/processApproval",
  1054. query: {
  1055. flowKey: row.processInstanceId,
  1056. id: row.flowId,
  1057. businessId: row.id,
  1058. processType: 20,
  1059. },
  1060. });
  1061. };
  1062. getList();
  1063. getDict();
  1064. // 上传文件
  1065. const uploadFile = async (file) => {
  1066. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  1067. uploadData.value = res.uploadBody;
  1068. file.id = res.id;
  1069. file.fileName = res.fileName;
  1070. file.fileUrl = res.fileUrl;
  1071. file.uploadState = true;
  1072. return true;
  1073. };
  1074. const handleSuccess = (any, UploadFile) => {
  1075. UploadFile.raw.uploadState = false;
  1076. };
  1077. const onPreviewFile = (file) => {
  1078. window.open(file.raw.fileUrl, "_blank");
  1079. };
  1080. const openFile = (item) => {
  1081. window.open(item.fileUrl, "_blank");
  1082. };
  1083. const handleGetDtl = (row) => {
  1084. if (row.type == "1") {
  1085. modalType.value = "edit";
  1086. formOption.disabled = true;
  1087. dialogVisible.value = true;
  1088. proxy
  1089. .post("/purchasePayRecord/detail", {
  1090. id: row.purchasePayRecordId,
  1091. })
  1092. .then((res) => {
  1093. res.supplyName = currentRow.value.supplyName;
  1094. formData.data = res;
  1095. formData.data.purchasePayRecordDetailList =
  1096. formData.data.purchasePayRecordDetailList.map((x) => ({
  1097. ...x,
  1098. code: x.contractCode,
  1099. waitAmount: x.purchaseAmount,
  1100. alreadyAmount: x.paidAmount,
  1101. }));
  1102. proxy
  1103. .post("/fileInfo/getList", {
  1104. businessIdList: [res.id],
  1105. })
  1106. .then((fileObj) => {
  1107. if (fileObj[res.id] && fileObj[res.id].length > 0) {
  1108. formData.data.fileList = fileObj[res.id].map((x) => ({
  1109. raw: x,
  1110. name: x.fileName,
  1111. url: x.fileUrl,
  1112. }));
  1113. }
  1114. });
  1115. });
  1116. } else {
  1117. modalType.value = "edit";
  1118. formOption.disabled = true;
  1119. dialogVisibleTwo.value = true;
  1120. proxy
  1121. .post("/purchaseRefundRecord/detail", {
  1122. id: row.id,
  1123. })
  1124. .then((res) => {
  1125. res.supplyName = currentRow.value.supplyName;
  1126. formData.dataOne = res;
  1127. });
  1128. }
  1129. };
  1130. const deriveExcel = () => {
  1131. ElMessage({
  1132. message: "请稍后",
  1133. type: "success",
  1134. });
  1135. proxy
  1136. .postTwo("/purchase/purchasePayExcelExport", sourceList.value.pagination)
  1137. .then(
  1138. (res) => {
  1139. exportData(res, "采购付款.xlsx");
  1140. },
  1141. (err) => {
  1142. return ElMessage({
  1143. message: "请重试",
  1144. type: "info",
  1145. });
  1146. }
  1147. );
  1148. };
  1149. const exportData = (res, name) => {
  1150. const content = res;
  1151. const blob = new Blob([content], { type: "application/ms-excel" });
  1152. const fileName = name;
  1153. if ("download" in document.createElement("a")) {
  1154. // 非IE下载
  1155. const elink = document.createElement("a");
  1156. elink.download = fileName;
  1157. elink.style.display = "none";
  1158. elink.href = URL.createObjectURL(blob);
  1159. document.body.appendChild(elink);
  1160. elink.click();
  1161. URL.revokeObjectURL(elink.href); // 释放URL 对象
  1162. document.body.removeChild(elink);
  1163. } else {
  1164. navigator.msSaveBlob(blob, fileName);
  1165. }
  1166. };
  1167. </script>
  1168. <style lang="scss" scoped>
  1169. .tenant {
  1170. padding: 20px;
  1171. }
  1172. :deep(.el-table__header-wrapper .el-checkbox) {
  1173. display: none;
  1174. }
  1175. </style>