<template>
  <div>
    <div v-if="isShow == 1">
      <p-card title="打印策略维护">
        <p-grid-form
          ref="formTarget"
          :items="gridItems"
          @submit="
            ($event, form) => {
              handleSubmit($event, form, 'formTarget');
            }
          "
        />
        <p-table
          v-if="tableColumnsConfig"
          ref="logTable"
          :columns="tableColumnsConfig"
          :execute="false"
          rowKey="strategyId"
          :expandRowByClick="false"
          :dataSource.sync="dataSource"
          :rowSelectType="false"
          :loading="tabLoding"
          :remoteUrl="remoteUrl"
          :remoteParams="remoteParams"
          dragle
          ellipsis
          bordered
          :pagination="paginations"
        >
          <div slot="status" slot-scope="record">
            <span slot="status" v-if="record === 0">否</span>
            <span slot="status" v-if="record === 1">是</span>
          </div>
          <div slot="action" href="javascript:;" slot-scope="text">
            <!-- <a slot="action" style="margin: 0 5px" @click.stop="lookat(text)">详情</a><a-divider type="vertical" /> -->
            <a slot="action" style="margin: 0 5px" @click.stop="edit(text)">修改</a><a-divider type="vertical" />
            <a slot="action" style="margin: 0 5px" @click.stop="log(text)">日志</a><a-divider type="vertical" />
            <a slot="action" style="margin: 0 5px" @click.stop="testSql(text)">测试</a><a-divider type="vertical" />
            <a slot="action" style="margin: 0 5px" @click.stop="deleteOne(text)">删除</a>
          </div>
        </p-table>
        <div class="btnList" slot="extra">
          <p-button type="primary" style="margin-right: 10px" @click="opentDatasource">数据源</p-button>

          <p-button type="primary" icon="plus" @click="add">新增</p-button>
        </div>
      </p-card>
    </div>
    <div v-if="isShow == 2">
      <dateSource @backto="isShow = 1"></dateSource>
    </div>
    <div>
      <p-modal :title="Title" width="1050px" v-if="visible" :visible="visible" :enlargeable="false" :draggable="true" :maskClosable="false" @cancel="handleCancel" :footer="null">
        <div v-if="visible" class="detailForm">
          <a-tabs v-model:activeKey="activeKey">
            <a-tab-pane key="1" tab="基础信息" force-render>
              <p-grid-form
                ref="formdetail"
                :items="detailFormItems"
                @submit="
                  ($event, form) => {
                    formSubmit($event, form, 'formdetail');
                  }
                "
              >
                <div slot="" slot-scope="" class="update-btn">
                  <a-upload :multiple="true" :file-list="fileList" @change="handleChange" :action="actionUrl" :headers="headers" :data="uploadData" :disabled="disabled" :showUploadList="false">
                    <a-button :disabled="dis">模板上传</a-button>
                  </a-upload>
                </div>
              </p-grid-form>
            </a-tab-pane>
            <a-tab-pane key="2" tab="打印策略" force-render>
              <!-- <div style="text-align:right;">
                <p-button type="primary"   @click="addPerpson('3')">人员方案维护</p-button>
                <p-button type="primary" style="margin-left:10px" @click="addPerpson('4')">人员打印机维护</p-button>
              </div> -->
              <p-grid-form
                ref="formdetail2"
                :items="detailFormItems2"
                @submit="
                  ($event, form) => {
                    formSubmit($event, form, 'formdetail');
                  }
                "
              />
              <div :key="printStrategy" v-if="printStrategy == '3' || printStrategy == '4'" style="padding: 0 80px">
                <div style="text-align: right; padding: 0 0 10px 0">
                  <p-button type="primary" style="margin-left: 10px" @click="addPersonStrategy">新增</p-button>
                </div>
                <p-table
                  ref="logTable3"
                  :columns="printStrategy == '4' ? tableColumnsConfig2 : tableColumnsConfig1"
                  :execute="false"
                  rowKey="id"
                  :autoLoad="isDisabled != 2"
                  :expandRowByClick="false"
                  :dataSource.sync="sysPrintStrategyPersonList"
                  :rowSelectType="false"
                  :pagination="false"
                  :scroll="{ y: 300 }"
                  :remoteUrl="remoteUrl1"
                  :remoteParams="remoteParams1"
                  dragle
                  ellipsis
                  bordered
                >
                  <div slot="action" href="javascript:;" slot-scope="text, record, index">
                    <!-- {{ index }} -->
                    <a slot="action" style="margin: 0 5px" @click.stop="deletePerson(text, index)">删除</a>
                  </div>
                </p-table>
              </div>
            </a-tab-pane>
            <a-tab-pane key="3" tab="SQL配置" force-render>
              <a-card class="sqlarea" :title="configTxt + '编辑区' + (clickedItem ? ' - ' + clickedItem.name : '')">
                <template v-slot:extra>
                  <a-tooltip placement="left" :title="helpTxt">
                    <plg-icon type="question-circle"></plg-icon>
                  </a-tooltip>

                  <!-- <p-button type="link" v-show="isHideSearch" style="margin-left: 10px" @click="showSearch">{{
                    $lang('还原')
                  }}</p-button>
                  <p-button type="link" v-show="!isHideSearch" style="margin-left: 10px" @click="hideSearch">{{
                    $lang('最大化')
                  }}</p-button>
                  <p-button
                    type="link"
                    v-show="slang != 'sql' && stepConf"
                    style="margin-left: 10px"
                    @click="changeStepConf"
                    >{{ $lang('代码视图') }}</p-button
                  >
                  <p-button
                    type="link"
                    v-show="slang != 'sql' && !stepConf"
                    style="margin-left: 10px"
                    @click="changeStepConf"
                    >{{ $lang('配置视图') }}</p-button
                  > -->

                  <PTest :temp="content" :infId="infId" :item="clickedItem" :testParams="testParams" @callBack="callBack" />
                  <!-- <p-button type="primary" style="margin-left: 10px" @click="saveSQL">{{ $lang('保存配置') }}</p-button> -->
                </template>
                <a-spin :spinning="spinning">
                  <PCode v-if="!stepConf" ref="code" :height="codeAreaHeight" v-model="content" :language="slang" />
                  <StepConfigurationPanel ref="StepConfigurationPanel" :conf="content" />
                </a-spin>
              </a-card>
            </a-tab-pane>
          </a-tabs>
          <div style="text-align: right">
            <p-button type="primary" v-if="isDisabled == 0 ? false : true" @click="addForm"> 保存 </p-button>
          </div>
        </div>
      </p-modal>
    </div>
    <p-modal title="人员打印机新增" width="1050px" :visible="addVisible" v-if="addVisible" :enlargeable="false" :draggable="true" :maskClosable="false" @cancel="addHandleCancels" @ok="handleOk">
      <p-grid-form
        ref="formdetail3"
        :items="detailFormItems3"
        @submit="
          ($event, form) => {
            formSubmit($event, form, 'formdetail');
          }
        "
      />
    </p-modal>
    <p-modal  
        :title="testFlag ? '测试' :'日志详情'"
        :width="testFlag ? '900px' : '1500px'"
        :visible="logVisible"
        :enlargeable="false"
        :enableDrag="true"
        :maskClosable="false"
        :footer="null"
        @cancel="cancelLogModal"
        @ok="cancelLogModal">
        <p-spin size="small" :spinning="logSpinning">
          <p-table
              ref="logtable"
              rowKey="id"
              border
              v-if="logFlag"
              :hasRowCount="false"
              :pagination="logPagination"
              @change="changePagination"
              :data-source="dataSourceLog"
            >
            <p-table-column :width="180" data-index='gmtCreate' title='请求时间' :ellipsis="true" >
              <template slot-scope='text'>
                <a-tooltip>
                  <template slot="title">
                    {{ text }}
                  </template>
                  {{ text }}
                </a-tooltip>
              </template>
            </p-table-column>
            <p-table-column :width="180" data-index='status' title='状态' :ellipsis="true">
              <template slot-scope='text'>
                <div>
                  <span :class="[text == 1 ? 'colSpan1' : 'colSpan']"></span>
                  {{text == 1 ? '成功' : '失败'}}
                </div>
              </template>
            </p-table-column>
            <p-table-column :width="180" data-index='param' title='请求参数' :ellipsis="true">
              <template slot-scope='text'>
                <a-tooltip>
                  <template slot="title">
                    {{ text }}
                  </template>
                  {{ text }}
                </a-tooltip>
              </template>
            </p-table-column>
            <p-table-column :width="180" data-index='path' title='请求接口路径' :ellipsis="true">
              <template slot-scope='text'>
                <a-tooltip>
                  <template slot="title">
                    {{ text }}
                  </template>
                  {{ text }}
                </a-tooltip>
              </template>
            </p-table-column>
            <p-table-column :width="180" data-index='printAdress' title='打印服务地址' :ellipsis="true">
              <template slot-scope='text'>
                <a-tooltip>
                  <template slot="title">
                    {{ text }}
                  </template>
                  {{ text }}
                </a-tooltip>
              </template>
            </p-table-column>
            <p-table-column :width="180" data-index='printParam' title='打印服务参数' :ellipsis="true">
              <template slot-scope='text'>
                <a-tooltip>
                  <template slot="title">
                    {{ text }}
                  </template>
                  {{ text }}
                </a-tooltip>
              </template>
            </p-table-column>
          </p-table>
          <PTestSql v-if="testFlag" :temp="content" :infId="infId" :item="clickedItem" :testParams="testParams"  @cancelLogModal="cancelLogModal"/>
        </p-spin>
    </p-modal>
  </div>
</template>
<script>
// import { diffOption } from '@/views/kzyWMS/utils/index.js'
import { setFormItems, tableColumnsConfig, detailFormItems, detailFormItems2, detailFormItems3, tableColumnsConfig1, tableColumnsConfig2, logColumnsConfig } from "./js/config";
import { getList, addDetail, delDetail, updateDetail, printStrategy, findByIdStrategy, editStrategy, deleteStrategy, addPersonStrategy, deletePersonStrategy, getLogs } from "./api/index";
import PCode from "./code";
import StepConfigurationPanel from "./stepConfigurationPanel.vue";
import PTest from "./test";
import PTestSql from './testSql.vue'
import success from "@/locales/lang/zh-CN/result/success";
import dateSource from "./modules/dateSource/index.vue";

const initPages = (pagesSize = 10) => {
  return {
    total: 0,
    defaultCurrent: 1,
    defaultPageSize: pagesSize,
    current: 1,
    pageSize: pagesSize,
    showQuickJumper: true,
    //  size: 'small',
    showTotal: function (total, range) {
      return "从" + range[0] + "至" + range[1] + ",共" + total + "条";
    },
    showSizeChanger: true,
    pageSizeOptions: ["50", "100", "150", "200", "250", "300", "500", "1000"],
  };
};

export default {
  // components: { detailDialog },
  components: {
    PTestSql: PTestSql,
    PCode: PCode,
    PTest: PTest,
    StepConfigurationPanel,
    dateSource,
  },
  data() {
    return {
      sysPrintStrategyPersonList: [],
      remoteUrl: {
        url: `/api/upcloud-base-common/print/strategy/list`,
        method: "post",
        // headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        params: {},
      },
      remoteUrl1: {
        url: `/api/upcloud-base-common/print/strategy/listPersonStrategy`,
        method: "get",
        params: {},
      },
      isShow: 1,
      remoteParams1: {},
      dataSource: [],
      gridItems: setFormItems(this),
      rowSelectType: 2,
      tableColumnsConfig: tableColumnsConfig,
      tableColumnsConfig1: tableColumnsConfig1,
      tableColumnsConfig2: tableColumnsConfig2,
      detailFormItems: detailFormItems(this),
      detailFormItems2: detailFormItems2(this),
      detailFormItems3: detailFormItems3(this),
      tabLoding: false,
      Title: "",
      visible: false,
      fileList: [],
      videoUrlList: [],
      actionUrl: "/api/service-filemanagement/file/upload-file",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      uploadData: { directory: "昆中药/打印模板/", storageType: 0, isFileName: 1 },
      disabled: false,
      dis: false,
      isDisabled: null,
      paginations: initPages(50),
      remoteParams: {},
      activeKey: "1",
      configTxt: "配置",
      clickedItem: null,
      isHideSearch: false,
      stepConf: true,
      infId: "0",
      slang: "sql",
      sqlTemplate: {},
      spinning: false,
      perpsonvisible: false,
      addVisible: false,
      printStrategy: "",
      testParams: {},
      content: `<script><\/script>`,
      helpTxt: ` 1、支持mybatis脚本语法，但需包含在
                  "script"中，并且sql为一层结构
                2、支持内置参数"currentUser",值为userDTO,结构如下：
                 String id;
                  String username;
                  String nickname;
                  String pwd;
                  String phone;
                  String email;
                  String enterpriseId;
                  String enterpriseName;
                  int state;
                  int type;
                  boolean disable;
                  Set&lt;String&gt; roles;
                  UserBizModel userBizModel;
                  Set&lt;String&gt; authorities;
                  Map&lt;String,Object&gt; extendsData;

                  userBizModel结构如下:
                  private String id;
                  private String defaultWarehouseId;
                  private String employeeNo;
                  private String employeeName;
                  //仓库id集合
                  private Set&lt;String&gt; warehouses;
                  //组织id集合
                  private Set&lt;String&gt; organizations;
                  //客户id集合
                  private Set&lt;String&gt; customers;
                  //货主id集合
                  private Set&lt;String&gt; consignors;
                  //供应商id集合
                  private Set&lt;String&gt; suppliers;
                  //承运商集合
                  private Set&lt;String&gt; carriers;
                  //行业集合
                  private Set&lt;String&gt; industries;`,
      logPagination: {
        total: 0,
        pageSize: 10, //每页中显示10条数据
        pageNum: 1,
        showSizeChanger: true,
        pageSizeOptions: ['10', '15', '20'], //每页中显示的数据
        showTotal: total => `共有 ${total} 条数据`, //分页中显示总的数据
      },
      logVisible:false,
      logColumns:logColumnsConfig,
      dataSourceLog:[],
      strategyId:null,
      logSpinning:false,
      logFlag:false,
      testFlag:false
    };
  },
  mounted() {
    let warehouse = this.$store.state.user.warehouse;
    this.$nextTick(() => {
      this.$refs.formTarget.form.setFieldsValue(warehouse);
      // this.getList()
    });
  },
  created() {
    // diffOption(tableColumnsConfig).then((res) => {
    //   this.tableColumnsConfig = res
    // })
    // this.headers = { Authorization: 'Bearer' + JSON.parse(localStorage.getItem('token')) }
    console.log(sessionStorage.getItem("token"));
    // console.log( JSON.parse(sessionStorage.getItem('token')))
    this.headers = { Authorization: "Bearer" + sessionStorage.getItem("token") };
    console.log(this.headers, "this.headers");
  },
  methods: {
    opentDatasource() {
      this.isShow = 2;
    },
    changeStepConf() {
      this.stepConf = !this.stepConf;
      if (this.stepConf) {
        // console.log( this.content)
        //代码视图
      } else if (!this.stepConf) {
        this.slang = "json";
        this.configTxt = "配置";
        this.content = JSON.stringify(this.$refs.StepConfigurationPanel.getFormValue());
        setTimeout(() => {
          this.formatSQL();
        }, 1000);
      }
    },
    formatSQL() {
      this.$refs.code.formatDoc();
    },
    saveSQL() {
      if (!this.clickedItem) return;
      var tempId = this.clickedItem.sqlTemplate ? this.clickedItem.sqlTemplate.id : "";
      if (this.clickedItem.type == "dynamics") {
        this.content = JSON.stringify(this.$refs.StepConfigurationPanel.getFormValue());
      }
      return this.handleAddOrUpdateSubItem(this.clickedItem.id, {
        template: this.content,
        id: tempId,
      });
    },
    handleAddOrUpdateSubItem(id, params) {
      // this.spinning = true
      // return addOrUpdateSubItem(id, params)
      //   .then((res) => {
      //     this.spinning = false
      //     if (!res.success) {
      //       this.$exception(res)
      //       return
      //     }
      //     this.$message.success(this.$lang('保存成功'))
      //   })
      //   .catch((er) => {
      //     this.spinning = false
      //   })
    },
    handleCancels() {
      this.perpsonvisible = false;
    },
    addPersonStrategy() {
      this.detailFormItems3[1].label = this.printStrategy == "3" ? "打印方案" : "打印机名称";

      this.addVisible = true;
    },
    addHandleCancels() {
      this.addVisible = false;
    },
    callBack() {
      const { dbKey, underlineToCamel } = this.$refs.formdetail.form.getFieldsValue();
      this.testParams = {
        dbKey,
        underlineToCamel,
      };
      this.content = JSON.stringify(this.$refs.StepConfigurationPanel.getFormValue());
      console.log(this.testParams);
    },
    deletePerson(text, index) {
      this.$confirm({
        title: "确定是否要删除?",
        content: "",
        onOk: () => {
          this.sysPrintStrategyPersonList.splice(index, 1);
          //   return new Promise((resolve, reject) => {
          //     deletePersonStrategy({ id: text.id }).then((res) => {
          //       if (res.success) {
          //         this.$message.success(res.message);
          //         this.$refs.logTable3.reload();
          //         resolve();
          //       } else {
          //         this.$message.error(res.message);
          //         resolve();
          //       }
          //     });
          //   }).catch(() => console.log("Oops errors!"));
        },
        onCancel() {},
      });
    },
    handleOk() {
      let data = this.$refs.formdetail3.form.getFieldsValue();
      data.printStrategy = this.printStrategy;
      console.log(data);
      this.sysPrintStrategyPersonList.push(data);
      this.addVisible = false;
      this.perpsonvisible = false;
      //   addPersonStrategy(data).then((res) => {
      //     if (res.success) {
      //       this.$message.success(res.message);
      //       this.$refs.logTable3.reload();
      //       this.addVisible = false;
      //       this.perpsonvisible = false;
      //     }
      //   });
    },
    resetFun() {
      this.activeKey = "1";
      this.printStrategy = "";
      this.content = `<script><\/script>`;
    },
    //弹框关闭
    handleCancel(e) {
      console.log("Clicked cancel button");
      this.visible = false;
      this.resetFun();

      // this.$refs.formdetail.form.resetFields()
    },
    enlargeChange(isEnlarge) {
      console.log(isEnlarge, "isEnlarge");
    },

    //查询事件
    handleSubmit(event, form) {
      event.preventDefault();
      let bb = this.$refs.formTarget.form.getFieldsValue();
      // let aa = { pageNum: 1, pageSize: 15 }
      let params = { ...bb };
      // this.tabLoding = true
      form.validateFields((error, values) => {
        if (!error) {
          this.remoteParams = params;
        }
      });
    },

    //跳转新增
    add() {
      this.sysPrintStrategyPersonList = [];
      this.visible = true;
      this.isDisabled = 2;
      this.dis = false;
      this.Title = "打印方案-新增";
      // this.$nextTick(() => {
      //   this.$refs.formdetail.form.resetFields()
      //   this.$refs.formdetail.form.enableItem()
      //   this.$refs.formdetail.form.setFieldsValue({ printServiceUrl: 'http://127.0.0.1:6060/print' })
      //   this.$refs.formdetail.form.disableItem('tempname')
      //   this.$refs.formdetail.form.disableItem('temppath')
      // })
    },

    //跳转详情
    lookat(text) {
      this.Title = `打印方案 [${text.configname}] 信息查看`;
      this.isDisabled = 0;
      this.dis = true;
      this.visible = true;
      let warehouse = this.$store.state.user.warehouse;
      let test = { ...text, ...warehouse };
      this.$nextTick(() => {
        this.$refs.formdetail.form.setFieldsValue(test);
        this.$refs.formdetail.form.disableItem();
      });
    },
    //跳转修改
    edit(text) {
      console.log(text, "texttext");
      this.Title = `[${text.printBillName}] 信息修改`;
      this.isDisabled = 1;
      let { strategyId } = text;
      this.sysPrintStrategyPersonList = [];
      this.remoteParams1.strategyId = strategyId;
      this.dis = false;
      this.visible = true;
      let warehouse = this.$store.state.user.warehouse;
      let params = {
        id: text.strategyId,
      };
      findByIdStrategy(params).then((res) => {
        if (res.success) {
          this.$nextTick(() => {
            // this.$refs.formdetail.form.enableItem()
            console.log(text, "信息修改");
            console.log(this.$refs, "this.$refs");
            this.$refs.formdetail.form.setFieldsValue(res.data.sysPrintStrategy);
            this.$refs.formdetail2.form.setFieldsValue(res.data.sysPrintStrategy);
            let value = res.data.sysPrintStrategy.printStrategy;
            this.printStrategy = value;
            this.remoteParams1.printStrategy = value;
            let form = this.$refs.formdetail2.form;
            if (value == "1") {
              form.visibleItem(["printSolution"]);
              form.invisibleItem(["printName"]);
            } else if (value == "2") {
              form.visibleItem(["printName"]);
              form.invisibleItem(["printSolution"]);
            } else if (value == "3" || value == "4" || value == "0") {
              form.invisibleItem(["printSolution", "printName"]);
            }
            this.sqlTemplate = res.data.sqlTemplate;
            this.content = res.data.sqlTemplate.template;
          });
        }
      });
      // let test = { ...text, ...warehouse }
      // this.$nextTick(() => {
      //   this.$refs.formdetail.form.enableItem()
      //   console.log(text, '信息修改')
      //   this.$refs.formdetail.form.setFieldsValue(test)
      // })
    },
    changePagination(params) {
      console.log(params)
      // current=当前页码 pageSize=每页数量 total=总数
      const {
          current,
          pageSize,
          total
      } = params
      this.logPagination = {
        ...this.logPagination,
        pageNum:current,
        pageSize,
        total,
      }

      this.log({strategyId:this.strategyId})
    },
    cancelLogModal(){
      this.logVisible = false
      this.testFlag = false
      this.logFlag = false
      this.dataSourceLog = []
      this.strategyId = null
    },
    // 测试sql
    testSql(text){
      this.logVisible = true
      this.testFlag = true
      this.logFlag = false
    },
    // 获取日志
    log(text){
      this.logFlag = true
      this.testFlag = false
      this.logVisible = true
      this.logSpinning = true
      const { strategyId } = text
      this.strategyId = strategyId
      let params = {
        strategyId,
        pageNum: this.logPagination.pageNum, // 页码
        pageSize: this.logPagination.pageSize // 页数
      }
      getLogs(params).then(res=>{
        this.logPagination.total = Number(res.data?.totalCount)
        this.dataSourceLog = res.data?.list
        // .map((v)=>{
        //   return {
        //     ...v,
        //     status:v.status == 1 ? '成功' : '失败'
        //   }
        // })
      }).finally(()=>{
        this.logSpinning = false
      })
    },
    //保存事件
    async addForm() {
      let from1 = this.$refs.formdetail.form.getFieldsValue();
      let from2 = this.$refs.formdetail2.form.getFieldsValue();
      console.log(this.$refs, "this.$refs");
      this.content = JSON.stringify(this.$refs.StepConfigurationPanel.getFormValue());
      // this.content = this.$refs.StepConfigurationPanel.getFormValue()
      console.log(from1, from2);
      let sysPrintStrategy = { ...from1, ...from2 };
      console.log(sysPrintStrategy);
      console.log(this.content);
      let sqlTemplate = this.sqlTemplate;
      sqlTemplate.template = this.content;
      let params = {
        sqlTemplate,
        sysPrintStrategy,
        sysPrintStrategyPersonList: this.sysPrintStrategyPersonList,
      };
      let dataArray = [this.$refs.formdetail.form.validateFields(), this.$refs.formdetail2.form.validateFields()];
      Promise.all(dataArray)
        .then((res) => {
          //isDisabled判断新增或修改
          if (this.isDisabled == 2) {
            const parame = this.$refs.formdetail.form.getFieldsValue();
            // let warehouse = this.$store.state.user.warehouse
            // parame.branchid = warehouse.warehouseId
            printStrategy(params).then((res) => {
              if (res.success) {
                this.$message.success(res.message);
                this.visible = false;
                this.resetFun();
                this.$refs.logTable.reload();
              } else {
                this.$message.error(res.message);
              }
            });
          } else {
            this.$nextTick(() => {
              editStrategy(params).then((res) => {
                if (res.success) {
                  this.$message.success(res.message);
                  this.visible = false;
                  this.resetFun();
                  this.$refs.logTable.reload();
                } else {
                  this.$message.error(res.message);
                }
              });
            });
          }
        })
        .catch((error) => {
          console.log(error, "error111111111111111");
          this.$message.error("请检查必填数据是否全部填写");
        });
    },

    //删除
    deleteOne(text) {
      let _this = this;
      console.log(text, "text");
      this.$confirm({
        title: "确定是否要删除?",
        content: "",
        onOk() {
          return new Promise((resolve, reject) => {
            deleteStrategy({ ids: text.strategyId }).then((res) => {
              if (res.success) {
                _this.$message.success(res.message);
                _this.$refs.logTable.reload();
                resolve();
              } else {
                _this.$message.error(res.message);
                resolve();
              }
            });
          }).catch(() => console.log("Oops errors!"));
        },
        onCancel() {},
      });
    },
    //upload change事件
    handleChange(info, data) {
      let { fileList } = info;
      const status = info.file.status;
      console.log(info, data, "upload change事件");
      this.$refs.formdetail.form.setFieldsValue({ tempName: info.file.name });
      this.iconLoading = true;
      if (status === "done") {
        this.videoUrlList.push({ uid: fileList[fileList.length - 1].uid, url: info.file.response.message });
        this.iconLoading = false;
        this.$emit("handleChange", info, data);
        if (info.file.response.success) {
          this.$message.success(info.file.response.message);
          this.$refs.formdetail.form.setFieldsValue({ temppathId: info.file.response.data.id });
          this.$refs.formdetail.form.setFieldsValue({ tempPath: info.file.response.data.path });
        } else {
          this.$message.error(info.file.response.message);
        }
      }
      this.fileList = [...fileList];
    },
  },
};
</script>
<style lang="less" scoped>
.detailForm {
  position: relative;
  .update-btn {
    position: absolute;
    left: 430px;
    top: 165px;
  }
}
.sqlarea {
  margin: 10px 0;
  .ant-card-body {
    padding: 0px 0px 0px 15px !important;
  }
}
</style>
