gaoluyang
8 小时以前 07f9f8657d057a38792c3822acc9b08d83478967
src/views/financialManagement/expenseManagement/index.vue
@@ -1,7 +1,7 @@
<template>
  <div class="app-container">
    <el-form :model="filters" :inline="true">
      <el-form-item label="录入日期:">
      <el-form-item label="支出日期:">
        <el-date-picker v-model="filters.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
                        placeholder="请选择" clearable @change="changeDaterange" />
      </el-form-item>
@@ -34,8 +34,8 @@
          <el-button
            type="danger"
            icon="Delete"
            :disabled="multipleList.length <= 0"
            @click="deleteRow(multipleList.map((item) => item.id))"
            :disabled="multipleList.length <= 0 || hasBusinessIdInSelection"
            @click="handleBatchDelete"
          >
            批量删除
          </el-button>
@@ -51,16 +51,23 @@
          size: pagination.pageSize,
          total: pagination.total,
        }"
        :isShowSummary="true"
        :summaryMethod="summarizeMainTable"
        @selection-change="handleSelectionChange"
        @pagination="changePage"
      >
        <template #operation="{ row }">
          <el-button type="primary" text @click="edit(row.id)" icon="editPen">
          <el-button
            type="primary"
            link
            :disabled="!!row.businessId"
            @click="edit(row.id)"
          >
            编辑
          </el-button>
          <el-button
            type="primary"
            text
            link
            @click="openFilesFormDia(row)"
          >
            附件
@@ -69,18 +76,18 @@
      </PIMTable>
    </div>
    <Modal ref="modalRef" @success="getTableData"></Modal>
    <files-dia ref="filesDia"></files-dia>
    <FileList v-if="fileDialogVisible"  v-model:visible="fileDialogVisible" record-type="account_expense" :record-id="recordId"  />
  </div>
</template>
<script setup>
import { usePaginationApi } from "@/hooks/usePaginationApi";
import { listPage, delAccountExpense } from "@/api/financialManagement/expenseManagement";
import { onMounted, getCurrentInstance } from "vue";
import {onMounted, getCurrentInstance, ref, computed, defineAsyncComponent} from "vue";
import Modal from "./Modal.vue";
import { ElMessageBox, ElMessage } from "element-plus";
import dayjs from "dayjs";
import FilesDia from "../revenueManagement/filesDia.vue";
const FileList = defineAsyncComponent(() => import("@/components/Dialog/FileList.vue"));
defineOptions({
  name: "支出管理",
@@ -92,7 +99,7 @@
const modalRef = ref();
const { checkout_payment } = proxy.useDict("checkout_payment");
const { expense_types } = proxy.useDict("expense_types");
const filesDia = ref()
const accountType = ref('支出');
const {
  filters,
@@ -106,11 +113,11 @@
  listPage,
  {
    expenseMethod: undefined,
    entryDate: undefined,
  },
  [
    {
      label: "支出日期",
      align: "center",
      prop: "expenseDate",
    },
    {
@@ -128,19 +135,16 @@
    },
    {
      label: "供应商名称",
      align: "center",
      prop: "supplierName",
    },
    {
      label: "支出金额",
      align: "center",
      prop: "expenseMoney",
    },
    {
      label: "支出描述",
      align: "center",
      prop: "expenseDescribed",
    },
@@ -148,6 +152,7 @@
      label: "付款方式",
      align: "center",
      prop: "expenseMethod",
         width: '120',
      dataType: "tag",
      formatData: (params) => {
        if (checkout_payment.value.find((m) => m.value == params)) {
@@ -159,24 +164,20 @@
    },
    {
      label: "发票号码",
      align: "center",
      prop: "invoiceNumber",
    },
    {
      label: "备注",
      align: "center",
      prop: "note",
    },
    {
      label: "录入人",
      align: "center",
      prop: "inputUser",
    },
    {
      label: "录入日期",
      align: "center",
      prop: "inputTime",
    },
@@ -186,20 +187,36 @@
      dataType: "slot",
      slot: "operation",
      align: "center",
      width: "200px",
      width: "160px",
    },
  ]
);
// 表格合计:支出金额
const summarizeMainTable = (param) => {
  return proxy.summarizeTable(param, ["expenseMoney"]);
};
// 多选后做什么
const handleSelectionChange = (selectionList) => {
  multipleList.value = selectionList;
};
// 判断选中的项中是否有 businessId
const hasBusinessIdInSelection = computed(() => {
  return multipleList.value.some(item => item.businessId);
});
const add = () => {
  modalRef.value.openModal();
};
const edit = (id) => {
  // 检查当前行是否有 businessId
  const row = dataList.value.find(item => item.id === id);
  if (row && row.businessId) {
    proxy.$modal.msgWarning("该记录已关联业务,不能编辑");
    return;
  }
  modalRef.value.loadForm(id);
};
const changePage = ({ page, limit }) => {
@@ -208,6 +225,25 @@
  onCurrentChange(page);
};
const deleteRow = (id) => {
  // 如果是数组,检查是否有 businessId
  if (Array.isArray(id)) {
    const hasBusinessId = id.some(itemId => {
      const row = dataList.value.find(item => item.id === itemId);
      return row && row.businessId;
    });
    if (hasBusinessId) {
      proxy.$modal.msgWarning("选中的记录中包含已关联业务的记录,不能删除");
      return;
    }
  } else {
    // 单个删除,检查是否有 businessId
    const row = dataList.value.find(item => item.id === id);
    if (row && row.businessId) {
      proxy.$modal.msgWarning("该记录已关联业务,不能删除");
      return;
    }
  }
  ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
@@ -224,11 +260,30 @@
  });
};
// 批量删除
const handleBatchDelete = () => {
  if (multipleList.value.length === 0) {
    proxy.$modal.msgWarning("请选择要删除的数据");
    return;
  }
  // 检查是否有 businessId
  if (hasBusinessIdInSelection.value) {
    proxy.$modal.msgWarning("选中的记录中包含已关联业务的记录,不能删除");
    return;
  }
  const ids = multipleList.value.map((item) => item.id);
  deleteRow(ids);
};
const changeDaterange = (value) => {
  if (value) {
    filters.entryDate = value;
    filters.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD");
    filters.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD");
  } else {
    filters.entryDate = null;
    filters.entryDateStart = undefined;
    filters.entryDateEnd = undefined;
  }
@@ -248,20 +303,18 @@
      proxy.$modal.msg("已取消");
    });
};
// 打开附件弹窗
const recordId =ref(0)
const fileDialogVisible = ref(false)
// 打开附件弹框
const openFilesFormDia = (row) => {
  nextTick(() => {
    filesDia.value?.openDialog( row,'支出')
  })
};
const openFilesFormDia = async (row) => {
  recordId.value = row.id
  fileDialogVisible.value = true
}
onMounted(() => {
  filters.entryDate = [
    dayjs().format("YYYY-MM-DD"),
    dayjs().add(1, "day").format("YYYY-MM-DD"),
  ]
  filters.entryDateStart = dayjs().format("YYYY-MM-DD")
  filters.entryDateEnd = dayjs().add(1, "day").format("YYYY-MM-DD")
  getTableData();
});
</script>