<template>
 <el-dialog
   :modal="true"
   :close-on-click-modal="false"
   :close-on-press-escape="false"
   destroy-on-close

   title="质检规则详情"
   :model-value="dialogVisible"

   :before-close="handleClose"

 >
   <diy-el-form ref="formRef" v-model:model-form="forms" :span-attrs="{
     span:10
   }" :forms="formConfig"/>
   <template #footer>
     <el-button :icon="SuccessFilled" @click="editQualityCheck">确定</el-button>
     <el-button  :icon="Close" @click="handleClose">取消</el-button>
   </template>
 </el-dialog>
</template>

<script>
import {Close, SuccessFilled} from "@element-plus/icons-vue";
import DiyElForm from "@/components/common/DiyElForm.vue";
import {qualityTypeDialogForm} from "@/data/all-forms";
import {onBeforeMount, ref} from "vue";
import {useRootStore} from "@/stores/useStore";
import {isValid} from "js-base64";
import {getQualityRuleDialogSelect} from "@/service/zsk/base-rule/quality-rule";

export default {
  name: "QualityTypeDetailDialog",
  components: {DiyElForm},
  computed: {
    Close() {
      return Close
    },
    SuccessFilled() {
      return SuccessFilled
    }
  },
  props:{
    dialogVisible:{

    },
    currentDialogObj:{

    },
    dialogOperationType:{

    }
  },
  setup(props,{emit}) {
    const formRef =ref(null)
    onBeforeMount(() => {
       if (props.dialogOperationType!== 'add'){
         forms.value ={...props.currentDialogObj}
       }

    })
    function editQualityCheck() {
      formRef.value.refEl.validate(isValid =>{
        if(isValid){
          emit('editQualityCheck',forms.value)
        }
      })
    }
    const forms = ref({

    })
    const formConfig = ref({...qualityTypeDialogForm()})
    function handleClose() {
      emit('update:dialogVisible',false)
    }
    return {
      handleClose,
      forms,
      formConfig,
      editQualityCheck,
      formRef
    }
  }
}
</script>

<style scoped lang="scss">

</style>
