
<template>
  <div class="page-table run-mod-box">
    <Form :model="searchParams" ref="filterConfig" class="ivu-form-no-margin-bottom" :label-width="80">
      <Row :gutter="15" class="code-row-bg">
        <Col span="10" style="border:none;">
          <Form-item prop="tableName" label="表格名称:">
            <Input size="small" type="text" v-model="searchParams.tableName"  disabled></Input>
          </Form-item>
        </Col>
      </Row>
      <Row :gutter="15" class="code-row-bg">
        <Col span="10" style="border:none;">
        <Form-item prop="operatorEmpName" label="过滤条件:"> 
          <Input type="textarea" v-model="searchParams.sqlText" ></Input>
        </Form-item>
        </Col>
      </Row>
    </Form>
    <div>
      <Button type="info" :loading="saveLoad" style="margin-left:80px" @click="save">保存</Button>
    </div>
  </div>
</template>
<script>
import { DataSelect } from "ems-components";
import Server from "./server.js";
const server = new Server();
export default {
  components: {
    DataSelect,
  },
  data() {
    return {
      server: server,
      searchParams:{
        tableName:"t_receivables_sql",
        sqlText:""
      },
      saveLoad:false,
      filterList:["insert","update","create","drop","alter","delete","intersect","except","truncate","netlocalgroup","administrators"]
    };
  },
  computed: {},
  created: function() {},
  beforeMount: function() {},
  mounted: function() {
    this.server.getReceivablePushTssSql().then(res=>{
      if(res.statusCode == "-1"){
        this.$Message.error(res.msg);
      }else{
        this.searchParams.sqlText = res.data.data;
      }
    });
  },
  beforeDestroy: function() {},
  destroyed: function() {},
  methods: {
    save(){
      if(this.searchParams.sqlText.trim() == ""){
        this.$Message.info("过滤条件不能为空");
        return;
      }
      for(let i=0;i<this.filterList.length;i++){
        if((this.searchParams.sqlText.trim()).indexOf(this.filterList[i]) > -1){
          this.$Message.info("过滤条件包含非法字段");
          return;
        }
      }
      this.saveLoad=true;
      this.server.updateReceivablePushTssSql({sqlText:this.searchParams.sqlText}).then(res=>{
        this.saveLoad=false;
        if(res.statusCode == "-1"){
          this.$Message.error(res.msg);
        }else{
          this.$Message.success("修改过滤条件成功");
        }
      });
    }
  },
  watch: {},
  directives: {}
};
</script>
<style>
</style>

