<template>
  <el-dialog title="维护" append-to-body :modelValue="openShow" width="30%" @close="closeDialog">
    <avue-form v-model="obj" :option="option" ref="form"></avue-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>
// dsBatchTask
import { dsBatchTask } from '@/api/processManagement/bathRefineTask.js';
export default {
  props: {
    showDialog: {
      type: Boolean,
      default: false,
    },
    maintainData: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {
      obj: {},
      openShow: false,
      option: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '维护结果',
            prop: 'isQualified',
            span: 24,
            type: 'radio',
            dicData: [
            { label: '合格', value: 0 },
              { label: '不合格', value: 1 },
            ],
            rules: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
          },
          {
            label: '实测值/添加量',
            prop: 'actualValue',
            span: 24,
            labelWidth:120,
            rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          },
        ],
      },
    };
  },
  mounted() {
    this.openShow = this.showDialog;
  },
  methods: {
    submit() {
      this.$refs.form.validate((valid, done, msg) => {
        if (valid) {
          let query_ = {
            ...this.maintainData[0],
            isQualified:this.obj.isQualified,
            auditDescribe:this.obj.auditDescribe
          }
          let ids = this.maintainData.map(item => item.id);
          dsBatchTask([query_]).then(res => {
            this.$message({
              type: 'success',
              message: '操作成功!',
            });
            this.closeDialog();
          });
        }
      });
    },
    closeDialog() {
      this.openShow = false;
      this.$emit('closeDialog');
    },
  },
};
</script>
<style lang="scss" scoped></style>
