<template> <div class="examineManage"> <div class="top"> <el-form ref="ruleForm" :model="form"> <el-row :gutter="20"> <el-col :span="4"> <el-form-item label="考核年度:" prop="time"> <el-date-picker v-model="form.year" value-format="YYYY" type="year" placeholder="请选择年份" style="width: 100%" /> </el-form-item> </el-col> <el-col :span="3"> <el-form-item> <el-button type="primary" icon="Search" @click="search"> 查询</el-button> <el-button icon="Refresh" @click="resetQuery">重置</el-button> </el-form-item> </el-col> </el-row> </el-form> <el-row class="mb8"> <el-button class="mr10" type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增</el-button> </el-row> </div> <el-table :data="tableData" v-loading="loading" :max-height="600"> <el-table-column type="index" width="55" label="序号" /> <el-table-column label="年份" prop="year" show-overflow-tooltip /> <el-table-column label="启用时间" prop="openTime" show-overflow-tooltip /> <el-table-column label="停用时间" prop="dwonTime" show-overflow-tooltip /> <el-table-column label="修改人" prop="updateBy" show-overflow-tooltip /> <el-table-column label="状态" prop="status" show-overflow-tooltip> <template #default="{ row }"> <el-switch v-model="row.status" active-value="1" inactive-value="0" @change=" val => { statusChange(row, val); } " :disabled="row.statusDisabled || type == 'view'" /> </template> </el-table-column> <el-table-column label="备注" prop="remark" show-overflow-tooltip /> <el-table-column label="操作" show-overflow-tooltip width="410"> <template #default="{ row }"> <el-button link type="primary" icon="View" @click="operateHandle(row, 'view')">查看</el-button> <el-button link type="primary" icon="Crop" @click="openDialog(row, 'crop')">复制</el-button> <el-button type="warning" icon="Edit" link @click="openDialog(row, 'edit')">编辑</el-button> <el-button type="success" icon="Edit" link @click="operateHandle(row, 'edit')">指标</el-button> <el-button type="danger" icon="Delete" link @click="del(row)">删除</el-button> </template> </el-table-column> </el-table> <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" /> <el-dialog v-model="visible" :title="`${opts.text}考核指标`" :close-on-click-modal="false" width="30%" :before-close="close" class="dialog" > <el-form :rules="ruleFormRules" ref="dialogruleForm" :model="dialogform" label-width="auto"> <el-form-item label="复制到年份:" prop="year" v-if="opts.type == 'crop'"> <el-date-picker v-model="dialogform.year" type="year" placeholder="请选择复制到年份" style="width: 100%" value-format="YYYY" :disabled="opts.type == 'edit'" /> </el-form-item> <el-form-item label="考核年度:" prop="year" v-else> <el-date-picker v-model="dialogform.year" type="year" placeholder="请选择年份" style="width: 100%" value-format="YYYY" :disabled="opts.type == 'edit'" /> </el-form-item> <el-form-item label="备注:" prop="remark" v-show="opts.type != 'crop'"> <el-input v-model="dialogform.remark" type="textarea" placeholder="请输入备注"></el-input> </el-form-item> </el-form> <template #footer v-if="opts.type !== 'view'"> <div class="dialog-footer"> <el-button type="primary" @click="submit">保存</el-button> <el-button @click="close">取消</el-button> </div> </template> </el-dialog> </div> </template> <script setup> import { ref, reactive, onMounted } from 'vue'; import operate from './operate.vue'; import { getAssessTargetConfigPage, assessTargetConfigCopy, assessTargetConfigDel, performanceConfigAdd, performanceConfigCopy, performanceConfigEdit, enableAndEnable, performanceConfigDisable, } from '@/api/spongePerformance/management.js'; import { optTextMap, statusMap } from '@/utils/map'; import { usePagination } from '@/hooks'; const { proxy } = getCurrentInstance(); // const route = useRoute(); const router = useRouter(); const emit = defineEmits(['toggle']); const { sponge_engineering_type } = proxy.useDict('sponge_engineering_type'); const engineeringTypeText = itemType => { const item = sponge_engineering_type.value.find(it => it.value === itemType); return item?.label || ''; }; const { assess_type } = proxy.useDict('assess_type'); const assessTypeText = itemType => { const item = assess_type.value.find(it => it.value === itemType); return item?.label || ''; }; const ruleFormRules = { year: [{ required: true, message: '考核年度不能为空', trigger: ['change'] }], }; const form = ref({}); const dialogform = ref({}); const params = computed(() => { const args = JSON.parse(JSON.stringify(form.value)); const { time } = args; delete args.time; return { ...args, }; }); const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getAssessTargetConfigPage, params); const opts = reactive({ type: '', text: '', }); const visible = ref(false); const search = () => { pageNum.value = 1; getTableList(); }; const resetQuery = () => { form.value = {}; proxy.$refs.ruleForm.resetFields(); search(); }; const openDialog = (row, type) => { visible.value = true; opts.type = type; if (type != 'add') dialogform.value = row; else dialogform.value = {}; // opts.text = optTextMap.get(type); }; const close = type => { visible.value = false; proxy.$refs.dialogruleForm.resetFields(); }; const submit = () => { proxy.$refs.dialogruleForm.validate(async (valid, fields) => { if (valid) { const params = { ...dialogform.value }; if (opts.type == 'add') { const res = await performanceConfigAdd(params); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); visible.value = false; } else if (opts.type == 'crop') { const res = await performanceConfigCopy({ sourceConfigId: dialogform.value.id, targetYear: dialogform.value.year }); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); visible.value = false; } else { const res = await performanceConfigEdit(params); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); visible.value = false; } getTableList(); } else { console.log('error submit!', fields); } }); }; // 复制 function Crop({ year, id }) { performanceConfigCopy({ sourceConfigId: id, targetYear: year }).them(({ code }) => { getTableList(); }); } // proxy.$refs.operateRef.submit(); const operateHandle = (data, type) => { console.log(data, 'datadata'); router.push(`/management/control/${data.id}?type=${type}&status=${data.status}&year=${data.year}`); }; const del = row => { proxy.$modal .confirm('是否确认删除?') .then(async () => { const res = await assessTargetConfigDel(row.id); if (res?.code !== 200) return; proxy.$modal.msgSuccess('操作成功!'); getTableList(); }) .catch(() => {}); }; //启用停用 const statusChange = (v, m) => { let s = v.status; console.log('s', s); proxy.$modal .confirm(`是否确认${s == '1' ? '启用' : '停用'}?`) .then(async () => { if (s == '1') { const { data, code } = await enableAndEnable(v.id); } else if (s == 0) { const { data, code } = await performanceConfigDisable(v.id); } getTableList(); proxy.$modal.msgSuccess('操作成功!'); }) .catch(() => { getTableList(); }); }; onMounted(() => { getTableList(); }); </script> <style lang="scss" scoped> .examineManage { padding: 20px; height: 90vh; overflow-y: hidden; .top { margin-bottom: 15px; } } :deep(.dialog) { .el-dialog__body { padding-bottom: 20px !important; } .el-dialog__footer { padding-top: 0 !important; } } </style>