|
@@ -0,0 +1,162 @@
|
|
|
+import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery ,EditReq,DelReq} 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;
|
|
|
+ return await api.UpdateObj(form);
|
|
|
+ };
|
|
|
+ const delRequest = async ({ row }: DelReq) => {
|
|
|
+ return await api.DelObj(row.id);
|
|
|
+ };
|
|
|
+ const addRequest = async ({ form }: AddReq) => {
|
|
|
+ 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: {
|
|
|
+ type: 'index',
|
|
|
+ align: 'center',
|
|
|
+ width: '70px',
|
|
|
+ columnSetDisabled: true, //禁止在列设置中选择
|
|
|
+ },
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ title: '公告标题',
|
|
|
+ search: {
|
|
|
+ show: true,
|
|
|
+ },
|
|
|
+ treeNode: true,
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ rules: [
|
|
|
+ // 表单校验规则
|
|
|
+ { required: true, message: '公告标题必填项' },
|
|
|
+ ],
|
|
|
+ component: {
|
|
|
+ placeholder: '请输入公告标题',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ content:{
|
|
|
+ title: '公告内容',
|
|
|
+ type: 'textarea',
|
|
|
+ column: {
|
|
|
+ show:true,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ col: {
|
|
|
+ span: 24
|
|
|
+ },
|
|
|
+ component: { showWordLimit: true, maxlength: 200 ,placeholder: '请填写公告内容' },
|
|
|
+ rules: [{
|
|
|
+ required: true,
|
|
|
+ message: '内容为必填项',
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ publisher_name:{
|
|
|
+ title: '发布人',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填发布人' },
|
|
|
+ rules: [{ required: false, message: '请填写发布人' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ publish_time:{
|
|
|
+ title: '发布时间',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写发布时间' },
|
|
|
+ rules: [{ required: false, message: '请填写发布时间' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ is_top:{
|
|
|
+ title: '是否在顶部',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show:false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ value:true,
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写是否在顶部' },
|
|
|
+ rules: [{ required: false, message: '请填写是否在顶部' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ status:{
|
|
|
+ title: '状态',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show:false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ value:1,
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写状态' },
|
|
|
+ rules: [{ required: false, message: '请填写状态' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+};
|