From c633b580be8406cd184d92d7272a01a137b12e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Sat, 18 Feb 2023 19:25:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD:=20tableSelector?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/tableSelector/index.vue | 144 +++++++++++++++----- web/src/settings.ts | 2 +- web/src/views/system/messageCenter/crud.tsx | 111 +++++++++------ 3 files changed, 175 insertions(+), 82 deletions(-) diff --git a/web/src/components/tableSelector/index.vue b/web/src/components/tableSelector/index.vue index 0fbaa13..180d8d8 100644 --- a/web/src/components/tableSelector/index.vue +++ b/web/src/components/tableSelector/index.vue @@ -1,82 +1,103 @@ - + - + - 搜索 + - - - - - - - + + - + diff --git a/web/src/settings.ts b/web/src/settings.ts index bc4b43e..cbe2219 100644 --- a/web/src/settings.ts +++ b/web/src/settings.ts @@ -18,7 +18,7 @@ export default { //i18n, //i18n配置,可选,默认使用中文,具体用法请看demo里的 src/i18n/index.js 文件 // 此处配置公共的dictRequest(字典请求) async dictRequest({ dict }: any) { - return await request({ url: dict.url }); //根据dict的url,异步返回一个字典数组 + return await request({ url: dict.url,params:dict.params || {} }); //根据dict的url,异步返回一个字典数组 }, //公共crud配置 commonOptions() { diff --git a/web/src/views/system/messageCenter/crud.tsx b/web/src/views/system/messageCenter/crud.tsx index 395ebfd..ffaa802 100644 --- a/web/src/views/system/messageCenter/crud.tsx +++ b/web/src/views/system/messageCenter/crud.tsx @@ -4,6 +4,7 @@ import {request} from "/@/utils/service"; import {dictionary} from "/@/utils/dictionary"; import tableSelector from "/@/components/tableSelector/index.vue" import {shallowRef} from "vue"; + interface CreateCrudOptionsTypes { crudOptions: CrudOptions; } @@ -35,7 +36,7 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos id: { title: 'id', form: { - show:false + show: false } }, @@ -58,8 +59,8 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos is_read: { title: '是否已读', type: 'dict-select', - column:{ - show:false + column: { + show: false }, dict: dict({ data: [ @@ -68,12 +69,12 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos ] }), form: { - show:false + show: false } }, target_type: { title: '目标类型', - type: ['dict-radio','colspan'], + type: ['dict-radio', 'colspan'], width: 120, // show() { // return vm.tabActivted === 'send' @@ -104,32 +105,27 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos }, width: 130, disabled: true, - dict: dict({ - cache: false, - url: '/api/system/user/', - value: 'id', // 数据字典中value字段的属性名 - label: 'name', // 数据字典中label字段的属性名 - }), form: { - component:{ + component: { name: shallowRef(tableSelector), vModel: "modelValue", - label:'name', - value:'date', - tableConfig:{ - isMultiple:true, - data:[{ - date: '2016-05-03', - name: 'Tom', - address: 'No. 189, Grove St, Los Angeles', - },{ - date: '2016-05-01', - name: 'Tom', - address: 'No. 189, Grove St, Los Angeles', - },] + tableConfig: { + url: '/api/system/user/', + label: 'name', + value: 'id', + isMultiple: true, + columns: [{ + prop: 'name', + label: '用户名称', + width: 120 + }, { + prop: 'phone', + label: '用户电话', + width: 120 + }] } }, - show:compute(({ form })=>{ + show: compute(({form}) => { return form.target_type === 0 }), rules: [ // 表单校验规则 @@ -153,15 +149,26 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos }, disabled: true, width: 130, - type: 'table-selector', - dict: { - cache: false, - url: '/api/system/role/', - value: 'id', // 数据字典中value字段的属性名 - label: 'name', // 数据字典中label字段的属性名 - }, form: { - show:compute(({ form })=>{ + component: { + name: shallowRef(tableSelector), + vModel: "modelValue", + tableConfig: { + url: '/api/system/role/', + label: 'name', + value: 'id', + isMultiple: true, + columns: [{ + prop: 'name', + label: '角色名称' + }, + { + prop: 'key', + label: '权限标识' + }] + } + }, + show: compute(({form}) => { return form.target_type === 1 }), rules: [ // 表单校验规则 @@ -184,17 +191,31 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos }, width: 130, type: 'table-selector', - dict: { - cache: false, - url: '/api/system/dept/all_dept/', - isTree: true, - value: 'id', // 数据字典中value字段的属性名 - label: 'name', // 数据字典中label字段的属性名 - children: 'children', // 数据字典中children字段的属性名 - }, - disabled: true, form: { - show:compute(({ form })=>{ + component: { + name: shallowRef(tableSelector), + vModel: "modelValue", + tableConfig: { + url: '/api/system/dept/all_dept/', + label: 'name', + value: 'id', + isTree: true, + isMultiple: true, + columns: [{ + prop: 'name', + label: '部门名称' + }, + { + prop: 'status_label', + label: '状态' + }, + { + prop: 'parent_name', + label: '父级部门' + }] + } + }, + show: compute(({form}) => { return form.target_type === 2 }), rules: [ // 表单校验规则 @@ -235,7 +256,7 @@ export const createCrudOptions = function ({crudExpose}: { crudExpose: CrudExpos config: {}, uploader: { type: "form", - buildUrl(res:any) { + buildUrl(res: any) { return res.url; } }