vue3 -> vue2

This commit is contained in:
2025-08-07 11:34:05 +08:00
parent 32705ffa7a
commit 34b0054be7

View File

@@ -33,10 +33,10 @@
<template #header> <template #header>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['system:dict:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button> <el-button v-hasPermi="['system:dict:add']" type="primary" plain icon="Plus" @click="handleAdd">新增 </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['system:dict:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()">修改</el-button> <el-button v-hasPermi="['system:dict:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()">修改 </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['system:dict:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"> <el-button v-hasPermi="['system:dict:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()">
@@ -44,10 +44,10 @@
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['system:dict:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button> <el-button v-hasPermi="['system:dict:export']" type="warning" plain icon="Download" @click="handleExport"> 导出 </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['system:dict:remove']" type="danger" plain icon="Refresh" @click="handleRefreshCache">刷新缓存</el-button> <el-button v-hasPermi="['system:dict:remove']" type="danger" plain icon="Refresh" @click="handleRefreshCache">刷新缓存 </el-button>
</el-col> </el-col>
<right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar> <right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
</el-row> </el-row>
@@ -107,140 +107,148 @@
</div> </div>
</template> </template>
<script setup name="Dict" lang="ts"> <script>
import { useDictStore } from '@/store/modules/dict'; import { useDictStore } from '@/store/modules/dict';
import { listType, getType, delType, addType, updateType, refreshCache } from '@/api/system/dict/type'; import { listType, getType, delType, addType, updateType, refreshCache } from '@/api/system/dict/type';
import { DictTypeForm, DictTypeQuery, DictTypeVO } from '@/api/system/dict/type/types'; import { DictTypeForm, DictTypeQuery, DictTypeVO } from '@/api/system/dict/type/types';
import { addDateRange } from '@/utils/ruoyi';
import { UserForm } from '@/api/system/user/types.js';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const initFormData = {
userId: undefined,
const typeList = ref<DictTypeVO[]>([]); deptId: undefined,
const loading = ref(true); userName: '',
const showSearch = ref(true); nickName: undefined,
const ids = ref<Array<number | string>>([]); password: '',
const single = ref(true); phonenumber: undefined,
const multiple = ref(true); email: undefined,
const total = ref(0); sex: undefined,
const dateRange = ref<[DateModelType, DateModelType]>(['', '']); status: '0',
remark: '',
const dictFormRef = ref<ElFormInstance>(); postIds: [],
const queryFormRef = ref<ElFormInstance>(); roleIds: []
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: DictTypeForm = {
dictId: undefined,
dictName: '',
dictType: '',
remark: ''
}; };
const data = reactive<PageData<DictTypeForm, DictTypeQuery>>({
form: { ...initFormData }, export default {
queryParams: { name: 'Student',
pageNum: 1, data() {
pageSize: 10, return {
dictName: '', typeList: [],
dictType: '' loading: true,
showSearch: true,
ids: [],
single: true,
multiple: true,
total: 0,
dateRange: ['', ''],
dialog: {
visible: false,
title: ''
},
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
dictName: '',
dictType: ''
},
rules: {
dictName: [{ required: true, message: '学生名称不能为空', trigger: 'blur' }],
dictType: [{ required: true, message: '学生类型不能为空', trigger: 'blur' }]
}
};
}, },
rules: { mounted() {
dictName: [{ required: true, message: '学生名称不能为空', trigger: 'blur' }], this.getList();
dictType: [{ required: true, message: '学生类型不能为空', trigger: 'blur' }] },
} methods: {
}); /** 查询学生类型列表 */
getList() {
const { queryParams, form, rules } = toRefs(data); this.loading = true;
listType(addDateRange(this.queryParams, this.dateRange)).then((res) => {
/** 查询学生类型列表 */ this.typeList = res.rows;
const getList = () => { this.total = res.total;
loading.value = true; this.loading = false;
listType(proxy?.addDateRange(queryParams.value, dateRange.value)).then((res) => { });
typeList.value = res.rows;
total.value = res.total;
loading.value = false;
});
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
dictFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
dateRange.value = ['', ''];
queryFormRef.value?.resetFields();
handleQuery();
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加学生类型';
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: DictTypeVO[]) => {
ids.value = selection.map((item) => item.dictId);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 修改按钮操作 */
const handleUpdate = async (row?: DictTypeVO) => {
reset();
const dictId = row?.dictId || ids.value[0];
const res = await getType(dictId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改学生类型';
};
/** 提交按钮 */
const submitForm = () => {
dictFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
form.value.dictId ? await updateType(form.value) : await addType(form.value);
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: DictTypeVO) => {
const dictIds = row?.dictId || ids.value;
await proxy?.$modal.confirm('是否确认删除学生编号为"' + dictIds + '"的数据项?');
await delType(dictIds);
getList();
proxy?.$modal.msgSuccess('删除成功');
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'system/dict/type/export',
{
...queryParams.value
}, },
`dict_${new Date().getTime()}.xlsx` cancel() {
); reset();
}; this.dialog.visible = false;
/** 刷新缓存按钮操作 */ },
const handleRefreshCache = async () => { /** 表单重置 */
await refreshCache(); reset() {
proxy?.$modal.msgSuccess('刷新成功'); this.form = { ...initFormData };
useDictStore().cleanDict(); this.$nextTick(() => {
}; this.$refs.dictFormRef?.resetFields();
});
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = ['', ''];
this.$refs.queryFormRef?.resetFields();
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.dialog.visible = true;
this.dialog.title = '添加学生类型';
},
/** 多选框选中数据 */
handleSelectionChange(selection: DictTypeVO[]) {
this.ids = selection.map((item) => item.dictId);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
/** 修改按钮操作 */
async handleUpdate (row) {
this.reset();
const dictId = row?.dictId || this.ids.value[0];
const res = await getType(dictId);
Object.assign(this.form, res.data);
this.dialog.visible = true;
this.dialog.title = '修改学生类型';
},
/** 提交按钮 */
async submitForm() {
this.$refs.dictFormRef?.validate(async (valid) => {
if (valid) {
this.form.dictId ? await updateType(this.form) : await addType(this.form);
ElMessage({
type: 'success',
message: '操作成功'
});
this.dialog.visible = false;
this.getList();
}
});
},
/** 删除按钮操作 */
async handleDelete (row) {
const dictIds = row?.dictId || this.ids.value;
await this.$confirm('是否确认删除学生编号为"' + dictIds + '"的数据项?');
await delType(dictIds);
this.getList();
this.$message({
type: 'success',
message: '删除成功'
});
},
/** 导出按钮操作 */
handleExport() {
onMounted(() => { },
getList(); /** 刷新缓存按钮操作 */
}); async handleRefreshCache () {
await refreshCache();
this.$message.success('刷新成功');
useDictStore().cleanDict();
}
}
};
</script> </script>