index.vue 27 KB

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