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.

309 lines
7.8 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
  1. <template>
  2. <div class="my-todo-container">
  3. <!-- 页面标题 -->
  4. <div class="page-header">
  5. <h2 class="page-title">我的待办QC人员</h2>
  6. <p class="page-desc">对于QC人员查看到自己的待验货的申请单</p>
  7. </div>
  8. <!-- 日期卡片网格 -->
  9. <div class="schedule-grid" v-loading="loading">
  10. <div
  11. v-for="day in scheduleDays"
  12. :key="day.date"
  13. class="schedule-card">
  14. <div class="card-header">
  15. <span class="date-label">{{ day.dateLabel }}</span>
  16. <span class="date-weekday">{{ day.weekday }}</span>
  17. </div>
  18. <div class="card-body">
  19. <div
  20. v-for="task in day.tasks"
  21. :key="task.requestNo"
  22. class="task-item"
  23. @click="handleTaskClick(task, day.date)">
  24. <div class="task-line-text" :title="buildTaskLineText(task)">{{ buildTaskLineText(task) }}</div>
  25. <!-- <div v-if="task.inspectAddress" class="task-address" :title="task.inspectAddress">
  26. <i class="el-icon-location"></i> {{ task.inspectAddress }}
  27. </div> -->
  28. </div>
  29. <div v-if="day.tasks.length === 0" class="empty-slot">
  30. <span class="empty-text">暂无排程</span>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { getScheduleView } from '@/api/inspection/inspectionRequestHeader.js'
  39. export default {
  40. name: 'MyTodoList',
  41. data () {
  42. return {
  43. scheduleDays: [],
  44. loading: false,
  45. refreshTimer: null
  46. }
  47. },
  48. mounted () {
  49. this.loadScheduleData()
  50. this.refreshTimer = setInterval(() => {
  51. this.loadScheduleData()
  52. }, 60000)
  53. },
  54. beforeDestroy () {
  55. if (this.refreshTimer) {
  56. clearInterval(this.refreshTimer)
  57. this.refreshTimer = null
  58. }
  59. },
  60. methods: {
  61. loadScheduleData () {
  62. this.loading = true
  63. const qcOperator = this.$store.state.user.name
  64. const startDate = this.formatDate(new Date())
  65. const site = this.$store.state.user.site
  66. const qcDisplay = this.$store.state.user.userDisplay || this.$store.state.user.name
  67. getScheduleView(qcOperator, startDate, site).then(({ data }) => {
  68. if (data.code === 0 && data.list) {
  69. const days = this.generateNextDays(10)
  70. const tasksByDate = {}
  71. data.list.forEach(task => {
  72. const startDate = new Date(task.planStartDate)
  73. const endDate = new Date(task.planEndDate || task.planStartDate)
  74. let currentDate = new Date(startDate)
  75. while (currentDate <= endDate) {
  76. const dateStr = this.formatDate(currentDate)
  77. if (!tasksByDate[dateStr]) tasksByDate[dateStr] = []
  78. const exists = tasksByDate[dateStr].some(t => t.requestNo === task.requestNo)
  79. if (!exists) {
  80. tasksByDate[dateStr].push({
  81. requestNo: task.requestNo,
  82. poNo: task.poNo,
  83. supplierName: task.supplierName,
  84. qcDisplay: qcDisplay,
  85. inspectAddress: task.inspectAddress,
  86. planStartDate: task.planStartDate,
  87. planEndDate: task.planEndDate
  88. })
  89. }
  90. currentDate.setDate(currentDate.getDate() + 1)
  91. }
  92. })
  93. this.scheduleDays = days.map(day => ({
  94. ...day,
  95. tasks: tasksByDate[day.date] || []
  96. }))
  97. } else {
  98. this.scheduleDays = this.generateNextDays(10)
  99. }
  100. }).catch((error) => {
  101. console.error('加载排程数据错误:', error)
  102. this.scheduleDays = this.generateNextDays(10)
  103. }).finally(() => {
  104. this.loading = false
  105. })
  106. },
  107. generateNextDays (days) {
  108. const result = []
  109. const today = new Date()
  110. const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  111. for (let i = 0; i < days; i++) {
  112. const date = new Date(today)
  113. date.setDate(today.getDate() + i)
  114. const dateStr = this.formatDate(date)
  115. const dateLabel = `${date.getMonth() + 1}/${date.getDate()}`
  116. const weekday = weekdays[date.getDay()]
  117. result.push({
  118. date: dateStr,
  119. dateLabel: dateLabel,
  120. weekday: weekday,
  121. tasks: []
  122. })
  123. }
  124. return result
  125. },
  126. formatDate (date) {
  127. const year = date.getFullYear()
  128. const month = String(date.getMonth() + 1).padStart(2, '0')
  129. const day = String(date.getDate()).padStart(2, '0')
  130. return `${year}-${month}-${day}`
  131. },
  132. getSupplierDisplayName (supplierName) {
  133. const value = supplierName || ''
  134. return value.length > 30 ? value.substring(0, 30) : value
  135. },
  136. buildTaskLineText (task) {
  137. const displayName = task.qcDisplay || this.$store.state.user.userDisplay || this.$store.state.user.name
  138. const poNo = task.poNo || ''
  139. const supplierName = this.getSupplierDisplayName(task.supplierName)
  140. return [displayName, poNo, supplierName].filter(item => item).join(' | ')
  141. },
  142. // 点击任务卡片 - 只传递申请单号
  143. handleTaskClick (task, date) {
  144. console.log('点击任务:', task, '日期:', date)
  145. // 构建查询参数,只传递申请单号
  146. const query = {}
  147. if (task.requestNo) {
  148. query.requestNo = task.requestNo
  149. }
  150. // 不再传递 planStartDate, planEndDate, supplierName
  151. this.$router.push({
  152. path: '/inspection-inspectionPendingList',
  153. query: query
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .my-todo-container {
  161. padding: 20px;
  162. background: #fff;
  163. min-height: 100%;
  164. }
  165. .page-header {
  166. margin-bottom: 20px;
  167. .page-title {
  168. font-size: 20px;
  169. font-weight: bold;
  170. color: #303133;
  171. margin: 0 0 8px 0;
  172. }
  173. .page-desc {
  174. font-size: 14px;
  175. color: #909399;
  176. margin: 0;
  177. }
  178. }
  179. .schedule-grid {
  180. display: grid;
  181. grid-template-columns: repeat(5, 1fr);
  182. grid-template-rows: repeat(2, 1fr);
  183. gap: 15px;
  184. min-height: 600px;
  185. }
  186. // 排程卡片 - 固定高度,内容区域滚动
  187. .schedule-card {
  188. border: 2px solid #dcdfe6;
  189. border-radius: 4px;
  190. background: #fff;
  191. display: flex;
  192. flex-direction: column;
  193. height: 470px;
  194. width: 100%;
  195. &:hover {
  196. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  197. }
  198. .card-header {
  199. padding: 10px 12px;
  200. background: #f5f7fa;
  201. border-bottom: 2px solid #dcdfe6;
  202. display: flex;
  203. justify-content: space-between;
  204. align-items: center;
  205. flex-shrink: 0;
  206. .date-label {
  207. font-size: 18px;
  208. font-weight: bold;
  209. color: #303133;
  210. }
  211. .date-weekday {
  212. font-size: 13px;
  213. color: #909399;
  214. }
  215. }
  216. .card-body {
  217. flex: 1;
  218. padding: 10px;
  219. overflow-y: auto;
  220. display: flex;
  221. flex-direction: column;
  222. gap: 8px;
  223. max-height: calc(100% - 55px);
  224. &::-webkit-scrollbar {
  225. width: 4px;
  226. }
  227. &::-webkit-scrollbar-thumb {
  228. background: #dcdfe6;
  229. border-radius: 2px;
  230. &:hover {
  231. background: #c0c4cc;
  232. }
  233. }
  234. }
  235. }
  236. .task-item {
  237. padding: 10px;
  238. background: #f5f7fa;
  239. border: 1px solid #dcdfe6;
  240. border-radius: 3px;
  241. cursor: pointer;
  242. transition: all 0.3s;
  243. flex-shrink: 0;
  244. &:hover {
  245. background: #ecf5ff;
  246. border-color: #409eff;
  247. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
  248. transform: translateY(-2px);
  249. }
  250. }
  251. .task-line-text {
  252. font-size: 12px;
  253. color: #303133;
  254. white-space: nowrap;
  255. overflow: hidden;
  256. text-overflow: ellipsis;
  257. }
  258. .empty-slot {
  259. flex: 1;
  260. display: flex;
  261. align-items: center;
  262. justify-content: center;
  263. min-height: 80px;
  264. .empty-text {
  265. color: #c0c4cc;
  266. font-size: 13px;
  267. }
  268. }
  269. ::-webkit-scrollbar {
  270. width: 6px;
  271. height: 6px;
  272. }
  273. ::-webkit-scrollbar-thumb {
  274. background: #c0c4cc;
  275. border-radius: 3px;
  276. &:hover {
  277. background: #909399;
  278. }
  279. }
  280. ::-webkit-scrollbar-track {
  281. background: #f5f7fa;
  282. }
  283. </style>