wms_vue/src/view/tenant/index.vue

182 lines
5.1 KiB
Vue
Raw Normal View History

2025-08-07 15:16:23 +08:00
<template>
2025-11-06 14:25:31 +08:00
<a-list-layout ref="pageRef">
<template #search>
<!-- 查询参数 -->
<pro-query :searchParam="searchParam" @on-search="search"></pro-query>
</template>
<!-- 列表 -->
<pro-table ref="tableRef" :fetch="fetch" :columns="columns" :toolbar="toolbar" :operate="operate"
:param="state.param" :pagination="pagination"
:row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }">
<!-- 继承至 a-table 的默认插槽 -->
</pro-table>
<save :visible="state.visibleSave" @close="closeSave"></save>
<edit :visible="state.visibleEdit" @close="closeEdit" :record="state.recordEdit"></edit>
<info :visible="state.visibleInfo" @close="closeInfo" :record="state.recordInfo"></info>
<give :visible="state.visibleGive" @close="closeGive" :record="state.recordGive"></give>
</a-list-layout>
2025-08-07 15:16:23 +08:00
</template>
<script>
2025-11-04 14:04:50 +08:00
import save from './modal/save.vue';
import edit from './modal/edit.vue';
import info from './modal/info.vue';
import give from './modal/give.vue';
2025-11-06 14:25:31 +08:00
import { message, Modal as modal } from '@hwork/ant-design-vue';
2025-08-07 15:16:23 +08:00
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { page, remove, removeBatch } from "@/api/module/tenant";
import { reactive, createVNode, ref } from 'vue';
const removeKey = "remove";
const removeBatchKey = "removeBatch";
export default {
components: {
save,
edit,
info,
give,
},
setup() {
const tableRef = ref()
const columns = [
{ dataIndex: "name", key: "name", title: "名称" },
2025-11-06 14:25:31 +08:00
{ dataIndex: "describe", key: "describe", title: "描述" },
2025-08-07 15:16:23 +08:00
{ dataIndex: "createTime", key: "createTime", title: "创建时间" },
];
/// 查询配置
const fetch = async (param) => {
var response = await page(param);
return {
total: response.data.total,
data: response.data.record,
};
};
/// 删除配置
const removeMethod = (record) => {
message.loading({ content: "提交中...", key: removeKey });
remove({ "id": record.id }).then((response) => {
if (response.success) {
message.success({ content: "删除成功", key: removeKey, duration: 1 }).then(() => {
tableRef.value.reload()
})
} else {
message.error({ content: "删除失败", key: removeKey, duration: 1 })
}
})
}
const removeBatchMethod = (ids) => {
2025-11-06 14:25:31 +08:00
modal.confirm({
2025-08-07 15:16:23 +08:00
title: '您是否确定要删除选择租户?',
icon: createVNode(ExclamationCircleOutlined),
okText: '确定',
cancelText: '取消',
onOk() {
message.loading({ content: "提交中...", key: removeBatchKey });
2025-11-06 14:25:31 +08:00
removeBatch({ "ids": ids }).then((response) => {
if (response.success) {
message.success({ content: "删除成功", key: removeBatchKey, duration: 1 }).then(() => {
2025-08-07 15:16:23 +08:00
tableRef.value.reload()
})
2025-11-06 14:25:31 +08:00
} else {
message.error({ content: "删除失败", key: removeBatchKey, duration: 1 })
2025-08-07 15:16:23 +08:00
}
})
}
});
}
/// 工具栏
const toolbar = [
2025-11-06 14:25:31 +08:00
{ label: "新增", event: function () { state.visibleSave = true } },
{ label: "删除", event: function () { removeBatchMethod(state.selectedRowKeys) } },
2025-08-07 15:16:23 +08:00
];
/// 行操作
const operate = [
2025-11-06 14:25:31 +08:00
{ label: "查看", event: function (record) { state.visibleInfo = true, state.recordInfo = record } },
{ label: "修改", event: function (record) { state.visibleEdit = true, state.recordEdit = record } },
{ label: "分配", event: function (record) { state.visibleGive = true, state.recordGive = record } },
{ label: "删除", isDel: true, delEvent: function (record) { removeMethod(record) } },
2025-08-07 15:16:23 +08:00
];
/// 分页参数
const pagination = {
pageNum: 1,
pageSize: 10,
}
/// 外置参数 - 当参数改变时, 重新触发 fetch 函数
const state = reactive({
selectedRowKeys: [],
param: {},
visibleSave: false,
visibleEdit: false,
visibleInfo: false,
visibleGive: false,
recordInfo: {},
recordEdit: {},
recordGive: {}
})
const onSelectChange = selectedRowKeys => {
state.selectedRowKeys = selectedRowKeys;
};
/// 查询参数
const searchParam = [
2025-11-06 14:25:31 +08:00
{ key: "name", type: "input", label: "名称" },
{ key: "key", type: "input", label: "Key" },
2025-08-07 15:16:23 +08:00
]
/// 查询操作
2025-11-06 14:25:31 +08:00
const search = function (value) {
2025-08-07 15:16:23 +08:00
state.param = value
tableRef.value.reload()
}
2025-11-06 14:25:31 +08:00
const closeSave = function () {
2025-08-07 15:16:23 +08:00
state.visibleSave = false;
tableRef.value.reload()
}
2025-11-06 14:25:31 +08:00
const closeEdit = function () {
2025-08-07 15:16:23 +08:00
state.visibleEdit = false;
tableRef.value.reload()
}
2025-11-06 14:25:31 +08:00
const closeInfo = function () {
2025-08-07 15:16:23 +08:00
state.visibleInfo = false;
}
2025-11-06 14:25:31 +08:00
const closeGive = function () {
2025-08-07 15:16:23 +08:00
state.visibleGive = false;
}
return {
2025-11-06 14:25:31 +08:00
state,
fetch,
2025-08-07 15:16:23 +08:00
search,
toolbar,
2025-11-06 14:25:31 +08:00
columns,
operate,
2025-08-07 15:16:23 +08:00
pagination,
2025-11-06 14:25:31 +08:00
searchParam,
2025-08-07 15:16:23 +08:00
onSelectChange,
closeSave,
closeEdit,
closeInfo,
closeGive,
2025-11-06 14:25:31 +08:00
2025-08-07 15:16:23 +08:00
tableRef
};
},
};
2025-11-06 14:25:31 +08:00
</script>