vue3 -> vue2

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

View File

@@ -107,37 +107,44 @@
</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,
deptId: undefined,
userName: '',
nickName: undefined,
password: '',
phonenumber: undefined,
email: undefined,
sex: undefined,
status: '0',
remark: '',
postIds: [],
roleIds: []
};
const typeList = ref<DictTypeVO[]>([]); export default {
const loading = ref(true); name: 'Student',
const showSearch = ref(true); data() {
const ids = ref<Array<number | string>>([]); return {
const single = ref(true); typeList: [],
const multiple = ref(true); loading: true,
const total = ref(0); showSearch: true,
const dateRange = ref<[DateModelType, DateModelType]>(['', '']); ids: [],
single: true,
const dictFormRef = ref<ElFormInstance>(); multiple: true,
const queryFormRef = ref<ElFormInstance>(); total: 0,
dateRange: ['', ''],
const dialog = reactive<DialogOption>({ dialog: {
visible: false, visible: false,
title: '' title: ''
}); },
const initFormData: DictTypeForm = {
dictId: undefined,
dictName: '',
dictType: '',
remark: ''
};
const data = reactive<PageData<DictTypeForm, DictTypeQuery>>({
form: { ...initFormData }, form: { ...initFormData },
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@@ -149,98 +156,99 @@ const data = reactive<PageData<DictTypeForm, DictTypeQuery>>({
dictName: [{ required: true, message: '学生名称不能为空', trigger: 'blur' }], dictName: [{ required: true, message: '学生名称不能为空', trigger: 'blur' }],
dictType: [{ required: true, message: '学生类型不能为空', trigger: 'blur' }] dictType: [{ required: true, message: '学生类型不能为空', trigger: 'blur' }]
} }
}); };
},
const { queryParams, form, rules } = toRefs(data); mounted() {
this.getList();
},
methods: {
/** 查询学生类型列表 */ /** 查询学生类型列表 */
const getList = () => { getList() {
loading.value = true; this.loading = true;
listType(proxy?.addDateRange(queryParams.value, dateRange.value)).then((res) => { listType(addDateRange(this.queryParams, this.dateRange)).then((res) => {
typeList.value = res.rows; this.typeList = res.rows;
total.value = res.total; this.total = res.total;
loading.value = false; this.loading = false;
}); });
}; },
/** 取消按钮 */ cancel() {
const cancel = () => {
reset(); reset();
dialog.visible = false; this.dialog.visible = false;
}; },
/** 表单重置 */ /** 表单重置 */
const reset = () => { reset() {
form.value = { ...initFormData }; this.form = { ...initFormData };
dictFormRef.value?.resetFields(); this.$nextTick(() => {
}; this.$refs.dictFormRef?.resetFields();
});
},
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { handleQuery() {
queryParams.value.pageNum = 1; this.queryParams.pageNum = 1;
getList(); this.getList();
}; },
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { resetQuery() {
dateRange.value = ['', '']; this.dateRange = ['', ''];
queryFormRef.value?.resetFields(); this.$refs.queryFormRef?.resetFields();
handleQuery(); this.handleQuery();
}; },
/** 新增按钮操作 */ /** 新增按钮操作 */
const handleAdd = () => { handleAdd() {
reset(); this.reset();
dialog.visible = true; this.dialog.visible = true;
dialog.title = '添加学生类型'; this.dialog.title = '添加学生类型';
}; },
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: DictTypeVO[]) => { handleSelectionChange(selection: DictTypeVO[]) {
ids.value = selection.map((item) => item.dictId); this.ids = selection.map((item) => item.dictId);
single.value = selection.length != 1; this.single = selection.length != 1;
multiple.value = !selection.length; this.multiple = !selection.length;
}; },
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: DictTypeVO) => { async handleUpdate (row) {
reset(); this.reset();
const dictId = row?.dictId || ids.value[0]; const dictId = row?.dictId || this.ids.value[0];
const res = await getType(dictId); const res = await getType(dictId);
Object.assign(form.value, res.data); Object.assign(this.form, res.data);
dialog.visible = true; this.dialog.visible = true;
dialog.title = '修改学生类型'; this.dialog.title = '修改学生类型';
}; },
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { async submitForm() {
dictFormRef.value?.validate(async (valid: boolean) => { this.$refs.dictFormRef?.validate(async (valid) => {
if (valid) { if (valid) {
form.value.dictId ? await updateType(form.value) : await addType(form.value); this.form.dictId ? await updateType(this.form) : await addType(this.form);
proxy?.$modal.msgSuccess('操作成功'); ElMessage({
dialog.visible = false; type: 'success',
getList(); message: '操作成功'
});
this.dialog.visible = false;
this.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` /** 删除按钮操作 */
); async handleDelete (row) {
}; const dictIds = row?.dictId || this.ids.value;
/** 刷新缓存按钮操作 */ await this.$confirm('是否确认删除学生编号为"' + dictIds + '"的数据项?');
const handleRefreshCache = async () => { await delType(dictIds);
await refreshCache(); this.getList();
proxy?.$modal.msgSuccess('刷新成功'); this.$message({
useDictStore().cleanDict(); type: 'success',
}; message: '删除成功'
onMounted(() => {
getList();
}); });
},
/** 导出按钮操作 */
handleExport() {
},
/** 刷新缓存按钮操作 */
async handleRefreshCache () {
await refreshCache();
this.$message.success('刷新成功');
useDictStore().cleanDict();
}
}
};
</script> </script>