<!--
 * @Descripttion: sql 详情
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2020-11-10 13:46:26
 * @LastEditors: 无尘
 * @LastEditTime: 2020-11-11 17:01:35
-->
<!--
<sql-detail :sql-row="sqlRow"></sql-detail>
import sqlDetail from '@/components/sql/sql-detail.vue';
-->
<template>
  <el-dialog title="SQL 详情" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
    <div class="">
      <el-form :model="ruleForm"  ref="ruleForm" label-width="10px" class="demo-ruleForm" @submit.native.prevent>
        <el-form-item label="项目名称" prop="">
          {{ruleForm.sqlCheckProjectName || '--'}}
        </el-form-item>
        <el-form-item label="表名称" prop="">
          {{ruleForm.sqlCheckTableName || '--'}}
        </el-form-item>
        <el-form-item label="SQL" prop="">
          <el-input class="w-440" readonly type="textarea" rows="3" v-model="ruleForm.sqlCheckSql" maxlength="500" show-word-limit></el-input>
        </el-form-item>
         <el-form-item label="完善状态" prop="">
          {{ruleForm.sqlCheckIndexType ? '已完善':'未完善'}}
        </el-form-item>
        <el-form-item label="上线状态" prop="">
          {{ruleForm.statusFlag ? '已上线':'未上线'}}
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'SqlDetail',
  components: {},
  props: {
    sqlRow: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      dialogVisible: true,
      loadBtn: false,
      ruleForm: {
        sqlCheckSqlId: '',
        sqlCheckSql: '',
        sqlCheckProjectName: '',
        sqlCheckTableName: '',
        sqlCheckIndexType: '',
        statusFlag: ''
      }
    };
  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    const that = this;
    if (Object.keys(that.sqlRow).length) {
      that.ruleForm = JSON.parse(JSON.stringify(that.sqlRow));
    }
  },
  // methods
  methods: {
    /**
     * @description: 关闭弹窗
     * @author: 无尘
     */
    handleClose() {
      const that = this;
      that.$emit('closeDetail');
      that.$refs['ruleForm'].resetFields();
    },

  },
  watch: {
    sqlRow(newData) {
      const that = this;
      if (Object.keys(newData).length) {
        that.ruleForm = JSON.parse(JSON.stringify(newData));
      }
    }
  }
};
</script>
<style lang='less' scoped>


</style>
