123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery,EditReq ,DelReq,dict} from '@fast-crud/fast-crud';
- import * as api from './api';
- import { auth } from '/@/utils/authFunction';
- export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
- const pageRequest = async (query: UserPageQuery) => {
- return await api.GetList(query);
- };
- const editRequest = async ({ form, row }: EditReq) => {
- form.id = row.id;
- form.device_id=Number(form.device);
- form.title=form.article_title;
- form.content=form.article_content;
- return await api.UpdateObj(form);
- };
- const delRequest = async ({ row }: DelReq) => {
- return await api.DelObj(row.id);
- };
- const addRequest = async ({ form }: AddReq) => {
- form.device_id=Number(form.device);
- form.title=form.article_title;
- form.content=form.article_content;
- // console.log("sdfsdfsdfform::::",form);
-
- return await api.AddObj(form);
- };
- return {
- crudOptions: {
- request: {
- pageRequest,
- addRequest,
- editRequest,
- delRequest,
- },
- actionbar: {
- buttons: {
- add: {
- show: auth('area:Create'),
- },
- },
- },
- toolbar:{
- show:false,
- },
- rowHandle:{
- buttons:{
- remove:{
- show:true,
- },
- edit:{
- show:true,
- }
- }
- },
- pagination: {
- show: false,
- },
- columns: {
- _index: {
- title: '序号',
- form: { show: false },
- column: {
- show:false,
- type: 'index',
- align: 'center',
- width: '70px',
- columnSetDisabled: true, //禁止在列设置中选择
- },
- },
- device:{
- title: '设备id',
- search: {
- show: false,
- },
- treeNode: true,
- type: 'dict-select',
- column: {
- show:false,
- minWidth: 120,
- },
- dict: dict({
- url: '/api/system/device/',
- value: 'id',
- label: 'name',
- }),
- form: {
- show:true,
- component: { placeholder: '请选择设备id' },
- rules: [{ required: true, message: '请选择设备id' }],
- },
- },
- device_code: {
- title: '设备编码',
- search: {
- show: false,
- },
- treeNode: true,
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- show:false,
- },
- },
- article_title: {
- title: '设备标题',
- search: {
- show: false,
- },
- treeNode: true,
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- show:true,
- rules: [
- // 表单校验规则
- { required: true, message: '标题必填项' },
- ],
- component: {
- placeholder: '请输入标题',
- },
- },
- },
- article_content:{
- title: '内容',
- type: 'textarea',
- column: {
- show:true,
- minWidth: 120,
- },
- form: {
- show:true,
- col: {
- span: 24
- },
- component: { showWordLimit: true, maxlength: 200 ,placeholder: '请填写内容' },
- rules: [{
- required: true,
- message: '内容为必填项',
- }],
- },
- },
- device_name:{
- title: '发布人',
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- show:false,
- component: { placeholder: '请填发布人' },
- rules: [{ required: false, message: '请填写发布人' }],
- },
- },
- create_datetime:{
- title: '发布时间',
- type: 'input',
- column: {
- minWidth: 120,
- },
- form: {
- show:false,
- component: { placeholder: '请填写发布时间' },
- rules: [{ required: false, message: '请填写发布时间' }],
- },
- },
- is_default:{
- title: '状态',
- type: 'input',
- column: {
- show:false,
- minWidth: 120,
- },
- form: {
- value:true,
- show:false,
- component: { placeholder: '请填写状态' },
- rules: [{ required: false, message: '请填写状态' }],
- },
- },
- // device_id:{
- // title: '设备id',
- // type: 'input',
- // column: {
- // show:false,
- // minWidth: 120,
- // },
- // form: {
- // show:true,
- // component: { placeholder: '请填写状态' },
- // rules: [{ required: false, message: '请填写状态' }],
- // },
- // },
- // title:{
- // title: '设备标题',
- // type: 'input',
- // column: {
- // show:false,
- // minWidth: 120,
- // },
- // form: {
- // show:true,
- // component: { placeholder: '请填写设备标题' },
- // rules: [{ required: false, message: '请填写设备标题' }],
- // },
- // },
- // content:{
- // title: '设备内容',
- // type: 'input',
- // column: {
- // show:false,
- // minWidth: 120,
- // },
- // form: {
- // show:true,
- // component: { placeholder: '请填写设备内容' },
- // rules: [{ required: false, message: '请填写设备内容' }],
- // },
- // },
- },
- },
- };
- };
|