Przeglądaj źródła

fix: 列表渲染迁移

johnsen 6 miesięcy temu
rodzic
commit
671abf1464

+ 1 - 14
src/business/platform/bpmn/form/dialog.vue

@@ -1,6 +1,6 @@
 <template>
   <van-popup
-    v-model="dialogVisible"
+    v-model="visible"
     class="ibps-fullscreen-popup"
     position="bottom"
     @opened="loadFormData"
@@ -60,19 +60,6 @@ export default {
     },
     title: String
   },
-  data() {
-    return {
-      dialogVisible: this.visible
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-      },
-      immediate: true
-    }
-  },
   methods: {
     loadFormData() {
       this.$nextTick(() => {

+ 106 - 75
src/business/platform/data/data-template/field-formatter.vue

@@ -1,6 +1,11 @@
 <template>
   <div>
-    <span class="ibps-data-template-data" v-html="label" />
+    <!-- {{ data }} -->
+    <span
+      :data-field-type="newFieldType"
+      class="ibps-data-template-data"
+      v-html="label || '/'"
+    />
     <!-- <div>
       <div v-for="(item, i) in data" :key="i">
         <span v-if="item.label">{{ item.label }}</span>
@@ -21,6 +26,7 @@ import { get as getOrgById } from '@/api/platform/org/org'
 import { get as getPositionById } from '@/api/platform/org/position'
 import { get as getRoleById } from '@/api/platform/org/role'
 import { get as getAttachmentById } from '@/api/platform/file/attachment'
+import { remoteRequest } from '@/utils/remote'
 import {
   queryDataById as getDataById,
   queryLinkageData as getLinkDataByKey
@@ -61,6 +67,7 @@ export default {
     },
     fieldType: String,
     fieldOptions: Object,
+    descField: Object,
     tem: Object,
     tag: String
   },
@@ -70,7 +77,8 @@ export default {
       roleList,
       deptList,
       userList,
-      label: ''
+      label: '',
+      newFieldType: ''
     }
   },
   watch: {
@@ -88,6 +96,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
@@ -97,8 +106,15 @@ export default {
         this.label = value
         return
       }
-      const fieldType = this.fieldType
-      const fieldOptions = this.fieldOptions
+      const fieldType =
+        this.descField && this.descField.same === 'N'
+          ? this.descField.field_type
+          : this.fieldType
+      const fieldOptions =
+        this.descField && this.descField.same === 'N'
+          ? this.descField.field_options
+          : this.fieldOptions
+      this.newFieldType = fieldType
       if (
         this.$utils.isEmpty(value) ||
         this.$utils.isEmpty(fieldType) ||
@@ -220,15 +236,17 @@ export default {
           'name'
         )
       } else {
-        getDictionaryData({
-          typeKey: key
+        remoteRequest('formTemplate', { key }, () => {
+          return getDictionaryData({
+            typeKey: key
+          })
         })
-          .then(response => {
+          .then((response) => {
             const data = response.data
             DICTIONARY_CACHE[key] = data
             this.label = this.formatterOptions(value, data, 'key', 'name')
           })
-          .catch(e => {
+          .catch((e) => {
             DICTIONARY_CACHE[key] = []
             // 异常
             console.error(e)
@@ -264,69 +282,77 @@ export default {
           this.userList.forEach((item, i) => {
             if (id.includes(item.userId)) {
               this.label += item.userName + ','
-              // SELECTOR_CACHE[key] = item.NAME_ + ','
+              SELECTOR_CACHE[key] = item.userName + ','
             }
           })
-          // getUserById({ employeeId: id })
-          //   .then(response => {
-          //     const data = response.data
-          //     data[nameKey] = data['name']
-          //     if (data) {
-          //       SELECTOR_CACHE[key] = data[nameKey]
-          //       this.label = data[nameKey]
-          //     }
-          //   })
-          //   .catch(e => {
-          //     console.error(e)
-          //   })
+          remoteRequest('formTemplate', { key }, () => {
+            return getUserById({ employeeId: id })
+          })
+            .then((response) => {
+              const data = response.data
+              data[nameKey] = data['name']
+              if (data) {
+                SELECTOR_CACHE[key] = data[nameKey]
+                this.label = data[nameKey]
+              }
+            })
+            .catch((e) => {
+              console.error(e)
+            })
         } else if (type === 'org') {
-          getOrgById({ orgId: id })
-            .then(response => {
+          remoteRequest('formTemplate', { key }, () => {
+            return getOrgById({ orgId: id })
+          })
+            .then((response) => {
               const data = response.data
               if (data) {
                 this.label = data[nameKey]
                 SELECTOR_CACHE[key] = data[nameKey]
               }
             })
-            .catch(e => {
+            .catch((e) => {
               console.error(e)
             })
         } else if (type === 'position') {
           this.deptList.forEach((item, i) => {
             if (id.includes(item.positionId)) {
               this.label += item.positionName + ','
-              // SELECTOR_CACHE[key] = item.NAME_ + ','
+              SELECTOR_CACHE[key] = item.positionName + ','
             }
           })
-          // getPositionById({ positionId: id })
-          //   .then(response => {
-          //     const data = response.data
-          //     if (data) {
-          //       this.label = data[nameKey]
-          //       SELECTOR_CACHE[key] = data[nameKey]
-          //     }
-          //   })
-          //   .catch(e => {
-          //     console.error(e)
-          //   })
+          remoteRequest('formTemplate', { key }, () => {
+            return getPositionById({ positionId: id })
+          })
+            .then((response) => {
+              const data = response.data
+              if (data) {
+                this.label = data[nameKey]
+                SELECTOR_CACHE[key] = data[nameKey]
+              }
+            })
+            .catch((e) => {
+              console.error(e)
+            })
         } else if (type === 'role') {
           this.roleList.forEach((item, i) => {
             if (id.includes(item.ID_)) {
               this.label += item.NAME_ + ','
-              // SELECTOR_CACHE[key] = item.NAME_ + ','
+              SELECTOR_CACHE[key] = item.NAME_ + ','
             }
           })
-          // getRoleById({ roleId: id })
-          //   .then(response => {
-          //     const data = response.data
-          //     if (data) {
-          //       this.label = data[nameKey]
-          //       SELECTOR_CACHE[key] = data[nameKey]
-          //     }
-          //   })
-          //   .catch(e => {
-          //     console.error(e)
-          //   })
+          remoteRequest('formTemplate', { key }, () => {
+            return getRoleById({ roleId: id })
+          })
+            .then((response) => {
+              const data = response.data
+              if (data) {
+                this.label = data[nameKey]
+                SELECTOR_CACHE[key] = data[nameKey]
+              }
+            })
+            .catch((e) => {
+              console.error(e)
+            })
         }
       }
     },
@@ -350,13 +376,13 @@ export default {
         this.label = ATTACHMENT_CACHE[id]
       } else {
         getAttachmentById({ attachmentId: id, type: type })
-          .then(response => {
+          .then((response) => {
             const data = response.data
             if (this.$utils.isEmpty(data)) return
             this.label = data['fileName']
             ATTACHMENT_CACHE[id] = data['fileName']
           })
-          .catch(e => {
+          .catch((e) => {
             console.error(e)
           })
       }
@@ -379,7 +405,7 @@ export default {
       const d = dataTitle.split(/(\$[0-9a-zA-Z._]+#[0-9A-Fa-f]*)/g)
       const rtn = []
 
-      d.forEach(n => {
+      d.forEach((n) => {
         let a = n
         if (/^\$(_widget_)/.test(n)) {
           // 对字段进行处理
@@ -394,22 +420,26 @@ export default {
     // 处理对话框id值
     formatterDataTemplateValue: function(value, key) {
       this.label = ''
-      value.split(',').forEach(id => {
+      value.split(',').forEach((id) => {
         if (key) {
-          getDataById({ id: id, key: key }).then(response => {
-            const responseData = response.data
-            const data = responseData.data[0]
-            // const data = response.data
-            const variables = response.data
-            if (this.$utils.isNotEmpty(data)) {
-              // TODO 多个字段组合处理
-              const a = this.exp(data, variables['title'].name)
-              const val = variables['title'] || ''
-              this.label += this.$utils.isNotEmpty(a) ? a : ''
-            }
-          }).catch((e) => {
-            console.error(e)
+          remoteRequest('formTemplate', { key }, () => {
+            return getDataById({ id: id, key: key })
           })
+            .then((response) => {
+              const responseData = response.data
+              const data = responseData.data[0]
+              // const data = response.data
+              const variables = response.data
+              if (this.$utils.isNotEmpty(data)) {
+                // TODO 多个字段组合处理
+                const a = this.exp(data, variables['title'].name)
+                const val = variables['title'] || ''
+                this.label += this.$utils.isNotEmpty(a) ? a : ''
+              }
+            })
+            .catch((e) => {
+              console.error(e)
+            })
         } else {
           const labelKeys = buildLabelTitle(this.tem)
           const a = this.handleLabel(this.data, labelKeys)
@@ -452,21 +482,21 @@ 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
       }
-      // TODO: 有问题
-      getLinkDataByKey({
-        key: key
+      remoteRequest('formTemplate', { key }, () => {
+        return getLinkDataByKey({ key: key })
       })
-        .then(response => {
+        .then((response) => {
           const data = response.data
           if (this.$utils.isNotEmpty(data)) {
             const arrayValue = value.split(',')
             const rtn = []
             for (var d = 0; d < data.length; d++) {
               const item = data[d]
-              const v = arrayValue.find(val => {
+              const v = arrayValue.find((val) => {
                 return val === item[__linkKey]
               })
               if (v) {
@@ -476,7 +506,7 @@ export default {
             this.label += rtn.join(',')
           }
         })
-        .catch(e => {
+        .catch((e) => {
           console.error(e)
         })
     },
@@ -539,7 +569,7 @@ export default {
     },
     getAddressData(fieldOptions, v, type) {
       // TODO: 获取地址信息
-      getAreaData().then(response => {
+      getAreaData().then((response) => {
         WorldDistricts = response.data
       })
       if (this.$utils.isEmpty(v)) {
@@ -595,11 +625,11 @@ export default {
      */
     formatterOptions(value, options, valueKey = 'value', labelKey = 'label') {
       const optionObj = {}
-      options.map(option => {
+      options.map((option) => {
         optionObj[option[valueKey]] = option[labelKey]
       })
       const aryValue = value.split(',')
-      const res = aryValue.map(v => {
+      const res = aryValue.map((v) => {
         return optionObj[v] || v
       })
       return res.join(',')
@@ -620,7 +650,7 @@ export default {
       if (typeof aryValue !== 'object') {
         return aryValue
       }
-      const res = aryValue.map(val => {
+      const res = aryValue.map((val) => {
         return val[key] || ''
       })
       return res.join(',')
@@ -632,5 +662,6 @@ export default {
 .ibps-data-template-data {
   word-break: break-all;
   word-wrap: break-word;
+  color: #333;
 }
 </style>

+ 156 - 94
src/business/platform/data/data-template/template.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
     <van-popup
-      v-model="showDialogPopup"
+      :value="visible"
       class="ibps-fullscreen-popup"
       position="bottom"
       get-container="body"
@@ -41,63 +41,76 @@
         </van-cell>
       </van-cell-group>
       <!--多选 -->
-      <van-list
-        v-model="loading"
-        :finished="finished"
-        finished-text="没有更多了"
-        @load="loadData"
-      >
-        <van-checkbox-group
-          ref="checkboxGroup"
-          v-model="checkbox"
-          :max="multiple ? 0 : 1"
-        >
-          <van-cell-group>
-            <van-cell
-              v-for="(data, index) in dataList"
-              :key="data[valueKey] + index"
-              clickable
-              @click="toggle(data, index)"
-            >
-              <div slot="title">
-                <van-checkbox ref="checkboxes" :name="data[valueKey]">
-                  <!-- <field-formatter
+      <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
+        <van-list v-model="loading" :finished="finished" @load="loadData">
+          <van-checkbox-group
+            ref="checkboxGroup"
+            v-model="checkbox"
+            :max="multiple ? 0 : 1"
+          >
+            <van-cell-group>
+              <van-cell
+                v-for="(data, index) in dataList"
+                :key="data[valueKey] + index"
+                clickable
+                @click="toggle(data, index)"
+              >
+                <div slot="title">
+                  <field-formatter
+                    v-if="labelField"
+                    class="titles"
                     :label-key="labelKey"
                     :data="data"
+                    :desc-field="labelField"
+                    :field-options="comFieldOptions(labelField['name'])"
+                    :field-type="comFieldType(labelField['name'])"
                     :template-fields="templateFields"
-                  /> -->
-                  <div>
+                  />
+                </div>
+                <div slot="label">
+                  <van-checkbox ref="checkboxes" :name="data[valueKey]">
+                    <!-- {{ labelKey }} -->
+                    <!-- <field-formatter
+                      :label-key="labelKey"
+                      :data="data"
+                      :template-fields="templateFields"
+                    /> -->
                     <div
                       v-for="(item, i) in data.showlabel"
                       :key="i"
-                      style="display:flex"
+                      style="display: flex"
                     >
                       <span>{{ item.label }}</span>
-                      <span v-if="item.label!=''">:</span>
+                      <span v-if="item.label != ''">:</span>
                       <field-formatter
                         :label-key="item.bt"
                         :data="data"
                         :template-fields="templateFields"
                         :field-options="item.fieldOptions"
+                        :desc-field="item"
                         :field-type="item.fieldType"
-                        :tem ="tem"
+                        :tem="tem"
                       />
                     </div>
-                  </div>
-                </van-checkbox>
-              </div>
-              <span
-                v-if="hasChild(data)"
-                slot="right-icon"
-                @click="toggle(data, index)"
-              >
-                <span class="van-cell__right-icon" />
-                <van-icon name="arrow " class="van-cell__right-icon" />
-              </span>
-            </van-cell>
-          </van-cell-group>
-        </van-checkbox-group>
-      </van-list>
+                  </van-checkbox>
+                </div>
+                <span
+                  v-if="hasChild(data)"
+                  slot="right-icon"
+                  @click="toggle(data, index)"
+                >
+                  <span class="van-cell__right-icon" />
+                  <van-icon name="arrow " class="van-cell__right-icon" />
+                </span>
+              </van-cell>
+            </van-cell-group>
+          </van-checkbox-group>
+        </van-list>
+        <ibps-list-result-page
+          v-if="dataList.length === 0 && !loading"
+          result-type="empty"
+        />
+      </van-pull-refresh>
     </van-popup>
 
     <!--点击明细-查看选中的 -->
@@ -127,8 +140,8 @@
                 :label-key="labelKey"
                 :data="data"
                 :template-fields="templateFields"
-                :tem ="tem"
-                :tag = "'Y'"
+                :tem="tem"
+                :tag="'Y'"
                 class="van-cell-text"
               />
             </template>
@@ -152,11 +165,11 @@
     </van-popup>
   </div>
 </template>
-
 <script>
 import { queryDataByKey, queryDataById } from '@/api/platform/data/dataTemplate'
 import { remoteRequest } from '@/utils/remote'
 import TreeUtils from '@/utils/tree'
+import IbpsListResultPage from '@/components/ibps-list-result-page'
 import ActionUtils from '@/utils/action'
 import { buildLabelTitle } from '../templaterender/utils/index'
 import i18n from '@/utils/i18n' // Internationalization 国际化
@@ -166,13 +179,15 @@ import IbpsPickerToolbar from '@/components/ibps-picker-toolbar'
 export default {
   components: {
     IbpsPickerToolbar,
-    FieldFormatter
+    FieldFormatter,
+    IbpsListResultPage
   },
   props: {
     visible: Boolean,
     templateKey: String,
     templateFields: Object,
     params: Object,
+    labelField: Object,
     values: Array,
     multiple: Boolean,
     leftText: String,
@@ -180,6 +195,7 @@ export default {
     isTree: Boolean,
     datat: Object,
     fieldType: String,
+    defaultFilterListCol: [Array, undefined],
     idKey: {
       // 唯一键
       type: String,
@@ -202,6 +218,7 @@ export default {
       type: String,
       default: 'children'
     },
+    label: String,
     queryKey: String,
     dynamicParams: Object, // 动态参数
     tem: Object
@@ -214,8 +231,8 @@ export default {
       dataList: [], // 数据
       cacheData: {}, // 缓存数据
       template: {},
-      displayColumns: [],
-
+      // displayColumns: [],
+      refreshing: false,
       checkedValue: [],
       dataTem: {},
       showDialogPopup: false,
@@ -230,6 +247,22 @@ export default {
     }
   },
   computed: {
+    comFieldOptions() {
+      return function(fieldLabel) {
+        const fieldOptions =
+          this.templateFields[fieldLabel] &&
+          this.templateFields[fieldLabel].field_options
+        return this.$utils.isNotEmpty(fieldOptions) ? fieldOptions : {}
+      }
+    },
+    comFieldType() {
+      return function(fieldLabel) {
+        const fieldType =
+          this.templateFields[fieldLabel] &&
+          this.templateFields[fieldLabel].field_type
+        return this.$utils.isNotEmpty(fieldType) ? fieldType : ''
+      }
+    },
     title() {
       if (this.multiple) {
         const length = this.checkbox.length
@@ -240,12 +273,16 @@ export default {
         if (this.$utils.isEmpty(this.checkbox)) {
           return ''
         }
+
         const checked = this.checkbox[0]
         if (this.fieldType === 'linkdata') {
           return checked
         }
         this.labelKeys = buildLabelTitle(this.tem)
-        const a = this.dataList.length > 0 && this.childrenIndex != -1 ? this.handleLabel(this.dataList[this.childrenIndex]) : ''
+        const a =
+          this.dataList.length > 0 && this.childrenIndex != -1
+            ? this.handleLabel(this.dataList[this.childrenIndex])
+            : ''
 
         return this.$utils.isNotEmpty(checked)
           ? this.cacheData[checked]
@@ -255,25 +292,23 @@ export default {
       }
     },
     selectedData() {
-      return this.checkbox.map(d => {
+      return this.checkbox.map((d) => {
         return this.cacheData[d] || {}
       })
+    },
+    displayColumns() {
+      const columns = this.tem.display_columns || []
+      return columns.filter((t) => t.isAppShow !== 'N' && t.isTitle !== 'Y')
     }
   },
   watch: {
     values: {
-      handler(val, oldVal) {
-        this.initData()
+      handler(val) {
+        val.length > 0 && this.initData()
       },
       deep: true,
       immediate: true
     },
-    visible() {
-      this.showDialogPopup = this.visible
-      if (this.visible && this.params) {
-        this.loadData(this.params, true)
-      }
-    },
     params() {
       this.initTemplate()
     },
@@ -292,22 +327,34 @@ export default {
       deep: true
     },
     valueKey: {
-      handler(val, oldVal) {
+      handler() {
         this.initData()
       },
       deep: true
       // immediate: true
+    },
+    visible: {
+      handler(val) {
+        val && this.loadData(this.params, true)
+      }
     }
   },
-  created() {
-    // const sql = `select name_,id_ from ibps_party_entity `
-    // this.$common.request('sql', sql).then(res => {
-    //   const { data } = res.variables
-    //   this.selectorArr = data
-    // })
+  mounted() {
+    this.values && this.values.length > 0 && this.loadData(this.params, true)
   },
   methods: {
-    initData() {
+    setlabelKeys() {
+      this.labelKeys = buildLabelTitle(this.tem)
+    },
+    onRefresh() {
+      this.refreshing = true
+      this.finished = false
+      this.loading = true
+      this.onSearch()
+    },
+    async initData() {
+      // 等待动态参数
+      await this.$nextTick()
       const data = this.values
       this.checkedValue = []
       this.checkbox = []
@@ -315,7 +362,7 @@ export default {
         this.emitInitData([])
         return
       }
-      data.forEach(v => {
+      data.forEach(async(v) => {
         // if (this.cacheData[v]) {
         //   this.checkedValue.push(v)
         // } else {
@@ -329,6 +376,7 @@ export default {
     },
     handleLabel(data) {
       const config = this.labelKeys
+      // console.log('this.labelKeys====>', config(data))
       if (typeof config === 'function') {
         return config(data)
       } else if (typeof config === 'string') {
@@ -352,7 +400,7 @@ export default {
       remoteRequest('dataTemplate', params, () => {
         return this.getRemoteDataTemplateByIdFunc(params)
       })
-        .then(responseData => {
+        .then((responseData) => {
           if (
             this.$utils.isNotEmpty(responseData) &&
             this.$utils.isNotEmpty(responseData.data)
@@ -366,7 +414,6 @@ export default {
             if (data[this.valueKey]) {
               this.checkedValue.push(data[this.valueKey])
             }
-
             this.emitInitData(this.getSelectedData(this.checkedValue))
           }
         })
@@ -375,16 +422,16 @@ export default {
     getRemoteDataTemplateByIdFunc(params) {
       return new Promise((resolve, reject) => {
         queryDataById(params)
-          .then(response => {
+          .then((response) => {
             resolve(response.data)
           })
-          .catch(error => {
+          .catch((error) => {
             reject(error)
           })
       })
     },
-
     loadData(p, isInit) {
+      console.log('触底加载')
       if (isInit) {
         this.pathData = []
       }
@@ -404,7 +451,7 @@ export default {
       // TODO: 分页数据处理
       // 加载数据
       queryDataByKey(ActionUtils.formatParams(params, pagination))
-        .then(response => {
+        .then((response) => {
           const dataResult = response.data.dataResult
           const pageResult = response.data.pageResult
           if (this.isTree) {
@@ -416,53 +463,53 @@ export default {
             // 初始化最顶级数据
             this.initRootTreeData(response.vars)
             // 缓存数据
-            dataResult.map(d => {
+            dataResult.map((d) => {
               this.cacheData[d[this.valueKey]] = d
             })
           } else {
             const dl = dataResult
-            dl.map(d => {
+            this.refreshing = false
+            dl.forEach((d) => {
               this.cacheData[d[this.valueKey]] = d
               // const objName = Object.keys(d)
-              const fb = { ...d }
-              fb.showlabel = {}
+              const fb = { ...d, showlabel: {}}
+              // 判断值来源 this.tem.display_columns为空就是关联数据
               if (typeof this.tem.display_columns !== 'undefined') {
-                const keyName = this.dataList.findIndex(t => t.id_ == d.id_)
+                const keyName = this.dataList.findIndex((t) => t.id_ == d.id_)
                 if (typeof keyName !== -1) {
-                  this.tem.display_columns.forEach((it, i) => {
-                    let b = {}
-
-                    b = {
+                  this.displayColumns.forEach((it) => {
+                    const b = {
                       label: it.label,
                       bt: it.name,
-                      val: {},
+                      val: {
+                        [it.name]: d[it.name]
+                      },
                       fieldType: it.field_type,
                       fieldOptions: it.field_options
                     }
-                    b.val[it.name] = d[it.name]
                     fb.showlabel[it.name] = b
                   })
-                  this.dataList.push(fb)
-                } else {
-                  //
                 }
               } else {
                 let b = {}
                 let key = ''
+
                 for (const k in d) {
                   b = {
                     label: '',
-                    bt: k,
+                    bt: this.labelKey || k,
                     val: {},
-                    fieldType: 'text',
+                    fieldType: 'linkdata',
                     fieldOptions: {}
                   }
+                  // console.log('d===>', k)
                   key = k
                 }
+
                 b.val = d[key]
                 fb.showlabel = [b]
-                this.dataList.push(fb)
               }
+              this.dataList.push(fb)
             })
           }
           this.page++
@@ -476,7 +523,7 @@ export default {
             this.finished = true
           }
         })
-        .catch(e => {
+        .catch((e) => {
           console.error(e)
         })
     },
@@ -497,7 +544,7 @@ export default {
       if (this.$utils.isEmpty(data)) {
         return []
       }
-      return data.map(d => {
+      return data.map((d) => {
         return this.cacheData[d]
       })
     },
@@ -526,7 +573,8 @@ export default {
     // 查询
     onSearch() {
       this.page = 1
-      this.list = []
+      this.dataList = []
+      this.selectorArr = []
       this.loadData()
     },
     onDetailCancel() {
@@ -558,7 +606,7 @@ export default {
     removeSelected(index) {
       this.checkbox.splice(index, 1)
     },
-    toggleMore(data, index) {
+    toggleMore(data) {
       this.$dialog.alert({
         message: this.format4popup(data)
       })
@@ -610,3 +658,17 @@ export default {
   }
 }
 </script>
+<style lang="scss" scoped>
+.titles {
+  font-weight: 600;
+  font-size: 16px;
+  display: block;
+}
+::v-deep .van-checkbox {
+  flex-direction: row-reverse;
+  justify-content: space-between;
+  .van-checkbox__label {
+    margin: 0;
+  }
+}
+</style>

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

@@ -51,6 +51,7 @@ export default {
     defaultValue: Object, // 默认值
     mainCode: String, // 主表名
     code: String, // 表名
+    rowElClass: String,
     row: [String, Number], // 子表行数
     readonlyRights: { // 只读
       type: Boolean,

+ 27 - 19
src/views/platform/data/components/dropMenu/index.vue

@@ -7,14 +7,22 @@
           :class="{
             active: index === activeMenuBarIndex,
             selected: $_checkBarItemSelect(index),
-            disabled: item.disabled,
+            disabled: item.disabled
           }"
           class="bar-item"
-          :style="{'padding':$utils.isNotEmpty(item.options)?8+'px':0}"
+          :style="{ padding: $utils.isNotEmpty(item.options) ? 8 + 'px' : 0 }"
           @click="$_onBarItemClick(item, index)"
         >
-          <slot name="checks" :text="$_getBarItemText(item, index)" :color="isPopupShow?'#666':'#38f'" />
-          <slot name="icon" :icon="isPopupShow?'up':'down'" :color="isPopupShow?'#38f':'#666'" />
+          <slot
+            name="checks"
+            :text="$_getBarItemText(item, index)"
+            :color="isPopupShow ? '#666' : '#38f'"
+          />
+          <slot
+            name="icon"
+            :icon="isPopupShow ? 'up' : 'down'"
+            :color="isPopupShow ? '#38f' : '#666'"
+          />
         </div>
       </template>
       <slot name="text" />
@@ -31,7 +39,7 @@
               clickable
               @click="$_onListItemClick(item)"
             >
-              <van-radio :name="item.name||item.text" />
+              <van-radio :name="item.name || item.text" />
             </van-cell>
           </van-cell-group>
         </van-radio-group>
@@ -65,7 +73,7 @@ export default {
     },
     optionRender: {
       type: Function,
-      default: function() {}
+      default: function () {}
     },
     async: {
       type: Boolean,
@@ -113,7 +121,7 @@ export default {
       }
     },
     async: {
-      handler: function(val, oldVal) {
+      handler: function (val, oldVal) {
         this.isPopupShow = false
       },
       immediate: true
@@ -200,23 +208,23 @@ export default {
 }
 </script>
 <style lang="scss" scoped>
-$font_size:14px;
-$font_color:#38f;
-.menus{
-  >div{
+$font_size: 14px;
+$font_color: #38f;
+.menus {
+  > div {
     position: relative;
     background-color: #f1f4f8;
     // height: 100%;
-    min-height:40px;
+    min-height: 40px;
   }
-  .bar-item{
+  .bar-item {
     display: inline-block;
     position: relative;
     padding: 8px;
     top: 3px;
     left: 5px;
     margin-right: 10px;
-    .menu-slot-checks{
+    .menu-slot-checks {
       max-width: 70px;
       overflow: hidden;
       white-space: nowrap;
@@ -224,7 +232,7 @@ $font_color:#38f;
       font-size: $font_size;
       text-align: center;
     }
-    .menu-slot-icon{
+    .menu-slot-icon {
       position: absolute;
       right: -7px;
       top: 9px;
@@ -232,16 +240,16 @@ $font_color:#38f;
       font-size: $font_size;
     }
   }
-  .menu-slot-text{
+  .menu-slot-text {
     font-size: $font_size;
     position: relative;
-    bottom:0;
+    bottom: 0;
     height: 100%;
   }
-  .menu-slot-right{
+  .menu-slot-right {
     padding: 8px;
     font-size: $font_size;
-    color:$font_color;
+    color: $font_color;
     position: absolute;
     top: 13%;
     right: 2%;

+ 4 - 2
src/views/platform/data/components/dropMenu/util/index.js

@@ -13,10 +13,12 @@ export function traverse(data, childrenKeys = [], fn = () => {}) {
   }
   let level = 0 // current level
   let indexs = [] // index set of all levels
-  const walk = curData => {
+  const walk = (curData) => {
     for (let i = 0, len = curData.length; i < len; i++) {
       const isArray = Array.isArray(curData[i])
-      const key = Array.isArray(childrenKeys) ? childrenKeys[level] : childrenKeys
+      const key = Array.isArray(childrenKeys)
+        ? childrenKeys[level]
+        : childrenKeys
       if (isArray || (curData[i] && curData[i][key])) {
         level++
         indexs.push(i)

+ 127 - 72
src/views/platform/data/components/search-field/index.vue

@@ -1,7 +1,7 @@
 <template>
   <!-- 单项选择 -->
   <ibps-radio
-    v-if="item.fieldType==='radio'"
+    v-if="item.fieldType === 'radio'"
     v-model="parameter[item.modelValue]"
     label=" "
     :desc="item.desc"
@@ -15,9 +15,9 @@
   />
   <!-- 多项选择 -->
   <ibps-checkbox
-    v-else-if="item.fieldType==='checkbox'"
+    v-else-if="item.fieldType === 'checkbox'"
     v-model="parameter[item.modelValue]"
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     :other-option-value="otherOptionValue"
     :options="options"
     :value-key="'val'"
@@ -28,19 +28,19 @@
   />
   <!-- 富文本 -->
   <ibps-editor
-    v-else-if="item.fieldType==='editor'"
+    v-else-if="item.fieldType === 'editor'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     :height="height"
     :name="item.prop"
   />
   <!-- 自动编号 -->
   <van-field
-    v-else-if="item.fieldType==='autoNumber'"
+    v-else-if="item.fieldType === 'autoNumber'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     autocomplete="off"
     autosize
     clearable
@@ -49,11 +49,11 @@
   />
   <!-- 上传附件 -->
   <ibps-uploader
-    v-else-if="item.fieldType==='attachment'"
+    v-else-if="item.fieldType === 'attachment'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
-    :store="fieldOptions.store||'json'"
+    :placeholder="item.placeholder"
+    :store="fieldOptions.store || 'json'"
     :max-size="maxFileSize"
     :limit="fileQuantity"
     :accept="accept"
@@ -62,10 +62,10 @@
   />
   <!-- 自定义对话框 -->
   <ibps-custom-dialog
-    v-else-if="item.fieldType==='customDialog'"
+    v-else-if="item.fieldType === 'customDialog'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     :multiple="!single"
     :template-key="fieldOptions.dialog"
     :store="fieldOptions.store"
@@ -78,10 +78,11 @@
   />
   <!-- 关联数据 -->
   <ibps-linkdata
-    v-else-if="item.fieldType==='linkdata'"
+    v-else-if="item.fieldType === 'linkdata'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
+    :field="item"
     :multiple="multiple"
     :template-key="fieldOptions.linkdata"
     :store="fieldOptions.store"
@@ -94,10 +95,10 @@
   />
   <!-- 地址 -->
   <ibps-address
-    v-else-if="item.fieldType==='address'"
+    v-else-if="item.fieldType === 'address'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     :top="fieldOptions.top"
     :top-val="getAddressTopVal()"
     :level="fieldOptions.level"
@@ -107,10 +108,12 @@
   />
   <!-- 当前时间、当前日期 -->
   <ibps-date-picker
-    v-else-if="item.fieldType==='currentDate'|| item.fieldType==='currentTime'"
+    v-else-if="
+      item.fieldType === 'currentDate' || item.fieldType === 'currentTime'
+    "
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     :format="dateFormat"
     :name="item.prop"
     type="custom"
@@ -118,28 +121,63 @@
   />
   <!-- 签名 -->
   <ibps-signature
-    v-else-if="item.fieldType==='signature'"
+    v-else-if="item.fieldType === 'signature'"
     v-model="parameter[item.modelValue]"
     label=" "
-    :placeholder="item.options.placeholder"
+    :placeholder="item.placeholder"
     :height="height"
     :name="item.name"
   />
   <!-- 选择器 -->
   <ibps-selector
-    v-else-if="item.fieldType==='selector'|| item.fieldType==='currentUser'|| item.fieldType==='currentOrg'"
+    v-else-if="
+      item.fieldType === 'selector' ||
+      item.fieldType === 'currentUser' ||
+      item.fieldType === 'currentOrg'
+    "
     v-model="parameter[item.modelValue]"
     label=" "
     :placeholder="item.placeholder"
-    :store="fieldOptions.store||'json'"
-    :type="fieldOptions.selector_type||'user'"
+    :store="fieldOptions.store || 'json'"
+    :type="fieldOptions.selector_type || 'user'"
     :multiple="!single"
     :bind-id="bindId"
     :field-options="fieldOptions"
+    :filter="fieldOptions.filter"
     :name="item.prop"
     :input-align="inputAlign"
     @bind-callback="selectorBindCallback"
   />
+  <!-- 选择器 -->
+  <!-- <ibps-selector
+    v-else-if="
+      fieldType === 'selector' ||
+      fieldType === 'currentUser' ||
+      fieldType === 'currentOrg'
+    "
+    v-model="dataModel"
+    :label="field.label"
+    :desc="field.desc"
+    :desc-position="descPosition"
+    :placeholder="placeholder"
+    :store="fieldOptions.store || 'id'"
+    :type="fieldOptions.selector_type || 'user'"
+    :multiple="multiple"
+    :bind-id="bindId"
+    :field-options="fieldOptions"
+    :filter="fieldOptions.filter"
+    :input-align="inputAlign"
+    :name="field.name"
+    :required="required"
+    :readonly="
+      fieldType === 'currentUser' || fieldType === 'currentOrg'
+        ? true
+        : readonly
+    "
+    :rules="rules"
+    @bind-callback="selectorBindCallback"
+    v-on="$listeners"
+  /> -->
   <!-- 流程实例-->
   <ibps-bpm-inst-his
     v-else-if="item.fieldType === 'bpmInstHis'"
@@ -152,10 +190,12 @@
   />
 </template>
 <script>
-
 import fecha from '@/utils/fecha'
 import FormOptions from '@/business/platform/form/constants/formOptions'
-import { fileTypes as FILE_TYPES, accept as ACCEPT } from '@/business/platform/file/constants/fileTypes'
+import {
+  fileTypes as FILE_TYPES,
+  accept as ACCEPT
+} from '@/business/platform/file/constants/fileTypes'
 
 import Vue from 'vue'
 import IbpsRadio from '@/components/ibps-radio'
@@ -185,32 +225,32 @@ import IbpsDesc from '@/business/platform/form/components/desc'
 import IbpsHyperlink from '@/business/platform/form/components/hyperlink'
 import IbpsAlert from '@/business/platform/form/components/alert'
 
-Vue.component('ibps-radio', IbpsRadio)
-Vue.component('ibps-checkbox', IbpsCheckbox)
-Vue.component('ibps-select', IbpsSelect)
-Vue.component('ibps-checker', IbpsChecker)
-Vue.component('ibps-date-picker', IbpsDatePicker)
-Vue.component('ibps-switch', IbpsSwitch)
-Vue.component('ibps-slider', IbpsSlider)
-Vue.component('ibps-rate', IbpsRate)
+Vue.component('IbpsRadio', IbpsRadio)
+Vue.component('IbpsCheckbox', IbpsCheckbox)
+Vue.component('IbpsSelect', IbpsSelect)
+Vue.component('IbpsChecker', IbpsChecker)
+Vue.component('IbpsDatePicker', IbpsDatePicker)
+Vue.component('IbpsSwitch', IbpsSwitch)
+Vue.component('IbpsSlider', IbpsSlider)
+Vue.component('IbpsRate', IbpsRate)
 
-Vue.component('ibps-editor', IbpsEditor)
-Vue.component('ibps-dictionary', IbpsDictionary)
-Vue.component('ibps-uploader', IbpsUploader)
-Vue.component('ibps-signature', IbpsSignature)
-Vue.component('ibps-address', IbpsAddress)
-Vue.component('ibps-selector', IbpsUserSelector)
-Vue.component('ibps-custom-dialog', IbpsCustomDialog)
-Vue.component('ibps-linkdata', IbpsLinkdata)
+Vue.component('IbpsEditor', IbpsEditor)
+Vue.component('IbpsDictionary', IbpsDictionary)
+Vue.component('IbpsUploader', IbpsUploader)
+Vue.component('IbpsSignature', IbpsSignature)
+Vue.component('IbpsAddress', IbpsAddress)
+Vue.component('IbpsSelector', IbpsUserSelector)
+Vue.component('IbpsCustomDialog', IbpsCustomDialog)
+Vue.component('IbpsLinkdata', IbpsLinkdata)
 
-Vue.component('ibps-approval-history', IbpsApprovalHistory)
-Vue.component('ibps-flow-diagram', IbpsFlowDiagram)
-Vue.component('ibps-bpm-inst-his', IbpsBpmInstHis)
-Vue.component('ibps-bpm-link', IbpsBpmLink)
+Vue.component('IbpsApprovalHistory', IbpsApprovalHistory)
+Vue.component('IbpsFlowDiagram', IbpsFlowDiagram)
+Vue.component('IbpsBpmInstHis', IbpsBpmInstHis)
+Vue.component('IbpsBpmLink', IbpsBpmLink)
 
-Vue.component('ibps-desc', IbpsDesc)
-Vue.component('ibps-hyperlink', IbpsHyperlink)
-Vue.component('ibps-alert', IbpsAlert)
+Vue.component('IbpsDesc', IbpsDesc)
+Vue.component('IbpsHyperlink', IbpsHyperlink)
+Vue.component('IbpsAlert', IbpsAlert)
 
 export default {
   props: {
@@ -237,13 +277,16 @@ export default {
   data() {
     const forms = this.forms
     const parameter = {}
-    forms.forEach((v, i) => {
+    forms.forEach((v) => {
       const propType = typeof v.prop
       if (propType === 'string') {
         v.modelValue = v.prop
         parameter[v.prop] = ''
-        if (v.fieldType === 'checker' || (v.fieldType === 'select' && v.options)) {
-          const index = v.options.findIndex(a => {
+        if (
+          v.fieldType === 'checker' ||
+          (v.fieldType === 'select' && v.options)
+        ) {
+          const index = v.options.findIndex((a) => {
             return a.value === ''
           })
           if (index > -1) {
@@ -255,9 +298,9 @@ export default {
         }
       } else if (
         propType === 'object' &&
-          Object.prototype.toString.call(v.prop) === '[object Array]'
+        Object.prototype.toString.call(v.prop) === '[object Array]'
       ) {
-        v.prop.forEach((vv, j) => {
+        v.prop.forEach((vv) => {
           parameter[vv] = ''
         })
       }
@@ -269,6 +312,13 @@ export default {
     }
   },
   computed: {
+    /**
+     * :linkConfig="getLinkConfig(fieldOptions)"
+    :linkStructure="getLinkStructure(fieldOptions)"
+    :linkLabelType="getLinkLabelType(fieldOptions)"
+    :linkLabelKey="getLinkLabelKey(fieldOptions)"
+    :linkValueKey="getLinkConfig(fieldOptions)"
+     */
     formData() {
       return this.data
     },
@@ -374,7 +424,7 @@ export default {
       }
       const x = FILE_TYPES[mediaType]
       if (x) {
-        return x.map(v => {
+        return x.map((v) => {
           return '.' + v
         })
       } else {
@@ -418,18 +468,20 @@ export default {
     dynamicParams() {
       const paramsObj = this.fieldOptions['params'] || []
       const rtn = {}
-      paramsObj.forEach(param => {
+      paramsObj.forEach((param) => {
         let value = ''
         let bindTbName = '' // 绑定的表名
         let bindColumn = '' // 绑定的字段
         if (param.value) {
-          const strValue = param.value.split('.')// 兼容旧版本
+          const strValue = param.value.split('.') // 兼容旧版本
           bindTbName = strValue.length > 1 ? strValue[0] : ''
           bindColumn = strValue.length > 1 ? strValue[1] : strValue[0]
         }
-        if (param.mode && param.mode === 'bind') { // 绑定字段
-          if (this.isSubTable) { // TODO 子表 暂时未处理
-            const subtbName = ''// 子表表名
+        if (param.mode && param.mode === 'bind') {
+          // 绑定字段
+          if (this.isSubTable) {
+            // TODO 子表 暂时未处理
+            const subtbName = '' // 子表表名
             // ① 取相同子表值 同一列的值
             // ② 取主表的值
             console.info(subtbName)
@@ -437,7 +489,8 @@ export default {
           } else {
             value = this.data[bindColumn]
           }
-        } else { // 固定值
+        } else {
+          // 固定值
           value = bindColumn
         }
         if (this.$utils.isNotEmpty(value)) {
@@ -465,7 +518,7 @@ export default {
       return this.parameter
     },
     resetForm() {
-      this.parameter = {...JSON.parse(JSON.stringify(this.defaultData))}
+      this.parameter = { ...JSON.parse(JSON.stringify(this.defaultData)) }
       return this.parameter
     },
     formatDate(value) {
@@ -474,7 +527,10 @@ export default {
         return fecha.format(value, this.dateFormat)
       } else {
         try {
-          return fecha.format(this.parseFormatDate(value, this.dateFormat), this.dateFormat)
+          return fecha.format(
+            this.parseFormatDate(value, this.dateFormat),
+            this.dateFormat
+          )
         } catch (error) {
           return value
         }
@@ -517,7 +573,7 @@ export default {
       }
       // 设置联动数据
       const formData = this.$utils.newData(this.formData)
-      bind.forEach(obj => {
+      bind.forEach((obj) => {
         const name = obj.name
         const field = obj.fieldName
         if (this.$utils.isEmpty(name) || this.$utils.isEmpty(field)) {
@@ -525,7 +581,7 @@ export default {
         }
         // TODO  目前只支持主表  数据处理没做
         const value = data
-          .map(d => {
+          .map((d) => {
             return d[field]
           })
           .join(',')
@@ -550,7 +606,7 @@ export default {
 
       // 设置联动数据
       const formData = this.$utils.newData(this.formData)
-      linkLinkage.forEach(obj => {
+      linkLinkage.forEach((obj) => {
         const name = obj.name
         const field = obj.field
         if (this.$utils.isEmpty(name) || this.$utils.isEmpty(field)) {
@@ -558,7 +614,7 @@ export default {
         }
         // TODO  目前只支持主表  数据处理没做
         const value = data
-          .map(d => {
+          .map((d) => {
             return d[field]
           })
           .join(',')
@@ -584,7 +640,7 @@ export default {
     linkageChangeFormData(linkAttr, formData, data, params) {
       if (this.$utils.isNotEmpty(linkAttr)) {
         // 关联属性
-        linkAttr.forEach(obj => {
+        linkAttr.forEach((obj) => {
           const name = obj.name
           const field = obj.field
           if (this.$utils.isEmpty(name) || this.$utils.isEmpty(field)) {
@@ -592,7 +648,7 @@ export default {
           }
           // TODO  目前只支持主表  数据处理没做
           const value = data
-            .map(d => {
+            .map((d) => {
               return d[field]
             })
             .join(',')
@@ -604,13 +660,13 @@ export default {
     getLinkLinkage() {
       return this.fieldOptions['link_linkage'] || []
     },
-    getLinkAttr: function() {
+    getLinkAttr: function () {
       return this.fieldOptions['link_attr'] || []
     },
-    getBind: function() {
+    getBind: function () {
       return this.fieldOptions['bind'] || []
     },
-    getBindId: function() {
+    getBindId: function () {
       return this.fieldOptions['bind_id'] || ''
     },
     selectorBindCallback(data) {
@@ -629,4 +685,3 @@ export default {
   }
 }
 </script>
-

+ 6 - 10
src/views/platform/data/custom-dialog/dialog.vue

@@ -1,14 +1,10 @@
 <template>
-  <div>
-
-  </div>
+  <div></div>
 </template>
 <script>
-  export default {
-    data() {
-      return {
-
-      }
-    }
+export default {
+  data() {
+    return {}
   }
-</script>
+}
+</script>

+ 202 - 123
src/views/platform/data/dataTemplate/field-formatter.vue

@@ -8,22 +8,24 @@
       :readonly="true"
     />
     <!-- 选择器 -->
-  <ibps-selector
-    v-else-if="
-      newFieldType === 'selector' ||
-      newFieldType === 'currentUser' ||
-      newFieldType === 'currentOrg'
-    "
-    v-model="label"
-    :store="newFieldOptions.store || 'id'"
-    :type="newFieldOptions.selector_type || 'user'"
-    :multiple="$utils.toBoolean(newFieldOptions.multiple, true)"
-    :field-options="newFieldOptions"
-    :filter="newFieldOptions.filter"
-    :readonly="true"
-    :islistShow="true"
-  />
-  <div v-else-if="hasCustomFormatter(descField.name)" v-html="customFormatter(descField.name, label, data, descField)" />
+    <template v-else-if="selectTypes.includes(newFieldType)">
+      <van-tag
+        v-for="(item, index) in selectorValue"
+        :key="item"
+        :color="'#D6EAFE'"
+        :text-color="'#3396FB'"
+        class="ibps-tag-span ibps-mr-8"
+      >
+        <template #default>
+          <div>{{ item }}</div>
+        </template>
+      </van-tag>
+    </template>
+
+    <div
+      v-else-if="hasCustomFormatter(descField.name)"
+      v-html="customFormatter(descField.name, label, data, descField)"
+    ></div>
     <span v-else class="ibps-data-template-data" v-html="label || '/'" />
   </div>
 </template>
@@ -37,9 +39,13 @@ import { get as getOrgById } from '@/api/platform/org/org'
 import { get as getPositionById } from '@/api/platform/org/position'
 import { get as getRoleById } from '@/api/platform/org/role'
 import { get as getAttachmentById } from '@/api/platform/file/attachment'
+import { remoteRequest } from '@/utils/remote'
+import ActionUtils from '@/utils/action'
 import {
   transferByIds as getDataById,
-  queryLinkageData as getLinkDataByKey
+  queryLinkageData as getLinkDataByKey,
+  queryDataTable,
+  getByKey
 } from '@/api/platform/data/dataTemplate'
 // import {
 //   loadDataTemplateByKey,
@@ -50,6 +56,7 @@ var WorldDistricts = null
 var DICTIONARY_CACHE = {}
 var ATTACHMENT_CACHE = {}
 var SELECTOR_CACHE = {}
+// var LINK_CACHE = {}
 
 // var DATA_KEY = {
 //   ID: '#id#',
@@ -71,9 +78,12 @@ export default {
       type: Object,
       default: () => {}
     },
+    cacheData: {
+      type: Map
+    },
     defaultValue: {
       type: String,
-      default: '&nbsp;'
+      default: '/'
     },
     // 列属性字段 当same为N时取自身的fieldType
     descField: Object,
@@ -91,7 +101,17 @@ export default {
       userList,
       label: '',
       newFieldType: '',
-      newFieldOptions: ''
+      newFieldOptions: '',
+      cachesData: new Map(),
+      selectTypes: ['selector', 'currentUser', 'currentOrg']
+    }
+  },
+  computed: {
+    selectorValue() {
+      if (this.selectTypes.includes(this.newFieldType)) {
+        return this.label && this.label.split ? this.label.split(',') : []
+      }
+      return []
     }
   },
   watch: {
@@ -102,7 +122,7 @@ export default {
       this.initData()
     }
   },
-  mounted: function() {
+  mounted: function () {
     this.initData()
   },
   methods: {
@@ -120,24 +140,27 @@ export default {
         return
       }
       // console.log('this.descField===>', this.descField, this.descField.field_type, this.fieldType)
-      const fieldType = this.descField.same === 'N' ? this.descField.field_type : this.fieldType
-      const fieldOptions = this.descField.same === 'N' ? this.descField.field_options : this.fieldOptions
+      const fieldType =
+        this.descField.same === 'N' ? this.descField.field_type : this.fieldType
+      const fieldOptions =
+        this.descField.same === 'N'
+          ? this.descField.field_options
+          : this.fieldOptions
       this.newFieldType = fieldType
       this.newFieldOptions = fieldOptions
+      // console.log('fieldType====>', fieldType)
       // 不转化值数组
       // newFieldType === 'selector' ||
       // newFieldType === 'currentUser' ||
       // newFieldType === 'currentOrg'
-      const noFormateValueTypes = ['selector', 'currentUser', 'currentOrg']
+      // const noFormateValueTypes = ['selector', 'currentUser', 'currentOrg']
       if (
         this.$utils.isEmpty(value) ||
         this.$utils.isEmpty(fieldType) ||
-        this.$utils.isEmpty(fieldOptions) ||
-        noFormateValueTypes.includes(fieldType)
+        this.$utils.isEmpty(fieldOptions)
+        // noFormateValueTypes.includes(fieldType)
       ) {
-        console.log('===>', this.labelKey)
         this.label = value
-        
         return
       }
       // 数据格式
@@ -145,28 +168,31 @@ export default {
     },
     /**
      * 脚本渲染函数
-     * @param name 
+     * @param name
      * @param value 当前行值
-     * @param rowData 
-     * @param column 
+     * @param rowData
+     * @param column
      */
-    customFormatter (name, value, rowData, column) {
+    customFormatter(name, value, rowData, column) {
       return JTemplate._customFormatter(this, name, value, rowData, column)
     },
-     // 自定义格式数据事件
-     hasCustomFormatter: function (name) {
-        const customFormatterResult = JTemplate._customFormatter(this, name)
-        if (typeof customFormatterResult !== 'undefined' && customFormatterResult) {
-            return true
-        }
-        return false
+    // 自定义格式数据事件
+    hasCustomFormatter: function (name) {
+      const customFormatterResult = JTemplate._customFormatter(this, name)
+      if (
+        typeof customFormatterResult !== 'undefined' &&
+        customFormatterResult
+      ) {
+        return true
+      }
+      return false
     },
     dataFormatter(value, fieldType, fieldOptions) {
       if (String(this.tag) === 'Y') {
         this.formatterCustomDialog(value, fieldOptions)
         return
       }
-      // console.log('fieldType==>', fieldType)
+      // console.log('fieldOptions==>', this.labelKey, fieldOptions)
       switch (fieldType) {
         case 'hidden':
         case 'text':
@@ -191,7 +217,6 @@ export default {
             fieldOptions['options'],
             'val'
           )
-          this.tag = true
           break
         case 'switch': // 开关
           this.label = this.formatterOptions(
@@ -204,10 +229,8 @@ export default {
           this.formatterDictionary(value, fieldOptions)
           break
         case 'customDialog': // TODO 自定义对话框
-        this.formatterSelectorData(
-          value,
-          'position'
-        )
+          console.log('descField===>', this.descField)
+          this.formatterSelectorData(value, 'position')
           break
         case 'linkdata': // TODO 关联数据
           this.formatterLinkdata(value, fieldOptions)
@@ -232,7 +255,7 @@ export default {
     /**
      * 格式化数字
      */
-    formatterNumber(value, fieldOptions) {
+    formatterNumber(value) {
       return value
     },
     /**
@@ -277,15 +300,17 @@ export default {
           'name'
         )
       } else {
-        getDictionaryData({
-          typeKey: key
+        remoteRequest('dataTemplate', { id: key }, () => {
+          return getDictionaryData({
+            typeKey: key
+          })
         })
-          .then(response => {
+          .then((response) => {
             const data = response.data
             DICTIONARY_CACHE[key] = data
             this.label = this.formatterOptions(value, data, 'key', 'name')
           })
-          .catch(e => {
+          .catch((e) => {
             DICTIONARY_CACHE[key] = []
             // 异常
             console.error(e)
@@ -315,6 +340,7 @@ export default {
     formatterSelectorData(id, type) {
       var key = type + ':' + id
       var nameKey = 'name'
+      // console.log('key====>', key)
       if (SELECTOR_CACHE[key]) {
         this.label = SELECTOR_CACHE[key]
       } else {
@@ -328,8 +354,10 @@ export default {
           })
           this.label = lab.replace(/,$/, '')
           if (!this.label) {
-            getUserById({ employeeId: id })
-              .then(response => {
+            remoteRequest('dataTemplate', { id }, () => {
+              return getUserById({ employeeId: id })
+            })
+              .then((response) => {
                 const data = response.data
                 data[nameKey] = data['name']
                 if (data) {
@@ -337,24 +365,26 @@ export default {
                   this.label = data[nameKey]
                 }
               })
-              .catch(e => {
+              .catch((e) => {
                 console.error(e)
               })
           }
         } else if (type === 'org') {
-          getOrgById({ orgId: id })
-            .then(response => {
+          remoteRequest('dataTemplate', { id }, () => {
+            return getOrgById({ orgId: id })
+          })
+            .then((response) => {
               const data = response.data
               if (data) {
                 this.label = data[nameKey]
                 SELECTOR_CACHE[key] = data[nameKey]
               }
             })
-            .catch(e => {
+            .catch((e) => {
               console.error(e)
             })
         } else if (type === 'position') {
-          // console.log('this.deptList===>', this.deptList)
+          // console.log('this.deptList===>11111111111', this.deptList, id)
           let lab = ''
           this.deptList.forEach((item, i) => {
             // console.log('item===>', id)
@@ -364,17 +394,38 @@ export default {
             }
           })
           this.label = lab.replace(/,$/, '')
-          console.log()
+          // console.log(
+          //   'this.label===>',
+          //   this.labelKey,
+          //   type,
+          //   this.deptList.filter((t) => id.includes(t.positionId))
+          // )
           if (!this.label) {
-            getPositionById({ positionId: id })
-              .then(response => {
-                const data = response.data
-                if (data) {
-                  this.label = data[nameKey]
-                  SELECTOR_CACHE[key] = data[nameKey]
+            remoteRequest('dataTemplate', { id }, () => {
+              return this.getRemoteDataTemplateFunc(
+                this.descField.field_options['dialog']
+              )
+            })
+              .then((response) => {
+                console.log('dasdsa==>', this.labelKey)
+                const dataTem = JSON.parse(response.data)
+                const data = dataTem?.datasets[0]
+                if (!data) {
+                  return
                 }
+                const tableName = data.name
+                const sql = `select ${this.labelKey} from ${tableName} where id_='${id}'`
+                remoteRequest('dataTemplatesql', { id }, () => {
+                  return this.$common.request('sql', sql)
+                }).then((res) => {
+                  const { data = [] } = res.variables || {}
+                  if (data) {
+                    this.label = data[0] ? data[0][this.labelKey] : '/'
+                    SELECTOR_CACHE[key] = this.label
+                  }
+                })
               })
-              .catch(e => {
+              .catch((e) => {
                 console.error(e)
               })
           }
@@ -387,15 +438,17 @@ export default {
             }
           })
           if (!lab) {
-            getRoleById({ roleId: id })
-              .then(response => {
+            remoteRequest('dataTemplate', { id }, () => {
+              return getRoleById({ roleId: id })
+            })
+              .then((response) => {
                 const data = response.data
                 if (data) {
                   this.label = data[nameKey]
                   SELECTOR_CACHE[key] = data[nameKey]
                 }
               })
-              .catch(e => {
+              .catch((e) => {
                 console.error(e)
               })
           } else {
@@ -424,13 +477,13 @@ export default {
         this.label = ATTACHMENT_CACHE[id]
       } else {
         getAttachmentById({ attachmentId: id, type: type })
-          .then(response => {
+          .then((response) => {
             const data = response.data
             if (this.$utils.isEmpty(data)) return
             this.label = data['fileName']
             ATTACHMENT_CACHE[id] = data['fileName']
           })
-          .catch(e => {
+          .catch((e) => {
             console.error(e)
           })
       }
@@ -439,7 +492,7 @@ export default {
      * 格式化自定义对话框
      */
     formatterCustomDialog(value, fieldOptions) {
-      console.log('this.labelKey--->', this.labelKey)
+      // console.log('this.labelKey--->', this.labelKey)
       const dialog = fieldOptions['dialog']
       // const store = fieldOptions['store_mode'] || 'id'
 
@@ -454,7 +507,7 @@ export default {
       const d = dataTitle.split(/(\$[0-9a-zA-Z._]+#[0-9A-Fa-f]*)/g)
       const rtn = []
 
-      d.forEach(n => {
+      d.forEach((n) => {
         let a = n
         if (/^\$(_widget_)/.test(n)) {
           // 对字段进行处理
@@ -470,22 +523,24 @@ export default {
     formatterDataTemplateValue: function (value, key) {
       // console.log('格式化自定义对话框===>', value)
       this.label = ''
-      value.split('-').forEach(id => {
+      value.split('-').forEach((id) => {
         if (key) {
-          getDataById({ id: id, key: key }).then(response => {
-            const responseData = response.data
-            const data = responseData.data[0]
-            // const data = response.data
-            const variables = response.data
-            if (this.$utils.isNotEmpty(data)) {
-              // TODO 多个字段组合处理
-              const a = this.exp(data, variables['title'].name)
-              // const val = variables['title'] || ''
-              this.label += this.$utils.isNotEmpty(a) ? a : ''
-            }
-          }).catch((e) => {
-            console.error(e)
-          })
+          getDataById({ id: id, key: key })
+            .then((response) => {
+              const responseData = response.data
+              const data = responseData.data[0]
+              // const data = response.data
+              const variables = response.data
+              if (this.$utils.isNotEmpty(data)) {
+                // TODO 多个字段组合处理
+                const a = this.exp(data, variables['title'].name)
+                // const val = variables['title'] || ''
+                this.label += this.$utils.isNotEmpty(a) ? a : ''
+              }
+            })
+            .catch((e) => {
+              console.error(e)
+            })
         } else {
           const labelKeys = buildLabelTitle(this.tem)
           const a = this.handleLabel(this.data, labelKeys)
@@ -522,38 +577,61 @@ export default {
       }
     },
     formatterLinkdata(value, fieldOptions) {
-      const linkConfig = fieldOptions['link_config'] || {}
-      const __key = fieldOptions['linkdata']
-      const __linkKey = linkConfig.id || 'id_'
-      const __linkText = linkConfig.text || 'name_'
-      this.label = this.getLinkdataValue(__key, __linkKey, __linkText, value)
+      this.label = value
+      // console.log('fieldOptions===>', fieldOptions)
+      // const linkConfig = fieldOptions['link_config'] || {}
+      // const __key = fieldOptions['linkdata']
+      // const __linkKey = linkConfig.id || 'id_'
+      // const __linkText = linkConfig.text || 'name_'
+      // this.getLinkdataValue(__key, __linkKey, __linkText, value)
+    },
+    async getRemoteDataTemplateFunc(templateKey) {
+      console.log('templateKey==>', templateKey)
+      return remoteRequest('dataTemplate1', templateKey, () => {
+        return getByKey({ dataTemplateKey: templateKey })
+      })
+    },
+    /**
+     * 获取格式化参数
+     */
+    async getFormatParams(key, __linkKey) {
+      let formParams = {}
+      const res = await this.getRemoteDataTemplateFunc(key)
+      const data = JSON.parse(res.data)
+      if (!data.templates) return {}
+      const template = data.templates[0]
+      console.log('data1111111111====>', this.templateFields)
+      const responseData = JSON.parse(JSON.stringify(template))
+      responseData.datasetKey = data.datasetKey
+      responseData.unique = __linkKey
+      responseData['key'] = key
+      responseData['dynamic_params'] = {}
+      formParams['response_data'] = JSON.stringify(responseData)
+      formParams['filter_condition_key'] = JSON.stringify({
+        key: 'filter_condition_key',
+        value: ''
+      })
+      return ActionUtils.formatParams(formParams)
     },
-    getLinkdataValue(key, __linkKey, __linkText, value) {
+    async getLinkdataValue(key, __linkKey, __linkText, value) {
       if (this.$utils.isEmpty(key)) {
         return value
       }
       // TODO: 有问题
-      getLinkDataByKey({
-        key: key
+      // const a = await this.getFormatParams(key)
+      console.log('getFormatParams===>', __linkKey)
+      remoteRequest('dataTemplate', { key }, async () => {
+        const params = await this.getFormatParams(key, __linkKey)
+        return queryDataTable(params)
       })
-        .then(response => {
-          const data = response.data
-          if (this.$utils.isNotEmpty(data)) {
-            const arrayValue = value.split(',')
-            const rtn = []
-            for (var d = 0; d < data.length; d++) {
-              const item = data[d]
-              const v = arrayValue.find(val => {
-                return val === item[__linkKey]
-              })
-              if (v) {
-                rtn.push(item[__linkText] || '')
-              }
-            }
-            this.label += rtn.join(',')
-          }
+        .then((response) => {
+          const item = response.data.dataResult.find(
+            (t) => t[__linkKey] === value
+          )
+          console.log('item====>', item)
+          this.label = item ? item[__linkText] : '/'
         })
-        .catch(e => {
+        .catch((e) => {
           console.error(e)
         })
     },
@@ -583,7 +661,7 @@ export default {
       }
     },
     // ====================地址展示处理================
-    getTextValue: function(data, value) {
+    getTextValue: function (data, value) {
       if (this.$utils.isEmpty(value) || this.$utils.isEmpty(data)) {
         return value || ''
       }
@@ -592,13 +670,13 @@ export default {
       }
       return value || ''
     },
-    getTop: function(fieldOptions) {
+    getTop: function (fieldOptions) {
       return fieldOptions['top'] ? fieldOptions['top'] : 'country'
     },
-    getLevel: function(fieldOptions) {
+    getLevel: function (fieldOptions) {
       return fieldOptions['level'] ? fieldOptions['level'] : 'district'
     },
-    getTopval: function(fieldOptions) {
+    getTopval: function (fieldOptions) {
       var top = this.getTop(fieldOptions)
       var rtnVal = '0'
       var topval = fieldOptions['topval']
@@ -616,7 +694,7 @@ export default {
     },
     getAddressData(fieldOptions, v, type) {
       // TODO: 获取地址信息
-      getAreaData().then(response => {
+      getAreaData().then((response) => {
         WorldDistricts = response.data
       })
       if (this.$utils.isEmpty(v)) {
@@ -672,11 +750,11 @@ export default {
      */
     formatterOptions(value, options, valueKey = 'value', labelKey = 'label') {
       const optionObj = {}
-      options.map(option => {
+      options.map((option) => {
         optionObj[option[valueKey]] = option[labelKey]
       })
       const aryValue = value.split(',')
-      const res = aryValue.map(v => {
+      const res = aryValue.map((v) => {
         return optionObj[v] || v
       })
       return res.join(',')
@@ -697,7 +775,7 @@ export default {
       if (typeof aryValue !== 'object') {
         return aryValue
       }
-      const res = aryValue.map(val => {
+      const res = aryValue.map((val) => {
         return val[key] || ''
       })
       return res.join(',')
@@ -709,12 +787,13 @@ export default {
 .ibps-data-template-data {
   word-break: break-all;
   word-wrap: break-word;
+  color: #333;
 }
 ::v-deep .van-cell__title {
-    width: 65%;
+  width: 65%;
 
-    .van-cell__label {
-      overflow-wrap: break-word;
-    }
+  .van-cell__label {
+    overflow-wrap: break-word;
   }
+}
 </style>

+ 6 - 10
src/views/platform/data/dataTemplate/template-list.vue

@@ -1,14 +1,10 @@
 <template>
-  <div>
-
-  </div>
+  <div></div>
 </template>
 <script>
-  export default {
-    data() {
-      return {
-
-      }
-    }
+export default {
+  data() {
+    return {}
   }
-</script>
+}
+</script>

+ 12 - 14
src/views/platform/data/template-list.vue

@@ -135,9 +135,7 @@
                 <!-- {{ item }}  -->
                 <!-- 默认第一行数据作为标题 -->
                 <van-row class="delayShow">
-                  <van-col
-span="6"
-class="titles"
+                  <van-col span="6" class="titles"
                     >{{ labelField['label'] }}:</van-col
                   >
                   <van-col span="17">
@@ -315,7 +313,7 @@ import IbpsPickerToolbar from '@/components/ibps-picker-toolbar'
 import IbpsBpmnFormrenderDialog from '@/business/platform/bpmn/form/dialog'
 
 export default {
-  name: 'template-list',
+  name: 'TemplateList',
   components: {
     // DropMenu,
     SearchField,
@@ -426,8 +424,8 @@ export default {
       return this.$store.getters.mainPosition
         ? this.$store.getters.mainPosition
         : this.$store.getters.position
-          ? this.$store.getters.position[0]
-          : { id: '' }
+        ? this.$store.getters.position[0]
+        : { id: '' }
     },
     toolbarButtons() {
       const arrs = ['add', 'addPlus']
@@ -435,7 +433,7 @@ export default {
       return filterAdd.length > 4 ? filterAdd.slice(0, 4) : filterAdd
     },
     comFieldOptions() {
-      return function(fieldLabel) {
+      return function (fieldLabel) {
         const fieldOptions =
           this.templateFields[fieldLabel] &&
           this.templateFields[fieldLabel].field_options
@@ -443,7 +441,7 @@ export default {
       }
     },
     comFieldType() {
-      return function(fieldLabel) {
+      return function (fieldLabel) {
         const fieldType =
           this.templateFields[fieldLabel] &&
           this.templateFields[fieldLabel].field_type
@@ -586,9 +584,9 @@ export default {
     },
     debounce(func, wait, immediate = false) {
       let timeoutId = null
-      const debounced = function(...args) {
+      const debounced = function (...args) {
         const context = this
-        const later = function() {
+        const later = function () {
           timeoutId = null
           if (!immediate) func.apply(context, args)
         }
@@ -598,7 +596,7 @@ export default {
         if (shouldCallNow) func.apply(context, args)
       }
       // 添加取消功能
-      debounced.cancel = function() {
+      debounced.cancel = function () {
         clearTimeout(timeoutId)
         timeoutId = null
       }
@@ -871,7 +869,7 @@ export default {
      * 获取格式化参数
      */
     getFormatParams() {
-      const formParams = this.getSearcFormData()
+      let formParams = this.getSearcFormData()
       console.log('formParams--===>', formParams)
       const responseData = JSON.parse(JSON.stringify(this.template))
       responseData.datasetKey = this.dataTemplate.datasetKey
@@ -1315,7 +1313,7 @@ export default {
       return type
     },
     // 自定义格式数据事件
-    hasButtonAction: function(key, button) {
+    hasButtonAction: function (key, button) {
       const buttonActionResult = JTemplate._onLoadActions(this, key, button)
       if (typeof buttonActionResult !== 'undefined' && buttonActionResult) {
         return true
@@ -1462,7 +1460,7 @@ export default {
      * 组合判断queryColumn最终形态
      * @param queryColumn queryColumn 列表查询区域的表单框集合
      */
-    convertField: function(queryColumn) {
+    convertField: function (queryColumn) {
       const field = this.fields[queryColumn.name.toLowerCase()] || null
       const same = !(queryColumn['same'] && queryColumn['same'] === 'N')
       let fieldType = same