From 556f10970a57b078faafcea14fbb1f2d9b2100f5 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Thu, 25 May 2023 16:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AD=97=E6=AE=B5CURD?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/dict/index.ts | 91 ++++++++++++++++++++++++------ src/api/dict/types.ts | 15 ++++- src/views/system/dict/DictData.vue | 29 +++++----- src/views/system/dict/index.vue | 21 ++++--- 4 files changed, 114 insertions(+), 42 deletions(-) diff --git a/src/api/dict/index.ts b/src/api/dict/index.ts index 6f8eed8..7a7c3a0 100644 --- a/src/api/dict/index.ts +++ b/src/api/dict/index.ts @@ -6,7 +6,8 @@ import { DictTypeForm, DictQuery, DictForm, - DictPageResult + DictPageResult, + dictId } from './types'; /** @@ -37,19 +38,24 @@ export function getDictTypePage( * * @param id */ -export function getDictTypeForm(id: number): AxiosPromise { +export function getDictTypeFormOld(id: number): AxiosPromise { return request({ url: '/api/v1/dict/types/' + id + '/form', method: 'get' }); } - +export function getDictTypeForm(id: number): AxiosPromise { + return request({ + url: '/systemapi/dict/get_dict_type_cont?id=' + id, + method: 'get' + }); +} /** * 新增字典类型 * * @param data */ -export function addDictType(data: DictTypeForm) { +export function addDictTypeOld(data: DictTypeForm) { return request({ url: '/api/v1/dict/types', method: 'post', @@ -57,30 +63,50 @@ export function addDictType(data: DictTypeForm) { }); } +export function addDictType(data: DictTypeForm) { + return request({ + url: '/systemapi/dict/add_dict_type', + method: 'post', + data: data + }); +} + /** * 修改字典类型 * * @param id * @param data */ -export function updateDictType(id: number, data: DictTypeForm) { +export function updateDictTypeOld(id: number, data: DictTypeForm) { return request({ url: '/api/v1/dict/types/' + id, method: 'put', data: data }); } - +export function updateDictType(data: DictTypeForm) { + return request({ + url: '/systemapi/dict/edit_dict_type_cont', + method: 'post', + data: data + }); +} /** * 删除字典类型 */ -export function deleteDictTypes(ids: string) { +export function deleteDictTypesOld(ids: string) { return request({ url: '/api/v1/dict/types/' + ids, method: 'delete' }); } - +export function deleteDictTypes(data: dictId) { + return request({ + url: '/systemapi/dict/del_dict_type_cont', + method: 'post', + data:data + }); +} /** * 获取字典类型的数据项 * @@ -96,7 +122,7 @@ export function getDictOptions(typeCode: string): AxiosPromise { /** * 字典分页列表 */ -export function getDictPage( +export function getDictPageOld( queryParams: DictQuery ): AxiosPromise { return request({ @@ -106,53 +132,86 @@ export function getDictPage( }); } +export function getDictPage( + queryParams: DictQuery +): AxiosPromise { + return request({ + url: '/systemapi/dict/get_dictionary', + method: 'post', + data: queryParams + }); +} /** * 获取字典表单数据 * * @param id */ -export function getDictFormData(id: number): AxiosPromise { +export function getDictFormDataOld(id: number): AxiosPromise { return request({ url: '/api/v1/dict/' + id + '/form', method: 'get' }); } - +export function getDictFormData(id: number): AxiosPromise { + return request({ + url: '/systemapi/dict/get_dictionary_cont?id=' + id, + method: 'get' + }); +} /** * 新增字典 * * @param data */ -export function addDict(data: DictForm) { +export function addDictOld(data: DictForm) { return request({ url: '/api/v1/dict', method: 'post', data: data }); } - +export function addDict(data: DictForm) { + return request({ + url: '/systemapi/dict/add_dictionary_cont', + method: 'post', + data: data + }); +} /** * 修改字典项 * * @param id * @param data */ -export function updateDict(id: number, data: DictForm) { +export function updateDictOld(id: number, data: DictForm) { return request({ url: '/api/v1/dict/' + id, method: 'put', data: data }); } - +export function updateDict(data: DictForm) { + return request({ + url: '/systemapi/dict/edit_dictionary_cont', + method: 'post', + data: data + }); +} /** * 删除字典 * * @param ids 字典项ID,多个以英文逗号(,)分割 */ -export function deleteDict(ids: string) { +export function deleteDictOld(ids: string) { return request({ url: '/api/v1/dict/' + ids, method: 'delete' }); } +export function deleteDict(data: dictId) { + return request({ + url: '/systemapi/dict/del_dictionary_cont', + method: 'post', + data:data + }); +} diff --git a/src/api/dict/types.ts b/src/api/dict/types.ts index 315da6d..fd5a860 100644 --- a/src/api/dict/types.ts +++ b/src/api/dict/types.ts @@ -32,6 +32,10 @@ export interface DictTypePageVO { * 备注 */ remark?: string; + /** + * 类型编码 + */ + codekey: string; } /** @@ -46,7 +50,7 @@ export interface DictTypeForm { /** * 字典类型ID */ - id?: number; + id?: number|string; /** * 类型名称 */ @@ -72,11 +76,11 @@ export interface DictQuery extends PageQuery { /** * 字典项名称 */ - name?: string; + keywords?: string; /** * 字典类型编码 */ - typeCode?: string; + codetype?: string; } /** @@ -140,3 +144,8 @@ export interface DictForm { */ remark?: string; } + +//删除字典类型 +export interface dictId { + id?:string[] +} diff --git a/src/views/system/dict/DictData.vue b/src/views/system/dict/DictData.vue index ec40afc..90fd651 100644 --- a/src/views/system/dict/DictData.vue +++ b/src/views/system/dict/DictData.vue @@ -32,7 +32,7 @@ const props = defineProps({ watch( () => props.typeCode, (newVal: string) => { - queryParams.typeCode = newVal; + queryParams.codetype = newVal; resetQuery(); } ); @@ -47,7 +47,7 @@ const total = ref(0); const queryParams = reactive({ page: 1, pagesize: 10, - typeCode: props.typeCode, + codetype: props.typeCode, }); const dictList = ref(); @@ -59,7 +59,7 @@ const dialog = reactive({ const formData = reactive({ status: 1, typeCode: props.typeCode, - sort: 1, + sort: 50, }); const rules = reactive({ @@ -71,7 +71,7 @@ const rules = reactive({ * 查询 */ function handleQuery() { - if (queryParams.typeCode) { + if (queryParams.codetype) { loading.value = true; getDictPage(queryParams) .then(({ data }) => { @@ -126,7 +126,7 @@ function handleSubmit() { if (isValid) { const dictId = formData.id; if (dictId) { - updateDict(dictId, formData) + updateDict(formData) .then(() => { ElMessage.success("修改成功"); closeDialog(); @@ -176,13 +176,13 @@ function handleDelete(dictId?: number) { ElMessage.warning("请勾选删除项"); return; } - + let dictionanyIdAry = dictIds.split(",") ElMessageBox.confirm("确认删除已选中的数据项?", "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }).then(() => { - deleteDict(dictIds).then(() => { + deleteDict({id:dictionanyIdAry}).then(() => { ElMessage.success("删除成功"); resetQuery(); }); @@ -201,7 +201,7 @@ onMounted(() => { @@ -236,14 +236,14 @@ onMounted(() => { > - - + + - + + { - + { 正常 - 停用 + 停用 diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index f7eaee6..34027db 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -41,7 +41,7 @@ const formData = reactive({ const rules = reactive({ name: [{ required: true, message: "请输入字典类型名称", trigger: "blur" }], - code: [{ required: true, message: "请输入字典类型编码", trigger: "blur" }], + // code: [{ required: true, message: "请输入字典类型编码", trigger: "blur" }], }); /** @@ -101,7 +101,8 @@ function handleSubmit() { if (isValid) { const dictTypeId = formData.id; if (dictTypeId) { - updateDictType(dictTypeId, formData) + formData.id = dictTypeId.toString() + updateDictType(formData) .then(() => { ElMessage.success("修改成功"); closeDialog(); @@ -149,13 +150,15 @@ function handleDelete(dictTypeId?: number) { ElMessage.warning("请勾选删除项"); return; } - + // console.log("请勾选删除项-------->",dictTypeIds) + let dictTypeIdAry = dictTypeIds.split(",") + // console.log("请勾选删除项-------->",dictTypeIdAry) ElMessageBox.confirm("确认删除已选中的数据项?", "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }).then(() => { - deleteDictTypes(dictTypeIds).then(() => { + deleteDictTypes({id:dictTypeIdAry}).then(() => { ElMessage.success("删除成功"); resetQuery(); }); @@ -176,7 +179,7 @@ function openDictDialog(row: DictTypePageVO) { dictDataDialog.visible = true; dictDataDialog.title = "【" + row.name + "】字典数据"; - selectedDictType.typeCode = row.code; + selectedDictType.typeCode = row.codekey; selectedDictType.typeName = row.name; } @@ -234,7 +237,7 @@ onMounted(() => { > - +