<template>
  <div class="inline-16">
    <el-button v-if="data.status !== '新建' && data.status !== '关闭'" type="primary" size="mini" @click="onShow">修改备注</el-button>
    <el-dialog title="修改备注信息" :visible.sync="dialogFormVisible" append-to-body width="500px">
      <el-form :model="form" size="small">
        <el-form-item label="销售类别" :label-width="formLabelWidth">
          <el-select v-model="form.saletype" size="small" placeholder="请选择">
            <el-option
              style="width:100%"
              v-for="item in saleroptions"
              :key="item.value"
              :label="item.remarks"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单备注" :label-width="formLabelWidth">
          <el-input type="textarea" :autosize="{minRows:4}" v-model="form.remarks" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item v-if="data.type === '标准订单' || data.type === '特殊订单'" label="项目备注" :label-width="formLabelWidth">
          <el-input type="textarea" :autosize="{minRows:4}" v-model="form.projectnote" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false" size="small">取 消</el-button>
        <el-button type="primary" @click="onSubmit()" size="small">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props:['data'],
  data () {
    return {
      formLabelWidth:'80px',
      dialogFormVisible:false,
      saletype:'',
      form:{},
      saleroptions:[]
    }
  },
  methods:{
    onShow () {
      this.form = Object.assign({},this.form,this.data)
      this.dialogFormVisible = true
      this.selectOptions()
    },
    async selectOptions () {
      const res = await this.$store.dispatch('optiontypeselect','saletype')
      this.saleroptions = res.data
    },
    async onSubmit() {
      const res = await this.$api.requested({
        "id": 20230301152702,
        "content": {
          "sa_orderid": this.data.sa_orderid,
          "projectnote": this.form.projectnote,
          "remarks":this.form.remarks,
          "saletype":this.form.saletype
        },

      })
      this.tool.showMessage(res,()=>{
        this.$emit('onSuccess')
        this.dialogFormVisible = false
      })
    },
  }
}

</script>
<style>
</style>