<template>
  <div :class="$style.wrapHeight">
    <sd-data-table-ex
      :key="key"
      ref="icDefectStatementList"
      :editnode="editnode"
      form-id="icDefectList"
      :data-url="'api/xcoa-mobile/v1//icrectrequire/all-list'"
      :columns="columns"
      show-selection
      :show-advance-query="false"
      :filter-expressions="expressions"
      :search-fields="['evaluationName', 'measureName']"
    >
    </sd-data-table-ex>
  </div>
</template>

<script>
import axios from '@/common/services/axios-instance'
import systemManage from '@/system-manage/system-manage'
import TableColumnTypes from '@/common/services/table-column-types'
import auditAdvancedQueryMixins from '@product/iam/components/audit-advanced-query-mixins'
import IcService from '../../ic-service'
import components from './_import-components/iam-ic-defect-statement-list-import'
export default {
  name: 'IamIcDefectStatementList',
  metaInfo: {
    title: '缺陷清单引用列表',
  },
  components: {
    ...components,
  },
  // auditAdvancedGroupMixins
  mixins: [auditAdvancedQueryMixins],
  data() {
    return {
      yearArry: [],
      waterMark: systemManage.getFormWaterMark(),
      flag: true,
      recordId: '',
      editnode: true, // 列表是否可以新建
      key: 0,
      treeData: [],
      searchform: 'searchform',
      formData: {
        year: '',
        evaluationname: '',
        evaluationways: '',
        evaluationtype: '',
      },
      evaluationways: [],
      evaluationtype: [],
      columns: [
        {
          title: '序号',
          customRender: (text, record, index) => `${index + 1}`,
          width: '70px',
        },
        { dataIndex: 'id', sdHidden: true },
        {
          title: '评价名称',
          dataIndex: 'evaluationName',
        },
        {
          title: '控制点名称',
          dataIndex: 'measureName',
          scopedSlots: { customRender: 'islink' },
        },

        {
          title: '控制点编号',
          dataIndex: 'measureCode',
          width: '170px',
        },
        {
          title: '录入方式',
          dataIndex: 'entryMethod',
          sdHidden: true,
        },
        {
          title: '缺陷类型',
          dataIndex: 'defectType',
          width: '150px',
        },
        {
          title: '缺陷责任组织',
          dataIndex: 'controOrgName',
          width: '150px',
        },
        { title: '整改联系人', dataIndex: 'rectContactName', sdHidden: true },
        {
          title: '拟整改完成日期',
          dataIndex: 'finishDate',
          sdRender: TableColumnTypes.date,
          sdHidden: true,
        },
        { title: '整改状态', dataIndex: 'rectStatus', sdHidden: true },
        {
          title: '整改完成日期',
          dataIndex: 'rectFinishDate',
          sdRender: TableColumnTypes.date,
          sdHidden: true,
        },
        {
          title: '创建日期',
          dataIndex: 'creationTime',
          sdRender: TableColumnTypes.date,
          sorter: true,
          defaultSortOrder: 'desc',
          width: '150px',
        },
        {
          title: '流程名称',
          dataIndex: 'prcName',
          sdHidden: true,
        },
        {
          title: '测试结果',
          dataIndex: 'testResult',
          sdHidden: true,
        },
        {
          dataIndex: 'liabilityOrgId',
          sdHidden: true,
        },
        {
          dataIndex: 'liabilityOrgCode',
          sdHidden: true,
        },
        {
          dataIndex: 'liabilityOrgName',
          sdHidden: true,
        },
        {
          dataIndex: 'controOrgId',
          sdHidden: true,
        },
        {
          dataIndex: 'controOrgCode',
          sdHidden: true,
        },
        {
          dataIndex: 'entryMethod',
          sdHidden: true,
        },
        {
          title: '缺陷等级',
          dataIndex: 'defectLevel',
          sdHidden: true,
        },
      ],
      expressions: [
        {
          dataType: 'str',
          name: 'rectRequireId',
          op: 'is_null',
        },
      ],
      catalogId: null,
      catalogName: '',
      auditMattersPath: '',
      visible: false,
    }
  },
  mounted() {
    this.initDictionaryInfo()
    // 获取当前人组织
    IcService.getGroupIds().then((res)=>{
      this.expressions.push({
        dataType: 'long',
          name: 'createDeptId',
          op: 'in',
          longValues: res.data,
      })
    })
  },
  methods: {
    export() {},

    initDictionaryInfo() {
      axios({
        url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=EVALUATION_TYPE',
        method: 'get',
      }).then((res) => {
        if (res.status === 200) {
          this.evaluationtype = res.data
        }
      })
      axios({
        url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=EVALUATION_MODE',
        method: 'get',
      }).then((res) => {
        if (res.status === 200) {
          this.evaluationways = res.data
        }
      })
    },
    handleSearch() {
      this.expressions = []
      // 审计事项名称
      if (this.formData.year) {
        this.expressions.push({
          dataType: 'str',
          name: 'year',
          op: 'eq',
          stringValue: this.formData.year[0].name,
        })
      }
      // 审计事项编号
      if (this.formData.evaluationname) {
        this.expressions.push({
          dataType: 'str',
          name: 'evaluationName',
          op: 'like',
          stringValue: '%' + this.formData.evaluationname + '%',
        })
      }

      if (this.formData.evaluationtype) {
        this.expressions.push({
          dataType: 'str',
          name: 'evaluationType',
          op: 'eq',
          stringValue: this.formData.evaluationtype[0].id,
        })
      }
      if (this.formData.evaluationways) {
        this.expressions.push({
          dataType: 'str',
          name: 'evaluationMode',
          op: 'eq',
          stringValue: this.formData.evaluationways[0].id,
        })
      }

      this.expressions = [...this.expressions]
    },

    // 重置
    resetForm() {
      this.formData.year = null
      this.formData.evaluationways = null
      this.formData.evaluationtype = null
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.wrap-height {
  height: 100%;
  .row-height {
    display: flex;
    flex: auto;
    height: 100%;
    .rightcard {
      flex: 1;
      width: calc(100% - 20%);
      height: 100%;
    }
  }
}
</style>
