<template>
  <div class="eibs-tab">
    <c-list-search @form-reset="handleReset" @form-search="handleSearch">
      <!-- ===================左边================= -->
      <c-col :span="11">
        <c-col :span="24">
          <el-form-item label="申报类型" prop="cnytyp">
            <c-select v-model="model.cnytyp" style="width: 100%" placeholder="请选择申报类型">
              <el-option v-for="item in codes.cnytyp" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </c-select>
          </el-form-item>
        </c-col>

        <c-col :span="24">
          <el-form-item label="业务编号" prop="ownref">
            <c-input v-model="model.ownref" maxlength="20" placeholder="请输入业务编号"></c-input>
          </el-form-item>
        </c-col>


      </c-col>
      <!-- =====================右边=========================== -->
      <c-col :span="11" :offset="1">

        <el-form-item label="日期" prop="frmdat">
          <c-col :span="24">
            <c-col :span="11">
              <c-date-picker type="date" v-model="model.frmdat" style="width: 100%" placeholder="请选择日期"></c-date-picker>
            </c-col>
            <c-col :span="2" style="text-align:center">-</c-col>
            <c-col :span="11">
              <c-date-picker type="date" v-model="model.tildat" style="width: 100%" placeholder="请选择日期"></c-date-picker>
            </c-col>
          </c-col>
        </el-form-item>

        <c-col :span="24">
          <el-form-item label="业务所属行" prop="ownextkey">
            <c-select v-model="model.ownextkey" style="width: 100%" placeholder="请选择业务所属行">
              <el-option v-for="item in ownextkey" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </c-select>
          </el-form-item>
        </c-col>
      </c-col>
    </c-list-search>

    <!-- ======================底部============================ -->
    <c-col :span="24">
      <!-- <c-col :span="24">
                <el-form-item label="Selection" prop="cnystm">
                    <c-input  v-model="model.cnystm"  placeholder="请输入Selection"></c-input>
                </el-form-item>
            </c-col> -->
      <c-istream-table :list="stmData.data" :columns="stmData.columns" :showButtonFlg="true">
        <el-table-column fixed="right" prop="op" width="auto">
          <template slot="header">
            <c-col :span="11" style="text-align: center">操作</c-col>
            <!-- <c-col :span="12" style="text-align:right"><c-button icon="el-icon-s-tools"></c-button></c-col> -->
          </template>
          <template slot-scope="scope">
            <c-button size="small" @click="getTrnInfo(scope.$index, scope.row)" slot="reference"
              :disabled="model.cnytyp == '6'">
              详情</c-button>
          </template>
        </el-table-column>
      </c-istream-table>
    </c-col>

  </div>


</template>
<script>
import Api from "~/service/Api";
import Utils from "~/utils";
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Cnysel/Event";

export default {
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonProcess],
  components: {
  },
  data() {
    return {
      ownextkey: [
        { label: "<ALL>", value: "<ALL>" },
        { label: "00000047 中国光大银行北京分部", value: "00000047" },
        { label: "00001047 LM ADD", value: "00001047" },
      ],
      stmData: {
        columns: [
          '0 1 "业务编号" 140',
          '1 2 "币种" 110',
          '2 3 "金额" 120 2 8:1 2 5',
          '3 4 "收款人名称" 250',
          '4 5 "付款人名称" 250',
          '5 6 "业务发生日期" 150 20 30 1',
          { index: 6, position: 7, width: 100, pattern: "code", label: "复核状态", "code": "relsta" },
        ],
        data: [],
      },

    };
  },
  // inject: {
  //   tabVal: "root.tabVal"
  // },
  methods: {
    ...Event,
    async getTrnInfo(idx, row) {
      console.log(row);
      console.log(this.root.tabVal);
      console.log(this.model.cnytyp);
      const selIds = [idx + 1];
      const selDst = "cnystm" //列表对应后台模型中的stream
      let params = { selDst, selIds };
      this.executeRule("dtlbut", params).then((res) => {
        if (res.respCode == SUCCESS) {
          console.log(res.data);
          Utils.copyValueFromVO(this.model, res.data);
          switch (this.model.cnytyp) {
            case "1":
              this.root.tabVal = "incp";
              break;
            case "2":
              this.root.tabVal = "outp";
              break;
            case "3":
              this.root.tabVal = "libp";
              break;
            case "4":
              this.root.tabVal = "trap";
              break;
            case "5":
              this.root.tabVal = "voup";
              break;
            default:
              this.root.tabVal = "selp";
          }
        } else {
          const h = this.$createElement;
          const msg = res.respMsg || '请求执行失败!'
          this.$notify.error({ title: '错误', message: h('p', { style: 'word-break:break-all;' }, msg) })
        }
      })
      console.log(this.root.tabVal);
    }
  },
  created: function () { },
};
</script>
<style>

</style>