diff --git a/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/controller/DictController.java b/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/controller/DictController.java index 89d28d7d..8f82372c 100644 --- a/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/controller/DictController.java +++ b/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/controller/DictController.java @@ -68,10 +68,10 @@ public class DictController { } @SysLog("字典删除") - @DeleteMapping("/remove/{ids:[\\w,]+}") + @DeleteMapping("/remove/{types:[\\w,]+}") @PreAuthorize("@pms.hasPermission('dict_del')") - public R remove(@PathVariable String[] ids) { - dictService.removeByIds(Arrays.asList(ids)); + public R remove(@PathVariable String[] types) { + dictService.deleteByTypes(types); return R.ok(); } diff --git a/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/DictService.java b/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/DictService.java index a457c5f8..54f9015a 100644 --- a/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/DictService.java +++ b/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/DictService.java @@ -13,4 +13,11 @@ import com.cloud.kicc.system.api.entity.Dict; */ public interface DictService extends IService { + /** + * 删除字典,包括字典数据 + * @param types 多个字典类型 + * @return void + */ + void deleteByTypes(String[] types); + } diff --git a/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/impl/DictServiceImpl.java b/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/impl/DictServiceImpl.java index f23f7671..a265aaa4 100644 --- a/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/impl/DictServiceImpl.java +++ b/kicc-platform/kicc-platform-biz/kicc-system-biz/src/main/java/com/cloud/kicc/system/service/impl/DictServiceImpl.java @@ -1,10 +1,15 @@ package com.cloud.kicc.system.service.impl; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.cloud.kicc.system.api.entity.Dict; +import com.cloud.kicc.system.api.entity.DictData; import com.cloud.kicc.system.mapper.DictMapper; +import com.cloud.kicc.system.service.DictDataService; import com.cloud.kicc.system.service.DictService; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** *

@@ -15,6 +20,18 @@ import org.springframework.stereotype.Service; * @Date: 2022/2/24 */ @Service +@RequiredArgsConstructor public class DictServiceImpl extends ServiceImpl implements DictService { + private final DictDataService dictDataService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByTypes(String[] types) { + for (int i = 0; i < types.length; ++i) { + this.remove(Wrappers.lambdaUpdate().eq(Dict::getType, types[i])); + dictDataService.remove(Wrappers.lambdaUpdate().eq(DictData::getDictType, types[i])); + } + } + } diff --git a/kicc-ui/.eslintrc.js b/kicc-ui/.eslintrc.js index c2b3fc73..deabb9cd 100644 --- a/kicc-ui/.eslintrc.js +++ b/kicc-ui/.eslintrc.js @@ -44,13 +44,14 @@ module.exports = defineConfig({ '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/quotes': ['error', 'single'], /** ----------eslint配置----------- */ 'no-use-before-define': 'off', 'no-unused-vars': 'off', 'space-before-function-paren': 'off', - 'semi': ['error', 'always',], - "prefer-const": 'off', + 'semi': ['error', 'always'], + 'prefer-const': 'off', /** ----------vue配置----------- */ 'vue/script-setup-uses-vars': 'error', @@ -75,5 +76,6 @@ module.exports = defineConfig({ math: 'always', }, ], + 'vue/html-quotes': [ 'error', 'double', { 'avoidEscape': false } ] }, }); diff --git a/kicc-ui/src/views/system/dict/dict.data.ts b/kicc-ui/src/views/system/dict/dict.data.ts index 21733432..1e8a42c4 100644 --- a/kicc-ui/src/views/system/dict/dict.data.ts +++ b/kicc-ui/src/views/system/dict/dict.data.ts @@ -1,119 +1,134 @@ -import {BasicColumn} from '/@/components/Table'; -import {FormSchema} from '/@/components/Table'; -import {h} from "vue"; -import {Tag} from "ant-design-vue"; +/** + * @program: kicc-ui + * @description: 字典模块动态渲染配置 + * @author: entfrm开发团队-王翔 + * @create: 2022/5/8 + */ +import { BasicColumn } from '/@/components/Table'; +import { FormSchema } from '/@/components/Table'; +import { h } from 'vue'; +import { Tag } from 'ant-design-vue'; + +/** 表格列配置 */ export const columns: BasicColumn[] = [ - { - title: '字典ID', - dataIndex: 'id', - width: 100, - }, - { - title: '字典名称', - dataIndex: 'name', - width: 100, - }, - { - title: '字典类型', - dataIndex: 'type', - width: 130, - }, - { - title: '系统内置', - dataIndex: 'isSys', - width: 90, - customRender: ({ record }) => { - const status = record.status; - const enable = status === '0'; - const color = 'gray'; - const text = enable ? '是' : '否'; - return h(Tag, { color: color }, () => text); - } - }, - { - title: '状态', - dataIndex: 'status', - width: 90, - customRender: ({ record }) => { - const status = record.status; - const enable = status === '0'; - const color = enable ? 'green' : 'red'; - const text = enable ? '启用' : '禁用'; - return h(Tag, { color: color }, () => text); - } + { + title: '字典名称', + dataIndex: 'name' + }, + { + title: '字典类型', + dataIndex: 'type' + }, + { + title: '系统内置', + dataIndex: 'isSys', + width: 90, + customRender: ({ record }) => { + const status = record.status; + const enable = ~~status === 0; + const color = enable ? 'green' : 'red'; + const text = enable ? '是' : '否'; + return h(Tag, { color: color }, () => text); } -]; - -export const searchFormSchema: FormSchema[] = [ - { - field: 'type', - label: '字典类型', - component: 'Input', - componentProps: { - placeholder: '请输入字典类型', - }, - colProps: {span: 16}, + }, + { + title: '状态', + dataIndex: 'status', + width: 130, + customRender: ({ record }) => { + const status = record.status; + const enable = ~~status === 0; + const color = enable ? 'green' : 'red'; + const text = enable ? '启用' : '禁用'; + return h(Tag, { color: color }, () => text); } + } ]; -export const formSchema: FormSchema[] = [ - { - field: 'id', - label: 'ID', - component: 'Input', - show: false, - }, - { - field: 'name', - label: '字典名称', - component: 'Input', - colProps:{ - span: 12 - } - +/** 搜索表单配置 */ +export const searchFormSchema: FormSchema[] = [ + { + field: 'name', + label: '字典名称', + component: 'Input', + componentProps: { + placeholder: '请输入字典名称', }, - { - field: 'type', - label: '字典类型', - component: 'Input', - colProps:{ - span: 12 - } + colProps: { span: 8 } + }, + { + field: 'type', + label: '字典类型', + component: 'Input', + componentProps: { + placeholder: '请输入字典类型', }, - { - field: 'isSys', - label: '系统内置', - component: 'Select', - defaultValue: '0', - componentProps: { - options: [ - { label: '是', value: '0' }, - { label: '否', value: '1' } - ] - }, - colProps:{ - span: 12 - } + colProps: { span: 8 } + }, + { + field: 'status', + label: '状态', + component: 'Select', + componentProps: { + options: [ + { label: '正常', value: '0' }, + { label: '停用', value: '1' } + ] }, - { - field: 'status', - label: '状态', - component: 'Select', - defaultValue: '0', - componentProps: { - options: [ - { label: '启用', value: '0' }, - { label: '禁用', value: '1' } - ] - }, - colProps:{ - span: 12 - } + colProps: { span: 8 } + } +]; + +/** 表单配置 */ +export const formSchema: FormSchema[] = [ + { + field: 'id', + label: 'ID', + component: 'Input', + show: false + }, + { + field: 'name', + label: '字典名称', + component: 'Input', + colProps:{ span: 12 } + }, + { + field: 'type', + label: '字典类型', + component: 'Input', + colProps:{ span: 12 } + }, + { + field: 'isSys', + label: '系统内置', + component: 'Select', + defaultValue: '0', + componentProps: { + options: [ + { label: '是', value: '0' }, + { label: '否', value: '1' } + ] }, - { - field: 'remarks', - label: '备注', - component: 'InputTextArea', + colProps:{ span: 12 } + }, + { + field: 'status', + label: '状态', + component: 'Select', + defaultValue: '0', + componentProps: { + options: [ + { label: '启用', value: '0' }, + { label: '禁用', value: '1' } + ] }, + colProps:{ span: 12 } + }, + { + field: 'remarks', + label: '备注', + component: 'InputTextArea', + }, ]; diff --git a/kicc-ui/src/views/system/dict/index.vue b/kicc-ui/src/views/system/dict/index.vue index 5d95cbd8..8723049e 100644 --- a/kicc-ui/src/views/system/dict/index.vue +++ b/kicc-ui/src/views/system/dict/index.vue @@ -1,109 +1,177 @@