<template>
  <div class="eibs-tab">
    <c-col :span="9">
      <c-istream-table :list="model.filstm.rows||[]" :columns="stmData.columns" :showButtonFlg="true"
        @chooseRowEvent="rowcli">
      </c-istream-table>
    </c-col>

    <c-col :span="9" :offset="1">
      <c-col :span="24">
        <el-form-item label="操作选择" prop="opetye">
          <c-select v-model="model.opetye" style="width: 100%">
            <el-option v-for="item in opetye" :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="filpth">
          <c-input v-model="model.filpth" style="width: 100%" placeholder="请输入本地文件路径" disabled></c-input>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="上传文件名" prop="newnam">
          <c-input v-model="model.newnam" style="width: 100%" :disabled="model.opetye !== '1'"></c-input>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注意:上传文件若包含表头系统将无法解析</span>
      </c-col>
      <c-col :span="24">
        <el-form-item label="删除首行上传">
          <c-checkbox v-model="model.flg" :disabled="model.opetye !== '1'"></c-checkbox>
        </el-form-item>
      </c-col>
      <c-col :span="24">
        <el-form-item label="解析文件名" prop="opefil">
          <c-input v-model="model.opefil" disabled></c-input>
        </el-form-item>
      </c-col>
    </c-col>

    <c-col :span="4" :offset="1">
      <c-col :span="24">
        <c-button type="primary" :disabled="!(this.flag && model.opetye == '1')" @click="onOpnfil">文件预览</c-button>
      </c-col>
      <c-col><br /></c-col>
      <c-col :span="24">
        <c-button type="primary" :disabled="!(this.flag && model.opetye == '1')" @click="onUpload">文件上传</c-button>
      </c-col>
      <c-col><br /></c-col>
      <c-col :span="24">
        <c-button type="primary" :disabled="!(this.flag && model.opetye =='2')" @click="onReadfil">文件解析</c-button>
      </c-col>
      <c-col><br /></c-col>
      <c-col :span="24">
        <c-button type="primary" :disabled="!(this.flag && (model.opetye == '1'||model.opetye == '2'))" @click="onDel">
          文件删除</c-button>
      </c-col>
    </c-col>
  </div>
</template>
<script>
import Api from "~/service/Api";
import commonProcess from "~/mixin/commonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Cptbat/Event";

export default {
  inject: ["root"],
  props: ["model", "codes"],
  mixins: [commonProcess],
  data() {
    return {
      flag: false,
      opetye: [
        { label: "文件上传", value: "1" },
        { label: "文件解析", value: "2" },
        { label: "已解析文件", value: "3" },
      ],
      stmData: {
        columns: [
          '0 1 "批量文件列表" 500',
        ],
        data: [],
      },


    };
  },
  methods: {
    ...Event,

  },
  watch: {
    "model.opetye": {
      immediate: true,
      async handler(val, oldVal) {
        if (this.model.opetye == '1') {
          let rtnmsg = await this.executeRule("opetye")
          if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

          }
          else {
            this.$notify.error({ title: '错误', message: '服务请求失败!' });
          }
        }
        else if (this.model.opetye == '2') {
          let rtnmsg = await this.executeRule("opetye")
          if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑

          }
          else {
            this.$notify.error({ title: '错误', message: '服务请求失败!' });
          }
        }
        if (this.model.opetye == '3') {
          let rtnmsg = await this.executeRule("opetye")
          if (rtnmsg.respCode == SUCCESS) {
            //TODO 处理数据逻辑
          }
          else {
            this.$notify.error({ title: '错误', message: '服务请求失败!' });
          }
        }
      },
    },
  },
  created: function () { },
};
</script>
<style>

</style>