kllay 1 өдөр өмнө
parent
commit
382f3c31de

+ 42 - 0
src/views/system/borrow/approval/RefuseNotification/index.vue

@@ -0,0 +1,42 @@
+<template>
+    <ElDialog
+      v-model="showRejectDialog"
+      title="拒绝原因"
+      width="400px"
+      @close="showRejectDialog = false"
+    >
+      <ElInput
+        type="textarea"
+        rows="3"
+        placeholder="请输入拒绝原因"
+        v-model="rejectReason"
+      />
+      <template #footer>
+        <ElButton @click="showRejectDialog = false">取消</ElButton>
+        <ElButton type="danger" @click="handleReject">确认拒绝</ElButton>
+      </template>
+    </ElDialog>
+  </template>
+  
+  <script lang="ts" setup name="RefuseNotification">
+  import { inject } from 'vue';
+  import { ElMessage } from 'element-plus';
+  import * as api from '../api';
+  
+  const showRejectDialog = inject('showRejectDialog') as Ref<boolean>;
+  const rejectReason = inject('rejectReason') as Ref<string>;
+  const currentFormId = inject('currentFormId') as Ref<number | null>;
+  const crudExpose = inject('crudExpose') as any;
+  const handleReject = async () => {
+    if (!rejectReason.value.trim()) {
+      ElMessage.warning("请填写拒绝原因");
+      return;
+    }
+    await api.BorrowingReview(currentFormId.value, "reject", rejectReason.value);
+    ElMessage.success("已拒绝申请");
+    showRejectDialog.value = false;
+    crudExpose?.doRefresh();
+  };
+  </script>
+  
+  

+ 135 - 62
src/views/system/borrow/approval/curd.tsx

@@ -1,12 +1,28 @@
-import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery } from '@fast-crud/fast-crud';
+import { 
+	AddReq, 
+	CreateCrudOptionsProps, 
+	CreateCrudOptionsRet, 
+	DelReq,
+	dict, 
+	EditReq,
+	FormWrapperContext,
+	ScopeContext,
+	UserPageQuery,
+	UserPageRes,
+	utils
+ } from '@fast-crud/fast-crud';
 import * as api from './api';
 import { BorrowingReview, Switchspost } from './api';
-import { ElMessage } from 'element-plus';
-import { Ref } from 'vue';
+import { ElMessage , ElInput, ElDialog, ElButton } from 'element-plus';
+import dayjs from 'dayjs';
+import { h, ref, computed } from "vue";
 
+export const createCrudOptions = function ({ crudExpose ,context, showRejectDialog, rejectReason, currentFormId }: CreateCrudOptionsProps& {
+	showRejectDialog: Ref<boolean>,
+	rejectReason: Ref<string>,
+	currentFormId: Ref<number | null>
+  }): CreateCrudOptionsRet {
 
-
-export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: CreateCrudOptionsProps& { approvalDialogRef: Ref<any> }): CreateCrudOptionsRet {
 	const pageRequest = async (query: UserPageQuery) => {
 		try {
 			const res = await api.GetList(query);
@@ -47,6 +63,35 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 				editRequest,
 				delRequest,
 			},
+			form: {
+				labelWidth: computed(() => {
+					return context.labelWidthRef?.value ? context.labelWidthRef.value + "px" : "100px";
+				}),
+				wrapper: {
+					buttons: {
+					ok: {
+						text: "通过", 
+						click: async (ctx: FormWrapperContext) => {
+						await api.BorrowingReview(ctx.form.id, "approve", "同意借用");
+						ElMessage.success("审批通过");
+						ctx.close();
+						crudExpose.doRefresh();
+						}
+					},
+					reject: {
+						text: "拒绝",
+						type: "danger",
+						click: async (context: FormWrapperContext) => {
+							currentFormId.value = context.form.id;
+							showRejectDialog.value = true;
+							context.close();
+							crudExpose.doRefresh();
+						} 
+					},			  
+				
+				}
+			}
+			},
 			search:{
 				show:true,
 				label:"搜索",
@@ -57,35 +102,48 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 				},
 			},
 			toolbar:{show: false},
-			actionbar:{show:false},
+			actionbar:{show:false},		  
 			rowHandle:{
 				fixed:'right',
 				width: 100,
 				show: true,
 				buttons: {
-					view: { show: false },
+					view: { 
+						show: true,
+					},
 					edit: { show: false },
 					remove: { show: false },
-				custom: {
-					text: "审批",
-					order: 5,
-					size: "small",
-					show: true,
-					click({row}) {
-							// eslint-disable-next-line no-console
-						// console.log("click", context);
-						// alert(context);
-						try{
-							approvalDialogRef.value.openApprovalDialog(row);
-							// BorrowingReview(context.row.id,'approve','同意借用');
-							// ElMessage.success('审批通过');
-						}catch(err){
-							// eslint-disable-next-line no-console
-							console.log("error:::::", err);
-							ElMessage.error("系统错误!");
-						}
-					}
-				}
+				// custom: {
+				// 	text: "审批",
+				// 	order: 5,
+				// 	size: "small",
+				// 	show: true,
+				// 	click({row}) {
+				// 			// eslint-disable-next-line no-console
+				// 		// console.log("click", context);
+				// 		// alert(context);
+				// 		try{
+				// 			// approvalDialogRef.value.openApprovalDialog(row);
+				// 			// BorrowingReview(context.row.id,'approve','同意借用');
+				// 			// ElMessage.success('审批通过');
+				// 		}catch(err){
+				// 			// eslint-disable-next-line no-console
+				// 			console.log("error:::::", err);
+				// 			ElMessage.error("系统错误!");
+				// 		}
+				// 	}
+				// }
+
+				// customView: {
+				// 	text: '审批',
+				// 	type: 'primary',
+				// 	size: 'small',
+				// 	order: 1,
+				// 	show: true,
+				// }
+
+
+
 				}
 
 			},
@@ -105,24 +163,24 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 					},
 				},
 				application_no: {
-					title: '借用编号',
+					title: '借用编号',
 					search: { show: false },
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入借用编号' },
 						rules: [{ required: false, message: '请输入借用编号' }],
 					},
 				},
-				
+				borrower_type_label: { title: '借用人角色', column: { minWidth: 100 } },
 				borrow_type_label: {
 					title: '借用性质',
 					search: { show: false },
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入借用性质' },
 						rules: [{ required: false, message: '请输入借用性质' }],
 					},
@@ -133,7 +191,7 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入学号/工号' },
 						rules: [{ required: false, message: '请输入学号/工号' }],
 					},
@@ -144,7 +202,7 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入借用人' },
 						rules: [{ required: false, message: '请输入借用人' }],
 					},
@@ -157,7 +215,7 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 						minWidth: 120
 					},
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入联系方式' },
 						rules: [{ required: false, message: '请输入联系方式' }],
 					}
@@ -169,66 +227,81 @@ export const createCrudOptions = function ({ crudExpose ,approvalDialogRef}: Cre
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入个人/团队' },
 						rules: [{ required: false, message: '请输入个人/团队' }],
 					},
 				},
-				expected_start_time: {
+				team_members: { title: '团队成员', column: { show:false,minWidth: 120 } },
+				team_members_count: { title: '团队人数', column: { show:false,minWidth: 80 }},
+				create_datetime: {
 					title: '创建时间',
 					search: { show: false },
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入创建时间' },
 						rules: [{ required: false, message: '请输入创建时间' }],
 					},
 				},
+				status_label: { title: '当前状态', column: { minWidth: 80 } },
+				actual_start_time: {
+					title: '借出时间',
+					column: { minWidth: 140, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
+				},
 				expected_end_time: {
-					title: '预计归还时间',
+					title: '预计归还',
 					search: { show: false },
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入预计归还时间' },
 						rules: [{ required: false, message: '请输入预计归还时间' }],
 					},
 				},
-				status_label: {
-					title: '当前状态',
-					search: { show: false },
-					type: 'input',
-					column: { minWidth: 120 },
-					form: {
-						show: false,
-						component: { placeholder: '请输入当前状态' },
-						rules: [{ required: false, message: '请输入当前状态' }],
-					},
+				actual_end_time: {
+					title: '完结时间',
+					column: { minWidth: 140, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
+				},
+				return_location: { title: '存放仓库', column: { minWidth: 120 } },
+				purpose: { title: '借用目的', column: { minWidth: 150 ,show:false} },
+				expected_start_time: {
+					title: '预计开始',
+					
+					column: { minWidth: 140,show:true, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
+				},
+			
+				
+				approve_time: {
+					title: '审批时间',
+					column: { show:false,minWidth: 140, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm') : '') },
+				},
+				approve_remark: { title: '审批备注', column: {show:false, minWidth: 120 } },
+				total_items: { title: '设备数量', column: { show:false,minWidth: 80 } },
+				
+				
+				applicant_remark: { title: '申请备注', column: { show:false, minWidth: 120 } },
+				
+				update_datetime: {
+					title: '更新时间',
+					column: { show:false,minWidth: 160, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
 				},
-				status: {
+				
+
+				approver_name: {
 					title: '当前审批人',
 					search: { show: false },
 					type: 'input',
 					column: { minWidth: 120 },
 					form: {
-						show: false,
+						show: true,
 						component: { placeholder: '请输入当前审批人' },
 						rules: [{ required: false, message: '请输入当前审批人' }],
 					},
 				},
-				return_location: {
-					title: '存放仓库',
-					search: { show: false },
-					type: 'input',
-					column: { minWidth: 120 },
-					form: {
-						show: false,
-						component: { placeholder: '请输入存放仓库' },
-						rules: [{ required: false, message: '请输入存放仓库' }],
-					},
-				},
+				
 		
 		
 		

+ 33 - 8
src/views/system/borrow/approval/index.vue

@@ -1,22 +1,47 @@
 <template>
 	<fs-page>
-		<fs-crud ref="crudRef" v-bind="crudBinding" />
-		<BorrowApprovalDialog ref="approvalDialogRef" @approved="crudExpose.doRefresh()" />
+
+		<fs-crud ref="crudRef" v-bind="crudBinding">
+			</fs-crud>
+			<RefuseNotification/>
+
+		<!-- <BorrowApprovalDialog ref="approvalDialogRef" @approved="crudExpose.doRefresh()" /> -->
 	</fs-page>
 </template>
 
 <script lang="ts" setup name="approval">
-import { onMounted,ref } from 'vue';
+import { onMounted,ref ,provide} from 'vue';
 import { useFs } from '@fast-crud/fast-crud';
 import { createCrudOptions } from './curd';
-import BorrowApprovalDialog from './BorrowApprovalDialog/index.vue';
+import { ElMessage } from 'element-plus';
+import { BorrowingReview } from './api';
+// import BorrowApprovalDialog from './BorrowApprovalDialog/index.vue';
+import RefuseNotification from './RefuseNotification/index.vue';
+
+
+// const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ createCrudOptions });
+const showRejectDialog = ref(false);
+const rejectReason = ref('');
+const currentFormId = ref(null);
+
+const { crudBinding, crudRef, crudExpose } = useFs({
+  createCrudOptions: (props) =>
+    createCrudOptions({
+      ...props,
+      showRejectDialog,
+      rejectReason,
+      currentFormId
+    })
+});
 
-const approvalDialogRef = ref();
 
 
-const { crudExpose, crudBinding } = useFs({
-  createCrudOptions: (props) => createCrudOptions({ ...props, approvalDialogRef })
-});
+
+provide('showRejectDialog', showRejectDialog);
+provide('rejectReason', rejectReason);
+provide('currentFormId', currentFormId);
+provide('crudExpose', crudExpose);
+
 
 
 

+ 8 - 4
src/views/system/device/crud.tsx

@@ -410,11 +410,15 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					form: {
 						component: { placeholder: '请输入库存数量' },
 						rules: [{ required: true, message: '请输入库存数量' }],
+						valueResolve({ form, value }) {
+							form.quantity = Number(value ?? 0);
+						},		  
 						valueBuilder({ form, value }) {
 							// form.tags =Array.from(String(value), Number);
 							form.quantity = form.total_quantity;
 
-						},
+						}
+						
 					}
 				},
 				tags:{
@@ -434,9 +438,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 					form: {
 						component: { placeholder: '请选择设备标签' },
 						rules: [{ required: true, message: '请选择设备标签' }],
-						// valueResolve({ form, value }) {
-						// 	form.tags = Array.from(String(value), Number);
-						// },
+						valueResolve({ form, value }) {
+							form.tags = Array.from(String(value), Number);
+						},
 						valueBuilder({ form, value }) {
 							if(value){
 								form.tags = Array.isArray(value)? value.length > 0 ? Number(value[0]) : '': Number(value);