<template>
  <a-config-provider :locale="zhCN">
    <a-modal v-model="visible" :width="1000" :closable="false" @ok="handleOk">
      <template slot="title">
        <div :class="$style.modaltitle"
          >样本信息
          <!-- <a-tooltip>
            <template slot="title">
              上传提示，内容待定
            </template>
            <span :class="$style.tips"><a-icon type="exclamation-circle"/></span>
          </a-tooltip> -->
        </div>
      </template>
      <xm-child-table
        ref="childTable"
        v-model="value"
        :class="$style.sampleinfo"
        :read-only="readonly"
        :fields="
          [
            {
              caption: '序号',
              name: 'sortNum',
              dataType: 'number',
              attr: {},
            },
          ].concat(Array.from(formData.attr.dync))
        "
        :columns="columns"
      >
      </xm-child-table>
    </a-modal>
  </a-config-provider>
</template>

<script>
import zhCN from 'ant-design-vue/es/locale-provider/zh_CN'
import components from './_import-components/ic-simple-info-modal-import'

export default {
  name: 'IcSimpleInfoModal',
  components,
  data() {
    return {
      zhCN,
      visible: false,
      formData: null,
      readonly: false,
      value: null,
      columns: [
        {
          title: '序号',
          dataIndex: 'sortNum',
          width: '80px',
          customRender: (text, record, index) => `${index + 1}`,
        },
        { dataIndex: 'id', sdHidden: true },
        { dataIndex: 'sourceId', sdHidden: true },
        { dataIndex: 'sampleName' },
        { dataIndex: 'sampleDesc' },
        { dataIndex: 'attachment', sdHidden: false },
      ],
    }
  },
  created() {
    this.readonly = this.model.readonly
    console.log(this.model.attr.dync)
    this.formData = this.model.attr.dync.find(
      (item) =>
        item.name === 'icEvaluationControlSampleList' || item.name === 'icEvaluationCrossSampleList'
    )
    const info =
      this.simpleData?.icEvaluationControlSampleList || this.simpleData?.icEvaluationCrossSampleList
    if (info) {
      this.value = JSON.parse(info)
    }
    this.visible = true
  },
  methods: {},
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.sampleinfo {
  :global(.ant-table-wrapper) {
    margin-top: 50px;
  }
  /* stylelint-disable-next-line  */
  :global(.caption_xm-child-table_product) {
    top: 60px;
    right: 10px;
  }
}
.modaltitle {
  position: relative;
  z-index: 9;
  .tips {
    float: right;
  }
}
</style>
