Jelajahi Sumber

扩展objp onchange

Ben 1 Minggu lalu
induk
melakukan
cb2c9d0357
1 mengubah file dengan 216 tambahan dan 216 penghapusan
  1. 216 216
      js/vue/ss-components.js

+ 216 - 216
js/vue/ss-components.js

@@ -263,17 +263,17 @@ import { EVEN_VAR } from "./EventBus.js";
 
       // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
       watch(
-        () => props.errTip,
-        (newVal) => {
-          errMsg.value = newVal;
-        },
-        { immediate: true }
+          () => props.errTip,
+          (newVal) => {
+            errMsg.value = newVal;
+          },
+          { immediate: true }
       );
       watch(
-        () => props.modelValue,
-        (newVal) => {
-          inputValue.value = newVal;
-        }
+          () => props.modelValue,
+          (newVal) => {
+            inputValue.value = newVal;
+          }
       );
 
       // 挂载时的逻辑
@@ -427,14 +427,14 @@ import { EVEN_VAR } from "./EventBus.js";
 
         // 构建参数字符串
         var str =
-          "&nrid=T-" +
-          fjid.value +
-          "&objectId=" +
-          fjid.value +
-          "&objectName=" +
-          fjName +
-          "&callback=" +
-          (window["fjidCallbackName"] || "");
+            "&nrid=T-" +
+            fjid.value +
+            "&objectId=" +
+            fjid.value +
+            "&objectName=" +
+            fjName +
+            "&callback=" +
+            (window["fjidCallbackName"] || "");
 
         console.log("str", str);
 
@@ -491,7 +491,7 @@ import { EVEN_VAR } from "./EventBus.js";
       // 如果有附件按钮,为按钮留出空间
       if (this.fj || (this.param&&this.param.button)) {//加上&&this.param.button条件 Ben(20251221)
         mainTextareaStyle.paddingRight = '75px';
-        
+
       }
 
       const mainTextareaRows = this.height ? Math.floor(parseFloat('80px') / 20) : 1
@@ -519,38 +519,38 @@ import { EVEN_VAR } from "./EventBus.js";
             }),
             // 附件按钮(优先使用 param,兼容旧的 fj)
             this.fj||(this.param&&this.param.button)//加上&&this.param.button条件 Ben(20251221)
-              ? h(
-                  "button",
-                  {
-                    type: "button",
-                    class: "fj-button",
-                    onClick: this.param ? this.onAttachmentClick : (e) => {
-                      e.preventDefault();
-                      console.log("附件配置:", this.fj);
+                ? h(
+                    "button",
+                    {
+                      type: "button",
+                      class: "fj-button",
+                      onClick: this.param ? this.onAttachmentClick : (e) => {
+                        e.preventDefault();
+                        console.log("附件配置:", this.fj);
+                      },
                     },
-                  },
-                  [
-                   
+                    [
+
                       h(SsEditorIcon, {
                         class: "editor-icon-link",
                       }),
                       h("span", { class: "fj-button-text" }, "附件")
-                    
-                  ]
+
+                    ]
                 )
-              : null,
+                : null,
             // this.showRequired ? h("div", { class: "required" }) : null,
           ]),
           this.contentFloatingDiv || ""
-            ? h("div", {
+              ? h("div", {
                 class: "floating-div",
                 style: this.floatingDivPosition === "bottom"
-                  ? {
+                    ? {
                       // 向下展开: 覆盖原输入框,top对齐首行
                       top: this.getFloatingDivTop,
                       bottom: 'auto',
                     }
-                  : {
+                    : {
                       // 向上展开: 同样覆盖原输入框,但从底部开始计算
                       top: 'auto',
                       bottom: this.height ? '5px' : '6px', // 对齐到原textarea的底部padding位置
@@ -572,7 +572,7 @@ import { EVEN_VAR } from "./EventBus.js";
                   },
                 }),
               ])
-            : null,
+              : null,
           // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
         ]),
         // 附件相关的隐藏字段(仅在有 param 时才渲染)
@@ -943,17 +943,17 @@ import { EVEN_VAR } from "./EventBus.js";
           }
         });
 
-        callGlobalOnchg(item.value); // 值变化时尝试调用全局onchange回调函数 Ben(20251217)
+        callGlobalOnchg(item.value,item.label); // 值变化时尝试调用全局onchange回调函数 Ben(20251217)
       };
 
       // 用于调用全局onchange回调函数 Ben(20251217)
-      const callGlobalOnchg = (value) => {
+      const callGlobalOnchg = (value,desc) => {
         // 检查 onchange 属性是否提供了有效的函数名
         if (props.onchange && typeof props.onchange === 'string') {
           // 检查 window 对象上是否存在该函数
           if (typeof window !== 'undefined' && window[props.onchange] && typeof window[props.onchange] === 'function') {
             try {
-              window[props.onchange](value) // 调用全局函数,并传入当前选中值
+              window[props.onchange](value,desc) // 调用全局函数,并传入当前选中值
             } catch (error) {
               console.error(`调用全局函数 ${props.onchange} 时出错:`, error)
             }
@@ -3479,8 +3479,8 @@ import { EVEN_VAR } from "./EventBus.js";
         if (props.url ) {
           const params = new URLSearchParams();
 
-        if(mode)
-          params.append("mode", mode);
+          if(mode)
+            params.append("mode", mode);
 
           if(props.modelValue)
             params.append("path", props.modelValue);
@@ -5750,9 +5750,9 @@ import { EVEN_VAR } from "./EventBus.js";
    * SsSubTab 左侧菜单+iframe内容组件
    * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
    */
-	  const SsSubTab = {
-	    name: "SsSubTab",
-	    props: {
+  const SsSubTab = {
+    name: "SsSubTab",
+    props: {
       menuList: {
         type: Array,
         required: true,
@@ -5775,144 +5775,144 @@ import { EVEN_VAR } from "./EventBus.js";
         default: 'collapse',
       },
     },
-	    emits: ["menu-change", "footer-click"],
-	    setup(props, { emit }) {
-	      // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
-	      const defaultIcons = [
-	        'icon-obj-ry',       // 人员
-	        'icon-obj-dw',       // 单位
-	        'icon-obj-gw',       // 岗位
-	        'icon-biz-rc',       // 人才
-	        'icon-biz-xc',       // 巡查
-	        'icon-biz-cl',       // 材料
-	        'icon-biz-men',      // 门
-	        'icon-obj-xy'        // 协议
-	      ];
-	      //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
-	      const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
-	      const resolveIconClass = (iconNameOrClass, fallbackIndex) => { //功能 by xu 20251222
-	        const fallback = `menu-icon ${defaultIcons[fallbackIndex % defaultIcons.length]}`;
-	        if (!iconNameOrClass) {
-	          return fallback;
-	        }
-	        // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
-	        if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
-	          return iconNameOrClass;
-	        }
-	        const iconName = iconNameOrClass;
-	        if (iconName === "menu-icon" || iconName === "menu-base-icon") {
-	          return fallback;
-	        }
-	        // 业务图标库:icon-biz / icon-obj -> menu-icon
-	        if (
-	            typeof iconName === "string" &&
-	            (iconName.indexOf("icon-obj-") === 0 || iconName.indexOf("icon-biz-") === 0)
-	        ) {
-	          return `menu-icon ${iconName}`;
-	        }
-	        // 默认认为是 icon-base 图标 -> menu-base-icon
-	        return `menu-base-icon ${iconName}`;
-	      };
-	      const getMenuIcon = (item, index) => { //功能 by xu 20251222
-	        if (!item) {
-	          return resolveIconClass(null, index);
-	        }
-	        //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
-	        if (item.title === "变动" || item.name === "sys_bd") {
-	          return resolveIconClass("icon-chg", index);
-	        }
-	        // 兼容旧字段 icon(优先使用)
-	        if (item.icon) return resolveIconClass(item.icon, index);
-	        // v3.0 使用后端下发 iconName
-	        if (item.iconName) return resolveIconClass(item.iconName, index);
-	        return resolveIconClass(null, index);
-	      };
-
-	      //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
-	      const getFooterIcon = (button) => { //功能 by xu 20251224
-	        if (!button) return "menu-base-icon icon-save";
-	        const iconNameOrClass = button.iconClass || button.iconName || button.icon;
-	        if (!iconNameOrClass) return "menu-base-icon icon-save";
-	        if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
-	          return iconNameOrClass;
-	        }
-	        return `menu-base-icon ${iconNameOrClass}`;
-	      };
-
-	      //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
-	      const normalizeMenuList = (rawList) => {
-	        if (!Array.isArray(rawList) || rawList.length === 0) {
-	          return [];
-	        }
-	        const hasTree = rawList.some((it) => Array.isArray(it?.children) && it.children.length > 0);
-	        if (hasTree) {
-	          return rawList.map((it) => ({
-	            ...it,
-	            __level: 1,
-	            children: Array.isArray(it.children)
-	                ? it.children.map((c) => ({ ...c, __level: 2 }))
-	                : it.children,
-	          }));
-	        }
-	        const hasMarker = rawList.some((it) => it && ("pobj" in it || "cobj" in it));
-	        if (!hasMarker) {
-	          return rawList.map((it) => ({ ...it, __level: 1 }));
-	        }
-	        const result = [];
-	        let currentGroup = null;
-	        for (const item of rawList) {
-	          //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
-	          const isChgItem = item && (item.title === "变动" || item.name === "sys_bd");
-	          if (isChgItem) {
-	            result.push({ ...item, __level: 1 });
-	            continue;
-	          }
-	          const isParent = isTrue(item?.pobj);
-	          const isChild = isTrue(item?.cobj);
-	          if (isParent) {
-	            currentGroup = {
-	              ...item,
-	              __level: 1,
-	              children: [],
-	            };
-	            result.push(currentGroup);
-	            continue;
-	          }
-	          if (isChild && currentGroup) {
-	            currentGroup.children.push({ ...item, __level: 2 });
-	            continue;
-	          }
-	          //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
-	          result.push({ ...item, __level: 1 });
-	        }
-	        return result;
-	      };
-	      const menuListComputed = computed(() => normalizeMenuList(props.menuList)); //功能 by xu 20251222
-	      //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
-	      const groupOpenState = reactive({}); // { [key]: boolean }
-	      const getGroupKey = (item) => (item?.name || item?.title || ""); //功能 by xu 20251222
-	      const isGroupOpen = (item) => { //功能 by xu 20251222
-	        const key = getGroupKey(item);
-	        if (!key) return true;
-	        return groupOpenState[key] !== false;
-	      };
-	      const toggleGroupOpen = (item) => { //功能 by xu 20251222
-	        const key = getGroupKey(item);
-	        if (!key) return;
-	        groupOpenState[key] = !isGroupOpen(item);
-	      };
-	      const getLevelClass = (item, fallbackLevel) => { //功能 by xu 20251222
-	        //功能: “变动”始终按一级样式处理 by xu 20251223
-	        if (item && (item.title === "变动" || item.name === "sys_bd")) {
-	          return "level-1";
-	        }
-	        const level = item?.__level || fallbackLevel || 1;
-	        return level === 2 ? "level-2" : "level-1";
-	      };
-
-	      // v3.0 新增:菜单模式管理 by xu 20251216
-	      const menuMode = ref(props.initialMode);
-	      const isHovering = ref(false);
+    emits: ["menu-change", "footer-click"],
+    setup(props, { emit }) {
+      // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
+      const defaultIcons = [
+        'icon-obj-ry',       // 人员
+        'icon-obj-dw',       // 单位
+        'icon-obj-gw',       // 岗位
+        'icon-biz-rc',       // 人才
+        'icon-biz-xc',       // 巡查
+        'icon-biz-cl',       // 材料
+        'icon-biz-men',      // 门
+        'icon-obj-xy'        // 协议
+      ];
+      //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
+      const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
+      const resolveIconClass = (iconNameOrClass, fallbackIndex) => { //功能 by xu 20251222
+        const fallback = `menu-icon ${defaultIcons[fallbackIndex % defaultIcons.length]}`;
+        if (!iconNameOrClass) {
+          return fallback;
+        }
+        // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
+        if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
+          return iconNameOrClass;
+        }
+        const iconName = iconNameOrClass;
+        if (iconName === "menu-icon" || iconName === "menu-base-icon") {
+          return fallback;
+        }
+        // 业务图标库:icon-biz / icon-obj -> menu-icon
+        if (
+            typeof iconName === "string" &&
+            (iconName.indexOf("icon-obj-") === 0 || iconName.indexOf("icon-biz-") === 0)
+        ) {
+          return `menu-icon ${iconName}`;
+        }
+        // 默认认为是 icon-base 图标 -> menu-base-icon
+        return `menu-base-icon ${iconName}`;
+      };
+      const getMenuIcon = (item, index) => { //功能 by xu 20251222
+        if (!item) {
+          return resolveIconClass(null, index);
+        }
+        //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
+        if (item.title === "变动" || item.name === "sys_bd") {
+          return resolveIconClass("icon-chg", index);
+        }
+        // 兼容旧字段 icon(优先使用)
+        if (item.icon) return resolveIconClass(item.icon, index);
+        // v3.0 使用后端下发 iconName
+        if (item.iconName) return resolveIconClass(item.iconName, index);
+        return resolveIconClass(null, index);
+      };
+
+      //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
+      const getFooterIcon = (button) => { //功能 by xu 20251224
+        if (!button) return "menu-base-icon icon-save";
+        const iconNameOrClass = button.iconClass || button.iconName || button.icon;
+        if (!iconNameOrClass) return "menu-base-icon icon-save";
+        if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
+          return iconNameOrClass;
+        }
+        return `menu-base-icon ${iconNameOrClass}`;
+      };
+
+      //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
+      const normalizeMenuList = (rawList) => {
+        if (!Array.isArray(rawList) || rawList.length === 0) {
+          return [];
+        }
+        const hasTree = rawList.some((it) => Array.isArray(it?.children) && it.children.length > 0);
+        if (hasTree) {
+          return rawList.map((it) => ({
+            ...it,
+            __level: 1,
+            children: Array.isArray(it.children)
+                ? it.children.map((c) => ({ ...c, __level: 2 }))
+                : it.children,
+          }));
+        }
+        const hasMarker = rawList.some((it) => it && ("pobj" in it || "cobj" in it));
+        if (!hasMarker) {
+          return rawList.map((it) => ({ ...it, __level: 1 }));
+        }
+        const result = [];
+        let currentGroup = null;
+        for (const item of rawList) {
+          //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
+          const isChgItem = item && (item.title === "变动" || item.name === "sys_bd");
+          if (isChgItem) {
+            result.push({ ...item, __level: 1 });
+            continue;
+          }
+          const isParent = isTrue(item?.pobj);
+          const isChild = isTrue(item?.cobj);
+          if (isParent) {
+            currentGroup = {
+              ...item,
+              __level: 1,
+              children: [],
+            };
+            result.push(currentGroup);
+            continue;
+          }
+          if (isChild && currentGroup) {
+            currentGroup.children.push({ ...item, __level: 2 });
+            continue;
+          }
+          //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
+          result.push({ ...item, __level: 1 });
+        }
+        return result;
+      };
+      const menuListComputed = computed(() => normalizeMenuList(props.menuList)); //功能 by xu 20251222
+      //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
+      const groupOpenState = reactive({}); // { [key]: boolean }
+      const getGroupKey = (item) => (item?.name || item?.title || ""); //功能 by xu 20251222
+      const isGroupOpen = (item) => { //功能 by xu 20251222
+        const key = getGroupKey(item);
+        if (!key) return true;
+        return groupOpenState[key] !== false;
+      };
+      const toggleGroupOpen = (item) => { //功能 by xu 20251222
+        const key = getGroupKey(item);
+        if (!key) return;
+        groupOpenState[key] = !isGroupOpen(item);
+      };
+      const getLevelClass = (item, fallbackLevel) => { //功能 by xu 20251222
+        //功能: “变动”始终按一级样式处理 by xu 20251223
+        if (item && (item.title === "变动" || item.name === "sys_bd")) {
+          return "level-1";
+        }
+        const level = item?.__level || fallbackLevel || 1;
+        return level === 2 ? "level-2" : "level-1";
+      };
+
+      // v3.0 新增:菜单模式管理 by xu 20251216
+      const menuMode = ref(props.initialMode);
+      const isHovering = ref(false);
 
       const toggleMenuMode = () => {
         menuMode.value = menuMode.value === 'collapse' ? 'fixed' : 'collapse';
@@ -5980,17 +5980,17 @@ import { EVEN_VAR } from "./EventBus.js";
       // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
       const loadedMenus = ref(new Set());
 
-	      const isMenuLoaded = (menuName) => {
-	        return loadedMenus.value.has(menuName);
-	      };
-
-	      // 根据标题找到对应的菜单项
-	      const findMenuByTitle = (title) => {
-	        for (const item of menuListComputed.value) { //功能 by xu 20251222
-	          if (item.children?.length > 0) {
-	            const child = item.children.find((c) => c.title === title);
-	            if (child) return child;
-	          } else if (item.title === title) {
+      const isMenuLoaded = (menuName) => {
+        return loadedMenus.value.has(menuName);
+      };
+
+      // 根据标题找到对应的菜单项
+      const findMenuByTitle = (title) => {
+        for (const item of menuListComputed.value) { //功能 by xu 20251222
+          if (item.children?.length > 0) {
+            const child = item.children.find((c) => c.title === title);
+            if (child) return child;
+          } else if (item.title === title) {
             return item;
           }
         }
@@ -6046,26 +6046,26 @@ import { EVEN_VAR } from "./EventBus.js";
         emit("footer-click", { button, index });
       };
 
-	      return {
-	        menuListComputed, //功能 by xu 20251222
-	        currentMenu,
-	        selectItem,
-	        handleFooterClick,
-	        getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
-	        menuMode,
-	        isHovering,
-	        isExpanded,
-	        toggleMenuMode,
-	        onMouseEnter,
-	        onMouseLeave,
-	        isMenuLoaded,
-	        getMenuIcon,
-	        isGroupOpen, //功能 by xu 20251222
-	        toggleGroupOpen, //功能 by xu 20251222
-	        getLevelClass, //功能 by xu 20251222
-	      };
-	    },
-	    template: `
+      return {
+        menuListComputed, //功能 by xu 20251222
+        currentMenu,
+        selectItem,
+        handleFooterClick,
+        getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
+        menuMode,
+        isHovering,
+        isExpanded,
+        toggleMenuMode,
+        onMouseEnter,
+        onMouseLeave,
+        isMenuLoaded,
+        getMenuIcon,
+        isGroupOpen, //功能 by xu 20251222
+        toggleGroupOpen, //功能 by xu 20251222
+        getLevelClass, //功能 by xu 20251222
+      };
+    },
+    template: `
 	          <div class="project-edit-container">
               <div class="left-side"
                    v-if="leftDisplay"
@@ -6632,16 +6632,16 @@ import { EVEN_VAR } from "./EventBus.js";
       app.component(componentName, EchartComponents[componentName]);
     }
     // 挂载 Vue 应用
-    let vm ; 
+    let vm ;
     try {
-    	vm = app.mount(el);
+      vm = app.mount(el);
       vm.data = vueOptions.data();
       console.log("vm:",vm)
       console.log("vueOptions:",vueOptions)
     } catch (error) {
       alert('Mount failed:'+ error);//vue Mount失败报错 Ben(20251206)
     }
-    
+
 
     return vm;
   };