<template>
  <div class="CenterRightboxContainer">
    <div class="CenterRightbox">
      <div class="ccenter">
        <div class="cheader">
          <!-- 顶部按钮 -->
          <BtnsTop
            title="外汇远期"
            @handleQuickSearch="handleQuickSearch"
            @handleattachmentVisible="handleattachmentVisible"
            @handleModal="handleModal"
          />
          <div class="publicFormbox">
            <publicForm
              ref="publicForm"
              :form-arr="zdArr"
              :form-data="formData"
            />
          </div>
        </div>
        <!-- 底部按钮 -->
        <BtnsBottom
          @handleclearForm="handleclearForm"
          @handlePreSubmit="handlePreSubmit"
        />
      </div>
      <div class="cright">
        <CRight
          :value="handleType"
          @handleModal="handleModal"
        />
      </div>
    </div>

    <!-- 要复制交易 弹窗 -->
    <QuickSearch
      :value="quickSearchVisible"
      @closeQuickSearch="handleCloseQuickSearch"
      @dblclick="handleQuickSearchdblclick"
    />

    <!-- 附件管理 弹窗 -->
    <Attachment
      :value="attachmentVisible"
      @closeAttachment="handleCloseAttachment"
      @dblclick="handleAttachmentdblclick"
    />
  </div>
</template>

<script>
import publicForm from '@/components/formLinkage';
import CRight from '../lineRight/index.vue';
import QuickSearch from '../component/quickSearch.vue';
import Attachment from '../component/attachment';
import BtnsTop from '../component/btnsTop.vue';
import BtnsBottom from '../component/btnsBottom.vue';
import { objAddPrefix } from '@/utils';
import './index.scss';

export default {
  components: {
    publicForm,
    CRight,
    QuickSearch,
    Attachment,
    BtnsTop,
    BtnsBottom,
  },
  data() {
    return {
      zdArr: [
        {
          title: '交易信息',
          formArr: [
            {
              type: 'select',
              prop: 'underlying',
              attrs: {
                label: '货币对',
                needStar: true,
              },
              options: [],
              rules: { required: true },
              events: {
                change: (e) => {
                  this.setccy1ccy2(e);

                  // 获取即期汇率
                  const data = { pairCode: e };
                  this.$apis.getdcsPairInfo(data).then((res) => {
                    const result = res.data.result;
                    this.formData.spotRate = result.spotRate;
                    this.formData.quotationUnit = result.quotationUnit;
                    this.formData.noDecimal1 = result.noDecimal1;
                    this.formData.noDecimal2 = result.noDecimal2;

                    if (this.formData.amount1) {
                      this.getamount2();
                    }
                  });

                  // 获取起息日
                  const data2 = {
                    tradeDate: this.formData.tradeDate,
                    code: this.formData.underlying,
                    type: 'PAIR',
                  };
                  this.$apis.getdcsValueDate(data2).then((res) => {
                    this.formData.maturityDate = res.data.result.toString();
                  });
                },
              },
            },
            {
              type: 'input',
              prop: 'shengtieshui',
              attrs: {
                label: `升贴水`,
                needStar: true,
              },
              rules: { required: true },
              events: {
                blur: () => {
                  // if (this.formData.amount1 && this.formData.spotRate) {
                  //   this.getamount2();
                  // }
                },
              },
            },
            {
              type: 'inputFinance',
              prop: 'amount1',
              attrs: {
                label: `金额()`,
                needStar: true,
              },
              rules: { required: true },
              events: {
                focus: () => {
                  if (
                    this.formData.amount2 &&
                    !this.formData.amount1 &&
                    this.formData.spotRate
                  ) {
                    this.getamount1();
                  }
                },
                blur: () => {
                  if (this.formData.amount1 && this.formData.spotRate) {
                    this.getamount2();
                  }
                },
              },
            },
            {
              type: 'input',
              prop: 'spotRate',
              attrs: {
                label: '即期汇率',
                needStar: true,
              },
              options: [],
              rules: { required: true },
              events: {
                blur: () => {
                  if (this.formData.amount1 && this.formData.spotRate) {
                    this.getamount2();
                  }
                },
              },
            },
            {
              type: 'input',
              prop: 'spotRateyuanqi',
              attrs: {
                label: '远期汇率',
                needStar: true,
              },
              options: [],
              rules: { required: true },
              events: {
                blur: () => {
                  // if (this.formData.amount1 && this.formData.spotRate) {
                  //   this.getamount2();
                  // }
                },
              },
            },
            {
              type: 'inputFinance',
              prop: 'amount2',
              attrs: {
                label: `金额()`,
                needStar: true,
              },
              rules: { required: true },
              events: {
                focus: () => {
                  if (
                    this.formData.amount1 &&
                    !this.formData.amount2 &&
                    this.formData.spotRate
                  ) {
                    this.getamount2();
                  }
                },
                blur: () => {
                  if (this.formData.amount2 && this.formData.spotRate) {
                    this.getamount1();
                  }
                },
              },
            },
            {
              type: 'pickerDateSingle',
              prop: 'tradeDate',
              span: 16,
              attrs: {
                label: '交易日期',
                needStar: true,
              },
              rules: { required: true },
            },
            {
              type: 'pickerTimeHHMM',
              prop: 'tradeTime',
              span: 8,
              attrs: {},
              rules: { required: true },
            },
            {
              type: 'pickerDateSingle',
              prop: 'maturityDate',
              attrs: {
                label: '即期起息日',
                needStar: true,
              },
              rules: { required: true },
            },
            {
              type: 'pickerDateSingle',
              prop: 'maturityDate2',
              attrs: {
                label: '择期交割日',
                needStar: true,
              },
              rules: { required: true },
            },
            {
              type: 'pickerDateSingle',
              prop: 'maturityDate3',
              attrs: {
                label: '到期日期',
                needStar: true,
              },
              rules: { required: true },
            },
          ],
        },
        {
          title: '交易账户',
          formArr: [
            {
              type: 'select',
              prop: 'folder',
              span: 16,
              attrs: {
                label: '账户',
                needStar: true,
                showValueName: 'name',
              },
              rules: { required: true },
              options: [],
              events: {
                focus: () => {
                  const data = {
                    q: '',
                    'queryParam.menuId': '',
                    'queryParam.productConfigGrp': '',
                  };
                  this.$apis.queryFolderQueryAuthList(data).then((res) => {
                    this.zdArr[1].formArr[0].options = res.data.result.map(
                      (item) => {
                        return {
                          label: item.code,
                          value: item.code,
                          name: item.localName,
                        };
                      },
                    );
                  });
                },
                change: (e) => {
                  const arr = this.zdArr[1].formArr[0].options.filter(
                    (item) => {
                      return item.value === e;
                    },
                  );
                  this.formData.folderName = arr[0].name;
                },
              },
            },
            {
              type: 'input',
              prop: 'folderName',
              span: 8,
              attrs: {
                disabled: true,
                placeHolder: '',
              },
            },
            {
              type: 'select',
              prop: 'cpty',
              span: 16,
              attrs: {
                label: '交易对手',
                needStar: true,
              },
              rules: { required: true },
              options: [],
              events: {
                focus: () => {
                  const data = {
                    isInternalTrade: 'N',
                    'queryParam.pageCtrl': 'true',
                    'queryParam.pageLimit': '100',
                    limitResultSet: 'true',
                    menuId: '',
                    productConfigGrp: '',
                    excludeBranch: 'N',
                    'queryParam.pageStart': '1',
                    scrollFlag: '0',
                    startDate: '',
                    q: '',
                  };
                  this.$apis.queryCptyPage(data).then((res) => {
                    this.zdArr[1].formArr[2].options =
                      res.data.result.datals.map((item) => {
                        return {
                          label: item.code,
                          value: item.code,
                          name: item.localName,
                        };
                      });
                  });
                },
                change: (e) => {
                  const arr = this.zdArr[1].formArr[2].options.filter(
                    (item) => {
                      return item.value === e;
                    },
                  );
                  this.formData.cptyName = arr[0].name;
                },
              },
            },
            {
              type: 'input',
              prop: 'cptyName',
              span: 8,
              attrs: {
                disabled: true,
                placeHolder: '',
              },
            },
          ],
        },
        {
          title: '备注',
          formArr: [
            {
              type: 'select',
              prop: 'dealFlag',
              attrs: {
                label: '交易性质',
                needStar: true,
              },
              rules: { required: true },
              options: [],
            },
            {
              type: 'input',
              prop: 'blockNo',
              span: 16,
              attrs: {
                label: '外部流水号',
              },
              options: [],
            },
            {
              type: 'select',
              prop: 'sourceName',
              span: 8,
              options: [],
            },
            {
              type: 'pickerDateSingle',
              prop: 'transactionDate',
              span: 16,
              attrs: {
                label: '交易成交日期',
              },
            },
            {
              type: 'pickerTimeHHMM',
              prop: 'transactionTime',
              span: 8,
            },
            {
              type: 'select',
              prop: 'tacount',
              attrs: {
                label: '项目',
              },
              options: [],
            },
            {
              type: 'select',
              prop: 'tpurpose',
              attrs: {
                label: '交易背景',
              },
              options: [],
            },
            {
              type: 'input',
              prop: 'ext20',
              attrs: {
                label: '交易目的',
              },
              options: [],
            },
            {
              type: 'input',
              prop: 'comments',
              attrs: {
                label: '备注',
              },
              options: [],
            },
          ],
        },
        {
          title: '拓展字段',
          formArr: [
            {
              type: 'select',
              prop: 'ssiCodeOurBuyCcy1',
              attrs: {
                label: `我方收结算路径()`,
              },
              options: [],
              events: {
                focus: () => {
                  const data = {
                    queryId: 'stb.baseQuery.queryAllSsiInfo',
                    'queryParam.pageCtrl': false,
                    'queryParam.isAllCurrenciesCode': 'N',
                    'queryParam.dealsId': 'NULL',
                    'queryParam.sitesCode': 'BANKZB',
                    'queryParam.tradeDate': this.formData.tradeDate,
                    'queryParam.cptyCode': '',
                    'queryParam.instrumentGrpCode': 'FXSPOT',
                    'queryParam.nostroVostro': 'NOSTRO',
                    'queryParam.payDirection': 'REV',
                    'queryParam.currenciesCode': '',
                    'queryParam.deliveryMode': '0',
                    'queryParam.clrMode': '',
                  };
                  this.$apis.querySettle(data).then((res) => {
                    this.zdArr[3].formArr[0].options =
                      res.data.result.datals.map((item) => {
                        return {
                          label: item.ssiName,
                          value: item.ssiCode,
                        };
                      });
                  });
                },
              },
            },
            {
              type: 'select',
              prop: 'ssiCodeCptyBuyCcy1',
              attrs: {
                label: `对手方收结算路径()`,
              },
              options: [],
              events: {
                focus: () => {
                  const data = {
                    queryId: 'stb.baseQuery.queryAllSsiInfo',
                    'queryParam.pageCtrl': false,
                    'queryParam.isAllCurrenciesCode': 'N',
                    'queryParam.dealsId': 'NULL',
                    'queryParam.sitesCode': 'BANKZB',
                    'queryParam.tradeDate': this.formData.tradeDate,
                    'queryParam.cptyCode': '',
                    'queryParam.instrumentGrpCode': 'FXSPOT',
                    'queryParam.nostroVostro': 'VOSTRO',
                    'queryParam.payDirection': 'REV',
                    'queryParam.currenciesCode': '',
                    'queryParam.deliveryMode': '0',
                    'queryParam.clrMode': '',
                  };
                  this.$apis.querySettle(data).then((res) => {
                    this.zdArr[3].formArr[1].options =
                      res.data.result.datals.map((item) => {
                        return {
                          label: item.ssiName,
                          value: item.ssiCode,
                        };
                      });
                  });
                },
              },
            },
            {
              type: 'select',
              prop: 'ssiCodeOurSellCcy2',
              attrs: {
                label: `我方付结算路径(${this.ccy2 ? this.ccy2 : ''})`,
              },
              options: [],
              events: {
                focus: () => {
                  const data = {
                    queryId: 'stb.baseQuery.queryAllSsiInfo',
                    'queryParam.pageCtrl': false,
                    'queryParam.isAllCurrenciesCode': 'N',
                    'queryParam.dealsId': 'NULL',
                    'queryParam.sitesCode': 'BANKZB',
                    'queryParam.tradeDate': this.formData.tradeDate,
                    'queryParam.cptyCode': '',
                    'queryParam.instrumentGrpCode': 'FXSPOT',
                    'queryParam.nostroVostro': 'NOSTRO',
                    'queryParam.payDirection': 'PAY',
                    'queryParam.currenciesCode': '',
                    'queryParam.deliveryMode': '0',
                    'queryParam.clrMode': '',
                  };
                  this.$apis.querySettle(data).then((res) => {
                    this.zdArr[3].formArr[2].options =
                      res.data.result.datals.map((item) => {
                        return {
                          label: item.ssiName,
                          value: item.ssiCode,
                        };
                      });
                  });
                },
              },
            },
            {
              type: 'select',
              prop: 'ssiCodeCptySellCcy2',
              attrs: {
                label: `对手方付结算路径()`,
              },
              options: [],
              events: {
                focus: () => {
                  const data = {
                    queryId: 'stb.baseQuery.queryAllSsiInfo',
                    'queryParam.pageCtrl': false,
                    'queryParam.isAllCurrenciesCode': 'N',
                    'queryParam.dealsId': 'NULL',
                    'queryParam.sitesCode': 'BANKZB',
                    'queryParam.tradeDate': this.formData.tradeDate,
                    'queryParam.cptyCode': '',
                    'queryParam.instrumentGrpCode': 'FXSPOT',
                    'queryParam.nostroVostro': 'VOSTRO',
                    'queryParam.payDirection': 'PAY',
                    'queryParam.currenciesCode': '',
                    'queryParam.deliveryMode': '0',
                    'queryParam.clrMode': '',
                  };
                  this.$apis.querySettle(data).then((res) => {
                    this.zdArr[3].formArr[3].options =
                      res.data.result.datals.map((item) => {
                        return {
                          label: item.ssiName,
                          value: item.ssiCode,
                        };
                      });
                  });
                },
              },
            },
            {
              type: 'select',
              prop: 'ext1',
              attrs: {
                label: '货币1账户行',
              },
              options: [],
            },
            {
              type: 'select',
              prop: 'ext2',
              attrs: {
                label: '货币2账户行',
              },
              options: [],
            },
            {
              type: 'select',
              prop: 'settlementMode',
              attrs: {
                label: '清算方式',
              },
              options: [],
            },
            {
              type: 'input',
              prop: 'ext4',
              attrs: {
                label: '业务员',
              },
              options: [],
            },
          ],
        },
      ],
      // 默认值
      formData: {
        tradeDate: '',
        tradeTime: '',
        transactionDate: '',
        transactionTime: '',
        maturityDate: '',
        folderName: '',
        cptyName: '',
        spotRate: '',
        quotationUnit: '', // 10的n次方
        noDecimal1: '', // 两个精度参数
        noDecimal2: '',
        amount1: '',
        amount2: '',
        dealFlag: 'INTERBANK',
        sourceName: 'RCS',
      },
      ccy1: '',
      ccy2: '',
      quickSearchVisible: false,
      attachmentVisible: false,
      bottomBtns: {
        addRight: 'Y',
        deleteRight: 'N',
        updateRight: 'N',
        expandBtn: 'N',
      },
      handleType: '',
    };
  },
  mounted() {
    this.getOptions();
    this.getSystemDate();
  },
  methods: {
    handleModal(num) {
      this.handleType = num;
      const data = {
        ...this.formData,
        dbCheck: '',
        quotationUnit: '1',
        capturedAmount: '1',
        conflictFlag: 'true',
        internalTradeFlag: 'false',
        cptyType: '',
        ofEventType: '',
        versionType: 'baseVersion',
        typeOfEvent: 'BOOKING',
        siteCode: 'BANKZB',
        inputMode: 'G',
      };
      const formData = objAddPrefix(data, 'deal');
      this.$bus.$emit('bujiformData', formData);
    },
    // 按钮权限
    getbottomBtns(folder, dealStatus, typeOfEvent) {
      this.$apis.getdcsdoGetFolderAuth({ code: folder }).then((res) => {
        const result = res.data?.result || {};
        result.addRight = 'N';
        result.expandBtn = 'Y';
        if (dealStatus === 'Z' || dealStatus === 'D') {
          result.deleteRight = 'N';
          result.updateRight = 'N';
          result.expandBtn = 'N';
        }
        if (dealStatus === 'C' && typeOfEvent === 'rollover') {
          result.deleteRight = 'N';
          result.updateRight = 'N';
          result.expandBtn = 'N';
        }
        this.bottomBtns = result;
      });
    },
    // get交易对手名称
    getDCSqueryCptyName(val) {
      this.$apis.getDCSqueryCptyName({ code: val }).then((res) => {
        const result = res.data.result;
        this.formData.cptyName = result;
      });
    },
    // get账户名称
    getDCSqueryFolderById(val) {
      this.$apis.getDCSqueryFolderById({ code: val }).then((res) => {
        const result = res.data.result;
        this.formData.folderName = result.localName;
      });
    },
    // get汇率
    getdcsPairInfo(val) {
      this.$apis.getdcsPairInfo({ pairCode: val }).then((res) => {
        const result = res.data.result;
        this.formData.quotationUnit = result.quotationUnit;
        this.formData.noDecimal1 = result.noDecimal1;
        this.formData.noDecimal2 = result.noDecimal2;
      });
    },
    // get金额1
    getamount1() {
      const data = {
        expression: `${this.formData.amount2} / ${
          this.formData.spotRate || 1
        } * -1 / ${Math.pow(10, this.formData.quotationUnit || 0)}`,
        precision: this.formData.noDecimal1 || 2,
      };
      this.$apis.getDCSdoEvaluation(data).then((res) => {
        this.formData.amount1 = res.data.result;
      });
    },
    // get金额2
    getamount2() {
      const data = {
        expression: `${this.formData.amount1} * ${
          this.formData.spotRate || 1
        } * -1 / ${Math.pow(10, this.formData.quotationUnit || 0)}`,
        precision: this.formData.noDecimal2 || 2,
      };
      this.$apis.getDCSdoEvaluation(data).then((res) => {
        this.formData.amount2 = res.data.result;
      });
    },
    // 初始化数据
    getOptions() {
      const data = {
        codifierGrpCodes:
          'settleMode,static_folders,static_cptys,DealStatusRcs,static_accBank,CashflowDirection,DealFlagRcs,AppId,Tpurpose,Tacount,static_currencies,static_pairs,static_pmPairs,OptionSettlementMode,BuySellRcs,static_pmCurrencies',
      };
      this.$apis.getDcsOptions(data).then((res) => {
        const result = res.data.result;
        this.zdArr[0].formArr[0].options = result.pairs;
        this.zdArr[2].formArr[0].options = result.DealFlagRcs;
        this.zdArr[2].formArr[2].options = result.AppId;
        this.zdArr[2].formArr[5].options = result.Tacount;
        this.zdArr[2].formArr[6].options = result.Tpurpose;
        this.zdArr[3].formArr[6].options = result.settleMode;
      });
    },
    // get日期
    getSystemDate() {
      this.$apis.getDCSgetSystemDate({}).then((res) => {
        const result = res.data.result;
        this.formData.tradeDate = this.formData.transactionDate =
          result.date.toString();
        this.formData.tradeTime = this.formData.transactionTime = result.time
          .toString()
          .slice(0, 4);
      });
    },
    // 设置ccy
    setccy1ccy2(val) {
      this.ccy1 = val.substring(0, 3);
      this.ccy2 = val.substring(3, 6);
      this.zdArr[0].formArr[1].attrs.label = `金额(${this.ccy1})`;
      this.zdArr[0].formArr[3].attrs.label = `金额(${this.ccy2})`;
      this.zdArr[3].formArr[0].attrs.label = `我方收结算路径(${this.ccy1})`;
      this.zdArr[3].formArr[1].attrs.label = `对手方收结算路径(${this.ccy1})`;
      this.zdArr[3].formArr[2].attrs.label = `我方付结算路径(${this.ccy2})`;
      this.zdArr[3].formArr[3].attrs.label = `对手方付结算路径(${this.ccy2})`;
    },
    // 预submit
    handlePreSubmit() {
      if (this.$refs.publicForm.submitForm()) {
        console.log('this.formData', this.formData);
        this.handleSubmitIsHoliday();
      }
    },
    // submit前判断是否是节假日
    handleSubmitIsHoliday() {
      const data = {
        code: this.formData.underlying,
        valueDate: this.formData.tradeDate,
        type: 'PAIR',
      };
      this.$apis.getdcsisHolidayByUnderlying(data).then((res) => {
        const result = res.data?.result;
        if (result) {
          this.$alert('【交易日期】是节假日，确认执行?', '提示', {
            confirmButtonText: '确定',
            showCancelButton: true,
            cancelButtonText: '取消',
            callback: (action) => {
              if (action === 'confirm') {
                this.handleSubmit();
              }
            },
          });
        } else {
          const data = {
            code: this.formData.underlying,
            valueDate: this.formData.maturityDate,
            type: 'PAIR',
          };
          this.$apis.getdcsisHolidayByUnderlying(data).then((res) => {
            const result = res.data?.result;
            if (result) {
              this.$alert('【起息日】是节假日，确认执行?', '提示', {
                confirmButtonText: '确定',
                showCancelButton: true,
                cancelButtonText: '取消',
                callback: (action) => {
                  if (action === 'confirm') {
                    this.handleSubmit();
                  }
                },
              });
            } else {
              this.handleSubmit();
            }
          });
        }
      });
    },
    // 提交 新增
    handleSubmit() {
      const data1 = {
        instrument: this.formData.instrument,
        product: this.formData.product,
        sourceName: this.formData.sourceName,
        errorShow: false,
      };
      this.$apis.getdcsDealNo(data1).then((response) => {
        this.formData.globalId = response.data.result;
        this.formData.dbCheck = '';
        this.formData.quotationUnit = '1';
        this.formData.capturedAmount = '1'; // 1 和 2怎么区分
        this.formData.conflictFlag = 'true';
        this.formData.internalTradeFlag = 'false';
        this.formData.cptyType = '';
        this.formData.ofEventType = '';
        this.formData.versionType = 'baseVersion';
        this.formData.typeOfEvent = 'BOOKING';
        this.formData.siteCode = 'BANKZB';
        this.formData.inputMode = 'G';
        const data = objAddPrefix(this.formData, 'deal');
        this.$apis.handledcsdealActionFlow(data).then((res) => {
          this.$message.success('操作成功');
          this.handleclearForm();
        });
      });
    },
    // 删除
    handleDelete() {},
    handleCancelForm() {
      this.$refs.publicForm.resetForm();
    },
    handleclearForm() {
      this.formData = {
        tradeDate: '',
        tradeTime: '',
        transactionDate: '',
        transactionTime: '',
        folderName: '',
        cptyName: '',
        spotRate: '',
        quotationUnit: '',
        noDecimal1: '',
        noDecimal2: '',
        maturityDate: '',
        amount1: '',
        amount2: '',
        dealFlag: 'INTERBANK',
        sourceName: 'RCS',
      };
      this.getSystemDate();
      this.bottomBtns = {
        addRight: 'Y',
        deleteRight: 'N',
        updateRight: 'N',
        expandBtn: 'N',
      };
      this.$bus.$off('bujiselectRow');
    },
    // 打开 要复制交易 弹窗
    handleQuickSearch() {
      this.quickSearchVisible = false;
      setTimeout(() => {
        this.quickSearchVisible = true;
      }, 20);
    },
    // 关闭 要复制交易 弹窗
    handleCloseQuickSearch() {
      this.quickSearchVisible = false;
    },
    // 要复制交易 table row 双击事件
    handleQuickSearchdblclick(row) {
      const data = {
        'queryParam.dealId': row.dealId,
        'queryParam.instrument': row.instrument,
        'queryParam.product': row.product,
      };
      this.$bus.$emit('bujiselectRow', row); // 现金流（注意和现金流预览区分）
      this.$apis.getdealQueryQueryList(data).then((res) => {
        const result = res.data.result[0];
        // this.formData = {
        //   ...this.formData,
        //   ...result,
        //   maturityDate: result.maturityDate.toString(),
        //   tradeDate: result.tradeDate.toString(),
        //   tradeTime: result.tradeTime.toString(),
        //   transactionDate: result.transactionDate.toString(),
        //   transactionTime: result.transactionTime.toString(),
        //   // transactionTime: '',
        // };

        this.formData = {
          folder: '',
          folderName: '',
          cptyName: '',
          spotDealId: '',
          userId: '',
          contractId: '',
          dealId: '',
          globalId: '',
          instrument: result.instrument,
          product: result.product,
          bank: result.bank,
          underlyingType: result.underlyingType,
          inputMode: result.inputMode,
          takerId: result.takerId,
          ext19: result.ext19,
          internalTradeFlag: result.internalTradeFlag,
          cpty: result.cpty,
          dbCheck: result.dbCheck,
          conflictFlag: result.conflictFlag,
          capturedAmount: result.capturedAmount,
          amount1bak: result.amount1bak,
          quotationUnit: result.quotationUnit,
          amount2bak: result.amount2bak,
          splitInfo: `{"splitRate2":${result.splitSpotRateSecond},"splitSpotRate":${result.splitSpotRateFirst},"firstDealPair":${result.underlying}}`,
          underlying: result.underlying,
          spotRate: result.spotRate,
          amount1: result.amount1,
          amount2: result.amount2,
          buySell: result.buySell,
          tradeDate: result.tradeDate?.toString(),
          tradeTime: result.tradeTime?.toString(),
          valueDate: result.valueDate?.toString(),
          dealFlag: result.dealFlag,
          sourceName: result.sourceName,
          templateCode: result.templateCode,
          transactionDate: result.transactionDate?.toString(),
          transactionTime: result.transactionTime?.toString(),
          tacount: result.tacount,
          tpurpose: result.tpurpose,
          ext20: result.ext20,
          comments: result.comments,
          ssiCodeOurBuyCcy1: result.ssiCodeOurBuyCcy1 || '',
          ssiCodeCptyBuyCcy1: result.ssiCodeCptyBuyCcy1 || '',
          ssiCodeOurSellCcy1: result.ssiCodeOurSellCcy1 || '',
          ssiCodeCptySellCcy1: result.ssiCodeCptySellCcy1 || '',
          ssiCodeOurBuyCcy2: result.ssiCodeOurBuyCcy2 || '',
          ssiCodeCptyBuyCcy2: result.ssiCodeCptyBuyCcy2 || '',
          ssiCodeOurSellCcy2: result.ssiCodeOurSellCcy2 || '',
          ssiCodeCptySellCcy2: result.ssiCodeCptySellCcy2 || '',
          ext1: result.ext1,
          ext2: result.ext2,
          ext3: result.ext3,
          ext4: result.ext4,
          settlementMode: result.settlementMode,
          isPass: result.isPass,
          isBondDuration: result.isBondDuration,
          extContent:
            '@undefined|\u8d27\u5e011\u8d26\u6237\u884c@|\u8d27\u5e012\u8d26\u6237\u884c@|\u6e05\u7b97\u65b9\u5f0f@|\u4e1a\u52a1\u5458@undefined',
          maturityDate: result.maturityDate?.toString(),
        };

        this.setccy1ccy2(result.underlying);
        this.getdcsPairInfo(result.underlying);
        // this.getDCSqueryFolderById(result.folder);
        this.getDCSqueryCptyName(result.cpty);
        // this.getbottomBtns(result.folder, result.dealStatus.toString(), result.typeOfEvent.toString());
      });

      this.quickSearchVisible = false;
    },
    // 打开 附件管理 弹窗
    handleattachmentVisible() {
      this.attachmentVisible = false;
      setTimeout(() => {
        this.attachmentVisible = true;
      }, 20);
    },
    // 关闭 附件管理 弹窗
    handleCloseAttachment() {
      this.attachmentVisible = false;
    },
    // 要复制交易 table row 双击事件
    handleAttachmentdblclick(row) {
      this.attachmentVisible = false;
    },
  },
};
</script>
