Просмотр исходного кода

feat: 选择器和自定义弹窗选择时回显问题修复

johnsen 8 месяцев назад
Родитель
Сommit
a5f160900a

+ 8 - 29
.vscode/settings.json

@@ -1,34 +1,13 @@
 {
-  // 编辑器基础设置
-  "editor.tabSize": 2,
-  //配置eslint
-  "eslint.run": "onSave",
-  // 控制是否将打开的编辑器显示为预览。预览编辑器将会重用至其被保留(例如,通过双击或编辑),且其字体样式将为斜体。
-  "workbench.editor.enablePreview": false,
-  "workbench.colorCustomizations": {
-    "activityBar.background": "#332A3A",
-    "titleBar.activeBackground": "#473B52",
-    "titleBar.activeForeground": "#FBFAFB"
-  },
-  "eslint.enable": true,
   "editor.codeActionsOnSave": {
-    "source.fixAll.eslint": "explicit"
+    "source.fixAll.eslint": "explicit" // 保存时自动修复 ESLint 错误
   },
-
-  // 文件和搜索设置
-  "files.eol": "\n",
+  "editor.formatOnSave": true, // 保存时格式化
+  "editor.defaultFormatter": "esbenp.prettier-vscode", // 默认使用 Prettier
   "files.autoSave": "onFocusChange",
-  "search.exclude": {
-    "**/node_modules": true,
-    "**/dist": true
-  },
-
-  // ESLint设置
-  "eslint.validate": ["javascript", "javascriptreact", "vue"],
-  "eslint.workingDirectories": [{ "mode": "auto" }],
-
-  // Prettier设置
-  "prettier.configPath": ".prettierrc.json",
-  "prettier.requireConfig": true,
-  "editor.defaultFormatter": "esbenp.prettier-vscode"
+  "eslint.validate": ["javascript", "vue"], // 检查 .vue 文件
+  "vetur.validation.template": false, // 关闭 Vetur 的模板检查(由 ESLint 处理)
+  "[vue]": {
+    "editor.defaultFormatter": "esbenp.prettier-vscode" // Vue 文件用 Prettier 格式化
+  }
 }

+ 14 - 0
src/business/platform/data/templaterender/custom-dialog/index.vue

@@ -60,6 +60,12 @@ export default {
         return this.multiple ? [] : {}
       }
     },
+    scope: {
+      type: Object,
+      default() {
+        return {}
+      }
+    },
     templateKey: {
       // 数据模版key
       type: String
@@ -235,14 +241,22 @@ export default {
     handleLabel(data) {
       const config = this.labelKey
       if (typeof config === 'function') {
+        this.setLabelValue(config(data))
         return config(data)
       } else if (typeof config === 'string') {
+        this.setLabelValue(data[config])
         return data[config]
       } else if (typeof config === 'undefined') {
         const dataProp = data['name']
+        this.setLabelValue(dataProp === undefined ? '' : dataProp)
         return dataProp === undefined ? '' : dataProp
       }
     },
+    setLabelValue(val) {
+      if (this.scope.row && this.scope.column) {
+        this.scope.row[this.scope.column.prop + '_label_value'] = val
+      }
+    },
     /**
      * 初始化数据
      */

+ 6 - 3
src/business/platform/data/templaterender/templates/list.vue

@@ -94,6 +94,7 @@
         <ibps-user-selector
           v-if="$utils.isNotEmpty(scope.column)"
           v-model="scope.value"
+          :scope="scope"
           :type="scope.column.field_options.selector_type || 'user'"
           :multiple="
             $utils.toBoolean(scope.column.field_options.multiple, true)
@@ -108,6 +109,7 @@
         <ibps-custom-dialog
           v-if="$utils.isNotEmpty(scope.column)"
           v-model="scope.value"
+          :scope="scope"
           :template-key="scope.column.field_options.dialog"
           :multiple="
             $utils.toBoolean(scope.column.field_options.multiple, true)
@@ -379,9 +381,8 @@ import Scan from '@/views/system/jbdScan/scan.vue'
 import IbpsExport from '@/plugins/export'
 import IbpsImport from '@/plugins/import'
 import Vue from 'vue'
-Vue.component(
-  'ibps-data-template-render-dialog',
-  () => import('@/business/platform/data/templaterender/preview/dialog.vue')
+Vue.component('ibps-data-template-render-dialog', () =>
+  import('@/business/platform/data/templaterender/preview/dialog.vue')
 )
 import generalModules from '@/views/system/jbdScan/generalModules.vue'
 import { upload } from '@/api/upload/zip'
@@ -706,6 +707,7 @@ export default {
       this.$emit('selected', this.multiple ? [] : '')
     },
     handleSelectionChange(selection) {
+      console.log('row===>', selection)
       this.selection = selection
       setTimeout(() => {
         this.changePageCoreRecordData()
@@ -2271,6 +2273,7 @@ export default {
      */
     handleRowOneclick(row, event, column) {
       if (event.label !== '操作') {
+        console.log(row)
         this.setRowEvent('单击', row)
       }
     },

+ 4 - 1
src/business/platform/data/templaterender/utils/index.js

@@ -142,13 +142,16 @@ export function buildLinkLabelTitle(titleType = 'first', dataTitle, lableKey) {
     return function (data) {
       const d = dataTitle.split(/(\$[0-9a-zA-Z._]+#[0-9A-Fa-f]*)/g)
       const rtn = []
-
       d.forEach((n) => {
         let a = n
         if (/^\$(_widget_)/.test(n)) {
           // 对字段进行处理
           const f = n.replace('$_widget_', '').split('#')
+          console.log('dataTitle====>', f)
           a = data[f[0]] || ''
+          if (f[0] && data[f[0] + '_label_value']) {
+            a = data[f[0] + '_label_value']
+          }
         }
         rtn.push(a)
       })

+ 13 - 0
src/business/platform/org/selector/index.vue

@@ -69,6 +69,12 @@ export default {
       type: String,
       default: 'employee'
     },
+    scope: {
+      type: Object,
+      default() {
+        return {}
+      }
+    },
     value: {
       type: [String, Number, Array, Object]
     },
@@ -158,9 +164,11 @@ export default {
       if (this.$utils.isEmpty(this.selectorValue)) return []
       if (this.multiple) {
         return this.selectorValue.map((data) => {
+          this.setLabelValue(data[this.labelKey] || '')
           return data[this.labelKey] || ''
         })
       } else {
+        this.setLabelValue(this.selectorValue[this.labelKey] || '')
         return [this.selectorValue[this.labelKey] || '']
       }
     }
@@ -177,6 +185,11 @@ export default {
     }
   },
   methods: {
+    setLabelValue(val) {
+      if (this.scope.row && this.scope.column) {
+        this.scope.row[this.scope.column.prop + '_label_value'] = val
+      }
+    },
     /**
      * 初始化数据
      */

+ 3 - 0
src/components/ibps-selector/dialog.vue

@@ -229,6 +229,9 @@ export default {
   methods: {
     handleLabel(data) {
       const config = this.labelKey
+      if (data[this.labelKey + '_label_value']) {
+        return data[this.labelKey + '_label_value']
+      }
       if (typeof config === 'function') {
         return config(data)
       } else if (typeof config === 'string') {

+ 1 - 1
src/components/ibps-selector/selector.vue

@@ -26,7 +26,7 @@
               disable-transitions
               @close="deleteTag(index)"
             >
-              <span class="el-selector__tags-text">{{ item }}</span>
+              <span class="el-selector__tags-text" :data-label-value="item">{{ item }}</span>
             </el-tag>
             <el-tag
               v-else-if="tempSearch && index === 1"

+ 4 - 4
src/views/platform/data/dataTemplate/list.vue

@@ -69,8 +69,8 @@
                 scope.data.showType === 'list'
                   ? 'ibps-icon-table'
                   : scope.data.showType === 'tree'
-                    ? 'ibps-icon-tree'
-                    : 'ibps-icon-puzzle-piece'
+                  ? 'ibps-icon-tree'
+                  : 'ibps-icon-puzzle-piece'
               "
             />
           </template>
@@ -82,8 +82,8 @@
                   scope.data.showType === 'list'
                     ? 'ibps-icon-table'
                     : scope.data.showType === 'tree'
-                      ? 'ibps-icon-tree'
-                      : 'ibps-icon-puzzle-piece'
+                    ? 'ibps-icon-tree'
+                    : 'ibps-icon-puzzle-piece'
                 "
                 class="ibps-icon-stack-1x"
                 style="top: 5px"