123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery } from '@fast-crud/fast-crud';
- import * as api from './api';
- import { auth } from '/@/utils/authFunction';
- import { commonCrudConfig } from '/@/utils/commonCrud';
- 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,
- },
- toolbar:{
- show:false,
- },
- actionbar: {
- buttons: {
- add: {
- show: auth('user:Create')
- }
- }
- },
- rowHandle: {
- fixed:'right',
- width: 100,
- buttons: {
- view: {
- type: 'text',
- },
- edit: {
- show: false,
- },
- remove: {
- show: false,
- },
- },
- },
- columns: {
- _index: {
- title: '序号',
- form: { show: false },
- column: {
- align: 'center',
- width: '70px',
- columnSetDisabled: true,
- formatter: (context) => {
- let index = context.index ?? 1;
- let pagination = crudExpose!.crudBinding.value.pagination;
- return ((pagination!.currentPage ?? 1) - 1) * pagination!.pageSize + index + 1;
- },
- },
- },
- code: {
- title: '供应商编号',
- search: { show: true },
- type: 'text',
- column: { minWidth: 120},
- form: {
- show: false,
-
- }
- },
- name: {
- title: '供应商名称',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- component: { placeholder: '请输入供应商名称' },
- rules: [{ required: true, message: '请输入供应商名称' }]
- }
- },
- contact_person: {
- title: '联系人',
- search: { show: true },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请选择联系人' },
- rules: [{ required: true, message: '请选择联系人' }],
- },
- },
- contact_phone: {
- title: '联系手机号',
- search: { show: true },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请选择联系手机号' },
- rules: [{ required: true, message: '请选择联系手机号' }],
- },
- },
- contact_email: {
- title: '联系邮箱',
- search: { show: true },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入联系邮箱' },
- rules: [{ required: true, message: '请输入联系邮箱' }],
- },
- },
- address: {
- title: '地址',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入地址' },
- rules: [{ required: false, message: '请输入地址' }],
- },
- },
- website: {
- title: '网址',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入网址' },
- rules: [{ required: false, message: '请输入网址' }],
- },
- },
- business_license: {
- title: '营业执照',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入营业执照' },
- rules: [{ required: false, message: '请输入营业执照' }],
- },
- },
- tax_number: {
- title: '税号',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入税号' },
- rules: [{ required: false, message: '请输入税号' }],
- },
- },
- bank_account: {
- title: '银行卡号',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入银行卡号' },
- rules: [{ required: false, message: '请输入银行卡号' }],
- },
- },
- credit_rating: {
- title: '信用评级',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入信用评级' },
- rules: [{ required: false, message: '请输入信用评级' }],
- },
- },
- cooperation_years: {
- title: '合作年份',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入合作年份' },
- rules: [{ required: false, message: '请输入合作年份' }],
- },
- },
- remark: {
- title: '备注',
- search: { show: false },
- type: 'input',
- column: { minWidth: 100 },
- form: {
- component: { placeholder: '请输入备注' },
- rules: [{ required: false, message: '请输入备注' }],
- },
- },
- tenant_id:{
- title: '租户id',
- type: 'dict-select',
- tenant_id:1,
- column: {
- show:false,
- minWidth: 120,
- },
- dict: dict({
- url: '/api/system/tenant/list/',
- value: 'id',
- label: 'name',
- }),
- form: {
- show:false,
- value: 1,
- component: { placeholder: '请填租户id' },
- rules: [{ required: false, message: '请填租户id' }],
- },
- },
- status: {
- title: '状态',
- type: 'dict-select',
- status:true,
- search: { show: false },
- dict: dict({
- data: [
- { label: '启用', value: true },
- { label: '禁用', value: false },
- ],
- }),
- column: { minWidth: 100 },
- form: {
- show:true,
- value:true,
- component: { placeholder: '请选择状态' },
- rules: [{ required: true, message: '请选择状态' }],
- },
- },
- ...commonCrudConfig({
- create_datetime: { search: false },
- update_datetime: { search: false },
- }),
- },
- },
- };
- };
|