|
|
@@ -0,0 +1,388 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-position="top">
|
|
|
+ <el-form-item label="岗位ID" prop="postId" label-position="top">
|
|
|
+ <el-select v-model="queryParams.postId" placeholder="请选择岗位" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="post in postOptions"
|
|
|
+ :key="post.postId"
|
|
|
+ :label="post.postName"
|
|
|
+ :value="post.postId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="首页ID" prop="homePageType" label-position="top">
|
|
|
+ <el-select v-model="queryParams.homePageType" placeholder="请选择首页类型" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="dict in home_page_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态" prop="status" label-position="top">
|
|
|
+ <el-select v-model="queryParams.status" placeholder="状态" clearable>
|
|
|
+ <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 label-position="top">
|
|
|
+ <div class="item-search"> </div>
|
|
|
+ <div class="item-search">
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="Plus"
|
|
|
+ @click="handleAdd"
|
|
|
+ v-hasPermi="['system:postHomePage:add']"
|
|
|
+ >新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ icon="Edit"
|
|
|
+ :disabled="single"
|
|
|
+ @click="handleUpdate"
|
|
|
+ v-hasPermi="['system:postHomePage:edit']"
|
|
|
+ >修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ icon="Delete"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleDelete"
|
|
|
+ v-hasPermi="['system:postHomePage:remove']"
|
|
|
+ >删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ icon="Download"
|
|
|
+ @click="handleExport"
|
|
|
+ v-hasPermi="['system:postHomePage:export']"
|
|
|
+ >导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="postHomePageList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
+ <el-table-column label="岗位ID" prop="postId">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ getPostNameById(scope.row.postId) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="首页ID" prop="homePageType">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="home_page_type" :value="scope.row.homePageType" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" prop="status">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="创建者" prop="createBy" />
|
|
|
+ <el-table-column label="创建时间" prop="createTime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.createTime) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="更新者" prop="updateBy" />
|
|
|
+ <el-table-column label="更新时间" prop="updateTime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.updateTime) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="备注" prop="remark" />
|
|
|
+ <el-table-column label="操作" width="180" class-name="small-padding fixed-width">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['system:postHomePage:edit']"><i class="fa fa-edit"></i>编辑</el-button>
|
|
|
+ <el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['system:postHomePage:remove']"><i class="fa fa-trash"></i>删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total > 0"
|
|
|
+ :total="total"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 添加或修改岗位首页配置对话框 -->
|
|
|
+ <el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
|
|
+ <el-form ref="postHomePageRef" :model="form" :rules="rules" label-width="80px">
|
|
|
+ <el-form-item label="岗位ID" prop="postId">
|
|
|
+ <el-select v-model="form.postId" placeholder="请选择岗位" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="post in postOptions"
|
|
|
+ :key="post.postId"
|
|
|
+ :label="post.postName"
|
|
|
+ :value="post.postId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="首页ID" prop="homePageType">
|
|
|
+ <el-select v-model="form.homePageType" placeholder="请选择首页类型" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="dict in home_page_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-radio-group v-model="form.status">
|
|
|
+ <el-radio
|
|
|
+ v-for="dict in sys_normal_disable"
|
|
|
+ :key="dict.value"
|
|
|
+ :value="dict.value"
|
|
|
+ >{{ dict.label }}</el-radio
|
|
|
+ >
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="PostHomePage">
|
|
|
+import { listPostHomePage, addPostHomePage, delPostHomePage, getPostHomePage, updatePostHomePage, listPost } from "@/api/system/postHomePage"
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance()
|
|
|
+const { sys_normal_disable, home_page_type } = proxy.useDict("sys_normal_disable", "home_page_type")
|
|
|
+
|
|
|
+const postHomePageList = ref([])
|
|
|
+const open = ref(false)
|
|
|
+const loading = ref(true)
|
|
|
+const showSearch = ref(true)
|
|
|
+const ids = ref([])
|
|
|
+const single = ref(true)
|
|
|
+const multiple = ref(true)
|
|
|
+const total = ref(0)
|
|
|
+const title = ref("")
|
|
|
+const postOptions = ref([])
|
|
|
+
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ postId: undefined,
|
|
|
+ homePageType: undefined,
|
|
|
+ status: undefined
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ postId: [{ required: true, message: "岗位ID不能为空", trigger: "blur" }],
|
|
|
+ homePageType: [{ required: true, message: "首页ID不能为空", trigger: "blur" }],
|
|
|
+ status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const { queryParams, form, rules } = toRefs(data)
|
|
|
+
|
|
|
+/** 根据岗位ID获取岗位名称 */
|
|
|
+function getPostNameById(postId) {
|
|
|
+ const post = postOptions.value.find(item => item.postId === postId)
|
|
|
+ return post ? post.postName : postId
|
|
|
+}
|
|
|
+
|
|
|
+/** 获取岗位列表 */
|
|
|
+function getPostList() {
|
|
|
+ listPost({ status: "0" }).then(response => {
|
|
|
+ postOptions.value = response.data
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/** 查询岗位首页配置列表 */
|
|
|
+function getList() {
|
|
|
+ loading.value = true
|
|
|
+ // 确保postId是数字类型
|
|
|
+ const params = { ...queryParams.value }
|
|
|
+ if (params.postId != null && typeof params.postId !== 'number') {
|
|
|
+ params.postId = Number(params.postId)
|
|
|
+ }
|
|
|
+
|
|
|
+ listPostHomePage(params).then(response => {
|
|
|
+ postHomePageList.value = response.rows
|
|
|
+ total.value = response.total
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/** 取消按钮 */
|
|
|
+function cancel() {
|
|
|
+ open.value = false
|
|
|
+ reset()
|
|
|
+}
|
|
|
+
|
|
|
+/** 表单重置 */
|
|
|
+function reset() {
|
|
|
+ form.value = {
|
|
|
+ postId: undefined,
|
|
|
+ homePageType: undefined,
|
|
|
+ status: "0", // 默认正常状态
|
|
|
+ remark: undefined
|
|
|
+ }
|
|
|
+ proxy.resetForm("postHomePageRef")
|
|
|
+}
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+function handleQuery() {
|
|
|
+ queryParams.value.pageNum = 1
|
|
|
+ // 确保postId是数字类型
|
|
|
+ if (queryParams.value.postId != null && typeof queryParams.value.postId !== 'number') {
|
|
|
+ queryParams.value.postId = Number(queryParams.value.postId)
|
|
|
+ }
|
|
|
+
|
|
|
+ getList()
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+function resetQuery() {
|
|
|
+ proxy.resetForm("queryRef")
|
|
|
+ handleQuery()
|
|
|
+}
|
|
|
+
|
|
|
+/** 多选框选中数据 */
|
|
|
+function handleSelectionChange(selection) {
|
|
|
+ ids.value = selection.map(item => item.postId)
|
|
|
+ single.value = selection.length != 1
|
|
|
+ multiple.value = !selection.length
|
|
|
+}
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+function handleAdd() {
|
|
|
+ reset()
|
|
|
+ open.value = true
|
|
|
+ title.value = "添加岗位首页配置"
|
|
|
+}
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+function handleUpdate(row) {
|
|
|
+ reset()
|
|
|
+ const postId = row.postId || (ids.value.length > 0 ? ids.value[0] : null)
|
|
|
+ if (postId) {
|
|
|
+ // 确保postId是数字类型
|
|
|
+ const id = typeof postId === 'number' ? postId : Number(postId)
|
|
|
+ getPostHomePage(id).then(response => {
|
|
|
+ form.value = response.data
|
|
|
+ open.value = true
|
|
|
+ title.value = "修改岗位首页配置"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msgWarning("请选择要修改的数据")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+function submitForm() {
|
|
|
+ proxy.$refs["postHomePageRef"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ // 确保postId是数字类型
|
|
|
+ const formData = { ...form.value }
|
|
|
+ if (formData.postId != null && typeof formData.postId !== 'number') {
|
|
|
+ formData.postId = Number(formData.postId)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保所有必需字段都有值
|
|
|
+ if (!formData.postId) {
|
|
|
+ proxy.$modal.msgError("请选择岗位")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!formData.homePageType) {
|
|
|
+ proxy.$modal.msgError("请选择首页类型")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!formData.status) {
|
|
|
+ formData.status = "0" // 默认正常状态
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据当前操作类型决定调用新增还是修改接口
|
|
|
+ // 如果是新增操作(title为"添加岗位首页配置"),调用新增接口
|
|
|
+ if (title.value === "添加岗位首页配置") {
|
|
|
+ addPostHomePage(formData).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ proxy.$modal.msgSuccess("新增成功")
|
|
|
+ open.value = false
|
|
|
+ getList()
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msgError("新增失败: " + response.msg)
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ proxy.$modal.msgError("新增失败: " + error.message)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 否则是修改操作
|
|
|
+ updatePostHomePage(formData).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ proxy.$modal.msgSuccess("修改成功")
|
|
|
+ open.value = false
|
|
|
+ getList()
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msgError("修改失败: " + response.msg)
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ proxy.$modal.msgError("修改失败: " + error.message)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+function handleDelete(row) {
|
|
|
+ const postIds = row.postId ? [row.postId] : ids.value
|
|
|
+ if (postIds && postIds.length > 0) {
|
|
|
+ proxy.$modal.confirm('是否确认删除岗位ID为"' + postIds.join(', ') + '"的数据项?').then(function() {
|
|
|
+ return delPostHomePage(postIds)
|
|
|
+ }).then(() => {
|
|
|
+ getList()
|
|
|
+ proxy.$modal.msgSuccess("删除成功")
|
|
|
+ }).catch(() => {})
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msgWarning("请选择要删除的数据")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+function handleExport() {
|
|
|
+ // 确保postId是数字类型
|
|
|
+ const params = { ...queryParams.value }
|
|
|
+ if (params.postId != null && typeof params.postId !== 'number') {
|
|
|
+ params.postId = Number(params.postId)
|
|
|
+ }
|
|
|
+
|
|
|
+ proxy.download("system/postHomePage/export", params, `postHomePage_${new Date().getTime()}.xlsx`)
|
|
|
+}
|
|
|
+
|
|
|
+getPostList()
|
|
|
+getList()
|
|
|
+</script>
|