You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1026 lines
32 KiB
1026 lines
32 KiB
<template>
|
|
<div class="schedule-container">
|
|
<!-- 左侧:QC人员清单 -->
|
|
<div class="left-panel">
|
|
<div class="panel-title">
|
|
<span>QC人员清单</span>
|
|
<el-button
|
|
type="text"
|
|
size="mini"
|
|
icon="el-icon-view"
|
|
style="float: right; margin-top: -2px;"
|
|
@click="showAllQcSchedule">查看全部</el-button>
|
|
</div>
|
|
<el-table
|
|
:data="qcList"
|
|
border
|
|
size="mini"
|
|
highlight-current-row
|
|
ref="qcTable"
|
|
@current-change="handleQcSelect"
|
|
@row-click="handleQcSelect"
|
|
style="width: 100%;"
|
|
:max-height="qcTableHeight"
|
|
class="qc-table">
|
|
<el-table-column prop="qcName" label="姓名" width="125" align="center" />
|
|
<!-- <el-table-column prop="region" label="负责区域" min-width="90" show-overflow-tooltip />-->
|
|
<el-table-column label="操作" width="125" align="center" fixed="right">
|
|
<template slot-scope="scope">
|
|
<!-- 只有当主表选中了数据且状态为已下达或已排程时才显示排程按钮 -->
|
|
<el-link
|
|
v-if="hasSelectedData && (currentStatusDb === 'Audited' || currentStatusDb === 'Scheduled')"
|
|
type="primary"
|
|
style="cursor: pointer;"
|
|
@click.stop="openScheduleDialog(null, scope.row)">{{ currentStatusDb === 'Scheduled' ? '修改' : '排程' }}</el-link>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
|
|
<!-- 右侧:排程卡片(始终显示) -->
|
|
<div class="right-panel">
|
|
<div class="panel-title">
|
|
<span v-if="selectedQc">{{ selectedQc.qcName }} - 排程视图(未来20天)</span>
|
|
<span v-else>查看排程</span>
|
|
<!-- 日期前后滚动:与“所有QC排程情况”弹窗风格一致 - rqrq -->
|
|
<div v-if="selectedQc" class="date-shift-group" style="float: right;">
|
|
<el-date-picker
|
|
v-model="scheduleStartDate"
|
|
type="date"
|
|
value-format="yyyy-MM-dd"
|
|
size="small"
|
|
placeholder="请选择起始日期"
|
|
style="width: 150px;"
|
|
@change="onScheduleDateChange" />
|
|
<el-button-group class="date-shift-buttons">
|
|
<el-button icon="el-icon-arrow-left" size="small" title="前一天" @click="shiftScheduleDate(-1)" />
|
|
<el-button icon="el-icon-arrow-right" size="small" title="后一天" @click="shiftScheduleDate(1)" />
|
|
</el-button-group>
|
|
</div>
|
|
</div>
|
|
<div class="schedule-grid" v-loading="loading">
|
|
<div v-for="day in scheduleDays" :key="day.date" class="schedule-card">
|
|
<div class="card-header">
|
|
<span class="date-label">{{ day.dateLabel }}</span>
|
|
<span class="date-weekday">{{ day.weekday }}</span>
|
|
</div>
|
|
<div class="card-body">
|
|
<div
|
|
v-for="task in day.tasks"
|
|
:key="task.requestNo"
|
|
:class="['task-item', { 'task-item--change-applying': isChangeApplyingTask(task) }]"
|
|
@click="handleTaskClick(task)">
|
|
<div class="task-line-text" :title="buildTaskLineText(task)">{{ buildTaskLineText(task) }}</div>
|
|
<!-- <div v-if="task.inspectAddress" class="task-address" :title="task.inspectAddress">
|
|
<i class="el-icon-location"></i> {{ task.inspectAddress }}
|
|
</div> -->
|
|
</div>
|
|
<div v-if="day.tasks.length === 0" class="empty-slot">
|
|
<span class="empty-text">暂无排程</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 排程弹窗 -->
|
|
<el-dialog
|
|
title="验货排程"
|
|
:visible.sync="scheduleDialogVisible"
|
|
width="500px"
|
|
:close-on-click-modal="false"
|
|
append-to-body>
|
|
<el-form :model="scheduleForm" :rules="scheduleRules" ref="scheduleForm" size="small" label-position="top">
|
|
<el-row :gutter="10">
|
|
<el-col :span="8">
|
|
<el-form-item label="QC人员:">
|
|
<el-input v-model="scheduleForm.qcOperator" disabled></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="16">
|
|
<el-form-item label="QC联系方式:">
|
|
<el-input v-model="scheduleForm.qcContact" clearable placeholder="按所选QC自动带出,可修改"></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-form-item label="计划验货日期:" prop="planStartDate">
|
|
<div style="display: flex; align-items: center; width: 100%;">
|
|
<el-date-picker v-model="scheduleForm.planStartDate" type="date" placeholder="选择开始日期" value-format="yyyy-MM-dd" style="flex: 1;"></el-date-picker>
|
|
<span style="margin: 0 10px;">-</span>
|
|
<el-date-picker v-model="scheduleForm.planEndDate" type="date" placeholder="选择结束日期" value-format="yyyy-MM-dd" style="flex: 1;"></el-date-picker>
|
|
</div>
|
|
</el-form-item>
|
|
<el-form-item label="备注:">
|
|
<el-input v-model="scheduleForm.remark" type="textarea" :rows="3" placeholder="请输入备注"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button type="primary" size="small" @click="submitSchedule" :loading="loading">保存</el-button>
|
|
<el-button size="small" @click="cancelSchedule">关闭</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
|
|
<!-- 所有QC排程查看弹窗 -->
|
|
<el-dialog
|
|
title="所有QC排程情况"
|
|
:visible.sync="allQcScheduleDialogVisible"
|
|
width="80%"
|
|
:close-on-click-modal="false"
|
|
append-to-body
|
|
top="5vh">
|
|
<el-form :inline="true" size="small" label-position="top" class="all-qc-query-form">
|
|
<el-form-item label="起始日期">
|
|
<div class="date-shift-group">
|
|
<el-date-picker
|
|
v-model="allQcQuery.startDate"
|
|
type="date"
|
|
value-format="yyyy-MM-dd"
|
|
placeholder="请选择起始日期"
|
|
style="width: 150px;" />
|
|
<el-button-group class="date-shift-buttons">
|
|
<el-button icon="el-icon-arrow-left" size="small" title="前一天" @click="shiftAllQcStartDate(-1)" />
|
|
<el-button icon="el-icon-arrow-right" size="small" title="后一天" @click="shiftAllQcStartDate(1)" />
|
|
</el-button-group>
|
|
</div>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div class="all-qc-schedule-container" v-loading="allQcLoading">
|
|
<div class="schedule-days-grid">
|
|
<div v-for="day in allScheduleDays" :key="day.date" class="schedule-day-card">
|
|
<div class="day-header">
|
|
<span class="date-label">{{ day.dateLabel }}</span>
|
|
<span class="date-weekday">{{ day.weekday }}</span>
|
|
</div>
|
|
<div class="day-body">
|
|
<div
|
|
v-for="qcTask in day.qcTasks"
|
|
:key="qcTask.userName"
|
|
class="qc-task-item">
|
|
<div class="task-list">
|
|
<div
|
|
v-for="task in qcTask.tasks"
|
|
:key="task.requestNo"
|
|
:class="['mini-task', { 'mini-task--change-applying': isChangeApplyingTask(task) }]"
|
|
@click="handleQcTaskClick({ ...task, qcName: qcTask.qcName, userName: qcTask.userName })">
|
|
<span class="task-line-text" :title="buildTaskLineText(task, qcTask.qcName)">{{ buildTaskLineText(task, qcTask.qcName) }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-if="day.qcTasks.length === 0" class="empty-day">
|
|
<span class="empty-text">暂无排程</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button size="small" @click="allQcScheduleDialogVisible = false">关闭</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { getQcPersonList, scheduleInspectionRequest, getScheduleView } from '@/api/inspection/inspectionRequestHeader.js'
|
|
|
|
export default {
|
|
name: 'InspectionScheduleView',
|
|
props: {
|
|
requestNos: { type: Array, default: () => [] },
|
|
currentRow: { type: Object, default: () => ({}) },
|
|
currentStatusDb: { type: String, default: '' }
|
|
},
|
|
data() {
|
|
return {
|
|
qcList: [],
|
|
selectedQc: null,
|
|
scheduleDays: [],
|
|
scheduleStartDate: '',
|
|
loading: false,
|
|
qcTableHeight: 500,
|
|
scheduleDialogVisible: false,
|
|
allQcScheduleDialogVisible: false,
|
|
allQcLoading: false,
|
|
allQcScheduleData: {}, // 存储所有QC的排程数据 { userName: [days] }
|
|
allScheduleDays: [], // 按日期组织的排程数据 [{ date, dateLabel, weekday, qcTasks: [...] }]
|
|
allQcQuery: {
|
|
startDate: ''
|
|
},
|
|
scheduleForm: {
|
|
qcOperator: '',
|
|
qcUserName: '',
|
|
qcContact: '',
|
|
planStartDate: '',
|
|
planEndDate: '',
|
|
remark: ''
|
|
},
|
|
scheduleRules: {
|
|
planStartDate: [{ required: true, message: '请选择开始日期', trigger: 'change' }]
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
// 判断主表是否选中了数据
|
|
hasSelectedData() {
|
|
return this.requestNos && this.requestNos.length > 0
|
|
}
|
|
},
|
|
watch: {
|
|
requestNos: {
|
|
handler() {
|
|
// 主表选中状态变化时,仍按当前选中QC刷新其排程视图(排程任务不依赖主表选择) - rqrq
|
|
if (this.selectedQc) {
|
|
this.loadScheduleData(this.selectedQc)
|
|
} else {
|
|
this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
|
|
}
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
console.log('[排程视图] 组件已挂载')
|
|
this.scheduleStartDate = this.getTodayDateString()
|
|
// 组件挂载时自动加载QC列表和排程数据
|
|
this.loadQcList()
|
|
// 计算QC表格高度
|
|
this.$nextTick(() => {
|
|
this.calculateQcTableHeight()
|
|
})
|
|
},
|
|
methods: {
|
|
// 计算QC表格高度
|
|
calculateQcTableHeight() {
|
|
// 计算10行数据的高度
|
|
// Element UI mini尺寸的表格,每行高度约为40px(包含边框)
|
|
const rowHeight = 40
|
|
const headerHeight = 45 // 表头高度
|
|
const rowCount = 10 // 显示10行数据
|
|
|
|
this.qcTableHeight = (rowHeight * rowCount) + headerHeight + 2 // 加2px用于边框
|
|
},
|
|
// 强制刷新当前选中的QC排程视图(供父组件调用)
|
|
forceRefresh() {
|
|
console.log('[排程视图] forceRefresh 被调用')
|
|
// 直接重新加载QC列表和排程数据;若“查看全部”弹窗打开,同步刷新弹窗数据 - rqrq
|
|
const loadPromise = this.loadQcList()
|
|
if (loadPromise && typeof loadPromise.finally === 'function') {
|
|
loadPromise.finally(() => {
|
|
if (this.allQcScheduleDialogVisible) {
|
|
this.loadAllQcSchedule()
|
|
}
|
|
})
|
|
} else if (this.allQcScheduleDialogVisible) {
|
|
this.loadAllQcSchedule()
|
|
}
|
|
},
|
|
loadQcList() {
|
|
console.log('[排程视图] 开始加载QC列表')
|
|
|
|
const params = {
|
|
page: 1,
|
|
limit: 100,
|
|
site: this.$store.state.user.site
|
|
}
|
|
return getQcPersonList(params)
|
|
.then(({ data }) => {
|
|
if (data.code === 0 && data.page && data.page.list) {
|
|
this.qcList = data.page.list.map(item => ({
|
|
id: item.id || item.userId,
|
|
qcName: item.userDisplay || item.userName,
|
|
userName: item.userName,
|
|
qcContact: item.userMobile || '',
|
|
region: ''
|
|
}))
|
|
console.log('[排程视图] QC列表加载成功:', this.qcList)
|
|
|
|
if (this.qcList.length) {
|
|
|
|
// 优先保持当前选中的QC,如果无效则选中第一个
|
|
if (
|
|
!this.selectedQc ||
|
|
!this.qcList.some(q => q.userName === this.selectedQc.userName)
|
|
) {
|
|
this.selectedQc = this.qcList[0]
|
|
}
|
|
|
|
// 只要选中了QC就加载其排程视图,与主表是否选中数据无关(排程任务按QC人员查询) - rqrq
|
|
this.loadScheduleData(this.selectedQc)
|
|
|
|
this.$nextTick(() => {
|
|
if (this.$refs.qcTable) {
|
|
this.$refs.qcTable.setCurrentRow(this.selectedQc)
|
|
}
|
|
})
|
|
} else {
|
|
this.selectedQc = null
|
|
this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
|
|
}
|
|
} else {
|
|
console.warn('[排程视图] 加载QC列表失败')
|
|
this.qcList = []
|
|
this.selectedQc = null
|
|
this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
|
|
}
|
|
})
|
|
.catch(err => {
|
|
console.error('[排程视图] 加载QC列表错误:', err)
|
|
this.qcList = []
|
|
this.selectedQc = null
|
|
this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
|
|
})
|
|
},
|
|
handleQcSelect(row) {
|
|
if (!row) return
|
|
this.selectedQc = row
|
|
// 选中QC即加载其排程视图,不依赖主表是否选中数据 - rqrq
|
|
this.loadScheduleData(row)
|
|
},
|
|
// 打开排程弹窗
|
|
openScheduleDialog(task, qcRow) {
|
|
this.scheduleForm = {
|
|
qcOperator: qcRow ? qcRow.userName : '',
|
|
qcUserName: qcRow ? qcRow.qcName : '',
|
|
qcContact: qcRow ? (qcRow.qcContact || '') : '',
|
|
planStartDate: '',
|
|
planEndDate: '',
|
|
remark: ''
|
|
}
|
|
|
|
// 如果是已排程状态,加载当前排程数据用于修改
|
|
if (this.currentStatusDb === 'Scheduled' && this.currentRow && this.currentRow.planStartDate) {
|
|
this.scheduleForm.planStartDate = this.currentRow.planStartDate || ''
|
|
this.scheduleForm.planEndDate = this.currentRow.planEndDate || this.currentRow.planStartDate || ''
|
|
this.scheduleForm.remark = this.currentRow.scheduleRemark || ''
|
|
// 仅当修改的是同一 QC 时才回显已保存的联系方式;换选其它 QC 则用其手机号自动带出的值,避免残留原 QC 联系方式 - rqrq
|
|
const savedQc = this.currentRow.qcOperator
|
|
const selectedQc = qcRow ? qcRow.userName : ''
|
|
if (savedQc && selectedQc && savedQc === selectedQc) {
|
|
this.scheduleForm.qcContact = this.currentRow.qcContact || this.scheduleForm.qcContact
|
|
}
|
|
}
|
|
|
|
this.scheduleDialogVisible = true
|
|
},
|
|
|
|
// 关闭排程弹窗
|
|
cancelSchedule() {
|
|
this.scheduleDialogVisible = false
|
|
},
|
|
|
|
// 提交排程
|
|
submitSchedule() {
|
|
this.$refs.scheduleForm.validate((valid) => {
|
|
if (!valid) return
|
|
if (!this.scheduleForm.planStartDate) {
|
|
this.$message.warning('请选择计划验货日期')
|
|
return
|
|
}
|
|
const params = {
|
|
requestNos: this.requestNos,
|
|
site: this.$store.state.user.site,
|
|
qcOperator: this.scheduleForm.qcOperator,
|
|
qcContact: this.scheduleForm.qcContact,
|
|
planStartDate: this.scheduleForm.planStartDate,
|
|
planEndDate: this.scheduleForm.planEndDate || this.scheduleForm.planStartDate,
|
|
remark: this.scheduleForm.remark
|
|
}
|
|
this.loading = true
|
|
scheduleInspectionRequest(params).then(({ data }) => {
|
|
if (data && data.code === 0) {
|
|
this.$message.success('排程成功')
|
|
this.scheduleDialogVisible = false
|
|
// 通知父组件刷新主表数据(会触发整页刷新)
|
|
this.$emit('schedule-success')
|
|
} else {
|
|
this.$message.error((data && data.msg) || '排程失败')
|
|
}
|
|
this.loading = false
|
|
}).catch((error) => {
|
|
console.error('排程失败:', error)
|
|
this.$message.error('排程失败')
|
|
this.loading = false
|
|
})
|
|
})
|
|
},
|
|
|
|
// 排程视图日期前后滚动:offset 为天数,滚动后重新加载当前 QC 排程 - rqrq
|
|
shiftScheduleDate (offset) {
|
|
const base = this.parseDateString(this.scheduleStartDate) || new Date()
|
|
const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + offset)
|
|
this.scheduleStartDate = this.formatDate(next)
|
|
if (this.selectedQc) {
|
|
this.loadScheduleData(this.selectedQc)
|
|
}
|
|
},
|
|
// 日期输入框手动选择后刷新排程视图 - rqrq
|
|
onScheduleDateChange () {
|
|
if (this.selectedQc && this.scheduleStartDate) {
|
|
this.loadScheduleData(this.selectedQc)
|
|
}
|
|
},
|
|
|
|
loadScheduleData(qc) {
|
|
console.log('======loadScheduleData======')
|
|
console.log('qc=', qc)
|
|
if (!qc) {
|
|
console.warn('[排程视图] loadScheduleData 参数为空')
|
|
this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
|
|
return
|
|
}
|
|
this.loading = true
|
|
console.log('[排程视图] 开始加载排程数据, QC:', qc.userName)
|
|
const startDate = this.scheduleStartDate || this.getTodayDateString()
|
|
getScheduleView(qc.userName, startDate, this.$store.state.user.site)
|
|
.then(({ data }) => {
|
|
if (data.code === 0) {
|
|
const days = this.generateNextDays(20, startDate)
|
|
const tasksByDate = {}
|
|
;(data.list || []).forEach(task => {
|
|
const taskStartDate = new Date(task.planStartDate)
|
|
const taskEndDate = new Date(task.planEndDate || task.planStartDate)
|
|
let currentDate = new Date(taskStartDate)
|
|
while (currentDate <= taskEndDate) {
|
|
const dateStr = this.formatDate(currentDate)
|
|
if (!tasksByDate[dateStr]) tasksByDate[dateStr] = []
|
|
const exists = tasksByDate[dateStr].some(t => t.requestNo === task.requestNo)
|
|
if (!exists) {
|
|
tasksByDate[dateStr].push({
|
|
requestNo: task.requestNo,
|
|
poNo: task.poNo,
|
|
supplierName: task.supplierName,
|
|
supplierShortOffice: task.supplierShortOffice || '',
|
|
qcDisplay: qc.qcName,
|
|
inspectAddress: task.inspectAddress,
|
|
inspectCityShort: task.inspectCityShort || '',
|
|
planStartDate: task.planStartDate,
|
|
planEndDate: task.planEndDate,
|
|
statusDb: task.statusDb || ''
|
|
})
|
|
}
|
|
currentDate.setDate(currentDate.getDate() + 1)
|
|
}
|
|
})
|
|
this.scheduleDays = days.map(day => ({
|
|
...day,
|
|
tasks: tasksByDate[day.date] || []
|
|
}))
|
|
console.log('scheduleDays=', this.scheduleDays)
|
|
|
|
console.log(
|
|
'任务总数=',
|
|
this.scheduleDays.reduce(
|
|
(sum, item) => sum + item.tasks.length,
|
|
0
|
|
)
|
|
)
|
|
console.log('[排程视图] 排程数据加载完成')
|
|
} else {
|
|
console.warn('[排程视图] 加载排程数据失败')
|
|
this.scheduleDays = this.generateNextDays(20, startDate)
|
|
}
|
|
})
|
|
.catch(err => {
|
|
console.error('[排程视图] 加载排程数据错误:', err)
|
|
this.scheduleDays = this.generateNextDays(20, startDate)
|
|
})
|
|
.finally(() => {
|
|
this.loading = false
|
|
})
|
|
},
|
|
generateNextDays(days, startDate) {
|
|
const result = []
|
|
const baseDate = this.parseDateString(startDate) || new Date()
|
|
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
|
|
for (let i = 0; i < days; i++) {
|
|
const date = new Date(baseDate)
|
|
date.setDate(baseDate.getDate() + i)
|
|
result.push({
|
|
date: this.formatDate(date),
|
|
dateLabel: `${date.getMonth() + 1}/${date.getDate()}`,
|
|
weekday: weekdays[date.getDay()],
|
|
tasks: []
|
|
})
|
|
}
|
|
return result
|
|
},
|
|
getTodayDateString() {
|
|
return this.formatDate(new Date())
|
|
},
|
|
parseDateString(dateStr) {
|
|
if (!dateStr) {
|
|
return null
|
|
}
|
|
const parts = String(dateStr).split('-')
|
|
if (parts.length !== 3) {
|
|
return null
|
|
}
|
|
const year = Number(parts[0])
|
|
const month = Number(parts[1]) - 1
|
|
const day = Number(parts[2])
|
|
const parsedDate = new Date(year, month, day)
|
|
if (Number.isNaN(parsedDate.getTime())) {
|
|
return null
|
|
}
|
|
return parsedDate
|
|
},
|
|
getShortOfficeDisplayName(shortOffice, supplierName) {
|
|
const value = shortOffice || supplierName || ''
|
|
return value.length > 30 ? value.substring(0, 30) : value
|
|
},
|
|
buildTaskLineText(task, qcDisplayName) {
|
|
const displayName = qcDisplayName || task.qcDisplay || (this.selectedQc ? this.selectedQc.qcName : '')
|
|
const supplierShortOffice = this.getShortOfficeDisplayName(task.supplierShortOffice, task.supplierName)
|
|
const inspectCityShort = task.inspectCityShort || ''
|
|
return [displayName, supplierShortOffice, inspectCityShort].filter(item => item).join(' | ')
|
|
},
|
|
// 申请变更中卡片高亮判断 - rqrq
|
|
isChangeApplyingTask (task) {
|
|
return !!(task && task.statusDb === 'ChangeApplying')
|
|
},
|
|
formatDate(date) {
|
|
const year = date.getFullYear()
|
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
|
const day = String(date.getDate()).padStart(2, '0')
|
|
return `${year}-${month}-${day}`
|
|
},
|
|
handleTaskClick(task) {
|
|
console.log('点击任务:', task)
|
|
this.$emit('task-click', task)
|
|
},
|
|
// 显示所有QC排程弹窗
|
|
showAllQcSchedule() {
|
|
this.allQcScheduleDialogVisible = true
|
|
this.allQcQuery.startDate = this.getTodayDateString()
|
|
this.loadAllQcSchedule()
|
|
},
|
|
// 按起始日期查询所有QC排程
|
|
queryAllQcSchedule() {
|
|
if (!this.allQcQuery.startDate) {
|
|
this.allQcQuery.startDate = this.getTodayDateString()
|
|
}
|
|
this.loadAllQcSchedule()
|
|
},
|
|
// 前后滚动“所有QC排程情况”起始日期:每次移动 1 天并刷新查询显示 - rqrq
|
|
shiftAllQcStartDate(offsetDays) {
|
|
const base = this.parseDateString(this.allQcQuery.startDate) || new Date()
|
|
const next = new Date(base)
|
|
next.setDate(base.getDate() + offsetDays)
|
|
this.allQcQuery.startDate = this.formatDate(next)
|
|
this.loadAllQcSchedule()
|
|
},
|
|
// 加载所有QC的排程数据
|
|
loadAllQcSchedule() {
|
|
if (!this.qcList || this.qcList.length === 0) {
|
|
this.$message.warning('暂无QC人员数据')
|
|
return
|
|
}
|
|
const startDate = this.allQcQuery.startDate || this.getTodayDateString()
|
|
this.allQcQuery.startDate = startDate
|
|
this.allQcLoading = true
|
|
const promises = this.qcList.map(qc => {
|
|
return getScheduleView(qc.userName, startDate, this.$store.state.user.site).then(({ data }) => {
|
|
if (data.code === 0) {
|
|
const days = this.generateNextDays(20, startDate)
|
|
const tasksByDate = {}
|
|
;(data.list || []).forEach(task => {
|
|
const taskStartDate = new Date(task.planStartDate)
|
|
const taskEndDate = new Date(task.planEndDate || task.planStartDate)
|
|
let currentDate = new Date(taskStartDate)
|
|
while (currentDate <= taskEndDate) {
|
|
const dateStr = this.formatDate(currentDate)
|
|
if (!tasksByDate[dateStr]) tasksByDate[dateStr] = []
|
|
const exists = tasksByDate[dateStr].some(t => t.requestNo === task.requestNo)
|
|
if (!exists) {
|
|
tasksByDate[dateStr].push({
|
|
requestNo: task.requestNo,
|
|
poNo: task.poNo,
|
|
supplierName: task.supplierName,
|
|
supplierShortOffice: task.supplierShortOffice || '',
|
|
inspectAddress: task.inspectAddress,
|
|
inspectCityShort: task.inspectCityShort || '',
|
|
planStartDate: task.planStartDate,
|
|
planEndDate: task.planEndDate,
|
|
statusDb: task.statusDb || ''
|
|
})
|
|
}
|
|
currentDate.setDate(currentDate.getDate() + 1)
|
|
}
|
|
})
|
|
const scheduleDays = days.map(day => ({
|
|
...day,
|
|
tasks: tasksByDate[day.date] || []
|
|
}))
|
|
return { userName: qc.userName, qcName: qc.qcName, scheduleDays }
|
|
} else {
|
|
return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(20, startDate) }
|
|
}
|
|
}).catch(() => {
|
|
return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(20, startDate) }
|
|
})
|
|
})
|
|
|
|
Promise.all(promises).then(results => {
|
|
// 按日期重新组织数据
|
|
const daysMap = {}
|
|
const baseDays = this.generateNextDays(20, startDate)
|
|
|
|
// 初始化每一天的数据结构
|
|
baseDays.forEach(day => {
|
|
daysMap[day.date] = {
|
|
date: day.date,
|
|
dateLabel: day.dateLabel,
|
|
weekday: day.weekday,
|
|
qcTasks: []
|
|
}
|
|
})
|
|
|
|
// 将每个QC的任务分配到对应的日期
|
|
results.forEach(result => {
|
|
result.scheduleDays.forEach(day => {
|
|
if (day.tasks && day.tasks.length > 0) {
|
|
if (daysMap[day.date]) {
|
|
daysMap[day.date].qcTasks.push({
|
|
userName: result.userName,
|
|
qcName: result.qcName,
|
|
tasks: day.tasks
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
// 转换为数组并按日期排序
|
|
this.allScheduleDays = Object.values(daysMap).sort((a, b) => a.date.localeCompare(b.date))
|
|
this.allQcLoading = false
|
|
}).catch(() => {
|
|
this.allQcLoading = false
|
|
})
|
|
},
|
|
// 点击QC任务项
|
|
handleQcTaskClick(qcTask) {
|
|
console.log('点击QC任务:', qcTask)
|
|
// 将“查看全部”中的任务点击事件抛给父组件处理(如申请变更中触发审批)- rqrq
|
|
this.$emit('task-click', qcTask)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
/* 样式与之前相同,保持不变 */
|
|
.schedule-container {
|
|
display: flex;
|
|
height: 100%;
|
|
background: #fff;
|
|
position: relative;
|
|
}
|
|
|
|
.empty-state {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: #fafafa;
|
|
}
|
|
|
|
.left-panel {
|
|
width: 280px;
|
|
border-right: 1px solid #dcdfe6;
|
|
display: flex;
|
|
flex-direction: column;
|
|
|
|
.panel-title {
|
|
padding: 8px 12px;
|
|
background: #f5f7fa;
|
|
color: #303133;
|
|
font-size: 13px;
|
|
font-weight: bold;
|
|
border-bottom: 1px solid #dcdfe6;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.qc-table {
|
|
flex: 1;
|
|
overflow: hidden;
|
|
}
|
|
}
|
|
|
|
.right-panel {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
|
|
.panel-title {
|
|
padding: 8px 12px;
|
|
background: #f5f7fa;
|
|
color: #303133;
|
|
font-size: 13px;
|
|
font-weight: bold;
|
|
border-bottom: 1px solid #dcdfe6;
|
|
flex-shrink: 0;
|
|
}
|
|
}
|
|
|
|
.schedule-grid {
|
|
flex: 1;
|
|
padding: 10px;
|
|
display: grid;
|
|
grid-template-columns: repeat(5, 1fr);
|
|
grid-template-rows: repeat(4, 1fr);
|
|
gap: 10px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.schedule-card {
|
|
border: 2px solid #dcdfe6;
|
|
border-radius: 4px;
|
|
background: #fff;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 140px;
|
|
width: 100%;
|
|
|
|
.card-header {
|
|
padding: 10px 12px;
|
|
background: #f5f7fa;
|
|
border-bottom: 2px solid #dcdfe6;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
height: 45px;
|
|
flex-shrink: 0;
|
|
|
|
.date-label {
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
color: #303133;
|
|
}
|
|
|
|
.date-weekday {
|
|
font-size: 12px;
|
|
color: #909399;
|
|
}
|
|
}
|
|
|
|
.card-body {
|
|
padding: 10px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
height: calc(100% - 45px);
|
|
overflow-y: auto;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 4px;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: #dcdfe6;
|
|
border-radius: 2px;
|
|
|
|
&:hover {
|
|
background: #c0c4cc;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.task-item {
|
|
padding: 10px;
|
|
background: #f5f7fa;
|
|
border: 1px solid #dcdfe6;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
flex-shrink: 0;
|
|
|
|
&:hover {
|
|
background: #ecf5ff;
|
|
border-color: #409eff;
|
|
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
|
|
}
|
|
}
|
|
|
|
.task-item--change-applying {
|
|
border: 2px solid #f56c6c;
|
|
background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
|
|
box-shadow:
|
|
0 0 0 1px rgba(245, 108, 108, 0.28),
|
|
0 0 10px rgba(245, 108, 108, 0.38);
|
|
}
|
|
|
|
.task-item--change-applying:hover {
|
|
border-color: #f23d3d;
|
|
box-shadow:
|
|
0 0 0 1px rgba(242, 61, 61, 0.4),
|
|
0 0 14px rgba(242, 61, 61, 0.5);
|
|
}
|
|
|
|
.task-line-text {
|
|
font-size: 12px;
|
|
color: #303133;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.empty-slot {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
.empty-text {
|
|
color: #c0c4cc;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
|
|
::-webkit-scrollbar {
|
|
width: 6px;
|
|
height: 6px;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
background: #c0c4cc;
|
|
border-radius: 3px;
|
|
|
|
&:hover {
|
|
background: #909399;
|
|
}
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
background: #f5f7fa;
|
|
}
|
|
|
|
.customer-bun-min {
|
|
padding: 7px 12px;
|
|
font-size: 12px;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
/* 所有QC排程弹窗样式 */
|
|
.all-qc-query-form {
|
|
padding: 0 10px;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.date-shift-group {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.date-shift-buttons {
|
|
margin-left: 8px;
|
|
}
|
|
|
|
/* 排程视图标题栏日期组件与弹窗保持一致,无需隐藏图标 */
|
|
|
|
.date-shift-buttons /deep/ .el-button {
|
|
padding: 6px 10px;
|
|
color: #606266;
|
|
}
|
|
|
|
.date-shift-buttons /deep/ .el-button:hover {
|
|
color: #409eff;
|
|
background: #ecf5ff;
|
|
}
|
|
|
|
.all-qc-schedule-container {
|
|
max-height: 75vh;
|
|
overflow-y: auto;
|
|
padding: 10px;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 6px;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: #dcdfe6;
|
|
border-radius: 3px;
|
|
|
|
&:hover {
|
|
background: #c0c4cc;
|
|
}
|
|
}
|
|
}
|
|
|
|
.schedule-days-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(5, 1fr);
|
|
gap: 12px;
|
|
}
|
|
|
|
.schedule-day-card {
|
|
border: 2px solid #dcdfe6;
|
|
border-radius: 4px;
|
|
background: #fff;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 240px;
|
|
width: 100%;
|
|
|
|
.day-header {
|
|
padding: 8px 10px;
|
|
background: #f5f7fa;
|
|
border-bottom: 2px solid #dcdfe6;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
height: 38px;
|
|
flex-shrink: 0;
|
|
|
|
.date-label {
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
color: #303133;
|
|
}
|
|
|
|
.date-weekday {
|
|
font-size: 11px;
|
|
color: #909399;
|
|
}
|
|
}
|
|
|
|
.day-body {
|
|
padding: 8px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
height: calc(100% - 38px);
|
|
overflow-y: auto;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 4px;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: #dcdfe6;
|
|
border-radius: 2px;
|
|
|
|
&:hover {
|
|
background: #c0c4cc;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.qc-task-item {
|
|
padding: 6px 8px;
|
|
background: #f5f7fa;
|
|
border: 1px solid #e4e7ed;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
|
|
&:hover {
|
|
background: #ecf5ff;
|
|
border-color: #409eff;
|
|
box-shadow: 0 2px 6px rgba(64, 158, 255, 0.12);
|
|
}
|
|
|
|
.task-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 3px;
|
|
}
|
|
|
|
.mini-task {
|
|
padding: 3px 5px;
|
|
background: #fff;
|
|
border-radius: 2px;
|
|
cursor: pointer;
|
|
border: 1px solid transparent;
|
|
|
|
&:hover {
|
|
background: #ecf5ff;
|
|
}
|
|
}
|
|
|
|
.mini-task--change-applying {
|
|
border-color: #f56c6c;
|
|
box-shadow: 0 0 6px rgba(245, 108, 108, 0.35);
|
|
background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
|
|
}
|
|
|
|
.mini-task--change-applying:hover {
|
|
background: #ffecec;
|
|
border-color: #f23d3d;
|
|
}
|
|
}
|
|
|
|
.empty-day {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
.empty-text {
|
|
color: #c0c4cc;
|
|
font-size: 13px;
|
|
}
|
|
}
|
|
</style>
|