diff --git a/packages/d2-crud-plus-example/src/business/modules/example/views/form/el/crud.js b/packages/d2-crud-plus-example/src/business/modules/example/views/form/el/crud.js
index 61418a578..2adcc3f94 100644
--- a/packages/d2-crud-plus-example/src/business/modules/example/views/form/el/crud.js
+++ b/packages/d2-crud-plus-example/src/business/modules/example/views/form/el/crud.js
@@ -1,115 +1,120 @@
-export const crudOptions = {
- options: {
- height: '100%' // 表格高度100%, 使用toolbar必须设置
- },
- columns: [
- {
- title: 'ID',
- key: 'id',
- width: 90,
- form: {
- disabled: true
- }
- },
- {
- title: '数字',
- search: {},
- key: 'number',
- type: 'number'
- },
- {
- title: '开关',
- key: 'switch',
- type: 'switch',
- search: {
- disabled: false,
- component: {
- show (context) {
- console.log('switch search show:', context)
- return true
- }
- }
- },
- form: {
- component: {
- show (context) {
- console.log('switch form show:', context)
- return true
- }
- }
- },
- component: {
- disabled (context) {
- console.log('switch row disabled:', context)
- return !context.form.number
- }
- }
- },
- {
- title: '滑块',
- key: 'slider',
- type: 'slider'
- },
- {
- title: '评分',
- key: 'rate',
- type: 'rate'
- },
- {
- title: '颜色',
- key: 'color-picker',
- type: 'color-picker'
- },
- {
- title: '穿梭框',
- key: 'transfer',
- type: 'transfer',
- form: {
- component: { span: 24 }
- },
- valueBuilder (row, col) {
- if (row[col.key] === '') {
- row[col.key] = null
- }
- console.log('tranfer:', row, row[col.key], col.key)
- }
-
- },
- {
- title: '输入建议(autocomplete)',
- key: 'autocomplete',
- search: {},
- type: 'autocomplete',
- form: {
- component: {
- props: {
- fetchSuggestions: (queryString, callback) => {
- const ret = [
- { value: '三全鲜食(北新泾店)', address: '长宁区新渔路144号' },
- { value: 'Hot honey 首尔炸鸡(仙霞路)', address: '上海市长宁区淞虹路661号' }
- ]
- callback(ret)
- }
- },
- events: {
- select (event) {
- console.log('autocomplete select:', event)
- }
- },
- slots: {
- // 自定义列表项
- default: (h, scope) => {
- return (
)
- }
- },
- children: [
- (h) => {
- return ()
- }
- ],
- span: 24
- }
- }
- }
- ]
-}
+export const crudOptions = {
+ options: {
+ height: '100%' // 表格高度100%, 使用toolbar必须设置
+ },
+ columns: [
+ {
+ title: 'ID',
+ key: 'id',
+ width: 90,
+ form: {
+ disabled: true
+ }
+ },
+ {
+ title: '数字',
+ search: {},
+ key: 'number',
+ type: 'number'
+ },
+ {
+ title: '开关',
+ key: 'switch',
+ type: 'switch',
+ search: {
+ disabled: false,
+ component: {
+ show (context) {
+ return true
+ }
+ }
+ },
+ form: {
+ component: {
+ show (context) {
+ return true
+ }
+ }
+ },
+ component: {
+ disabled (context) {
+ return !context.form.number
+ }
+ }
+ },
+ {
+ title: '开关2',
+ key: 'switch2',
+ sortable: true,
+ search: { disabled: false },
+ type: 'dict-switch', // 区别在于这个是包装组件,支持dict,并且单元格使用tag展示
+ dict: { data: [{ value: 1, label: '开启' }, { value: 0, label: '关闭' }] }
+ },
+ {
+ title: '滑块',
+ key: 'slider',
+ type: 'slider'
+ },
+ {
+ title: '评分',
+ key: 'rate',
+ type: 'rate'
+ },
+ {
+ title: '颜色',
+ key: 'color-picker',
+ type: 'color-picker'
+ },
+ {
+ title: '穿梭框',
+ key: 'transfer',
+ type: 'transfer',
+ form: {
+ component: { span: 24 }
+ },
+ valueBuilder (row, col) {
+ if (row[col.key] === '') {
+ row[col.key] = null
+ }
+ // console.log('tranfer:', row, row[col.key], col.key)
+ }
+
+ },
+ {
+ title: '输入建议(autocomplete)',
+ key: 'autocomplete',
+ search: {},
+ type: 'autocomplete',
+ form: {
+ component: {
+ props: {
+ fetchSuggestions: (queryString, callback) => {
+ const ret = [
+ { value: '三全鲜食(北新泾店)', address: '长宁区新渔路144号' },
+ { value: 'Hot honey 首尔炸鸡(仙霞路)', address: '上海市长宁区淞虹路661号' }
+ ]
+ callback(ret)
+ }
+ },
+ events: {
+ select (event) {
+ console.log('autocomplete select:', event)
+ }
+ },
+ slots: {
+ // 自定义列表项
+ default: (h, scope) => {
+ return ()
+ }
+ },
+ children: [
+ (h) => {
+ return ()
+ }
+ ],
+ span: 24
+ }
+ }
+ }
+ ]
+}
diff --git a/packages/d2-crud-plus-example/src/business/modules/example/views/form/select/mock.js b/packages/d2-crud-plus-example/src/business/modules/example/views/form/select/mock.js
index 10cb1036b..706b94505 100644
--- a/packages/d2-crud-plus-example/src/business/modules/example/views/form/select/mock.js
+++ b/packages/d2-crud-plus-example/src/business/modules/example/views/form/select/mock.js
@@ -1,249 +1,250 @@
-import mockUtil from '@/business/mock/base'
-
-const options = {
- name: 'select',
- idGenerator: 0
-}
-const list = [
- {
- status: '0',
- mselect: 'sz,bj,gz,sh,hz,wh',
- cascader: ['zhinan', 'shejiyuanze', 'yizhi'],
- checkbox: '0',
- status_custom_1: '0',
- status_custom_2: '0',
- checkedRadio: '1',
- mcascader: [['zhinan', 'shejiyuanze', 'yizhi']]
- },
- {
- status: '1',
- status_custom_1: '1',
- status_custom_2: '2',
- mselect: 'sh,sz',
- slotExample: 'slotExample',
- checkbox: '0'
- },
- {
- date: '2016-05-03',
- status: '2',
- status_custom_1: '2',
- status_custom_2: '1',
- mselect: 'wh,gz',
- slotExample: 'slotExample',
- checkbox: '0'
- }
-]
-
-const dictData = [
- {
- value: 'zhinan',
- label: '指南',
- children: [{
- value: 'shejiyuanze',
- label: '设计原则',
- children: [{
- value: 'yizhi',
- label: '一致'
- }, {
- value: 'fankui',
- label: '反馈'
- }, {
- value: 'xiaolv',
- label: '效率'
- }, {
- value: 'kekong',
- label: '可控'
- }]
- }, {
- value: 'daohang',
- label: '导航',
- children: [{
- value: 'cexiangdaohang',
- label: '侧向导航'
- }, {
- value: 'dingbudaohang',
- label: '顶部导航'
- }]
- }]
- }, {
- value: 'zujian',
- label: '组件',
- children: [{
- value: 'basic',
- label: 'Basic',
- children: [{
- value: 'layout',
- label: 'Layout 布局'
- }, {
- value: 'color',
- label: 'Color 色彩'
- }, {
- value: 'typography',
- label: 'Typography 字体'
- }, {
- value: 'icon',
- label: 'Icon 图标'
- }, {
- value: 'button',
- label: 'Button 按钮'
- }]
- }, {
- value: 'form',
- label: 'Form',
- children: [{
- value: 'radio',
- label: 'Radio 单选框'
- }, {
- value: 'checkbox',
- label: 'Checkbox 多选框'
- }, {
- value: 'input',
- label: 'Input 输入框'
- }, {
- value: 'input-number',
- label: 'InputNumber 计数器'
- }, {
- value: 'select',
- label: 'Select 选择器'
- }, {
- value: 'cascader',
- label: 'Cascader 级联选择器'
- }, {
- value: 'switch',
- label: 'Switch 开关'
- }, {
- value: 'slider',
- label: 'Slider 滑块'
- }, {
- value: 'time-picker',
- label: 'TimePicker 时间选择器'
- }, {
- value: 'date-picker',
- label: 'DatePicker 日期选择器'
- }, {
- value: 'datetime-picker',
- label: 'DateTimePicker 日期时间选择器'
- }, {
- value: 'upload',
- label: 'Upload 上传'
- }, {
- value: 'rate',
- label: 'Rate 评分'
- }, {
- value: 'form',
- label: 'Form 表单'
- }]
- }, {
- value: 'data',
- label: 'Data',
- children: [{
- value: 'table',
- label: 'Table 表格'
- }, {
- value: 'tag',
- label: 'Tag 标签'
- }, {
- value: 'progress',
- label: 'Progress 进度条'
- }, {
- value: 'tree',
- label: 'Tree 树形控件'
- }, {
- value: 'pagination',
- label: 'Pagination 分页'
- }, {
- value: 'badge',
- label: 'Badge 标记'
- }]
- }, {
- value: 'notice',
- label: 'Notice',
- children: [{
- value: 'alert',
- label: 'Alert 警告'
- }, {
- value: 'loading',
- label: 'Loading 加载'
- }, {
- value: 'message',
- label: 'Message 消息提示'
- }, {
- value: 'message-box',
- label: 'MessageBox 弹框'
- }, {
- value: 'notification',
- label: 'Notification 通知'
- }]
- }, {
- value: 'navigation',
- label: 'Navigation',
- children: [{
- value: 'menu',
- label: 'NavMenu 导航菜单'
- }, {
- value: 'tabs',
- label: 'Tabs 标签页'
- }, {
- value: 'breadcrumb',
- label: 'Breadcrumb 面包屑'
- }, {
- value: 'dropdown',
- label: 'Dropdown 下拉菜单'
- }, {
- value: 'steps',
- label: 'Steps 步骤条'
- }]
- }, {
- value: 'others',
- label: 'Others',
- children: [{
- value: 'dialog',
- label: 'Dialog 对话框'
- }, {
- value: 'tooltip',
- label: 'Tooltip 文字提示'
- }, {
- value: 'popover',
- label: 'Popover 弹出框'
- }, {
- value: 'card',
- label: 'Card 卡片'
- }, {
- value: 'carousel',
- label: 'Carousel 走马灯'
- }, {
- value: 'collapse',
- label: 'Collapse 折叠面板'
- }]
- }]
- }, {
- value: 'ziyuan',
- label: '资源',
- children: [{
- value: 'axure',
- label: 'Axure Components'
- }, {
- value: 'sketch',
- label: 'Sketch Templates'
- }, {
- value: 'jiaohu',
- label: '组件交互文档'
- }]
- }]
-
-options.list = list
-options.copyTimes = 1000
-const mock = mockUtil.buildMock(options)
-mock.push({
- path: '/select/cascadeData',
- method: 'get',
- handle (req) {
- return {
- code: 0,
- msg: 'success',
- data: dictData
- }
- }
-})
-
-export default mock
+import mockUtil from '@/business/mock/base'
+
+const options = {
+ name: 'select',
+ idGenerator: 0
+}
+const list = [
+ {
+ status: '0',
+ mselect: 'sz,bj,gz,sh,hz,wh',
+ cascader: ['zhinan', 'shejiyuanze', 'yizhi'],
+ checkbox: '0',
+ status_custom_1: '0',
+ status_custom_2: '0',
+ checkedRadio: '1',
+ switch: true,
+ mcascader: [['zhinan', 'shejiyuanze', 'yizhi']]
+ },
+ {
+ status: '1',
+ status_custom_1: '1',
+ status_custom_2: '2',
+ mselect: 'sh,sz',
+ slotExample: 'slotExample',
+ checkbox: '0'
+ },
+ {
+ date: '2016-05-03',
+ status: '2',
+ status_custom_1: '2',
+ status_custom_2: '1',
+ mselect: 'wh,gz',
+ slotExample: 'slotExample',
+ checkbox: '0'
+ }
+]
+
+const dictData = [
+ {
+ value: 'zhinan',
+ label: '指南',
+ children: [{
+ value: 'shejiyuanze',
+ label: '设计原则',
+ children: [{
+ value: 'yizhi',
+ label: '一致'
+ }, {
+ value: 'fankui',
+ label: '反馈'
+ }, {
+ value: 'xiaolv',
+ label: '效率'
+ }, {
+ value: 'kekong',
+ label: '可控'
+ }]
+ }, {
+ value: 'daohang',
+ label: '导航',
+ children: [{
+ value: 'cexiangdaohang',
+ label: '侧向导航'
+ }, {
+ value: 'dingbudaohang',
+ label: '顶部导航'
+ }]
+ }]
+ }, {
+ value: 'zujian',
+ label: '组件',
+ children: [{
+ value: 'basic',
+ label: 'Basic',
+ children: [{
+ value: 'layout',
+ label: 'Layout 布局'
+ }, {
+ value: 'color',
+ label: 'Color 色彩'
+ }, {
+ value: 'typography',
+ label: 'Typography 字体'
+ }, {
+ value: 'icon',
+ label: 'Icon 图标'
+ }, {
+ value: 'button',
+ label: 'Button 按钮'
+ }]
+ }, {
+ value: 'form',
+ label: 'Form',
+ children: [{
+ value: 'radio',
+ label: 'Radio 单选框'
+ }, {
+ value: 'checkbox',
+ label: 'Checkbox 多选框'
+ }, {
+ value: 'input',
+ label: 'Input 输入框'
+ }, {
+ value: 'input-number',
+ label: 'InputNumber 计数器'
+ }, {
+ value: 'select',
+ label: 'Select 选择器'
+ }, {
+ value: 'cascader',
+ label: 'Cascader 级联选择器'
+ }, {
+ value: 'switch',
+ label: 'Switch 开关'
+ }, {
+ value: 'slider',
+ label: 'Slider 滑块'
+ }, {
+ value: 'time-picker',
+ label: 'TimePicker 时间选择器'
+ }, {
+ value: 'date-picker',
+ label: 'DatePicker 日期选择器'
+ }, {
+ value: 'datetime-picker',
+ label: 'DateTimePicker 日期时间选择器'
+ }, {
+ value: 'upload',
+ label: 'Upload 上传'
+ }, {
+ value: 'rate',
+ label: 'Rate 评分'
+ }, {
+ value: 'form',
+ label: 'Form 表单'
+ }]
+ }, {
+ value: 'data',
+ label: 'Data',
+ children: [{
+ value: 'table',
+ label: 'Table 表格'
+ }, {
+ value: 'tag',
+ label: 'Tag 标签'
+ }, {
+ value: 'progress',
+ label: 'Progress 进度条'
+ }, {
+ value: 'tree',
+ label: 'Tree 树形控件'
+ }, {
+ value: 'pagination',
+ label: 'Pagination 分页'
+ }, {
+ value: 'badge',
+ label: 'Badge 标记'
+ }]
+ }, {
+ value: 'notice',
+ label: 'Notice',
+ children: [{
+ value: 'alert',
+ label: 'Alert 警告'
+ }, {
+ value: 'loading',
+ label: 'Loading 加载'
+ }, {
+ value: 'message',
+ label: 'Message 消息提示'
+ }, {
+ value: 'message-box',
+ label: 'MessageBox 弹框'
+ }, {
+ value: 'notification',
+ label: 'Notification 通知'
+ }]
+ }, {
+ value: 'navigation',
+ label: 'Navigation',
+ children: [{
+ value: 'menu',
+ label: 'NavMenu 导航菜单'
+ }, {
+ value: 'tabs',
+ label: 'Tabs 标签页'
+ }, {
+ value: 'breadcrumb',
+ label: 'Breadcrumb 面包屑'
+ }, {
+ value: 'dropdown',
+ label: 'Dropdown 下拉菜单'
+ }, {
+ value: 'steps',
+ label: 'Steps 步骤条'
+ }]
+ }, {
+ value: 'others',
+ label: 'Others',
+ children: [{
+ value: 'dialog',
+ label: 'Dialog 对话框'
+ }, {
+ value: 'tooltip',
+ label: 'Tooltip 文字提示'
+ }, {
+ value: 'popover',
+ label: 'Popover 弹出框'
+ }, {
+ value: 'card',
+ label: 'Card 卡片'
+ }, {
+ value: 'carousel',
+ label: 'Carousel 走马灯'
+ }, {
+ value: 'collapse',
+ label: 'Collapse 折叠面板'
+ }]
+ }]
+ }, {
+ value: 'ziyuan',
+ label: '资源',
+ children: [{
+ value: 'axure',
+ label: 'Axure Components'
+ }, {
+ value: 'sketch',
+ label: 'Sketch Templates'
+ }, {
+ value: 'jiaohu',
+ label: '组件交互文档'
+ }]
+ }]
+
+options.list = list
+options.copyTimes = 1000
+const mock = mockUtil.buildMock(options)
+mock.push({
+ path: '/select/cascadeData',
+ method: 'get',
+ handle (req) {
+ return {
+ code: 0,
+ msg: 'success',
+ data: dictData
+ }
+ }
+})
+
+export default mock
diff --git a/packages/d2-crud-plus/src/lib/components/form/DictSwitch.vue b/packages/d2-crud-plus/src/lib/components/form/DictSwitch.vue
index 9917cb1c2..87744f965 100644
--- a/packages/d2-crud-plus/src/lib/components/form/DictSwitch.vue
+++ b/packages/d2-crud-plus/src/lib/components/form/DictSwitch.vue
@@ -1,85 +1,93 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/packages/d2-crud-plus/src/lib/mixins/input-dict.js b/packages/d2-crud-plus/src/lib/mixins/input-dict.js
index b5a2ab27f..30791419f 100644
--- a/packages/d2-crud-plus/src/lib/mixins/input-dict.js
+++ b/packages/d2-crud-plus/src/lib/mixins/input-dict.js
@@ -93,10 +93,14 @@ export default {
if (this.onReady != null) {
this.onReady({ component: this, data: data, setDictData: this.setDictData, form: options.form })
}
+ this.onDictLoaded()
})
},
setDictData (data) {
this.$set(this, 'dictOptions', data)
+ },
+ onDictLoaded () {
+
}
}
}