@kp-ui/lowcode 2.16.0-alpha.12 → 2.16.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/FormRender/useFormContext.js +1 -1
- package/src/components/FormRender/useFormContext.js.map +1 -1
- package/src/components/public/ConfigView/CustomPageRender.vue.js +56 -45
- package/src/components/public/ConfigView/CustomPageRender.vue.js.map +1 -1
- package/src/components/public/CustomerModal/CustomerModal.vue2.js.map +1 -1
- package/stats.html +1 -1
package/package.json
CHANGED
|
@@ -138,6 +138,7 @@ const _e = ({ renderForm: x, props: a }) => {
|
|
|
138
138
|
i18nt: d,
|
|
139
139
|
goBack: ae,
|
|
140
140
|
reload: ie,
|
|
141
|
+
formValidator: f,
|
|
141
142
|
getFieldValue: le,
|
|
142
143
|
resetValidation: K,
|
|
143
144
|
clearValidate: Q,
|
|
@@ -173,7 +174,6 @@ const _e = ({ renderForm: x, props: a }) => {
|
|
|
173
174
|
readModeFlag: R,
|
|
174
175
|
// 引用
|
|
175
176
|
widgetRefList: F,
|
|
176
|
-
formValidator: f,
|
|
177
177
|
widgetList: W,
|
|
178
178
|
labelPosition: j,
|
|
179
179
|
labelWidth: S,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext.js","sources":["../../../../src/components/FormRender/useFormContext.ts"],"sourcesContent":["import { computed, nextTick, onMounted, provide, ref, watchEffect } from 'vue';\nimport { useFormValidation } from './formValidation';\n\n/**\n * 表单上下文接口\n */\nimport { Widget } from '@/types/schema';\nimport {\n cloneFormConfigWithoutEventHandler,\n generateId,\n getContainerWidgetByName,\n insertCustomCssToHead,\n insertGlobalFunctionsToHtml\n} from '@/utils/util';\nimport { cloneDeep, set } from 'lodash-es';\nimport { message } from 'ant-design-vue';\nimport { useI18n } from '@/utils/i18n';\nimport { getUuidKey } from '@kp-ui/tool';\nimport { routerReloadStatus, useComRef, useExecFunction, useRef } from 'tmgc2-share';\nimport DynamicDialog from '../form-render/dynamic-dialog.vue';\nimport { useEmitter } from '@/utils/useEmitter';\nimport { useAppRef } from '../form-designer/useAppRef';\nexport interface FormRenderProps {\n vfCtx?: Record<string, any>;\n formJson?: any;\n formData?: Record<string, any>;\n optionData?: Record<string, any>;\n disabledMode?: boolean;\n renderConfig?: {\n languageName?: string;\n };\n globalDsv?: Record<string, any>;\n parentForm?: any;\n dynamicCreation?: boolean;\n debug?: boolean;\n}\n\n/**\n * 表单上下文配置\n */\nexport interface FormContextOptions {\n props: FormRenderProps;\n renderForm: any;\n}\n\n/**\n * 创建表单上下文\n * @param options 表单上下文配置\n * @returns 表单上下文\n */\nexport const useFormContext = ({ renderForm, props }: FormContextOptions) => {\n const { formJson } = props;\n const dynamicDialgRef = useComRef(DynamicDialog);\n const { i18nt } = useI18n();\n const [readModeFlag, setReadMode] = useRef(false);\n\n const emitter = useEmitter();\n\n const formJsonObj = ref();\n // 状态变量\n const formDataModel = ref<Record<string, any>>({});\n const isLoading = ref(false);\n const widgetRefList = ref<Map<string, any>>(new Map());\n const dialogProps = ref({});\n const childFormRef = ref();\n\n const formWidgetId = Symbol('formWidget');\n\n // 提供给子组件的数据\n provide('refList', widgetRefList);\n provide('getFormConfig', () => formConfig.value);\n provide('formData', formDataModel);\n provide('getReadMode', () => readModeFlag.value);\n provide('designState', false); // 设计态标识\n\n const dialogOrDrawerRef = ref();\n\n const { executeFunction, context, execHttpFunction } = useExecFunction();\n const { getFormRef, getWidgetRef, registerToRefList } = useAppRef(widgetRefList, formWidgetId);\n\n // 计算属性\n const formConfig = computed(() => formJsonObj.value?.formConfig || {});\n\n provide('formConfig', formConfig);\n provide('formWidgetId', formWidgetId);\n\n const widgetList = computed(() => formJsonObj.value?.widgetList || []);\n const labelPosition = computed(() => {\n return formConfig.value?.labelPosition || 'horizontal';\n });\n\n const setChildFormRef = chid => {\n childFormRef.value = chid;\n };\n\n const labelWidth = computed(() => {\n return formConfig.value?.labelWidth ? `${formConfig.value.labelWidth}px` : '80px';\n });\n\n const customClass = computed(() => {\n return formConfig.value?.customClass || '';\n });\n\n // 初始化表单验证器\n let formValidator = useFormValidation(renderForm);\n\n // 监听 widgetList 变化,重新初始化验证器\n watchEffect(() => {\n formValidator = useFormValidation(renderForm);\n });\n\n /**\n * 设置表单JSON数据\n */\n const setFormJson = async (json: any) => {\n console.log({ json });\n\n formJsonObj.value = json || { widgetList: [], formConfig: {} };\n // 重新构建表单数据模型\n formDataModel.value = {};\n\n await nextTick();\n handleOnMounted();\n };\n\n /**\n * 获取表单数据\n */\n const getFormData = () => {\n return formDataModel.value || {};\n };\n\n /**\n * 设置表单数据\n */\n const setFormData = (data: Record<string, any>) => {\n if (!data) return;\n // 更新表单数据模型\n Object.keys(data).forEach(key => {\n if (key === 'processingDescribe') {\n console.log(data[key]);\n }\n if (Object.prototype.hasOwnProperty.call(formDataModel.value, key)) {\n formDataModel.value[key] = data[key];\n }\n });\n };\n\n /**\n * 设置加载状态\n */\n const setLoading = (loading: boolean) => {\n isLoading.value = loading;\n };\n\n /**\n * 重置表单验证\n */\n const resetValidation = () => {\n formValidator.resetValidation();\n };\n\n /**\n * 清除表单验证\n */\n const clearValidate = () => {\n formValidator.clearValidate();\n };\n\n const setDialogOrDrawerRef = (ddRef: any) => {\n dialogOrDrawerRef.value = ddRef;\n };\n\n /**\n * 当显示多级嵌套弹窗或抽屉时,获取最顶层VFormRender组件实例\n * @returns {object}\n */\n const getTopFormRef = () => {\n if (!props.parentForm) {\n return getFormRef();\n }\n\n let topFormRef = props.parentForm;\n while (topFormRef.parentForm) {\n topFormRef = topFormRef.parentForm;\n }\n\n return topFormRef;\n };\n\n /**\n * 显示弹窗表单,动态创建v-form-render组件,option-data、global-dsv等属性继承父级表单\n * @param dialogName\n * @param formData\n * @param extraData\n */\n const showDialog = (dialogName, formData = {}, extraData = {}) => {\n const topFormRef = getTopFormRef();\n const dialogCon = (getContainerWidgetByName(topFormRef?.widgetList || [], dialogName) ||\n getContainerWidgetByName(widgetList.value || [], dialogName)) as Widget | null;\n\n if (dialogCon === null) {\n message.error(i18nt('render.hint.refNotFound') + dialogName);\n return;\n }\n\n if (!dialogName || dialogCon.type !== 'vf-dialog') {\n message.error(i18nt('render.hint.refNotFound') + dialogName);\n return;\n }\n const dFormJson = {\n widgetList: cloneDeep(dialogCon?.widgetList || []),\n formConfig: cloneFormConfigWithoutEventHandler(topFormRef?.formConfig?.value || {})\n };\n const wrapperDivId = getUuidKey();\n dialogProps.value = {\n options: dialogCon.options,\n formJson: dFormJson,\n formData: { ...formData },\n optionData: topFormRef.optionData,\n globalDsv: topFormRef.globalDsv,\n parentFormRef: context.value,\n extraData: extraData,\n wrapperId: wrapperDivId,\n vfCtx: { ...formData }\n };\n\n dynamicDialgRef.value?.show();\n };\n /**\n * 获取父级VFormRender组件实例\n * @returns {object}\n */\n const getParentFormRef = () => {\n return props.parentForm;\n };\n\n const getChildFormRef = () => {\n return dynamicDialgRef.value?.getFormRef();\n };\n\n /**\n * 字段值变化事件处理器\n */\n const fieldChangeEventHandler = () => {\n emitter.off$('fieldChange');\n emitter.on$('fieldChange', ({ fieldName, value }) => {\n // 过滤掉错误值\n if (typeof fieldName !== 'undefined' && typeof value !== 'undefined') {\n set(formDataModel.value, fieldName, value);\n }\n });\n };\n\n const onFormDetail = async () => {\n const serveList = formConfig.value.serveList;\n const res = await execHttpFunction(serveList.vformDetail, {\n vfCtx: props.vfCtx\n });\n console.log('res: ', res);\n return res;\n };\n\n const onFormUpdate = async () => {\n const valid = await formValidator.validate();\n if (!valid) throw new Error(i18nt('表单验证失败'));\n\n const serveList = formConfig.value.serveList;\n const res = await execHttpFunction(serveList.vformUpdate, {\n data: formDataModel.value,\n vfCtx: props.vfCtx\n });\n console.log('res: ', res);\n return res;\n };\n\n const handleOnMounted = () => {\n if (formConfig.value?.onFormMounted) {\n console.log('onFormMounted: ');\n executeFunction({\n functionBody: formConfig.value?.onFormMounted\n });\n }\n };\n\n /**\n * 插入自定义样式和脚本\n * @param cssCode CSS代码\n * @param functions 自定义函数\n * @param formId 表单ID\n */\n const insertCustomCode = () => {\n const formId = 'vfRender' + generateId();\n const { cssCode, functions } = formConfig.value;\n if (cssCode) {\n insertCustomCssToHead(cssCode, formId || '');\n }\n if (functions) {\n insertGlobalFunctionsToHtml(functions, formId || '');\n }\n };\n\n const reload = () => {\n const router = context.value?.$router;\n router?.replace({\n query: {\n ...router.currentRoute.value.query,\n _t: Date.now()\n }\n });\n };\n\n const goBack = (reloadStatus?: routerReloadStatus, cb?: () => void) => {\n const goBack = getFormRef().vfCtx?.goBack;\n if (typeof goBack === 'function') {\n goBack(reloadStatus, cb);\n } else {\n const router = context.value?.$router;\n router?.go(-1);\n }\n };\n\n const getFieldValue = (field: string) => {\n return formDataModel.value[field];\n };\n\n const getVfCtx = () => {\n return props.vfCtx;\n };\n\n onMounted(() => {\n if (formJson) {\n setFormJson(formJson);\n }\n fieldChangeEventHandler();\n insertCustomCode();\n });\n\n const expose = {\n context,\n i18nt,\n goBack,\n reload,\n getFieldValue,\n resetValidation,\n clearValidate,\n getVfCtx,\n getParentFormRef,\n getFormRef,\n getWidgetRef,\n showDialog,\n getFormData,\n getChildFormRef,\n setFormData,\n setReadMode,\n setFormJson,\n setLoading,\n onFormDetail,\n onFormUpdate,\n formDataModel,\n isLoading,\n vfCtx: props.vfCtx,\n // 计算属性\n formConfig,\n dynamicDialgRef,\n setChildFormRef,\n setDialogOrDrawerRef\n };\n\n return {\n formWidgetId,\n registerToRefList,\n dialogOrDrawerRef,\n\n emitter,\n // 状态\n formJsonObj,\n readModeFlag,\n // 引用\n widgetRefList,\n formValidator,\n\n widgetList,\n labelPosition,\n labelWidth,\n customClass,\n dialogProps,\n\n expose,\n ...expose\n };\n};\n"],"names":["useFormContext","renderForm","props","formJson","dynamicDialgRef","useComRef","DynamicDialog","i18nt","useI18n","readModeFlag","setReadMode","useRef","emitter","useEmitter","formJsonObj","ref","formDataModel","isLoading","widgetRefList","dialogProps","childFormRef","formWidgetId","provide","formConfig","dialogOrDrawerRef","executeFunction","context","execHttpFunction","useExecFunction","getFormRef","getWidgetRef","registerToRefList","useAppRef","computed","_a","widgetList","labelPosition","setChildFormRef","chid","labelWidth","customClass","formValidator","useFormValidation","watchEffect","setFormJson","json","nextTick","handleOnMounted","getFormData","setFormData","data","key","setLoading","loading","resetValidation","clearValidate","setDialogOrDrawerRef","ddRef","getTopFormRef","topFormRef","showDialog","dialogName","formData","extraData","dialogCon","getContainerWidgetByName","message","dFormJson","cloneDeep","cloneFormConfigWithoutEventHandler","wrapperDivId","getUuidKey","_b","getParentFormRef","getChildFormRef","fieldChangeEventHandler","fieldName","value","set","onFormDetail","serveList","res","onFormUpdate","insertCustomCode","formId","generateId","cssCode","functions","insertCustomCssToHead","insertGlobalFunctionsToHtml","reload","router","goBack","reloadStatus","cb","getFieldValue","field","getVfCtx","onMounted","expose"],"mappings":";;;;;;;;;;;;AAkDO,MAAMA,KAAiB,CAAC,EAAE,YAAAC,GAAY,OAAAC,QAAgC;AACzE,QAAM,EAAE,UAAAC,MAAaD,GACfE,IAAkBC,GAAUC,EAAa,GACzC,EAAE,OAAAC,EAAA,IAAUC,GAAA,GACZ,CAACC,GAAcC,CAAW,IAAIC,GAAO,EAAK,GAE1CC,IAAUC,GAAA,GAEVC,IAAcC,EAAA,GAEdC,IAAgBD,EAAyB,EAAE,GAC3CE,IAAYF,EAAI,EAAK,GACrBG,IAAgBH,EAAsB,oBAAI,KAAK,GAC/CI,IAAcJ,EAAI,EAAE,GACpBK,IAAeL,EAAA,GAEfM,IAAe,OAAO,YAAY;AAGxC,EAAAC,EAAQ,WAAWJ,CAAa,GAChCI,EAAQ,iBAAiB,MAAMC,EAAW,KAAK,GAC/CD,EAAQ,YAAYN,CAAa,GACjCM,EAAQ,eAAe,MAAMb,EAAa,KAAK,GAC/Ca,EAAQ,eAAe,EAAK;AAE5B,QAAME,IAAoBT,EAAA,GAEpB,EAAE,iBAAAU,GAAiB,SAAAC,GAAS,kB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A,IACA,iBAAAzC;AAAA,IACA,eAAAC;AAAA,IACA,UAAA0C;AAAA,IACA,kBAAAxB;AAAA,IACA,YAAA5C;AAAA,IACA,cAAAC;AAAA,IACA,YAAA8B;AAAA,IACA,aAAAZ;AAAA,IACA,iBAAA0B;AAAA,IACA,aAAAzB;AAAA,IACA,aAAAvC;AAAA,IACA,aAAAkC;AAAA,IACA,YAAAQ;AAAA,IACA,cAAA2B;AAAA,IACA,cAAAG;AAAA,IACA,eAAAlE;AAAA,IACA,WAAAC;AAAA,IACA,OAAOf,EAAM;AAAA;AAAA,IAEb,YAAAqB;AAAA,IACA,iBAAAnB;AAAA,IACA,iBAAAiC;AAAA,IACA,sBAAAmB;AAAA,EAAA;AAGJ,SAAO;AAAA,IACH,cAAAnC;AAAA,IACA,mBAAAU;AAAA,IACA,mBAAAP;AAAA,IAEA,SAAAZ;AAAA;AAAA,IAEA,aAAAE;AAAA,IACA,cAAAL;AAAA;AAAA,IAEA,eAAAS;AAAA,IACA,eAAAuB;AAAA,IAEA,YAAAN;AAAA,IACA,eAAAC;AAAA,IACA,YAAAG;AAAA,IACA,aAAAC;AAAA,IACA,aAAArB;AAAA,IAEA,QAAAgF;AAAA,IACA,GAAGA;AAAA,EAAA;AAEX;"}
|
|
1
|
+
{"version":3,"file":"useFormContext.js","sources":["../../../../src/components/FormRender/useFormContext.ts"],"sourcesContent":["import { computed, nextTick, onMounted, provide, ref, watchEffect } from 'vue';\nimport { useFormValidation } from './formValidation';\n\n/**\n * 表单上下文接口\n */\nimport { Widget } from '@/types/schema';\nimport {\n cloneFormConfigWithoutEventHandler,\n generateId,\n getContainerWidgetByName,\n insertCustomCssToHead,\n insertGlobalFunctionsToHtml\n} from '@/utils/util';\nimport { cloneDeep, set } from 'lodash-es';\nimport { message } from 'ant-design-vue';\nimport { useI18n } from '@/utils/i18n';\nimport { getUuidKey } from '@kp-ui/tool';\nimport { routerReloadStatus, useComRef, useExecFunction, useRef } from 'tmgc2-share';\nimport DynamicDialog from '../form-render/dynamic-dialog.vue';\nimport { useEmitter } from '@/utils/useEmitter';\nimport { useAppRef } from '../form-designer/useAppRef';\nexport interface FormRenderProps {\n vfCtx?: Record<string, any>;\n formJson?: any;\n formData?: Record<string, any>;\n optionData?: Record<string, any>;\n disabledMode?: boolean;\n renderConfig?: {\n languageName?: string;\n };\n globalDsv?: Record<string, any>;\n parentForm?: any;\n dynamicCreation?: boolean;\n debug?: boolean;\n}\n\n/**\n * 表单上下文配置\n */\nexport interface FormContextOptions {\n props: FormRenderProps;\n renderForm: any;\n}\n\n/**\n * 创建表单上下文\n * @param options 表单上下文配置\n * @returns 表单上下文\n */\nexport const useFormContext = ({ renderForm, props }: FormContextOptions) => {\n const { formJson } = props;\n const dynamicDialgRef = useComRef(DynamicDialog);\n const { i18nt } = useI18n();\n const [readModeFlag, setReadMode] = useRef(false);\n\n const emitter = useEmitter();\n\n const formJsonObj = ref();\n // 状态变量\n const formDataModel = ref<Record<string, any>>({});\n const isLoading = ref(false);\n const widgetRefList = ref<Map<string, any>>(new Map());\n const dialogProps = ref({});\n const childFormRef = ref();\n\n const formWidgetId = Symbol('formWidget');\n\n // 提供给子组件的数据\n provide('refList', widgetRefList);\n provide('getFormConfig', () => formConfig.value);\n provide('formData', formDataModel);\n provide('getReadMode', () => readModeFlag.value);\n provide('designState', false); // 设计态标识\n\n const dialogOrDrawerRef = ref();\n\n const { executeFunction, context, execHttpFunction } = useExecFunction();\n const { getFormRef, getWidgetRef, registerToRefList } = useAppRef(widgetRefList, formWidgetId);\n\n // 计算属性\n const formConfig = computed(() => formJsonObj.value?.formConfig || {});\n\n provide('formConfig', formConfig);\n provide('formWidgetId', formWidgetId);\n\n const widgetList = computed(() => formJsonObj.value?.widgetList || []);\n const labelPosition = computed(() => {\n return formConfig.value?.labelPosition || 'horizontal';\n });\n\n const setChildFormRef = chid => {\n childFormRef.value = chid;\n };\n\n const labelWidth = computed(() => {\n return formConfig.value?.labelWidth ? `${formConfig.value.labelWidth}px` : '80px';\n });\n\n const customClass = computed(() => {\n return formConfig.value?.customClass || '';\n });\n\n // 初始化表单验证器\n let formValidator = useFormValidation(renderForm);\n\n // 监听 widgetList 变化,重新初始化验证器\n watchEffect(() => {\n formValidator = useFormValidation(renderForm);\n });\n\n /**\n * 设置表单JSON数据\n */\n const setFormJson = async (json: any) => {\n console.log({ json });\n\n formJsonObj.value = json || { widgetList: [], formConfig: {} };\n // 重新构建表单数据模型\n formDataModel.value = {};\n\n await nextTick();\n handleOnMounted();\n };\n\n /**\n * 获取表单数据\n */\n const getFormData = () => {\n return formDataModel.value || {};\n };\n\n /**\n * 设置表单数据\n */\n const setFormData = (data: Record<string, any>) => {\n if (!data) return;\n // 更新表单数据模型\n Object.keys(data).forEach(key => {\n if (key === 'processingDescribe') {\n console.log(data[key]);\n }\n if (Object.prototype.hasOwnProperty.call(formDataModel.value, key)) {\n formDataModel.value[key] = data[key];\n }\n });\n };\n\n /**\n * 设置加载状态\n */\n const setLoading = (loading: boolean) => {\n isLoading.value = loading;\n };\n\n /**\n * 重置表单验证\n */\n const resetValidation = () => {\n formValidator.resetValidation();\n };\n\n /**\n * 清除表单验证\n */\n const clearValidate = () => {\n formValidator.clearValidate();\n };\n\n const setDialogOrDrawerRef = (ddRef: any) => {\n dialogOrDrawerRef.value = ddRef;\n };\n\n /**\n * 当显示多级嵌套弹窗或抽屉时,获取最顶层VFormRender组件实例\n * @returns {object}\n */\n const getTopFormRef = () => {\n if (!props.parentForm) {\n return getFormRef();\n }\n\n let topFormRef = props.parentForm;\n while (topFormRef.parentForm) {\n topFormRef = topFormRef.parentForm;\n }\n\n return topFormRef;\n };\n\n /**\n * 显示弹窗表单,动态创建v-form-render组件,option-data、global-dsv等属性继承父级表单\n * @param dialogName\n * @param formData\n * @param extraData\n */\n const showDialog = (dialogName, formData = {}, extraData = {}) => {\n const topFormRef = getTopFormRef();\n const dialogCon = (getContainerWidgetByName(topFormRef?.widgetList || [], dialogName) ||\n getContainerWidgetByName(widgetList.value || [], dialogName)) as Widget | null;\n\n if (dialogCon === null) {\n message.error(i18nt('render.hint.refNotFound') + dialogName);\n return;\n }\n\n if (!dialogName || dialogCon.type !== 'vf-dialog') {\n message.error(i18nt('render.hint.refNotFound') + dialogName);\n return;\n }\n const dFormJson = {\n widgetList: cloneDeep(dialogCon?.widgetList || []),\n formConfig: cloneFormConfigWithoutEventHandler(topFormRef?.formConfig?.value || {})\n };\n const wrapperDivId = getUuidKey();\n dialogProps.value = {\n options: dialogCon.options,\n formJson: dFormJson,\n formData: { ...formData },\n optionData: topFormRef.optionData,\n globalDsv: topFormRef.globalDsv,\n parentFormRef: context.value,\n extraData: extraData,\n wrapperId: wrapperDivId,\n vfCtx: { ...formData }\n };\n\n dynamicDialgRef.value?.show();\n };\n /**\n * 获取父级VFormRender组件实例\n * @returns {object}\n */\n const getParentFormRef = () => {\n return props.parentForm;\n };\n\n const getChildFormRef = () => {\n return dynamicDialgRef.value?.getFormRef();\n };\n\n /**\n * 字段值变化事件处理器\n */\n const fieldChangeEventHandler = () => {\n emitter.off$('fieldChange');\n emitter.on$('fieldChange', ({ fieldName, value }) => {\n // 过滤掉错误值\n if (typeof fieldName !== 'undefined' && typeof value !== 'undefined') {\n set(formDataModel.value, fieldName, value);\n }\n });\n };\n\n const onFormDetail = async () => {\n const serveList = formConfig.value.serveList;\n const res = await execHttpFunction(serveList.vformDetail, {\n vfCtx: props.vfCtx\n });\n console.log('res: ', res);\n return res;\n };\n\n const onFormUpdate = async () => {\n const valid = await formValidator.validate();\n if (!valid) throw new Error(i18nt('表单验证失败'));\n\n const serveList = formConfig.value.serveList;\n const res = await execHttpFunction(serveList.vformUpdate, {\n data: formDataModel.value,\n vfCtx: props.vfCtx\n });\n console.log('res: ', res);\n return res;\n };\n\n const handleOnMounted = () => {\n if (formConfig.value?.onFormMounted) {\n console.log('onFormMounted: ');\n executeFunction({\n functionBody: formConfig.value?.onFormMounted\n });\n }\n };\n\n /**\n * 插入自定义样式和脚本\n * @param cssCode CSS代码\n * @param functions 自定义函数\n * @param formId 表单ID\n */\n const insertCustomCode = () => {\n const formId = 'vfRender' + generateId();\n const { cssCode, functions } = formConfig.value;\n if (cssCode) {\n insertCustomCssToHead(cssCode, formId || '');\n }\n if (functions) {\n insertGlobalFunctionsToHtml(functions, formId || '');\n }\n };\n\n const reload = () => {\n const router = context.value?.$router;\n router?.replace({\n query: {\n ...router.currentRoute.value.query,\n _t: Date.now()\n }\n });\n };\n\n const goBack = (reloadStatus?: routerReloadStatus, cb?: () => void) => {\n const goBack = getFormRef().vfCtx?.goBack;\n if (typeof goBack === 'function') {\n goBack(reloadStatus, cb);\n } else {\n const router = context.value?.$router;\n router?.go(-1);\n }\n };\n\n const getFieldValue = (field: string) => {\n return formDataModel.value[field];\n };\n\n const getVfCtx = () => {\n return props.vfCtx;\n };\n\n onMounted(() => {\n if (formJson) {\n setFormJson(formJson);\n }\n fieldChangeEventHandler();\n insertCustomCode();\n });\n\n const expose = {\n context,\n i18nt,\n goBack,\n reload,\n formValidator,\n getFieldValue,\n resetValidation,\n clearValidate,\n getVfCtx,\n getParentFormRef,\n getFormRef,\n getWidgetRef,\n showDialog,\n getFormData,\n getChildFormRef,\n setFormData,\n setReadMode,\n setFormJson,\n setLoading,\n onFormDetail,\n onFormUpdate,\n formDataModel,\n isLoading,\n vfCtx: props.vfCtx,\n // 计算属性\n formConfig,\n dynamicDialgRef,\n setChildFormRef,\n setDialogOrDrawerRef\n };\n\n return {\n formWidgetId,\n registerToRefList,\n dialogOrDrawerRef,\n\n emitter,\n // 状态\n formJsonObj,\n readModeFlag,\n // 引用\n widgetRefList,\n\n widgetList,\n labelPosition,\n labelWidth,\n customClass,\n dialogProps,\n\n expose,\n ...expose\n };\n};\n"],"names":["useFormContext","renderForm","props","formJson","dynamicDialgRef","useComRef","DynamicDialog","i18nt","useI18n","readModeFlag","setReadMode","useRef","emitter","useEmitter","formJsonObj","ref","formDataModel","isLoading","widgetRefList","dialogProps","childFormRef","formWidgetId","provide","formConfig","dialogOrDrawerRef","executeFunction","context","execHttpFunction","useExecFunction","getFormRef","getWidgetRef","registerToRefList","useAppRef","computed","_a","widgetList","labelPosition","setChildFormRef","chid","labelWidth","customClass","formValidator","useFormValidation","watchEffect","setFormJson","json","nextTick","handleOnMounted","getFormData","setFormData","data","key","setLoading","loading","resetValidation","clearValidate","setDialogOrDrawerRef","ddRef","getTopFormRef","topFormRef","showDialog","dialogName","formData","extraData","dialogCon","getContainerWidgetByName","message","dFormJson","cloneDeep","cloneFormConfigWithoutEventHandler","wrapperDivId","getUuidKey","_b","getParentFormRef","getChildFormRef","fieldChangeEventHandler","fieldName","value","set","onFormDetail","serveList","res","onFormUpdate","insertCustomCode","formId","generateId","cssCode","functions","insertCustomCssToHead","insertGlobalFunctionsToHtml","reload","router","goBack","reloadStatus","cb","getFieldValue","field","getVfCtx","onMounted","expose"],"mappings":";;;;;;;;;;;;AAkDO,MAAMA,KAAiB,CAAC,EAAE,YAAAC,GAAY,OAAAC,QAAgC;AACzE,QAAM,EAAE,UAAAC,MAAaD,GACfE,IAAkBC,GAAUC,EAAa,GACzC,EAAE,OAAAC,EAAA,IAAUC,GAAA,GACZ,CAACC,GAAcC,CAAW,IAAIC,GAAO,EAAK,GAE1CC,IAAUC,GAAA,GAEVC,IAAcC,EAAA,GAEdC,IAAgBD,EAAyB,EAAE,GAC3CE,IAAYF,EAAI,EAAK,GACrBG,IAAgBH,EAAsB,oBAAI,KAAK,GAC/CI,IAAcJ,EAAI,EAAE,GACpBK,IAAeL,EAAA,GAEfM,IAAe,OAAO,YAAY;AAGxC,EAAAC,EAAQ,WAAWJ,CAAa,GAChCI,EAAQ,iBAAiB,MAAMC,EAAW,KAAK,GAC/CD,EAAQ,YAAYN,CAAa,GACjCM,EAAQ,eAAe,MAAMb,EAAa,KAAK,GAC/Ca,EAAQ,eAAe,EAAK;AAE5B,QAAME,IAAoBT,EAAA,GAEpB,EAAE,iBAAAU,GAAiB,SAAAC,GAAS,kBAAAC,EAAA,IAAqBC,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A,IACA,iBAAAzC;AAAA,IACA,eAAAC;AAAA,IACA,UAAA0C;AAAA,IACA,kBAAAxB;AAAA,IACA,YAAA5C;AAAA,IACA,cAAAC;AAAA,IACA,YAAA8B;AAAA,IACA,aAAAZ;AAAA,IACA,iBAAA0B;AAAA,IACA,aAAAzB;AAAA,IACA,aAAAvC;AAAA,IACA,aAAAkC;AAAA,IACA,YAAAQ;AAAA,IACA,cAAA2B;AAAA,IACA,cAAAG;AAAA,IACA,eAAAlE;AAAA,IACA,WAAAC;AAAA,IACA,OAAOf,EAAM;AAAA;AAAA,IAEb,YAAAqB;AAAA,IACA,iBAAAnB;AAAA,IACA,iBAAAiC;AAAA,IACA,sBAAAmB;AAAA,EAAA;AAGJ,SAAO;AAAA,IACH,cAAAnC;AAAA,IACA,mBAAAU;AAAA,IACA,mBAAAP;AAAA,IAEA,SAAAZ;AAAA;AAAA,IAEA,aAAAE;AAAA,IACA,cAAAL;AAAA;AAAA,IAEA,eAAAS;AAAA,IAEA,YAAAiB;AAAA,IACA,eAAAC;AAAA,IACA,YAAAG;AAAA,IACA,aAAAC;AAAA,IACA,aAAArB;AAAA,IAEA,QAAAgF;AAAA,IACA,GAAGA;AAAA,EAAA;AAEX;"}
|
|
@@ -1,58 +1,69 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { getLocat as
|
|
3
|
-
import { TpfAddInfoLayout as
|
|
4
|
-
import { useLowcode as
|
|
5
|
-
import
|
|
1
|
+
import { defineComponent as g, onMounted as x, createElementBlock as B, openBlock as k, createVNode as o, unref as t, withCtx as m, createElementVNode as L } from "vue";
|
|
2
|
+
import { getLocat as s } from "@kp-ui/tool";
|
|
3
|
+
import { TpfAddInfoLayout as v } from "tmgc2-share";
|
|
4
|
+
import { useLowcode as R } from "../../../hooks/useLowcode.js";
|
|
5
|
+
import y from "../ActionButtonListRender.vue.js";
|
|
6
6
|
import b from "../../FormRender/index.vue.js";
|
|
7
7
|
const h = {
|
|
8
8
|
class: "t-bg-[#fff] t-h-full"
|
|
9
|
-
},
|
|
9
|
+
}, J = /* @__PURE__ */ g({
|
|
10
10
|
__name: "CustomPageRender",
|
|
11
|
-
|
|
11
|
+
props: {
|
|
12
|
+
title: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: ""
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(w) {
|
|
12
18
|
const {
|
|
13
|
-
formCode:
|
|
14
|
-
id:
|
|
15
|
-
type:
|
|
16
|
-
} =
|
|
19
|
+
formCode: u = "",
|
|
20
|
+
id: a = "",
|
|
21
|
+
type: p = "edit"
|
|
22
|
+
} = s(), {
|
|
17
23
|
vfdRef: e,
|
|
18
|
-
formConfig:
|
|
19
|
-
getComponentJson:
|
|
20
|
-
goBack:
|
|
21
|
-
} =
|
|
22
|
-
formCode:
|
|
23
|
-
type:
|
|
24
|
-
}),
|
|
25
|
-
item:
|
|
24
|
+
formConfig: n,
|
|
25
|
+
getComponentJson: _,
|
|
26
|
+
goBack: r
|
|
27
|
+
} = R({
|
|
28
|
+
formCode: u,
|
|
29
|
+
type: p
|
|
30
|
+
}), C = ({
|
|
31
|
+
item: f
|
|
26
32
|
}) => {
|
|
27
|
-
|
|
33
|
+
f.name === "cancelButton" && r();
|
|
34
|
+
};
|
|
35
|
+
return x(async () => {
|
|
36
|
+
await _([]);
|
|
37
|
+
}), (f, i) => {
|
|
38
|
+
var c;
|
|
39
|
+
return k(), B("div", h, [o(t(v), {
|
|
40
|
+
title: (c = t(n)) == null ? void 0 : c.title
|
|
41
|
+
}, {
|
|
42
|
+
footerRight: m(() => {
|
|
43
|
+
var d, l;
|
|
44
|
+
return [i[0] || (i[0] = L("div", {
|
|
45
|
+
id: "fromBtn"
|
|
46
|
+
}, null, -1)), o(y, {
|
|
47
|
+
buttonList: ((d = t(n)) == null ? void 0 : d.buttonList) || [],
|
|
48
|
+
ctx: (l = t(e)) == null ? void 0 : l.context,
|
|
49
|
+
onOnClick: C
|
|
50
|
+
}, null, 8, ["buttonList", "ctx"])];
|
|
51
|
+
}),
|
|
52
|
+
default: m(() => [o(b, {
|
|
53
|
+
ref_key: "vfdRef",
|
|
54
|
+
ref: e,
|
|
55
|
+
vfCtx: {
|
|
56
|
+
_id: t(a),
|
|
57
|
+
...t(s)(),
|
|
58
|
+
goBack: t(r)
|
|
59
|
+
}
|
|
60
|
+
}, null, 8, ["vfCtx"])]),
|
|
61
|
+
_: 1
|
|
62
|
+
}, 8, ["title"])]);
|
|
28
63
|
};
|
|
29
|
-
return g(async () => {
|
|
30
|
-
await p([]);
|
|
31
|
-
}), (r, f) => (B(), x("div", h, [o(t(L), null, {
|
|
32
|
-
footerRight: m(() => {
|
|
33
|
-
var i, c;
|
|
34
|
-
return [f[0] || (f[0] = k("div", {
|
|
35
|
-
id: "fromBtn"
|
|
36
|
-
}, null, -1)), o(R, {
|
|
37
|
-
buttonList: ((i = t(a)) == null ? void 0 : i.buttonList) || [],
|
|
38
|
-
ctx: (c = t(e)) == null ? void 0 : c.context,
|
|
39
|
-
onOnClick: _
|
|
40
|
-
}, null, 8, ["buttonList", "ctx"])];
|
|
41
|
-
}),
|
|
42
|
-
default: m(() => [o(b, {
|
|
43
|
-
ref_key: "vfdRef",
|
|
44
|
-
ref: e,
|
|
45
|
-
vfCtx: {
|
|
46
|
-
_id: t(u),
|
|
47
|
-
...t(d)(),
|
|
48
|
-
goBack: t(n)
|
|
49
|
-
}
|
|
50
|
-
}, null, 8, ["vfCtx"])]),
|
|
51
|
-
_: 1
|
|
52
|
-
})]));
|
|
53
64
|
}
|
|
54
65
|
});
|
|
55
66
|
export {
|
|
56
|
-
|
|
67
|
+
J as default
|
|
57
68
|
};
|
|
58
69
|
//# sourceMappingURL=CustomPageRender.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPageRender.vue.js","sources":["../../../../../src/components/public/ConfigView/CustomPageRender.vue"],"sourcesContent":["<template>\n <div class=\"t-bg-[#fff] t-h-full\">\n <TpfAddInfoLayout>\n <VFormRender ref=\"vfdRef\" :vfCtx=\"{ _id: id, ...getLocat(), goBack }\" />\n <template #footerRight>\n <div id=\"fromBtn\"></div>\n <ActionButtonListRender\n :buttonList=\"formConfig?.buttonList || []\"\n :ctx=\"vfdRef?.context\"\n @on-click=\"handleButtonClick\"\n />\n </template>\n </TpfAddInfoLayout>\n </div>\n</template>\n\n<script lang=\"tsx\" setup>\n import { getLocat } from '@kp-ui/tool';\n import { onMounted } from 'vue';\n import { TpfAddInfoLayout } from 'tmgc2-share';\n import { useLowcode } from '@/hooks/useLowcode';\n import ActionButtonListRender from '@/components/public/ActionButtonListRender.vue';\n import VFormRender from '@/components/FormRender/index.vue';\n import { ActionButton } from '@/types/button';\n\n const { formCode = '', id = '', type = 'edit' } = getLocat();\n\n const { vfdRef, formConfig, getComponentJson, goBack } = useLowcode({ formCode, type });\n\n const handleButtonClick = ({ item }: { item: ActionButton }) => {\n if (item.name === 'cancelButton') {\n goBack();\n }\n };\n\n onMounted(async () => {\n await getComponentJson([]);\n });\n</script>\n\n<style lang=\"less\"></style>\n"],"names":["formCode","id","type","getLocat","vfdRef","formConfig","getComponentJson","goBack","useLowcode","handleButtonClick","item","name","onMounted","_openBlock","_createElementBlock","_hoisted_1","_createVNode","_unref","TpfAddInfoLayout","footerRight","_createElementVNode","ActionButtonListRender","buttonList","ctx","context","onOnClick","VFormRender","ref","vfCtx","_id"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomPageRender.vue.js","sources":["../../../../../src/components/public/ConfigView/CustomPageRender.vue"],"sourcesContent":["<template>\n <div class=\"t-bg-[#fff] t-h-full\">\n <TpfAddInfoLayout :title=\"formConfig?.title\">\n <VFormRender ref=\"vfdRef\" :vfCtx=\"{ _id: id, ...getLocat(), goBack }\" />\n <template #footerRight>\n <div id=\"fromBtn\"></div>\n <ActionButtonListRender\n :buttonList=\"formConfig?.buttonList || []\"\n :ctx=\"vfdRef?.context\"\n @on-click=\"handleButtonClick\"\n />\n </template>\n </TpfAddInfoLayout>\n </div>\n</template>\n\n<script lang=\"tsx\" setup>\n import { getLocat } from '@kp-ui/tool';\n import { computed, onMounted } from 'vue';\n import { TpfAddInfoLayout } from 'tmgc2-share';\n import { useLowcode } from '@/hooks/useLowcode';\n import ActionButtonListRender from '@/components/public/ActionButtonListRender.vue';\n import VFormRender from '@/components/FormRender/index.vue';\n import { ActionButton } from '@/types/button';\n\n const props = defineProps({\n title: {\n type: String,\n default: ''\n }\n });\n const { formCode = '', id = '', type = 'edit' } = getLocat();\n\n const { vfdRef, formConfig, getComponentJson, goBack } = useLowcode({ formCode, type });\n\n const handleButtonClick = ({ item }: { item: ActionButton }) => {\n if (item.name === 'cancelButton') {\n goBack();\n }\n };\n\n onMounted(async () => {\n await getComponentJson([]);\n });\n</script>\n\n<style lang=\"less\"></style>\n"],"names":["formCode","id","type","getLocat","vfdRef","formConfig","getComponentJson","goBack","useLowcode","handleButtonClick","item","name","onMounted","_openBlock","_createElementBlock","_hoisted_1","_createVNode","_unref","TpfAddInfoLayout","title","footerRight","_createElementVNode","ActionButtonListRender","buttonList","ctx","context","onOnClick","VFormRender","ref","vfCtx","_id"],"mappings":";;;;;;;;;;;;;;;;;AA+BI,UAAM;AAAA,MAAEA,UAAAA,IAAW;AAAA,MAAIC,IAAAA,IAAK;AAAA,MAAIC,MAAAA,IAAO;AAAA,QAAWC,EAAQ,GAEpD;AAAA,MAAEC,QAAAA;AAAAA,MAAQC,YAAAA;AAAAA,MAAYC,kBAAAA;AAAAA,MAAkBC,QAAAA;AAAAA,QAAWC,EAAW;AAAA,MAAER,UAAAA;AAAAA,MAAUE,MAAAA;AAAAA,IAAK,CAAC,GAEhFO,IAAoBA,CAAC;AAAA,MAAEC,MAAAA;AAAAA,IAA6B,MAAM;AAC5D,MAAIA,EAAKC,SAAS,kBACdJ,EAAM;AAAA,IAEd;AAEAK,WAAAA,EAAU,YAAY;AAClB,YAAMN,EAAiB,CAAA,CAAE;AAAA,IAC7B,CAAC;;AA1CD,aAAAO,EAAA,GAAAC,EAYM,OAZNC,GAYM,CAXFC,EAUmBC,EAAAC,CAAA,GAAA;AAAA,QAVAC,QAAOF,IAAAA,EAAAZ,CAAA,MAAAY,gBAAAA,EAAYE;AAAAA;QAEvBC,eACP,MAAA;;AAAwB,kCAAxBC,EAAwB,OAAA;AAAA,YAAnBpB,IAAG;AAAA,aAAS,MAAA,EAAA,IACjBe,EAIEM,GAAA;AAAA,YAHGC,cAAYN,IAAAA,EAAAZ,CAAA,MAAAY,gBAAAA,EAAYM,eAAU,CAAA;AAAA,YAClCC,MAAKP,IAAAA,EAAAb,CAAA,MAAAa,gBAAAA,EAAQQ;AAAAA,YACbC,WAAUjB;AAAAA;;mBANnB,MAAwE,CAAxEO,EAAwEW,GAAA;AAAA,mBAAvD;AAAA,UAAJC,KAAIxB;AAAAA,UAAUyB,OAAK;AAAA,YAAAC,KAASb,EAAAhB,CAAA;AAAA,YAAE,GAAKgB,EAAAd,CAAA,EAAQ;AAAA,oBAAIc,EAAAV,CAAA;AAAA,UAAM;AAAA;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerModal.vue2.js","sources":["../../../../../src/components/public/CustomerModal/CustomerModal.vue"],"sourcesContent":["<template>\n <TpfConfigProvider>\n <TpfModal v-model:visible=\"visible\" v-bind=\"$attrs\" :title=\"title\" :leftNum=\"leftNum\">\n <Skeleton active :loading=\"isLoading\">\n <VFormRender :vfCtx=\"vfCtx\" ref=\"vfdRef\" />\n </Skeleton>\n <template #footerRight>\n <ActionButtonListRender\n :buttonList=\"formConfig?.buttonList || []\"\n :ctx=\"vfdRef?.context\"\n @on-click=\"handleButtonClick\"\n />\n
|
|
1
|
+
{"version":3,"file":"CustomerModal.vue2.js","sources":["../../../../../src/components/public/CustomerModal/CustomerModal.vue"],"sourcesContent":["<template>\n <TpfConfigProvider>\n <TpfModal v-model:visible=\"visible\" v-bind=\"$attrs\" :title=\"title\" :leftNum=\"leftNum\">\n <Skeleton active :loading=\"isLoading\">\n <VFormRender :vfCtx=\"vfCtx\" ref=\"vfdRef\" />\n </Skeleton>\n <template #footerRight>\n <ActionButtonListRender\n :buttonList=\"formConfig?.buttonList || []\"\n :ctx=\"vfdRef?.context\"\n @on-click=\"handleButtonClick\"\n />\n </template>\n </TpfModal>\n </TpfConfigProvider>\n</template>\n\n<script setup lang=\"tsx\">\n import { useLowcode } from '@/hooks/useLowcode';\n import { useAttrs, onMounted, nextTick, computed, getCurrentInstance, ref } from 'vue';\n import VFormRender from '@/components/FormRender/index.vue';\n import { TpfModal, TpfConfigProvider, useExecFunction } from 'tmgc2-share';\n import { Skeleton } from 'ant-design-vue';\n import { useI18n } from '@/utils/i18n';\n import ActionButtonListRender from '@/components/public/ActionButtonListRender.vue';\n\n const { i18nt } = useI18n();\n\n const instance = getCurrentInstance()!;\n\n const attrs = (useAttrs() || {}) as any;\n const visible = ref(false);\n\n type Props = {\n title: string;\n type: string;\n formCode: string;\n };\n\n const props = withDefaults(defineProps<Props>(), {});\n const vfCtx = computed(() => {\n return {\n $router: instance.proxy!.$router,\n _id: attrs?.row?.record?._id || null,\n type: props.type,\n instance,\n ...attrs\n };\n });\n const isDisabled = ref(false);\n const { vfdRef, formConfig, getComponentJson, isLoading } = useLowcode({\n formCode: props.formCode,\n type: props.type\n });\n const leftNum = ref(null);\n\n const title = computed(() => {\n if (props.title) return props.title;\n if (props.type === 'add') return '新增';\n if (props.type === 'edit') return '编辑';\n if (props.type === 'view') return '查看';\n return '新增';\n });\n\n const show = async () => {\n visible.value = true;\n await nextTick();\n await getComponentJson([]);\n console.log('attrs', attrs);\n };\n\n const setleftText = number => {\n leftNum.value = number;\n };\n\n const setDisabled = status => {\n isDisabled.value = status;\n };\n\n onMounted(() => {\n show();\n });\n\n const handleCloseDialog = () => {\n visible.value = false;\n };\n\n const handleButtonClick = async ({ item, result }: any) => {\n if (item.name === 'cancelButton') {\n return handleCloseDialog();\n }\n if (result !== false) {\n handleCloseDialog();\n }\n };\n\n defineExpose({\n handleCloseDialog,\n i18nt,\n setDisabled,\n setleftText\n });\n</script>\n\n<style lang=\"less\" scoped></style>\n"],"names":["i18nt","useI18n","instance","getCurrentInstance","attrs","useAttrs","visible","ref","props","__props","vfCtx","computed","$router","proxy","_id","row","record","type","isDisabled","vfdRef","formConfig","getComponentJson","isLoading","useLowcode","formCode","leftNum","title","show","value","nextTick","console","log","setleftText","number","setDisabled","status","onMounted","handleCloseDialog","handleButtonClick","item","result","name","__expose","_createBlock","_unref","TpfConfigProvider","_createVNode","_mergeProps","$event","$attrs","footerRight","ActionButtonListRender","buttonList","ctx","context","onOnClick","Skeleton","active","loading","VFormRender"],"mappings":";;;;;;;;;;;;;;;;;AA0BI,UAAM;AAAA,MAAEA,OAAAA;AAAAA,QAAUC,EAAO,GAEnBC,IAAWC,EAAkB,GAE7BC,IAASC,EAAQ,KAAM,CAAA,GACvBC,IAAUC,EAAI,EAAK,GAQnBC,IAAQC,GACRC,IAAQC,EAAS,MAAM;;AACzB,aAAO;AAAA,QACHC,SAASV,EAASW,MAAOD;AAAAA,QACzBE,OAAKV,KAAAA,IAAAA,KAAAA,gBAAAA,EAAOW,QAAPX,gBAAAA,EAAYY,WAAZZ,gBAAAA,EAAoBU,QAAO;AAAA,QAChCG,MAAMT,EAAMS;AAAAA,QACZf,UAAAA;AAAAA,QACA,GAAGE;AAAAA;IAEX,CAAC,GACKc,IAAaX,EAAI,EAAK,GACtB;AAAA,MAAEY,QAAAA;AAAAA,MAAQC,YAAAA;AAAAA,MAAYC,kBAAAA;AAAAA,MAAkBC,WAAAA;AAAAA,QAAcC,EAAW;AAAA,MACnEC,UAAUhB,EAAMgB;AAAAA,MAChBP,MAAMT,EAAMS;AAAAA,IAChB,CAAC,GACKQ,IAAUlB,EAAI,IAAI,GAElBmB,IAAQf,EAAS,MACfH,EAAMkB,QAAclB,EAAMkB,QAC1BlB,EAAMS,SAAS,QAAc,OAC7BT,EAAMS,SAAS,SAAe,OAC9BT,EAAMS,SAAS,SA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