<template>
  <!-- 删除计划-->
  <a-modal class="plan_uncommitted_delete"
           title="删除计划"
           centered
           v-model:visible="visible"
           @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"
                  :form="form"
                  @submit="handleSearch">
              <a-row :gutter="24">
                  <a-col :span="12">
                      <a-form-item label="计划类型">
                          <span class="white">{{ getPlanContractType(selectedRow.contracttype) }}</span>
                      </a-form-item>
                  </a-col>
                  <a-col :span="12">
                      <a-form-item label="计划名称">
                          <span class="white">{{ formatValue(selectedRow.hedgeplanno) }}</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.deliverygoodsname) }}</span>
                      </a-form-item>
                  </a-col>
                  <a-col :span="12">
                      <a-form-item label="标仓系数">
                          <span class="white">{{ formatValue(selectedRow.convertfactor) }}</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.planqty) }}</span>
                      </a-form-item>
                  </a-col>
                  <a-col :span="12">
                      <a-form-item label="备注">
                          <span class="white">{{ formatValue(selectedRow.remark) }}</span>
                      </a-form-item>
                  </a-col>
              </a-row>
          </a-form>
      </fieldset>
      <fieldset class="formFieldSet">
          <legend>其它信息</legend>
          <a-row :gutter="24">
              <a-col :span="12">
                  <a-form-item label="交易用户">
                      <span class="white">{{ formatValue(selectedRow.tradeusername) }}</span>
                  </a-form-item>
              </a-col>
              <a-col :span="12">
                  <a-form-item label="结算币种">
                      <span class="white">{{ formatValue(selectedRow.currencyname) }}</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.remark) }}</span>
                  </a-form-item>
              </a-col>
          </a-row>
      </fieldset>
  </a-modal>
</template>

<script lang="ts">
import {defineComponent, PropType, ref} from 'vue';
import { closeModal } from '@/common/setup/modal/index';
import {Ermcp3HedgePlan} from "@/services/go/ermcp/plan/interface";
import {formatValue} from "@/common/methods";
import {getPlanContractType} from "@/views/business/plan/setup";
import {Modal} from "ant-design-vue";
import {changeStatus} from "@/views/business/plan/components/setup";
import {ErmcpHedgePlanReq, HedgePlanOperateReq} from "@/services/proto/hedgeplan/interface";
import * as Long from "long";

export default defineComponent({
    name: 'plan_uncommitted_delete',
    components: {},
    props: {
        selectedRow: {
            type: Object as PropType<Ermcp3HedgePlan>,
            default: {},
        },
    },
    setup(props, context) {
        const { visible, cancel } = closeModal('plan_uncommitted_delete');
        const loading = ref<boolean>(false);
        function submit() {
            Modal.confirm({
                title: '是否确认删除',
                okText: '确认删除',
                cancelText: '取消',
                onOk() {
                    const params: ErmcpHedgePlanReq = {
                        HedgePlanID: Long.fromString(props.selectedRow.hedgeplanid),
                        OperateType: 3,
                    }
                    changeStatus(params, 3, loading)
                        .then(res => {
                            cancel()
                            context.emit('refresh')
                        })
                        .catch(err => {

                        })
                },
                onCancel() {
                    console.log('Cancel');
                },
            });
        }
        return {
            visible,
            cancel,
            submit,
            formatValue,
            getPlanContractType,
        };
    },
});
</script>

<style lang="less">
.plan_uncommitted_delete {
}
</style
>;
