kllay hai 5 días
pai
achega
8ca050239b

+ 1 - 1
src/views/system/borrowingnotice/crud.tsx

@@ -75,7 +75,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 				title: {
 					title: '标题',
 					search: {
-						show: false,
+						show: true,
 					},
 					treeNode: true,
 					type: 'input',

+ 15 - 0
src/views/system/device/api.ts

@@ -11,6 +11,21 @@ export function GetList(query: UserPageQuery) {
 	});
 }
 
+export function getBorrowRecords(id: number) {
+	return request({
+		url: `/api/system/device/${id}/borrow_records/`,
+		method: 'get'
+	});
+  }
+  
+  export function getMaintenanceHistory(id: number) {
+	return request({
+		url: `/api/system/device/${id}/maintenance_history/`,
+		method: 'get'
+	});
+  }
+
+  
 export function GetObj(id: InfoReq) {
 	return request({
 		url: apiPrefix + id,

+ 121 - 104
src/views/system/device/crud.tsx

@@ -1,17 +1,90 @@
-import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, uiContext, UserPageQuery } from '@fast-crud/fast-crud';
+import { AddReq, compute,useCrud , CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, uiContext, UserPageQuery, } from '@fast-crud/fast-crud';
 import dayjs from 'dayjs';
 import * as api from './api';
 import { uploadFile } from './api';
 import { auth } from '/@/utils/authFunction';
-// 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';
-import { computed, h } from 'vue';
+import { computed, h,defineComponent, ref, onMounted, watch  } from 'vue';
+import { ElTable, ElTableColumn, ElLoading } from 'element-plus';
 
+
+
+const BorrowRecords = defineComponent({
+	props: { form: Object },
+	setup(props) {
+		try {
+			const records = ref([]);
+			const loading = ref(false);
+			const loadData = async () => {
+				if (!props.form?.id) return;
+				loading.value = true;
+				try {
+					const res = await api.getBorrowRecords(props.form.id);
+					records.value = res.data || [];
+				} finally {
+					loading.value = false;
+				}
+			};
+
+			watch(() => props.form?.id, loadData, { immediate: true });
+
+			return () => (
+			<ElTable data={records.value} v-loading={loading.value} style="width: 100%">
+				<ElTableColumn prop="application_no" label="借用编号" />
+				<ElTableColumn prop="borrower_name" label="借用人" />
+				<ElTableColumn prop="record_type_label" label="状态" />
+				<ElTableColumn prop="borrower_type" label="借用类型" />
+				
+			</ElTable>
+			);
+		} catch (e) {
+			console.error("BorrowRecords setup error:", e);
+			return () => <div>组件加载失败</div>;
+		}
+	}
+  });
+  
+  const MaintenanceHistory = defineComponent({
+	props: { form: Object },
+	setup(props) {
+		try {
+		const records = ref([]);
+		const loading = ref(false);
+		const loadData = async () => {
+		if (!props.form?.id) return;
+		loading.value = true;
+		try {
+			const res = await api.getMaintenanceHistory(props.form.id);
+			records.value = res.data || [];
+		} finally {
+			loading.value = false;
+		}
+		};
+
+		watch(() => props.form?.id, loadData, { immediate: true });
+
+		return () => (
+		<ElTable data={records.value} v-loading={loading.value} style="width: 100%">
+			<ElTableColumn prop="damage_no" label="维修编号" />
+			<ElTableColumn prop="device_name" label="设备名称" />
+			<ElTableColumn prop="damage_reason" label="损坏原因" />
+			<ElTableColumn prop="estimated_loss" label="损失价格" />
+		</ElTable>
+		);
+	} catch (e) {
+		console.error("MaintenanceHistory setup error:", e);
+		return () => <div>组件加载失败</div>;
+	}
+
+	}
+  });
+
+  
 export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
 	const pageRequest = async (query: UserPageQuery) => {
 		return await api.GetList(query);
@@ -27,10 +100,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 		return await api.AddObj(form);
 	};
 
-	
-
-	const ui = uiContext.get();
-
 	return {
 		crudOptions: {
 			request: {
@@ -62,27 +131,24 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
                         show: auth('user:Create')
                     },
 					batchimport:{
-						text: "批量导入",//按钮文字
-                        title: "导入",//鼠标停留显示的信息
+						text: "批量导入",
+                        title: "导入",
                         // show: auth('user:batchimport'),
 					},
                     export: {
-                        text: "导出",//按钮文字
-                        title: "导出",//鼠标停留显示的信息
+                        text: "导出",
+                        title: "导出",
                         show: auth('user:Export'),
-
                     },
 					downloadtemplate: {
-                        text: "下载模板",//按钮文字
-                        title: "下载模板",//鼠标停留显示的信息
+                        text: "下载模板",
+                        title: "下载模板",
                         // show: auth('user:Export'),
-
                     },
 					batchdelete: {
-                        text: "批量删除",//按钮文字
-                        title: "批量删除",//鼠标停留显示的信息
+                        text: "批量删除",
+                        title: "批量删除",
                         // show: auth('user:Export'),
-
                     },
                 }
             },
@@ -590,52 +656,16 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						console.log("form[key]:::",form[key]);
 						form[key] = Array.isArray(form[key]) ? form[key][0] : form[key];
 					}
-					// form: {
-					// 	// component: { placeholder: '请上传图片' },
-					// 	component: {
-					// 		limit: 1,
-					// 		uploader: {
-					// 		type: "form"
-					// 	}
-					// 	},
-					// 	rules: createUploaderRules([{ required: true, message: "此项必传", trigger: "change" }]),
-					// 	change:()=>{
-
-					// 	},
-					// 	helper: "上传设备图片",
-					// },
-	
 					
 				},
-				// maintenancename: {
-				// 	title: '维修名称',
-				// 	type: 'input',
-				// 	search: { show: false },
-				// 	column: { show:false,minWidth: 100 },
-				// 	form: {
-				// 		component: { placeholder: '请输入设备购入价格' },
-				// 		rules: [{ required: true, message: '请输入设备购入价格' }],
-				// 	},
-				// },
-				jieyong: {
-					title: '借用',
-					search: { show: false },
-					type: 'input',
-					column: { minWidth: 120 },
-					form: {
-						component: { placeholder: '请输入借用' }
-					},
-					viewForm:{
-						component: { placeholder: '' },
-						rules: [{ required: true, message: '' }],
-					}
-				},
-				weixiu: {
-					title: '维修',
+
+				id: {
+					title: 'deviceid',
 					search: { show: false },
 					type: 'input',
-					column: { minWidth: 120 },
+					column: { show:false,minWidth: 120 },
 					form: {
+						show:true,
 						component: { placeholder: '请输入维修' }
 					},
 					viewForm:{
@@ -643,37 +673,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						rules: [{ required: true, message: '' }],
 					}
 				},
-				baoyang: {
-					title: '保养',
-					search: { show: false },
-					type: 'input',
-					column: { minWidth: 120 },
-					form: {
-						component: { placeholder: '请输入保养' }
-					},
-					viewForm:{
-						component: { placeholder: '' },
-						rules: [{ required: true, message: '' }],
-					}
-				},
-				tongji: {
-					title: '统计',
-					search: { show: false },
-					type: 'input',
-					column: { minWidth: 120 },
-					form: {
-						component: { placeholder: '请输入统计' }
-					},
-					viewForm:{
-						component: { placeholder: '' },
-						rules: [{ required: true, message: '' }],
-					}
-				},
-
-
 
 			},
-			form: {
+			viewForm: {
 				wrapper: {
 					buttons: {
 						ok:{
@@ -683,45 +685,60 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 				},
 				row: { gutter: 20 },
 				group: {
-				groupType: "tabs", //collapse, tabs
-				accordion: false,
+				groupType: "tabs", 
 				groups: {
 					base: {
 						slots: {
-						label: (scope) => {
-						return (
-							<span style={{ color: scope.hasError ? "red" : "green" }}>
-								<fs-icon icon={"ion:checkmark-circle"} />
-								基础信息
-							</span>
-						);
+							label: (scope) => {
+							return (
+								<span style={{ color: scope.hasError ? "red" : "green" }}>
+									<fs-icon icon={"ion:checkmark-circle"} />
+									基础信息
+								</span>
+							);
 						}
 					},
 						icon: "el-icon-goods",
 						columns: ["code","category_name", "name", "status","borrowed_quantity","brand","specification","serial_number","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","tenant_id","category","quantity","tags","image"]
 					},
 					borrow: {
+						show:true,
 						label: "借用记录",
 						icon: "el-icon-price-tag",
-						columns: ["jieyong",]
+						columns: ["id"],
+						slots: {
+							default: (scope) => {
+								const currentRow = crudExpose.getFormData();
+								console.log("currentRow::",currentRow);
+								return <BorrowRecords form={currentRow || {}}/>;
+							}
+						}
 					},
 					maintenance: {
+						show:true,
 						label: "维修记录",
-						collapsed: true, //默认折叠
+						// collapsed: true, 
 						icon: "el-icon-warning-outline",
-						columns: ["weixiu"]
+						columns: ["id"],
+						slots: {
+							default: (scope) => {
+								const currentRowwx = crudExpose.getFormData();
+								console.log("currentRowwx::",currentRowwx);
+								return <MaintenanceHistory form={currentRowwx || {}} />
+							}
+						}
 					},
 					maintain: {
 						label: "保养记录",
-						collapsed: true, //默认折叠
+						collapsed: true, 
 						icon: "el-icon-warning-outline",
-						columns: ["baoyang"]
+						columns: []
 					},
 					datastatis: {
 						label: "数据统计",
-						collapsed: true, //默认折叠
+						collapsed: true,
 						icon: "el-icon-warning-outline",
-						columns: ["tongji"]
+						columns: []
 					},
 
 

+ 11 - 2
src/views/system/devicemaintenance/crud.tsx

@@ -114,6 +114,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						component: { placeholder: '请填写设备id' },
 						rules: [{ required: true, message: '请填写设备id' }],
 					},
+					editForm:{
+						component: { disabled: true },
+					},
 					viewForm:{
 						component: { placeholder: '' },
 						rules: [{ required: true, message: '' }],
@@ -160,9 +163,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						minWidth: 120,
 					},
 					form: {
-						component: { placeholder: '请填写库存数量' },
+						component: { placeholder: '请填写库存数量'},
 						rules: [{ required: false, message: '请填写库存数量' }],
 					},
+					editForm:{
+						component: { disabled: true },
+					},
 					valueResolve({ form, value }) {
 						form.quantity = Number(value);
 					},
@@ -186,9 +192,12 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					form: {
 						value:1,
 						show:true,
-						component: { placeholder: '请填写排序' },
+						component: { placeholder: '请填写排序'},
 						rules: [{ required: false, message: '请填写排序' }],
 					},
+					editForm:{
+						component: { disabled: true },
+					},
 					viewForm:{
 						component: { placeholder: '' },
 						rules: [{ required: true, message: '' }],