<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 v-model:model-form="forms" :span-attrs="{
     span:10
   }" :forms="formConfig"/>
   <template #footer>
     <el-button :icon="SuccessFilled" @click="$emit('editClearCheck',forms)">确定</el-button>
     <el-button @click="handleClose" :icon="Close">取消</el-button>
   </template>
 </el-dialog>
</template>

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

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

    }, currentDialogObj:{

    },
    dialogOperationType:{

    }

  },
  setup(props,{emit}) {
    const forms = ref({

    })
    onBeforeMount(() => {
      if (props.dialogOperationType!== 'add'){
        forms.value ={...props.currentDialogObj,
          cleaningRuleCode:props.currentDialogObj.CODE,
          cleaningRuleName:props.currentDialogObj.CLEANING_NAME,
          inspRuleUuid :props.currentDialogObj.INSP_RULE_UUID,
          cleaningRuleTodo :props.currentDialogObj.TODO,
        }
      }
      getQualityRuleDialogSelect().then(res => {
        let data =res.msg[0].Rows || []
        let findS = formConfig.value.formItemsArr.find(i => i.modelValue ==='inspRuleUuid')
        findS.options= [{value:'',label:'请选择'}].concat(data.map(i => {
          return {
            value:i.UUID,
            label: i.NAME
          }
        }))
      })
    })
    const formConfig = ref({...clearTypeDialogForm})

    function handleClose() {
      emit('update:dialogVisible',false)
    }
    return {
      handleClose,
      forms,
      formConfig
    }
  }
}
</script>

<style scoped lang="scss">

</style>
