django-vue-admin/web/src/views/system/messageCenter/crud.js

301 lines
7.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { request } from '@/api/service'
export const crudOptions = (vm) => {
return {
indexRow: { // 或者直接传true,不显示title不居中
title: '序号',
align: 'center'
},
options: {
height: '100%' // 表格高度100%, 使用toolbar必须设置
},
viewOptions: {
},
columns: [
{
title: 'id',
key: 'id',
width: 100,
form: { disabled: true }
},
{
title: '标题',
key: 'title',
search: {
disabled: false
},
width: 400,
form: {
rules: [ // 表单校验规则
{
required: true,
message: '必填项'
}
],
component: { span: 24, placeholder: '请输入标题' }
}
},
{
title: '目标类型',
key: 'target_type',
type: 'radio',
dict: { data: [{ value: 0, label: '按用户' }, { value: 1, label: '按角色' }, { value: 2, label: '按部门' }] },
form: {
rules: [
{
required: true,
message: '必选项',
trigger: ['blur', 'change']
}
]
}
},
{
title: '目标用户',
key: 'target_user',
search: {
disabled: true
},
minWidth: 130,
type: 'table-selector',
dict: {
cache: false,
url: '/api/system/user/',
value: 'id', // 数据字典中value字段的属性名
label: 'name', // 数据字典中label字段的属性名
getData: (url, dict, {
form,
component
}) => {
return request({
url: url,
params: {
page: 1,
limit: 10
}
}).then(ret => {
component._elProps.page = ret.data.page
component._elProps.limit = ret.data.limit
component._elProps.total = ret.data.total
return ret.data.data
})
}
},
form: {
rules: [ // 表单校验规则
{
required: true,
message: '必填项'
}
],
itemProps: {
class: { yxtInput: true }
},
component: {
span: 24,
show (context) {
return context.form.target_type === 0
},
pagination: true,
props: { multiple: true },
elProps: {
columns: [
{
field: 'name',
title: '用户名称'
},
{
field: 'phone',
title: '用户电话'
}
]
}
}
},
component: {
name: 'manyToMany',
valueBinding: 'user_info',
children: 'name'
}
},
{
title: '目标角色',
key: 'target_role',
search: {
disabled: true
},
minWidth: 130,
type: 'table-selector',
dict: {
cache: false,
url: '/api/system/role/',
value: 'id', // 数据字典中value字段的属性名
label: 'name', // 数据字典中label字段的属性名
getData: (url, dict, {
form,
component
}) => {
return request({
url: url,
params: {
page: 1,
limit: 10
}
}).then(ret => {
component._elProps.page = ret.data.page
component._elProps.limit = ret.data.limit
component._elProps.total = ret.data.total
return ret.data.data
})
}
},
form: {
rules: [ // 表单校验规则
{
required: true,
message: '必填项'
}
],
itemProps: {
class: { yxtInput: true }
},
component: {
span: 24,
show (context) {
return context.form.target_type === 1
},
pagination: true,
props: { multiple: true },
elProps: {
columns: [
{
field: 'name',
title: '角色名称'
},
{
field: 'key',
title: '权限标识'
}
]
}
}
},
component: {
name: 'manyToMany',
valueBinding: 'role_info',
children: 'name'
}
},
{
title: '目标部门',
key: 'target_dept',
search: {
disabled: true
},
minWidth: 130,
type: 'table-selector',
dict: {
cache: false,
url: '/api/system/dept/',
isTree: true,
value: 'id', // 数据字典中value字段的属性名
label: 'name', // 数据字典中label字段的属性名
children: 'children', // 数据字典中children字段的属性名
getData: (url, dict, {
form,
component
}) => {
return request({
url: url,
params: {
page: 1,
limit: 999
}
}).then(ret => {
return ret.data.data
})
}
},
form: {
rules: [ // 表单校验规则
{
required: true,
message: '必填项'
}
],
itemProps: {
class: { yxtInput: true }
},
component: {
span: 24,
show (context) {
return context.form.target_type === 2
},
props: {
multiple: true,
elProps: {
treeConfig: {
transform: true,
rowField: 'id',
parentField: 'parent',
expandAll: true
},
columns: [
{
field: 'name',
title: '部门名称',
treeNode: true
},
{
field: 'status_label',
title: '状态'
},
{
field: 'parent_name',
title: '父级部门'
}
]
}
}
}
},
component: {
name: 'manyToMany',
valueBinding: 'dept_info',
children: 'name'
}
},
{
title: '内容',
key: 'content',
width: 300,
type: 'editor-quill', // 富文本图片上传依赖file-uploader请先配置好file-uploader
form: {
rules: [ // 表单校验规则
{
required: true,
message: '必填项'
}
],
component: {
disabled: () => {
return vm.getEditForm().disable
},
props: {
uploader: {
type: 'form' // 上传后端类型cos,aliyun,oss,form
}
},
events: {
'text-change': (event) => {
console.log('text-change:', event)
}
}
}
}
}
]
}
}