<template>
  <div>
    <el-button size="mini" type="text" @click="onShow(dialogFormVisible = true)">{{$t(`编辑`)}}</el-button>
    <el-drawer
        :title="$t(`编辑优势劣势`)"
        :visible.sync="dialogFormVisible"
        size="600px"
        direction="rtl"
        :show-close="false"
        append-to-body
        @close="onCancel">
      <div class="drawer__panel">
        <el-row :gutter="20">
          <el-form :model="form"   ref="form"  size="mini" label-position="right" :label-width="tool.onlyZh('75px')">
            <el-col :span="24">
              <el-form-item :label="$t(`优势信息`)+':'" >
                <el-input type="textarea" rows="5" v-model="form.advantage" :placeholder="$t(`请输入优势信息`)"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t(`劣势信息`)+':'" >
                <el-input type="textarea" rows="5" v-model="form.inferiority" :placeholder="$t(`请输入劣势信息`)"></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div class="fixed__btn__panel">
        <el-button size="small" @click="onCancel" class="normal-btn-width inline-16">{{$t('取 消')}}</el-button>
        <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">{{$t('确 定')}}</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
export default {
  name: "edit",
  props:['data'],
  data(){
    return {
      dialogFormVisible:false,
      form:{
        "sa_competitorid": this.$route.query.id,
        "sa_competitor_advid": 0,
        "inferiority": "",
        "advantage": "",
        "isdefault": 1
      }
    }
  },
  methods:{
    onShow(){
      this.form = Object.assign({}, this.form, this.data)
    },
    async onSubmit(){
      const res = await this.$api.requested({
        "content": this.form,
        "id": 2025031809205102,
      })
      this.tool.showMessage(res,()=>{
        this.onCancel()
      })
    },
    onCancel(){
      this.dialogFormVisible = false
      this.form.inferiority = ''
      this.form.advantage = ''
      this.$emit('editSuccess')
    }
  }
}
</script>

<style scoped>

</style>
