<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>
    <div class="my-b-title-sxy">数据项信息</div>
    <diy-el-form ref="formDialogRefSJX" v-bind="{'span-attrs':{span:3}}" class="form" :forms="formConfigSJX" v-model:model-form="formSJX">

    </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 {commissionThreeInventoryInformationManageDetailSJQD,commissionThreeInventoryInformationManageDetailSJQDSJX} from "@/data/all-form";
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 {InsertSyslog} from "@/units/use-method/user-log";
export default {
  name: "CommissionThreeInventoryInformationManageSJQDSettingDialog",
  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 formSJX = ref({});  //表单配置项内容-值
    const formConfig = ref({...commissionThreeInventoryInformationManageDetailSJQD});
    const formConfigSJX = ref({...commissionThreeInventoryInformationManageDetailSJQDSJX});
    const formDialogRef =ref(null);  //表单ref
    const formDialogRefSJX =ref(null);  //表单配置项ref
    function conform(){
      formDialogRef.value.refEl.validate(commit);
    }
    function commit(){
      debugger
      if(form.value.ID){  //修改
        proUpdateXyxxSqd({
          ID:form.value.ID,
          CONDITIONZERO: "1",
          CONDITIONONE: form.value.BMLX,
          CONDITIONTWO: form.value.DWMC,
          CONDITIONTHREE: form.value.SGSS,
          CONDITIONFOUR: form.value.SXLB,
          CONDITIONFIVE: form.value.XXSX,
          CONDITIONSIX: form.value.XDR,
          CONDITIONSEVEN: form.value.GXFW,
          CONDITIONEIGHT: form.value.GKSX,
          CONDITIONNINE: form.value.FGCJ,
          CONDITIONTEN: form.value.TGZQ,
          CONDITIONELEVEN: form.value.TGFS,
          CONDITIONTWELVE: form.value.GXPL,
          CONDITIONTHRITEEN: form.value.BZBM,
          CONDITIONFORTEEN: form.value.BBH,
          CONDITIONFIFTEEN: form.value.YXQX,
          CONDITIONSIXTEEN: formSJX.value.A1,
          CONDITIONSEVETEEN: formSJX.value.A2,
          CONDITIONEIGHTEEN: formSJX.value.A3,
          CONDITIONNINTEEN: formSJX.value.A4,
          CONDITIONTWENTEEN: formSJX.value.A5,
          CONDITIONTWENTEENONE: formSJX.value.A6,
          CONDITIONTWENTEENTWO: formSJX.value.A7,
          CONDITIONTWENTEENTHREE: formSJX.value.A8,
          CONDITIONTWENTEENFOUR: formSJX.value.A9,
          CONDITIONTWENTEENFIVE: formSJX.value.A10,
          CONDITIONTWENTEENSIX: formSJX.value.A11,
          CONDITIONTWENTEENSEVEN: formSJX.value.A12,
          CONDITIONTWENTEENEIGHT: formSJX.value.A13,
          CONDITIONTWENTEENNINE: formSJX.value.A14,
          CONDITIONTHIRTY: formSJX.value.A15,
          CONDITIONTHIRTYONE: formSJX.value.A16,
          CONDITIONTHIRTYTWO: formSJX.value.A17,
          CONDITIONTHIRTYTHREE: formSJX.value.A18,
          CONDITIONTHIRTYFOUR: formSJX.value.A19,
          CONDITIONTHIRTYFIVE: formSJX.value.A20,
          CONDITIONTHIRTYSIX: formSJX.value.A21,
          CONDITIONTHIRTYSEVEN: formSJX.value.A22,
          CONDITIONTHIRTYEIGHT: formSJX.value.A23,
          CONDITIONTHIRTYNINE: formSJX.value.A24,
          CONDITIONFORTY: formSJX.value.A25,
          CONDITIONFORTYONE: formSJX.value.A26,
          CONDITIONFORTYTWO: formSJX.value.A27,
          CONDITIONFORTYTHREE: formSJX.value.A28,
          CONDITIONFORTYFOUR: formSJX.value.A29,
          CONDITIONFORTYFIVE: formSJX.value.A30
        }).then(res =>{
          handleMes(res,() => {
            handleClose();
            InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息修改", "三清单修改成功", "委三清单信息管理", "")
            emit('getTableData')
          })
        })
      }else{  //新增
        proInsertXyxxSqd({
          CONDITIONZERO: "1",
          CONDITIONONE: form.value.BMLX,
          CONDITIONTWO: form.value.DWMC,
          CONDITIONTHREE: form.value.SGSS,
          CONDITIONFOUR: form.value.SXLB,
          CONDITIONFIVE: form.value.XXSX,
          CONDITIONSIX: form.value.XDR,
          CONDITIONSEVEN: form.value.GXFW,
          CONDITIONEIGHT: form.value.GKSX,
          CONDITIONNINE: form.value.FGCJ,
          CONDITIONTEN: form.value.TGZQ,
          CONDITIONELEVEN: form.value.TGFS,
          CONDITIONTWELVE: form.value.GXPL,
          CONDITIONTHRITEEN: form.value.BZBM,
          CONDITIONFORTEEN: form.value.BBH,
          CONDITIONFIFTEEN: form.value.YXQX,
          CONDITIONSIXTEEN: formSJX.value.A1,
          CONDITIONSEVETEEN: formSJX.value.A2,
          CONDITIONEIGHTEEN: formSJX.value.A3,
          CONDITIONNINTEEN: formSJX.value.A4,
          CONDITIONTWENTEEN: formSJX.value.A5,
          CONDITIONTWENTEENONE: formSJX.value.A6,
          CONDITIONTWENTEENTWO: formSJX.value.A7,
          CONDITIONTWENTEENTHREE: formSJX.value.A8,
          CONDITIONTWENTEENFOUR: formSJX.value.A9,
          CONDITIONTWENTEENFIVE: formSJX.value.A10,
          CONDITIONTWENTEENSIX: formSJX.value.A11,
          CONDITIONTWENTEENSEVEN: formSJX.value.A12,
          CONDITIONTWENTEENEIGHT: formSJX.value.A13,
          CONDITIONTWENTEENNINE: formSJX.value.A14,
          CONDITIONTHIRTY: formSJX.value.A15,
          CONDITIONTHIRTYONE: formSJX.value.A16,
          CONDITIONTHIRTYTWO: formSJX.value.A17,
          CONDITIONTHIRTYTHREE: formSJX.value.A18,
          CONDITIONTHIRTYFOUR: formSJX.value.A19,
          CONDITIONTHIRTYFIVE: formSJX.value.A20,
          CONDITIONTHIRTYSIX: formSJX.value.A21,
          CONDITIONTHIRTYSEVEN: formSJX.value.A22,
          CONDITIONTHIRTYEIGHT: formSJX.value.A23,
          CONDITIONTHIRTYNINE: formSJX.value.A24,
          CONDITIONFORTY: formSJX.value.A25,
          CONDITIONFORTYONE: formSJX.value.A26,
          CONDITIONFORTYTWO: formSJX.value.A27,
          CONDITIONFORTYTHREE: formSJX.value.A28,
          CONDITIONFORTYFOUR: formSJX.value.A29,
          CONDITIONFORTYFIVE: formSJX.value.A30
        }).then(res =>{
          handleMes(res,() => {
            handleClose();
            InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"), "信息新增", "三清单新增成功", "委三清单信息管理", "")
            emit('getTableData')
          })
        })
      }

    }
    function handleClose(){
      emit('update:dialogVisible',false);
    }
    function getDifferentSJX(){
      debugger
      if(form.value.SGSS == '1' &&form.value.SXLB =='资质类'){
        formSJX.value = {
          A1:"行政相对人名称",
          A2:"行政相对人类别",
          A3:"统一社会信用代码",
          A4:"工商注册号",
          A5:"组织机构代码",
          A6:"税务登记号",
          A7:"事业单位证书号",
          A8:"社会组织登记证号",
          A9:"法定代表人",
          A10:"法定代表人证件类型",
          A11:"法定代表人证件号码",
          A12:"证件类型",
          A13:"证件号码",
          A14:"行政许可决定文书名称",
          A15:"行政许可决定文书号",
          A16:"许可类别",
          A17:"许可证书名称",
          A18:"许可编号",
          A19:"许可内容",
          A20:"许可决定",
          A21:"有效期自",
          A22:"有效期至",
          A23:"许可机关",
          A24:"许可机关统一社会信用代码",
          A25:"当前状态",
          A26:"数据来源单位",
          A27:"数据来源单位统一社会信用代码",
          A28:"备注",
          A29:"",
          A30:"",
        }
      }else if(form.value.SGSS == '1' &&form.value.SXLB =='监管类'){
        formSJX.value = {
          A1:"行政相对人名称",
          A2:"行政相对人类别",
          A3:"统一社会信用代码",
          A4:"工商注册号",
          A5:"组织机构代码",
          A6:"税务登记号",
          A7:"事业单位证书号",
          A8:"社会组织登记证号",
          A9:"法定代表人",
          A10:"法定代表人证件类型",
          A11:"法定代表人证件号码",
          A12:"证件类型",
          A13:"证件号码",
          A14:"行政处罚决定书文号",
          A15:"违法行为类型",
          A16:"违法事实",
          A17:"处罚依据",
          A18:"处罚类别",
          A19:"处罚内容",
          A20:"罚款金额（万元）",
          A21:"没收违法所得、没收非法财物的金额（万元）",
          A22:"暂扣或吊销证照名称及编号",
          A23:"处罚决定日期",
          A24:"处罚有效期",
          A25:"公示截止期",
          A26:"处罚机关",
          A27:"处罚机关统一社会信用代码",
          A28:"数据来源单位",
          A29:"数据来源单位统一社会信用代码",
          A30:"备注"
        }
      }else{
        formSJX.value = {
          A1:"",
          A2:"",
          A3:"",
          A4:"",
          A5:"",
          A6:"",
          A7:"",
          A8:"",
          A9:"",
          A10:"",
          A11:"",
          A12:"",
          A13:"",
          A14:"",
          A15:"",
          A16:"",
          A17:"",
          A18:"",
          A19:"",
          A20:"",
          A21:"",
          A22:"",
          A23:"",
          A24:"",
          A25:"",
          A26:"",
          A27:"",
          A28:"",
          A29:"",
          A30:""
        }
      }
    }
    onBeforeMount(()=>{

      formConfig.value.formAttrs.disabled=props.dialogOperationType === 'detail';
      formConfigSJX.value.formAttrs.disabled=props.dialogOperationType === 'detail';
      const sgssItem = formConfig.value.formItemsArr.find(i => i.modelValue === "SGSS");
      const sxlbItem = formConfig.value.formItemsArr.find(i => i.modelValue === "SXLB");
      sgssItem.events = {
        'change'(val){
          getDifferentSJX()
        }
      }
      sxlbItem.events = {
        'change'(val){
          getDifferentSJX()
        }
      }
      debugger
      form.value = {
        ...props.currentDialogObj
      }
      formSJX.value = {
        ...props.currentDialogObj
      }
    })
    return {
      form,
      formSJX,
      formDialogRef,
      formDialogRefSJX,
      formConfig,
      formConfigSJX,
      conform,
      handleClose,
    }
  }
}
</script>

<style scoped lang="scss">
.my-b-title-sxy{
  padding: 10px 15px;
  margin-bottom: 20px;
  font-weight: 600;
  line-height: 40px;
  font-size: 15px;
  border-bottom: 1px solid var(--el-border-color-light);
}
</style>