<template>
  <div id="detail">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="top">
          <el-button type="primary" size="mini" @click="back">返回</el-button>
        </el-col>
        <el-col :span="24" class="down">
          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @view="toView"></data-table>
        </el-col>
      </el-col>
    </el-row>
    <el-dialog class="dialog" title="意见详情" width="40%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
      <el-col :span="24" class="one">
        <el-col :span="24" class="info">
          {{ form.desc }}
        </el-col>
      </el-col>
    </el-dialog>
  </div>
</template>

<script>
import dataTable from '@common/src/components/frame/filter-page-table.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: verifyRecord } = createNamespacedHelpers('verifyRecord');
export default {
  name: 'detail',
  props: {},
  components: {
    dataTable,
  },
  data: function() {
    return {
      opera: [
        {
          label: '意见查看',
          method: 'view',
        },
        {
          label: '专家意见查看',
          method: 'expertView',
          display: item => {
            return item.status == '-2' ? true : false;
          },
        },
      ],
      fields: [
        { label: '审核类型', prop: 'step', showTip: true },
        { label: '审核人', prop: 'verify', showTip: true },
        { label: '审核电话', prop: 'verify_phone', showTip: true },
        { label: '审核时间', prop: 'create_time', showTip: true },
        {
          label: '状态',
          prop: 'status',
          format: item => {
            return item === '0'
              ? '待审中'
              : item === '1'
              ? '初审通过'
              : item === '-1'
              ? '初审未通过'
              : item === '2'
              ? '评分通过'
              : item === '-2'
              ? '评分未通过'
              : '1';
          },
        },
      ],
      list: [],
      total: 0,
      // 意见详情
      dialog: false,
      form: {},
    };
  },
  async created() {
    await this.search();
  },
  methods: {
    ...verifyRecord(['query']),
    // 查询列表
    async search({ skip = 0, limit = 10, ...info } = {}) {
      const res = await this.query({ skip, limit, apply_id: this.id, ...info });
      if (this.$checkRes(res)) {
        this.$set(this, 'list', res.data);
        this.$set(this, `total`, res.total);
      }
    },
    // 意见查看
    toView({ data }) {
      this.$set(this, `form`, data);
      this.dialog = true;
    },
    // 取消查看
    handleClose() {
      this.form = {};
      this.dialog = false;
    },
    // 返回
    back() {
      this.$router.push({ path: '/updateApply' });
    },
  },
  computed: {
    ...mapState(['user']),
    id() {
      return this.$route.query.id;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

<style lang="less" scoped>
.main {
  .top {
    text-align: right;
    margin: 0 0 10px 0;
  }
}
.dialog {
  /deep/.el-dialog__body {
    min-height: 330px;
    padding: 0px 0px 10px 20px;
  }
  .one {
    .text {
      font-size: 18px;
      font-weight: bold;
      margin: 0 0 5px 0;
    }
    .info {
      font-size: 16px;
      height: 325px;
      overflow-y: auto;
      line-height: 30px;
    }
  }
}
</style>
