<template>
    <div class="examination">
      <el-dialog @close="closeDialog" :visible.sync="dialogTableVisible">
        <div slot="title" class="titleBox">
         <i class="el-icon-document" style="font-size: 18px"></i>
        <span style="font-size:16px">公式编辑</span>
        </div>
        <div class="div-button">
            <button @click="add">+</button>
            <button @click="minus">-</button>
            <button @click="multiple">×</button>
            <button @click="division">÷</button>
            <button @click="leftBracket">(</button>
            <button @click="rightBracket">)</button>
        </div>
        <el-input type="textarea" v-model="reviseFormula" :rows="5"></el-input>
        <span slot="footer" class="dialog-footer">
        <el-button type="goon" size="mini" icon="el-icon-check" @click="modifyData">确定</el-button>
        <el-button size="mini" type="goon" icon="el-icon-remove-outline" @click="cancel">取消</el-button>
        </span>
     </el-dialog>
    </div>
</template>
<script>
import {
  getCookie
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js';
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
    props: ['showFlag2', 'Params2'],
    data () {
        return {
            dialogTableVisible: false,
            inputData: {},
            reviseFormula: ''
        }
    },
    methods: {
      cancel () {
        let _this = this;
        _this.inputData = []
        _this.dialogTableVisible = false
        _this.$emit('refresh')
      },
      closeDialog () {
       let _this = this;
       _this.inputData = {};
       _this.$emit('refresh')
     },
     add () {
       this.reviseFormula = this.reviseFormula + '+'
     },
     minus () {
       this.reviseFormula = this.reviseFormula + '-'
     },
     multiple () {
       this.reviseFormula = this.reviseFormula + '×'
     },
     division () {
       this.reviseFormula = this.reviseFormula + '÷'
     },
     leftBracket () {
       this.reviseFormula = this.reviseFormula + '('
     },
     rightBracket () {
       this.reviseFormula = this.reviseFormula + ')'
     },
     modifyData () {
        let _this = this;
        _this.dialogTableVisible = false;
        _this.inputData.reviseFormula = _this.reviseFormula;
        _this.inputData.updateMan = userName;
        _this.inputData.updateNo = userId
        _this.axios.put('pass/baseManagement/v1/limsbasereviserules/', _this.inputData, {individualType: 'json'}).then(res => {
           if (res.succeed) {
            this.$message.success('公式修改成功')
            _this.$emit('refresh')
           } else {
            this.$message.error(res.message)
           }
           }).catch(e => {
            this.$message.error(e.message)
          })
     }
    },
    watch: {
      showFlag2 (arg) {
        let _this = this;
        _this.dialogTableVisible = true;
        _this.inputData = _this.Params2;
        _this.reviseFormula = _this.inputData.reviseFormula;
      }
    }
}
</script>
<style lang="less" scoped>
.div-button {
    height: 40px;
    padding-left: 25px;
    box-shadow: 1px 1px 1px rgb(226, 226, 226);
    margin-bottom: 10px;
}
.div-button button {
    width: 30px;
    height: 30px;
    cursor: pointer;
    background-color: #fff;
    border: 1px solid rgb(100, 100, 100);
    color: rgb(100, 100, 100);
    border-radius: 3px;
    font-size: 20px;
    margin-right:10px;
}
</style>
