<template>
  <div>
    <el-button size="mini" type="text" @click="editBtn">编 辑</el-button>
    <el-drawer title="新 建" append-to-body :show-close="false" :visible.sync="dialogFormVisible" size="600px">
      <div slot="title" style="font-size: 15px">
        编辑工序节点
      </div>
      <div class="drawer__panel">
        <el-row :gutter="20">
          <el-form :model="form" :rules="rules" ref="form" label-width="140px" label-position="right" size="mini">
            <el-col :span="24">
              <el-form-item label="操作说明:" prop="remarks">
                <el-input type="textarea" v-model="form.remarks" placeholder="请输入操作说明"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24" v-if="data.textedit == 1 || data.textedit == 11">
              <el-form-item label="文本内容" prop="textcontent">
                <el-input type="textarea" v-model="form.textcontent" placeholder="请输入文本内容"></el-input>
              </el-form-item> 
            </el-col>
             <el-col :span="12" v-if="form.confirm">
              <el-form-item label="是否确认" prop="isconfirm">
                <el-radio-group v-model="form.isconfirm">
                  <el-radio :label="1">是</el-radio>
                  <el-radio :label="0">否</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="form.isconfirm">
              <el-form-item label="确认值:" prop="confirm_value">
                <el-input v-model="form.confirm_value" placeholder="请输入确认值"></el-input>
              </el-form-item>
            </el-col>
             <el-col :span="24">
              <el-form-item label="异常属实" prop="isfact">
             
              </el-form-item>
            </el-col>
             <el-col :span="24">
              <el-form-item label="异常属实" prop="isfact">
            
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div class="fixed__btn__panel">
        <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-drawer>
  </div>
</template>

<script>
import { log } from '@antv/g2plot/lib/utils'
export default {
  name: "add",
  props:['data'],
  components:{},
  data(){
    return {
      dialogFormVisible:false,
      form:{
        "sa_workorderid":1,
        "sa_workorder_nodeid":22,
        "remarks":"",
        "textcontent":"",
        "confirm_value":"",
        "amount":10,
        "isconfirm":0,
        "team":[],
        "trainers":[{
            "sys_enterpriseid":1,
            "userid":0
        },{
            "sys_enterpriseid":0,
            "userid":101
        }
        ],
        "traintitem":[{
            "itemid":40,
            "qty":10
        }]

      },
      rules:{
        servicetype:[
          { required: true, message: '请选择服务类型', trigger: 'change'},
        ],
        enterprisename:[
          { required: true, message: '请选择经销商', trigger: 'change'}
        ],
        sonum:[
          { required: true, message: '请选择订单', trigger: 'change'},
        ],
      },
      agentParam: {
        "id":20221216145803,
        "content": {

        }
      }
    }
  },
  methods:{
    editBtn () {
      console.log(this.data);
      
      this.dialogFormVisible = true
      this.form = Object.assign({},this.form,this.data)
    },
    onSubmit(){
      console.log(this.form)
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        if (this.form.province) {
          this.form.city = this.form.province[1]
          this.form.county = this.form.province[2]
          this.form.province = this.form.province[0]
        }
        const res = await this.$api.requested({
          "id": "20230206091403",
          "version":1,
          "content": this.form
        })
        this.tool.showMessage(res,()=>{
          this.$emit('onSuccess')
          this.$refs['form'].resetFields();
          this.dialogFormVisible = false
        })
      })
    },
    orderChange (data) {
      console.log(data);
      
      this.form.sa_orderid = data.sa_orderid
      this.form.sonum = data.sonum
      this.$refs.order.visible = false
      console.log(this.form.sonum);
      
    },
  },
  created () {
  }
}
</script>

<style scoped>
.dialog-footer {
  margin-top: 0;
}
.el-select,.el-input,.el-cascader {
  width: 100% !important;
}
</style>