|
@@ -4,14 +4,20 @@
|
|
|
<div style="font-weight: bold; font-size: 18px; margin-bottom: 8px">课程信息</div>
|
|
|
<el-row :gutter="8" style="margin-bottom: 8px; align-items: center">
|
|
|
<el-col :span="6">
|
|
|
- <el-select v-model="form.course_name" placeholder="请选择课程">
|
|
|
- <el-option label="广告配音艺术" value="广告配音艺术" />
|
|
|
- <!-- 这里可动态加载课程列表 -->
|
|
|
+ <el-select v-model="form.purpose" placeholder="请选择课程" @change="onCourseChange">
|
|
|
+ <el-option
|
|
|
+ v-for="course in weeklyCourses"
|
|
|
+ :key="course.id"
|
|
|
+ :label="`${course.classdetail} - ${course.teacher_name}`"
|
|
|
+ :value="course.classdetail"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-col>
|
|
|
- <el-col :span="3">
|
|
|
+
|
|
|
+
|
|
|
+ <!-- <el-col :span="3">
|
|
|
<el-button>手动输入</el-button>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
<el-col :span="6">
|
|
|
<el-input v-model="form.course_input" placeholder="请输入课程名称" />
|
|
|
</el-col>
|
|
@@ -19,10 +25,9 @@
|
|
|
<el-button type="primary">搜索</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <el-table :data="courseTableData" border style="width: 100%; margin-bottom: 12px">
|
|
|
- <el-table-column prop="date" label="日期" />
|
|
|
- <el-table-column v-for="col in courseTableCols" :key="col" :prop="col" :label="col" />
|
|
|
- </el-table>
|
|
|
+ <div style="max-height: 400px; overflow-y: auto; border: 1px solid #eee; padding: 8px; margin-bottom:0px">
|
|
|
+ <timetablemanage />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<el-form :model="form" label-width="110px" label-position="top" :rules="rules" ref="formRef">
|
|
|
<el-row :gutter="16">
|
|
@@ -32,23 +37,23 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="借用人" prop="borrower_name">
|
|
|
- <el-input v-model="form.borrower_name" placeholder="请输入借用人" disabled />
|
|
|
+ <el-form-item label="借用人" prop="emergency_contact">
|
|
|
+ <el-input v-model="form.emergency_contact" placeholder="请输入借用人" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="学号/工号" prop="user_code">
|
|
|
- <el-input v-model="form.user_code" placeholder="请输入学号/工号" disabled />
|
|
|
+ <el-form-item label="学号/工号" prop="app_user_borrower">
|
|
|
+ <el-input v-model="form.app_user_borrower" placeholder="请输入学号/工号" />
|
|
|
</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 />
|
|
|
+ <el-input v-model="form.emergency_phone" placeholder="请输入联系电话" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="信用部门" prop="borrower_dept">
|
|
|
- <el-input v-model="form.borrower_dept" placeholder="请输入信用部门" disabled />
|
|
|
+ <el-input v-model="form.borrower_dept" placeholder="请输入信用部门" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="4">
|
|
@@ -66,11 +71,16 @@
|
|
|
<el-input v-model="form.applicant_remark" placeholder="请输入备注" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="预计归还时间" prop="expected_end_time">
|
|
|
+ <el-date-picker v-model="form.expected_end_time" type="datetime" placeholder="请选择预计归还时间" style="width: 100%" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
<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="device_name" label="设备分类" />
|
|
|
+ <el-table-column prop="remark" label="设备分类" />
|
|
|
<el-table-column prop="quantity" label="借用数量" />
|
|
|
<el-table-column prop="location" label="存放仓库" />
|
|
|
<el-table-column label="操作" width="80">
|
|
@@ -95,48 +105,108 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { ref, watch, defineProps, defineEmits, onMounted, computed } from 'vue';
|
|
|
-import SelectDeviceDialog from '../CommonBorrow/SelectDeviceDialog/index.vue';
|
|
|
+import SelectDeviceDialog from '../SpecialBorrow/SelectDeviceDialog/index.vue';
|
|
|
+import timetablemanage from '../../../timetablemanage/index.vue';
|
|
|
+import * as apis from '../../../timetablemanage/api';
|
|
|
+import { provide } from 'vue';
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+
|
|
|
+
|
|
|
+provide('isEmbedded', true);
|
|
|
+provide('onCourseSelected', handleCourseSelected);
|
|
|
+
|
|
|
const props = defineProps<{ visible: boolean; modelValue?: any }>();
|
|
|
const emit = defineEmits(['update:visible', 'update:modelValue', 'submit']);
|
|
|
const visible = ref(props.visible);
|
|
|
const formRef = ref();
|
|
|
|
|
|
+
|
|
|
+function handleCourseSelected({ course_name, expected_start_time }) {
|
|
|
+ form.value.purpose = course_name;
|
|
|
+ form.value.expected_start_time = expected_start_time;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const weeklyCourses = ref<any[]>([]);
|
|
|
+
|
|
|
+async function fetchWeeklySchedule() {
|
|
|
+ const res = await apis.GetCurrentWeekList();
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ // console.log("res.data:::",res.data)
|
|
|
+ const schedule = res.data.schedule;
|
|
|
+
|
|
|
+ const courseMap = new Map<string, any>();
|
|
|
+
|
|
|
+ for (const dayKey in schedule) {
|
|
|
+ const daySchedule = schedule[dayKey];
|
|
|
+ for (const timeKey in daySchedule) {
|
|
|
+ const courses = daySchedule[timeKey];
|
|
|
+ for (const course of courses) {
|
|
|
+ if (!courseMap.has(course.classdetail)) {
|
|
|
+ courseMap.set(course.classdetail, course);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ weeklyCourses.value = Array.from(courseMap.values());
|
|
|
+}
|
|
|
+
|
|
|
+function onCourseChange(selectedName: string) {
|
|
|
+ const selectedCourse = weeklyCourses.value.find(c => c.classdetail === selectedName);
|
|
|
+ if (selectedCourse) {
|
|
|
+ form.value.expected_start_time = `${selectedCourse.class_date} ${getStartTime(selectedCourse.time)}`;
|
|
|
+ form.value.teacher_name = selectedCourse.teacher_name;
|
|
|
+ form.value.classroom = selectedCourse.classroom;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getStartTime(time: number): string {
|
|
|
+ const timeMap = {
|
|
|
+ 1: '09:00',
|
|
|
+ 2: '14:00',
|
|
|
+ 3: '19:00'
|
|
|
+ };
|
|
|
+ return timeMap[time] || '09:00';
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
const form = ref({
|
|
|
application_no: '',
|
|
|
- borrower_name: '',
|
|
|
+ emergency_contact: '',
|
|
|
+ purpose:'',
|
|
|
emergency_phone: '',
|
|
|
- user_code: '',
|
|
|
+ app_user_borrower: 1,
|
|
|
borrower_dept: '',
|
|
|
- team_members_count: '',
|
|
|
+ team_type: 1,
|
|
|
+ team_members_count: 1,
|
|
|
team_members: '',
|
|
|
+ expected_start_time:'',
|
|
|
+ expected_end_time: "",
|
|
|
applicant_remark: '',
|
|
|
+ return_location:'',
|
|
|
items: [],
|
|
|
- course_name: '',
|
|
|
+ borrow_type:1,
|
|
|
course_input: '',
|
|
|
});
|
|
|
const showSelectDeviceDialog = ref(false);
|
|
|
const isViewMode = computed(() => props.modelValue?.mode === 'view');
|
|
|
-// 课程表模拟数据
|
|
|
-const courseTableCols = ['08:00-08:45', '08:55-09:40', '09:50-10:35', '10:45-11:30', '11:40-12:25'];
|
|
|
-const courseTableData = [
|
|
|
- { date: '周一', '08:00-08:45': '', '08:55-09:40': '', '09:50-10:35': '', '10:45-11:30': '', '11:40-12:25': '' },
|
|
|
- { date: '周二', '08:00-08:45': '', '08:55-09:40': '', '09:50-10:35': '', '10:45-11:30': '', '11:40-12:25': '' },
|
|
|
- { date: '周三', '08:00-08:45': '', '08:55-09:40': '', '09:50-10:35': '', '10:45-11:30': '', '11:40-12:25': '' },
|
|
|
- { date: '周四', '08:00-08:45': '', '08:55-09:40': '', '09:50-10:35': '', '10:45-11:30': '', '11:40-12:25': '' },
|
|
|
- { date: '周五', '08:00-08:45': '', '08:55-09:40': '', '09:50-10:35': '', '10:45-11:30': '', '11:40-12:25': '' },
|
|
|
-];
|
|
|
-
|
|
|
-// 自动填充用户信息
|
|
|
+
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
try {
|
|
|
const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
|
|
|
if (userInfo) {
|
|
|
- form.value.borrower_name = userInfo.username || '';
|
|
|
- form.value.user_code = userInfo.dept_info?.dept_id || '';
|
|
|
+ form.value.emergency_contact = userInfo.username || '';
|
|
|
+ form.value.app_user_borrower = Number(userInfo.dept_info?.dept_id )|| 1;
|
|
|
form.value.emergency_phone = userInfo.mobile || '';
|
|
|
form.value.borrower_dept = userInfo.dept_info?.dept_name || '';
|
|
|
}
|
|
|
- } catch (e) {}
|
|
|
+ } catch (e) {console.error(e)}
|
|
|
+ fetchWeeklySchedule();
|
|
|
});
|
|
|
|
|
|
watch(
|
|
@@ -157,9 +227,9 @@ function onDeviceSelected(devices) {
|
|
|
form.value.items.push(
|
|
|
...devices.map((d) => ({
|
|
|
device: d.id,
|
|
|
- device_name: d.name,
|
|
|
+ remark: d.category_name,
|
|
|
quantity: 1,
|
|
|
- location: d.location,
|
|
|
+ location: d.warehouse,
|
|
|
}))
|
|
|
);
|
|
|
}
|
|
@@ -169,11 +239,19 @@ function removeItem(index) {
|
|
|
function onCancel() {
|
|
|
emit('update:visible', false);
|
|
|
}
|
|
|
+
|
|
|
+const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
|
function onSave() {
|
|
|
formRef.value.validate((valid) => {
|
|
|
if (valid) {
|
|
|
+ const firstLocation = form.value.items[0]?.location || '';
|
|
|
+ form.value.return_location = firstLocation;
|
|
|
+ // form.value.expected_start_time = now;
|
|
|
+ form.value.expected_end_time = dayjs(form.value.expected_end_time).format('YYYY-MM-DD HH:mm:ss')|| now;
|
|
|
+ form.value.team_members_count=Number(form.team_members_count)||1;
|
|
|
emit('submit', { ...form.value });
|
|
|
emit('update:visible', false);
|
|
|
+ ElMessage.success("添加成功!");
|
|
|
}
|
|
|
});
|
|
|
}
|