| | |
| | | <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> |
| | |
| | | @pagination="changePage" |
| | | > |
| | | <template #operation="{ row }"> |
| | | <el-button type="primary" link @click="edit(row.id)"> |
| | | <el-button |
| | | type="primary" |
| | | link |
| | | :disabled="!!row.businessId" |
| | | @click="edit(row.id)" |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button |
| | |
| | | <script setup> |
| | | import { usePaginationApi } from "@/hooks/usePaginationApi"; |
| | | import { listPage, delAccountExpense, fileListPage, fileAdd, fileDel } from "@/api/financialManagement/expenseManagement"; |
| | | import { onMounted, getCurrentInstance } from "vue"; |
| | | import { onMounted, getCurrentInstance, ref, computed } from "vue"; |
| | | import Modal from "./Modal.vue"; |
| | | import { ElMessageBox, ElMessage } from "element-plus"; |
| | | import dayjs from "dayjs"; |
| | |
| | | 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 }) => { |
| | |
| | | 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: "取消", |
| | |
| | | }); |
| | | }; |
| | | |
| | | // 批量删除 |
| | | 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; |