index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="table-container">
  3. <vab-query-form>
  4. <vab-query-form-left-panel>
  5. <el-form
  6. ref="searchForm"
  7. :model="searchForm"
  8. :inline="true"
  9. @submit.native.prevent
  10. >
  11. <el-form-item>
  12. <el-date-picker
  13. v-model="times"
  14. type="datetimerange"
  15. range-separator="至"
  16. start-placeholder="开始日期"
  17. end-placeholder="结束日期"
  18. format="yyyy-MM-dd HH:mm:ss"
  19. value-format="yyyy-MM-dd HH:mm:ss"
  20. ></el-date-picker>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-select clearable v-model="searchForm.type" placeholder="请选择">
  24. <el-option
  25. v-for="item in types"
  26. :key="item.value"
  27. :label="item.label"
  28. :value="item.value">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button
  34. icon="el-icon-search"
  35. type="primary"
  36. native-type="submit"
  37. @click="handleQuery"
  38. >
  39. 查询
  40. </el-button>
  41. </el-form-item>
  42. </el-form>
  43. </vab-query-form-left-panel>
  44. <vab-query-form-right-panel :span="1">
  45. </vab-query-form-right-panel>
  46. </vab-query-form>
  47. <el-table
  48. ref="table"
  49. v-loading="listLoading"
  50. :data="tableData"
  51. :element-loading-text="elementLoadingText"
  52. :height="height"
  53. :header-cell-style="{ 'text-align': 'center' }"
  54. :cell-style="{ 'text-align': 'center' }"
  55. >
  56. <el-table-column show-overflow-tooltip label="序号" width="95">
  57. <template #default="scope">
  58. {{ scope.$index + 1 }}
  59. </template>
  60. </el-table-column>
  61. <el-table-column show-overflow-tooltip label="日志类型" prop="type" :formatter="formatType"/>
  62. <el-table-column show-overflow-tooltip label="内容" prop="content" :formatter="formatContent"/>
  63. <el-table-column show-overflow-tooltip label="状态" prop="state" />
  64. <el-table-column show-overflow-tooltip label="状态内容" prop="stateContent" />
  65. <el-table-column show-overflow-tooltip label="场站编码" prop="stationCode" />
  66. <el-table-column
  67. show-overflow-tooltip
  68. label="标记时间"
  69. prop="time"
  70. :formatter="formatDate"
  71. />
  72. <el-table-column
  73. show-overflow-tooltip
  74. label="创建时间"
  75. prop="createTime"
  76. :formatter="formatDate"
  77. />
  78. <el-table-column show-overflow-tooltip label="操作" width="180px">
  79. <template #default="{ row }">
  80. <el-button type="text" @click="handleDelete(row)">
  81. <el-tag type="danger">删除</el-tag>
  82. </el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <el-pagination
  87. :background="background"
  88. :current-page="page.currentPage"
  89. :layout="layout"
  90. :page-size="page.pageSize"
  91. :total="page.total"
  92. @current-change="handleCurrentChange"
  93. @size-change="handleSizeChange"
  94. ></el-pagination>
  95. </div>
  96. </template>
  97. <script>
  98. import { fetchList ,delObj} from '@/api/record'
  99. export default {
  100. name: 'Record',
  101. data() {
  102. return {
  103. tableData: [],
  104. types: [
  105. {label:"修正DQ数据",value:"PULL_CORRECT"},
  106. {label:"交互权限",value:"COM_PERMISSON"},
  107. {label:"修正DQ文件",value:"PULL_CORRECT_JY"},
  108. {label:"修正数据",value:"CORRECT_DATA"},
  109. {label:"回传数据",value:"BACK_DATA"},
  110. {label:"回传文件解析",value:"BACK_DATA_FILE"},
  111. ],
  112. contents:[
  113. {label:"回传预测数据",value:"BACK_FORE_ALL"},
  114. {label:"回传统计数据",value:"BACK_STAT_ALL"},
  115. {label:"下发超短期修正",value:"CORRULTRSHOR"},
  116. {label:"下发检修计划",value:"REPAPLAN"},
  117. {label:"文件解析",value:"BACK_FILE_ANALYSIS"},
  118. ],
  119. searchForm: {},
  120. times: [
  121. this.dateFormat("yyyy-MM-dd HH:mm:ss",new Date(new Date().setHours(0, 0, 0, 0))),
  122. this.dateFormat("yyyy-MM-dd HH:mm:ss",new Date(new Date().setHours(23, 59, 59, 59))),
  123. ],
  124. listLoading: true,
  125. layout: 'total, sizes, prev, pager, next, jumper',
  126. total: 0,
  127. background: true,
  128. elementLoadingText: '正在加载...',
  129. page: {
  130. total: 0, // 总页数
  131. currentPage: 1, // 当前页数
  132. pageSize: 20, // 每页显示多少条
  133. },
  134. }
  135. },
  136. computed: {
  137. height() {
  138. return this.$baseTableHeight()
  139. },
  140. },
  141. created() {
  142. this.fetchData()
  143. },
  144. methods: {
  145. async fetchData() {
  146. this.listLoading = true
  147. this.searchForm.startTime = null
  148. this.searchForm.endTime = null
  149. if(this.times !=null){
  150. this.searchForm.startTime = this.times[0]
  151. this.searchForm.endTime = this.times[1]
  152. }
  153. fetchList(
  154. Object.assign(
  155. {
  156. current: this.page.currentPage,
  157. size: this.page.pageSize,
  158. },
  159. this.searchForm
  160. )
  161. )
  162. .then((response) => {
  163. this.tableData = response.data.records
  164. this.page.total = response.data.total
  165. this.listLoading = false
  166. })
  167. .catch(() => {
  168. this.listLoading = false
  169. })
  170. },
  171. handleSizeChange(val) {
  172. this.page.pageSize = val
  173. this.page.currentPage = 1
  174. this.fetchData()
  175. },
  176. handleCurrentChange(val) {
  177. this.page.currentPage = val
  178. this.fetchData()
  179. },
  180. handleQuery() {
  181. for (var v in this.searchForm) {
  182. if (this.searchForm[v] == '') {
  183. delete this.searchForm[v]
  184. }
  185. }
  186. this.page.currentPage = 1
  187. this.fetchData()
  188. },
  189. handleDelete(row) {
  190. this.$baseConfirm('你确定要删除当前项吗', null, async () => {
  191. await delObj(row.id)
  192. this.$baseMessage('删除成功', 'success')
  193. this.fetchData()
  194. })
  195. },
  196. formatType(row, column) {
  197. for (let i = 0; i < this.types.length; i++) {
  198. if (row.type == this.types[i].value) {
  199. return this.types[i].label
  200. }
  201. }
  202. },
  203. formatContent(row, column) {
  204. for (let i = 0; i < this.contents.length; i++) {
  205. if (row.content == this.contents[i].value) {
  206. return this.contents[i].label
  207. }
  208. }
  209. },
  210. formatDate(row, column) {
  211. let pro = column.property
  212. return row[pro]
  213. },
  214. dateFormat(fmt, date) {
  215. let ret
  216. const opt = {
  217. 'y+': date.getFullYear().toString(), // 年
  218. 'M+': (date.getMonth() + 1).toString(), // 月
  219. 'd+': date.getDate().toString(), // 日
  220. 'H+': date.getHours().toString(), // 时
  221. 'm+': date.getMinutes().toString(), // 分
  222. 's+': date.getSeconds().toString(), // 秒
  223. // 有其他格式化字符需求可以继续添加,必须转化成字符串
  224. }
  225. for (let k in opt) {
  226. ret = new RegExp('(' + k + ')').exec(fmt)
  227. if (ret) {
  228. fmt = fmt.replace(
  229. ret[1],
  230. ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, '0')
  231. )
  232. }
  233. }
  234. return fmt
  235. },
  236. },
  237. }
  238. </script>
  239. <style>
  240. .demo-table-expand {
  241. font-size: 0;
  242. }
  243. .demo-table-expand label {
  244. width: 90px;
  245. color: #99a9bf;
  246. }
  247. .demo-table-expand .el-form-item {
  248. margin-right: 0;
  249. margin-bottom: 0;
  250. width: 50%;
  251. }
  252. </style>