auditRecord.vue 4.81 KB
<template>
  <div class="app-content" style="height:70vh;overflow:auto;">
    <div class="submit-btn">
      <a-button type="primary" @click="recordClick(null,'create')">添加</a-button>
    </div>
    <a-table :dataSource="tableData" :columns="columns" rowKey="id" :pagination="false" :loading="loading">
      <template slot="state" slot-scope="record">
        {{record.state}}
      </template>
      <template slot="option" slot-scope="record">
        <a-button type="link" size="small" @click="recordClick(record,'edit')">修改</a-button>
        <a-popconfirm title="删除后不可恢复,确定要删除吗?" ok-text="确定" cancel-text="取消" @confirm="recordClick(record,'del')">
          <a-button type="link" size="small">删除</a-button>
        </a-popconfirm>
      </template>
    </a-table>
    <a-pagination v-if="pagination.total > 0" :total="pagination.total" show-size-changer show-quick-jumper v-model="pagination.pageIndex" :page-size="pagination.pageSize" :page-size-options="pagination.pageSizeOptions" @showSizeChange="showSizeChange" @change="change" :showTotal="() => `共 ${pagination.total} 条`" />
    <a-modal v-model="visible" title="添加/修改" width="60%" :dialog-style="{ top: '14%' }" :footer="null" destroyOnClose>
      <record-edit v-model="auditObjectId" :obj="obj" @close="closeWindow" />
    </a-modal>
  </div>
</template>

<script>
import moment from 'moment'
import { isEmptyParams } from '@/views/utils/common'
import recordEdit from '@/views/manager/project/components/recordEdit';

export default {
  name: 'auditRecord',
  components: {
    recordEdit
  },
  data () {
    return {
      form: this.$form.createForm(this, { name: 'assign_search' }),
      searchForm: { auditObjectId: null },
      tableData: [],
      columns: [
        { title: '年度', dataIndex: 'reportYear', align: 'center' },
        { title: '审核单位', dataIndex: 'unitName', align: 'center' },
        { title: '审核人', dataIndex: 'personName', align: 'center' },
        { title: '审核内容', dataIndex: 'auditContent', align: 'center' },
        { title: '审核类型', dataIndex: 'auditTypeName', align: 'center' },
        { title: '审核方式', dataIndex: 'auditMethodName', align: 'center' },
        { title: '审核顺序', dataIndex: 'showIndex', align: 'center' },
        { title: '审核结果', dataIndex: 'auditResultName', align: 'center' },
        { title: '添加时间', dataIndex: 'created', align: 'center' },
        { title: '修改时间', dataIndex: 'updated', align: 'center' },
        { title: '操作', scopedSlots: { customRender: 'option' }, align: 'center', fixed: 'right', width: 120, },
      ],
      pagination: { pageIndex: 1, pageSize: this.$defaultPageSize, total: 0, pageSizeOptions: this.$defaultPageSizeOptions },
      loading: true,
      visible: false,
      auditObjectId: null,
      obj: null
    }
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null
      }
    }
  },
  created () {
    this.getListByPage()
  },
  methods: {
    moment,
    getListByPage () {
      if (!!this.value) {
        this.loading = true
        this.searchForm.auditObjectId = this.value
        let par = { ...this.searchForm, pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }
        this.$api.auditManager.getListByPage(par).then(({ data = {} }) => {
          if (data) {
            const { dataList = [], total = 0 } = data
            this.tableData = dataList
            this.pagination.total = total
            this.loading = false
          }
        }).catch(() => {
          this.loading = false
        })
      } else {
        this.loading = false
      }
    },
    change () {
      this.getListByPage()
    },
    showSizeChange (current, pageSize) {
      this.pagination.pageIndex = current
      this.pagination.pageSize = pageSize
      this.getListByPage()
    },
    search () {
      this.pagination.pageIndex = 1
      this.getListByPage()
    },
    reset () {
      this.pagination.pageIndex = 1
      this.getListByPage()
    },
    recordClick (record, type) {
      if (type === 'create') {
        this.auditObjectId = this.value
        this.obj = null
        this.visible = true
      }
      if (type === 'edit') {
        this.auditObjectId = this.value
        this.obj = record
        this.visible = true
      } else if (type === 'del') {
        this.loading = true
        this.$api.auditManager.deleteRecord({ id: record.id }).then(({ data = {} }) => {
          if (data) {
            this.$message.success('删除成功')
            this.getListByPage()
          }
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      }
    },
    closeWindow (value) {
      if (value === 'edit') {
        this.visible = false
        this.getListByPage()
      }
    },
  },

}
</script>