| | |
| | | <template> |
| | | <div class="p-2"> |
| | | <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
| | | <div class="search" v-show="showSearch"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="70"> |
| | | <el-form-item label="岗位编码" prop="postCode"> |
| | | <el-input v-model="queryParams.postCode" placeholder="请输入岗位编码" clearable style="width: 200px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位名称" prop="postName"> |
| | | <el-input v-model="queryParams.postName" placeholder="请输入岗位名称" clearable style="width: 200px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="岗位状态" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="mb-[10px]" v-show="showSearch"> |
| | | <el-card shadow="hover"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="70"> |
| | | <el-form-item label="岗位编码" prop="postCode"> |
| | | <el-input v-model="queryParams.postCode" placeholder="请输入岗位编码" clearable style="width: 200px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="岗位名称" prop="postName"> |
| | | <el-input v-model="queryParams.postName" placeholder="请输入岗位名称" clearable style="width: 200px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select v-model="queryParams.status" placeholder="岗位状态" clearable style="width: 200px"> |
| | | <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-card> |
| | | </div> |
| | | </transition> |
| | | <el-card shadow="never"> |
| | | <el-card shadow="hover"> |
| | | <template #header> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | |
| | | <script setup name="Post" lang="ts"> |
| | | import { listPost, addPost, delPost, getPost, updatePost } from "@/api/system/post"; |
| | | import { PostForm, PostQuery, PostVO } from "@/api/system/post/types"; |
| | | import { ComponentInternalInstance } from "vue"; |
| | | |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable")); |
| | |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | |
| | | const postFormRef = ref(ElForm); |
| | | const queryFormRef = ref(ElForm); |
| | | const postFormRef = ref<ElFormInstance>(); |
| | | const queryFormRef = ref<ElFormInstance>(); |
| | | |
| | | const dialog = reactive<DialogOption>({ |
| | | visible: false, |
| | | title: '' |
| | | visible: false, |
| | | title: '' |
| | | }); |
| | | |
| | | const initFormData: PostForm = { |
| | | postId: undefined, |
| | | postCode: '', |
| | | postName: '', |
| | | postSort: 0, |
| | | status: "0", |
| | | remark: '' |
| | | postId: undefined, |
| | | postCode: '', |
| | | postName: '', |
| | | postSort: 0, |
| | | status: "0", |
| | | remark: '' |
| | | } |
| | | |
| | | const data = reactive<PageData<PostForm, PostQuery>>({ |
| | | form: {...initFormData}, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | postCode: '', |
| | | postName: '', |
| | | status: '' |
| | | }, |
| | | rules: { |
| | | postName: [{ required: true, message: "岗位名称不能为空", trigger: "blur" }], |
| | | postCode: [{ required: true, message: "岗位编码不能为空", trigger: "blur" }], |
| | | postSort: [{ required: true, message: "岗位顺序不能为空", trigger: "blur" }], |
| | | } |
| | | form: { ...initFormData }, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | postCode: '', |
| | | postName: '', |
| | | status: '' |
| | | }, |
| | | rules: { |
| | | postName: [{ required: true, message: "岗位名称不能为空", trigger: "blur" }], |
| | | postCode: [{ required: true, message: "岗位编码不能为空", trigger: "blur" }], |
| | | postSort: [{ required: true, message: "岗位顺序不能为空", trigger: "blur" }], |
| | | } |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs<PageData<PostForm, PostQuery>>(data); |
| | | |
| | | /** 查询岗位列表 */ |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | const res = await listPost(queryParams.value); |
| | | postList.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | loading.value = true; |
| | | const res = await listPost(queryParams.value); |
| | | postList.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | } |
| | | /** 取消按钮 */ |
| | | const cancel = () => { |
| | | reset(); |
| | | dialog.visible = false; |
| | | reset(); |
| | | dialog.visible = false; |
| | | } |
| | | /** 表单重置 */ |
| | | const reset = () => { |
| | | form.value = {...initFormData}; |
| | | postFormRef.value.resetFields(); |
| | | form.value = { ...initFormData }; |
| | | postFormRef.value?.resetFields(); |
| | | } |
| | | /** 搜索按钮操作 */ |
| | | const handleQuery = () => { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | } |
| | | /** 重置按钮操作 */ |
| | | const resetQuery = () => { |
| | | queryFormRef.value.resetFields(); |
| | | handleQuery(); |
| | | queryFormRef.value?.resetFields(); |
| | | handleQuery(); |
| | | } |
| | | /** 多选框选中数据 */ |
| | | const handleSelectionChange = (selection: PostVO[]) => { |
| | | ids.value = selection.map(item => item.postId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | ids.value = selection.map(item => item.postId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | } |
| | | /** 新增按钮操作 */ |
| | | const handleAdd = () => { |
| | | dialog.visible = true; |
| | | dialog.title = "添加岗位"; |
| | | nextTick(() => { |
| | | reset(); |
| | | }) |
| | | dialog.visible = true; |
| | | dialog.title = "添加岗位"; |
| | | nextTick(() => { |
| | | reset(); |
| | | }) |
| | | } |
| | | /** 修改按钮操作 */ |
| | | const handleUpdate = (row?: PostVO) => { |
| | | dialog.visible = true; |
| | | dialog.title = "修改岗位"; |
| | | nextTick(async () => { |
| | | reset(); |
| | | const postId = row?.postId || ids.value[0]; |
| | | const res = await getPost(postId); |
| | | form.value = res.data; |
| | | }) |
| | | dialog.visible = true; |
| | | dialog.title = "修改岗位"; |
| | | nextTick(async () => { |
| | | reset(); |
| | | const postId = row?.postId || ids.value[0]; |
| | | const res = await getPost(postId); |
| | | form.value = res.data; |
| | | }) |
| | | } |
| | | /** 提交按钮 */ |
| | | const submitForm = () => { |
| | | postFormRef.value.validate(async (valid: boolean) => { |
| | | if (valid) { |
| | | form.value.postId ? await updatePost(form.value) : await addPost(form.value); |
| | | proxy?.$modal.msgSuccess("操作成功"); |
| | | dialog.visible = false; |
| | | getList(); |
| | | } |
| | | }); |
| | | postFormRef.value?.validate(async (valid: boolean) => { |
| | | if (valid) { |
| | | form.value.postId ? await updatePost(form.value) : await addPost(form.value); |
| | | proxy?.$modal.msgSuccess("操作成功"); |
| | | dialog.visible = false; |
| | | await getList(); |
| | | } |
| | | }); |
| | | } |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (row?: PostVO) => { |
| | | const postIds = row?.postId || ids.value; |
| | | await proxy?.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?'); |
| | | await delPost(postIds); |
| | | getList(); |
| | | proxy?.$modal.msgSuccess("删除成功"); |
| | | const postIds = row?.postId || ids.value; |
| | | await proxy?.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?'); |
| | | await delPost(postIds); |
| | | await getList(); |
| | | proxy?.$modal.msgSuccess("删除成功"); |
| | | } |
| | | /** 导出按钮操作 */ |
| | | const handleExport = () => { |
| | | proxy?.download("system/post/export", { |
| | | ...queryParams.value |
| | | }, `post_${new Date().getTime()}.xlsx`); |
| | | proxy?.download("system/post/export", { |
| | | ...queryParams.value |
| | | }, `post_${new Date().getTime()}.xlsx`); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | getList(); |
| | | }); |
| | | </script> |