<template>
  <!-- 买卖大厅详情 -->
  <Drawer :title="'详情'"
          :placement="'right'"
          :visible="visible"
          class="top top486"
          @cancel="cancel">
    <div class="detailCont">
      <div class="rows">
        <div class="row"
             v-for="item in lstitem"
             :key="item.name">
          <div class="left">{{item.name}}</div>
          <div class="right">{{item.value}}</div>
        </div>
      </div>
      <div class="ruleTitle">履约规则：</div>
      <div class="rulesCont">
        <a-row>
          <a-col :span="24"
                 class="ruleCol">
            <div class="line"
                 v-for="item in lststep"
                 :key="item.autoid">
              <!-- <div class="no">{{index + 1}}</div> -->
              <div class="name">{{item.stepinfo}}<span></span></div>
              <div class="time">{{item.stepdate}}</div>
            </div>
          </a-col>
        </a-row>
      </div>
    </div>
  </Drawer>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import Drawer from '@/common/components/drawer/index.vue';
import { QueryWrGoodsInfoReq, WrGoodsPerformanceStep, WrOrderQuote, WrTypeItem } from '@/services/go/wrtrade/interface';
import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { ModalEnum } from '@/common/constants/modalNameEnum';
import { _closeModal } from '@/common/setup/modal/modal';
import { queryWrGoodsInfo } from '@/services/go/wrtrade';
import { EnumRouterName } from '@/common/constants/enumRouterName';

export default defineComponent({
    name: ModalEnum.spot_trade_warehouse_delisting,
    components: { Drawer },
    emits: ['cancel', 'update'],
    props: {
        selectedRow: {
            type: Object as PropType<WrOrderQuote>,
            default: {},
        },
        enumName: {
            default: '',
            type: String as PropType<EnumRouterName>,
        },
    },
    setup(props, context) {
        const loading = ref<boolean>(false);
        const { visible, cancel } = _closeModal(context);
        const lstitem = ref<WrTypeItem[]>();
        const lststep = ref<WrGoodsPerformanceStep[]>();
        function isSale(): boolean {
            return props.enumName === EnumRouterName.warehouse_pre_sale_price || props.enumName === EnumRouterName.warehouse_pre_sale_floating_price;
        }
        const param: QueryWrGoodsInfoReq = {
            haswr: isSale() ? 0 : 1,
            wrfactortypeid: props.selectedRow.wrfactortypeid,
            // tmplateid: props.selectedRow.performancetemplateid,
        };
        queryResultLoadingAndInfo(queryWrGoodsInfo, loading, param).then((res) => {
            if (res.length) {
                lstitem.value = res[0].lstitem;
                lststep.value = res[0].lststep;
            }
        });

        return {
            lstitem,
            lststep,
            visible,
            cancel,
        };
    },
});
</script>

<style lang="less" scoped>
.detailCont {
    padding: 10px;
    .rows {
        .flex;
        flex-direction: column;
        width: 100%;
        border: 1px solid @m-black6;
        background: @m-black13;
        .row {
            display: inline-flex;
            width: 100%;
            height: 38px;
            line-height: 38px;
            border-bottom: 1px solid @m-black6;
            > div {
                text-align: center;
                font-size: 16px;
            }
            .left {
                width: 126px;
                color: @m-grey1;
                border-right: 1px solid @m-black6;
            }
            .right {
                flex: 1;
                color: @m-white11;
            }
        }
    }
    .ruleTitle {
        width: 100%;
        height: 30px;
        line-height: 30px;
        margin-top: 10px;
        font-size: 16px;
        color: @m-grey1;
    }
}
</style>
