<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.steptypename}}</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, WrTypeItem } from '@/services/go/wrtrade/interface';
import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
import { _closeModal } from '@/common/setup/modal/modal';
import { queryWrBsGoodsInfo, queryWrGoodsInfo } from '@/services/go/wrtrade';
import { EnumRouterName } from '@/common/constants/enumRouterName';
import { QueryDeliveryRelationRsp } from '@/services/go/delivery/interface';

export default defineComponent({
    name: 'detail',
    components: { Drawer },
    emits: ['cancel', 'update'],
    props: {
        parantSelectedRow: {
            type: Object as PropType<QueryDeliveryRelationRsp>,
            default: {},
        },
    },
    setup(props, context) {
        const loading = ref<boolean>(false);
        const { visible, cancel } = _closeModal(context);
        const lstitem = ref<WrTypeItem[]>();
        const lststep = ref<WrGoodsPerformanceStep[]>();
        queryResultLoadingAndInfo(queryWrBsGoodsInfo, loading, props.parantSelectedRow.goodsid).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;
    }
    .rulesCont {
        margin-top: 10px;
        .flex;
        overflow-x: auto;
        overflow-y: hidden;
        max-width: 450px;
        .ruleCol.ant-col {
            margin-bottom: 10px;
        }
    }
}
.ant-row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    .ant-col {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-bottom: 20px;
        .rounded-corners(3px);
        display: inline-flex;
        .line {
            width: 100%;
            .flex;
            flex-direction: column;
            .name {
                min-width: 120px;
                height: 30px;
                background: @m-blue28;
                border: 1px solid @m-black37;
                .rounded-corners(3px);
                text-align: center;
                font-size: 16px;
                color: @m-white6;
            }

            .time {
                margin: 6px auto 0;
                width: 50px;
                height: 28px;
                background: @m-black38;
                .rounded-corners(5px);
                color: @m-blue26;
                font-size: 14px;
                text-align: center;
            }
        }
        .line:nth-child(2n) {
            .name {
                background: @m-yellow4;
                border-color: @m-yellow5;
            }
        }

        .line + .line {
            margin-left: 5px;
        }
    }
}
</style>
