ExecutorlogList.vue 3.92 KB
<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: false }"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      ></a-table>
    </div>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { httpGroupRequest } from '@/api/GroupRequest.js'
import { getAction, postAction } from '@/api/manage'

export default {
  name: 'ScaninRecordList',
  mixins: [JeecgListMixin, mixinDevice],
  props: ['groupId'],
  components: {},
  data() {
    let ellipsis1 = (v, l = 180) => <j-ellipsis value={v} length={l} />
    return {
      description: '上线扫码管理页面',
      dataSource: [],
      isorter: {
        column: 'updateTime',
        order: 'desc'
      },
      // 表头
      columns: [
        {
          title: 'ID',
          align: 'center',
          dataIndex: 'id'
        },
        {
          title: this.$t('system.content'),
          align: 'center',
          dataIndex: 'content',
          customRender: t => ellipsis1(t)
        },
        {
          title: this.$t('system.level'),
          align: 'center',
          dataIndex: 'level'
        },
        {
          title: this.$t('system.createTime'),
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: this.$t('system.updateTime'),
          align: 'center',
          dataIndex: 'updateTime'
        }
      ],
      url: {
        list: '/log/executorlog/list',
        add: '/scan/scaninRecord/add'
      },
      dictOptions: {},
      superFieldList: []
    }
  },
  mounted() {
    // 每隔3秒定时刷新
    this.timer = setInterval(() => {
      this.loadPeriodData()
    }, 2000)
  },
  created() {
    // this.$nextTick(() => this.$refs.input.focus())
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    // focus() {
    //   this.$nextTick(() => this.$refs.input.focus())
    // },
    add() {
      let params = Object.assign({}, this.queryParam, this.isorter)
      let url = `${this.url.add}`
      //缓存key
      let groupIdKey
      if (this.groupId) {
        groupIdKey = this.groupId + url
      }
      httpGroupRequest(() => postAction(url, params), groupIdKey).then(res => {
        if (res.success) {
          if (res.message != '') {
            this.$notification.success({
              message: this.$t('system.systemMessage'),
              description: this.queryParam.context + ' ' + this.$t('scanin.scanSuccessful')
            })
            this.loadPeriodData()
          }
        } else {
          this.$notification.error({
            message: this.$t('system.systemMessage'),
            description: res.message
          })
        }
        this.searchReset()
      })
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'context', text: 'context', dictCode: '' })
      fieldList.push({ type: 'string', value: 'status', text: 'status', dictCode: '' })
      this.superFieldList = fieldList
    },
    async loadPeriodData() {
      let params = Object.assign({}, null, this.isorter)
      let url = `${this.url.list}`
      //缓存key
      let groupIdKey
      if (this.groupId) {
        groupIdKey = this.groupId + url
      }
      httpGroupRequest(() => getAction(url, params), groupIdKey).then(res => {
        let data = res.result
        if (data.length > 0) {
          this.dataSource = data
        } else {
          this.dataSource = []
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>