<template>
  <!-- 采购合同详情-->
  <a-modal class="commonModal paddingDialog purchase-detail"
           title="详情"
           v-model:visible="visible"
           centered
           @cancel="cancel"
           width="890px">
    <template #footer>
      <a-button key="submit"
                type="primary"
                :loading="loading"
                @click="submit">关闭
      </a-button>
    </template>
    <fieldset class="formFieldSet">
      <legend>合同基本信息</legend>
      <a-form class="inlineForm">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="合同编号">
              <span class="white">{{ formatValue(selectedRow.contractno) }}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="合同类型">
              <span class="white">{{ getPriceTypeName(selectedRow.pricetype) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="销售方">
              <span class="white">{{ formatValue(selectedRow.accountname) }}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="现货品种">
              <span class="white">{{ formatValue(selectedRow.deliverygoodsname) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="合同签署量">
              <span
                    class="white">{{ formatValue(selectedRow.qty + selectedRow.enumdicname) }}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="合同暂定价">
              <span class="white">{{ formatValue(selectedRow.price) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="点价合约">
              <span class="white">{{ formatValue(selectedRow.goodsname) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </fieldset>
    <fieldset class="formFieldSet">
      <legend>已登记信息</legend>
      <a-form class="inlineForm">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="已定价量">
              <span class="white">{{ selectedRow.pricedqty + selectedRow.enumdicname }}</span>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="已点均价">
              <span class="white">{{ formatValue(selectedRow.pricedavg.toFixed(2)) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </fieldset>
    <fieldset class="formFieldSet">
      <legend>本次点价信息</legend>
      <a-form class="inlineForm">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="升贴水">
              <span class="white">{{ formatValue(selectedRow.pricemove) }}</span>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </fieldset>
  </a-modal>
</template>

<script lang="ts">
import { defineComponent, PropType, ref } from 'vue';
import { formatValue } from '@/common/methods';
import { Ermcp3SellBuyContract } from '@/services/go/ermcp/purchase/interface';
import { getPriceTypeName } from '@/common/constants/enumsName';
import { _closeModal } from '@/common/setup/modal/modal';

export default defineComponent({
    name: 'purchase_pending-detail',
    components: {},
    emits: ['cancel', 'update'],
    props: {
        selectedRow: {
            type: Object as PropType<Ermcp3SellBuyContract>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = _closeModal(context);
        const loading = ref<boolean>(false);

        function submit() {
            cancel();
        }

        return {
            visible,
            cancel,
            submit,
            loading,
            formatValue,
            getPriceTypeName,
        };
    },
});
</script>

<style lang="less">
</style>;
