<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 {commissionThreeInventoryInformationManageDetailXWQD} from "@/data/all-form";
export default {
  name: "CommissionThreeInventoryInformationManageXWQDSettingDialog",
  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({...commissionThreeInventoryInformationManageDetailXWQD});
    const formDialogRef =ref(null);  //表单ref
    function conform(){
      formDialogRef.value.refEl.validate(commit);
    }
    function commit(){
      debugger
      if(form.value.ID){  //修改
        proUpdateXyxxSqd({
          ID: form.value.ID,
          CONDITIONZERO: "2",
          CONDITIONONE: form.value.DWLB,
          CONDITIONTWO: form.value.TGDW,
          CONDITIONTHREE: form.value.BMMC,
          CONDITIONFOUR: form.value.XWSX,
          CONDITIONFIVE: form.value.XWFL,
          CONDITIONSIX: form.value.CDFJ,
          CONDITIONSEVEN: form.value.CLJG,
          CONDITIONEIGHT: form.value.XXSX,
          CONDITIONNINE: form.value.XDR,
          CONDITIONTEN: form.value.BBH
        }).then(res =>{
          handleMes(res,() => {
            handleClose();
            emit('getTableData')
          })
        })
      }else{  //新增
        proInsertXyxxSqd({
          CONDITIONZERO: "2",
          CONDITIONONE: form.value.DWLB,
          CONDITIONTWO: form.value.TGDW,
          CONDITIONTHREE: form.value.BMMC,
          CONDITIONFOUR: form.value.XWSX,
          CONDITIONFIVE: form.value.XWFL,
          CONDITIONSIX: form.value.CDFJ,
          CONDITIONSEVEN: form.value.CLJG,
          CONDITIONEIGHT: form.value.XXSX,
          CONDITIONNINE: form.value.XDR,
          CONDITIONTEN: form.value.BBH
        }).then(res =>{
          handleMes(res,() => {
            handleClose();
            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>