<template>
  <div>
    <div class="my-title">处理</div>
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="130px"
    >
      <el-row>
        <el-col :span="8">
          <el-form-item label="处理分析人" prop="analyseId">
            <UserComponent v-model="dataForm.analyseId" :user-id.sync="dataForm.analyseId"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="处置措施人" prop="measureId">
            <UserComponent v-model="dataForm.measureId" :user-id.sync="dataForm.measureId"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
           <el-form-item label="处理分析" prop="disposeAnalyse">
            <el-input v-model="dataForm.disposeAnalyse" placeholder="请输入处理分析" type="textarea"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
           <el-form-item label="处置措施" prop="disposeMeasure">
            <el-input v-model="dataForm.disposeMeasure" placeholder="请输入处置措施" type="textarea"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="返工数量" prop="reworkCnt">
            <el-input-number v-model="dataForm.reworkCnt" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="返修数量" prop="repairCnt">
            <el-input-number v-model="dataForm.repairCnt" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="不合格/报损数量" prop="damageCnt">
            <el-input-number v-model="dataForm.damageCnt" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="让步接收数量" prop="concessionCnt">
            <el-input-number v-model="dataForm.concessionCnt" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="顾客放行表">
            <upload-component :accept="'*'" v-model="dataForm.releaseList" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="附件">
            <upload-component :accept="'*'" v-model="dataForm.attachList" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="onChose">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
    </span>
  </div>
</template>

<script>
import UserComponent from '../common/user-component'
import UploadComponent from '../common/upload-component-v2'
export default {
  name: 'quality-disqualification-dispose',
  components: {UploadComponent, UserComponent},
  data () {
    return {
      dataForm: {},
      dataRule: {
        analyseId: [{required: true, message: '请选择处理分析人', trigger: 'change'}],
        measureId: [{required: true, message: '请选择处置措施人', trigger: 'change'}],
        disposeAnalyse: [{required: true, message: '请输入处理分析', trigger: 'blur'}],
        disposeMeasure: [{required: true, message: '请输入处置措施', trigger: 'blur'}]
      }
    }
  },
  mounted () {},
  methods: {
    init (item) {
      this.dataForm = { ...item }
    },
    onChose () {
      this.$emit('onChose')
    },
    dataFormSubmit () {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl(`/biz-service/disqualification/updateDispose`),
            method: 'post',
            data: this.$http.adornData({ ...this.dataForm, orgId: this.orgId })
          }).then(({ data }) => {
            if (data && data.code === '200') {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.onChose()
                  this.$emit('refreshDataList')
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>