<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="formDialogRef" class="form" :forms="formConfig" v-model:model-form="form">

    </diy-el-form>
    <template  v-if="dialogOperationType != 'detail'" #footer>
      <el-button :icon="SuccessFilled" @click="conform">确定</el-button>
      <el-button @click="handleClose" :icon="Close">取消</el-button>
    </template>
  </el-dialog>
</template>

<script>
import {Close, Delete, Edit, Plus, SuccessFilled} from "@element-plus/icons-vue";
import DiyElForm from "@/components/common/DiyElForm.vue";
import {computed, onBeforeMount, ref} from "vue";
import {
  proInsertXyxxSqd, proUpdateXyxxSqd
} from "@/service/credit-information/commission-three-inventory-information-manage/commission-three-inventory-information-manage";
import {handleMes} from "@/units/element-ui/tip";
import {commissionThreeInventoryInformationManageDetailBBMJCQD} from "@/data/all-form";
import {InsertSyslog} from "@/units/use-method/user-log";
export default {
  name: "CommissionThreeInventoryInformationManageBBMCJCSSetting",
  components:{DiyElForm},
  computed: {
    Delete() {
      return Delete
    },
    Edit() {
      return Edit
    },
    Plus() {
      return Plus
    },
    SuccessFilled() {
      return SuccessFilled
    },
    Close() {
      return Close
    }
  },
  props:{
    dialogVisible:{  //是否可见

    },
    dialogOperationType:{   //操作类型

    },
    currentDialogObj:{   //当前选中信息

    },
  },
  setup(props,{emit}){
    const form = ref({});  //表单内容-值
    const formConfig = ref({...commissionThreeInventoryInformationManageDetailBBMJCQD});
    const formDialogRef =ref(null);  //表单ref
    function conform(){
      formDialogRef.value.refEl.validate(commit);
    }
    function commit(){
      if(form.value.ID){  //修改
        proUpdateXyxxSqd({
          ID: form.value.ID,
          CONDITIONZERO: "4",
          CONDITIONONE: form.value.DWMC,
          CONDITIONTWO: form.value.BZBM,
          CONDITIONTHREE: form.value.YYSX,
          CONDITIONFOUR: form.value.XYGLDX,
          CONDITIONFIVE: form.value.XYGLCS,
          CONDITIONSIX: form.value.LYBM,
          CONDITIONSEVEN: form.value.ZDYJ,
          CONDITIONEIGHT: form.value.ZDLYBM==undefined?'':form.value.ZDLYBM,
          CONDITIONNINE: form.value.BBH
        }).then(res =>{
          handleMes(res,() => {
            handleClose();
            InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息修改", "三清单修改成功", "委三清单信息管理", "")
            emit('getTableData')
          })
        })
      }else{  //新增
        proInsertXyxxSqd({
          CONDITIONZERO: "4",
          CONDITIONONE: form.value.DWMC,
          CONDITIONTWO: form.value.BZBM,
          CONDITIONTHREE: form.value.YYSX,
          CONDITIONFOUR: form.value.XYGLDX,
          CONDITIONFIVE: form.value.LYBM,
          CONDITIONSIX: form.value.BBH,
          CONDITIONSEVEN: form.value.XYGLCS,
          CONDITIONEIGHT: form.value.ZDYJ,
          CONDITIONNINE: form.value.ZDLYBM==undefined?'':form.value.ZDLYBM,
        }).then(res =>{
          handleMes(res,() => {
            handleClose();
            InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息新增", "三清单新增成功", "委三清单信息管理", "")
            emit('getTableData')
          })
        })
      }
    }
    function handleClose(){
      emit('update:dialogVisible',false);
    }
    onBeforeMount(()=>{
      formConfig.value.formAttrs.disabled=props.dialogOperationType === 'detail';
      form.value = {
        ...props.currentDialogObj
      }
    })
    return {
      form,
      formDialogRef,
      formConfig,
      conform,
      handleClose,
    }
  }
}
</script>

<style scoped>

</style>