|
@@ -241,42 +241,51 @@
|
|
<el-form :model="form" label-width="110px">
|
|
<el-form :model="form" label-width="110px">
|
|
<el-row :gutter="16">
|
|
<el-row :gutter="16">
|
|
<el-col :span="24">
|
|
<el-col :span="24">
|
|
- <div style="margin: 8px 0">
|
|
|
|
|
|
+ <div style="margin: 8px 0" v-if="!isView" >
|
|
<el-input :disabled="isView" v-model="returnSearchText" placeholder="请扫描设备条码添加" style="width: 300px" @keyup.enter="handleReturnScanSearch" />
|
|
<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>
|
|
</div>
|
|
- <el-table :data="returnDeviceList" border style="width: 100%" @selection-change="handleSelectionChange">
|
|
|
|
- <el-table-column type="selection" width="55" align="center" />
|
|
|
|
|
|
+ <el-table :data="returnDeviceList" border style="width: 100%" >
|
|
|
|
+ <!-- <el-table-column type="selection" width="55" align="center" />@selection-change="handleSelectionChange" -->
|
|
<el-table-column type="index" label="序号" width="60" 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_no" label="设备编号" align="center" />
|
|
<el-table-column prop="device_type" 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="device_name" label="设备名称" align="center" />
|
|
<el-table-column prop="borrow_count" label="借用数量" align="center" width="150">
|
|
<el-table-column prop="borrow_count" label="借用数量" align="center" width="150">
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
- <el-input-number v-model="row.borrow_count" :min="1" :max="999" size="small" :disabled="isView" />
|
|
|
|
|
|
+ <el-input-number v-model="row.borrow_count" :min="1" :max="999" size="small" :disabled="true" />
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column prop="brand" label="品牌" align="center" />
|
|
<el-table-column prop="brand" label="品牌" align="center" />
|
|
<el-table-column prop="model" label="规格型号" align="center" />
|
|
<el-table-column prop="model" label="规格型号" align="center" />
|
|
<el-table-column prop="warehouse" label="存放仓库" align="center" />
|
|
<el-table-column prop="warehouse" label="存放仓库" align="center" />
|
|
- <el-table-column prop="status" label="状态" align="center" v-if="['已领取', '已归还','已借出'].includes(form.status_label)">
|
|
|
|
|
|
+ <el-table-column prop="status" label="状态" align="center">
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
- <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>
|
|
|
|
|
|
+ {{ row.return_status.label }}
|
|
|
|
+ <!-- <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> -->
|
|
<!-- <span v-else>{{ form.status_label }}</span> -->
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
+ <el-table-column prop="status" label="归还时间" align="center">
|
|
|
|
+ <template #default="{ row }">
|
|
|
|
+ {{ row.return_time ? dayjs(row.return_time).format('YYYY-MM-DD HH:mm:ss') : (row.return_status?.label === '已归还' ? dayjs().format('YYYY-MM-DD HH:mm:ss') : '') }}
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
<el-table-column label="操作" width="150" align="center">
|
|
<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==0" @click="handleAbnormal($index)">异常操作</el-button>
|
|
|
|
|
|
+ <template #default="{ $index,row }">
|
|
|
|
+
|
|
|
|
+ <el-button :disabled="isView" type="text" style="color: red"
|
|
|
|
+ v-if="!isView && (!returnDeviceList[$index]?.condition || returnDeviceList[$index]?.photos?.length==0)&& row.problem_records?.length ==0"
|
|
|
|
+ @click="handleAbnormal($index)">异常操作</el-button>
|
|
<el-button
|
|
<el-button
|
|
- :disabled="isView"
|
|
|
|
|
|
+
|
|
type="text"
|
|
type="text"
|
|
style="color: #409EFF"
|
|
style="color: #409EFF"
|
|
@click="handleViewAbnormal($index)"
|
|
@click="handleViewAbnormal($index)"
|
|
- v-if="returnDeviceList[$index]?.condition || returnDeviceList[$index]?.photos?.length"
|
|
|
|
|
|
+ v-if="row.problem_records?.length || (returnDeviceList[$index]?.condition || returnDeviceList[$index]?.photos?.length)"
|
|
>查看异常</el-button>
|
|
>查看异常</el-button>
|
|
- <el-button type="text" :disabled="isView" style="color: red" @click="handleReturnRemove($index)">移除</el-button>
|
|
|
|
|
|
+ <!-- <el-button type="text" v-if="!isView" :disabled="isView" style="color: red" @click="handleReturnRemove($index)">移除</el-button> -->
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-table>
|
|
@@ -289,8 +298,10 @@
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|
|
<div style="font-weight: bold; margin-bottom: 8px">当前状态</div>
|
|
<div style="font-weight: bold; margin-bottom: 8px">当前状态</div>
|
|
- <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-input v-model="returnStatus" v-if="!isView" :disabled="true" placeholder="" style="width: 150px" />
|
|
|
|
+ <el-input value="已归还" v-else :disabled="true" placeholder="" style="width: 150px" />
|
|
|
|
+ <el-button type="primary" v-if="!isView" style="margin-left: 16px" @click="clickReturn"
|
|
|
|
+ :disabled="returnStatus=='已归还'||isView">归还</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24" style="margin-top: 16px">
|
|
<el-col :span="24" style="margin-top: 16px">
|
|
<div style="font-weight: bold; margin-bottom: 8px">备注</div>
|
|
<div style="font-weight: bold; margin-bottom: 8px">备注</div>
|
|
@@ -332,7 +343,11 @@
|
|
<el-button type="primary" @click="onSubmit" v-if="!isView"> {{ isCollect ? '提交' : '确认' }}</el-button>
|
|
<el-button type="primary" @click="onSubmit" v-if="!isView"> {{ isCollect ? '提交' : '确认' }}</el-button>
|
|
</template>
|
|
</template>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
- <SelectDeviceDialog v-model:visible="showSelectDeviceDialog" @confirm="onDeviceSelected" />
|
|
|
|
|
|
+ <SelectDeviceDialog
|
|
|
|
+ v-model:visible="showSelectDeviceDialog"
|
|
|
|
+ @confirm="onDeviceSelected"
|
|
|
|
+ :device-ids="returnDeviceList.filter(item => item.return_status.label !== '已归还').map(item => item.device_no)"
|
|
|
|
+/>
|
|
<SettlementDialog v-model:visible="showSettlementDialog" :settlement-data="settlementData" />
|
|
<SettlementDialog v-model:visible="showSettlementDialog" :settlement-data="settlementData" />
|
|
<AbnormalDialog v-model:visible="showAbnormalDialog" @confirm="onAbnormalConfirm" />
|
|
<AbnormalDialog v-model:visible="showAbnormalDialog" @confirm="onAbnormalConfirm" />
|
|
<ViewAbnormalDialog
|
|
<ViewAbnormalDialog
|
|
@@ -546,11 +561,19 @@ const onAbnormalConfirm = (data: { condition: string; photos: any[] }) => {
|
|
// 处理查看异常
|
|
// 处理查看异常
|
|
const handleViewAbnormal = (index: number) => {
|
|
const handleViewAbnormal = (index: number) => {
|
|
const device = returnDeviceList.value[index];
|
|
const device = returnDeviceList.value[index];
|
|
|
|
+ console.log("device:::",device);
|
|
if (device) {
|
|
if (device) {
|
|
- currentAbnormalData.value = {
|
|
|
|
- condition: device.condition || '',
|
|
|
|
- photos: device.photos || []
|
|
|
|
- };
|
|
|
|
|
|
+ if(device.problem_records?.length){
|
|
|
|
+ currentAbnormalData.value = {
|
|
|
|
+ condition: device.problem_records?.[0].device_condition_after ||'',
|
|
|
|
+ photos: device.problem_records?.[0].returned_images.map((item:any)=>item.image_url) ||[]
|
|
|
|
+ };
|
|
|
|
+ }else{
|
|
|
|
+ currentAbnormalData.value = {
|
|
|
|
+ condition: device.condition ||'',
|
|
|
|
+ photos: device.photos ||[]
|
|
|
|
+ };
|
|
|
|
+ }
|
|
showViewAbnormalDialog.value = true;
|
|
showViewAbnormalDialog.value = true;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -633,7 +656,8 @@ const handleReturnScanSearch = async () => {
|
|
brand: device.brand || '',
|
|
brand: device.brand || '',
|
|
model: device.model || '',
|
|
model: device.model || '',
|
|
warehouse: device.warehouse,
|
|
warehouse: device.warehouse,
|
|
- status: '已归还'
|
|
|
|
|
|
+ return_status:device.return_status,
|
|
|
|
+ return_time:device.return_times
|
|
});
|
|
});
|
|
ElMessage.success('设备已添加到列表');
|
|
ElMessage.success('设备已添加到列表');
|
|
}
|
|
}
|
|
@@ -723,7 +747,10 @@ function onDeviceSelected(devices: Device[]) {
|
|
const existingDeviceIndex = returnDeviceList.value.findIndex(item => item.device_no === d.id);
|
|
const existingDeviceIndex = returnDeviceList.value.findIndex(item => item.device_no === d.id);
|
|
if (existingDeviceIndex !== -1) {
|
|
if (existingDeviceIndex !== -1) {
|
|
// 如果设备已存在,更新其状态
|
|
// 如果设备已存在,更新其状态
|
|
- returnDeviceList.value[existingDeviceIndex].status = '已归还';
|
|
|
|
|
|
+ returnDeviceList.value[existingDeviceIndex].return_status.value = 2;
|
|
|
|
+ returnDeviceList.value[existingDeviceIndex].return_status.label = '已归还';
|
|
|
|
+ returnDeviceList.value[existingDeviceIndex].is_return = true;
|
|
|
|
+ returnDeviceList.value[existingDeviceIndex].return_time = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
ElMessage.success(`设备 ${d.category_name} 状态已更新为已归还`);
|
|
ElMessage.success(`设备 ${d.category_name} 状态已更新为已归还`);
|
|
} else {
|
|
} else {
|
|
// 如果设备不存在,添加新记录
|
|
// 如果设备不存在,添加新记录
|
|
@@ -880,7 +907,10 @@ watch(() => props.modelValue, async (val) => {
|
|
brand: '',
|
|
brand: '',
|
|
model: item.device_specification,
|
|
model: item.device_specification,
|
|
warehouse: item.location,
|
|
warehouse: item.location,
|
|
- status: '未归还'
|
|
|
|
|
|
+ problem_records: item.problem_records,
|
|
|
|
+ /* status: '未归还' */
|
|
|
|
+ return_status:item.return_status,
|
|
|
|
+ return_time:item.return_times
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
// 同步 form.records 到 returnAbnormalList
|
|
// 同步 form.records 到 returnAbnormalList
|
|
@@ -933,7 +963,9 @@ watch(() => props.modelValue, async (val) => {
|
|
brand: '',
|
|
brand: '',
|
|
model: item.device_specification,
|
|
model: item.device_specification,
|
|
warehouse: item.location,
|
|
warehouse: item.location,
|
|
- status: '未归还'
|
|
|
|
|
|
+ problem_records: item.problem_records,
|
|
|
|
+ return_status:item.return_status,
|
|
|
|
+ return_time:item.return_times
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1085,14 +1117,16 @@ function onSubmit() {
|
|
} else {
|
|
} else {
|
|
// 归还逻辑修改
|
|
// 归还逻辑修改
|
|
// 使用所有设备列表而不是选中的设备
|
|
// 使用所有设备列表而不是选中的设备
|
|
- const allDevices = returnDeviceList.value.map(item => ({
|
|
|
|
|
|
+ const allDevices = returnDeviceList.value
|
|
|
|
+ .filter(item => item.is_return === true) // 只选择 return_status 为 2 的设备
|
|
|
|
+ .map(item => ({
|
|
device: item.device_no,
|
|
device: item.device_no,
|
|
quantity: item.borrow_count,
|
|
quantity: item.borrow_count,
|
|
remark: returnRemark.value,
|
|
remark: returnRemark.value,
|
|
device_id: Number(item.device_no) || 0,
|
|
device_id: Number(item.device_no) || 0,
|
|
// 添加异常相关字段
|
|
// 添加异常相关字段
|
|
condition: item.condition, // 异常说明
|
|
condition: item.condition, // 异常说明
|
|
- photos: item.photos || [], // 异常照片
|
|
|
|
|
|
+ photo_urls: item.photos || [], // 异常照片
|
|
}));
|
|
}));
|
|
|
|
|
|
const submitData = {
|
|
const submitData = {
|