|
@@ -0,0 +1,229 @@
|
|
|
+import { AddReq, CreateCrudOptionsProps,dict, CreateCrudOptionsRet, UserPageQuery } from '@fast-crud/fast-crud';
|
|
|
+import * as api from './api';
|
|
|
+import { auth } from '/@/utils/authFunction';
|
|
|
+import { ja } from 'element-plus/es/locale';
|
|
|
+
|
|
|
+
|
|
|
+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,
|
|
|
+
|
|
|
+ },
|
|
|
+ form:{
|
|
|
+ wrapper: {
|
|
|
+ buttons: {
|
|
|
+ ok:{
|
|
|
+ text:'提交'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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, //禁止在列设置中选择
|
|
|
+ },
|
|
|
+ },
|
|
|
+ damage_no: {
|
|
|
+ title: '编号',
|
|
|
+ search: {
|
|
|
+ show: true,
|
|
|
+ },
|
|
|
+ treeNode: true,
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ // rules: [
|
|
|
+ // // 表单校验规则
|
|
|
+ // // { required: true, message: '名称必填项' },
|
|
|
+ // ],
|
|
|
+ component: {
|
|
|
+ placeholder: '请输入编号',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ device:{
|
|
|
+ title: '设备id',
|
|
|
+ type: 'dict-select',
|
|
|
+ column: {
|
|
|
+ show:false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ dict: dict({
|
|
|
+ url: '/api/system/device/',
|
|
|
+ value: 'id',
|
|
|
+ label: 'name',
|
|
|
+ }),
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写设备id' },
|
|
|
+ rules: [{ required: true, message: '请填写设备id' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ device_code:{
|
|
|
+ title: '设备编码',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show:false,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写设备编码' },
|
|
|
+ rules: [{ required: true, message: '请填写设备编码' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ device_name:{
|
|
|
+ title: '设备名称',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show:true,
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写设备名称' },
|
|
|
+ rules: [{ required: true, message: '请填写设备名称' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ quantity:{
|
|
|
+ title: '库存数量',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写库存数量' },
|
|
|
+ rules: [{ required: false, message: '请填写库存数量' }],
|
|
|
+ },
|
|
|
+ valueResolve({ form, value }) {
|
|
|
+ form.quantity = Number(value);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ damage_type:{
|
|
|
+ title: '维修类型',
|
|
|
+ type: 'dict-select',
|
|
|
+ dict: dict({
|
|
|
+ data: [
|
|
|
+ { label: '报废', value: 0 },
|
|
|
+ { label: '维修', value: 1 },
|
|
|
+ ],
|
|
|
+ }),
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ value:1,
|
|
|
+ show:true,
|
|
|
+ component: { placeholder: '请填写排序' },
|
|
|
+ rules: [{ required: false, message: '请填写排序' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ damage_reason:{
|
|
|
+ title: '报损原因',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写报损原因' },
|
|
|
+ rules: [{ required: false, message: '请填写报损原因' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ estimated_loss:{
|
|
|
+ title: '预估维修费用',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写预估维修费用' },
|
|
|
+ rules: [{ required: false, message: '请填写预估维修费用' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ responsible_person:{
|
|
|
+ title: '负责人',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ component: { placeholder: '请填写负责人' },
|
|
|
+ rules: [{ required: false, message: '请填写负责人' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ status_display:{
|
|
|
+ title: '状态',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ minWidth: 120,
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写负责人' },
|
|
|
+ rules: [{ required: false, message: '请填写负责人' }],
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+};
|