<template>
  <div style="margin-bottom:16px">
    <el-button size="mini" type="primary" @click="addBtn">新 建</el-button>
    <el-dialog title="新 建" append-to-body :visible.sync="dialogFormVisible" width="500px">
      <div slot="title" style="font-size: 15px">
        新增明细
      </div>
      <el-row :gutter="20">
        <el-form :model="form" :rules="rules" ref="form" label-width="90px" label-position="right" size="mini">
          <el-col :span="24">
            <el-form-item label="新增标签" prop="tag">
              <el-input v-model="form.tag" placeholder="请输入标签名"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { log } from '@antv/g2plot/lib/utils'
export default {
  name: "add",
  props:['data'],
  data(){
    return {
      dialogFormVisible:false,
      currentData:'',
      form:{
        tag:'',
        sys_systemtagid:0,
      },
      rules:{
        tag:[
          { required: true, message: '请输入标签名', trigger: 'blur'},
        ],
      }
    }
  },
  methods:{
    addBtn () {
      this.dialogFormVisible = true
      this.currentData = this.data
    },
    onSubmit(){
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        this.form.sys_systemtagid = this.currentData.sys_systemtagid
        const res = await this.$api.requested({
          "id": "20221013104501",
          "version":1,
          "content": this.form
        })
        this.tool.showMessage(res,()=>{
          this.$emit('onSuccess')
          this.$refs['form'].resetFields();
          this.dialogFormVisible = false
        })
      })
    }
  }
}
</script>

<style scoped>

</style>