qaz 5 ngày trước cách đây
mục cha
commit
c68c98870a

+ 6 - 4
src/views/system/borrow/component/ClassroomBorrow/index.vue

@@ -67,7 +67,7 @@
 					</el-form-item>
 				</el-col>
 			</el-row>
-			<div style="margin: 16px 0 8px 0; font-weight: bold">借用明细表</div>
+			<div style="margin: 16px 0 8px 0; font-weight: bold">借用表</div>
 			<el-table :data="form.items" border style="width: 100%; margin-bottom: 12px">
 				<el-table-column type="index" label="序号" width="60" />
 				<el-table-column prop="remark" label="设备分类" />
@@ -119,13 +119,15 @@
 			<el-button @click="onCancel">关闭</el-button>
 			<el-button v-if="!isViewMode" type="primary" @click="onSave">提交</el-button>
 		</template>
-		<SelectDeviceDialog v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
+		<!-- <SelectDeviceDialog v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" /> -->
+		<SelectCatgory v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
 	</el-dialog>
 </template>
 
 <script setup lang="ts">
 import { ref, watch, defineProps, defineEmits, onMounted, computed,inject,Ref, } from 'vue';
 import SelectDeviceDialog from '../SpecialBorrow/SelectDeviceDialog/index.vue';
+import SelectCatgory from '../SelectCatgory/index.vue';
 import timetablemanage from '../../../timetablemanage/index.vue';
 import * as apis from '../../../timetablemanage/api';
 import * as api from '../../api';
@@ -413,9 +415,9 @@ function onDeviceSelected(devices) {
   }
 	form.value.items.push(
 		...devices.map((d) => ({
-			device_category: d.category,
+			device_category: d.id,
 			device: d.id,
-			remark: d.category_name,
+			remark: d.name,
 			quantity: 1,
 			location: d.warehouse,
 		}))

+ 1 - 1
src/views/system/borrow/component/CollectEquipment/AbnormalDialog/index.vue

@@ -28,7 +28,7 @@
           <el-button type="primary">选择图片</el-button>
           <template #tip>
             <div class="el-upload__tip">
-              只能上传jpg/png文件,且不超过500kb
+              只能上传jpg/png文件
             </div>
           </template>
         </el-upload>

+ 49 - 45
src/views/system/borrow/component/CollectEquipment/index.vue

@@ -70,7 +70,7 @@
                             </el-form-item>
                         </el-col>
                     </el-row>
-                    <div style="margin: 16px 0 8px 0; font-weight: bold"> {{ isCollect ? '借用明细表' : '归还明细表' }}</div>
+                    <div style="margin: 16px 0 8px 0; font-weight: bold"> {{ isCollect ? '借用列表' : '归还列表' }}</div>
                     <el-table :data="form.items" border style="width: 100%; margin-bottom: 12px">
                         <el-table-column type="index" label="序号" width="60" />
                         <el-table-column prop="device_category_name" label="设备分类" />
@@ -149,7 +149,7 @@
                     <el-col :span="24">
                         <div style="margin: 8px 0">
                             <el-input v-model="searchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter="handleScanSearch" />
-                            <el-button type="primary" style="margin-left: 16px" @click="handleAdd">手动添加</el-button>
+                            <el-button type="primary" style="margin-left: 16px" @click="handleAdd">手动借用</el-button>
                         </div>
                         <el-table :data="deviceList" border style="width: 100%">
                             <el-table-column type="index" label="序号" width="60" align="center" />
@@ -184,15 +184,19 @@
                 </el-row>
                 <el-row :gutter="16" style="margin-top: 16px">
                     <el-col :span="24">
-                        <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ abnormalList.length }}</span> 条</div>
+                      <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ 
+                          abnormalList?.length ? 
+                          abnormalList.reduce((sum, item) => sum + (Number(item?.condition) || 0), 0)
+                          : 0 
+                        }}</span> 次</div>
                         <el-table v-if="abnormalList.length > 0" :data="abnormalList" border style="width: 100%">
-                          <el-table-column type="index" label="序号" width="60" align="center" />
-                            <el-table-column prop="application_no" label="借用单编号" align="center" />
+                          <!-- <el-table-column type="index" label="序号" width="60" align="center" />
+                            <el-table-column prop="application_no" label="借用单编号" align="center" /> -->
                             <el-table-column prop="operator_name" label="借用人" align="center" />
                             <el-table-column prop="user_code" label="学号" align="center" />
                             <el-table-column prop="emergency_phone" label="借用人电话" align="center" />
                            <!--  <el-table-column prop="time" label="发生时间" align="center" /> -->
-                            <el-table-column prop="type" label="异常类型" align="center">
+                            <el-table-column prop="type" label="异常" align="center">
                                 <template #default="{ row }">
                                     {{ row.type }}
                                 </template>
@@ -213,7 +217,7 @@
                     <el-col :span="24">
                         <div style="margin: 8px 0">
                             <el-input :disabled="isView" v-model="returnSearchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter="handleReturnScanSearch" />
-                            <el-button type="primary" style="margin-left: 16px" @click="handleAdd" :disabled="isView">手动添加</el-button>
+                            <el-button type="primary" style="margin-left: 16px" @click="handleAdd" :disabled="isView">手动归还</el-button>
                         </div>
                         <el-table :data="returnDeviceList" border style="width: 100%" @selection-change="handleSelectionChange">
                             <el-table-column type="selection" width="55" align="center" />
@@ -229,14 +233,16 @@
                             <el-table-column prop="brand" label="品牌" align="center" />
                             <el-table-column prop="model" label="规格型号" align="center" />
                             <el-table-column prop="warehouse" label="存放仓库" align="center" />
-                            <el-table-column prop="status" label="状态" align="center">
+                            <el-table-column prop="status" label="状态" align="center" v-if="['已领取', '已归还','已借出'].includes(form.status_label)">
                                 <template #default="{ row }">
-                                    <el-tag :type="row.status === '已归还' ? 'success' : 'warning'">{{ row.status }}</el-tag>
+                                    <el-tag v-if="!isView" :type="row.status === '已归还' ? 'success' : 'warning'">{{ row.status }}</el-tag>
+                                    <el-tag v-else-if="['已领取', '已归还'].includes(form.status_label)">{{ form.status_label }}</el-tag>
+                                    <!-- <span v-else>{{ form.status_label }}</span> -->
                                 </template>
                             </el-table-column>
                             <el-table-column label="操作" width="150" align="center">
                                 <template #default="{ $index }">
-                                  <el-button :disabled="isView" type="text" style="color: red"  v-if="!returnDeviceList[$index]?.condition || !returnDeviceList[$index]?.photos?.length" @click="handleAbnormal($index)">异常操作</el-button>
+                                  <el-button :disabled="isView" type="text" style="color: red"  v-if="!returnDeviceList[$index]?.condition || returnDeviceList[$index]?.photos?.length==0" @click="handleAbnormal($index)">异常操作</el-button>
                                   <el-button 
                                   :disabled="isView"
                                     type="text" 
@@ -267,15 +273,19 @@
                 </el-row>
                 <el-row :gutter="16" style="margin-top: 16px">
                     <el-col :span="24">
-                        <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ returnAbnormalList.length }}</span> 条</div>
-                        <el-table v-if="returnAbnormalList.length > 0" :data="returnAbnormalList" border style="width: 100%">
-                            <el-table-column type="index" label="序号" width="60" align="center" />
-                            <el-table-column prop="application_no" label="借用单编号" align="center" />
+                        <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ 
+                          returnAbnormalList?.length ? 
+                          returnAbnormalList.reduce((sum, item) => sum + (Number(item?.condition) || 0), 0)
+                          : 0 
+                        }}</span> 次</div>
+                        <el-table v-if="returnAbnormalList?.length > 0" :data="returnAbnormalList" border style="width: 100%">
+                           <!--  <el-table-column type="index" label="序号" width="60" align="center" />
+                            <el-table-column prop="application_no" label="借用单编号" align="center" /> -->
                             <el-table-column prop="operator_name" label="借用人" align="center" />
                             <el-table-column prop="user_code" label="学号" align="center" />
                             <el-table-column prop="emergency_phone" label="借用人电话" align="center" />
                            <!--  <el-table-column prop="time" label="发生时间" align="center" /> -->
-                            <el-table-column prop="type" label="异常类型" align="center">
+                            <el-table-column prop="type" label="异常" align="center">
                                 <template #default="{ row }">
                                     {{ row.type }}
                                 </template>
@@ -306,7 +316,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, watch, defineProps, defineEmits, onMounted,computed } from 'vue';
+import { ref, watch, defineProps, defineEmits, onMounted, computed, nextTick } from 'vue';
 import SelectDeviceDialog from './SelectDeviceDialog/index.vue';
 import SettlementDialog from './SettlementDialog.vue';
 import AbnormalDialog from './AbnormalDialog/index.vue';
@@ -437,7 +447,7 @@ const activeStep = ref(1);
 const activeName = ref('first');
 const returnStatus = ref('未归还'); // 添加独立的状态变量
 
-// 借用明细表相关数据
+// 借用表相关数据
 const searchText = ref('');
 const deviceList = ref<DeviceListItem[]>([]);
 const accessoryInfo = ref('');
@@ -614,7 +624,7 @@ const handleView = (row: any) => {
     // 这里可以添加查看详情的逻辑
 };
 
-// 借用明细表相关方法
+// 借用表相关方法
 const handleAdd = () => {
   showSelectDeviceDialog.value = true;
 };
@@ -935,7 +945,7 @@ function onSubmit() {
     
     if (!hasDevicesInFirstTab && !hasDevicesInSecondTab) {
       ElMessage.warning('请添加设备信息后再提交');
-      activeName.value = 'second'; // 自动切换到借用明细表标签页
+      activeName.value = 'second'; // 自动切换到借用表标签页
       return;
     }
 
@@ -945,7 +955,7 @@ function onSubmit() {
 
     if (hasInvalidQuantityInFirstTab || hasInvalidQuantityInSecondTab) {
       ElMessage.warning('请确保所有设备的数量大于0');
-      activeName.value = 'second'; // 自动切换到借用明细表标签页
+      activeName.value = 'second'; // 自动切换到借用表标签页
       return;
     }
 
@@ -984,8 +994,6 @@ function onSubmit() {
             device_category: item.device_type,
             device_code: item.device_no,
             borrow_type: form.value.borrow_type,
-            /* borrow_type_label: form.value.borrow_type_label,
-            borrower_info: form.value.borrower_info, */
             borrower_dept: form.value.borrower_dept,
             emergency_contact: form.value.emergency_contact,
             emergency_phone: form.value.emergency_phone,
@@ -995,31 +1003,23 @@ function onSubmit() {
           remark: remark.value,
           expected_start_time: dayjs().format('YYYY-MM-DD HH:mm:ss')
         };
-        // 显示结算单
-        showSettlementDialog.value = true;
-        emit('update:visible', false);
+        
+        // 先触发提交事件进行页面刷新
         emit('submit');
+        
+        // 关闭当前对话框
+        emit('update:visible', false);
+        
+        // 使用 nextTick 确保在 DOM 更新后再显示结算单
+        nextTick(() => {
+          showSettlementDialog.value = true;
+        });
       }
     });
   } else {
-    // 验证是否有选中的设备
-    if (selectedDevices.value.length === 0) {
-      ElMessage.warning('请选择要归还的设备');
-      activeName.value = 'third';
-      return;
-    }
-
-    // 验证设备数量
-    const hasInvalidQuantity = selectedDevices.value.some(item => !item.borrow_count || item.borrow_count <= 0);
-
-    if (hasInvalidQuantity) {
-      ElMessage.warning('请确保所有设备的数量大于0');
-      activeName.value = 'third';
-      return;
-    }
-
-    // 只提交选中的设备数据
-    const allDevices = selectedDevices.value.map(item => ({
+    // 归还逻辑修改
+    // 使用所有设备列表而不是选中的设备
+    const allDevices = returnDeviceList.value.map(item => ({
       device: item.device_no,
       quantity: item.borrow_count,
       condition: returnRemark.value,
@@ -1030,7 +1030,7 @@ function onSubmit() {
       id: form.value.id,
       items: allDevices,
       status: returnStatus.value,
-      accessories:form.value.accessories,
+      accessories: form.value.accessories,
     };
     
     ReturnEquipment(submitData).then(async (res: ApiResponse) => {
@@ -1055,7 +1055,11 @@ function onSubmit() {
 
 function clickReturn(){
   returnStatus.value = '已归还';
-  
+  // 自动选择所有设备
+  const tableRef = document.querySelector('.el-table__header-wrapper th.el-table__cell.is-leaf .el-checkbox');
+  if (tableRef) {
+    (tableRef as HTMLElement).click();
+  }
 }
 
 	/* formRef.value.validate((valid: boolean) => {

+ 98 - 0
src/views/system/borrow/component/SelectCatgory/index.vue

@@ -0,0 +1,98 @@
+<template>
+	<el-dialog v-model="visible" title="选择设备分类" width="800px" :close-on-click-modal="false" @close="onCancel">
+		<div style="margin-bottom: 12px">
+			<el-input v-model="search" placeholder="输入关键字搜索" style="width: 240px; margin-right: 8px" @keyup.enter="fetchData(true)" />
+			<el-button type="primary" @click="fetchData(true)">搜索</el-button>
+		</div>
+		<el-table :data="tableData" border style="width: 100%" @selection-change="onSelectionChange" ref="tableRef">
+			<el-table-column type="selection" width="50" />
+			<el-table-column type="index" label="序号" width="60" />
+            <el-table-column prop="code" label="分类编号" />
+			<el-table-column prop="name" label="设备分类" />
+			<!-- <el-table-column prop="inventory.available_quantity" label="可用数量" /> -->
+		<!-- 	<el-table-column prop="category_name" label="设备分类" /> 
+			<el-table-column prop="warehouse" label="存放仓库" />-->
+		</el-table>
+		<el-pagination
+			style="margin-top: 12px; text-align: right"
+			:current-page="page"
+			:page-size="pageSize"
+			:total="total"
+			@current-change="onPageChange"
+		/>
+		<template #footer>
+			<el-button @click="onCancel">取消</el-button>
+			<el-button type="primary" @click="onConfirm">确定</el-button>
+		</template>
+	</el-dialog>
+</template>
+
+<script setup lang="ts">
+import { ref, watch, defineProps, defineEmits } from 'vue';
+import * as deviceApi from '../../../deviceclass/api';
+import * as storeapi from '../../../storelist/api';
+import { status } from 'nprogress';
+
+const props = defineProps<{ visible: boolean }>();
+const emit = defineEmits(['update:visible', 'confirm']);
+
+const visible = ref(props.visible);
+watch(
+	() => props.visible,
+	(v) => (visible.value = v)
+);
+
+const search = ref('');
+const page = ref(1);
+const pageSize = ref(10);
+const total = ref(0);
+const tableData = ref([]);
+const selectedRows = ref([]);
+const warehouseMap = ref<Record<number, string>>({});
+
+
+function fetchWarehouseMap() {
+    storeapi.GetPermission().then((res) => {
+        const map: Record<number, string> = {};
+        res.data.forEach((item) => {
+            map[item.id] = item.name;
+        });
+        warehouseMap.value = map;
+    });
+}
+
+
+async function fetchData(resetPage = false) {
+	if (resetPage) page.value = 1;
+	await fetchWarehouseMap(); 
+	deviceApi.GetList({ page: page.value, limit: pageSize.value, code: search.value,status:1 })
+	.then((res) => {
+		const devices = res.data
+		/* .filter(device => device.available_quantity > 0)
+		.map((device) => ({
+            ...device,
+            warehouse: `${warehouseMap.value[device.warehouse] || `ID:${device.warehouse}`} (${device.available_quantity})`
+        })); */
+		tableData.value = devices;
+		// tableData.value = [...res.data];
+		total.value = res.total;
+	});
+}
+function onSelectionChange(val) {
+	selectedRows.value = val;
+}
+function onPageChange(val) {
+	page.value = val;
+	fetchData();
+}
+function onConfirm() {
+	emit('confirm', selectedRows.value);
+	emit('update:visible', false);
+}
+function onCancel() {
+	emit('update:visible', false);
+}
+watch([visible, page], (v) => {
+	if (visible.value) fetchData();
+});
+</script>

+ 5 - 3
src/views/system/borrow/component/SpecialBorrow/index.vue

@@ -68,7 +68,7 @@
 					</el-form-item>
 				</el-col>
 			</el-row>
-			<div style="margin: 16px 0 8px 0; font-weight: bold">借用明细表</div>
+			<div style="margin: 16px 0 8px 0; font-weight: bold">借用表</div>
 			<el-table :data="form.items" border style="width: 100%; margin-bottom: 12px">
 				<el-table-column type="index" label="序号" width="60" />
 				<el-table-column prop="remark" label="设备分类" />
@@ -123,7 +123,8 @@
 			<el-button type="primary" @click="onSubmit" v-if="!isView">提交</el-button>
 		</template>
 	</el-dialog>
-	<SelectDeviceDialog v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
+	<!-- <SelectDeviceDialog v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" /> -->
+	<SelectCatgory v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
 </template>
 
 <script setup lang="ts">
@@ -135,6 +136,7 @@ import * as api from '../../api';
 import Cookies from 'js-cookie';
 import { request } from '/@/utils/service';
 import { Plus } from '@element-plus/icons-vue';
+import SelectCatgory from '../SelectCatgory/index.vue';
 
 
 
@@ -371,7 +373,7 @@ function onDeviceSelected(devices) {
 	form.value.items.push(
 		...devices.map((d) => ({
 			device: d.id,
-			remark: d.category_name,
+			remark: d.name,
 			quantity: 1,
 			location: d.warehouse,
 		}))

+ 2 - 2
src/views/system/borrow/crud.tsx

@@ -53,7 +53,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						show:true,	
 						order:4,
 						disabled:compute( ({row})=>{
-							return row.borrow_type === 0;
+							return row.status !== 1 && row.status !== 2;
 						}), 
 						click: ({ row }) => {
 							window.dispatchEvent(new CustomEvent('borrow-edit', { detail: row }));
@@ -131,7 +131,7 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
 						minWidth: 100,
 					},
 				},
-				emergency_contact: { title: '借用人', column: { show:false, minWidth: 100 } },
+				external_borrower_name: { title: '借用人', column: { show:false, minWidth: 100 } },
 				emergency_phone: { title: '联系方式', column: { minWidth: 120 } },
 				team_type_label: { title: '个人/团队', column: { minWidth: 80 } },
 				team_members: { title: '团队成员', column: { show:false,minWidth: 120 } },