<template>
    <div>
      <h3>调查项</h3>
      <el-table v-loading="loading" :data="inforList">
        <el-table-column label="检查任务编码" align="center" prop="fCheckTaskCode" />
        <el-table-column label="检查对象分类" align="center" prop="fTypeCode" :formatter="fTypeCodeFormat" />
        <el-table-column label="调查内容" align="center" prop="fContents">
          <template slot-scope="scope">
            <span v-if="scope.row.fContents">{{ scope.row.fContents }}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="结果填写类型" align="center" prop="fResType" :formatter="fResTypeFormat" />
        <el-table-column label="结果填写选项" align="center" prop="fResOption">
          <template slot-scope="scope">
            <span v-if="scope.row.fResOption">{{ scope.row.fResOption }}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="顺序号" align="center" prop="ord">
          <template slot-scope="scope">
            <span v-if="scope.row.ord">{{ scope.row.ord }}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="最后修改时间" align="center" prop="fLastUpdateTime" :show-overflow-tooltip="true"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-document"
              @click="handleDetail(scope.row)"
            >详情</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        :pageSizes="[5,10, 20, 30, 50]"
        @pagination="getList"
      />

      <!-- 详情 -->
      <DetailInfo ref="detail"/>
    </div>
</template>

<script>
  import { listInfor } from "@/api/supervision/survey";
  import DetailInfo from "../../survey/components/DetailInfo";
  export default {
    name: "survey",
    props:{
      fCheckTaskCode:{
        type: String
      }
    },
    components:{
      DetailInfo
    },
    data(){
      return{
        loading: false,
        total: 0,
        queryParams: {
          pageNum: 1,
          pageSize: 5,
        },
        inforList:[],
        // 检查对象分类
        fTypeCodeOptions: [],
        // 结果填写类型
        fResTypeOptions: [],
      }
    },
    created() {
      this.queryParams.fCheckTaskCode = this.fCheckTaskCode;
      this.getList();
      this.getDicts("t_type_code").then(response => {
          this.fTypeCodeOptions = response.data;
      });
      this.getDicts("f_res_type").then(response => {
          this.fResTypeOptions = response.data;
      });
    },
    methods:{
      getList() {
        this.loading = true;
        listInfor(this.queryParams).then(response => {
          this.inforList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 检查对象分类
      fTypeCodeFormat(row, column) {
        return this.selectDictLabel(this.fTypeCodeOptions, row.fTypeCode);
      },
      // 结果填写类型，1单选、2-多选、3 输入字典翻译
      fResTypeFormat(row, column) {
        return this.selectDictLabel(this.fResTypeOptions, row.fResType);
      },
      //详情
      handleDetail(row){
        this.$refs.detail.getDetailInfo(row.fInsSurListInforId);
      },
    }
  }
</script>

<style scoped>

</style>
