123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- <template>
- <div class="tenant">
- <!-- <Banner /> -->
- <div class="content">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- highlight-current-row
- :selectConfig="selectConfig"
- :table-events="{
- //element talbe事件都能传
- select: selectRow,
- }"
- :action-list="[
- {
- text: '合并付款',
- disabled: selectData.length === 0,
- action: () => handlePayment(20),
- },
- ]"
- @get-list="getList"
- >
- <template #contractCode="{ item }">
- <div
- style="cursor: pointer; color: #409eff"
- @click="handleClickContractCode(item)"
- >
- {{ item.contractCode }}
- </div>
- </template>
- <template #payStatus="{ item }">
- <div
- style="cursor: pointer; color: #409eff"
- @click="handleClickPayStatus(item)"
- >
- {{ dictValueLabel(item.payStatus, paymentStatus) }}
- </div>
- </template>
- <template #btn="{ item }">
- <div>
- <el-button
- type="primary"
- link
- v-if="item.payStatus != 30"
- @click="handlePayment(10, item)"
- >付款</el-button
- >
- <el-button
- type="primary"
- link
- v-if="item.payStatus != 30"
- @click="handleEnd(item)"
- >结束</el-button
- >
- <el-button type="primary" link @click="handleClear(item)"
- >清空</el-button
- >
- </div>
- </template>
- </byTable>
- </div>
- <el-dialog
- :title="'付款'"
- v-model="dialogVisible"
- width="800"
- v-loading="submitLoading"
- destroy-on-close
- :before-close="handleClose"
- >
- <byForm
- :formConfig="formConfig"
- :formOption="formOption"
- v-model="formData.data"
- :rules="rules"
- ref="byform"
- >
- <template #details>
- <div style="width: 100%">
- <el-table :data="formData.data.purchasePayRecordDetailList">
- <el-table-column prop="code" label="采购单号" />
- <el-table-column prop="waitAmount" label="采购金额" />
- <el-table-column prop="alreadyAmount" label="已付款金额" />
- <el-table-column prop="amount" label="付款金额" min-width="150">
- <template #default="{ row, $index }">
- <el-form-item
- :prop="'purchasePayRecordDetailList.' + $index + '.amount'"
- :rules="rules.amount"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.amount"
- :precision="4"
- :controls="false"
- :min="0"
- onmousewheel="return false;"
- />
- </el-form-item>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="handleClose" size="large">取 消</el-button>
- <el-button
- type="primary"
- @click="submitForm('byform')"
- size="large"
- :loading="submitLoading"
- >
- 确 定
- </el-button>
- </template>
- </el-dialog>
- <el-dialog
- v-model="dialogVisibleOne"
- title="付款记录"
- width="500"
- append-to-body
- destroy-on-close
- >
- <div>
- <el-timeline :reverse="false">
- <el-timeline-item
- placement="top"
- v-for="(activity, index) in activities"
- :key="index"
- :timestamp="activity.payUserName"
- >
- <div>
- 付款账号: {{ dictValueLabel(activity.payAccount, accountData) }}
- </div>
- <div style="margin-top: 5px">
- 付款金额:{{ moneyFormat(activity.amount, 2) }}
- </div>
- <div style="margin-top: 5px">付款时间: {{ activity.payDate }}</div>
- </el-timeline-item>
- </el-timeline>
- </div>
- <template #footer>
- <el-button @click="dialogVisibleOne = false">关闭</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
-
- <script setup>
- import { ElMessage, ElMessageBox } from "element-plus";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- const loading = ref(false);
- const submitLoading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- type: "",
- keyword: "",
- },
- });
- let dialogVisible = ref(false);
- let dialogVisibleOne = ref(false);
- let activities = ref([]);
- let modalType = ref("add");
- let rules = ref({
- amount: [{ required: true, message: "请输入付款金额", trigger: "blur" }],
- payDate: [{ required: true, message: "请选择付款时间", trigger: "change" }],
- payAccount: [
- { required: true, message: "请选择付款账号", trigger: "change" },
- ],
- });
- const { proxy } = getCurrentInstance();
- const arrivalStatus = ref([
- {
- label: "未到货",
- value: "0",
- },
- {
- label: "部分到货",
- value: "10",
- },
- {
- label: "已到货",
- value: "20",
- },
- ]);
- const paymentStatus = ref([
- {
- label: "未付款",
- value: "0",
- },
- {
- label: "部分付款",
- value: "10",
- },
- {
- label: "已付款",
- value: "20",
- },
- {
- label: "付款结束",
- value: "30",
- },
- ]);
- const selectConfig = computed(() => [
- {
- label: "到货状态",
- prop: "arrivalStatus",
- data: arrivalStatus.value,
- },
- {
- label: "付款状态",
- prop: "payStatus",
- data: paymentStatus.value,
- },
- ]);
- const config = computed(() => {
- return [
- {
- type: "selection",
- attrs: {
- checkAtt: "isCheck",
- },
- },
- {
- attrs: {
- label: "采购单号",
- slot: "contractCode",
- },
- },
- {
- attrs: {
- label: "供应商",
- prop: "supplyName",
- },
- },
- {
- attrs: {
- label: "收货仓库",
- prop: "receiptWarehouseName",
- },
- },
- {
- attrs: {
- label: "采购金额",
- prop: "amount",
- width: 100,
- },
- render(amount) {
- return proxy.moneyFormat(amount, 2);
- },
- },
- {
- attrs: {
- label: "已付款金额",
- prop: "paidAmount",
- width: 100,
- },
- render(paidAmount) {
- return proxy.moneyFormat(paidAmount, 2);
- },
- },
- {
- attrs: {
- label: "采购人",
- prop: "purchaseName",
- width: 150,
- },
- },
- {
- attrs: {
- label: "采购时间",
- prop: "createTime",
- width: 155,
- },
- },
- {
- attrs: {
- label: "到货状态",
- prop: "arrivalStatus",
- width: 100,
- },
- render(status) {
- return proxy.dictValueLabel(status, arrivalStatus.value);
- },
- },
- {
- attrs: {
- label: "付款状态",
- slot: "payStatus",
- width: 100,
- },
- },
- {
- attrs: {
- label: "操作",
- slot: "btn",
- width: "180",
- align: "center",
- fixed: "right",
- },
- },
- ];
- });
- let formData = reactive({
- data: {
- type: "1",
- },
- });
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const byform = ref(null);
- let formConfig = computed(() => [
- {
- type: "input",
- prop: "supplyName",
- label: "供应商",
- disabled: true,
- },
- {
- type: "date",
- itemType: "datetime",
- prop: "payDate",
- label: "付款时间",
- format: "YYYY-MM-DD HH:mm:ss",
- itemWidth: 35,
- },
- {
- type: "select",
- prop: "payAccount",
- label: "付款账号",
- data: accountData.value,
- itemWidth: 50,
- },
- {
- type: "number",
- prop: "amount",
- label: "付款金额",
- precision: 4,
- min: 0,
- controls: false,
- },
- {
- type: "title",
- title: "付款明细",
- },
- {
- type: "slot",
- slotName: "details",
- label: "",
- },
- ]);
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/purchase/pageByWdly", sourceList.value.pagination)
- .then((res) => {
- sourceList.value.data = res.rows.map((x) => ({
- ...x,
- ...JSON.parse(x.victoriatouristJson),
- isCheck: true,
- }));
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- const submitForm = () => {
- byform.value.handleSubmit((valid) => {
- const list = formData.data.purchasePayRecordDetailList;
- for (let i = 0; i < list.length; i++) {
- const e = list[i];
- if (Number(e.amount) + Number(e.alreadyAmount) > Number(e.waitAmount)) {
- return ElMessage({
- message: `本次付款加已付款金额不可大于采购金额`,
- type: "info",
- });
- }
- }
- const total = list.reduce((total, x) => (total += Number(x.amount)), 0);
- if (Number(formData.data.amount) != total) {
- return ElMessage({
- message: "本次付款合计必须等于上方的付款金额",
- type: "info",
- });
- }
- proxy.post("/purchasePayRecord/add", formData.data).then(
- (res) => {
- ElMessage({
- message: "操作成功",
- type: "success",
- });
- handleClose();
- setTimeout(() => {
- submitLoading.value = false;
- }, 5000);
- getList();
- },
- (err) => {
- submitLoading.value = false;
- }
- );
- });
- };
- const selectData = ref([]);
- const selectRow = (data) => {
- selectData.value = data;
- };
- const handleClose = () => {
- selectData.value = [];
- dialogVisible.value = false;
- };
- watch(selectData, (newVal, oldVal) => {
- if (newVal.length == 0) {
- sourceList.value.data.forEach((x) => {
- x.isCheck = true;
- });
- } else if (newVal.length == 1) {
- const current = newVal[0];
- sourceList.value.data.forEach((x) => {
- if (x.supplyId !== current.supplyId) {
- x.isCheck = false;
- }
- });
- }
- });
- const handlePayment = (type, data) => {
- modalType.value = "add";
- if (type === 10) {
- selectData.value = [data];
- } else if (type === 20) {
- }
- formData.data = {
- supplyName: selectData.value[0].supplyName,
- amount: "",
- payDate: "",
- purchasePayRecordDetailList: selectData.value.map((x) => ({
- purchaseId: x.id,
- code: x.contractCode,
- waitAmount: x.amount,
- alreadyAmount: x.paidAmount,
- amount: null,
- })),
- };
- dialogVisible.value = true;
- };
- const handleClickPayStatus = (row) => {
- proxy
- .post("/purchasePayRecordDetail/page", { purchaseId: row.id })
- .then((res) => {
- if (res && res.rows && res.rows.length > 0) {
- activities.value = res.rows;
- dialogVisibleOne.value = true;
- } else {
- return ElMessage({
- message: `暂无付款记录`,
- type: "info",
- });
- }
- });
- };
- const handleEnd = (row) => {
- // 弹窗提示是否删除
- ElMessageBox.confirm("是否确认结束?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- // 删除
- proxy
- .post("/purchase/edit", {
- ...row,
- payStatus: 30,
- })
- .then((res) => {
- ElMessage({
- message: "操作成功",
- type: "success",
- });
- getList();
- });
- });
- };
- const handleClear = (row) => {
- // 弹窗提示是否删除
- ElMessageBox.confirm("是否确认清空付款记录?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- // 删除
- proxy
- .post("/purchasePayRecordDetail/empty", {
- purchaseId: row.id,
- })
- .then((res) => {
- ElMessage({
- message: "操作成功",
- type: "success",
- });
- getList();
- });
- });
- };
- const accountData = ref([]);
- const getDict = () => {
- proxy.getDictOne(["purchase_payment_account"]).then((res) => {
- accountData.value = res["purchase_payment_account"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- };
- getList();
- getDict();
- </script>
-
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- :deep(.el-table__header-wrapper .el-checkbox) {
- display: none;
- }
- </style>
|