<template>
  <div class="edit">
    <el-button type="text" size="small" @click="editBtn">编辑</el-button>
    <el-dialog
      title="编辑"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
      append-to-body>
      <div class="info">
        <el-form :model="currentData" ref="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
        <el-form-item label="基本目标" prop="target_l">
          <el-input v-model="currentData.target_l" size="small"></el-input>
        </el-form-item>
        <el-form-item label="挑战目标" prop="target_h">
          <el-input v-model="currentData.target_h" size="small"></el-input>
        </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="bottom">
          <el-button @click="dialogVisible = false" size="small">取 消</el-button>
          <el-button type="primary" @click="submit" size="small">确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      dialogVisible:false,
      currentData: {
        target_l:'',
        target_h:'',
        sa_salestargetid:''
      },
      rules:{
        target_l:[
          { required: true, message: '请填写基本目标', trigger: 'blur' }
        ],
        target_h:[
          { required: true, message: '请填写挑战目标', trigger: 'blur' }
        ]
      }
    };
  },
  props:['editData'],
  computed:{
  },
  watch:{
  },
  methods: {
    handleClose() {
      this.dialogVisible = false
    },
    editBtn() {
      this.dialogVisible = true
      this.currentData = {
        target_l:this.editData.data.target_l,
        target_h:this.editData.data.target_h,
        sa_salestargetid:this.editData.data.sa_salestargetid
      }
    },
    async submit() {
      let res = await this.$api.requested({
        "id": 20220906112602,
        "content": this.currentData,
      })
      console.log(res);
      this.tool.showMessage(res,() => {
        this.$emit('editSuccess')
        this.dialogVisible = false
      })
    }
  },
};
</script>

<style scoped>

</style>
