|
@@ -1,10 +1,15 @@
|
|
-import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, uiContext, UserPageQuery } from '@fast-crud/fast-crud';
|
|
|
|
|
|
+import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, uiContext, UserPageQuery } from '@fast-crud/fast-crud';
|
|
import dayjs from 'dayjs';
|
|
import dayjs from 'dayjs';
|
|
import * as api from './api';
|
|
import * as api from './api';
|
|
import { uploadFile } from './api';
|
|
import { uploadFile } from './api';
|
|
import { auth } from '/@/utils/authFunction';
|
|
import { auth } from '/@/utils/authFunction';
|
|
import { commonCrudConfig } from '/@/utils/commonCrud';
|
|
import { commonCrudConfig } from '/@/utils/commonCrud';
|
|
-
|
|
|
|
|
|
+import {request} from '/@/utils/service';
|
|
|
|
+import {getBaseURL} from '/@/utils/baseUrl';
|
|
|
|
+import Cookies from 'js-cookie';
|
|
|
|
+import { successMessage } from '/@/utils/message';
|
|
|
|
+import { dictionary } from '/@/utils/dictionary';
|
|
|
|
+import { APIResponseData } from '../columns/types';
|
|
|
|
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
const pageRequest = async (query: UserPageQuery) => {
|
|
const pageRequest = async (query: UserPageQuery) => {
|
|
@@ -36,6 +41,25 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
toolbar:{
|
|
toolbar:{
|
|
show:false,
|
|
show:false,
|
|
},
|
|
},
|
|
|
|
+ rowHandle: {
|
|
|
|
+ fixed: 'right',
|
|
|
|
+ width: 220,
|
|
|
|
+ view: {
|
|
|
|
+ show: true,
|
|
|
|
+ click: ({ row }) => {
|
|
|
|
+ window.dispatchEvent(new CustomEvent('workflow-view', { detail: row }));
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ edit: {
|
|
|
|
+ show: true,
|
|
|
|
+ click: ({ row }) => {
|
|
|
|
+ window.dispatchEvent(new CustomEvent('workflow-edit', { detail: row }));
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ remove: {
|
|
|
|
+ show: true,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
actionbar: {
|
|
actionbar: {
|
|
buttons: {
|
|
buttons: {
|
|
add: {
|
|
add: {
|
|
@@ -134,6 +158,17 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
rules: [{ required: true, message: '请选择设备状态' }],
|
|
rules: [{ required: true, message: '请选择设备状态' }],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ borrowed_quantity:{
|
|
|
|
+ title:"已借出",
|
|
|
|
+ type:'input',
|
|
|
|
+ search:{show:false},
|
|
|
|
+ column: { minWidth: 100 },
|
|
|
|
+ form: {
|
|
|
|
+ show:false,
|
|
|
|
+ component: { placeholder: '请输入已借出' },
|
|
|
|
+ rules: [{ required: true, message: '请输入已借出' }],
|
|
|
|
+ },
|
|
|
|
+ },
|
|
brand:{
|
|
brand:{
|
|
title:'品牌',
|
|
title:'品牌',
|
|
type:"input",
|
|
type:"input",
|
|
@@ -157,7 +192,19 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
title:'库存数量',
|
|
title:'库存数量',
|
|
type:"input",
|
|
type:"input",
|
|
column: { minWidth: 100 },
|
|
column: { minWidth: 100 },
|
|
- from:{show: false}
|
|
|
|
|
|
+ addForm:{
|
|
|
|
+ show:false,
|
|
|
|
+ },
|
|
|
|
+ viewForm:{
|
|
|
|
+ show:false,
|
|
|
|
+ },
|
|
|
|
+ editForm:{show:false},
|
|
|
|
+ from:{
|
|
|
|
+ show:false,
|
|
|
|
+ component: { placeholder: '请输入已借出' },
|
|
|
|
+ rules: [{ required: true, message: '请输入已借出' }],
|
|
|
|
+
|
|
|
|
+ }
|
|
},
|
|
},
|
|
warehouse:{
|
|
warehouse:{
|
|
title:'库存仓库',
|
|
title:'库存仓库',
|
|
@@ -174,17 +221,26 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
},
|
|
},
|
|
is_visible:{
|
|
is_visible:{
|
|
title:'是否可见',
|
|
title:'是否可见',
|
|
- type:"dict-select",
|
|
|
|
- column: { minWidth: 120 },
|
|
|
|
|
|
+ type: 'dict-radio',
|
|
|
|
+ column: {
|
|
|
|
+ minWidth: 90,
|
|
|
|
+ component: {
|
|
|
|
+ name: 'fs-dict-switch',
|
|
|
|
+ activeText: '',
|
|
|
|
+ inactiveText: '',
|
|
|
|
+ style: '--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6',
|
|
|
|
+ onChange: compute((context) => {
|
|
|
|
+ return () => {
|
|
|
|
+ api.UpdateObj(context.row).then((res:APIResponseData) => {
|
|
|
|
+ successMessage(res.msg as string);
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ }),
|
|
|
|
+ },
|
|
|
|
+ },
|
|
dict: dict({
|
|
dict: dict({
|
|
- data: [
|
|
|
|
- { label: '可见', value: true },
|
|
|
|
- { label: '隐藏', value: false },
|
|
|
|
- ],
|
|
|
|
|
|
+ data: dictionary('button_status_bool'),
|
|
}),
|
|
}),
|
|
- form: {
|
|
|
|
- component: { placeholder: '请输入是否可见' }
|
|
|
|
- }
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -274,27 +330,47 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
uploader: {
|
|
uploader: {
|
|
type: 'form',
|
|
type: 'form',
|
|
limit: 1,
|
|
limit: 1,
|
|
|
|
+ action: '/api/system/device/upload-image/',
|
|
accept: ".jpg,.png",
|
|
accept: ".jpg,.png",
|
|
- // uploadRequest: uploadRequestHandler,
|
|
|
|
- // uploadRequest: async (file) => {
|
|
|
|
- // // eslint-disable-next-line no-console
|
|
|
|
- // // console.log("files::",file);
|
|
|
|
- // const previewUrl = URL.createObjectURL(file.file);
|
|
|
|
- // file.value=previewUrl;
|
|
|
|
- // const formData = new FormData();
|
|
|
|
- // formData.append('image', file.file);
|
|
|
|
- // // eslint-disable-next-line no-console
|
|
|
|
- // // console.log("files::",file);
|
|
|
|
- // const res = await uploadFile(formData);
|
|
|
|
- // // eslint-disable-next-line no-console
|
|
|
|
- // console.log("url::"+res.data.image_url);
|
|
|
|
- // file.value = res.data.image_url; // 绑定表单字段
|
|
|
|
- // // const testurl="http://58.34.94.147:8086/media/files/3/c/3c711548de2284d59922379243a60bd8.png";
|
|
|
|
- // // const apiUrl = import.meta.env.VITE_API_URL;
|
|
|
|
- // // const res = await axios.post(`${import.meta.env.VITE_API_URL}/api/system/device/upload-image/`, formData);
|
|
|
|
- // return {url: "http://58.34.94.147:8086/media/files/3/c/3c711548de2284d59922379243a60bd8.png"} // 必须返回包含url的对象
|
|
|
|
- // }
|
|
|
|
|
|
+ uploadRequest: async ({ action, file, onProgress }) => {
|
|
|
|
+ const token = Cookies.get('token');
|
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
|
+ console.log("token:::",token);
|
|
|
|
+ const data = new FormData();
|
|
|
|
+ data.append("image", file);
|
|
|
|
+ return await request({
|
|
|
|
+ url: action,
|
|
|
|
+ method: "post",
|
|
|
|
+ timeout: 60000,
|
|
|
|
+ headers: {
|
|
|
|
+ "Content-Type": "multipart/form-data",
|
|
|
|
+ "Authorization": token ? `JWT ${token}` : ''
|
|
|
|
+ },
|
|
|
|
+ data,
|
|
|
|
+ onUploadProgress: (p) => {
|
|
|
|
+ onProgress({ percent: Math.round((p.loaded / p.total) * 100) });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ successHandle(ret) {
|
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
|
+ console.log("ret.data.image_url:::",ret.data.image_url);
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ url: getBaseURL(ret.data.image_url),
|
|
|
|
+ key: ret.data.id,
|
|
|
|
+ ...ret.data
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ valueBuilder({ row, key }) {
|
|
|
|
+ return row[key] ? [row[key]] : [];
|
|
|
|
+ },
|
|
|
|
+ valueResolve({ form, key }) {
|
|
|
|
+ form[key] = Array.isArray(form[key]) ? form[key][0] : form[key];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -378,16 +454,16 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
},
|
|
},
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- maintenancename: {
|
|
|
|
- title: '维修名称',
|
|
|
|
- type: 'input',
|
|
|
|
- search: { show: false },
|
|
|
|
- column: { show:false,minWidth: 100 },
|
|
|
|
- form: {
|
|
|
|
- component: { placeholder: '请输入设备购入价格' },
|
|
|
|
- rules: [{ required: true, message: '请输入设备购入价格' }],
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ // maintenancename: {
|
|
|
|
+ // title: '维修名称',
|
|
|
|
+ // type: 'input',
|
|
|
|
+ // search: { show: false },
|
|
|
|
+ // column: { show:false,minWidth: 100 },
|
|
|
|
+ // form: {
|
|
|
|
+ // component: { placeholder: '请输入设备购入价格' },
|
|
|
|
+ // rules: [{ required: true, message: '请输入设备购入价格' }],
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
...commonCrudConfig({
|
|
...commonCrudConfig({
|
|
create_datetime: { search: false },
|
|
create_datetime: { search: false },
|
|
update_datetime: { search: false },
|
|
update_datetime: { search: false },
|
|
@@ -411,7 +487,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
}
|
|
}
|
|
},
|
|
},
|
|
icon: "el-icon-goods",
|
|
icon: "el-icon-goods",
|
|
- columns: ["code","category_name", "name", "status","brand","specification","serial_number","total_quantity","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","image","tenant_id","category","quantity","tags"]
|
|
|
|
|
|
+ columns: ["code","category_name", "name", "status","borrowed_quantity","brand","specification","serial_number","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","image","tenant_id","category","quantity","tags"]
|
|
},
|
|
},
|
|
borrow: {
|
|
borrow: {
|
|
label: "借用记录",
|
|
label: "借用记录",
|
|
@@ -422,7 +498,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
label: "维修记录",
|
|
label: "维修记录",
|
|
collapsed: true, //默认折叠
|
|
collapsed: true, //默认折叠
|
|
icon: "el-icon-warning-outline",
|
|
icon: "el-icon-warning-outline",
|
|
- columns: ["maintenancename"]
|
|
|
|
|
|
+ columns: [""]
|
|
},
|
|
},
|
|
maintain: {
|
|
maintain: {
|
|
label: "保养记录",
|
|
label: "保养记录",
|