From cf737303392b72255039bd0645c22f34242acd29 Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Thu, 27 Feb 2025 11:39:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8B=E8=BD=BD=E7=8F=AD?= =?UTF-8?q?=E7=BB=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DesignForm/app/index.vue | 961 ++++++++++-------- .../DesignForm/public/expand/org.vue | 141 ++- .../DesignForm/public/form/form.vue | 14 +- .../DesignForm/public/form/formGroup.vue | 3 +- .../DesignForm/tableListPage/index.vue | 908 +++++++++-------- src/views/hr/teams/index.vue | 79 +- .../lowcodepage/appPage/appMenus.vue | 13 +- .../appPage/appPageForm/pageList.vue | 3 +- .../lowcodepage/appPage/appSetUp/setup.vue | 3 +- 9 files changed, 1211 insertions(+), 914 deletions(-) diff --git a/src/components/DesignForm/app/index.vue b/src/components/DesignForm/app/index.vue index 9a42738..6f5fdf8 100644 --- a/src/components/DesignForm/app/index.vue +++ b/src/components/DesignForm/app/index.vue @@ -28,9 +28,9 @@ import { orgDeptUnit, } from "@/api/DesignForm/fieldUnit"; import type { FormInstance, FormRules } from "element-plus"; -import { ElLoading,ElMessage,ElNotification } from 'element-plus' -import html2canvas from 'html2canvas'; -import JSZip, { forEach } from 'jszip'; +import { ElLoading, ElMessage, ElNotification } from "element-plus"; +import html2canvas from "html2canvas"; +import JSZip, { forEach } from "jszip"; import { gainFormPageListCont } from "@/api/DesignForm/requestapi"; import { Picture, InfoFilled, QuestionFilled } from "@element-plus/icons-vue"; import request from "@/utils/request"; @@ -73,8 +73,8 @@ const props = withDefaults( versiontitle?: string; viewPage?: viewPageType; formBasicConfig?: any; - fieldsDetailList?:any; - orgAndManTree?:any; + fieldsDetailList?: any; + orgAndManTree?: any; }>(), { showPage: true, @@ -230,36 +230,35 @@ const resetFields = (formEl: FormInstance | undefined) => { } }; - //20250117 李文轩 二维码表格 -const qrCodesPrintDialogFlag = ref(false) +const qrCodesPrintDialogFlag = ref(false); let tableRefs = reactive({}); -const tablesData = ref({}) -function getDetailQrCodes(val:any) { +const tablesData = ref({}); +function getDetailQrCodes(val: any) { return request({ url: "/javasys/lowCode/QrCode/getDetailQrCodes", method: "post", data: { cfid: props.formId, - idArray:val, - settings:props.formBasicConfig, + idArray: val, + settings: props.formBasicConfig, }, }); } -function modifyFieldsMap4(fieldsMap: any): Array<{ key: string, value: string }> { - let result: Array<{ key: string, value: string }> = []; - // 使用 Object.entries 获取键值对数组,保留原始顺序 - for (const [key, value] of Object.entries(fieldsMap)) { - let parts = value.split("!@#@!"); - if (parts.length === 2) { - result.push({ key: parts[0], value: parts[1] }); - } else { - // 如果格式不符合,可进行错误处理,这里暂时不做处理,直接使用原属性名和属性值 - result.push({ key, value }); - } +function modifyFieldsMap4(fieldsMap: any): Array<{ key: string; value: string }> { + let result: Array<{ key: string; value: string }> = []; + // 使用 Object.entries 获取键值对数组,保留原始顺序 + for (const [key, value] of Object.entries(fieldsMap)) { + let parts = value.split("!@#@!"); + if (parts.length === 2) { + result.push({ key: parts[0], value: parts[1] }); + } else { + // 如果格式不符合,可进行错误处理,这里暂时不做处理,直接使用原属性名和属性值 + result.push({ key, value }); } - return result; + } + return result; } // 定义两个响应式的布尔值来控制按钮的禁用状态 @@ -271,7 +270,7 @@ async function downloadTables() { isButton2Disabled.value = true; const loadingInstance = ElLoading.service({ fullscreen: true, - text: '正在生成图片,请稍候...' // 添加的文字内容,可根据需要修改 + text: "正在生成图片,请稍候...", // 添加的文字内容,可根据需要修改 }); //ElMessage('This is a message.') const zip = new JSZip(); @@ -279,12 +278,12 @@ async function downloadTables() { for (const [tableKey, element] of Object.entries(tableRefs)) { try { const canvas = await html2canvas(element); - const dataUrl = canvas.toDataURL('image/png'); - const byteString = atob(dataUrl.split(',')[1]); - const mimeString = dataUrl.split(',')[0].split(':')[1].split(';')[0]; + const dataUrl = canvas.toDataURL("image/png"); + const byteString = atob(dataUrl.split(",")[1]); + const mimeString = dataUrl.split(",")[0].split(":")[1].split(";")[0]; const ab = new ArrayBuffer(byteString.length); const ia = new Uint8Array(ab); - + for (let i = 0; i < byteString.length; i++) { ia[i] = byteString.charCodeAt(i); } @@ -296,27 +295,35 @@ async function downloadTables() { } } - zip.generateAsync({ type: 'blob' }).then(function(content) { + zip.generateAsync({ type: "blob" }).then(function (content) { const now = new Date(); - const formattedDate = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`; + const formattedDate = `${now.getFullYear()}${String(now.getMonth() + 1).padStart( + 2, + "0" + )}${String(now.getDate()).padStart(2, "0")}_${String(now.getHours()).padStart( + 2, + "0" + )}${String(now.getMinutes()).padStart(2, "0")}${String(now.getSeconds()).padStart( + 2, + "0" + )}`; const fileName = `${props.formBasicConfig.formName}-${formattedDate}.zip`; - - const link = document.createElement('a'); + + const link = document.createElement("a"); link.href = URL.createObjectURL(content); link.download = fileName; - loadingInstance.close() + loadingInstance.close(); link.click(); - tableRefs = {} + tableRefs = {}; // 不管成功与否,最后都要恢复按钮的状态 isButton1Disabled.value = false; isButton2Disabled.value = false; }); } -function closeQrDownload(){ - qrCodesPrintDialogFlag.value = false - tableRefs = {} +function closeQrDownload() { + qrCodesPrintDialogFlag.value = false; + tableRefs = {}; //console.log(tableRefs) - } let asfs: any[] = []; @@ -325,116 +332,136 @@ let checkboxs: any[] = []; let switchs: any[] = []; let selects: any[] = []; let tables: any[] = []; -let dofs: any[] = [];//deptOrgAndOrgCententAndFounderArr +let dofs: any[] = []; //deptOrgAndOrgCententAndFounderArr function getAsfs() { //setTimeout(() => { - let dataList = ref({}); - dataList.value = props.fieldsDetailList - if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { - for (let i = 0; i < dataList.value.length; i++) { - if (dataList.value[i].type == "associatedForms") { - asfs.push(dataList.value[i]); - }else if(dataList.value[i].type == "radio"){ - radios.push(dataList.value[i]) - } else if(dataList.value[i].type == "checkbox"){ - checkboxs.push(dataList.value[i]) - } else if(dataList.value[i].type == "switch"){ - switchs.push(dataList.value[i]) - } else if(dataList.value[i].type == "select"){ - selects.push(dataList.value[i]) - } else if(dataList.value[i].type == "deptOrg"||dataList.value[i].type == "orgCentent"||dataList.value[i].type == "founder"){//||dataList.value[i].type == "owner"拥有者,"expand-user"选择用户 - dofs.push(dataList.value[i]) - }else if ( - dataList.value[i].type == "card" || - dataList.value[i].type == "flex" || - dataList.value[i].type == "div" || - dataList.value[i].type == "table" - ) { - if (dataList.value[i].type == "table") { - tables.push(dataList.value[i]); - } + let dataList = ref({}); + dataList.value = props.fieldsDetailList; + if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { + for (let i = 0; i < dataList.value.length; i++) { + if (dataList.value[i].type == "associatedForms") { + asfs.push(dataList.value[i]); + } else if (dataList.value[i].type == "radio") { + radios.push(dataList.value[i]); + } else if (dataList.value[i].type == "checkbox") { + checkboxs.push(dataList.value[i]); + } else if (dataList.value[i].type == "switch") { + switchs.push(dataList.value[i]); + } else if (dataList.value[i].type == "select") { + selects.push(dataList.value[i]); + } else if ( + dataList.value[i].type == "deptOrg" || + dataList.value[i].type == "orgCentent" || + dataList.value[i].type == "founder" + ) { + //||dataList.value[i].type == "owner"拥有者,"expand-user"选择用户 + dofs.push(dataList.value[i]); + } else if ( + dataList.value[i].type == "card" || + dataList.value[i].type == "flex" || + dataList.value[i].type == "div" || + dataList.value[i].type == "table" + ) { + if (dataList.value[i].type == "table") { + tables.push(dataList.value[i]); + } - dataList.value[i].list.forEach((element: any) => { - if (element.type == "associatedForms") { - asfs.push(element); - }else if(element.type == "radio"){ - radios.push(element) - }else if(element.type == "checkbox"){ - checkboxs.push(element) - }else if(element.type == "switch"){ - switchs.push(element) - }else if(element.type == "select"){ - selects.push(element) - }else if(element.type == "deptOrg"||element.type == "orgCentent"||element.type == "founder"){ - dofs.push(element) - } - }); - } else if (dataList.value[i].type == "grid") { - let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); - - if (columns.length > 0) { - for (let z = 0; z < columns.length; z++) { - for (let x = 0; x < columns[z].list.length; x++) { - let a = JSON.parse(JSON.stringify(columns[z].list[x])); - - if (a.type == "associatedForms") { - asfs.push(a); - }else if(a.type == "radio"){ - radios.push(a) - }else if(a.type == "checkbox"){ - checkboxs.push(a) - }else if(a.type == "switch"){ - switchs.push(a) - }else if(a.type == "select"){ - selects.push(a) - }else if(a.type == "deptOrg"||a.type == "orgCentent"||a.type == "founder"){ - dofs.push(a) - } + dataList.value[i].list.forEach((element: any) => { + if (element.type == "associatedForms") { + asfs.push(element); + } else if (element.type == "radio") { + radios.push(element); + } else if (element.type == "checkbox") { + checkboxs.push(element); + } else if (element.type == "switch") { + switchs.push(element); + } else if (element.type == "select") { + selects.push(element); + } else if ( + element.type == "deptOrg" || + element.type == "orgCentent" || + element.type == "founder" + ) { + dofs.push(element); + } + }); + } else if (dataList.value[i].type == "grid") { + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } else if (a.type == "radio") { + radios.push(a); + } else if (a.type == "checkbox") { + checkboxs.push(a); + } else if (a.type == "switch") { + switchs.push(a); + } else if (a.type == "select") { + selects.push(a); + } else if ( + a.type == "deptOrg" || + a.type == "orgCentent" || + a.type == "founder" + ) { + dofs.push(a); } } } - } else if (dataList.value[i].type == "tabs") { - //tabs标签页有可能再嵌套一层flex或者table - let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); - if (columns.length > 0) { - for (let z = 0; z < columns.length; z++) { - for (let x = 0; x < columns[z].list.length; x++) { - let a = JSON.parse(JSON.stringify(columns[z].list[x])); - - if (a.type == "associatedForms") { - asfs.push(a); - }else if(a.type == "radio"){ - radios.push(a) - }else if(a.type == "checkbox"){ - checkboxs.push(a) - }else if(a.type == "switch"){ - switchs.push(a) - }else if(a.type == "select"){ - selects.push(a) - }else if(a.type == "deptOrg"||a.type == "orgCentent"||a.type == "founder"){ - dofs.push(a) - }else if (a.type == "flex" || a.type == "table") { - if (a.type == "table") { - tables.push(dataList.value[i]); - } + } + } else if (dataList.value[i].type == "tabs") { + //tabs标签页有可能再嵌套一层flex或者table + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } else if (a.type == "radio") { + radios.push(a); + } else if (a.type == "checkbox") { + checkboxs.push(a); + } else if (a.type == "switch") { + switchs.push(a); + } else if (a.type == "select") { + selects.push(a); + } else if ( + a.type == "deptOrg" || + a.type == "orgCentent" || + a.type == "founder" + ) { + dofs.push(a); + } else if (a.type == "flex" || a.type == "table") { + if (a.type == "table") { + tables.push(dataList.value[i]); + } - if (a.list.length > 0) { - for (let m = 0; m < a.list.length; m++) { - let q = JSON.parse(JSON.stringify(a.list[m])); - - if (q.type == "associatedForms") { - asfs.push(q); - }else if(q.type == "radio"){ - radios.push(q) - }else if(q.type == "checkbox"){ - checkboxs.push(q) - }else if(q.type == "switch"){ - switchs.push(q) - }else if(q.type == "select"){ - selects.push(q) - }else if(q.type == "deptOrg"||q.type == "orgCentent"||q.type == "founder"){ - dofs.push(q) - } + if (a.list.length > 0) { + for (let m = 0; m < a.list.length; m++) { + let q = JSON.parse(JSON.stringify(a.list[m])); + + if (q.type == "associatedForms") { + asfs.push(q); + } else if (q.type == "radio") { + radios.push(q); + } else if (q.type == "checkbox") { + checkboxs.push(q); + } else if (q.type == "switch") { + switchs.push(q); + } else if (q.type == "select") { + selects.push(q); + } else if ( + q.type == "deptOrg" || + q.type == "orgCentent" || + q.type == "founder" + ) { + dofs.push(q); } } } @@ -444,37 +471,37 @@ function getAsfs() { } } } + } //}, 500); } - function convertStringToArray(str: string) { - if (typeof str!== 'string') { - throw new Error('Input must be a string.'); - } - if (str === '') { - return []; - } - // 去除首尾的中括号 - str = str.slice(1, -1); - if (str === '') { - return []; - } - let parts = str.split(','); - return parts.map(part => parseFloat(part)); + if (typeof str !== "string") { + throw new Error("Input must be a string."); + } + if (str === "") { + return []; + } + // 去除首尾的中括号 + str = str.slice(1, -1); + if (str === "") { + return []; + } + let parts = str.split(","); + return parts.map((part) => parseFloat(part)); } interface Tree { - id?: string; - label: string; - disabled?: boolean; - children?: Tree[]; - parentId?: string; - [key: string]: any; + id?: string; + label: string; + disabled?: boolean; + children?: Tree[]; + parentId?: string; + [key: string]: any; } function getLabelById(id: string): string | undefined { //console.log(id) const treeNodes = props.orgAndManTree; - + const findLabel = (nodes: Tree[]): string | undefined => { for (const node of nodes) { // 检查当前节点是否匹配目标id @@ -493,12 +520,8 @@ function getLabelById(id: string): string | undefined { return findLabel(treeNodes); } - - //liwenxuan 20250120 二维码 end - - /** @ 作者: 秦东 @ 时间: 2024-04-01 11:36:07 @@ -510,216 +533,256 @@ const setUpClick = (val: string, id: string) => { if (val.key == "newAdd") { drawerWith.value = container.value?.clientWidth; openTaskDrawer.value = true; - } else if(val.key == "showQrCode"){ - - + } else if (val.key == "showQrCode") { //liwenxuan 20250114 二维码打印弹窗 start //在此组装参数,以生成二维码图片 - let idArray = state.selectionChecked.map(item => item.id); - if(idArray.length>0){ - + let idArray = state.selectionChecked.map((item) => item.id); + if (idArray.length > 0) { //console.log(props.formBasicConfig) - if(props.formBasicConfig.qrCodeFlag==true){ - if(props.formBasicConfig.qrCodeInside==true){ - if(props.formBasicConfig.qrCodePrintStyle&&props.formBasicConfig.qrCodePrintStyle=="2"&&props.formBasicConfig.qrCodeShowFields.length==0){ - alert("未配置表格展示字段") - return + if (props.formBasicConfig.qrCodeFlag == true) { + if (props.formBasicConfig.qrCodeInside == true) { + if ( + props.formBasicConfig.qrCodePrintStyle && + props.formBasicConfig.qrCodePrintStyle == "2" && + props.formBasicConfig.qrCodeShowFields.length == 0 + ) { + alert("未配置表格展示字段"); + return; } const loadingInstance1 = ElLoading.service({ fullscreen: true, - text: '正在生成二维码,请稍候...' // 添加的文字内容,可根据需要修改 + text: "正在生成二维码,请稍候...", // 添加的文字内容,可根据需要修改 }); //请求数据 - let getDetailQrCodesData: any = {} - let currentFieldsMapArrObj: any = {} - getDetailQrCodes(idArray).then(({ data }) => { - getDetailQrCodesData = JSON.parse(JSON.stringify(data)); - if(props.formBasicConfig.qrCodePrintStyle&&props.formBasicConfig.qrCodePrintStyle=="2"){ - let asfQueryParams1: any[] = []; - for (let key in getDetailQrCodesData) { - currentFieldsMapArrObj[key] = getDetailQrCodesData[key] - if (getDetailQrCodesData.hasOwnProperty(key)) { - let currentFieldsMap = getDetailQrCodesData[key].fieldsMap + let getDetailQrCodesData: any = {}; + let currentFieldsMapArrObj: any = {}; + getDetailQrCodes(idArray) + .then(({ data }) => { + getDetailQrCodesData = JSON.parse(JSON.stringify(data)); + if ( + props.formBasicConfig.qrCodePrintStyle && + props.formBasicConfig.qrCodePrintStyle == "2" + ) { + let asfQueryParams1: any[] = []; + for (let key in getDetailQrCodesData) { + currentFieldsMapArrObj[key] = getDetailQrCodesData[key]; + if (getDetailQrCodesData.hasOwnProperty(key)) { + let currentFieldsMap = getDetailQrCodesData[key].fieldsMap; //console.log(currentFieldsMap) // 遍历对象的属性 for (let attr_name in currentFieldsMap) { - if (currentFieldsMap.hasOwnProperty(attr_name)) { - //console.log("attr_name------"+attr_name) - //console.log(`属性名: ${attr_name}, 属性值: ${currentFieldsMap[attr_name]}`); - radios.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let optionsHasCurrentValue = false - element.options.forEach((element1: any) => { - if(toConvertValue==element1.value){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+element1.label - optionsHasCurrentValue = true - } - }); - if(optionsHasCurrentValue==false){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"" - } - } - }); - selects.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let optionsHasCurrentValue = false - element.options.forEach((element1: any) => { - if(toConvertValue==element1.value){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+element1.label - optionsHasCurrentValue = true - } - }); - if(optionsHasCurrentValue==false){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"" - } - } - }); - //console.log(dofs) - dofs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let orgName = getLabelById(toConvertValue) - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+orgName - } + if (currentFieldsMap.hasOwnProperty(attr_name)) { + //console.log("attr_name------"+attr_name) + //console.log(`属性名: ${attr_name}, 属性值: ${currentFieldsMap[attr_name]}`); + radios.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let optionsHasCurrentValue = false; + element.options.forEach((element1: any) => { + if (toConvertValue == element1.value) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + element1.label; + optionsHasCurrentValue = true; + } }); - switchs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - if(toConvertValue=="0"){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"禁用" - }else{ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"启用" - } - } + if (optionsHasCurrentValue == false) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + ""; + } + } + }); + selects.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let optionsHasCurrentValue = false; + element.options.forEach((element1: any) => { + if (toConvertValue == element1.value) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + element1.label; + optionsHasCurrentValue = true; + } }); - checkboxs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let toConvertArr = convertStringToArray(toConvertValue); - let toAddStr = "" - if(toConvertArr.length>0){ - toConvertArr.forEach((element1: any) => { - element.options.forEach((element2: any) => { - if(element1==element2.value){ - toAddStr = toAddStr+element2.label+"," - } - }); - }); - toAddStr = toAddStr.slice(0, -1) - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+toAddStr - } + if (optionsHasCurrentValue == false) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + ""; + } + } + }); + //console.log(dofs) + dofs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let orgName = getLabelById(toConvertValue); + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + orgName; + } + }); + switchs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + if (toConvertValue == "0") { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + "禁用"; + } else { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + "启用"; + } + } + }); + checkboxs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let toConvertArr = convertStringToArray(toConvertValue); + let toAddStr = ""; + if (toConvertArr.length > 0) { + toConvertArr.forEach((element1: any) => { + element.options.forEach((element2: any) => { + if (element1 == element2.value) { + toAddStr = toAddStr + element2.label + ","; + } + }); + }); + toAddStr = toAddStr.slice(0, -1); + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + toAddStr; + } + } + }); + asfs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此关联表单,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + if (toConvertValue.length > 0) { + //console.log(element) + let fieldCount = 0; //如果>0则有此field名 + asfQueryParams1.forEach((item1: any) => { + //如果参数数组中已存在同field的 关联表单asfQueryParamsItem1,则往已存在的如果参数数组中已存在同field的关联表单asfQueryParamsItem1.asfToSelectIds1中新增asfMasterAndAsfId1 + // 不存在则push一个新的关联表单asfQueryParamsItem1 + if (item1.field == element.name) { + fieldCount++; } - }); - asfs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此关联表单,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - if(toConvertValue.length>0){ - //console.log(element) - let fieldCount = 0;//如果>0则有此field名 - asfQueryParams1.forEach((item1: any) => { - //如果参数数组中已存在同field的 关联表单asfQueryParamsItem1,则往已存在的如果参数数组中已存在同field的关联表单asfQueryParamsItem1.asfToSelectIds1中新增asfMasterAndAsfId1 - // 不存在则push一个新的关联表单asfQueryParamsItem1 - if(item1.field==element.name){ - fieldCount++ - } - }); - if(fieldCount>0){ - //已存在 - //得到已存在的相关field参数对象 - asfQueryParams1.forEach((item1: any) => { - if(item1.field==element.name){ - let asfMasterAndAsfId1: any = {}; - asfMasterAndAsfId1.asfId = toConvertValue+""; - asfMasterAndAsfId1.asfMasterId = key+""; - item1.asfToSelectIds.push(asfMasterAndAsfId1) - } - }); - }else{ - //不存在 - let asfQueryParamsItem1: any = {}; - asfQueryParamsItem1.formId = element.control.formid; - asfQueryParamsItem1.field = element.name; - let asfToSelectIds1: any[] = []; - asfQueryParamsItem1.asfToSelectIds = asfToSelectIds1; + }); + if (fieldCount > 0) { + //已存在 + //得到已存在的相关field参数对象 + asfQueryParams1.forEach((item1: any) => { + if (item1.field == element.name) { let asfMasterAndAsfId1: any = {}; - asfMasterAndAsfId1.asfId = toConvertValue+""; - asfMasterAndAsfId1.asfMasterId = key+""; - asfToSelectIds1.push(asfMasterAndAsfId1) - asfQueryParams1.push(asfQueryParamsItem1) + asfMasterAndAsfId1.asfId = toConvertValue + ""; + asfMasterAndAsfId1.asfMasterId = key + ""; + item1.asfToSelectIds.push(asfMasterAndAsfId1); } - } + }); + } else { + //不存在 + let asfQueryParamsItem1: any = {}; + asfQueryParamsItem1.formId = element.control.formid; + asfQueryParamsItem1.field = element.name; + let asfToSelectIds1: any[] = []; + asfQueryParamsItem1.asfToSelectIds = asfToSelectIds1; + let asfMasterAndAsfId1: any = {}; + asfMasterAndAsfId1.asfId = toConvertValue + ""; + asfMasterAndAsfId1.asfMasterId = key + ""; + asfToSelectIds1.push(asfMasterAndAsfId1); + asfQueryParams1.push(asfQueryParamsItem1); } - }) - } + } + } + }); + } } - setTimeout(()=>{ - getDetailQrCodesData[key].fieldsMap = modifyFieldsMap4(currentFieldsMap) - },800) + setTimeout(() => { + getDetailQrCodesData[key].fieldsMap = modifyFieldsMap4( + currentFieldsMap + ); + }, 800); + } } - } - getAsfDataTitlesByIds(asfQueryParams1).then(({ data }) => { - let getAsfDataTitlesByIdsData = JSON.parse(JSON.stringify(data)); - for (let key in currentFieldsMapArrObj) { - if (getDetailQrCodesData.hasOwnProperty(key)) { - let currentFieldsMap = getDetailQrCodesData[key].fieldsMap - getAsfDataTitlesByIdsData.forEach((element1: any) => { - element1.list.forEach((element2: any) => { - if(key==element2.asfMasterId){ - currentFieldsMap[element1.field] = currentFieldsMap[element1.field].split("!@#@!")[0]+"!@#@!"+element2.label - } - }) - }) + getAsfDataTitlesByIds(asfQueryParams1).then(({ data }) => { + let getAsfDataTitlesByIdsData = JSON.parse(JSON.stringify(data)); + for (let key in currentFieldsMapArrObj) { + if (getDetailQrCodesData.hasOwnProperty(key)) { + let currentFieldsMap = getDetailQrCodesData[key].fieldsMap; + getAsfDataTitlesByIdsData.forEach((element1: any) => { + element1.list.forEach((element2: any) => { + if (key == element2.asfMasterId) { + currentFieldsMap[element1.field] = + currentFieldsMap[element1.field].split("!@#@!")[0] + + "!@#@!" + + element2.label; + } + }); + }); + } } - } - }) - - - - setTimeout(()=>{ - tablesData.value = getDetailQrCodesData - },810) - - - - setTimeout(()=>{ - loadingInstance1.close() - qrCodesPrintDialogFlag.value = true - },820) - - }else if(props.formBasicConfig.qrCodePrintStyle&&props.formBasicConfig.qrCodePrintStyle=="1"){ - //fieldsMap = null - tablesData.value = getDetailQrCodesData - qrCodesPrintDialogFlag.value = true - loadingInstance1.close() - } - - }).finally(()=>{ - loadingInstance1.close() - }) - }else{ - alert("内部二维码功能未启用") + }); + + setTimeout(() => { + tablesData.value = getDetailQrCodesData; + }, 810); + + setTimeout(() => { + loadingInstance1.close(); + qrCodesPrintDialogFlag.value = true; + }, 820); + } else if ( + props.formBasicConfig.qrCodePrintStyle && + props.formBasicConfig.qrCodePrintStyle == "1" + ) { + //fieldsMap = null + tablesData.value = getDetailQrCodesData; + qrCodesPrintDialogFlag.value = true; + loadingInstance1.close(); + } + }) + .finally(() => { + loadingInstance1.close(); + }); + } else { + alert("内部二维码功能未启用"); } - }else{ - alert("请先为本表单开启二维码功能") + } else { + alert("请先为本表单开启二维码功能"); } - - }else{ - alert("未选中任何一条,请先选择") - + } else { + alert("未选中任何一条,请先选择"); } //liwenxuan 20250114 二维码打印弹窗 end - - - }else { + } else { if (idList.value.length > 0) { ElMessageBox.confirm("确认删除此数据项?删除后不可恢复!", "警告", { confirmButtonText: "确定", @@ -957,7 +1020,7 @@ const getPageData = () => { selects = []; tables = []; dofs = []; - getAsfs() + getAsfs(); }); } }; @@ -1014,7 +1077,7 @@ const asfGetPageData = (asfFormId: any, asfToSelectMastersKey: any) => { for (let i = 0; i < data.data.list.length; i++) { let asfMasterAndAsfId: any = {}; //asfMasterAndAsfId.asfId = data.data.list[i][asfDetails[j].field]; - asfMasterAndAsfId.asfId = data.data.list[i].id + asfMasterAndAsfId.asfId = data.data.list[i].id; asfMasterAndAsfId.asfMasterId = data.data.list[i].id; asfToSelectIds.push(asfMasterAndAsfId); @@ -1064,12 +1127,11 @@ const asfGetPageData = (asfFormId: any, asfToSelectMastersKey: any) => { /* state.loading = false; */ //显示关联表单本条详情 - setTimeout(()=>{ + setTimeout(() => { tablePageClass.value = 4; drawerWith.value = container.value?.clientWidth; asflookPageInfoIsShow.value = true; - },500) - + }, 500); }); }; @@ -1122,7 +1184,7 @@ onMounted(() => { nextTick(() => { drawerWith.value = container.value?.clientWidth; }); - getAsfs() + getAsfs(); }); /** @ 作者: 秦东 @@ -1510,13 +1572,13 @@ const transformOption = (val: string | number, type?: string) => { :placeholder="'请选择' + item.label" value-format="x" /> - - + { :oper-state="operState" @getPageData="getPageData" /> - { +
-
-
- - - - - - - - - -
{{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }}二维码
{{ item.key }}{{ item.value }}
-
+
+ + + + + + + + + +
+ {{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }} + + 二维码 +
{{ item.key }}{{ item.value }}
-
-
+
+
+ + + + + + + +
+ {{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }}-{{ + tablesData[tableKey].dataTitle + }} +
+ 二维码 +
+
+
+ + + diff --git a/src/components/DesignForm/public/expand/org.vue b/src/components/DesignForm/public/expand/org.vue index c00f204..3581636 100644 --- a/src/components/DesignForm/public/expand/org.vue +++ b/src/components/DesignForm/public/expand/org.vue @@ -3,88 +3,87 @@ @ 时间: 2024-09-12 10:03:22 @ 备注: 行政组织选择 --> - - + diff --git a/src/components/DesignForm/public/form/form.vue b/src/components/DesignForm/public/form/form.vue index 54376a1..8211580 100644 --- a/src/components/DesignForm/public/form/form.vue +++ b/src/components/DesignForm/public/form/form.vue @@ -486,13 +486,13 @@ watch( // 表单组件值改变事件 tProp为子表格相关 provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) => { - /* console.log("表单组件值改变事件----------1--------->",key) - console.log("表单组件值改变事件----------2--------->",value) - console.log("表单组件值改变事件----------3--------->",data) - console.log("表单组件值改变事件----------4--------->",tProp) - console.log("表单组件值改变事件----------5--------->",type) - console.log("表单组件值改变事件----------6--------->",attribute) - console.log("表单组件值改变事件----------11--------->",model.value) */ + // console.log("表单组件值改变事件----------1--------->", key); + // console.log("表单组件值改变事件----------2--------->", value); + // console.log("表单组件值改变事件----------3--------->", data); + // console.log("表单组件值改变事件----------4--------->", tProp); + // console.log("表单组件值改变事件----------5--------->", type); + // console.log("表单组件值改变事件----------6--------->", attribute); + // console.log("表单组件值改变事件----------11--------->", model.value); let fieldVal = {}; for (let i in model.value) { if (i == key) { diff --git a/src/components/DesignForm/public/form/formGroup.vue b/src/components/DesignForm/public/form/formGroup.vue index 949650b..5d58591 100644 --- a/src/components/DesignForm/public/form/formGroup.vue +++ b/src/components/DesignForm/public/form/formGroup.vue @@ -265,13 +265,14 @@ const groupClick = (item: any, ele?: string) => { inputStyle: {}, }; } - // console.log("点击激活当前--->",getGroupName(item)) + store.setActiveKey(getGroupName(item)); store.setControlAttr(item); // grid时显示添加列按钮 state.gridAdd = item.type === "grid"; // state.clone = !notNested(item.type) state.clone = !notNestedTableFlex(item.type); + console.log("点击激活当前--->", store); }; // 返回栅格宽度 const getFormItemStyle = (ele: FormList) => { diff --git a/src/components/DesignForm/tableListPage/index.vue b/src/components/DesignForm/tableListPage/index.vue index 2ac3db3..bcec556 100644 --- a/src/components/DesignForm/tableListPage/index.vue +++ b/src/components/DesignForm/tableListPage/index.vue @@ -31,9 +31,9 @@ import type { FormInstance, FormRules } from "element-plus"; import { gainFormPageListCont } from "@/api/DesignForm/requestapi"; import { Picture, InfoFilled, QuestionFilled } from "@element-plus/icons-vue"; import request from "@/utils/request"; -import html2canvas from 'html2canvas'; -import JSZip, { forEach } from 'jszip'; -import { ElLoading,ElMessage,ElNotification } from 'element-plus' +import html2canvas from "html2canvas"; +import JSZip, { forEach } from "jszip"; +import { ElLoading, ElMessage, ElNotification } from "element-plus"; import { softDeletion, retractRunWorkFlow } from "@/api/taskapi/management"; import { formatNumber } from "@/api/DesignForm/utils"; @@ -69,8 +69,8 @@ const props = withDefaults( versiontitle?: string; viewPage?: viewPageType; formBasicConfig?: any; - fieldsDetailList?:any; - orgAndManTree?:any; + fieldsDetailList?: any; + orgAndManTree?: any; }>(), { showPage: true, @@ -225,34 +225,34 @@ const resetFields = (formEl: FormInstance | undefined) => { }; //20250117 李文轩 二维码表格 -const qrCodesPrintDialogFlag = ref(false) +const qrCodesPrintDialogFlag = ref(false); let tableRefs = reactive({}); -const tablesData = ref({}) -function getDetailQrCodes(val:any) { +const tablesData = ref({}); +function getDetailQrCodes(val: any) { return request({ url: "/javasys/lowCode/QrCode/getDetailQrCodes", method: "post", data: { cfid: props.formId, - idArray:val, - settings:props.formBasicConfig, + idArray: val, + settings: props.formBasicConfig, }, }); } -function modifyFieldsMap4(fieldsMap: any): Array<{ key: string, value: string }> { - let result: Array<{ key: string, value: string }> = []; - // 使用 Object.entries 获取键值对数组,保留原始顺序 - for (const [key, value] of Object.entries(fieldsMap)) { - let parts = value.split("!@#@!"); - if (parts.length === 2) { - result.push({ key: parts[0], value: parts[1] }); - } else { - // 如果格式不符合,可进行错误处理,这里暂时不做处理,直接使用原属性名和属性值 - result.push({ key, value }); - } +function modifyFieldsMap4(fieldsMap: any): Array<{ key: string; value: string }> { + let result: Array<{ key: string; value: string }> = []; + // 使用 Object.entries 获取键值对数组,保留原始顺序 + for (const [key, value] of Object.entries(fieldsMap)) { + let parts = value.split("!@#@!"); + if (parts.length === 2) { + result.push({ key: parts[0], value: parts[1] }); + } else { + // 如果格式不符合,可进行错误处理,这里暂时不做处理,直接使用原属性名和属性值 + result.push({ key, value }); } - return result; + } + return result; } // 定义两个响应式的布尔值来控制按钮的禁用状态 @@ -264,7 +264,7 @@ async function downloadTables() { isButton2Disabled.value = true; const loadingInstance = ElLoading.service({ fullscreen: true, - text: '正在生成图片,请稍候...' // 添加的文字内容,可根据需要修改 + text: "正在生成图片,请稍候...", // 添加的文字内容,可根据需要修改 }); //ElMessage('This is a message.') const zip = new JSZip(); @@ -272,12 +272,12 @@ async function downloadTables() { for (const [tableKey, element] of Object.entries(tableRefs)) { try { const canvas = await html2canvas(element); - const dataUrl = canvas.toDataURL('image/png'); - const byteString = atob(dataUrl.split(',')[1]); - const mimeString = dataUrl.split(',')[0].split(':')[1].split(';')[0]; + const dataUrl = canvas.toDataURL("image/png"); + const byteString = atob(dataUrl.split(",")[1]); + const mimeString = dataUrl.split(",")[0].split(":")[1].split(";")[0]; const ab = new ArrayBuffer(byteString.length); const ia = new Uint8Array(ab); - + for (let i = 0; i < byteString.length; i++) { ia[i] = byteString.charCodeAt(i); } @@ -289,27 +289,35 @@ async function downloadTables() { } } - zip.generateAsync({ type: 'blob' }).then(function(content) { + zip.generateAsync({ type: "blob" }).then(function (content) { const now = new Date(); - const formattedDate = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`; + const formattedDate = `${now.getFullYear()}${String(now.getMonth() + 1).padStart( + 2, + "0" + )}${String(now.getDate()).padStart(2, "0")}_${String(now.getHours()).padStart( + 2, + "0" + )}${String(now.getMinutes()).padStart(2, "0")}${String(now.getSeconds()).padStart( + 2, + "0" + )}`; const fileName = `${props.formBasicConfig.formName}-${formattedDate}.zip`; - - const link = document.createElement('a'); + + const link = document.createElement("a"); link.href = URL.createObjectURL(content); link.download = fileName; - loadingInstance.close() + loadingInstance.close(); link.click(); - tableRefs = {} + tableRefs = {}; // 不管成功与否,最后都要恢复按钮的状态 isButton1Disabled.value = false; isButton2Disabled.value = false; }); } -function closeQrDownload(){ - qrCodesPrintDialogFlag.value = false - tableRefs = {} +function closeQrDownload() { + qrCodesPrintDialogFlag.value = false; + tableRefs = {}; //console.log(tableRefs) - } let asfs: any[] = []; @@ -318,117 +326,137 @@ let checkboxs: any[] = []; let switchs: any[] = []; let selects: any[] = []; let tables: any[] = []; -let dofs: any[] = [];//deptOrgAndOrgCententAndFounderArr +let dofs: any[] = []; //deptOrgAndOrgCententAndFounderArr function getAsfs() { //setTimeout(() => { - let dataList = ref({}); - dataList.value = props.fieldsDetailList - if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { - for (let i = 0; i < dataList.value.length; i++) { - if (dataList.value[i].type == "associatedForms") { - asfs.push(dataList.value[i]); - }else if(dataList.value[i].type == "radio"){ - radios.push(dataList.value[i]) - } else if(dataList.value[i].type == "checkbox"){ - checkboxs.push(dataList.value[i]) - } else if(dataList.value[i].type == "switch"){ - switchs.push(dataList.value[i]) - } else if(dataList.value[i].type == "select"){ - selects.push(dataList.value[i]) - } else if(dataList.value[i].type == "deptOrg"||dataList.value[i].type == "orgCentent"||dataList.value[i].type == "founder"){//||dataList.value[i].type == "owner"拥有者,"expand-user"选择用户 - dofs.push(dataList.value[i]) - }else if ( - dataList.value[i].type == "card" || - dataList.value[i].type == "flex" || - dataList.value[i].type == "div" || - dataList.value[i].type == "table" - ) { - if (dataList.value[i].type == "table") { - tables.push(dataList.value[i]); - } + let dataList = ref({}); + dataList.value = props.fieldsDetailList; + if (dataList && Array.isArray(dataList.value) && dataList.value.length > 0) { + for (let i = 0; i < dataList.value.length; i++) { + if (dataList.value[i].type == "associatedForms") { + asfs.push(dataList.value[i]); + } else if (dataList.value[i].type == "radio") { + radios.push(dataList.value[i]); + } else if (dataList.value[i].type == "checkbox") { + checkboxs.push(dataList.value[i]); + } else if (dataList.value[i].type == "switch") { + switchs.push(dataList.value[i]); + } else if (dataList.value[i].type == "select") { + selects.push(dataList.value[i]); + } else if ( + dataList.value[i].type == "deptOrg" || + dataList.value[i].type == "orgCentent" || + dataList.value[i].type == "founder" + ) { + //||dataList.value[i].type == "owner"拥有者,"expand-user"选择用户 + dofs.push(dataList.value[i]); + } else if ( + dataList.value[i].type == "card" || + dataList.value[i].type == "flex" || + dataList.value[i].type == "div" || + dataList.value[i].type == "table" + ) { + if (dataList.value[i].type == "table") { + tables.push(dataList.value[i]); + } - dataList.value[i].list.forEach((element: any) => { - if (element.type == "associatedForms") { - asfs.push(element); - }else if(element.type == "radio"){ - radios.push(element) - }else if(element.type == "checkbox"){ - checkboxs.push(element) - }else if(element.type == "switch"){ - switchs.push(element) - }else if(element.type == "select"){ - selects.push(element) - }else if(element.type == "deptOrg"||element.type == "orgCentent"||element.type == "founder"){ - dofs.push(element) - } - }); - } else if (dataList.value[i].type == "grid") { - let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); - - if (columns.length > 0) { - for (let z = 0; z < columns.length; z++) { - for (let x = 0; x < columns[z].list.length; x++) { - let a = JSON.parse(JSON.stringify(columns[z].list[x])); - - if (a.type == "associatedForms") { - asfs.push(a); - }else if(a.type == "radio"){ - radios.push(a) - }else if(a.type == "checkbox"){ - checkboxs.push(a) - }else if(a.type == "switch"){ - switchs.push(a) - }else if(a.type == "select"){ - selects.push(a) - }else if(a.type == "deptOrg"||a.type == "orgCentent"||a.type == "founder"){ - dofs.push(a) - } + dataList.value[i].list.forEach((element: any) => { + if (element.type == "associatedForms") { + asfs.push(element); + } else if (element.type == "radio") { + radios.push(element); + } else if (element.type == "checkbox") { + checkboxs.push(element); + } else if (element.type == "switch") { + switchs.push(element); + } else if (element.type == "select") { + selects.push(element); + } else if ( + element.type == "deptOrg" || + element.type == "orgCentent" || + element.type == "founder" + ) { + dofs.push(element); + } + }); + } else if (dataList.value[i].type == "grid") { + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } else if (a.type == "radio") { + radios.push(a); + } else if (a.type == "checkbox") { + checkboxs.push(a); + } else if (a.type == "switch") { + switchs.push(a); + } else if (a.type == "select") { + selects.push(a); + } else if ( + a.type == "deptOrg" || + a.type == "orgCentent" || + a.type == "founder" + ) { + dofs.push(a); } } } - } else if (dataList.value[i].type == "tabs") { - //tabs标签页有可能再嵌套一层flex或者table - let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); - if (columns.length > 0) { - for (let z = 0; z < columns.length; z++) { - for (let x = 0; x < columns[z].list.length; x++) { - let a = JSON.parse(JSON.stringify(columns[z].list[x])); - - if (a.type == "associatedForms") { - asfs.push(a); - }else if(a.type == "radio"){ - radios.push(a) - }else if(a.type == "checkbox"){ - checkboxs.push(a) - }else if(a.type == "switch"){ - switchs.push(a) - }else if(a.type == "select"){ - selects.push(a) - }else if(a.type == "deptOrg"||a.type == "orgCentent"||a.type == "founder"){ - dofs.push(a) - }else if (a.type == "flex" || a.type == "table") { - if (a.type == "table") { - tables.push(dataList.value[i]); - } + } + } else if (dataList.value[i].type == "tabs") { + //tabs标签页有可能再嵌套一层flex或者table + let columns = JSON.parse(JSON.stringify(dataList.value[i].columns)); + if (columns.length > 0) { + for (let z = 0; z < columns.length; z++) { + for (let x = 0; x < columns[z].list.length; x++) { + let a = JSON.parse(JSON.stringify(columns[z].list[x])); + + if (a.type == "associatedForms") { + asfs.push(a); + } else if (a.type == "radio") { + radios.push(a); + } else if (a.type == "checkbox") { + checkboxs.push(a); + } else if (a.type == "switch") { + switchs.push(a); + } else if (a.type == "select") { + selects.push(a); + } else if ( + a.type == "deptOrg" || + a.type == "orgCentent" || + a.type == "founder" + ) { + dofs.push(a); + } else if (a.type == "flex" || a.type == "table") { + if (a.type == "table") { + tables.push(dataList.value[i]); + } - if (a.list.length > 0) { - for (let m = 0; m < a.list.length; m++) { - let q = JSON.parse(JSON.stringify(a.list[m])); - - if (q.type == "associatedForms") { - asfs.push(q); - }else if(q.type == "radio"){ - radios.push(q) - }else if(q.type == "checkbox"){ - checkboxs.push(q) - }else if(q.type == "switch"){ - switchs.push(q) - }else if(q.type == "select"){ - selects.push(q) - }else if(q.type == "deptOrg"||q.type == "orgCentent"||q.type == "founder"){ - dofs.push(q) - } + if (a.list.length > 0) { + for (let m = 0; m < a.list.length; m++) { + let q = JSON.parse(JSON.stringify(a.list[m])); + + if (q.type == "associatedForms") { + asfs.push(q); + } else if (q.type == "radio") { + radios.push(q); + } else if (q.type == "checkbox") { + checkboxs.push(q); + } else if (q.type == "switch") { + switchs.push(q); + } else if (q.type == "select") { + selects.push(q); + } else if ( + q.type == "deptOrg" || + q.type == "orgCentent" || + q.type == "founder" + ) { + dofs.push(q); } } } @@ -438,37 +466,38 @@ function getAsfs() { } } } + } //}, 500); } function convertStringToArray(str: string) { - if (typeof str!== 'string') { - throw new Error('Input must be a string.'); - } - if (str === '') { - return []; - } - // 去除首尾的中括号 - str = str.slice(1, -1); - if (str === '') { - return []; - } - let parts = str.split(','); - return parts.map(part => parseFloat(part)); + if (typeof str !== "string") { + throw new Error("Input must be a string."); + } + if (str === "") { + return []; + } + // 去除首尾的中括号 + str = str.slice(1, -1); + if (str === "") { + return []; + } + let parts = str.split(","); + return parts.map((part) => parseFloat(part)); } interface Tree { - id?: string; - label: string; - disabled?: boolean; - children?: Tree[]; - parentId?: string; - [key: string]: any; + id?: string; + label: string; + disabled?: boolean; + children?: Tree[]; + parentId?: string; + [key: string]: any; } function getLabelById(id: string): string | undefined { //console.log(id) const treeNodes = props.orgAndManTree; - + const findLabel = (nodes: Tree[]): string | undefined => { for (const node of nodes) { // 检查当前节点是否匹配目标id @@ -487,20 +516,18 @@ function getLabelById(id: string): string | undefined { return findLabel(treeNodes); } function isAllCharactersNumbers(str: string) { - // 遍历字符串中的每个字符 - for (let i = 0; i < str.length; i++) { - // 检查当前字符是否不是数字字符 - if (isNaN(parseInt(str[i], 10))) { - return false; - } + // 遍历字符串中的每个字符 + for (let i = 0; i < str.length; i++) { + // 检查当前字符是否不是数字字符 + if (isNaN(parseInt(str[i], 10))) { + return false; } - return true; + } + return true; } //liwenxuan 20250120 二维码 end - - /** @ 作者: 秦东 @ 时间: 2024-04-01 11:36:07 @@ -511,220 +538,261 @@ const setUpClick = (val: string, id: string) => { if (val.key == "newAdd") { drawerWith.value = container.value?.clientWidth; openTaskDrawer.value = true; - } else if(val.key == "showQrCode"){ + } else if (val.key == "showQrCode") { //liwenxuan 20250114 二维码打印弹窗 start //在此组装参数,以生成二维码图片 - let idArray = state.selectionChecked.map(item => item.id); - if(idArray.length>0){ - + let idArray = state.selectionChecked.map((item) => item.id); + if (idArray.length > 0) { //console.log(props.formBasicConfig) - if(props.formBasicConfig.qrCodeFlag==true){ - if(props.formBasicConfig.qrCodeInside==true){ - if(props.formBasicConfig.qrCodePrintStyle&&props.formBasicConfig.qrCodePrintStyle=="2"&&props.formBasicConfig.qrCodeShowFields.length==0){ - alert("未配置表格展示字段") - return + if (props.formBasicConfig.qrCodeFlag == true) { + if (props.formBasicConfig.qrCodeInside == true) { + if ( + props.formBasicConfig.qrCodePrintStyle && + props.formBasicConfig.qrCodePrintStyle == "2" && + props.formBasicConfig.qrCodeShowFields.length == 0 + ) { + alert("未配置表格展示字段"); + return; } const loadingInstance1 = ElLoading.service({ fullscreen: true, - text: '正在生成二维码,请稍候...' // 添加的文字内容,可根据需要修改 + text: "正在生成二维码,请稍候...", // 添加的文字内容,可根据需要修改 }); //请求数据 - let getDetailQrCodesData: any = {} - let currentFieldsMapArrObj: any = {} - getDetailQrCodes(idArray).then(({ data }) => { - getDetailQrCodesData = JSON.parse(JSON.stringify(data)); - if(props.formBasicConfig.qrCodePrintStyle&&props.formBasicConfig.qrCodePrintStyle=="2"){ - let asfQueryParams1: any[] = []; - for (let key in getDetailQrCodesData) { - currentFieldsMapArrObj[key] = getDetailQrCodesData[key] - if (getDetailQrCodesData.hasOwnProperty(key)) { - let currentFieldsMap = getDetailQrCodesData[key].fieldsMap + let getDetailQrCodesData: any = {}; + let currentFieldsMapArrObj: any = {}; + getDetailQrCodes(idArray) + .then(({ data }) => { + getDetailQrCodesData = JSON.parse(JSON.stringify(data)); + if ( + props.formBasicConfig.qrCodePrintStyle && + props.formBasicConfig.qrCodePrintStyle == "2" + ) { + let asfQueryParams1: any[] = []; + for (let key in getDetailQrCodesData) { + currentFieldsMapArrObj[key] = getDetailQrCodesData[key]; + if (getDetailQrCodesData.hasOwnProperty(key)) { + let currentFieldsMap = getDetailQrCodesData[key].fieldsMap; //console.log(currentFieldsMap) // 遍历对象的属性 for (let attr_name in currentFieldsMap) { - if (currentFieldsMap.hasOwnProperty(attr_name)) { - //console.log("attr_name------"+attr_name) - //console.log(`属性名: ${attr_name}, 属性值: ${currentFieldsMap[attr_name]}`); - radios.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let optionsHasCurrentValue = false - element.options.forEach((element1: any) => { - if(toConvertValue==element1.value){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+element1.label - optionsHasCurrentValue = true - } - }); - if(optionsHasCurrentValue==false){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"" - } - } - }); - selects.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let optionsHasCurrentValue = false - element.options.forEach((element1: any) => { - if(toConvertValue==element1.value){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+element1.label - optionsHasCurrentValue = true - } - }); - if(optionsHasCurrentValue==false){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"" - } - } - }); - //console.log(dofs) - dofs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - //console.log(toConvertValue) - if(isAllCharactersNumbers(toConvertValue)){ - let orgName = getLabelById(toConvertValue) - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+orgName - } - - - } + if (currentFieldsMap.hasOwnProperty(attr_name)) { + //console.log("attr_name------"+attr_name) + //console.log(`属性名: ${attr_name}, 属性值: ${currentFieldsMap[attr_name]}`); + radios.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let optionsHasCurrentValue = false; + element.options.forEach((element1: any) => { + if (toConvertValue == element1.value) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + element1.label; + optionsHasCurrentValue = true; + } }); - switchs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - if(toConvertValue=="0"){ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"禁用" - }else{ - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+"启用" - } - } + if (optionsHasCurrentValue == false) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + ""; + } + } + }); + selects.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let optionsHasCurrentValue = false; + element.options.forEach((element1: any) => { + if (toConvertValue == element1.value) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + element1.label; + optionsHasCurrentValue = true; + } }); - checkboxs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此单选,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - let toConvertArr = convertStringToArray(toConvertValue); - let toAddStr = "" - if(toConvertArr.length>0){ - toConvertArr.forEach((element1: any) => { - element.options.forEach((element2: any) => { - if(element1==element2.value){ - toAddStr = toAddStr+element2.label+"," - } - }); - }); - toAddStr = toAddStr.slice(0, -1) - currentFieldsMap[attr_name] = currentFieldsMap[attr_name].split("!@#@!")[0]+"!@#@!"+toAddStr - } + if (optionsHasCurrentValue == false) { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + ""; + } + } + }); + //console.log(dofs) + dofs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + //console.log(toConvertValue) + if (isAllCharactersNumbers(toConvertValue)) { + let orgName = getLabelById(toConvertValue); + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + orgName; + } + } + }); + switchs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + if (toConvertValue == "0") { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + "禁用"; + } else { + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + "启用"; + } + } + }); + checkboxs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此单选,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + let toConvertArr = convertStringToArray(toConvertValue); + let toAddStr = ""; + if (toConvertArr.length > 0) { + toConvertArr.forEach((element1: any) => { + element.options.forEach((element2: any) => { + if (element1 == element2.value) { + toAddStr = toAddStr + element2.label + ","; + } + }); + }); + toAddStr = toAddStr.slice(0, -1); + currentFieldsMap[attr_name] = + currentFieldsMap[attr_name].split("!@#@!")[0] + + "!@#@!" + + toAddStr; + } + } + }); + asfs.forEach(function (element) { + if (attr_name == element.name) { + //表格属性中存在此关联表单,将其value根据options替换为可读值 + let toConvertValue = currentFieldsMap[attr_name].split( + "!@#@!" + )[1]; + if (toConvertValue.length > 0) { + //console.log(element) + let fieldCount = 0; //如果>0则有此field名 + asfQueryParams1.forEach((item1: any) => { + //如果参数数组中已存在同field的 关联表单asfQueryParamsItem1,则往已存在的如果参数数组中已存在同field的关联表单asfQueryParamsItem1.asfToSelectIds1中新增asfMasterAndAsfId1 + // 不存在则push一个新的关联表单asfQueryParamsItem1 + if (item1.field == element.name) { + fieldCount++; } - }); - asfs.forEach(function(element) { - if(attr_name==element.name){ - //表格属性中存在此关联表单,将其value根据options替换为可读值 - let toConvertValue = currentFieldsMap[attr_name].split("!@#@!")[1] - if(toConvertValue.length>0){ - //console.log(element) - let fieldCount = 0;//如果>0则有此field名 - asfQueryParams1.forEach((item1: any) => { - //如果参数数组中已存在同field的 关联表单asfQueryParamsItem1,则往已存在的如果参数数组中已存在同field的关联表单asfQueryParamsItem1.asfToSelectIds1中新增asfMasterAndAsfId1 - // 不存在则push一个新的关联表单asfQueryParamsItem1 - if(item1.field==element.name){ - fieldCount++ - } - }); - if(fieldCount>0){ - //已存在 - //得到已存在的相关field参数对象 - asfQueryParams1.forEach((item1: any) => { - if(item1.field==element.name){ - let asfMasterAndAsfId1: any = {}; - asfMasterAndAsfId1.asfId = toConvertValue+""; - asfMasterAndAsfId1.asfMasterId = key+""; - item1.asfToSelectIds.push(asfMasterAndAsfId1) - } - }); - }else{ - //不存在 - let asfQueryParamsItem1: any = {}; - asfQueryParamsItem1.formId = element.control.formid; - asfQueryParamsItem1.field = element.name; - let asfToSelectIds1: any[] = []; - asfQueryParamsItem1.asfToSelectIds = asfToSelectIds1; + }); + if (fieldCount > 0) { + //已存在 + //得到已存在的相关field参数对象 + asfQueryParams1.forEach((item1: any) => { + if (item1.field == element.name) { let asfMasterAndAsfId1: any = {}; - asfMasterAndAsfId1.asfId = toConvertValue+""; - asfMasterAndAsfId1.asfMasterId = key+""; - asfToSelectIds1.push(asfMasterAndAsfId1) - asfQueryParams1.push(asfQueryParamsItem1) + asfMasterAndAsfId1.asfId = toConvertValue + ""; + asfMasterAndAsfId1.asfMasterId = key + ""; + item1.asfToSelectIds.push(asfMasterAndAsfId1); } - } + }); + } else { + //不存在 + let asfQueryParamsItem1: any = {}; + asfQueryParamsItem1.formId = element.control.formid; + asfQueryParamsItem1.field = element.name; + let asfToSelectIds1: any[] = []; + asfQueryParamsItem1.asfToSelectIds = asfToSelectIds1; + let asfMasterAndAsfId1: any = {}; + asfMasterAndAsfId1.asfId = toConvertValue + ""; + asfMasterAndAsfId1.asfMasterId = key + ""; + asfToSelectIds1.push(asfMasterAndAsfId1); + asfQueryParams1.push(asfQueryParamsItem1); } - }) - } + } + } + }); + } } - setTimeout(()=>{ - getDetailQrCodesData[key].fieldsMap = modifyFieldsMap4(currentFieldsMap) - },800) - } - } - - getAsfDataTitlesByIds(asfQueryParams1).then(({ data }) => { - let getAsfDataTitlesByIdsData = JSON.parse(JSON.stringify(data)); - for (let key in currentFieldsMapArrObj) { - if (getDetailQrCodesData.hasOwnProperty(key)) { - let currentFieldsMap = getDetailQrCodesData[key].fieldsMap - getAsfDataTitlesByIdsData.forEach((element1: any) => { - element1.list.forEach((element2: any) => { - if(key==element2.asfMasterId){ - currentFieldsMap[element1.field] = currentFieldsMap[element1.field].split("!@#@!")[0]+"!@#@!"+element2.label - } - }) - }) + setTimeout(() => { + getDetailQrCodesData[key].fieldsMap = modifyFieldsMap4( + currentFieldsMap + ); + }, 800); } } - }) - - - - setTimeout(()=>{ - tablesData.value = getDetailQrCodesData - },810) - - - - setTimeout(()=>{ - loadingInstance1.close() - qrCodesPrintDialogFlag.value = true - },820) - - }else if(props.formBasicConfig.qrCodePrintStyle&&props.formBasicConfig.qrCodePrintStyle=="1"){ - //fieldsMap = null - tablesData.value = getDetailQrCodesData - qrCodesPrintDialogFlag.value = true - loadingInstance1.close() - } - - }).finally(()=>{ - loadingInstance1.close() - }) - }else{ - alert("内部二维码功能未启用") + getAsfDataTitlesByIds(asfQueryParams1).then(({ data }) => { + let getAsfDataTitlesByIdsData = JSON.parse(JSON.stringify(data)); + for (let key in currentFieldsMapArrObj) { + if (getDetailQrCodesData.hasOwnProperty(key)) { + let currentFieldsMap = getDetailQrCodesData[key].fieldsMap; + getAsfDataTitlesByIdsData.forEach((element1: any) => { + element1.list.forEach((element2: any) => { + if (key == element2.asfMasterId) { + currentFieldsMap[element1.field] = + currentFieldsMap[element1.field].split("!@#@!")[0] + + "!@#@!" + + element2.label; + } + }); + }); + } + } + }); + + setTimeout(() => { + tablesData.value = getDetailQrCodesData; + }, 810); + + setTimeout(() => { + loadingInstance1.close(); + qrCodesPrintDialogFlag.value = true; + }, 820); + } else if ( + props.formBasicConfig.qrCodePrintStyle && + props.formBasicConfig.qrCodePrintStyle == "1" + ) { + //fieldsMap = null + tablesData.value = getDetailQrCodesData; + qrCodesPrintDialogFlag.value = true; + loadingInstance1.close(); + } + }) + .finally(() => { + loadingInstance1.close(); + }); + } else { + alert("内部二维码功能未启用"); } - }else{ - alert("请先为本表单开启二维码功能") + } else { + alert("请先为本表单开启二维码功能"); } - }else{ - alert("未选中任何一条,请先选择") - + } else { + alert("未选中任何一条,请先选择"); } //liwenxuan 20250114 二维码打印弹窗 end - - }else { + } else { if (idList.value.length > 0) { ElMessageBox.confirm("确认删除此数据项?删除后不可恢复!", "警告", { confirmButtonText: "确定", @@ -953,7 +1021,7 @@ const getPageData = () => { switchs = []; selects = []; tables = []; - getAsfs() + getAsfs(); }); } }; @@ -1010,7 +1078,7 @@ const asfGetPageData = (asfFormId: any, asfToSelectMastersKey: any) => { for (let i = 0; i < data.data.list.length; i++) { let asfMasterAndAsfId: any = {}; //asfMasterAndAsfId.asfId = data.data.list[i][asfDetails[j].field]; - asfMasterAndAsfId.asfId = data.data.list[i].id + asfMasterAndAsfId.asfId = data.data.list[i].id; asfMasterAndAsfId.asfMasterId = data.data.list[i].id; asfToSelectIds.push(asfMasterAndAsfId); @@ -1058,15 +1126,14 @@ const asfGetPageData = (asfFormId: any, asfToSelectMastersKey: any) => { }) .finally(() => { /* state.loading = false; */ - setTimeout(()=>{ - //nextTick(() => { + setTimeout(() => { + //nextTick(() => { //显示关联表单本条详情 tablePageClass.value = 4; drawerWith.value = container.value?.clientWidth; asflookPageInfoIsShow.value = true; - //}); - },500) - + //}); + }, 500); }); }; @@ -1075,7 +1142,7 @@ onMounted(() => { nextTick(() => { drawerWith.value = container.value?.clientWidth; }); - getAsfs() + getAsfs(); }); //liwenxuan 关联表单数据获取 start function getAsfDataTitlesByIds(asfQueryParams: any[]) { @@ -1505,13 +1572,13 @@ const diGuiJilian = (val: any, options: any[]) => { :placeholder="'请选择' + item.label" value-format="x" /> - - + { :versionid="props.versionid" :versiontitle="props.versiontitle" :drawerwith="drawerWith" - :cfid = "props.formId" + :cfid="props.formId" @searchquery="getListData" /> @@ -2038,18 +2105,30 @@ const diGuiJilian = (val: any, options: any[]) => { style="margin-top: 10px" width="40%" > -
-
+
- - + + @@ -2058,20 +2137,41 @@ const diGuiJilian = (val: any, options: any[]) => {
{{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }}二维码 + {{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }} + + 二维码 +
{{ item.key }}
-
-
+
- +
- + - +
{{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }}-{{ tablesData[tableKey].dataTitle }} + {{ tablesData[tableKey].appName }}-{{ tablesData[tableKey].formName }}-{{ + tablesData[tableKey].dataTitle + }} +
二维码 + 二维码 +
@@ -2079,8 +2179,19 @@ const diGuiJilian = (val: any, options: any[]) => {