table.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div class="eventTable height_100">
  3. <el-table :data="tableData" header-row-class-name="custom-table-header" @sort-change="sortChange"
  4. v-el-table-infinite-scroll="getList" :infinite-scroll-distance="10" :infinite-scroll-disabled="disabled"
  5. :height="row ? '300' : ''">
  6. <el-table-column label="#" width="60" type="index" align="center">
  7. <template slot-scope="scope">
  8. <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
  9. </template>
  10. </el-table-column>
  11. <el-table-column v-for="item in column" :key="item.value" :prop="item.value" :label="item.name" align="center"
  12. sortable="custom">
  13. <template slot-scope="scope">
  14. <div v-if="['name', 'reportProjectNum', 'patentProjectNum'].includes(item.value)">
  15. <el-link @click="handleItem(scope.row, item.value)">{{ scope.row[item.value] }}</el-link>
  16. </div>
  17. <div v-else-if="['scenarioId', 'eventDate'].includes(item.value)" v-html="getColumnData(scope.row, item.value)">
  18. </div>
  19. <div v-else>{{ scope.row[item.value] ? scope.row[item.value] : '--' }}</div>
  20. </template>
  21. </el-table-column>
  22. <el-table-column v-if="[1].indexOf(isOperate) == -1" label="操作" align="center" width="150px" >
  23. <template slot-scope="scope">
  24. <el-dropdown split-button type="primary" size="small" @click="handleClick(scope.row)"
  25. @command="handleCommand($event,scope.row)">
  26. <span>编 辑</span>
  27. <el-dropdown-menu slot="dropdown" style="text-align:center">
  28. <el-dropdown-item command="0">新增专题库</el-dropdown-item>
  29. <el-dropdown-item>
  30. <el-dropdown trigger="hover" placement="right-start">
  31. <span class="el-dropdown-link"> 新增报告 </span>
  32. <el-dropdown-menu class="children_item" v-if="dictMessage.REPORT_TYPE">
  33. <el-dropdown-item v-for="item in dictMessage.REPORT_TYPE.filter(item=>!['6'].includes(item.dictChildValue))" :key="item.dictChildLabel" @click.native="handleAnalyse(item.dictChildValue,scope.row)" v-if="$permission('/pcs/report/add/' + item.permission)">{{item.dictChildLabel}}</el-dropdown-item>
  34. </el-dropdown-menu>
  35. </el-dropdown>
  36. </el-dropdown-item>
  37. <el-dropdown-item command="10" divided style="color:red">删 除</el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <el-alert v-if="isFlag" title="正在努力加载中..." type="success" center :closable="false" show-icon></el-alert>
  44. <el-alert v-if="isMore" title="没有更多啦!" type="warning" center show-icon></el-alert>
  45. </div>
  46. </template>
  47. <script>
  48. import mixins from '../mixins';
  49. export default {
  50. mixins: [mixins],
  51. props: {
  52. isOperate: {//控制显示
  53. type: String,
  54. default: ''
  55. },
  56. column: {//显示栏位管理数组
  57. type: Array,
  58. default: () => {
  59. return [
  60. {
  61. ifGroup: false,
  62. ifSearch: true,
  63. name: "事件名称",
  64. type: "String",
  65. value: "name",
  66. },
  67. {
  68. name: "创建人",
  69. type: "String",
  70. value: "createName",
  71. ifSearch: true,
  72. ifGroup: false
  73. },
  74. {
  75. name: "创建时间",
  76. type: "DateTime",
  77. value: "createTime",
  78. ifSearch: true,
  79. ifGroup: true
  80. },
  81. {
  82. name: "发生时间",
  83. type: "DateTime",
  84. value: "eventDate",
  85. ifSearch: true,
  86. ifGroup: true
  87. },
  88. {
  89. name: "描述",
  90. type: "String",
  91. value: "description",
  92. ifSearch: true,
  93. ifGroup: false
  94. },
  95. {
  96. name: "应用场景",
  97. type: "Integer",
  98. value: "scenarioId",
  99. ifSearch: true,
  100. ifGroup: true
  101. }
  102. ]
  103. }
  104. },
  105. row: null
  106. },
  107. data() {
  108. return {
  109. //正在努力加载中
  110. isFlag: false,
  111. //没有更多啦!
  112. isMore: false,
  113. //禁用懒加载
  114. disabled: true,
  115. params: {
  116. size: 10,
  117. current: 0
  118. },
  119. // 排序数组
  120. sort: [],
  121. };
  122. },
  123. watch: {
  124. },
  125. mounted() {
  126. if (!this.row) {
  127. this.disabled = true
  128. } else {
  129. this.disabled = false
  130. // this.getList()
  131. }
  132. },
  133. methods: {
  134. getList() {
  135. if (!this.row) return;
  136. if (this.params.current * this.params.size >= this.params.total) {
  137. this.isMore = true
  138. if (!this.row.searchOption) {
  139. this.disabled = true
  140. }
  141. setTimeout(() => {
  142. this.isMore = false;
  143. this.isFlag = false
  144. }, 1000)
  145. }
  146. if (this.disabled) return;
  147. if (!this.row.searchOption) {
  148. this.params.current += 1
  149. } else {
  150. this.params.current = 1
  151. this.tableData=[]
  152. }
  153. let params = {
  154. ...this.params,
  155. ...this.row.searchOption,//检索条件
  156. orderDTOList: this.sort,//排序
  157. groupField: this.row.groupBy,
  158. groupFieldValue: this.row.row.value,
  159. }
  160. this.isMore = false;
  161. this.isFlag = true;
  162. this.$api.queryEvent(params).then(res => {
  163. if (res.code == 200) {
  164. this.tableData = this.tableData.concat(res.data.data)
  165. this.params.total = res.data.total
  166. }
  167. }).catch(err => {
  168. this.tableData = []
  169. })
  170. setTimeout(() => {
  171. this.isMore = false;
  172. this.isFlag = false
  173. }, 1000)
  174. },
  175. // 排序
  176. sortChange({ column, prop, order }) {
  177. this.handleSort({ column, prop, order })
  178. this.$emit('on-sort', { column, prop, order })
  179. },
  180. // 排序方法
  181. handleSort({ column, prop, order }) {
  182. if (order == 'null') {
  183. return;
  184. }
  185. var orderType = {
  186. ascending: 0,
  187. descending: 1
  188. }
  189. var params = this.sort.find(item => {
  190. return item.orderBy == prop
  191. })
  192. if (params) {
  193. params.orderType = orderType[order]
  194. } else {
  195. params = {}
  196. params.orderBy = prop
  197. params.orderType = orderType[order]
  198. this.sort.push(params)
  199. }
  200. this.getList()
  201. },
  202. // 数据处理
  203. getColumnData(row, key) {
  204. if (key == 'scenarioId') {
  205. if (row.scenarioName) {
  206. return row.scenarioName
  207. } else {
  208. return '--'
  209. }
  210. }
  211. else if (key == 'eventDate') {
  212. if (row.eventDate) {
  213. return row.eventDate.slice(0, 10)
  214. } else {
  215. return '--'
  216. }
  217. }
  218. },
  219. },
  220. };
  221. </script>
  222. <style lang="scss">
  223. .eventTable {}
  224. </style>
  225. <style lang="scss" scoped></style>