|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <el-dialog v-model="visible" :title="isCollect ? '领取' : '归还'" width="75%" :close-on-click-modal="false" @close="onCancel">
|
|
|
+ <el-dialog v-model="visible" :title="isView ? '借用单详情' : isCollect ? '领取' : '归还'" width="75%" :close-on-click-modal="false" @close="onCancel">
|
|
|
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
|
|
<el-tab-pane label="借用单信息" name="first">
|
|
|
<el-form :model="form" label-width="110px" label-position="top" :rules="rules" ref="formRef">
|
|
@@ -77,24 +77,24 @@
|
|
|
<!-- <el-table-column prop="quantity" label="借用数量" /> -->
|
|
|
<el-table-column :label="isCollect ? '借用数量' : '归还数量'">
|
|
|
<template #default="{ row }">
|
|
|
- <el-input v-model="row.quantity" type="number" :min="1" prop="quantity" size="small" :disabled="isView" />
|
|
|
+ <el-input v-model="row.quantity" type="number" :min="1" prop="quantity" size="small" :disabled="true" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="condition" label="归还备注" v-if="isReturn">
|
|
|
<template #default="{ row }">
|
|
|
- <el-input v-model="row.condition" placeholder="请输入备注" :disabled="isView" />
|
|
|
+ <el-input v-model="row.condition" placeholder="请输入备注" :disabled="true" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="location" label="存放仓库" />
|
|
|
<el-table-column label="操作" width="80">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <el-button type="text" style="color: red" @click="removeItem($index)" :disabled="isView">移除</el-button>
|
|
|
+ <template #default="{ $index }">
|
|
|
+ <el-button type="text" style="color: red" @click="removeItem($index)" :disabled="true">移除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<el-button type="primary" @click="addItem" v-if="!isView" :disabled="true">添加设备</el-button>
|
|
|
<div style="margin: 16px 0 8px 0; font-weight: bold">配件信息</div>
|
|
|
- <el-input v-model="form.accessory_info" placeholder="请输入配件信息" :disabled="true"/>
|
|
|
+ <el-input v-model="form.accessories" placeholder="请输入配件信息" :disabled="true"/>
|
|
|
|
|
|
<div style="margin: 16px 0 8px 0; font-weight: bold" >附件</div>
|
|
|
<el-upload
|
|
@@ -158,7 +158,7 @@
|
|
|
<el-table-column prop="device_name" label="设备名称" align="center" />
|
|
|
<el-table-column prop="borrow_count" label="借用数量" align="center" width="150">
|
|
|
<template #default="{ row }">
|
|
|
- <el-input-number v-model="row.borrow_count" :min="1" :max="999" size="small" />
|
|
|
+ <el-input-number v-model="row.borrow_count" :disabled="isView" :min="1" :max="999" size="small" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="brand" label="品牌" align="center" />
|
|
@@ -166,7 +166,7 @@
|
|
|
<el-table-column prop="warehouse" label="存放仓库" align="center" />
|
|
|
<el-table-column label="操作" width="80" align="center">
|
|
|
<template #default="{ $index }">
|
|
|
- <el-button type="text" style="color: red" @click="handleRemove($index)">移除</el-button>
|
|
|
+ <el-button type="text" style="color: red" :disabled="isView" @click="handleRemove($index)">移除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -175,30 +175,32 @@
|
|
|
<el-row :gutter="16" style="margin-top: 16px">
|
|
|
<el-col :span="24">
|
|
|
<div style="font-weight: bold; margin-bottom: 8px">配件信息</div>
|
|
|
- <el-input v-model="accessoryInfo" type="textarea" placeholder="请输入配件信息" />
|
|
|
+ <el-input v-model="form.accessories" :disabled="isView" type="textarea" placeholder="请输入配件信息" />
|
|
|
</el-col>
|
|
|
<el-col :span="24" style="margin-top: 16px">
|
|
|
<div style="font-weight: bold; margin-bottom: 8px">备注</div>
|
|
|
- <el-input v-model="remark" type="textarea" placeholder="请输入备注" />
|
|
|
+ <el-input v-model="remark" type="textarea" :disabled="isView" placeholder="请输入备注" />
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="16" style="margin-top: 16px">
|
|
|
<el-col :span="24">
|
|
|
- <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ 0 }}</span> 条</div>
|
|
|
+ <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ abnormalList.length }}</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="borrowNo" label="借用单编号" align="center" />
|
|
|
- <el-table-column prop="borrower" label="借用人" align="center" />
|
|
|
- <el-table-column prop="time" 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">
|
|
|
<template #default="{ row }">
|
|
|
- <el-tag :type="row.type === '逾期' ? 'danger' : 'warning'">{{ row.type }}</el-tag>
|
|
|
+ {{ row.type }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="operation" label="操作" align="center" width="80">
|
|
|
- <template #default="{ row }">
|
|
|
- <el-button type="text" @click="handleView(row)">查看</el-button>
|
|
|
- </template>
|
|
|
+ <el-table-column prop="condition" label="数量" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{ row.condition }}
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-col>
|
|
@@ -210,17 +212,18 @@
|
|
|
<el-row :gutter="16">
|
|
|
<el-col :span="24">
|
|
|
<div style="margin: 8px 0">
|
|
|
- <el-input v-model="returnSearchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter="handleReturnScanSearch" />
|
|
|
- <el-button type="primary" style="margin-left: 16px" @click="handleAdd">手动添加</el-button>
|
|
|
+ <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>
|
|
|
</div>
|
|
|
- <el-table :data="returnDeviceList" border style="width: 100%">
|
|
|
+ <el-table :data="returnDeviceList" border style="width: 100%" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column type="index" label="序号" width="60" align="center" />
|
|
|
<el-table-column prop="device_no" label="设备编号" align="center" />
|
|
|
<el-table-column prop="device_type" label="设备分类" align="center" />
|
|
|
<el-table-column prop="device_name" label="设备名称" align="center" />
|
|
|
<el-table-column prop="borrow_count" label="借用数量" align="center" width="150">
|
|
|
<template #default="{ row }">
|
|
|
- <el-input-number v-model="row.borrow_count" :min="1" :max="999" size="small" />
|
|
|
+ <el-input-number v-model="row.borrow_count" :min="1" :max="999" size="small" :disabled="isView" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="brand" label="品牌" align="center" />
|
|
@@ -231,9 +234,17 @@
|
|
|
<el-tag :type="row.status === '已归还' ? 'success' : 'warning'">{{ row.status }}</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" width="80" align="center">
|
|
|
+ <el-table-column label="操作" width="150" align="center">
|
|
|
<template #default="{ $index }">
|
|
|
- <el-button type="text" style="color: red" @click="handleReturnRemove($index)">移除</el-button>
|
|
|
+ <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: #409EFF"
|
|
|
+ @click="handleViewAbnormal($index)"
|
|
|
+ v-if="returnDeviceList[$index]?.condition || returnDeviceList[$index]?.photos?.length"
|
|
|
+ >查看异常</el-button>
|
|
|
+ <el-button type="text" :disabled="isView" style="color: red" @click="handleReturnRemove($index)">移除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -242,35 +253,37 @@
|
|
|
<el-row :gutter="16" style="margin-top: 16px">
|
|
|
<el-col :span="16">
|
|
|
<div style="font-weight: bold; margin-bottom: 8px">配件信息</div>
|
|
|
- <el-input v-model="returnAccessoryInfo" placeholder="请输入配件信息" />
|
|
|
+ <el-input v-model="form.accessories" :disabled="isView" placeholder="请输入配件信息" />
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<div style="font-weight: bold; margin-bottom: 8px">当前状态</div>
|
|
|
- <el-input v-model="form.status_label" :disabled="true" placeholder="" style="width: 150px" />
|
|
|
- <el-button type="primary" style="margin-left: 16px" @click="clickReturn" :disabled="form.status_label=='已归还'">归还</el-button>
|
|
|
+ <el-input v-model="returnStatus" :disabled="true" placeholder="" style="width: 150px" />
|
|
|
+ <el-button type="primary" style="margin-left: 16px" @click="clickReturn" :disabled="returnStatus=='已归还'||isView">归还</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="24" style="margin-top: 16px">
|
|
|
<div style="font-weight: bold; margin-bottom: 8px">备注</div>
|
|
|
- <el-input v-model="returnRemark" type="textarea" placeholder="请输入备注" />
|
|
|
+ <el-input v-model="returnRemark" type="textarea" :disabled="isView" placeholder="请输入备注" />
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="16" style="margin-top: 16px">
|
|
|
<el-col :span="24">
|
|
|
- <div style="font-weight: bold; margin-bottom: 8px">异常记录 <span>{{ 0 }}</span> 条</div>
|
|
|
+ <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="borrowNo" label="借用单编号" align="center" />
|
|
|
- <el-table-column prop="borrower" label="借用人" align="center" />
|
|
|
- <el-table-column prop="time" label="发生时间" 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">
|
|
|
<template #default="{ row }">
|
|
|
- <el-tag :type="row.type === '逾期' ? 'danger' : 'warning'">{{ row.type }}</el-tag>
|
|
|
+ {{ row.type }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="operation" label="操作" align="center" width="80">
|
|
|
- <template #default="{ row }">
|
|
|
- <el-button type="text" @click="handleView(row)">查看</el-button>
|
|
|
- </template>
|
|
|
+ <el-table-column prop="condition" label="数量" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ {{ row.condition }}
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-col>
|
|
@@ -285,12 +298,19 @@
|
|
|
</el-dialog>
|
|
|
<SelectDeviceDialog v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
|
|
|
<SettlementDialog v-model:visible="showSettlementDialog" :settlement-data="settlementData" />
|
|
|
+ <AbnormalDialog v-model:visible="showAbnormalDialog" @confirm="onAbnormalConfirm" />
|
|
|
+ <ViewAbnormalDialog
|
|
|
+ v-model:visible="showViewAbnormalDialog"
|
|
|
+ :abnormal-data="currentAbnormalData"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { ref, watch, defineProps, defineEmits, onMounted,computed } from 'vue';
|
|
|
import SelectDeviceDialog from './SelectDeviceDialog/index.vue';
|
|
|
import SettlementDialog from './SettlementDialog.vue';
|
|
|
+import AbnormalDialog from './AbnormalDialog/index.vue';
|
|
|
+import ViewAbnormalDialog from './ViewAbnormalDialog/index.vue';
|
|
|
import dayjs from 'dayjs';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import * as api from '../../api';
|
|
@@ -312,17 +332,25 @@ interface Device {
|
|
|
brand?: string;
|
|
|
model?: string;
|
|
|
warehouse: string;
|
|
|
+ device_specification?: string;
|
|
|
+ device_name?: string;
|
|
|
}
|
|
|
|
|
|
interface DeviceListItem {
|
|
|
device_no: string | number;
|
|
|
device_type: string;
|
|
|
- device_name: string;
|
|
|
+ device_name?: string; // 改为可选
|
|
|
borrow_count: number;
|
|
|
brand: string;
|
|
|
- model: string;
|
|
|
+ model?: string; // 改为可选
|
|
|
warehouse: string;
|
|
|
- status?: string; // 添加状态字段
|
|
|
+ status?: string;
|
|
|
+ condition?: string;
|
|
|
+ photos?: Array<{
|
|
|
+ filename: string;
|
|
|
+ data: string;
|
|
|
+ }>;
|
|
|
+ device_specification?: string;
|
|
|
}
|
|
|
|
|
|
interface FormItem {
|
|
@@ -330,6 +358,13 @@ interface FormItem {
|
|
|
remark: string;
|
|
|
quantity: number;
|
|
|
location: string;
|
|
|
+ device_name?: string;
|
|
|
+ device_specification?: string;
|
|
|
+ condition?: string;
|
|
|
+ photos?: Array<{
|
|
|
+ filename: string;
|
|
|
+ data: string;
|
|
|
+ }>;
|
|
|
}
|
|
|
|
|
|
interface FormData {
|
|
@@ -352,6 +387,30 @@ interface FormData {
|
|
|
return_location: string;
|
|
|
status_label?: string;
|
|
|
id?: number;
|
|
|
+ records?: any[];
|
|
|
+ borrower_info?: {
|
|
|
+ user_code: string;
|
|
|
+ };
|
|
|
+ borrower_damage_count?: number;
|
|
|
+ accessories?: string;
|
|
|
+}
|
|
|
+
|
|
|
+interface AbnormalData {
|
|
|
+ condition: string;
|
|
|
+ photos: Array<{
|
|
|
+ filename: string;
|
|
|
+ data: string;
|
|
|
+ }>;
|
|
|
+}
|
|
|
+
|
|
|
+interface AbnormalRecord {
|
|
|
+ application_no: string;
|
|
|
+ operator_name: string;
|
|
|
+ user_code: string;
|
|
|
+ emergency_phone: string;
|
|
|
+ type: '损坏' | '逾期';
|
|
|
+ condition: number;
|
|
|
+ create_time: string;
|
|
|
}
|
|
|
|
|
|
const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
@@ -376,6 +435,7 @@ const timeline = ref({
|
|
|
const activeStep = ref(1);
|
|
|
|
|
|
const activeName = ref('first');
|
|
|
+const returnStatus = ref('未归还'); // 添加独立的状态变量
|
|
|
|
|
|
// 借用明细表相关数据
|
|
|
const searchText = ref('');
|
|
@@ -388,11 +448,54 @@ const returnSearchText = ref('');
|
|
|
const returnDeviceList = ref<DeviceListItem[]>([]);
|
|
|
const returnAccessoryInfo = ref('');
|
|
|
const returnRemark = ref('');
|
|
|
+const selectedDevices = ref<DeviceListItem[]>([]); // 添加选中设备列表
|
|
|
+
|
|
|
|
|
|
// 添加结算单相关的状态
|
|
|
const showSettlementDialog = ref(false);
|
|
|
const settlementData = ref<any>(null);
|
|
|
|
|
|
+// 添加异常操作相关的状态
|
|
|
+const showAbnormalDialog = ref(false);
|
|
|
+const currentAbnormalIndex = ref(-1);
|
|
|
+
|
|
|
+// 添加查看异常相关的状态
|
|
|
+const showViewAbnormalDialog = ref(false);
|
|
|
+const currentAbnormalData = ref<AbnormalData>({
|
|
|
+ condition: '',
|
|
|
+ photos: []
|
|
|
+});
|
|
|
+
|
|
|
+// 处理异常操作
|
|
|
+const handleAbnormal = (index: number) => {
|
|
|
+ currentAbnormalIndex.value = index;
|
|
|
+ showAbnormalDialog.value = true;
|
|
|
+ console.log("showAbnormalDialog:::", showAbnormalDialog.value, "currentAbnormalIndex:::", currentAbnormalIndex.value);
|
|
|
+};
|
|
|
+
|
|
|
+// 处理异常操作确认
|
|
|
+const onAbnormalConfirm = (data: { condition: string; photos: any[] }) => {
|
|
|
+ console.log("异常操作确认数据:", data);
|
|
|
+ if (currentAbnormalIndex.value !== -1) {
|
|
|
+ const device = returnDeviceList.value[currentAbnormalIndex.value];
|
|
|
+ device.condition = data.condition;
|
|
|
+ device.photos = data.photos;
|
|
|
+ ElMessage.success('异常信息已保存');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 处理查看异常
|
|
|
+const handleViewAbnormal = (index: number) => {
|
|
|
+ const device = returnDeviceList.value[index];
|
|
|
+ if (device) {
|
|
|
+ currentAbnormalData.value = {
|
|
|
+ condition: device.condition || '',
|
|
|
+ photos: device.photos || []
|
|
|
+ };
|
|
|
+ showViewAbnormalDialog.value = true;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
// 处理扫码搜索
|
|
|
const handleScanSearch = async () => {
|
|
|
if (!searchText.value.trim()) return;
|
|
@@ -456,10 +559,11 @@ const handleReturnScanSearch = async () => {
|
|
|
const device = res.data[0];
|
|
|
|
|
|
// 检查是否已存在
|
|
|
- const existingDevice = returnDeviceList.value.find(d => d.device_no === device.id);
|
|
|
- if (existingDevice) {
|
|
|
- existingDevice.borrow_count++;
|
|
|
- ElMessage.success('设备数量已更新');
|
|
|
+ const existingDeviceIndex = returnDeviceList.value.findIndex(d => d.device_no === device.id);
|
|
|
+ if (existingDeviceIndex !== -1) {
|
|
|
+ // 如果设备已存在,更新其状态
|
|
|
+ returnDeviceList.value[existingDeviceIndex].status = '已归还';
|
|
|
+ ElMessage.success(`设备 ${device.category_name} 状态已更新为已归还`);
|
|
|
} else {
|
|
|
// 添加新设备到列表
|
|
|
returnDeviceList.value.push({
|
|
@@ -470,7 +574,7 @@ const handleReturnScanSearch = async () => {
|
|
|
brand: device.brand || '',
|
|
|
model: device.model || '',
|
|
|
warehouse: device.warehouse,
|
|
|
- status: '未归还'
|
|
|
+ status: '已归还'
|
|
|
});
|
|
|
ElMessage.success('设备已添加到列表');
|
|
|
}
|
|
@@ -522,21 +626,26 @@ const handleReturnRemove = (index: number) => {
|
|
|
returnDeviceList.value.splice(index, 1);
|
|
|
};
|
|
|
|
|
|
+// 处理表格多选变化
|
|
|
+const handleSelectionChange = (selection: DeviceListItem[]) => {
|
|
|
+ selectedDevices.value = selection;
|
|
|
+};
|
|
|
+
|
|
|
// 设备选择处理
|
|
|
function onDeviceSelected(devices: Device[]) {
|
|
|
console.log("devices:::",devices,"activeName:::",activeName.value);
|
|
|
if (activeName.value === 'first') {
|
|
|
- // 第一个标签页的处理逻辑
|
|
|
form.value.items.push(
|
|
|
...devices.map((d) => ({
|
|
|
device: d.id,
|
|
|
remark: d.category_name,
|
|
|
quantity: 1,
|
|
|
location: d.warehouse,
|
|
|
+ device_name: d.name,
|
|
|
+ device_specification: d.device_specification
|
|
|
}))
|
|
|
);
|
|
|
} else if (activeName.value === 'second') {
|
|
|
- // 第二个标签页的处理逻辑 - 直接添加到设备列表
|
|
|
deviceList.value.push(
|
|
|
...devices.map(d => ({
|
|
|
device_no: d.id,
|
|
@@ -544,35 +653,34 @@ function onDeviceSelected(devices: Device[]) {
|
|
|
device_name: d.name || '',
|
|
|
borrow_count: 1,
|
|
|
brand: d.brand || '',
|
|
|
- model: d.model || '',
|
|
|
- device_specification: d.device_specification || '',
|
|
|
+ model: d.model,
|
|
|
+ device_specification: d.device_specification,
|
|
|
warehouse: d.warehouse
|
|
|
}))
|
|
|
);
|
|
|
}else if(activeName.value === 'third'){
|
|
|
- // 在添加前先检查是否存在相同id的设备
|
|
|
- /* const newDevices = devices.filter(d => {
|
|
|
- const existingItem = form.value.items.find(item => item.device === d.id);
|
|
|
- console.log("existingItem:::",existingItem);
|
|
|
- if (!existingItem) {
|
|
|
- ElMessage.warning(`设备 ${d.category_name} 不在借用清单中`);
|
|
|
- return false;
|
|
|
+ // 在添加前检查每个设备是否已存在
|
|
|
+ devices.forEach(d => {
|
|
|
+ const existingDeviceIndex = returnDeviceList.value.findIndex(item => item.device_no === d.id);
|
|
|
+ if (existingDeviceIndex !== -1) {
|
|
|
+ // 如果设备已存在,更新其状态
|
|
|
+ returnDeviceList.value[existingDeviceIndex].status = '已归还';
|
|
|
+ ElMessage.success(`设备 ${d.category_name} 状态已更新为已归还`);
|
|
|
+ } else {
|
|
|
+ // 如果设备不存在,添加新记录
|
|
|
+ /* returnDeviceList.value.push({
|
|
|
+ device_no: d.id,
|
|
|
+ device_type: d.category_name,
|
|
|
+ device_name: d.name || '',
|
|
|
+ borrow_count: 1,
|
|
|
+ brand: d.brand || '',
|
|
|
+ model: d.model || '',
|
|
|
+ warehouse: d.warehouse,
|
|
|
+ status: '已归还'
|
|
|
+ }); */
|
|
|
+ /* ElMessage.success(`设备 ${d.category_name} 已添加到归还列表`); */
|
|
|
}
|
|
|
- return true;
|
|
|
- }); */
|
|
|
-
|
|
|
- returnDeviceList.value.push(
|
|
|
- ...devices.map(d => ({
|
|
|
- device_no: d.id,
|
|
|
- device_type: d.category_name,
|
|
|
- device_name: d.name || '',
|
|
|
- borrow_count: 1,
|
|
|
- brand: d.brand || '',
|
|
|
- model: d.model || '',
|
|
|
- warehouse: d.warehouse
|
|
|
- }))
|
|
|
- );
|
|
|
-
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -681,7 +789,7 @@ watch(
|
|
|
|
|
|
watch(() => props.modelValue, async (val) => {
|
|
|
console.log("props:::",props.modelValue);
|
|
|
- console.log("val:::",val && val.id && isView.value);
|
|
|
+ console.log("val:::", isView.value);
|
|
|
if (val && val.id) {
|
|
|
try {
|
|
|
const res = await api.GetApplicationDetail(val.id);
|
|
@@ -696,6 +804,47 @@ watch(() => props.modelValue, async (val) => {
|
|
|
if (data.status >= 1) activeStep.value = 2; // 待审批
|
|
|
if (data.status >= 2) activeStep.value = 3; // 审批通过
|
|
|
if (data.status >= 3) activeStep.value = 4; // 完成
|
|
|
+
|
|
|
+ // 同步 form.items 到 returnDeviceList
|
|
|
+ if (form.value.items && form.value.items.length > 0) {
|
|
|
+ returnDeviceList.value = form.value.items.map(item => ({
|
|
|
+ device_no: item.device,
|
|
|
+ device_type: item.remark,
|
|
|
+ device_name: item.device_name,
|
|
|
+ borrow_count: item.quantity,
|
|
|
+ brand: '',
|
|
|
+ model: item.device_specification,
|
|
|
+ warehouse: item.location,
|
|
|
+ status: '未归还'
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ // 同步 form.records 到 returnAbnormalList
|
|
|
+ if (form.value.records && form.value.records.length > 0) {
|
|
|
+ // 添加损坏类型记录
|
|
|
+ const damageRecord: AbnormalRecord = {
|
|
|
+ application_no: form.value.application_no,
|
|
|
+ operator_name: form.value.emergency_contact,
|
|
|
+ user_code: form.value.borrower_info?.user_code || '',
|
|
|
+ emergency_phone: form.value.emergency_phone,
|
|
|
+ type: '损坏',
|
|
|
+ condition: form.value.borrower_damage_count || 0,
|
|
|
+ create_time: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ };
|
|
|
+
|
|
|
+ // 添加逾期类型记录
|
|
|
+ const overdueRecord: AbnormalRecord = {
|
|
|
+ application_no: form.value.application_no,
|
|
|
+ operator_name: form.value.emergency_contact,
|
|
|
+ user_code: form.value.borrower_info?.user_code || '',
|
|
|
+ emergency_phone: form.value.emergency_phone,
|
|
|
+ type: '逾期',
|
|
|
+ condition: form.value.borrower_overdue_count || 0, // 逾期数量设为1
|
|
|
+ create_time: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
|
+ };
|
|
|
+
|
|
|
+ returnAbnormalList.value = [damageRecord, overdueRecord];
|
|
|
+ abnormalList.value = [damageRecord, overdueRecord];
|
|
|
+ }
|
|
|
}
|
|
|
} catch (e) {
|
|
|
ElMessage.error('获取审批信息失败');
|
|
@@ -706,6 +855,20 @@ watch(() => props.modelValue, async (val) => {
|
|
|
if (res.code === 2000 && res.data) {
|
|
|
const data = res.data;
|
|
|
Object.assign(form.value, data);
|
|
|
+
|
|
|
+ // 同步 form.items 到 returnDeviceList
|
|
|
+ if (form.value.items && form.value.items.length > 0) {
|
|
|
+ returnDeviceList.value = form.value.items.map(item => ({
|
|
|
+ device_no: item.device,
|
|
|
+ device_type: item.remark,
|
|
|
+ device_name: item.device_name,
|
|
|
+ borrow_count: item.quantity,
|
|
|
+ brand: '',
|
|
|
+ model: item.device_specification,
|
|
|
+ warehouse: item.location,
|
|
|
+ status: '未归还'
|
|
|
+ }));
|
|
|
+ }
|
|
|
}
|
|
|
} catch (e) {
|
|
|
ElMessage.error('获取审批信息失败');
|
|
@@ -732,8 +895,36 @@ function removeItem(index: number) {
|
|
|
form.value.items.splice(index, 1);
|
|
|
}
|
|
|
function onCancel() {
|
|
|
+ // 重置标签页到第一个
|
|
|
activeName.value = 'first';
|
|
|
- emit('update:visible', false);
|
|
|
+ // 清理异常记录列表
|
|
|
+ returnAbnormalList.value = [];
|
|
|
+ abnormalList.value = [];
|
|
|
+ // 清理设备列表
|
|
|
+ deviceList.value = [];
|
|
|
+ returnDeviceList.value = [];
|
|
|
+ // 清理搜索框
|
|
|
+ searchText.value = '';
|
|
|
+ returnSearchText.value = '';
|
|
|
+ // 清理备注
|
|
|
+ remark.value = '';
|
|
|
+ returnRemark.value = '';
|
|
|
+ // 重置状态
|
|
|
+ returnStatus.value = '未归还';
|
|
|
+ // 清理选中的设备
|
|
|
+ selectedDevices.value = [];
|
|
|
+ // 关闭所有对话框
|
|
|
+ showSelectDeviceDialog.value = false;
|
|
|
+ showSettlementDialog.value = false;
|
|
|
+ showAbnormalDialog.value = false;
|
|
|
+ showViewAbnormalDialog.value = false;
|
|
|
+ // 重置当前异常数据
|
|
|
+ currentAbnormalData.value = {
|
|
|
+ condition: '',
|
|
|
+ photos: []
|
|
|
+ };
|
|
|
+ // 发出关闭事件
|
|
|
+ emit('update:visible', false);
|
|
|
}
|
|
|
// 提交时合并数据
|
|
|
function onSubmit() {
|
|
@@ -772,6 +963,7 @@ function onSubmit() {
|
|
|
item_id:form.value.id,
|
|
|
device_assignments: allDevices,
|
|
|
remark:remark.value,
|
|
|
+ accessories:form.value.accessories,
|
|
|
};
|
|
|
|
|
|
CollectEquipment(submitData).then((res: ApiResponse) => {
|
|
@@ -810,67 +1002,60 @@ function onSubmit() {
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- emit('update:visible', false);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function clickReturn(){
|
|
|
- console.log("clickReturn:::",form.value);
|
|
|
- // 验证是否有设备信息
|
|
|
- const hasDevicesInFirstTab = form.value.items && form.value.items.length > 0;
|
|
|
- const hasDevicesInSecondTab = returnDeviceList.value && returnDeviceList.value.length > 0;
|
|
|
-
|
|
|
- if (!hasDevicesInFirstTab && !hasDevicesInSecondTab) {
|
|
|
- ElMessage.warning('请添加设备信息后再提交');
|
|
|
- activeName.value = 'third'; // 自动切换到借用明细表标签页
|
|
|
+ // 验证是否有选中的设备
|
|
|
+ if (selectedDevices.value.length === 0) {
|
|
|
+ ElMessage.warning('请选择要归还的设备');
|
|
|
+ activeName.value = 'third';
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 验证设备数量
|
|
|
- const hasInvalidQuantityInFirstTab = form.value.items.some(item => !item.quantity || item.quantity <= 0);
|
|
|
- const hasInvalidQuantityInSecondTab = returnDeviceList.value.some(item => !item.borrow_count || item.borrow_count <= 0);
|
|
|
+ const hasInvalidQuantity = selectedDevices.value.some(item => !item.borrow_count || item.borrow_count <= 0);
|
|
|
|
|
|
- if (hasInvalidQuantityInFirstTab || hasInvalidQuantityInSecondTab) {
|
|
|
+ if (hasInvalidQuantity) {
|
|
|
ElMessage.warning('请确保所有设备的数量大于0');
|
|
|
- activeName.value = 'third'; // 自动切换到借用明细表标签页
|
|
|
+ activeName.value = 'third';
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 合并两个标签页的设备数据
|
|
|
- const allDevices = [
|
|
|
- ...returnDeviceList.value.map(item => ({
|
|
|
- device: item.device_no,
|
|
|
- quantity: item.borrow_count,
|
|
|
- condition:returnRemark.value,
|
|
|
- device_id: Number(item.device_no) || 0
|
|
|
- }))
|
|
|
- ];
|
|
|
+ // 只提交选中的设备数据
|
|
|
+ const allDevices = selectedDevices.value.map(item => ({
|
|
|
+ device: item.device_no,
|
|
|
+ quantity: item.borrow_count,
|
|
|
+ condition: returnRemark.value,
|
|
|
+ device_id: Number(item.device_no) || 0
|
|
|
+ }));
|
|
|
|
|
|
const submitData = {
|
|
|
- id:form.value.id,
|
|
|
- items: allDevices
|
|
|
+ id: form.value.id,
|
|
|
+ items: allDevices,
|
|
|
+ status: returnStatus.value,
|
|
|
+ accessories:form.value.accessories,
|
|
|
};
|
|
|
-
|
|
|
- console.log("submitData:::",submitData);
|
|
|
|
|
|
ReturnEquipment(submitData).then(async (res: ApiResponse) => {
|
|
|
if(res.code===2000){
|
|
|
ElMessage.success("归还成功");
|
|
|
- // 获取最新详情
|
|
|
try {
|
|
|
if (form.value.id) {
|
|
|
const detailRes = await api.GetApplicationDetail(form.value.id);
|
|
|
if (detailRes.code === 2000 && detailRes.data) {
|
|
|
- // 只更新状态标签,保持其他数据不变
|
|
|
- form.value.status_label = detailRes.data.status_label || '';
|
|
|
+ returnStatus.value = detailRes.data.status_label || returnStatus.value;
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
|
ElMessage.error('获取最新状态失败');
|
|
|
}
|
|
|
emit('submit');
|
|
|
+ emit('update:visible', false);
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function clickReturn(){
|
|
|
+ returnStatus.value = '已归还';
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/* formRef.value.validate((valid: boolean) => {
|