赫艾前端
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.

301 lines
8.5 KiB

  1. <template>
  2. <div class="mod-config">
  3. <el-row>
  4. <el-col :span="24" style="display:flex">
  5. <div style=" margin: auto; width: 300px;height: 50px;display:flex">
  6. <h2>赫艾内部MES沟通系统</h2>
  7. </div>
  8. </el-col>
  9. </el-row>
  10. <el-row>
  11. <el-col :span="24">
  12. <el-table
  13. :data="dataList"
  14. border
  15. ref="task_table"
  16. :height="height"
  17. :row-class-name="tableRowClassName"
  18. @mouseenter.native="mouseEnter"
  19. @mouseleave.native="mouseLeave"
  20. style="width: 100%;">
  21. <el-table-column
  22. v-for="(item,index) in columnList" :key="index"
  23. :sortable="item.columnSortable"
  24. :prop="item.columnProp"
  25. :header-align="'center'"
  26. :show-overflow-tooltip="item.showOverflowTooltip"
  27. :align="item.align"
  28. :fixed="item.fixed==''?false:item.fixed"
  29. :width="item.columnWidth"
  30. :label="item.columnLabel">
  31. <template slot-scope="scope">
  32. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  33. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  34. style="width: 100px; height: 80px"/></span>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </template>
  42. <script>
  43. import {getTaskDetailList} from '@/api/taskmanage/tasklist.js'
  44. let domTimer = '' // 自动滚动的定时任务
  45. let dataTimer = '' // 数据定时任务
  46. export default {
  47. data() {
  48. return {
  49. height: 200,
  50. dataForm: {
  51. site: this.$store.state.user.site ? this.$store.state.user.site : 1,
  52. customer: '',
  53. taskHeader: '',
  54. project: '',
  55. taskDescription: '',
  56. taskInitiator: '',
  57. finalStatus: '未完成',
  58. department: '',
  59. responsiblePerson: '',
  60. startDate: '',
  61. endDate: '',
  62. finishStartDate: '',
  63. finishEndDate: '',
  64. status: '',
  65. },
  66. // 展示列集
  67. columnList: [
  68. {
  69. tableId: "ProjectInfo",
  70. tableName: this.$route.meta.title,
  71. columnProp: "customer",
  72. columnLabel: "客户",
  73. columnHidden: false,
  74. columnImage: false,
  75. columnSortable: false,
  76. columnWidth: 100,
  77. format: null,
  78. functionId: this.$route.meta.menuId,
  79. sortLv: 0,
  80. status: true,
  81. fixed: '',
  82. serialNumber: null,
  83. columnType: null,
  84. align: null
  85. },
  86. {
  87. tableId: "ProjectInfo",
  88. tableName: this.$route.meta.title,
  89. columnProp: "project",
  90. columnLabel: "项目",
  91. columnHidden: false,
  92. columnImage: false,
  93. columnSortable: false,
  94. columnWidth: 100,
  95. format: null,
  96. functionId: this.$route.meta.menuId,
  97. sortLv: 0,
  98. status: true,
  99. fixed: '',
  100. serialNumber: null,
  101. columnType: null,
  102. align: null
  103. },
  104. {
  105. tableId: "ProjectInfo",
  106. tableName: this.$route.meta.title,
  107. columnProp: "taskHeader",
  108. columnLabel: "任务主题",
  109. columnHidden: false,
  110. columnImage: false,
  111. columnSortable: false,
  112. columnWidth: null,
  113. format: null,
  114. functionId: this.$route.meta.menuId,
  115. sortLv: 0,
  116. status: true,
  117. fixed: '',
  118. serialNumber: null,
  119. columnType: null,
  120. align: null
  121. },
  122. {
  123. tableId: "ProjectInfo",
  124. tableName: this.$route.meta.title,
  125. columnProp: "taskStartDate",
  126. columnLabel: "发起日期",
  127. columnHidden: false,
  128. columnImage: false,
  129. columnSortable: false,
  130. columnWidth: 100,
  131. format: null,
  132. functionId: this.$route.meta.menuId,
  133. sortLv: 0,
  134. status: true,
  135. fixed: '',
  136. serialNumber: null,
  137. columnType: null,
  138. align: null
  139. },
  140. {
  141. tableId: "ProjectInfo",
  142. tableName: this.$route.meta.title,
  143. columnProp: "requiredCompletionDate",
  144. columnLabel: "要求完成日期",
  145. columnHidden: false,
  146. columnImage: false,
  147. columnSortable: false,
  148. columnWidth: 100,
  149. format: null,
  150. functionId: this.$route.meta.menuId,
  151. sortLv: 0,
  152. status: true,
  153. fixed: '',
  154. serialNumber: null,
  155. columnType: null,
  156. align: null
  157. },
  158. {
  159. tableId: "ProjectInfo",
  160. tableName: this.$route.meta.title,
  161. columnProp: "depUserName",
  162. columnLabel: "责任部门|责任人",
  163. columnHidden: false,
  164. columnImage: false,
  165. columnSortable: false,
  166. columnWidth: 120,
  167. format: null,
  168. functionId: this.$route.meta.menuId,
  169. sortLv: 0,
  170. status: true,
  171. fixed: '',
  172. serialNumber: null,
  173. columnType: null,
  174. align: null
  175. },
  176. {
  177. tableId: "ProjectInfo",
  178. tableName: this.$route.meta.title,
  179. columnProp: "status",
  180. columnLabel: "状态",
  181. columnHidden: false,
  182. columnImage: false,
  183. columnSortable: false,
  184. columnWidth: 80,
  185. format: null,
  186. functionId: this.$route.meta.menuId,
  187. sortLv: 0,
  188. status: true,
  189. fixed: '',
  190. serialNumber: null,
  191. columnType: null,
  192. align: null
  193. },
  194. ],
  195. dataList: [],
  196. // 默认的刷新,滚动时间,滚动间距
  197. refreshTime: 5,
  198. rollTime: 5,
  199. rollPx: 1,
  200. }
  201. },
  202. activated() {
  203. // this.getDataList()
  204. },
  205. mounted() {
  206. this.$nextTick(() => {
  207. this.height = window.innerHeight - 30;
  208. })
  209. },
  210. methods: {
  211. // 获取数据列表
  212. getDataList() {
  213. getTaskDetailList(this.dataForm).then(({data}) => {
  214. if (data && data.code === 0) {
  215. this.dataList = data.data
  216. } else {
  217. this.dataList = []
  218. }
  219. this.dataListLoading = false
  220. })
  221. },
  222. tableRowClassName({row, rowIndex}) {
  223. if (row.status == '未受理' && this.dayjs(this.dayjs()).diff( row.createdDate,'minutes')/60>=12) {
  224. return 'finish'
  225. }
  226. if (row.status == '未受理') {
  227. return 'not-processing'
  228. }
  229. if (row.status == '已受理') {
  230. return 'processing'
  231. }
  232. // return ''
  233. },
  234. // 鼠标进入
  235. mouseEnter(time) {
  236. // 鼠标进入停止滚动和切换的定时任务
  237. this.autoRoll(true)
  238. },
  239. // 鼠标离开
  240. mouseLeave() {
  241. // 开启
  242. this.autoRoll()
  243. },
  244. // 设置自动滚动
  245. autoRoll(stop) {
  246. if (stop) {
  247. clearInterval(domTimer)
  248. return
  249. }
  250. this.$nextTick(() => {
  251. // 拿到表格挂载后的真实DOM
  252. const table = this.$refs.task_table
  253. // 拿到表格中承载数据的div元素
  254. const divData = table.bodyWrapper
  255. // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果
  256. domTimer = setInterval(() => {
  257. // 元素自增距离顶部像素
  258. divData.scrollTop = this.decimalUtil.add(Number(divData.scrollTop), Number(this.rollPx))
  259. // 判断元素是否滚动到底部(可视高度+距离顶部=整个高度)
  260. if (divData.clientHeight + divData.scrollTop + 1 >= divData.scrollHeight) {
  261. // 重置table距离顶部距离
  262. divData.scrollTop = 0
  263. }
  264. }, this.rollTime * 10)
  265. })
  266. },
  267. },
  268. created() {
  269. this.autoRoll()
  270. dataTimer = setInterval(() => {
  271. this.getDataList()
  272. }, 3000)
  273. },
  274. beforeUnmount() {
  275. clearInterval(dataTimer)
  276. clearInterval(domTimer)
  277. }
  278. }
  279. </script>
  280. <style>
  281. .mod-config .not-processing {
  282. background-color: #ffff00;
  283. }
  284. .mod-config .processing {
  285. // background-color: #5f0e3f;
  286. }
  287. .mod-config .finish {
  288. background-color:orangered;
  289. }
  290. </style>