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

303 lines
8.1 KiB

3 years ago
  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. :min-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. ipAddress: this.$route.query.ip
  66. },
  67. // 展示列集
  68. columnList: [
  69. {
  70. tableId: "ProjectInfo",
  71. tableName: this.$route.meta.title,
  72. columnProp: "customer",
  73. columnLabel: "客户",
  74. columnHidden: false,
  75. columnImage: false,
  76. columnSortable: false,
  77. columnWidth: 100,
  78. format: null,
  79. functionId: this.$route.meta.menuId,
  80. sortLv: 0,
  81. status: true,
  82. fixed: '',
  83. serialNumber: null,
  84. columnType: null,
  85. align: null
  86. },
  87. {
  88. tableId: "ProjectInfo",
  89. tableName: this.$route.meta.title,
  90. columnProp: "project",
  91. columnLabel: "项目",
  92. columnHidden: false,
  93. columnImage: false,
  94. columnSortable: false,
  95. columnWidth: 100,
  96. format: null,
  97. functionId: this.$route.meta.menuId,
  98. sortLv: 0,
  99. status: true,
  100. fixed: '',
  101. serialNumber: null,
  102. columnType: null,
  103. align: null
  104. },
  105. {
  106. tableId: "ProjectInfo",
  107. tableName: this.$route.meta.title,
  108. columnProp: "taskHeader",
  109. columnLabel: "任务主题",
  110. columnHidden: false,
  111. columnImage: false,
  112. columnSortable: false,
  113. columnWidth: null,
  114. format: null,
  115. functionId: this.$route.meta.menuId,
  116. sortLv: 0,
  117. status: true,
  118. fixed: '',
  119. serialNumber: null,
  120. columnType: null,
  121. align: null
  122. },
  123. {
  124. tableId: "ProjectInfo",
  125. tableName: this.$route.meta.title,
  126. columnProp: "taskStartDate",
  127. columnLabel: "发起日期",
  128. columnHidden: false,
  129. columnImage: false,
  130. columnSortable: false,
  131. columnWidth: 100,
  132. format: null,
  133. functionId: this.$route.meta.menuId,
  134. sortLv: 0,
  135. status: true,
  136. fixed: '',
  137. serialNumber: null,
  138. columnType: null,
  139. align: null
  140. },
  141. {
  142. tableId: "ProjectInfo",
  143. tableName: this.$route.meta.title,
  144. columnProp: "requiredCompletionDate",
  145. columnLabel: "要求完成日期",
  146. columnHidden: false,
  147. columnImage: false,
  148. columnSortable: false,
  149. columnWidth: 100,
  150. format: null,
  151. functionId: this.$route.meta.menuId,
  152. sortLv: 0,
  153. status: true,
  154. fixed: '',
  155. serialNumber: null,
  156. columnType: null,
  157. align: null
  158. },
  159. {
  160. tableId: "ProjectInfo",
  161. tableName: this.$route.meta.title,
  162. columnProp: "depUserName",
  163. columnLabel: "责任部门|责任人",
  164. columnHidden: false,
  165. columnImage: false,
  166. columnSortable: false,
  167. columnWidth: 120,
  168. format: null,
  169. functionId: this.$route.meta.menuId,
  170. sortLv: 0,
  171. status: true,
  172. fixed: '',
  173. serialNumber: null,
  174. columnType: null,
  175. align: null
  176. },
  177. {
  178. tableId: "ProjectInfo",
  179. tableName: this.$route.meta.title,
  180. columnProp: "status",
  181. columnLabel: "状态",
  182. columnHidden: false,
  183. columnImage: false,
  184. columnSortable: false,
  185. columnWidth: 80,
  186. format: null,
  187. functionId: this.$route.meta.menuId,
  188. sortLv: 0,
  189. status: true,
  190. fixed: '',
  191. serialNumber: null,
  192. columnType: null,
  193. align: null
  194. },
  195. ],
  196. dataList: [],
  197. // 默认的刷新,滚动时间,滚动间距
  198. refreshTime: 5,
  199. rollTime: 5,
  200. rollPx: 1,
  201. }
  202. },
  203. activated() {
  204. // this.getDataList()
  205. },
  206. mounted() {
  207. this.$nextTick(() => {
  208. this.height = window.innerHeight - 30;
  209. })
  210. },
  211. methods: {
  212. // 获取数据列表
  213. getDataList() {
  214. getTaskDetailList(this.dataForm).then(({data}) => {
  215. if (data && data.code === 0) {
  216. this.dataList = data.data
  217. } else {
  218. this.dataList = []
  219. }
  220. this.dataListLoading = false
  221. })
  222. },
  223. tableRowClassName({row, rowIndex}) {
  224. if (row.status == '未受理' && this.dayjs(this.dayjs()).diff(row.createdDate, 'minutes') / 60 >= 12) {
  225. return 'finish'
  226. }
  227. if (row.status == '未受理') {
  228. return 'not-processing'
  229. }
  230. if (row.status == '已受理') {
  231. return 'processing'
  232. }
  233. // return ''
  234. },
  235. // 鼠标进入
  236. mouseEnter(time) {
  237. // 鼠标进入停止滚动和切换的定时任务
  238. this.autoRoll(true)
  239. },
  240. // 鼠标离开
  241. mouseLeave() {
  242. // 开启
  243. this.autoRoll()
  244. },
  245. // 设置自动滚动
  246. autoRoll(stop) {
  247. if (stop) {
  248. clearInterval(domTimer)
  249. return
  250. }
  251. this.$nextTick(() => {
  252. // 拿到表格挂载后的真实DOM
  253. const table = this.$refs.task_table
  254. // 拿到表格中承载数据的div元素
  255. const divData = table.bodyWrapper
  256. // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果
  257. domTimer = setInterval(() => {
  258. // 元素自增距离顶部像素
  259. divData.scrollTop = this.decimalUtil.add(Number(divData.scrollTop), Number(this.rollPx))
  260. // 判断元素是否滚动到底部(可视高度+距离顶部=整个高度)
  261. if (divData.clientHeight + divData.scrollTop + 1 >= divData.scrollHeight) {
  262. // 重置table距离顶部距离
  263. divData.scrollTop = 0
  264. }
  265. }, this.rollTime * 10)
  266. })
  267. },
  268. },
  269. created() {
  270. this.autoRoll()
  271. dataTimer = setInterval(() => {
  272. this.getDataList()
  273. }, 3000)
  274. },
  275. beforeUnmount() {
  276. clearInterval(dataTimer)
  277. clearInterval(domTimer)
  278. }
  279. }
  280. </script>
  281. <style>
  282. .mod-config .not-processing {
  283. background-color: #ffff00;
  284. }
  285. .mod-config .processing {
  286. / / background-color: #5f0e3f;
  287. }
  288. .mod-config .finish {
  289. background-color: orangered;
  290. color: #f2f6fc;
  291. }
  292. </style>