kllay 5 dagar sedan
förälder
incheckning
198a700908
3 ändrade filer med 35 tillägg och 27 borttagningar
  1. 7 6
      src/settings.ts
  2. 0 17
      src/views/system/device/crud.tsx
  3. 28 4
      src/views/system/devicemanual/crud.tsx

+ 7 - 6
src/settings.ts

@@ -13,7 +13,7 @@ import {FsExtendsEditor, FsExtendsUploader } from '@fast-crud/fast-extends';
 import '@fast-crud/fast-extends/dist/style.css';
 import {successNotification} from '/@/utils/message';
 import XEUtils from "xe-utils";
-
+import Cookies from 'js-cookie';
 
 
 export default {
@@ -118,19 +118,21 @@ export default {
             defaultType: "form",
             form: {
                 action: `/api/system/file/`,
-                // action: `/api/system/device/upload-image/`,
                 name: "file",
                 withCredentials: false,
                 uploadRequest: async ({ action, file, onProgress }: { action: string; file: any; onProgress: Function }) => {
                     // @ts-ignore
                     const data = new FormData();
                     data.append("file", file);
+                    const token = Cookies.get('token');
+                    // console.log("tokens::::::::",token);
                     return await request({
                         url: action,
                         method: "post",
                         timeout: 60000,
                         headers: {
-                            "Content-Type": "multipart/form-data"
+                            "Content-Type": "multipart/form-data",
+                            Authorization: `Bearer ${token}`
                         },
                         data,
                         onUploadProgress: (p: any) => {
@@ -139,12 +141,11 @@ export default {
                     });
                 },
                 successHandle(ret: any) {
-                    // 上传完成后的结果处理, 此处应返回格式为{url:xxx,key:xxx}
                     return {
+                        ...ret.data,
                         url: getBaseURL(ret.data.url),
-                        // url: getBaseURL(ret.data.image_url),
                         key: ret.data.id,
-                        ...ret.data
+                       
                     };
                 }
             },

+ 0 - 17
src/views/system/device/crud.tsx

@@ -216,22 +216,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						rules: [{ required: true, message: '' }],
 					}
 				},
-				// statusss: {
-				// 	title: '设备状态',
-				// 	type: 'dict-select',
-				// 	search: { show: false },
-				// 	dict: dict({
-				// 		data: [
-				// 			{ label: '在借', value: 1 },
-				// 			{ label: '空闲', value: 2 },
-				// 		],
-				// 	}),
-				// 	column: { minWidth: 100 },
-				// 	form: {
-				// 		component: { placeholder: '请选择设备状态' },
-				// 		rules: [{ required: true, message: '请选择设备状态' }],
-				// 	},
-				// },
 				"inventory.borrowed_quantity":{
 						title: '设备状态',
 						type: 'text',
@@ -717,7 +701,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					maintenance: {
 						show:true,
 						label: "维修记录",
-						// collapsed: true, 
 						icon: "el-icon-warning-outline",
 						columns: ["id"],
 						slots: {

+ 28 - 4
src/views/system/devicemanual/crud.tsx

@@ -1,7 +1,8 @@
-import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery,EditReq ,DelReq,dict} from '@fast-crud/fast-crud';
+import { AddReq,useCompute, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery,EditReq ,DelReq,dict} from '@fast-crud/fast-crud';
 import * as api from './api';
 import { auth } from '/@/utils/authFunction';
 
+const { compute } = useCompute();
 
 export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
 	const pageRequest = async (query: UserPageQuery) => {
@@ -136,7 +137,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 				article_title: {
 					title: '设备标题',
 					search: {
-						show: false,
+						show: true,
 					},
 					treeNode: true,
 					type: 'input',
@@ -160,7 +161,8 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 				},
 				article_content:{
 					title: '内容',
-					type: 'textarea',
+					// type: 'textarea',
+					type: 'editor-wang5',
 					column: {
 						show:true,
 						minWidth: 120,
@@ -170,11 +172,33 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						col: {
 							span: 24
 						},
-						component: { showWordLimit: true, maxlength: 200 ,placeholder: '请填写内容' },
+						// component: { showWordLimit: true, maxlength: 200 ,placeholder: '请填写内容' },
 						rules: [{ 
 							required: true,
 								message: '内容为必填项',
 							}],
+						component: {
+							disabled: false,
+							id: '1', // 当同一个页面有多个editor时,需要配置不同的id
+							editorConfig: {
+								// 是否只读
+								readOnly: compute((context) => {
+									const { mode } = context;
+									if (mode === 'add') {
+										return false;
+									}
+									return true;
+								}),
+							},
+							uploader: {
+								type: 'form',
+								buildUrl(res: any) {
+									console.log("res::::",res)
+									return res.url;
+								},
+							},
+							},
+
 					},
 					viewForm:{
 						component: { placeholder: '' },