<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>
          {{selctedDeliveryGoods.data.deliverygoodsname}}（{{selctedDeliveryGoods.data.enumdicname}}）
        </span>
        <span class="green ml10">{{selctedDeliveryGoods.data.isvalid ? '正常' : '停用'}}</span>
      </div>
      <div class="tltBtns">
        <template v-if="selctedDeliveryGoods.data.isvalid">
          <BtnList :btnList="forDataBtn" />
        </template>
        <template v-else>
          <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">商品（{{selctedDeliveryGoods.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="(item, i) in selctedDeliveryGoods.gmlist"
                 :key="i + '11'">
            <a-col :span="8">{{item.wrstandardname}}</a-col>
            <a-col :span="8">{{item.enumdicname}}</a-col>
            <a-col :span="8">{{item.convertfactor}}</a-col>
          </a-row>
        </a-collapse-panel>
        <a-collapse-panel key="2">
          <template #header>
            <a-row class="headRow">
              <a-col :span="24">品牌（{{selctedDeliveryGoods.gblist.length}}）</a-col>
            </a-row>
          </template>
          <a-row class="contRow"
                 v-for="(item, i) in selctedDeliveryGoods.gblist"
                 :key="i + '22'">
            <a-col :span="24">{{item.brandname}}</a-col>
          </a-row>
        </a-collapse-panel>
        <a-collapse-panel key="3">
          <template #header>
            <a-row class="headRow">
              <a-col :span="8">套保品种（{{selctedDeliveryGoods.mgList.length}}）</a-col>
              <a-col :span="8">单位</a-col>
              <a-col :span="8">套保系数</a-col>
            </a-row>
          </template>
          <template v-for="(item, i) in selctedDeliveryGoods.mgList"
                    :key="i + '33'">
            <a-row class="contRow">
              <a-col :span="8">{{item.mg.middlegoodsname}}</a-col>
              <a-col :span="8">{{item.mg.enumdicname}}</a-col>
              <a-col :span="8">{{item.convertratio}}</a-col>
            </a-row>
            <a-collapse default-active-key="4-0">
              <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.mg.relatedgoodstype === 1 ? '期货合约' : '期货品种'}}（{{item.gplist.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, j) in item.gplist"
                       :key="j + 'kkk'">
                  <a-col :span="8">{{sub.goodsgroupname}}</a-col>
                  <a-col :span="8">{{sub.enumdicname}}</a-col>
                  <a-col :span="8">{{sub.convertratio}}</a-col>
                </a-row>
              </a-collapse-panel>
            </a-collapse>
          </template>
        </a-collapse-panel>
      </a-collapse>
    </div>
    <Modify :selctedDeliveryGoods="selctedDeliveryGoods"
            @refresh="refresh" />
    <Disable :selectedRow="selctedDeliveryGoods"
             @refresh="refresh" />
    <SpotDetail :selectedRow="selctedDeliveryGoods" />
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, PropType } from 'vue';
import { initDG } from '@/views/information/goods/list/spot-variety/setup';
import { ErmcpDeliveryGoodsDetailEx } from '@/services/go/ermcp/goodsInfo/interface';
import { initData } from '@/common/methods';
import { openModal } from '@/common/setup/modal/index';
import Modify from '../modify/index.vue';
import Disable from '../disable/index.vue';
import { getThirdMenuData, handleBtnList } from '@/common/setup/table/button';
import { BtnList } from '@/common/export/table';
import SpotDetail from '../spotDetail/index.vue';

export default defineComponent({
    name: 'rightSpot',
    props: {
        selctedDeliveryGoods: {
            default: initDG,
            type: Object as PropType<ErmcpDeliveryGoodsDetailEx>,
        },
        isNormal: {
            default: true,
            type: Boolean,
        },
    },
    components: {
        Modify,
        Disable,
        BtnList,
        SpotDetail,
    },
    setup(props, context) {
        const menuList = getThirdMenuData();
        const temp = menuList.find((e) => e.code === 'goods_info_spot');
        let list = undefined;
        if (temp) {
            list = temp.children.find((e) => e.code === 'goods_info_spot_normal');
        }

        const { forDataBtn } = handleBtnList(list, 'goods_info_spot_normal', true);
        function refresh() {
            context.emit('refresh');
        }
        initData(() => {});
        return { forDataBtn, refresh };
    },
});
</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;
        }

        .tltBtns {
            .ant-btn + .ant-btn {
                margin-left: 10px;
            }
            .btnPrimary.ant-btn {
                height: 26px;
                line-height: 27px;
            }
        }
    }
    .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-row.headRow {
    .ant-col:first-child {
        text-align: left;
    }
    .ant-col:nth-child(3) {
        text-align: right;
    }
}
</style
>;
