<!--
 * @description: 出罪指标
 * @fileName: InnocentIndex
 * @author: 17076
 * @date: 2024/6/26-下午3:15
 * @version: V1.0.0
-->

<template>
  <div class="innocent-content">
    <vxe-grid v-bind="gridOptions" style="margin-top: 10px">
      <template #opera="{row}">
        <el-button type="text" icon="el-icon-check" @click="handelStart(row)" />
        <el-button type="text" icon="el-icon-close" @click="handleDel(row)" />
      </template>
      <template #result="{row}">
        <div v-if="row.newFlag" style="padding: 10px 0;">
          <el-badge value="new" class="item">
            <el-tag :type="row.indexResult === 'true' ? 'success' : 'error'">{{ row.indexResult?row.indexResult=== 'true' ? '符合' : '不符合': '未评估' }}</el-tag>
          </el-badge>
        </div>
        <el-tag v-else :type="row.indexResult === 'true' ? 'success' : 'error'">{{ row.indexResult?row.indexResult=== 'true' ? '符合' : '不符合': '未评估' }}</el-tag>
      </template>
    </vxe-grid>
    <div style="text-align: center">
      <cs-page
        :page.sync="queryForm.page"
        :limit.sync="queryForm.size"
        :total="queryForm.total"
        @pagination="fetchData"
      />
    </div>
  </div>
</template>

<script>
import mixin from '@/views/mixin'
import { queryIndexDetail } from '@/api/caseDetails'

export default {
  name: 'InnocentIndex',
  mixins: [mixin],
  props: {
    // 是否编辑
    isEdit: {
      type: Boolean,
      default: false
    },
    // 是否展开
    isExpand: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      gridOptions: {
        ...mixin.data().gridOptions,
        treeConfig: {},
        columns: [
          { title: '', width: '50px', treeNode: true },
          { title: '序号', type: 'seq', width: '50px' },
          { title: '分析结果', width: '200px', field: 'indexResult', slots: { default: 'result' }},
          { title: '指标名称', field: 'indexName', align: 'left' },
          { title: '分值', width: '200px', field: 'score' },
          { title: '数据来源', width: '200px', field: 'indexSource', formatter: ({ cellValue }) => {
            return cellValue ? this.indexSourceList.find(item => item.value === cellValue).label : ''
          } },
          { title: '笔录结果', field: 'record' },
          // { title: '原子指标', field: 'atomicIndex' }
          // { title: '必要证据', field: 'questioner' },
          // { title: '评估结果', field: 'startTime' },
          // { title: '评估操作', slots: { default: 'opera' }, fixed: 'right', width: '100px' },
        ],
        data: []

      },
      indexSourceList: JSON.parse(sessionStorage.getItem('index_source'))
    }
  },
  watch: {
    isExpand: {
      handler: function(newVal, oldVal) {
        if (newVal !== oldVal) {
          this.tableHeight(this.isExpand ? 530 : 320)
        }
      },
      immediate: true
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    // 获取数据
    fetchData() {
      queryIndexDetail({ caseId: this.$route.params['id'], indexType: '3' }, this.queryForm.page, this.queryForm.size).then(res => {
        this.gridOptions.data = res.data.records
        this.queryForm.total = res.data.total
      })
    },
    // 开始分析
    handelStart(row) {

    },
    // 删除
    handleDel(row) {
      this.$baseConfirm('你确定要删除当前项吗', null, async() => {

      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
