<template>
  <el-dialog title="处理" append-to-body :modelValue="openShow" width="35%" @close="closeDialog">
    <el-form
      ref="form"
      :model="formData"
      :rules="rules"
      label-width="80px"
      class="vd-form-row"
    >
      <el-row>
        <el-col :span="24">
          <el-form-item label="审理单号" prop="rsCode">
            <el-input v-model="formData.rsCode" type="text" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="处理意见" prop="handleResult">
            <el-input v-model="formData.handleResult" type="textarea" :rows="3" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- <el-form v-else ref="form" :model="formData" label-width="80px" class="vd-form-row">
      <el-row>
        <el-col :span="24">
          <el-form-item label="处理意见" prop="handleResult">
            <el-input v-model="formData.handleResult" type="textarea" :rows="3" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form> -->

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script>
import { taskComplete } from '@/api/productionManagement/WIPChange.js';

export default {
  props: {
    showDialog: {
      type: Boolean,
      default: false,
    },
    rowItem: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      openShow: false,
      formData: {},
      rules: {
        rsCode: [{ required: true }],
        handleResult: [{ required: true }],
      },
    };
  },
  mounted() {
    this.openShow = this.showDialog;
  },
  methods: {
    closeDialog() {
      this.openShow = false;
      this.$emit('closeDialog');
    },
    submit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          let query = {
            ddtIdList:[this.rowItem.ddtId], //调度任务ID
            rsCode: this.formData.rsCode, //审理单号
            handleResult: this.formData.handleResult, //处理结果
            loginUser: '', //登录用户
            isDefault: '',
            partCode: this.rowItem.partCode, //物料号
            partName: this.rowItem.partName, //物料名称
            plate: this.rowItem.plate, //镀种
            version: this.rowItem.version, //版本
            changeNo: this.rowItem.changeNo, //更改单号
            disAssignMan: this.rowItem.disAssignMan, //调度员
          };
          taskComplete(query).then(res => {
            this.$message.success('处理成功');
            this.closeDialog();
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped></style>
