|
@@ -10,18 +10,41 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="借用人" prop="emergency_contact">
|
|
|
- <el-input v-model="form.emergency_contact" placeholder="请输入借用人" :disabled="true" />
|
|
|
- </el-form-item>
|
|
|
+ <el-form-item label="借用人类型" prop="borrower_type">
|
|
|
+ <el-select v-model="form.borrower_type" placeholder="请选择借用人角色" :disabled="true">
|
|
|
+ <el-option label="管理员用户" :value=0 />
|
|
|
+ <el-option label="应用用户" :value=1 />
|
|
|
+ <el-option label="外部用户" :value=2 />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8" >
|
|
|
+ <!-- <el-form-item label="借用人" prop="external_borrower_name" v-if="form.borrower_type !== 2">
|
|
|
+ <el-input v-model="form.borrower_info.name" placeholder="请输入借用人" :disabled="true" />
|
|
|
+ </el-form-item> -->
|
|
|
+ <el-form-item label="借用人" prop="admin_borrower" v-if="form.borrower_type == 0">
|
|
|
+ <el-select v-model="form.admin_borrower" placeholder="请选择借用人" :disabled="true" >
|
|
|
+ <el-option :label="adminList.name" :value="adminList.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="借用人" prop="app_user_borrower" v-if="form.borrower_type == 1">
|
|
|
+ <el-select v-model="form.app_user_borrower.id" placeholder="请选择借用人" :disabled="true" >
|
|
|
+ <el-option v-for="item in allUserList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="借用人" prop="external_borrower_name" v-if="form.borrower_type == 2">
|
|
|
+ <el-input v-model="form.external_borrower_name" placeholder="请输入借用人" :disabled="true" />
|
|
|
+ </el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="学号/工号" prop="app_user_borrower">
|
|
|
- <el-input v-model="form.app_user_borrower" placeholder="请输入学号/工号" :disabled="true"/>
|
|
|
+ <el-form-item label="学号/工号" prop="user_code">
|
|
|
+ <!-- {{ form.borrower_info.user_code }} -->
|
|
|
+ <el-input v-model="form.app_user_borrower.user_code" placeholder="请输入学号/工号" :disabled="true"/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="联系电话" prop="emergency_phone">
|
|
|
- <el-input v-model="form.emergency_phone" placeholder="请输入联系电话" :disabled="true" />
|
|
|
+ <el-form-item label="联系电话" >
|
|
|
+ <el-input v-model="form.app_user_borrower.mobile" placeholder="请输入联系电话" :disabled="true" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
@@ -71,7 +94,7 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<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 :data="form.items.filter(item => item.device === null)" border style="width: 100%; margin-bottom: 12px">
|
|
|
<el-table-column type="index" label="序号" width="60" />
|
|
|
<el-table-column prop="device_category_name" label="设备分类" />
|
|
|
<!-- <el-table-column prop="quantity" label="借用数量" /> -->
|
|
@@ -327,6 +350,29 @@ import * as api from '../../api';
|
|
|
import * as deviceApi from '../../../device/api';
|
|
|
import { CollectEquipment, ReturnEquipment } from '../../api';
|
|
|
import type { TabsPaneContext } from 'element-plus';
|
|
|
+import { getUserInfo } from '../../../login/api';
|
|
|
+
|
|
|
+
|
|
|
+/* 获取管理员列表 */
|
|
|
+const adminList = ref([]);
|
|
|
+
|
|
|
+async function getAdminList() {
|
|
|
+ const res = await getUserInfo();
|
|
|
+ adminList.value = res.data;
|
|
|
+ console.log("adminList.value:::",adminList.value)
|
|
|
+}
|
|
|
+/* */
|
|
|
+/* 获取所有用户 */
|
|
|
+const allUserList = ref([]);
|
|
|
+async function getAllUserList() {
|
|
|
+ const res = await api.GetAllUser();
|
|
|
+ allUserList.value = res.data;
|
|
|
+ // 设置默认选择第一个用户
|
|
|
+ if (allUserList.value.length > 0) {
|
|
|
+ form.value.app_user_borrower = allUserList.value[0].id;
|
|
|
+ }
|
|
|
+ console.log("allUserList.value:::",allUserList.value)
|
|
|
+}
|
|
|
|
|
|
interface ApiResponse {
|
|
|
code: number;
|
|
@@ -725,6 +771,10 @@ function handleUploadError(err: any, file: any, fileList: any) {
|
|
|
|
|
|
|
|
|
const form = ref<FormData>({
|
|
|
+ borrower_info:{
|
|
|
+ user_code:'',
|
|
|
+ mobile:''
|
|
|
+ },
|
|
|
application_no: '',
|
|
|
emergency_contact: '',
|
|
|
emergency_phone: '',
|
|
@@ -779,6 +829,8 @@ const rules = {
|
|
|
|
|
|
// 自动填充用户信息
|
|
|
onMounted(() => {
|
|
|
+ getAdminList()
|
|
|
+ getAllUserList()
|
|
|
try {
|
|
|
const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
|
|
|
if (userInfo) {
|
|
@@ -798,8 +850,6 @@ watch(
|
|
|
);
|
|
|
|
|
|
watch(() => props.modelValue, async (val) => {
|
|
|
- console.log("props:::",props.modelValue);
|
|
|
- console.log("val:::", isView.value);
|
|
|
if (val && val.id) {
|
|
|
try {
|
|
|
const res = await api.GetApplicationDetail(val.id);
|
|
@@ -817,25 +867,27 @@ watch(() => props.modelValue, async (val) => {
|
|
|
|
|
|
// 同步 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: '未归还'
|
|
|
- }));
|
|
|
+ returnDeviceList.value = form.value.items
|
|
|
+ .filter(item => item.device !== null)
|
|
|
+ .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,
|
|
|
+ operator_name: form.value.emergency_contact||form.value.app_user_borrower.name,
|
|
|
+ user_code: form.value.borrower_info?.user_code || form.value.app_user_borrower.user_code,
|
|
|
+ emergency_phone: form.value.emergency_phone || form.value.app_user_borrower.mobile,
|
|
|
type: '损坏',
|
|
|
condition: form.value.borrower_damage_count || 0,
|
|
|
create_time: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
@@ -844,9 +896,9 @@ watch(() => props.modelValue, async (val) => {
|
|
|
// 添加逾期类型记录
|
|
|
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,
|
|
|
+ operator_name: form.value.emergency_contact||form.value.app_user_borrower.name,
|
|
|
+ user_code: form.value.borrower_info?.user_code || form.value.app_user_borrower.user_code,
|
|
|
+ emergency_phone: form.value.emergency_phone || form.value.app_user_borrower.mobile,
|
|
|
type: '逾期',
|
|
|
condition: form.value.borrower_overdue_count || 0, // 逾期数量设为1
|
|
|
create_time: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
@@ -868,16 +920,18 @@ watch(() => props.modelValue, async (val) => {
|
|
|
|
|
|
// 同步 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: '未归还'
|
|
|
- }));
|
|
|
+ returnDeviceList.value = form.value.items
|
|
|
+ .filter(item => item.device !== null)
|
|
|
+ .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) {
|
|
@@ -897,7 +951,16 @@ watch(() => props.modelValue, async (val) => {
|
|
|
// }
|
|
|
// }, { immediate: true }
|
|
|
// );
|
|
|
-
|
|
|
+// 监听借用人选择变化
|
|
|
+watch(() => form.value.app_user_borrower, (newValue) => {
|
|
|
+ if (newValue && allUserList.value.length > 0) {
|
|
|
+ const selectedUser = allUserList.value.find(user => user.id === newValue);
|
|
|
+ if (selectedUser) {
|
|
|
+ form.value.user_code = selectedUser.user_code || '';
|
|
|
+ form.value.mobile = selectedUser.mobile || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
function addItem() {
|
|
|
showSelectDeviceDialog.value = true;
|
|
|
}
|
|
@@ -1023,7 +1086,8 @@ function onSubmit() {
|
|
|
device: item.device_no,
|
|
|
quantity: item.borrow_count,
|
|
|
condition: returnRemark.value,
|
|
|
- device_id: Number(item.device_no) || 0
|
|
|
+ device_id: Number(item.device_no) || 0,
|
|
|
+
|
|
|
}));
|
|
|
|
|
|
const submitData = {
|