Browse Source

fix: https://doc.weixin.qq.com/sheet/e3_ARAA_wbkAOcCN3i1eXa1TTCuhzXlb?scode=ANcAeQeGAAwz3UNRalARAA_wbkAOc&tab=BB08J2 8月5号

johnsen 9 months ago
parent
commit
7dce0f2c1c

+ 3 - 0
src/business/platform/data/data-template/field-formatter.vue

@@ -1,5 +1,6 @@
 <template>
   <div>
+    <!-- {{ data }} -->
     <span class="ibps-data-template-data" v-html="label || '/'" />
     <!-- <div>
       <div v-for="(item, i) in data" :key="i">
@@ -90,6 +91,7 @@ export default {
     initData() {
       if (!this.labelKey) return
       const value = this.data[this.labelKey]
+      // console.log('value==>', this.data)
       if (this.$utils.isEmpty(value)) {
         this.label = this.defaultValue
         return
@@ -474,6 +476,7 @@ export default {
       this.label = this.getLinkdataValue(__key, __linkKey, __linkText, value)
     },
     getLinkdataValue(key, __linkKey, __linkText, value) {
+      console.log('00000000000000')
       if (this.$utils.isEmpty(key)) {
         return value
       }

+ 12 - 4
src/business/platform/data/data-template/template.vue

@@ -303,8 +303,8 @@ export default {
   },
   watch: {
     values: {
-      handler() {
-        this.initData()
+      handler(val) {
+        val.length > 0 && this.initData()
       },
       deep: true,
       immediate: true
@@ -332,10 +332,15 @@ export default {
       },
       deep: true
       // immediate: true
+    },
+    visible: {
+      handler(val) {
+        val && this.loadData(this.params, true)
+      }
     }
   },
   mounted() {
-    this.loadData(this.params, true)
+    this.values && this.values.length > 0 && this.loadData(this.params, true)
   },
   methods: {
     setlabelKeys() {
@@ -488,16 +493,19 @@ export default {
               } else {
                 let b = {}
                 let key = ''
+
                 for (const k in d) {
                   b = {
                     label: '',
-                    bt: k,
+                    bt: this.labelKey || k,
                     val: {},
                     fieldType: 'linkdata',
                     fieldOptions: {}
                   }
+                  console.log('d===>', k)
                   key = k
                 }
+
                 b.val = d[key]
                 fb.showlabel = [b]
               }

+ 3 - 5
src/business/platform/data/templaterender/custom-dialog/index.vue

@@ -121,15 +121,13 @@ import {
   buildDataTemplateFields
 } from '@/business/platform/data/utils'
 import DataTemplatePopup from '@/business/platform/data/data-template/template'
-import FieldFormatter from '@/business/platform/data/data-template/field-formatter'
-import FieldFormatterr from '@/business/platform/data/data-template/field-formatter'
+// import FieldFormatter from '@/business/platform/data/data-template/field-formatter'
+// import FieldFormatterr from '@/business/platform/data/data-template/field-formatter'
 import { buildLabelTitle } from '../utils/index'
 export default {
   name: 'IbpsCustomDialog',
   components: {
-    DataTemplatePopup,
-    FieldFormatter,
-    FieldFormatterr
+    DataTemplatePopup
   },
   mixins: [FieldMixin],
   props: {

+ 2 - 2
src/business/platform/form/dynamic-form/form-field.vue

@@ -9,12 +9,12 @@
     :label="label"
     :placeholder="placeholder"
     :input-align="inputAlign"
-    :type="fieldType"
+    :type="fieldType === 'textarea' ? 'text' : fieldType"
     :required="required"
     :readonly="readonly"
     :rules="rules"
     :autosize="autosize"
-    :rows="fieldType === 'textarea' && (fieldOptions.rows || 2)"
+    :rows="1"
     :desc="field.desc"
     autocomplete="off"
     border

+ 7 - 0
src/business/platform/form/dynamic-form/form-table.vue

@@ -1096,6 +1096,13 @@ export default {
     color: #1989fa;
     cursor: pointer;
   }
+  ::v-deep .van-field {
+    padding-left: 0 !important;
+    padding-right: 0 !important;
+  }
+  ::v-deep .van-cell--required::before {
+    left: -8px !important;
+  }
   // ::v-deep .van-field__control {
   //   min-height: 36px;
   // }

+ 2 - 2
src/components/ibps-checkbox/index.vue

@@ -108,7 +108,7 @@
           :text-color="textColor"
           :plain="plain"
           size="medium"
-          ><div class="ibps-ellipsis">{{ item[labelKey] }}</div></van-tag
+          ><div>{{ item[labelKey] }}</div></van-tag
         >
         <van-tag
           v-if="selectedOptions.length > num"
@@ -130,7 +130,7 @@ import IbpsPickerToolbar from '@/components/ibps-picker-toolbar'
 import ActionUtils from '@/utils/action'
 
 export default {
-  name: 'ibps-checkbox',
+  name: 'IbpsCheckbox',
   components: {
     IbpsPickerToolbar
   },

+ 0 - 1
src/views/platform/data/dataTemplate/field-formatter.vue

@@ -159,7 +159,6 @@ export default {
         this.$utils.isEmpty(fieldOptions)
         // noFormateValueTypes.includes(fieldType)
       ) {
-        console.log('===>', this.labelKey)
         this.label = value
         return
       }

+ 89 - 98
src/views/platform/data/template-list.vue

@@ -47,11 +47,11 @@
       <!-- 设置过滤条件 -->
 
       <van-dropdown-menu class="menus" active-color="#3388FF">
-        <van-dropdown-item
+        <!-- <van-dropdown-item
           v-if="$utils.isNotEmpty(rangeData[rootIndex].options)"
           v-model="checkFilter"
           :options="rangeData[rootIndex].options"
-        />
+        /> -->
         <van-dropdown-item
           disabled
           title-class="menu-slot-text"
@@ -115,81 +115,66 @@
           :key="item[idKey] + index"
           class="ibps-p-0"
         >
-          <van-swipe-cell
-            :right-width="manages.length > 0 ? manages.length * 60 : 0"
-            :on-close="onClose"
-          >
-            <van-checkbox-group v-model="checkedIds">
-              <van-cell
-                border
-                style="padding: 15px 16px"
-                @click="onClick(item, index)"
-              >
-                <template slot="icon">
-                  <van-checkbox
-                    v-if="checkMode"
-                    ref="checkboxes"
-                    :name="item"
-                    class="ibps-mr-10"
-                  />
-                </template>
-                <!--标题-->
-                <template #title>
-                  <!-- {{ labelField['name'] }} 地点 -->
-                  <!-- {{ item }}  -->
-                  <!-- 默认第一行数据作为标题 -->
-                  <field-formatter
-                    v-if="labelField"
-                    class="titles"
-                    :label-key="labelField['name']"
-                    :data="item"
-                    :desc-field="labelField"
-                    :field-options="comFieldOptions(labelField['name'])"
-                    :field-type="comFieldType(labelField['name'])"
-                    :template-fields="templateFields"
-                  />
-                </template>
-                <!--描述展示 剩余数据作为描述-->
-                <template #label>
-                  <template v-if="$utils.isNotEmpty(descFields)">
-                    <!-- v-if="descField&&descField['name']&&item[descField['name']]" -->
-                    <div
-                      v-for="descField in descFields"
-                      :key="descField['name']"
-                      class="van-card-list__desc"
-                    >
-                      <van-row class="delayShow">
-                        <van-col span="6">{{ descField['label'] }}:</van-col>
-                        <van-col span="17">
-                          <field-formatter
-                            :label-key="descField['name']"
-                            :data="item"
-                            :field-options="comFieldOptions(descField['name'])"
-                            :field-type="comFieldType(descField['name'])"
-                            :template-fields="templateFields"
-                            :desc-field="descField"
-                            class="desc"
-                            default-value
-                          />
-                        </van-col>
-                      </van-row>
-                    </div>
-                  </template>
+          <van-checkbox-group v-model="checkedIds">
+            <van-cell
+              border
+              style="padding: 15px 16px"
+              @click="onClick(item, index)"
+            >
+              <template slot="icon">
+                <van-checkbox
+                  v-if="checkMode"
+                  ref="checkboxes"
+                  :name="item"
+                  class="ibps-mr-10"
+                />
+              </template>
+              <!--标题-->
+              <template #title>
+                <!-- {{ labelField['name'] }} 地点 -->
+                <!-- {{ item }}  -->
+                <!-- 默认第一行数据作为标题 -->
+                <field-formatter
+                  v-if="labelField"
+                  class="titles"
+                  :label-key="labelField['name']"
+                  :data="item"
+                  :desc-field="labelField"
+                  :field-options="comFieldOptions(labelField['name'])"
+                  :field-type="comFieldType(labelField['name'])"
+                  :template-fields="templateFields"
+                />
+              </template>
+              <!--描述展示 剩余数据作为描述-->
+              <template #label>
+                <template v-if="$utils.isNotEmpty(descFields)">
+                  <!-- v-if="descField&&descField['name']&&item[descField['name']]" -->
+                  <div
+                    v-for="descField in descFields"
+                    :key="descField['name']"
+                    class="van-card-list__desc"
+                  >
+                    <van-row class="delayShow">
+                      <van-col span="6">{{ descField['label'] }}:</van-col>
+                      <van-col span="17">
+                        <field-formatter
+                          :label-key="descField['name']"
+                          :data="item"
+                          :field-options="comFieldOptions(descField['name'])"
+                          :field-type="comFieldType(descField['name'])"
+                          :template-fields="templateFields"
+                          :desc-field="descField"
+                          class="desc"
+                          default-value
+                        />
+                      </van-col>
+                    </van-row>
+                  </div>
                 </template>
-              </van-cell>
-            </van-checkbox-group>
-            <!--删除-->
-            <template #right>
-              <van-button
-                v-for="button in manages"
-                :key="button.key"
-                :type="button.type"
-                :text="button.name"
-                class="ibps-swipe-button"
-                @click="handleAction(button, item)"
-              />
-            </template>
-          </van-swipe-cell>
+              </template>
+            </van-cell>
+          </van-checkbox-group>
+
           <div v-if="listData.length - 1 > index" class="ibps-blank-bar" />
         </van-cell>
       </van-list>
@@ -396,7 +381,8 @@ export default {
       defaultFilterListCol: ['di_dian_'],
       nameParams: {},
       format: {},
-      datePrefix: 'daterange-prefix'
+      datePrefix: 'daterange-prefix',
+      cilckEventButtons: []
     }
   },
   computed: {
@@ -422,9 +408,9 @@ export default {
         : { id: '' }
     },
     toolbarButtons() {
-      return this.toolbars.length > 4
-        ? this.toolbars.slice(0, 4)
-        : this.toolbars
+      const arrs = ['add', 'addPlus']
+      const filterAdd = this.toolbars.filter((t) => !arrs.includes(t.code))
+      return filterAdd.length > 4 ? filterAdd.slice(0, 4) : filterAdd
     },
     comFieldOptions() {
       return function (fieldLabel) {
@@ -443,9 +429,10 @@ export default {
       }
     },
     moreToolbarButtons() {
-      return this.toolbars.length > 4
-        ? this.toolbars.slice(4, this.toolbars.length)
-        : null
+      const arrs = ['add', 'addPlus']
+      const filterAdd = this.toolbars.filter((t) => !arrs.includes(t.code))
+      console.log('filterAdd===>', filterAdd)
+      return filterAdd.length > 4 ? filterAdd.slice(4, filterAdd.length) : null
     },
     hasToolbar() {
       return this.toolbars.length > 0 && this.$utils.isNotEmpty(this.listData)
@@ -694,7 +681,7 @@ export default {
           // 列表标题无设置则默认第一列
           this.labelField = titleCol || columns[0]
           this.columnsAttrs = columns
-          const notTitleCols = columns.filter((e, i) => {
+          const notTitleCols = columns.filter((e) => {
             return (
               this.labelField.label !== e.label &&
               !this.defaultFilterListCol.includes(e.name)
@@ -705,6 +692,7 @@ export default {
         }
         this.editButtons = template['buttons']['edit_buttons']
         this.functionButtons = template['buttons']['function_buttons']
+        this.cilckEventButtons = template['buttons']['click_event_buttons']
         // 按钮设置
         this.initToolbarAction()
       }
@@ -800,9 +788,9 @@ export default {
       }
      */
     loadData1() {
-      const customDialogCols = this.columnsAttrs.filter(
-        (t) => t.field_type === 'customDialog'
-      )
+      // const customDialogCols = this.columnsAttrs.filter(
+      //   (t) => t.field_type === 'customDialog'
+      // )
       if (this.$utils.isEmpty(this.templateKey)) {
         return
       }
@@ -979,8 +967,8 @@ export default {
     },
     // 默认显示字段列表
     initOptions(list) {
-      list.forEach((val, index) => {
-        console.log('tttt==>', val)
+      list.forEach((val) => {
+        // console.log('tttt==>', val)
         if (this.configKey === '') {
           this.chooseResult.push(val.label)
         }
@@ -1017,13 +1005,12 @@ export default {
     onClick(item, index) {
       if (this.checkMode) {
         this.$refs.checkboxes[index].toggle()
-      } else {
-        return
-        // this.gotoForm({
-        //   readonly: true,
-        //   pkValue: item[this.idKey]
-        // })
       }
+      // 取第一个配置按钮
+      // 点击行事件
+      const [btn] = this.cilckEventButtons
+      console.log('1111111', btn, this.manages)
+      btn && this.handleAction(btn, item)
     },
 
     generateTitle(name, title) {
@@ -1154,7 +1141,7 @@ export default {
       this.dialogFormVisible = true
     },
     handleRemove(ids) {
-      this.removeRecord(ids, (r) => {
+      this.removeRecord(ids, () => {
         this.checkMode = false
         this.checkedIds = []
       })
@@ -1191,8 +1178,12 @@ export default {
      */
     initToolbarAction() {
       const functionButtons = this.functionButtons || []
+      const cilckEventButtons = this.cilckEventButtons || []
       const toolbars = []
       const manages = []
+      this.cilckEventButtons = cilckEventButtons.map((rf, i) =>
+        this.buildButton(rf, i)
+      )
       // 功能按钮
       functionButtons.forEach((rf, i) => {
         const btn = this.buildButton(rf, i)
@@ -1279,7 +1270,7 @@ export default {
         deflow: rf.deflow || null,
         mode: mode,
         rightIcon: rightIcon,
-        initAddDataCont: rf.initAddDataCont ? obj : null,
+        initAddDataCont: rf.initAddDataCont || null,
         menus: menus,
         disabled: disabled,
         hidden: hidden,
@@ -1301,7 +1292,7 @@ export default {
       }
       return false
     },
-    customCallback(item) {
+    customCallback() {
       this.beforeSubmit('custom')
       // TODO 后面是自定义按钮的事
     },

+ 56 - 10
src/views/system/dashboard/index.vue

@@ -162,7 +162,7 @@ import ActionUtils from '@/utils/action'
 // import navbar from '@/mixins/navbar'
 import { Lazyload } from 'vant'
 Vue.use(Lazyload)
-import TreeUtils from '@/utils/tree'
+// import TreeUtils from '@/utils/tree'
 import i18n from '@/utils/i18n' // Internationalization 国际化
 import IbpsAvatar from '@/components/ibps-avatar'
 import NoticeDialog from '@/views/platform/notice/edit'
@@ -268,8 +268,8 @@ export default {
             const listData = data.filter((d) => {
               return d.id !== '0' && d.displayInMenu === 'Y'
             })
-            listData.sort((a, b) => a.id * 1 - b.id * 1)
-            this.dashboards = TreeUtils.transformToTreeFormat(listData, {
+            // listData.sort((a, b) => a.id * 1 - b.id * 1)
+            this.dashboards = this.toTree(listData, {
               idKey: this.idKey,
               parentIdKey: this.parentIdKey,
               childrenKey: this.childrenKey
@@ -290,6 +290,52 @@ export default {
           })
       }
     },
+    toTree(
+      data,
+      options = {
+        idKey: 'id',
+        parentIdKey: '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[options.childrenKey] = [] // 初始化子节点数组
+        map.set(item[options.idKey], item)
+      })
+      // 第二遍遍历:建立父子关系
+      data1.forEach((item) => {
+        const parentId = item[options.parentIdKey]
+        // 处理根节点(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
+    },
     loadCountInfo() {
       getInfoCount({}, false)
         .then((response) => {
@@ -304,7 +350,7 @@ export default {
             this.countInfo = countInfo
           })
         })
-        .catch((e) => {})
+        .catch(() => {})
     },
 
     loadNotice() {
@@ -318,7 +364,7 @@ export default {
           this.noticeList = response.data.dataResult
           this.emptyNoticeData = !(this.noticeList.length > 0)
         })
-        .catch((e) => {
+        .catch(() => {
           this.emptyNoticeData = true
         })
     },
@@ -367,7 +413,7 @@ export default {
       const that = this
       let mid = []
       let objArr1 = {}
-      return new Promise((resolve, reject) => {
+      return new Promise((resolve) => {
         findAllByCurrUserId({}, false)
           .then((res) => {
             const data = res.data || []
@@ -379,7 +425,7 @@ export default {
               const mint = new Date(
                 this.$common.getFormatDate('string', 19, timeTime)
               ).getTime()
-              data.forEach((item, i) => {
+              data.forEach((item) => {
                 const st = new Date(item.startTime + ' 00:00:00').getTime()
                 const et = new Date(item.endTime + ' 24:00:00').getTime()
                 if (
@@ -399,7 +445,7 @@ export default {
                 const vdata = resp.variables.data || []
                 if (vdata.length > 0) {
                   objArr1 = {}
-                  vdata.forEach((item, i) => {
+                  vdata.forEach((item) => {
                     const dArr = this.generationDate(
                       item.start_date_,
                       item.end_date_
@@ -436,10 +482,10 @@ export default {
                 console.log(objArr1)
                 resolve(mid.length + objArr1[time].num)
               })
-              .catch((e) => {})
+              .catch(() => {})
             // resolve(data)
           })
-          .catch((e) => {
+          .catch(() => {
             // this.emptyNoticeData = true
           })
       })