From c334c2d76c1b51d0fbe1531bf524e1b90f921a7c Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期二, 20 五月 2025 15:16:39 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/views/system/dict/data.vue | 164 +++++++++++++++++++++++++++++------------------------- 1 files changed, 88 insertions(+), 76 deletions(-) diff --git a/src/views/system/dict/data.vue b/src/views/system/dict/data.vue index 65f8868..f4e2c6f 100644 --- a/src/views/system/dict/data.vue +++ b/src/views/system/dict/data.vue @@ -157,7 +157,7 @@ <el-radio v-for="dict in sys_normal_disable" :key="dict.value" - :label="dict.value" + :value="dict.value" >{{ dict.label }}</el-radio> </el-radio-group> </el-form-item> @@ -177,24 +177,24 @@ <script setup name="Data"> import useDictStore from '@/store/modules/dict' -import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type"; -import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data"; +import { optionselect as getDictOptionselect, getType } from "@/api/system/dict/type" +import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data" -const { proxy } = getCurrentInstance(); -const { sys_normal_disable } = proxy.useDict("sys_normal_disable"); +const { proxy } = getCurrentInstance() +const { sys_normal_disable } = proxy.useDict("sys_normal_disable") -const dataList = 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 defaultDictType = ref(""); -const typeOptions = ref([]); -const route = useRoute(); +const dataList = 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 defaultDictType = ref("") +const typeOptions = ref([]) +const route = useRoute() // 鏁版嵁鏍囩鍥炴樉鏍峰紡 const listClassOptions = ref([ { value: "default", label: "榛樿" }, @@ -203,15 +203,15 @@ { value: "info", label: "淇℃伅" }, { value: "warning", label: "璀﹀憡" }, { value: "danger", label: "鍗遍櫓" } -]); +]) const data = reactive({ form: {}, queryParams: { pageNum: 1, pageSize: 10, - dictLabel: undefined, dictType: undefined, + dictLabel: undefined, status: undefined }, rules: { @@ -219,39 +219,42 @@ dictValue: [{ required: true, message: "鏁版嵁閿�间笉鑳戒负绌�", trigger: "blur" }], dictSort: [{ required: true, message: "鏁版嵁椤哄簭涓嶈兘涓虹┖", trigger: "blur" }] } -}); +}) -const { queryParams, form, rules } = toRefs(data); +const { queryParams, form, rules } = toRefs(data) /** 鏌ヨ瀛楀吀绫诲瀷璇︾粏 */ function getTypes(dictId) { getType(dictId).then(response => { - queryParams.value.dictType = response.data.dictType; - defaultDictType.value = response.data.dictType; - getList(); - }); + queryParams.value.dictType = response.data.dictType + defaultDictType.value = response.data.dictType + getList() + }) } /** 鏌ヨ瀛楀吀绫诲瀷鍒楄〃 */ function getTypeList() { getDictOptionselect().then(response => { - typeOptions.value = response.data; - }); + typeOptions.value = response.data + }) } + /** 鏌ヨ瀛楀吀鏁版嵁鍒楄〃 */ function getList() { - loading.value = true; + loading.value = true listData(queryParams.value).then(response => { - dataList.value = response.rows; - total.value = response.total; - loading.value = false; - }); + dataList.value = response.rows + total.value = response.total + loading.value = false + }) } + /** 鍙栨秷鎸夐挳 */ function cancel() { - open.value = false; - reset(); + open.value = false + reset() } + /** 琛ㄥ崟閲嶇疆 */ function reset() { form.value = { @@ -263,88 +266,97 @@ dictSort: 0, status: "0", remark: undefined - }; - proxy.resetForm("dataRef"); + } + proxy.resetForm("dataRef") } + /** 鎼滅储鎸夐挳鎿嶄綔 */ function handleQuery() { - queryParams.value.pageNum = 1; - getList(); + queryParams.value.pageNum = 1 + getList() } + /** 杩斿洖鎸夐挳鎿嶄綔 */ function handleClose() { - const obj = { path: "/system/dict" }; - proxy.$tab.closeOpenPage(obj); + const obj = { path: "/system/dict" } + proxy.$tab.closeOpenPage(obj) } + /** 閲嶇疆鎸夐挳鎿嶄綔 */ function resetQuery() { - proxy.resetForm("queryRef"); - queryParams.value.dictType = defaultDictType.value; - handleQuery(); + proxy.resetForm("queryRef") + queryParams.value.dictType = defaultDictType.value + handleQuery() } + /** 鏂板鎸夐挳鎿嶄綔 */ function handleAdd() { - reset(); - open.value = true; - title.value = "娣诲姞瀛楀吀鏁版嵁"; - form.value.dictType = queryParams.value.dictType; + reset() + open.value = true + title.value = "娣诲姞瀛楀吀鏁版嵁" + form.value.dictType = queryParams.value.dictType } + /** 澶氶�夋閫変腑鏁版嵁 */ function handleSelectionChange(selection) { - ids.value = selection.map(item => item.dictCode); - single.value = selection.length != 1; - multiple.value = !selection.length; + ids.value = selection.map(item => item.dictCode) + single.value = selection.length != 1 + multiple.value = !selection.length } + /** 淇敼鎸夐挳鎿嶄綔 */ function handleUpdate(row) { - reset(); - const dictCode = row.dictCode || ids.value; + reset() + const dictCode = row.dictCode || ids.value getData(dictCode).then(response => { - form.value = response.data; - open.value = true; - title.value = "淇敼瀛楀吀鏁版嵁"; - }); + form.value = response.data + open.value = true + title.value = "淇敼瀛楀吀鏁版嵁" + }) } + /** 鎻愪氦鎸夐挳 */ function submitForm() { proxy.$refs["dataRef"].validate(valid => { if (valid) { if (form.value.dictCode != undefined) { updateData(form.value).then(response => { - useDictStore().removeDict(queryParams.value.dictType); - proxy.$modal.msgSuccess("淇敼鎴愬姛"); - open.value = false; - getList(); - }); + useDictStore().removeDict(queryParams.value.dictType) + proxy.$modal.msgSuccess("淇敼鎴愬姛") + open.value = false + getList() + }) } else { addData(form.value).then(response => { - useDictStore().removeDict(queryParams.value.dictType); - proxy.$modal.msgSuccess("鏂板鎴愬姛"); - open.value = false; - getList(); - }); + useDictStore().removeDict(queryParams.value.dictType) + proxy.$modal.msgSuccess("鏂板鎴愬姛") + open.value = false + getList() + }) } } - }); + }) } + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ function handleDelete(row) { - const dictCodes = row.dictCode || ids.value; + const dictCodes = row.dictCode || ids.value proxy.$modal.confirm('鏄惁纭鍒犻櫎瀛楀吀缂栫爜涓�"' + dictCodes + '"鐨勬暟鎹」锛�').then(function() { - return delData(dictCodes); + return delData(dictCodes) }).then(() => { - getList(); - proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); - useDictStore().removeDict(queryParams.value.dictType); - }).catch(() => {}); + getList() + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") + useDictStore().removeDict(queryParams.value.dictType) + }).catch(() => {}) } + /** 瀵煎嚭鎸夐挳鎿嶄綔 */ function handleExport() { proxy.download("system/dict/data/export", { ...queryParams.value - }, `dict_data_${new Date().getTime()}.xlsx`); + }, `dict_data_${new Date().getTime()}.xlsx`) } -getTypes(route.params && route.params.dictId); -getTypeList(); +getTypes(route.params && route.params.dictId) +getTypeList() </script> -- Gitblit v1.9.3