|
@@ -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) => {
|