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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
4 months ago
​
​
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
4 months ago
​
4 months ago
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
4 months ago
​
​
​
4 months ago
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
4 months ago
​
4 months ago
​
​
​
​
​
​
​
​
4 months ago
4 months ago
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 months ago
4 months ago
4 months ago
​
​
4 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div class="schedule-container">
  3. <!-- 左侧:QC人员清单 -->
  4. <div class="left-panel">
  5. <div class="panel-title">
  6. <span>QC人员清单</span>
  7. <el-button
  8. type="text"
  9. size="mini"
  10. icon="el-icon-view"
  11. style="float: right; margin-top: -2px;"
  12. @click="showAllQcSchedule">查看全部</el-button>
  13. </div>
  14. <el-table
  15. :data="qcList"
  16. border
  17. size="mini"
  18. highlight-current-row
  19. ref="qcTable"
  20. @current-change="handleQcSelect"
  21. @row-click="handleQcSelect"
  22. style="width: 100%;"
  23. :max-height="qcTableHeight"
  24. class="qc-table">
  25. <el-table-column prop="qcName" label="姓名" width="125" align="center" />
  26. <!-- <el-table-column prop="region" label="负责区域" min-width="90" show-overflow-tooltip />-->
  27. <el-table-column label="操作" width="125" align="center" fixed="right">
  28. <template slot-scope="scope">
  29. <!-- 只有当主表选中了数据且状态为已下达或已排程时才显示排程按钮 -->
  30. <el-link
  31. v-if="hasSelectedData && (currentStatusDb === 'Audited' || currentStatusDb === 'Scheduled')"
  32. type="primary"
  33. style="cursor: pointer;"
  34. @click.stop="openScheduleDialog(null, scope.row)">{{ currentStatusDb === 'Scheduled' ? '修改' : '排程' }}</el-link>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. </div>
  39. <!-- 右侧:排程卡片(始终显示) -->
  40. <div class="right-panel">
  41. <div class="panel-title">
  42. <span v-if="selectedQc">{{ selectedQc.qcName }} - 排程视图(未来20天)</span>
  43. <span v-else>查看排程</span>
  44. <!-- 日期前后滚动:与“所有QC排程情况”弹窗风格一致 - rqrq -->
  45. <div v-if="selectedQc" class="date-shift-group" style="float: right;">
  46. <el-date-picker
  47. v-model="scheduleStartDate"
  48. type="date"
  49. value-format="yyyy-MM-dd"
  50. size="small"
  51. placeholder="请选择起始日期"
  52. style="width: 150px;"
  53. @change="onScheduleDateChange" />
  54. <el-button-group class="date-shift-buttons">
  55. <el-button icon="el-icon-arrow-left" size="small" title="前一天" @click="shiftScheduleDate(-1)" />
  56. <el-button icon="el-icon-arrow-right" size="small" title="后一天" @click="shiftScheduleDate(1)" />
  57. </el-button-group>
  58. </div>
  59. </div>
  60. <div class="schedule-grid" v-loading="loading">
  61. <div v-for="day in scheduleDays" :key="day.date" class="schedule-card">
  62. <div class="card-header">
  63. <span class="date-label">{{ day.dateLabel }}</span>
  64. <span class="date-weekday">{{ day.weekday }}</span>
  65. </div>
  66. <div class="card-body">
  67. <div
  68. v-for="task in day.tasks"
  69. :key="task.requestNo"
  70. :class="['task-item', { 'task-item--change-applying': isChangeApplyingTask(task) }]"
  71. @click="handleTaskClick(task)">
  72. <div class="task-line-text" :title="buildTaskLineText(task)">{{ buildTaskLineText(task) }}</div>
  73. <!-- <div v-if="task.inspectAddress" class="task-address" :title="task.inspectAddress">
  74. <i class="el-icon-location"></i> {{ task.inspectAddress }}
  75. </div> -->
  76. </div>
  77. <div v-if="day.tasks.length === 0" class="empty-slot">
  78. <span class="empty-text">暂无排程</span>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- 排程弹窗 -->
  85. <el-dialog
  86. title="验货排程"
  87. :visible.sync="scheduleDialogVisible"
  88. width="500px"
  89. :close-on-click-modal="false"
  90. append-to-body>
  91. <el-form :model="scheduleForm" :rules="scheduleRules" ref="scheduleForm" size="small" label-position="top">
  92. <el-row :gutter="10">
  93. <el-col :span="8">
  94. <el-form-item label="QC人员:">
  95. <el-input v-model="scheduleForm.qcOperator" disabled></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="16">
  99. <el-form-item label="QC联系方式:">
  100. <el-input v-model="scheduleForm.qcContact" clearable placeholder="按所选QC自动带出,可修改"></el-input>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. <el-form-item label="计划验货日期:" prop="planStartDate">
  105. <div style="display: flex; align-items: center; width: 100%;">
  106. <el-date-picker v-model="scheduleForm.planStartDate" type="date" placeholder="选择开始日期" value-format="yyyy-MM-dd" style="flex: 1;"></el-date-picker>
  107. <span style="margin: 0 10px;">-</span>
  108. <el-date-picker v-model="scheduleForm.planEndDate" type="date" placeholder="选择结束日期" value-format="yyyy-MM-dd" style="flex: 1;"></el-date-picker>
  109. </div>
  110. </el-form-item>
  111. <el-form-item label="备注:">
  112. <el-input v-model="scheduleForm.remark" type="textarea" :rows="3" placeholder="请输入备注"></el-input>
  113. </el-form-item>
  114. </el-form>
  115. <div slot="footer" class="dialog-footer">
  116. <el-button type="primary" size="small" @click="submitSchedule" :loading="loading">保存</el-button>
  117. <el-button size="small" @click="cancelSchedule">关闭</el-button>
  118. </div>
  119. </el-dialog>
  120. <!-- 所有QC排程查看弹窗 -->
  121. <el-dialog
  122. title="所有QC排程情况"
  123. :visible.sync="allQcScheduleDialogVisible"
  124. width="80%"
  125. :close-on-click-modal="false"
  126. append-to-body
  127. top="5vh">
  128. <el-form :inline="true" size="small" label-position="top" class="all-qc-query-form">
  129. <el-form-item label="起始日期">
  130. <div class="date-shift-group">
  131. <el-date-picker
  132. v-model="allQcQuery.startDate"
  133. type="date"
  134. value-format="yyyy-MM-dd"
  135. placeholder="请选择起始日期"
  136. style="width: 150px;" />
  137. <el-button-group class="date-shift-buttons">
  138. <el-button icon="el-icon-arrow-left" size="small" title="前一天" @click="shiftAllQcStartDate(-1)" />
  139. <el-button icon="el-icon-arrow-right" size="small" title="后一天" @click="shiftAllQcStartDate(1)" />
  140. </el-button-group>
  141. </div>
  142. </el-form-item>
  143. </el-form>
  144. <div class="all-qc-schedule-container" v-loading="allQcLoading">
  145. <div class="schedule-days-grid">
  146. <div v-for="day in allScheduleDays" :key="day.date" class="schedule-day-card">
  147. <div class="day-header">
  148. <span class="date-label">{{ day.dateLabel }}</span>
  149. <span class="date-weekday">{{ day.weekday }}</span>
  150. </div>
  151. <div class="day-body">
  152. <div
  153. v-for="qcTask in day.qcTasks"
  154. :key="qcTask.userName"
  155. class="qc-task-item">
  156. <div class="task-list">
  157. <div
  158. v-for="task in qcTask.tasks"
  159. :key="task.requestNo"
  160. :class="['mini-task', { 'mini-task--change-applying': isChangeApplyingTask(task) }]"
  161. @click="handleQcTaskClick({ ...task, qcName: qcTask.qcName, userName: qcTask.userName })">
  162. <span class="task-line-text" :title="buildTaskLineText(task, qcTask.qcName)">{{ buildTaskLineText(task, qcTask.qcName) }}</span>
  163. </div>
  164. </div>
  165. </div>
  166. <div v-if="day.qcTasks.length === 0" class="empty-day">
  167. <span class="empty-text">暂无排程</span>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button size="small" @click="allQcScheduleDialogVisible = false">关闭</el-button>
  175. </div>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. import { getQcPersonList, scheduleInspectionRequest, getScheduleView } from '@/api/inspection/inspectionRequestHeader.js'
  181. export default {
  182. name: 'InspectionScheduleView',
  183. props: {
  184. requestNos: { type: Array, default: () => [] },
  185. currentRow: { type: Object, default: () => ({}) },
  186. currentStatusDb: { type: String, default: '' }
  187. },
  188. data() {
  189. return {
  190. qcList: [],
  191. selectedQc: null,
  192. scheduleDays: [],
  193. scheduleStartDate: '',
  194. loading: false,
  195. qcTableHeight: 500,
  196. scheduleDialogVisible: false,
  197. allQcScheduleDialogVisible: false,
  198. allQcLoading: false,
  199. allQcScheduleData: {}, // 存储所有QC的排程数据 { userName: [days] }
  200. allScheduleDays: [], // 按日期组织的排程数据 [{ date, dateLabel, weekday, qcTasks: [...] }]
  201. allQcQuery: {
  202. startDate: ''
  203. },
  204. scheduleForm: {
  205. qcOperator: '',
  206. qcUserName: '',
  207. qcContact: '',
  208. planStartDate: '',
  209. planEndDate: '',
  210. remark: ''
  211. },
  212. scheduleRules: {
  213. planStartDate: [{ required: true, message: '请选择开始日期', trigger: 'change' }]
  214. }
  215. }
  216. },
  217. computed: {
  218. // 判断主表是否选中了数据
  219. hasSelectedData() {
  220. return this.requestNos && this.requestNos.length > 0
  221. }
  222. },
  223. watch: {
  224. requestNos: {
  225. handler() {
  226. // 主表选中状态变化时,仍按当前选中QC刷新其排程视图(排程任务不依赖主表选择) - rqrq
  227. if (this.selectedQc) {
  228. this.loadScheduleData(this.selectedQc)
  229. } else {
  230. this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
  231. }
  232. }
  233. }
  234. },
  235. mounted() {
  236. console.log('[排程视图] 组件已挂载')
  237. this.scheduleStartDate = this.getTodayDateString()
  238. // 组件挂载时自动加载QC列表和排程数据
  239. this.loadQcList()
  240. // 计算QC表格高度
  241. this.$nextTick(() => {
  242. this.calculateQcTableHeight()
  243. })
  244. },
  245. methods: {
  246. // 计算QC表格高度
  247. calculateQcTableHeight() {
  248. // 计算10行数据的高度
  249. // Element UI mini尺寸的表格,每行高度约为40px(包含边框)
  250. const rowHeight = 40
  251. const headerHeight = 45 // 表头高度
  252. const rowCount = 10 // 显示10行数据
  253. this.qcTableHeight = (rowHeight * rowCount) + headerHeight + 2 // 加2px用于边框
  254. },
  255. // 强制刷新当前选中的QC排程视图(供父组件调用)
  256. forceRefresh() {
  257. console.log('[排程视图] forceRefresh 被调用')
  258. // 直接重新加载QC列表和排程数据;若“查看全部”弹窗打开,同步刷新弹窗数据 - rqrq
  259. const loadPromise = this.loadQcList()
  260. if (loadPromise && typeof loadPromise.finally === 'function') {
  261. loadPromise.finally(() => {
  262. if (this.allQcScheduleDialogVisible) {
  263. this.loadAllQcSchedule()
  264. }
  265. })
  266. } else if (this.allQcScheduleDialogVisible) {
  267. this.loadAllQcSchedule()
  268. }
  269. },
  270. loadQcList() {
  271. console.log('[排程视图] 开始加载QC列表')
  272. const params = {
  273. page: 1,
  274. limit: 100,
  275. site: this.$store.state.user.site
  276. }
  277. return getQcPersonList(params)
  278. .then(({ data }) => {
  279. if (data.code === 0 && data.page && data.page.list) {
  280. this.qcList = data.page.list.map(item => ({
  281. id: item.id || item.userId,
  282. qcName: item.userDisplay || item.userName,
  283. userName: item.userName,
  284. qcContact: item.userMobile || '',
  285. region: ''
  286. }))
  287. console.log('[排程视图] QC列表加载成功:', this.qcList)
  288. if (this.qcList.length) {
  289. // 优先保持当前选中的QC,如果无效则选中第一个
  290. if (
  291. !this.selectedQc ||
  292. !this.qcList.some(q => q.userName === this.selectedQc.userName)
  293. ) {
  294. this.selectedQc = this.qcList[0]
  295. }
  296. // 只要选中了QC就加载其排程视图,与主表是否选中数据无关(排程任务按QC人员查询) - rqrq
  297. this.loadScheduleData(this.selectedQc)
  298. this.$nextTick(() => {
  299. if (this.$refs.qcTable) {
  300. this.$refs.qcTable.setCurrentRow(this.selectedQc)
  301. }
  302. })
  303. } else {
  304. this.selectedQc = null
  305. this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
  306. }
  307. } else {
  308. console.warn('[排程视图] 加载QC列表失败')
  309. this.qcList = []
  310. this.selectedQc = null
  311. this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
  312. }
  313. })
  314. .catch(err => {
  315. console.error('[排程视图] 加载QC列表错误:', err)
  316. this.qcList = []
  317. this.selectedQc = null
  318. this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
  319. })
  320. },
  321. handleQcSelect(row) {
  322. if (!row) return
  323. this.selectedQc = row
  324. // 选中QC即加载其排程视图,不依赖主表是否选中数据 - rqrq
  325. this.loadScheduleData(row)
  326. },
  327. // 打开排程弹窗
  328. openScheduleDialog(task, qcRow) {
  329. this.scheduleForm = {
  330. qcOperator: qcRow ? qcRow.userName : '',
  331. qcUserName: qcRow ? qcRow.qcName : '',
  332. qcContact: qcRow ? (qcRow.qcContact || '') : '',
  333. planStartDate: '',
  334. planEndDate: '',
  335. remark: ''
  336. }
  337. // 如果是已排程状态,加载当前排程数据用于修改
  338. if (this.currentStatusDb === 'Scheduled' && this.currentRow && this.currentRow.planStartDate) {
  339. this.scheduleForm.planStartDate = this.currentRow.planStartDate || ''
  340. this.scheduleForm.planEndDate = this.currentRow.planEndDate || this.currentRow.planStartDate || ''
  341. this.scheduleForm.remark = this.currentRow.scheduleRemark || ''
  342. // 仅当修改的是同一 QC 时才回显已保存的联系方式;换选其它 QC 则用其手机号自动带出的值,避免残留原 QC 联系方式 - rqrq
  343. const savedQc = this.currentRow.qcOperator
  344. const selectedQc = qcRow ? qcRow.userName : ''
  345. if (savedQc && selectedQc && savedQc === selectedQc) {
  346. this.scheduleForm.qcContact = this.currentRow.qcContact || this.scheduleForm.qcContact
  347. }
  348. }
  349. this.scheduleDialogVisible = true
  350. },
  351. // 关闭排程弹窗
  352. cancelSchedule() {
  353. this.scheduleDialogVisible = false
  354. },
  355. // 提交排程
  356. submitSchedule() {
  357. this.$refs.scheduleForm.validate((valid) => {
  358. if (!valid) return
  359. if (!this.scheduleForm.planStartDate) {
  360. this.$message.warning('请选择计划验货日期')
  361. return
  362. }
  363. const params = {
  364. requestNos: this.requestNos,
  365. site: this.$store.state.user.site,
  366. qcOperator: this.scheduleForm.qcOperator,
  367. qcContact: this.scheduleForm.qcContact,
  368. planStartDate: this.scheduleForm.planStartDate,
  369. planEndDate: this.scheduleForm.planEndDate || this.scheduleForm.planStartDate,
  370. remark: this.scheduleForm.remark
  371. }
  372. this.loading = true
  373. scheduleInspectionRequest(params).then(({ data }) => {
  374. if (data && data.code === 0) {
  375. this.$message.success('排程成功')
  376. this.scheduleDialogVisible = false
  377. // 通知父组件刷新主表数据(会触发整页刷新)
  378. this.$emit('schedule-success')
  379. } else {
  380. this.$message.error((data && data.msg) || '排程失败')
  381. }
  382. this.loading = false
  383. }).catch((error) => {
  384. console.error('排程失败:', error)
  385. this.$message.error('排程失败')
  386. this.loading = false
  387. })
  388. })
  389. },
  390. // 排程视图日期前后滚动:offset 为天数,滚动后重新加载当前 QC 排程 - rqrq
  391. shiftScheduleDate (offset) {
  392. const base = this.parseDateString(this.scheduleStartDate) || new Date()
  393. const next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + offset)
  394. this.scheduleStartDate = this.formatDate(next)
  395. if (this.selectedQc) {
  396. this.loadScheduleData(this.selectedQc)
  397. }
  398. },
  399. // 日期输入框手动选择后刷新排程视图 - rqrq
  400. onScheduleDateChange () {
  401. if (this.selectedQc && this.scheduleStartDate) {
  402. this.loadScheduleData(this.selectedQc)
  403. }
  404. },
  405. loadScheduleData(qc) {
  406. console.log('======loadScheduleData======')
  407. console.log('qc=', qc)
  408. if (!qc) {
  409. console.warn('[排程视图] loadScheduleData 参数为空')
  410. this.scheduleDays = this.generateNextDays(20, this.scheduleStartDate)
  411. return
  412. }
  413. this.loading = true
  414. console.log('[排程视图] 开始加载排程数据, QC:', qc.userName)
  415. const startDate = this.scheduleStartDate || this.getTodayDateString()
  416. getScheduleView(qc.userName, startDate, this.$store.state.user.site)
  417. .then(({ data }) => {
  418. if (data.code === 0) {
  419. const days = this.generateNextDays(20, startDate)
  420. const tasksByDate = {}
  421. ;(data.list || []).forEach(task => {
  422. const taskStartDate = new Date(task.planStartDate)
  423. const taskEndDate = new Date(task.planEndDate || task.planStartDate)
  424. let currentDate = new Date(taskStartDate)
  425. while (currentDate <= taskEndDate) {
  426. const dateStr = this.formatDate(currentDate)
  427. if (!tasksByDate[dateStr]) tasksByDate[dateStr] = []
  428. const exists = tasksByDate[dateStr].some(t => t.requestNo === task.requestNo)
  429. if (!exists) {
  430. tasksByDate[dateStr].push({
  431. requestNo: task.requestNo,
  432. poNo: task.poNo,
  433. supplierName: task.supplierName,
  434. supplierShortOffice: task.supplierShortOffice || '',
  435. qcDisplay: qc.qcName,
  436. inspectAddress: task.inspectAddress,
  437. inspectCityShort: task.inspectCityShort || '',
  438. planStartDate: task.planStartDate,
  439. planEndDate: task.planEndDate,
  440. statusDb: task.statusDb || ''
  441. })
  442. }
  443. currentDate.setDate(currentDate.getDate() + 1)
  444. }
  445. })
  446. this.scheduleDays = days.map(day => ({
  447. ...day,
  448. tasks: tasksByDate[day.date] || []
  449. }))
  450. console.log('scheduleDays=', this.scheduleDays)
  451. console.log(
  452. '任务总数=',
  453. this.scheduleDays.reduce(
  454. (sum, item) => sum + item.tasks.length,
  455. 0
  456. )
  457. )
  458. console.log('[排程视图] 排程数据加载完成')
  459. } else {
  460. console.warn('[排程视图] 加载排程数据失败')
  461. this.scheduleDays = this.generateNextDays(20, startDate)
  462. }
  463. })
  464. .catch(err => {
  465. console.error('[排程视图] 加载排程数据错误:', err)
  466. this.scheduleDays = this.generateNextDays(20, startDate)
  467. })
  468. .finally(() => {
  469. this.loading = false
  470. })
  471. },
  472. generateNextDays(days, startDate) {
  473. const result = []
  474. const baseDate = this.parseDateString(startDate) || new Date()
  475. const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  476. for (let i = 0; i < days; i++) {
  477. const date = new Date(baseDate)
  478. date.setDate(baseDate.getDate() + i)
  479. result.push({
  480. date: this.formatDate(date),
  481. dateLabel: `${date.getMonth() + 1}/${date.getDate()}`,
  482. weekday: weekdays[date.getDay()],
  483. tasks: []
  484. })
  485. }
  486. return result
  487. },
  488. getTodayDateString() {
  489. return this.formatDate(new Date())
  490. },
  491. parseDateString(dateStr) {
  492. if (!dateStr) {
  493. return null
  494. }
  495. const parts = String(dateStr).split('-')
  496. if (parts.length !== 3) {
  497. return null
  498. }
  499. const year = Number(parts[0])
  500. const month = Number(parts[1]) - 1
  501. const day = Number(parts[2])
  502. const parsedDate = new Date(year, month, day)
  503. if (Number.isNaN(parsedDate.getTime())) {
  504. return null
  505. }
  506. return parsedDate
  507. },
  508. getShortOfficeDisplayName(shortOffice, supplierName) {
  509. const value = shortOffice || supplierName || ''
  510. return value.length > 30 ? value.substring(0, 30) : value
  511. },
  512. buildTaskLineText(task, qcDisplayName) {
  513. const displayName = qcDisplayName || task.qcDisplay || (this.selectedQc ? this.selectedQc.qcName : '')
  514. const supplierShortOffice = this.getShortOfficeDisplayName(task.supplierShortOffice, task.supplierName)
  515. const inspectCityShort = task.inspectCityShort || ''
  516. return [displayName, supplierShortOffice, inspectCityShort].filter(item => item).join(' | ')
  517. },
  518. // 申请变更中卡片高亮判断 - rqrq
  519. isChangeApplyingTask (task) {
  520. return !!(task && task.statusDb === 'ChangeApplying')
  521. },
  522. formatDate(date) {
  523. const year = date.getFullYear()
  524. const month = String(date.getMonth() + 1).padStart(2, '0')
  525. const day = String(date.getDate()).padStart(2, '0')
  526. return `${year}-${month}-${day}`
  527. },
  528. handleTaskClick(task) {
  529. console.log('点击任务:', task)
  530. this.$emit('task-click', task)
  531. },
  532. // 显示所有QC排程弹窗
  533. showAllQcSchedule() {
  534. this.allQcScheduleDialogVisible = true
  535. this.allQcQuery.startDate = this.getTodayDateString()
  536. this.loadAllQcSchedule()
  537. },
  538. // 按起始日期查询所有QC排程
  539. queryAllQcSchedule() {
  540. if (!this.allQcQuery.startDate) {
  541. this.allQcQuery.startDate = this.getTodayDateString()
  542. }
  543. this.loadAllQcSchedule()
  544. },
  545. // 前后滚动“所有QC排程情况”起始日期:每次移动 1 天并刷新查询显示 - rqrq
  546. shiftAllQcStartDate(offsetDays) {
  547. const base = this.parseDateString(this.allQcQuery.startDate) || new Date()
  548. const next = new Date(base)
  549. next.setDate(base.getDate() + offsetDays)
  550. this.allQcQuery.startDate = this.formatDate(next)
  551. this.loadAllQcSchedule()
  552. },
  553. // 加载所有QC的排程数据
  554. loadAllQcSchedule() {
  555. if (!this.qcList || this.qcList.length === 0) {
  556. this.$message.warning('暂无QC人员数据')
  557. return
  558. }
  559. const startDate = this.allQcQuery.startDate || this.getTodayDateString()
  560. this.allQcQuery.startDate = startDate
  561. this.allQcLoading = true
  562. const promises = this.qcList.map(qc => {
  563. return getScheduleView(qc.userName, startDate, this.$store.state.user.site).then(({ data }) => {
  564. if (data.code === 0) {
  565. const days = this.generateNextDays(20, startDate)
  566. const tasksByDate = {}
  567. ;(data.list || []).forEach(task => {
  568. const taskStartDate = new Date(task.planStartDate)
  569. const taskEndDate = new Date(task.planEndDate || task.planStartDate)
  570. let currentDate = new Date(taskStartDate)
  571. while (currentDate <= taskEndDate) {
  572. const dateStr = this.formatDate(currentDate)
  573. if (!tasksByDate[dateStr]) tasksByDate[dateStr] = []
  574. const exists = tasksByDate[dateStr].some(t => t.requestNo === task.requestNo)
  575. if (!exists) {
  576. tasksByDate[dateStr].push({
  577. requestNo: task.requestNo,
  578. poNo: task.poNo,
  579. supplierName: task.supplierName,
  580. supplierShortOffice: task.supplierShortOffice || '',
  581. inspectAddress: task.inspectAddress,
  582. inspectCityShort: task.inspectCityShort || '',
  583. planStartDate: task.planStartDate,
  584. planEndDate: task.planEndDate,
  585. statusDb: task.statusDb || ''
  586. })
  587. }
  588. currentDate.setDate(currentDate.getDate() + 1)
  589. }
  590. })
  591. const scheduleDays = days.map(day => ({
  592. ...day,
  593. tasks: tasksByDate[day.date] || []
  594. }))
  595. return { userName: qc.userName, qcName: qc.qcName, scheduleDays }
  596. } else {
  597. return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(20, startDate) }
  598. }
  599. }).catch(() => {
  600. return { userName: qc.userName, qcName: qc.qcName, scheduleDays: this.generateNextDays(20, startDate) }
  601. })
  602. })
  603. Promise.all(promises).then(results => {
  604. // 按日期重新组织数据
  605. const daysMap = {}
  606. const baseDays = this.generateNextDays(20, startDate)
  607. // 初始化每一天的数据结构
  608. baseDays.forEach(day => {
  609. daysMap[day.date] = {
  610. date: day.date,
  611. dateLabel: day.dateLabel,
  612. weekday: day.weekday,
  613. qcTasks: []
  614. }
  615. })
  616. // 将每个QC的任务分配到对应的日期
  617. results.forEach(result => {
  618. result.scheduleDays.forEach(day => {
  619. if (day.tasks && day.tasks.length > 0) {
  620. if (daysMap[day.date]) {
  621. daysMap[day.date].qcTasks.push({
  622. userName: result.userName,
  623. qcName: result.qcName,
  624. tasks: day.tasks
  625. })
  626. }
  627. }
  628. })
  629. })
  630. // 转换为数组并按日期排序
  631. this.allScheduleDays = Object.values(daysMap).sort((a, b) => a.date.localeCompare(b.date))
  632. this.allQcLoading = false
  633. }).catch(() => {
  634. this.allQcLoading = false
  635. })
  636. },
  637. // 点击QC任务项
  638. handleQcTaskClick(qcTask) {
  639. console.log('点击QC任务:', qcTask)
  640. // 将“查看全部”中的任务点击事件抛给父组件处理(如申请变更中触发审批)- rqrq
  641. this.$emit('task-click', qcTask)
  642. }
  643. }
  644. }
  645. </script>
  646. <style scoped lang="scss">
  647. /* 样式与之前相同,保持不变 */
  648. .schedule-container {
  649. display: flex;
  650. height: 100%;
  651. background: #fff;
  652. position: relative;
  653. }
  654. .empty-state {
  655. width: 100%;
  656. height: 100%;
  657. display: flex;
  658. flex-direction: column;
  659. align-items: center;
  660. justify-content: center;
  661. background: #fafafa;
  662. }
  663. .left-panel {
  664. width: 280px;
  665. border-right: 1px solid #dcdfe6;
  666. display: flex;
  667. flex-direction: column;
  668. .panel-title {
  669. padding: 8px 12px;
  670. background: #f5f7fa;
  671. color: #303133;
  672. font-size: 13px;
  673. font-weight: bold;
  674. border-bottom: 1px solid #dcdfe6;
  675. flex-shrink: 0;
  676. }
  677. .qc-table {
  678. flex: 1;
  679. overflow: hidden;
  680. }
  681. }
  682. .right-panel {
  683. flex: 1;
  684. display: flex;
  685. flex-direction: column;
  686. .panel-title {
  687. padding: 8px 12px;
  688. background: #f5f7fa;
  689. color: #303133;
  690. font-size: 13px;
  691. font-weight: bold;
  692. border-bottom: 1px solid #dcdfe6;
  693. flex-shrink: 0;
  694. }
  695. }
  696. .schedule-grid {
  697. flex: 1;
  698. padding: 10px;
  699. display: grid;
  700. grid-template-columns: repeat(5, 1fr);
  701. grid-template-rows: repeat(4, 1fr);
  702. gap: 10px;
  703. overflow-y: auto;
  704. }
  705. .schedule-card {
  706. border: 2px solid #dcdfe6;
  707. border-radius: 4px;
  708. background: #fff;
  709. display: flex;
  710. flex-direction: column;
  711. height: 140px;
  712. width: 100%;
  713. .card-header {
  714. padding: 10px 12px;
  715. background: #f5f7fa;
  716. border-bottom: 2px solid #dcdfe6;
  717. display: flex;
  718. justify-content: space-between;
  719. align-items: center;
  720. height: 45px;
  721. flex-shrink: 0;
  722. .date-label {
  723. font-size: 16px;
  724. font-weight: bold;
  725. color: #303133;
  726. }
  727. .date-weekday {
  728. font-size: 12px;
  729. color: #909399;
  730. }
  731. }
  732. .card-body {
  733. padding: 10px;
  734. display: flex;
  735. flex-direction: column;
  736. gap: 8px;
  737. height: calc(100% - 45px);
  738. overflow-y: auto;
  739. &::-webkit-scrollbar {
  740. width: 4px;
  741. }
  742. &::-webkit-scrollbar-thumb {
  743. background: #dcdfe6;
  744. border-radius: 2px;
  745. &:hover {
  746. background: #c0c4cc;
  747. }
  748. }
  749. }
  750. }
  751. .task-item {
  752. padding: 10px;
  753. background: #f5f7fa;
  754. border: 1px solid #dcdfe6;
  755. border-radius: 3px;
  756. cursor: pointer;
  757. transition: all 0.3s;
  758. flex-shrink: 0;
  759. &:hover {
  760. background: #ecf5ff;
  761. border-color: #409eff;
  762. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
  763. }
  764. }
  765. .task-item--change-applying {
  766. border: 2px solid #f56c6c;
  767. background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
  768. box-shadow:
  769. 0 0 0 1px rgba(245, 108, 108, 0.28),
  770. 0 0 10px rgba(245, 108, 108, 0.38);
  771. }
  772. .task-item--change-applying:hover {
  773. border-color: #f23d3d;
  774. box-shadow:
  775. 0 0 0 1px rgba(242, 61, 61, 0.4),
  776. 0 0 14px rgba(242, 61, 61, 0.5);
  777. }
  778. .task-line-text {
  779. font-size: 12px;
  780. color: #303133;
  781. white-space: nowrap;
  782. overflow: hidden;
  783. text-overflow: ellipsis;
  784. }
  785. .empty-slot {
  786. flex: 1;
  787. display: flex;
  788. align-items: center;
  789. justify-content: center;
  790. .empty-text {
  791. color: #c0c4cc;
  792. font-size: 12px;
  793. }
  794. }
  795. ::-webkit-scrollbar {
  796. width: 6px;
  797. height: 6px;
  798. }
  799. ::-webkit-scrollbar-thumb {
  800. background: #c0c4cc;
  801. border-radius: 3px;
  802. &:hover {
  803. background: #909399;
  804. }
  805. }
  806. ::-webkit-scrollbar-track {
  807. background: #f5f7fa;
  808. }
  809. .customer-bun-min {
  810. padding: 7px 12px;
  811. font-size: 12px;
  812. border-radius: 3px;
  813. }
  814. /* 所有QC排程弹窗样式 */
  815. .all-qc-query-form {
  816. padding: 0 10px;
  817. margin-bottom: 6px;
  818. }
  819. .date-shift-group {
  820. display: flex;
  821. align-items: center;
  822. }
  823. .date-shift-buttons {
  824. margin-left: 8px;
  825. }
  826. /* 排程视图标题栏日期组件与弹窗保持一致,无需隐藏图标 */
  827. .date-shift-buttons /deep/ .el-button {
  828. padding: 6px 10px;
  829. color: #606266;
  830. }
  831. .date-shift-buttons /deep/ .el-button:hover {
  832. color: #409eff;
  833. background: #ecf5ff;
  834. }
  835. .all-qc-schedule-container {
  836. max-height: 75vh;
  837. overflow-y: auto;
  838. padding: 10px;
  839. &::-webkit-scrollbar {
  840. width: 6px;
  841. }
  842. &::-webkit-scrollbar-thumb {
  843. background: #dcdfe6;
  844. border-radius: 3px;
  845. &:hover {
  846. background: #c0c4cc;
  847. }
  848. }
  849. }
  850. .schedule-days-grid {
  851. display: grid;
  852. grid-template-columns: repeat(5, 1fr);
  853. gap: 12px;
  854. }
  855. .schedule-day-card {
  856. border: 2px solid #dcdfe6;
  857. border-radius: 4px;
  858. background: #fff;
  859. display: flex;
  860. flex-direction: column;
  861. height: 240px;
  862. width: 100%;
  863. .day-header {
  864. padding: 8px 10px;
  865. background: #f5f7fa;
  866. border-bottom: 2px solid #dcdfe6;
  867. display: flex;
  868. justify-content: space-between;
  869. align-items: center;
  870. height: 38px;
  871. flex-shrink: 0;
  872. .date-label {
  873. font-size: 14px;
  874. font-weight: bold;
  875. color: #303133;
  876. }
  877. .date-weekday {
  878. font-size: 11px;
  879. color: #909399;
  880. }
  881. }
  882. .day-body {
  883. padding: 8px;
  884. display: flex;
  885. flex-direction: column;
  886. gap: 6px;
  887. height: calc(100% - 38px);
  888. overflow-y: auto;
  889. &::-webkit-scrollbar {
  890. width: 4px;
  891. }
  892. &::-webkit-scrollbar-thumb {
  893. background: #dcdfe6;
  894. border-radius: 2px;
  895. &:hover {
  896. background: #c0c4cc;
  897. }
  898. }
  899. }
  900. }
  901. .qc-task-item {
  902. padding: 6px 8px;
  903. background: #f5f7fa;
  904. border: 1px solid #e4e7ed;
  905. border-radius: 3px;
  906. cursor: pointer;
  907. transition: all 0.3s;
  908. &:hover {
  909. background: #ecf5ff;
  910. border-color: #409eff;
  911. box-shadow: 0 2px 6px rgba(64, 158, 255, 0.12);
  912. }
  913. .task-list {
  914. display: flex;
  915. flex-direction: column;
  916. gap: 3px;
  917. }
  918. .mini-task {
  919. padding: 3px 5px;
  920. background: #fff;
  921. border-radius: 2px;
  922. cursor: pointer;
  923. border: 1px solid transparent;
  924. &:hover {
  925. background: #ecf5ff;
  926. }
  927. }
  928. .mini-task--change-applying {
  929. border-color: #f56c6c;
  930. box-shadow: 0 0 6px rgba(245, 108, 108, 0.35);
  931. background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
  932. }
  933. .mini-task--change-applying:hover {
  934. background: #ffecec;
  935. border-color: #f23d3d;
  936. }
  937. }
  938. .empty-day {
  939. flex: 1;
  940. display: flex;
  941. align-items: center;
  942. justify-content: center;
  943. .empty-text {
  944. color: #c0c4cc;
  945. font-size: 13px;
  946. }
  947. }
  948. </style>