فهرست منبع

feat: 添加移动端点击配置与修复树刷新报错问题

johnsen 9 ماه پیش
والد
کامیت
ff3c744b88

+ 22 - 0
src/business/platform/data/templatebuilder/right-aside/settings/list.vue

@@ -112,6 +112,28 @@
         />
       </template>
     </button-template>
+    <!-- 移动端点击配置(只支持编辑和审阅) -->
+    <button-template
+      :template="buttons"
+      :data="template"
+      :types="['edit', 'detail', 'custom']"
+      :default-value="fucntionButtonDefaultValue"
+      title="移动端点击配置"
+      call-module="list"
+      prop="click_event_buttons"
+      @input="handleButtons"
+      @callbackField="handleAttrs"
+    >
+      <template slot="edit" slot-scope="scope">
+        <editor-button
+          :data="scope.data"
+          :template="template"
+          :form-key="formKey"
+          type="function"
+          @callback="handleAttrs"
+        />
+      </template>
+    </button-template>
     <!--编辑页-功能按钮-->
     <button-template
       :template="buttons"

+ 9 - 30
src/business/platform/form/formbuilder/right-aside/propertys/index.vue

@@ -219,10 +219,15 @@
             content="跟PC端一致"
             placement="bottom"
           >
-            <el-switch v-model="isSame" @change="changeSame" />
+            <el-switch
+              v-model="formDef.attrs.same"
+              active-value="Y"
+              inactive-value="N"
+              @change="changeSame"
+            />
           </el-tooltip>
         </div>
-        <div v-if="!isSame" class="panel-body">
+        <div v-if="formDef.attrs.same === 'N'" class="panel-body">
           <el-form-item label="标签宽度">
             <el-row>
               <el-col :span="12">
@@ -367,10 +372,6 @@ export default {
         name: [{ required: true, message: this.$t('validate.required') }],
         key: [{ required: true, message: this.$t('validate.required') }]
       },
-      same:
-        this.formDef && this.formDef.attrs
-          ? this.$utils.toBoolean(this.formDef.attrs.same, true)
-          : true,
       labelSuf:
         this.formDef && this.formDef.attrs
           ? this.formDef.attrs.labelSuffix || ''
@@ -386,15 +387,6 @@ export default {
         ? this.formDef.attrs.mobile_script || ''
         : this.formDef.attrs.script || ''
     },
-    isSame: {
-      get() {
-        return this.$utils.toBoolean(this.same, true)
-      },
-      set(val) {
-        this.same = val
-        this.$set(this.formDef.attrs, 'same', this.isSame)
-      }
-    },
     labelSuffix: {
       get() {
         return this.labelSuf
@@ -409,6 +401,7 @@ export default {
     data: {
       handler: function (val, oldVal) {
         this.formDef = this.data
+        this.$set(this.formDef.attrs, 'same', this.formDef.attrs.same || 'Y')
       },
       immediate: true,
       deep: true
@@ -419,20 +412,6 @@ export default {
       },
       deep: true
     },
-    same: {
-      handler(val, oldVal) {
-        if (this.$utils.isEmpty(this.formDef.attrs.same)) {
-          this.isSame = true
-          this.$set(this.formDef.attrs, 'same', this.isSame)
-        } else {
-          if (val !== oldVal) {
-            this.isSame = val
-            this.$set(this.formDef.attrs, 'same', this.isSame)
-          }
-        }
-      },
-      immediate: true
-    },
     labelSuf: {
       handler(val, oldVal) {
         if (this.$utils.isEmpty(this.formDef.attrs.labelSuffix)) {
@@ -457,7 +436,7 @@ export default {
       this.labelSuf = this.formDef.attrs.labelSuffix
     },
     changeSame(value) {
-      if (!value) {
+      if (value === 'N' && !this.formDef.attrs.mobileLabelWidth) {
         this.formDef.attrs = Object.assign({}, this.formDef.attrs, {
           mobileLabelWidth: 100,
           mobileLabelWidthUnit: 'px',

+ 42 - 5
src/views/platform/org/position/manage.vue

@@ -184,11 +184,43 @@ export default {
     //     })
     // },
     toTree(data) {
-      return TreeUtils.transformToTreeFormat(data, {
-        idKey: 'id',
-        pIdKey: 'parentId',
-        childrenKey: 'children'
+      // return TreeUtils.transformToTreeFormat(data, {
+      //   idKey: 'id',
+      //   pIdKey: 'parentId',
+      //   childrenKey: 'children'
+      // })
+      const data1 = JSON.parse(JSON.stringify(data))
+      const map = new Map()
+      const tree = []
+      // 第一遍遍历:将所有节点存入映射表,并初始化children数组
+      data1.forEach((item) => {
+        item.children = [] // 初始化子节点数组
+        map.set(item.id, item)
       })
+      // 第二遍遍历:建立父子关系
+      data1.forEach((item) => {
+        const parentId = item.parentId
+        // 处理根节点(parentId为null)
+        if (parentId === null) {
+          // 检查根节点是否已存在(id为"0"的节点)
+          if (item.id === '0') {
+            tree.push(item)
+          }
+          return
+        }
+        // 查找父节点
+        if (map.has(parentId)) {
+          const parent = map.get(parentId)
+          // console.log('22222==>', parent)
+          parent.children.push(item)
+          // 更新父节点的hasChild属性
+          parent.hasChild = true
+        } else {
+          // 处理孤立节点(没有找到父节点)
+          tree.push(item)
+        }
+      })
+      return tree
     },
     refreshTree() {
       this.init()
@@ -287,7 +319,12 @@ export default {
     },
     // 查询
     search() {
-      this.$refs.tree.refreshNode(this.parentId)
+      // 如果有父节点则刷新父节点如果没有刷新整个树
+      if (this.parentId) {
+        this.$refs.tree.refreshNode(this.parentId)
+      } else {
+        this.$refs.tree.handleActionEvent({ key: 'refresh' }, 'toolbar')
+      }
     },
     handleNodeSort(data) {
       getTreeData({