<template>
  <div>
    <a-table
      class="mar-bottom10"
      size="small"
      :columns="columns"
      :locale="{ emptyText: 'No Data' }"
      :data-source="conditionList"
      row-key="id"
      :pagination="false"
    ></a-table>
  </div>
</template>

<script>
export default {
  props: {
    formData: {
      default: {},
    },
  },
  data() {
    const columns = [
      { title: "条件类型", dataIndex: "frequencyDesc" },
      { title: "条件内容", dataIndex: "limitDesc" },
      // { title: "最小值", dataIndex: "minValue" },
      { title: "福利限制", dataIndex: "maxValue", customRender: (val, row) => {
        if (row.limitCode.indexOf('07') === 0) {
          return val + '%'
        }
        for(let i = 0; i < this.currencyCode.length; i ++) {
          if (this.currencyCode[i].refcd === row.currency) {
            return val + this.currencyCode[i].descCh
          }
        }
        return val + row.currency
      }},
      { title: "剩余金额", dataIndex: "leftValue" },
      { title: "备注", dataIndex: "remark" }
    ];
    return {
      columns,
      conditionList: [],
    };
  },
  mounted() {
    this._getRefcdByRefgrp()
    this._getConditionList();
  },
  methods: {
    _getConditionList() {
      const {
        planCode,
        payorCode,
        coverageCode,
        corpCode,
        benefitCode,
        conditionType,
      } = this.formData;
      const data = {
        planCode,
        payorCode,
        coverageCode,
        corpCode,
        benefitCode,
        conditionType,
      };
      this.$apis.GETCONDITIONLIST(data).then((res) => {
        this.conditionList = res.content || [];
      });
    },
    // 获取币种列表
    _getRefcdByRefgrp() {
      this.$apis.getRefcdByRefgrp({
        modid: "CI",
        refgrp: "CURRENCY_TYPE"
      }).then((res) => {
        this.currencyCode = res.content || [];
      });
    },
  },
};
</script>

<style></style>
