diff --git a/src/api/data/config.ts b/src/api/data/config.ts index 192bfcf..0badf08 100644 --- a/src/api/data/config.ts +++ b/src/api/data/config.ts @@ -10,13 +10,6 @@ export function getConfigList(params?) { params, }); } -export function getConfigAllList(params?) { - return http.request({ - url: '/config/list', - method: 'GET', - params, - }); -} /** * @description: 根据ID获取详情 */ @@ -26,6 +19,15 @@ export function getConfigDetail(id) { method: 'get', }); } +/** + * @description: 刷新缓存 + */ +export function refreshCache() { + return http.request({ + url: '/config/refreshCache', + method: 'get', + }); +} /** * @description: 添加配置 */ @@ -64,4 +66,63 @@ export function configBatchDelete(data:any) { method: 'DELETE', data }); +} + +/** + * @description: 配置项列表 + */ +export function getConfigItemList(params?) { + return http.request({ + url: '/config/item/page', + method: 'GET', + params, + }); +} +/** + * @description: 根据ID获取详情 + */ +export function getConfigItemDetail(id) { + return http.request({ + url: '/config/item/detail/'+id, + method: 'get', + }); +} +/** + * @description: 添加配置项 + */ +export function configItemAdd(data:any) { + return http.request({ + url: '/config/item/add', + method: 'POST', + data, + }); +} +/** + * @description: 更新配置项 + */ +export function configItemUpdate(data:any) { + return http.request({ + url: '/config/item/update', + method: 'PUT', + data + }); +} +/** + * @description: 删除配置项 + */ +export function configItemDelete(id) { + return http.request({ + url: '/config/item/delete/'+id, + method: 'DELETE', + }); +} +/** + * @description: 批量删除配置项 + */ +export function configItemBatchDelete(data:any) { + return http.request({ + url: '/config/item/batchDelete', + method: 'DELETE', + data + }); } \ No newline at end of file diff --git a/src/components/Table/src/Table.vue b/src/components/Table/src/Table.vue index 84fea79..466bc7f 100644 --- a/src/components/Table/src/Table.vue +++ b/src/components/Table/src/Table.vue @@ -312,6 +312,7 @@ size: unref(getTableSize), stripe: unref(getStriped), 'max-height': getDeviceHeight.value, + height:getDeviceHeight.value, }; }); diff --git a/src/utils/validate.ts b/src/utils/validate.ts new file mode 100644 index 0000000..7362d28 --- /dev/null +++ b/src/utils/validate.ts @@ -0,0 +1,206 @@ +/** + * 判断是否为空 + * @param val 数据 + */ +export const validateNull = (val: any) => { + if (typeof val === 'boolean') { + return false; + } + if (typeof val === 'number') { + return false; + } + if (val instanceof Array) { + if (val.length === 0) return true; + } else if (val instanceof Object) { + if (JSON.stringify(val) === '{}') return true; + } else { + if (val === 'null' || val == null || val === 'undefined' || val === undefined || val === '') return true; + return false; + } + return false; +}; + +export const rule = { + /** + * 校验 请输入中文、英文、数字包括下划线 + * 名称校验 + */ + validatorNameCn(rule: any, value: any, callback: any) { + const acount = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/; + if (value && !acount.test(value)) { + callback(new Error('请输入中文、英文、数字包括下划线')); + } else { + callback(); + } + }, + /** + * 校验 请输入大写英文、下划线 + * 名称校验 + */ + validatorCapital(rule: any, value: any, callback: any) { + const acount = /^[A-Z_]+$/; + if (value && !acount.test(value)) { + callback(new Error('请输入大写英文、下划线')); + } else { + callback(); + } + }, + + /** + * 校验 请输入小写英文、下划线 + * 名称校验 + */ + validatorLowercase(rule: any, value: any, callback: any) { + const acount = /^[a-z_]+$/; + if (value && !acount.test(value)) { + callback(new Error('请输入小写英文、下划线')); + } else { + callback(); + } + }, + + /** + * 校验 请输入小写英文 + * 名称校验 + */ + validatorLower(rule: any, value: any, callback: any) { + const acount = /^[a-z]+$/; + if (value && !acount.test(value)) { + callback(new Error('请输入小写英文')); + } else { + callback(); + } + }, + + /** + * 校验首尾空白字符的正则表达式 + * + */ + checkSpace(rule: any, value: any, callback: any) { + const longrg = /[^\s]+$/; + if (!longrg.test(value)) { + callback(new Error('请输入非空格信息')); + } else { + callback(); + } + }, + + /** + * 校验手机号 + */ + validatePhone(rule: any, value: any, callback: any) { + var isPhone = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/; + + if (value.indexOf('****') >= 0) { + return callback(); + } + + if (!isPhone.test(value)) { + callback(new Error('请输入合法手机号')); + } else { + callback(); + } + }, + + /* 数字 */ + number(rule, value, callback) { + validateFn('number', rule, value, callback, '包含非数字字符'); + }, + + /* 字母 */ + letter(rule, value, callback) { + validateFn('letter', rule, value, callback, '包含非字母字符'); + }, + + /* 字母和数字 */ + letterAndNumber(rule, value, callback) { + validateFn('letterAndNumber', rule, value, callback, '只能输入字母或数字'); + }, + + /* 手机号码 */ + mobilePhone(rule, value, callback) { + validateFn('mobilePhone', rule, value, callback, '手机号码格式有误'); + }, + + /* 字母开头,仅可包含数字 */ + letterStartNumberIncluded(rule, value, callback) { + validateFn('letterStartNumberIncluded', rule, value, callback, '必须以字母开头,可包含数字'); + }, + + /* 禁止中文输入 */ + noChinese(rule, value, callback) { + validateFn('noChinese', rule, value, callback, '不可输入中文字符'); + }, + + /* 必须中文输入 */ + chinese(rule, value, callback) { + validateFn('chinese', rule, value, callback, '只能输入中文字符'); + }, + + /* 电子邮箱 */ + email(rule, value, callback) { + validateFn('email', rule, value, callback, '邮箱格式有误'); + }, + + /* URL网址 */ + url(rule, value, callback) { + validateFn('url', rule, value, callback, 'URL格式有误'); + }, + + regExp(rule, value, callback) { + if (validateNull(value) || value.length <= 0) { + callback(); + return; + } + + const pattern = new RegExp(rule.regExp); + + if (!pattern.test(value)) { + const errTxt = rule.errorMsg || 'invalid value'; + callback(new Error(errTxt)); + } else { + callback(); + } + }, +}; + +/** + * @desc [自定义校验规则] + * @example + * import { validateRule } from "@/utils/validateRules"; + * rules: [ + * { validator: validateRule.emailValue, trigger: 'blur'} + * ] + */ + +export const getRegExp = function (validatorName) { + const commonRegExp = { + number: '^[-]?\\d+(\\.\\d+)?$', + letter: '^[A-Za-z]+$', + letterAndNumber: '^[A-Za-z0-9]+$', + mobilePhone: '^[1][3-9][0-9]{9}$', + letterStartNumberIncluded: '^[A-Za-z]+[A-Za-z\\d]*$', + noChinese: '^[^\u4e00-\u9fa5]+$', + chinese: '^[\u4e00-\u9fa5]+$', + email: '^([-_A-Za-z0-9.]+)@([_A-Za-z0-9]+\\.)+[A-Za-z0-9]{2,3}$', + url: '(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]' + }; + return commonRegExp[validatorName]; +}; + +const validateFn = (validatorName, rule, value, callback, defaultErrorMsg) => { + if (validateNull(value) || value.length <= 0) { + callback(); + return; + } + + const reg = new RegExp(getRegExp(validatorName)); + + if (!reg.test(value)) { + const errTxt = rule.errorMsg || defaultErrorMsg; + callback(new Error(errTxt)); + } else { + callback(); + } +}; + diff --git a/src/views/data/config/columns.ts b/src/views/data/config/columns.ts index baca339..f5c40a5 100644 --- a/src/views/data/config/columns.ts +++ b/src/views/data/config/columns.ts @@ -12,13 +12,5 @@ export const columns = [ { label: '排序', prop: 'sort', - }, - { - label: '创建人', - prop: 'createUser', - }, - { - label: '创建时间', - prop: 'createTime', - }, + } ]; diff --git a/src/views/data/config/columnsItem.ts b/src/views/data/config/columnsItem.ts new file mode 100644 index 0000000..6e8e759 --- /dev/null +++ b/src/views/data/config/columnsItem.ts @@ -0,0 +1,99 @@ +import { h } from 'vue'; +import { ElTag } from 'element-plus'; +export const columns = [ + { + type: 'selection', + }, + { + label: '配置项名称', + prop: 'name', + }, + { + label: '配置项编码', + prop: 'code', + }, + { + label: '配置项值', + prop: 'value', + }, + { + label: '配置项类型', + prop: 'type', + render(record) { + let typeText = '' + switch (record.row.type) { + case 'hidden': + typeText='隐藏' + break; + case 'readonly': + typeText='只读文本' + break; + case 'number': + typeText='数字' + break; + case 'text': + typeText='单行文本' + break; + case 'textarea': + typeText='多行文本' + break; + case 'password': + typeText='密码' + break; + case 'radio': + typeText='单选框' + break; + case 'checkbox': + typeText='复选框' + break; + case 'select': + typeText='下拉框(单选)' + break; + case 'selects': + typeText='下拉框(多选)' + break; + case 'icon': + typeText='字体图标' + break; + case 'date': + typeText='日期' + break; + case 'datetime': + typeText='时间' + break; + case 'image': + typeText='单张图片' + break; + case 'images': + typeText='多张图片' + break; + case 'file': + typeText='单个文件' + case 'files': + typeText='多个文件' + break; + case 'ueditor': + typeText='富文本编辑器' + break; + default: + break; + } + return h('span', typeText || '-'); + }, + }, + { + label: '配置项状态', + prop: 'status', + render(record) { + return h( + ElTag, + { + type: record.row.status ==1 ? 'success' : 'danger', + }, + { + default: () => (record.row.status ==1 ? '正常' : '停用'), + }, + ); + }, + }, +]; diff --git a/src/views/data/config/configItem.vue b/src/views/data/config/configItem.vue new file mode 100644 index 0000000..23ebf65 --- /dev/null +++ b/src/views/data/config/configItem.vue @@ -0,0 +1,127 @@ + + + + diff --git a/src/views/data/config/editItem.vue b/src/views/data/config/editItem.vue new file mode 100644 index 0000000..19f6e52 --- /dev/null +++ b/src/views/data/config/editItem.vue @@ -0,0 +1,233 @@ + + diff --git a/src/views/data/config/index.vue b/src/views/data/config/index.vue index 808647f..f206749 100644 --- a/src/views/data/config/index.vue +++ b/src/views/data/config/index.vue @@ -1,157 +1,142 @@ - - + diff --git a/src/views/data/config/querySchemas.ts b/src/views/data/config/querySchemas.ts deleted file mode 100644 index acba086..0000000 --- a/src/views/data/config/querySchemas.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { FormSchema } from '@/components/Form/index'; -export const schemas: FormSchema[] = [ - { - field: 'name', - component: 'Input', - label: '配置名称', - componentProps: { - placeholder: '请输入配置名称', - }, - } -];