<template>
  <div class="rightSpot">
    <div class="title">
      <div class="tltLeft">
        <span class="blue">
          <svg class="icon svg-icon"
               aria-hidden="true">
            <use xlink:href="#icon-shuzhuangtu"></use>
          </svg>
          {{selctedMG.mg.middlegoodsname}}（{{getGoodsUnitEnumItemName(selctedMG.mg.goodsunitid)}}）
        </span>
        <span class="green ml10">{{selctedMG.mg.isvalid ? '正常' : '停用'}}</span>
        <span class="green ml10">套保比例{{(selctedMG.mg.needhedgeratio * 100).toFixed(2)}}%</span>
        <span class="green ml10">套利比例100%</span>
      </div>
      <div class="tltBtns">
        <template v-if="isNormal">
          <BtnList :btnList="forDataBtn" />
        </template>
        <template>
          <a-button class="blueBtn">恢复</a-button>
        </template>
      </div>
    </div>
    <div class="spotCont">
      <a-collapse class="spotCollapse"
                  :bordered="false">
        <template #expandIcon="props">
          <svg class="icon svg-icon"
               aria-hidden="true"
               v-if="props.isActive == 0">
            <use xlink:href="#icon-shouqi1"></use>
          </svg>
          <svg class="icon svg-icon"
               aria-hidden="true"
               v-else>
            <use xlink:href="#icon-shouqi2"></use>
          </svg>
        </template>
        <a-collapse-panel key="1">
          <template #header>
            <a-row class="headRow">
              <a-col :span="8">期货品种（{{selctedMG.gplist.length}}）</a-col>
              <a-col :span="8">单位</a-col>
              <a-col :span="8">品种系数</a-col>
            </a-row>
          </template>

          <template v-for="(item, i) in selctedMG.gplist"
                    :key="i + '1111'">
            <a-row class="contRow">
              <a-col :span="8">{{item.goodsgroupname}}</a-col>
              <a-col :span="8">{{item.enumdicname}}</a-col>
              <a-col :span="8">{{item.convertratio}}</a-col>
            </a-row>
            <a-collapse>
              <template #expandIcon="props">
                <svg class="icon svg-icon"
                     aria-hidden="true"
                     v-if="props.isActive == 0">
                  <use xlink:href="#icon-shouqi1"></use>
                </svg>
                <svg class="icon svg-icon"
                     aria-hidden="true"
                     v-else>
                  <use xlink:href="#icon-shouqi2"></use>
                </svg>
              </template>
              <a-collapse-panel>
                <template #header>
                  <a-row class="headRow">
                    <a-col :span="8">期货合约（{{item.glist.length}}）</a-col>
                    <a-col :span="8">单位</a-col>
                    <a-col :span="8">合约系数</a-col>
                  </a-row>
                </template>
                <a-row class="contRow"
                       v-for="sub in item.glist"
                       :key="sub.goodsid">
                  <a-col :span="8">{{sub.goodsname}}</a-col>
                  <a-col :span="8">{{sub.enumdicname}}</a-col>
                  <a-col :span="8">{{sub.agreeunit}}</a-col>
                </a-row>
              </a-collapse-panel>
            </a-collapse>
          </template>
        </a-collapse-panel>
        <a-collapse-panel key="2">
          <template #header>
            <a-row class="headRow">
              <a-col :span="8">现货品种（{{selctedMG.dglist.length}}）</a-col>
              <a-col :span="8">单位</a-col>
              <a-col :span="8">品种系数</a-col>
            </a-row>
          </template>
          <template v-for="(item, i) in selctedMG.dglist"
                    :key="i + '33'">
            <a-row class="contRow">
              <a-col :span="8">{{item.data.deliverygoodsname}}</a-col>
              <a-col :span="8">{{item.data.agreeunit}}</a-col>
              <a-col :span="8">{{item.data.enumdicname}}</a-col>
            </a-row>
            <a-collapse>
              <template #expandIcon="props">
                <svg class="icon svg-icon"
                     aria-hidden="true"
                     v-if="props.isActive == 0">
                  <use xlink:href="#icon-shouqi1"></use>
                </svg>
                <svg class="icon svg-icon"
                     aria-hidden="true"
                     v-else>
                  <use xlink:href="#icon-shouqi2"></use>
                </svg>
              </template>
              <a-collapse-panel>
                <template #header>
                  <a-row class="headRow">
                    <a-col :span="8">品类（{{item.gmlist.length}}）</a-col>
                    <a-col :span="8">单位</a-col>
                    <a-col :span="8">标仓系数</a-col>
                  </a-row>
                </template>
                <a-row class="contRow"
                       v-for="(sub) in item.gmlist"
                       :key="sub.goodsid">
                  <a-col :span="8">{{sub.wrstandardname}}</a-col>
                  <a-col :span="8">{{sub.enumdicname}}</a-col>
                  <a-col :span="8">{{sub.convertfactor}}</a-col>
                </a-row>
              </a-collapse-panel>
            </a-collapse>
          </template>
        </a-collapse-panel>
      </a-collapse>
    </div>
    <HedgingDetail :selctedMG="selctedMG" />
    <HedgingModify :selctedMG="selctedMG" />

  </div>
</template>

<script lang="ts">
import { defineComponent, PropType, reactive } from 'vue';
import { initMG } from '@/views/information/goods/list/hedging-variety/setup';
import { Ermcp3MiddleGoodsDetail2 } from '@/services/go/ermcp/goodsInfo/interface';
import { initData } from '@/common/methods';
import HedgingModify from '../hedgingModify/index.vue';
import HedgingDetail from '../spotDetail/index.vue';
import { BtnList } from '@/common/export/table';
import { getThirdMenuData, handleBtnList } from '@/common/setup/table/button';
import { getGoodsUnitEnumItemName } from '@/common/constants/enumsName';

export default defineComponent({
    name: 'rightHedging',
    props: {
        selctedMG: {
            default: initMG,
            type: Object as PropType<Ermcp3MiddleGoodsDetail2>,
        },
        isNormal: {
            default: true,
            type: Boolean,
        },
    },
    components: {
        BtnList,
        HedgingDetail,
        HedgingModify,
    },
    setup(props, context) {
        const menuList = getThirdMenuData();
        const temp = menuList.find((e) => e.code === 'goods_info_hedge');
        let list = undefined;
        if (temp) {
            list = temp.children.find((e) => e.code === 'goods_info_hedge_normal');
        }

        const { forDataBtn } = handleBtnList(list, 'goods_info_hedge_normal', true);

        initData(() => {});
        return { getGoodsUnitEnumItemName, forDataBtn };
    },
});
</script>

<style lang="less">
.rightSpot {
    width: 100%;
    height: 100%;
    padding: 10px 12px;
    .flex;
    flex-direction: column;
    .title {
        width: 100%;
        height: 35px;
        .flex;
        justify-content: space-between;
        div {
            align-self: center;
            align-items: center;
        }
        .tltLeft {
            font-size: 16px;
            .icon {
                font-size: 20px;
                fill: @m-blue0;
                margin-right: 10px;
            }
        }
        .tltBtns {
            .ant-btn + .ant-btn {
                margin-left: 10px;
            }
        }
    }
    .spotCont {
        width: 100%;
        padding: 0 30px;
    }
}
.blue {
    color: @m-blue0;
}
.green {
    color: @m-green0;
}
.ml10 {
    margin-left: 10px;
}
.blueBtn {
    width: 80px;
    height: 26px;
    text-align: center;
    background: linear-gradient(0deg, @m-blue2, @m-blue0);
    box-shadow: -1px 0px 0px 0px #121618;
    .rounded-corners(3px);
    border: 0;
    color: @m-white0;
    font-size: 14px;
    &:hover,
    &:focus {
        background: linear-gradient(0deg, @m-blue2-hover, @m-blue0-hover);
        color: @m-white0-hover;
    }
}
.redBtn {
    width: 80px;
    height: 26px;
    background: linear-gradient(0deg, @m-red0, @m-red1);
    .rounded-corners(3px);
    border: 0;
    color: @m-white0;
    font-size: 14px;
    &:hover,
    &:focus {
        background: linear-gradient(0deg, @m-red0-hover, @m-red1-hover);
        color: @m-white0-hover;
    }
}
.ant-collapse {
    background-color: transparent;
    border: 0;
    .ant-collapse-item {
        border: 0;
        .ant-collapse-header {
            background-color: transparent;
            border-bottom: 0;
        }
        .ant-collapse-content {
            background-color: transparent;
            border-top: 0;
        }
    }
}
// .ant-collapse.spotCollapse.ant-collapse-borderless {
//     margin-top: 10px;
//     background-color: transparent;
//     .ant-collapse-item {
//         border-bottom: 0;
//         .ant-collapse-header {
//             color: @m-grey17;
//             font-size: 14px;
//             border-bottom: 1px solid @m-grey18;
//             padding: 10px 8px 10px 44px;
//             height: 43px;
//             .ant-collapse-arrow {
//                 fill: @m-grey17;
//                 width: 16px;
//                 height: 16px;
//                 font-size: 16px;
//                 left: 0;
//             }
//         }
//         .ant-collapse-content {
//             .ant-collapse-content-box {
//                 padding: 0 0 0 30px;
//                 background-color: transparent;
//                 .ant-row.contRow {
//                     width: 100%;
//                     height: 40px;
//                     line-height: 40px;
//                     font-size: 16px;
//                     color: @m-white1;
//                     margin-bottom: 10px;
//                     background: #0f161c;
//                     border: 1px solid #172b56;
//                     border-radius: 3px;
//                     padding-left: 14px;
//                     padding-right: 12px;
//                     .ant-col:last-child {
//                         text-align: right;
//                     }
//                     .ant-col:first-child {
//                         text-align: left;
//                     }
//                 }
//                 .contRow:first-child {
//                     margin-top: 9px;
//                 }
//                 .contRow:last-child {
//                     margin-bottom: 20px;
//                 }
//             }
//         }
//     }
// }
</style>;
