系统字典删除多余文件
This commit is contained in:
parent
f7382a44ea
commit
c5383269ee
@ -1,207 +0,0 @@
|
||||
<template>
|
||||
<div class="table-box">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
title="用户列表"
|
||||
:columns="columns"
|
||||
:requestApi="getTableList"
|
||||
:initParam="initParam"
|
||||
:dataCallback="dataCallback"
|
||||
:tool-button="false"
|
||||
:pagination="true"
|
||||
background
|
||||
>
|
||||
<template #formButton="scope">
|
||||
<el-button type="primary" @click="handleAddItem()">新增</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation="scope">
|
||||
<el-button type="primary" link :icon="EditPen" @click="handleEditItem('edit', scope.row)">编辑</el-button>
|
||||
<el-button type="primary" link :icon="Delete" @click="deleteAccount(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<DialogForm
|
||||
:title="title"
|
||||
:formConfig="formConfig"
|
||||
:formData="formData"
|
||||
v-model:visible="visible"
|
||||
append-to-body
|
||||
width="700px"
|
||||
@confirm="saveItem"
|
||||
>
|
||||
</DialogForm>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx" name="jxjDictionary">
|
||||
import { ref, reactive } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { useRouter } from "vue-router";
|
||||
import { User } from "@/api/interface";
|
||||
import { ColumnProps } from "@/components/ProTable/interface";
|
||||
import { useHandleData } from "@/hooks/useHandleData";
|
||||
import { useDownload } from "@/hooks/useDownload";
|
||||
import ProTable from "@/components/ProTable/index.vue";
|
||||
import DialogForm from "@/components/DialogForm/index.vue";
|
||||
import { CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
|
||||
import { getDictionaryList, deleteDictionary, editDictionary, addDictionary } from "@/api/modules/jxjview";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const visible = ref(false);
|
||||
const title = ref("");
|
||||
const formData = ref({});
|
||||
const mode = ref("");
|
||||
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
|
||||
const proTable = ref();
|
||||
// 添加数据按钮
|
||||
const handleAddItem = () => {
|
||||
mode.value = "add";
|
||||
visible.value = true;
|
||||
title.value = "新增";
|
||||
formData.value = reactive({});
|
||||
};
|
||||
|
||||
// 修改数据按钮
|
||||
function handleEditItem(index: string, row: any) {
|
||||
mode.value = "edit";
|
||||
visible.value = true;
|
||||
title.value = "编辑";
|
||||
formData.value = reactive(row);
|
||||
}
|
||||
|
||||
// 表格配置项
|
||||
const columns: ColumnProps[] = [
|
||||
{
|
||||
prop: "dictCode",
|
||||
label: "序号"
|
||||
},
|
||||
{
|
||||
prop: "dictValue",
|
||||
label: "字典名称",
|
||||
// enum:dictType,
|
||||
search: { el: "input" }
|
||||
// fieldNames: { label: "genderLabel", value: "genderValue" }
|
||||
},
|
||||
// 多级 prop
|
||||
{
|
||||
prop: "dictLabel",
|
||||
label: "字典键值"
|
||||
// search: { el: "input" }
|
||||
},
|
||||
{
|
||||
prop: "dictSort",
|
||||
label: "字典排序"
|
||||
// search: { el: "input" }
|
||||
},
|
||||
{
|
||||
prop: "status",
|
||||
label: "状态",
|
||||
enum: [
|
||||
{ label: "正常", value: "1" },
|
||||
{ label: "停用", value: "0" }
|
||||
]
|
||||
// search: { el: "select" }
|
||||
},
|
||||
{ prop: "remark", label: "备注" },
|
||||
{
|
||||
prop: "createTime",
|
||||
label: "创建时间"
|
||||
// search: {
|
||||
// el: "date-picker",
|
||||
// span: 2,
|
||||
// props: { type: "datetimerange", valueFormat: "YYYY-MM-DD HH:mm:ss" },
|
||||
// defaultValue: ["", ""]
|
||||
// }
|
||||
},
|
||||
{ prop: "operation", label: "操作", fixed: "right", width: 330 }
|
||||
];
|
||||
|
||||
// 弹窗中的配置
|
||||
const formConfig = {
|
||||
formItemConfig: [
|
||||
{
|
||||
label: "字典名称",
|
||||
prop: "dictValue",
|
||||
type: "input"
|
||||
},
|
||||
{
|
||||
label: "字典类型",
|
||||
prop: "dictType",
|
||||
type: "input"
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
type: "radio",
|
||||
data: [
|
||||
{ label: "正常", value: "1" },
|
||||
{ label: "停用", value: "0" }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
type: "input"
|
||||
}
|
||||
],
|
||||
rules: {
|
||||
configKey: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入类型名",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// 如果表格需要初始化请求参数,直接定义传给 ProTable(之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
||||
const initParam = reactive({
|
||||
type: 1
|
||||
});
|
||||
|
||||
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,那么你可以在这里进行处理成这些字段
|
||||
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
|
||||
const dataCallback = (data: any) => {
|
||||
// console.log(data);
|
||||
return {
|
||||
list: data.records,
|
||||
total: Number(data.total),
|
||||
pageNo: Number(data.current),
|
||||
pageSize: Number(data.size)
|
||||
};
|
||||
};
|
||||
|
||||
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
|
||||
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
|
||||
const getTableList = (params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params));
|
||||
// console.log(newParams);
|
||||
newParams.endTime = newParams.createTime[1];
|
||||
newParams.createTime = newParams.createTime[0];
|
||||
return getDictionaryList(newParams);
|
||||
};
|
||||
|
||||
// 新增,编辑数据
|
||||
const saveItem = async (form: any) => {
|
||||
if (form.dictCode) {
|
||||
// console.log(form.dictCode);
|
||||
const res = await editDictionary(form);
|
||||
proTable.value.getTableList();
|
||||
ElMessage.success("编辑成功");
|
||||
} else {
|
||||
const res = await addDictionary(form);
|
||||
ElMessage.success("新增成功");
|
||||
proTable.value.getTableList();
|
||||
}
|
||||
visible.value = false;
|
||||
};
|
||||
|
||||
// 删除用户信息
|
||||
const deleteAccount = async (params: User.ResUserList) => {
|
||||
await useHandleData(deleteDictionary, { id: params.dictCode }, `删除【${params.username}】用户`);
|
||||
proTable.value.getTableList();
|
||||
};
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user