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

task-5519 查看冰箱弹窗报错

tianxinyu 4 месяцев назад
Родитель
Сommit
c14147bea0

+ 43 - 34
src/business/platform/data/templaterender/custom-dialog/index.vue

@@ -1,7 +1,8 @@
 <template>
+  <!-- 修复自定义框回显 -->
   <van-field
     ref="input"
-    v-model="inputValue"
+    :value="value"
     :label="label"
     :name="name"
     :size="size"
@@ -60,20 +61,13 @@
           size="medium"
           plain
         >
-        <span>{{handleLabel(item, showLableKey)}}</span>
-          <!-- <field-formatterr
-            :label-key="showLableKey"
-            :data="item"
-            :tem="tem"
-            :tag="'Y'"
-            :field-type="fieldType"
-            :template-fields="templateFields"
-          /> -->
+          <span>{{ handleLabel(item, showLableKey) }}</span>
         </van-tag>
       </div>
       <input
         v-else
         :placeholder="placeholder"
+        :value="selectedValue"
         class="van-field__control"
         readonly
       />
@@ -83,8 +77,11 @@
         :visible="showPopup"
         :template-key="templateKey"
         :params="params"
+        :label-field="labelField"
         :values="selectedValue"
         :multiple="multiple"
+        :search-placeholder="searchPlaceholder"
+        :default-filter-list-col="defaultFilterListCol"
         :left-text="leftText"
         :id-key="idKey"
         :value-key="valueKey"
@@ -95,6 +92,7 @@
         :template-fields="templateFields"
         :field-type="fieldType"
         :dynamic-params="dynamicParams"
+        :label="label"
         @init-data="initData"
         @cancel="onCancel"
         @confirm="onConfirm"
@@ -123,16 +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: 'ibps-custom-dialog',
+  name: 'IbpsCustomDialog',
   components: {
-    DataTemplatePopup,
-    FieldFormatter,
-    FieldFormatterr
-
+    DataTemplatePopup
   },
   mixins: [FieldMixin],
   props: {
@@ -147,7 +142,7 @@ export default {
       // 存储类型 对应[多选]有效,json: json字符串,id:只存储id, array:存储数组数据 ,arrayId: 字符串类型。
       type: String,
       default: 'json',
-      validator: function(value) {
+      validator: function (value) {
         return ['json', 'id', 'array', 'arrayId'].indexOf(value) !== -1
       }
     },
@@ -172,14 +167,17 @@ export default {
       valueKey: 'id_',
       labelKey: '',
       parentIdKey: '',
+      searchPlaceholder: '',
       isTree: false,
+      labelField: null,
       queryKey: '',
       params: {},
       templateFields: {}, // 模版字段
       showPopup: false, // 弹窗
       selectedData: [], // 选中的数据,这个值是用于展示的
       selectedValue: [], // 选中的值 是valueKey的值
-      tem: {}
+      tem: {},
+      defaultFilterListCol: ['di_dian_']
     }
   },
   computed: {
@@ -229,20 +227,19 @@ export default {
     loadData(key) {
       const params = {}
       loadDataTemplateByKey(key, params)
-        .then(data => {
+        .then((data) => {
           const template = getDataTemplateListTemplate(data)
-          this.tem ={...template}
+          this.tem = { ...template }
           this.templateFields = buildDataTemplateFields(data.fields)
           this.buildKey(data, template)
         })
-        .catch(e => {
+        .catch((e) => {
           console.error(e)
         })
     },
     buildKey(dataTemplate, template) {
-      
       this.idKey = this.valueKey = dataTemplate['unique']
-      this.queryKey = this.getQueryKey(template['query_columns'])
+      // this.queryKey = this.getQueryKey(template['query_columns'])
       if (dataTemplate.showType === 'tree') {
         // 树形
         this.isTree = true
@@ -254,15 +251,26 @@ export default {
         }
       } else if (dataTemplate.showType === 'list') {
         this.isTree = false
-        const displayColumns = template['result_columns']
+        const displayColumns = template['display_columns']
         if (this.$utils.isNotEmpty(displayColumns)) {
-          this.labelKey =
-            (displayColumns[0] ? displayColumns[0]['name'] : '') || ''
+          const titleCol = displayColumns.find(
+            (t) =>
+              t.isTitle === 'Y' && !this.defaultFilterListCol.includes(t.name)
+          )
+          // 列表标题无设置则默认第一列
+          const labelField = titleCol || displayColumns[0]
+          this.labelField = labelField
+          this.labelKey = labelField ? labelField.name : ''
+          this.queryKey = labelField ? labelField.name : ''
+          this.searchPlaceholder = labelField
+            ? '请输入' + labelField.label + '查询'
+            : ''
         }
       }
     },
     initSelectedData() {
       this.selectedValue = this.getArrayValue(this.value)
+      // console.log('this.selectedValue===>', this.selectedValue)
     },
     getArrayValue(value) {
       if (this.$utils.isEmpty(value)) {
@@ -277,7 +285,7 @@ export default {
           const data = o
             ? [this.$utils.parseData(value)]
             : this.$utils.parseData(value)
-          return data.map(d => {
+          return data.map((d) => {
             return d[this.valueKey]
           })
         } catch (error) {
@@ -291,7 +299,7 @@ export default {
         // 数组id
         return value
       } else {
-        return value.map(d => {
+        return value.map((d) => {
           return d[this.valueKey]
         })
       }
@@ -303,7 +311,7 @@ export default {
         if (this.$utils.isEmpty(value)) {
           return ''
         }
-        value.forEach(v => {
+        value.forEach((v) => {
           if (this.$utils.isEmpty(v)) {
             return true
           }
@@ -315,7 +323,7 @@ export default {
         return JSON.stringify(res)
       } else if (this.store === 'id') {
         // id
-        value.forEach(v => {
+        value.forEach((v) => {
           res.push(v[this.valueKey])
         })
         return res.join(this.storeSeparator)
@@ -332,7 +340,7 @@ export default {
         //         return res.join(this.storeSeparator)
       } else if (this.store === 'arrayId') {
         // 数组id
-        return value.map(d => {
+        return value.map((d) => {
           return d[this.valueKey]
         })
       } else {
@@ -372,15 +380,16 @@ export default {
       const result = this.formatData(value)
       this.$emit('input', result)
       // 处理回调
+      console.log('this.selectedData=-==>', this.formatData(value))
       this.$nextTick(() => {
         this.$emit('callback', this.selectedData)
       })
     },
     // 回调初始化数据
     initData(data) {
+      console.log('data===>', this.label, data)
       this.selectedData = data
       this._setInputValue()
-
       this.$nextTick(() => {
         this.$emit('attr-callback', this.selectedData)
       })
@@ -397,7 +406,7 @@ export default {
       if (this.store === 'json') {
         // json
         const resutlList = JSON.parse(this.$utils.newData(data))
-        resutlList.forEach(element => {
+        resutlList.forEach((element) => {
           element[this.dialogId] = element[this.valueKey]
           element[this.dialogTitle] = element[this.labelKey]
         })

+ 139 - 80
src/business/platform/data/templaterender/linkdata/index.vue

@@ -14,7 +14,6 @@
     :is-link="isLink"
     :error="error"
     :error-message="errorMessage"
-
     :arrow-direction="arrowDirection"
     :label-class="labelClass"
     :label-width="labelWidth"
@@ -25,12 +24,19 @@
     :left-icon="leftIcon"
     :right-icon="rightIcon"
     :icon-prefix="iconPrefix"
-    :rules="editable?rules:null"
+    :rules="editable ? rules : null"
+    class="no-err"
     readonly
     @click-input="onClick"
   >
     <template #label>
-      {{ label }}<van-icon v-if="desc && descPosition==='lableIcon'" name="warning" class="ibps-dialog-icon" @click="$action.descDialog({ title:label, message:desc })" />
+      {{ label
+      }}<van-icon
+        v-if="desc && descPosition === 'lableIcon'"
+        name="warning"
+        class="ibps-dialog-icon"
+        @click="$action.descDialog({ title: label, message: desc })"
+      />
     </template>
     <template v-if="editable" #right-icon>
       <van-icon
@@ -41,29 +47,35 @@
       />
       <van-icon
         v-else
-        :name="showPopup?'arrow-up':'arrow-down'"
+        :name="showPopup ? 'arrow-up' : 'arrow-down'"
         @click.native.stop="onClick"
       />
-
     </template>
     <template #input>
       <div v-if="$utils.isNotEmpty(selectedData)" class="van-field__control">
         <van-tag
-          v-for="(item,index) in selectedData"
-          :key="item[valueKey]+index"
+          v-for="(item, index) in selectedData"
+          :key="item[linkValueKey] + index"
           type="primary"
           class="ibps-tag-span"
           size="medium"
           plain
         >
           <field-formatter
-            :label-key="showLableKey"
+            :label-key="linkValueKey"
             :data="item"
             :template-fields="templateFields"
           />
         </van-tag>
       </div>
-      <input v-else :placeholder="placeholder" class="van-field__control" readonly>
+      <!-- 关联数据审阅时回显问题 -->
+      <input
+        v-else
+        :placeholder="placeholder"
+        :value="selectedValue"
+        class="van-field__control"
+        readonly
+      />
       <!-- 数据模版对话框-->
       <data-template-popup
         :tem="tem"
@@ -72,22 +84,21 @@
         :params="params"
         :values="selectedValue"
         :multiple="multiple"
-
         :left-text="leftText"
         :id-key="idKey"
-        :value-key="valueKey"
-        :label-key="labelKey"
+        :value-key="linkValueKey"
+        :label-key="linkLabelKey"
         :parent-id-key="parentIdKey"
         :is-tree="isTree"
         :query-key="queryKey"
+        field-type="linkdata"
+        :search-placeholder="'请输入'"
         :template-fields="templateFields"
         :dynamic-params="dynamicParams"
-
         @init-data="initData"
         @cancel="onCancel"
         @confirm="onConfirm"
       />
-
     </template>
   </van-field>
 </template>
@@ -106,51 +117,52 @@ import i18n from '@/utils/i18n' // Internationalization 国际化
 
 import { isDef } from 'vant/lib/utils'
 import FieldMixin from '@/mixins/field'
-import { loadDataTemplateByKey, getDataTemplateListTemplate, buildDataTemplateFields } from '@/business/platform/data/utils'
+import {
+  loadDataTemplateByKey,
+  getDataTemplateListTemplate,
+  buildDataTemplateFields
+} from '@/business/platform/data/utils'
 import DataTemplatePopup from '../../data-template/template'
 import FieldFormatter from '../../data-template/field-formatter'
 
 export default {
-  name: 'ibps-linkdata',
+  name: 'IbpsLinkdata',
   components: {
     DataTemplatePopup,
     FieldFormatter
   },
   mixins: [FieldMixin],
   props: {
-    templateKey: { // 数据模版key
+    templateKey: {
+      // 数据模版key
       type: String,
       required: true
     },
-    store: { // 存储类型 对应[多选]有效,json: json字符串,id:只存储id, array:存储数组数据 ,arrayId: 字符串类型。
+    store: {
+      // 存储类型 对应[多选]有效,json: json字符串,id:只存储id, array:存储数组数据 ,arrayId: 字符串类型。
       type: String,
       default: 'id',
-      validator: function(value) {
+      validator: function (value) {
         return ['json', 'id', 'array', 'arrayId'].indexOf(value) !== -1
       }
     },
-    storeSeparator: { // 存储值分割符,对于设置字符串类型的分隔符
+    storeSeparator: {
+      // 存储值分割符,对于设置字符串类型的分隔符
       type: String,
       default: ','
     },
+    fieldOptions: {
+      type: Object
+    },
     leftText: {
       type: String,
       default: i18n.t('cancel')
     },
-    multiple: { // 是否多选
+    multiple: {
+      // 是否多选
       type: Boolean,
       default: false
     },
-    valueKey: { // 值key
-      type: String
-    },
-    labelType: { // 文本类型
-      type: String,
-      default: 'first'
-    },
-    labelKey: { // 文本key
-      type: [String, Function]
-    },
     emptyText: {
       type: String,
       default: '暂无数据'
@@ -175,10 +187,37 @@ export default {
   },
   computed: {
     showClear() {
-      return this.clearable && this.$utils.isNotEmpty(this.value) && isDef(this.value) && this.editable
+      return (
+        this.clearable &&
+        this.$utils.isNotEmpty(this.value) &&
+        isDef(this.value) &&
+        this.editable
+      )
+    },
+    linkValueKey() {
+      return this.fieldOptions['link_config']
+        ? this.fieldOptions['link_config'].id || ''
+        : ''
+    },
+    linkLabelType() {
+      return this.fieldOptions['link_config']
+        ? this.fieldOptions['link_config'].type || 'first'
+        : 'first'
+    },
+    linkLabelKey() {
+      return this.fieldOptions['link_config']
+        ? this.fieldOptions['link_config'].text || ''
+        : ''
+    },
+    linkStructure() {
+      return this.fieldOptions['link_config']
+        ? this.fieldOptions['link_config'].structure || 'list'
+        : 'list'
     },
-    showLableKey() {
-      return this.labelKey
+    linkConfig() {
+      return this.fieldOptions['link_config']
+        ? this.fieldOptions['link_config'] || {}
+        : {}
     }
   },
   watch: {
@@ -201,36 +240,36 @@ export default {
     // 加载加载配置数据
     loadData(key) {
       const params = {}
-      loadDataTemplateByKey(key, params).then((data) => {
-        const template = getDataTemplateListTemplate(data)
-        this.tem = { ...template }
-        this.templateFields = buildDataTemplateFields(data.fields)
-        this.buildKey(data, template)
-      }).catch((e) => {
-        console.error(e)
-      })
+      loadDataTemplateByKey(key, params)
+        .then((data) => {
+          const template = getDataTemplateListTemplate(data)
+          this.tem = { ...template }
+          this.templateFields = buildDataTemplateFields(data.fields)
+          this.buildKey(data, template)
+        })
+        .catch((e) => {
+          console.error(e)
+        })
     },
     buildKey(dataTemplate, template) {
       this.idKey = dataTemplate['unique']
       this.queryKey = this.getQueryKey(template['query_columns'])
       const resultColumns = template['result_columns']
-      // console.log(resultColumns, 'resultColumnsresultColumns')
-      if (this.$utils.isEmpty(resultColumns)) { return }
-      this.labelKey = resultColumns[0]['name']
-      if (dataTemplate.showType === 'tree') { // 树形
+      console.log(resultColumns, 'resultColumnsresultColumns')
+      if (this.$utils.isEmpty(resultColumns)) {
+        return
+      }
+      // this.linkLabelKey = resultColumns[0]['name']
+      if (dataTemplate.showType === 'tree') {
+        // 树形
         this.isTree = true
         const displayColumns = template['display_columns']
         if (this.$utils.isNotEmpty(displayColumns)) {
-          this.labelKey = displayColumns['name_key']
           this.idKey = displayColumns['id_key']
           this.parentIdKey = displayColumns['pid_key']
         }
       } else if (dataTemplate.showType === 'list') {
         this.isTree = false
-        const displayColumns = template['display_columns']
-        if (this.$utils.isNotEmpty(displayColumns)) {
-          this.labelKey = (displayColumns[0] ? displayColumns[0]['name'] : '') || ''
-        }
       }
     },
     initSelectedData() {
@@ -240,56 +279,72 @@ export default {
       if (this.$utils.isEmpty(value)) {
         return []
       }
-      if (this.store === 'json') { // json
-        const o = Object.prototype.toString.call(this.$utils.parseData(value)) === '[object Object]'
+      if (this.store === 'json') {
+        // json
+        const o =
+          Object.prototype.toString.call(this.$utils.parseData(value)) ===
+          '[object Object]'
         try {
-          const data = o ? [this.$utils.parseData(value)] : this.$utils.parseData(value)
+          const data = o
+            ? [this.$utils.parseData(value)]
+            : this.$utils.parseData(value)
           return data.map((d) => {
-            return d[this.valueKey]
+            return d[this.linkValueKey]
           })
         } catch (error) {
           console.error(error)
           return []
         }
-      } else if (this.store === 'id') { // id
+      } else if (this.store === 'id') {
+        // id
         return value.split(this.storeSeparator)
-      } else if (this.store === 'arrayId') { // 数组id
+      } else if (this.store === 'arrayId') {
+        // 数组id
         return value
       } else {
         return value.map((d) => {
-          return d[this.valueKey]
+          return d[this.linkValueKey]
         })
       }
     },
     getStoreValue(value) {
+      console.log('this.store==>', this.store, this.linkValueKey)
       const res = []
-      if (this.store === 'json') { // json
+      if (this.store === 'json') {
+        // json
         if (this.$utils.isEmpty(value)) {
           return ''
         }
-        value.forEach(v => {
-          if (this.$utils.isEmpty(v)) { return true }
+        value.forEach((v) => {
+          if (this.$utils.isEmpty(v)) {
+            return true
+          }
           const o = {}
-          o[this.valueKey] = v[this.valueKey]
-          o[this.labelKey] = v[this.labelKey]
+          o[this.linkValueKey] = v[this.linkValueKey]
+          o[this.linkLabelKey] = v[this.linkLabelKey]
           res.push(o)
         })
         return JSON.stringify(res)
-      } else if (this.store === 'id') { // id
-        value.forEach(v => {
-          res.push(v[this.valueKey])
+      } else if (this.store === 'id') {
+        // id
+        value.forEach((v) => {
+          res.push(v[this.linkValueKey])
         })
         return res.join(this.storeSeparator)
-      } else if (this.store === 'arrayId') { // 数组id
+      } else if (this.store === 'arrayId') {
+        // 数组id
         return value.map((d) => {
-          return d[this.valueKey]
+          return d[this.linkValueKey]
         })
-      } else { // 数组
+      } else {
+        // 数组
         return value || []
       }
     },
     onClick() {
-      if (!this.editable) { return }
+      if (!this.editable) {
+        return
+      }
       this.initSelectedData()
       this.showPopup = true
     },
@@ -305,8 +360,8 @@ export default {
         return
       }
       this.showPopup = false
-
       this.selectedData = selectedData
+      console.log('selectedDataselectedDataselectedData==>', selectedData)
       this.setInputValue(this.getStoreValue(selectedData))
     },
     onRightIconClick() {
@@ -317,6 +372,7 @@ export default {
     },
     setInputValue(value) {
       const result = this.formatData(value)
+      console.log('result===>', result)
       this.$emit('input', result)
       // 处理回调
       this.$nextTick(() => {
@@ -326,6 +382,7 @@ export default {
     },
     // 回调初始化数据
     initData(data) {
+      console.log('2132132', data)
       this.selectedData = data
       this._setInputValue()
       this.$nextTick(() => {
@@ -338,14 +395,16 @@ export default {
       }
     },
     formatData(data) {
+      console.log('222222222222222222222222222===>', data)
       if (this.$utils.isEmpty(data)) {
         return ''
       }
-      if (this.store === 'json') { // json
+      if (this.store === 'json') {
+        // json
         const resutlList = JSON.parse(this.$utils.newData(data))
-        resutlList.forEach(element => {
-          element[this.dialogId] = element[this.valueKey]
-          element[this.dialogTitle] = element[this.labelKey]
+        resutlList.forEach((element) => {
+          element[this.dialogId] = element[this.linkValueKey]
+          element[this.dialogTitle] = element[this.linkLabelKey]
         })
         return JSON.stringify(resutlList)
       } else if (this.store === 'id') {
@@ -356,9 +415,9 @@ export default {
 }
 </script>
 <style lang="scss" scoped>
-  .ibps-tag-span {
-    ::v-deep .ibps-data-template-data {
-      color: #4399fb !important;
-    }
+.ibps-tag-span {
+  ::v-deep .ibps-data-template-data {
+    color: #4399fb !important;
   }
-  </style>
+}
+</style>

+ 100 - 73
src/business/platform/data/templaterender/utils/JComposeTemplate.js

@@ -1,4 +1,3 @@
-
 /**
  * 数据模版--封装自定义代码扩展接口
  */
@@ -14,86 +13,114 @@ import router from '@/router'
 // 定义全局
 var JComposeTemplate
 if (!window.JComposeTemplate) {
-    JComposeTemplate = window.JComposeTemplate = {}
+  JComposeTemplate = window.JComposeTemplate = {}
 } else {
-    JComposeTemplate = window.JComposeTemplate
+  JComposeTemplate = window.JComposeTemplate
 }
 /**
-   * 封装自定义代码扩展接口
-   */
+ * 封装自定义代码扩展接口
+ */
 _.extend(JComposeTemplate, {
-    // 已经初始化
-    _isInitialization: false,
-    _isLoadJavaScriptFile: false,
-    // 初始化表单
-    _init: function (template) {
-        if (this._isInitialization) return
-        this.$template = template
-        this.$vue = Vue
-        this.$request = request
-        this.$dialog = dialog
-        this.$common = common
-        this.$router = router
-        this.$store = store
-        this.$import = _import
-        this._ = _
-        this._isInitialization = true
-    },
+  // 已经初始化
+  _isInitialization: false,
+  _isLoadJavaScriptFile: false,
+  // 初始化表单
+  _init: function (template) {
+    if (this._isInitialization) return
+    this.$template = template
+    this.$vue = Vue
+    this.$request = request
+    this.$dialog = dialog
+    this.$common = common
+    this.$router = router
+    this.$store = store
+    this.$import = _import
+    this._ = _
+    this._isInitialization = true
+  },
 
-    // 页面加载
-    _onLoad: function (template) {
-        this._init(template)
-        if (_.isFunction(this.onLoad)) {
-            this.onLoad(template)
-        }
-    },
+  // 页面加载
+  _onLoad: function (template) {
+    this._init(template)
+    if (_.isFunction(this.onLoad)) {
+      this.onLoad(template)
+    }
+  },
 
-    // 加载按钮
-    _onLoadActions: function (template) {
-        if (_.isFunction(this.onLoadActions)) {
-            this.onLoadActions(template)
-        }
-    },
-    // 按钮提交前事件
-    _beforeSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.beforeSubmit)) {
-            return this.beforeSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
+  // 加载按钮
+  _onLoadActions: function (template) {
+    if (_.isFunction(this.onLoadActions)) {
+      this.onLoadActions(template)
+    }
+  },
+  // 按钮提交前事件
+  _beforeSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.beforeSubmit)) {
+      return this.beforeSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
 
-    // 按钮提交后事件
-    _afterSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.afterSubmit)) {
-            return this.afterSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
-    // 单元格自定义格式
-    _customFormatter: function (template, name, value, rowData, column) {
-        if (_.isFunction(this.customFormatter)) {
-            return this.customFormatter(template, name, value, rowData, column)
-        }
-    },
-    // 清理所有自定义事件
-    cleanEvents: function () {
-        this.onLoad = null
-        this.onLoadActions = null
-        this.onValidate = null
-        this.afterSubButton = null
-        this.beforeSubButton = null
-        this.summaryMethod = null
-        this.afterSubmit = null
-        this.beforeSubmit = null
-        this.customFormatter = null
-        this._isInitialization = false
+  // 按钮提交后事件
+  _afterSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.afterSubmit)) {
+      return this.afterSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
+  // 单元格自定义格式
+  _customFormatter: function (template, name, value, rowData, column) {
+    if (_.isFunction(this.customFormatter)) {
+      return this.customFormatter(template, name, value, rowData, column)
     }
+  },
+  // 清理所有自定义事件
+  cleanEvents: function () {
+    this.onLoad = null
+    this.onLoadActions = null
+    this.onValidate = null
+    this.afterSubButton = null
+    this.beforeSubButton = null
+    this.summaryMethod = null
+    this.afterSubmit = null
+    this.beforeSubmit = null
+    this.customFormatter = null
+    this._isInitialization = false
+  }
 })
 
 export default JComposeTemplate

+ 100 - 72
src/business/platform/data/templaterender/utils/JDialogTemplate.js

@@ -13,86 +13,114 @@ import router from '@/router'
 // 定义全局
 var JDialog
 if (!window.JDialog) {
-    JDialog = window.JDialog = {}
+  JDialog = window.JDialog = {}
 } else {
-    JDialog = window.JDialog
+  JDialog = window.JDialog
 }
 /**
-   * 封装自定义代码扩展接口
-   */
+ * 封装自定义代码扩展接口
+ */
 _.extend(JDialog, {
-    // 已经初始化
-    _isInitialization: false,
-    _isLoadJavaScriptFile: false,
-    // 初始化表单
-    _init: function (template) {
-        if (this._isInitialization) return
-        this.$template = template
-        this.$vue = Vue
-        this.$request = request
-        this.$dialog = dialog
-        this.$common = common
-        this.$router = router
-        this.$store = store
-        this.$import = _import
-        this._ = _
-        this._isInitialization = true
-    },
+  // 已经初始化
+  _isInitialization: false,
+  _isLoadJavaScriptFile: false,
+  // 初始化表单
+  _init: function (template) {
+    if (this._isInitialization) return
+    this.$template = template
+    this.$vue = Vue
+    this.$request = request
+    this.$dialog = dialog
+    this.$common = common
+    this.$router = router
+    this.$store = store
+    this.$import = _import
+    this._ = _
+    this._isInitialization = true
+  },
 
-    // 页面加载
-    _onLoad: function (template) {
-        this._init(template)
-        if (_.isFunction(this.onLoad)) {
-            this.onLoad(template)
-        }
-    },
+  // 页面加载
+  _onLoad: function (template) {
+    this._init(template)
+    if (_.isFunction(this.onLoad)) {
+      this.onLoad(template)
+    }
+  },
 
-    // 加载按钮
-    _onLoadActions: function (template) {
-        if (_.isFunction(this.onLoadActions)) {
-            this.onLoadActions(template)
-        }
-    },
-    // 按钮提交前事件
-    _beforeSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.beforeSubmit)) {
-            return this.beforeSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
+  // 加载按钮
+  _onLoadActions: function (template) {
+    if (_.isFunction(this.onLoadActions)) {
+      this.onLoadActions(template)
+    }
+  },
+  // 按钮提交前事件
+  _beforeSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.beforeSubmit)) {
+      return this.beforeSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
 
-    // 按钮提交后事件
-    _afterSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.afterSubmit)) {
-            return this.afterSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
-    // 单元格自定义格式
-    _customFormatter: function (template, name, value, rowData, column) {
-        if (_.isFunction(this.customFormatter)) {
-            return this.customFormatter(template, name, value, rowData, column)
-        }
-    },
-    // 清理所有自定义事件
-    cleanEvents: function () {
-        this.onLoad = null
-        this.onLoadActions = null
-        this.onValidate = null
-        this.afterSubButton = null
-        this.beforeSubButton = null
-        this.summaryMethod = null
-        this.afterSubmit = null
-        this.beforeSubmit = null
-        this.customFormatter = null
-        this._isInitialization = false
+  // 按钮提交后事件
+  _afterSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.afterSubmit)) {
+      return this.afterSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
+  // 单元格自定义格式
+  _customFormatter: function (template, name, value, rowData, column) {
+    if (_.isFunction(this.customFormatter)) {
+      return this.customFormatter(template, name, value, rowData, column)
     }
+  },
+  // 清理所有自定义事件
+  cleanEvents: function () {
+    this.onLoad = null
+    this.onLoadActions = null
+    this.onValidate = null
+    this.afterSubButton = null
+    this.beforeSubButton = null
+    this.summaryMethod = null
+    this.afterSubmit = null
+    this.beforeSubmit = null
+    this.customFormatter = null
+    this._isInitialization = false
+  }
 })
 
 export default JDialog

+ 98 - 70
src/business/platform/data/templaterender/utils/JTemplate.js

@@ -13,86 +13,114 @@ import router from '@/router'
 // 定义全局
 var JTemplate
 if (!window.JTemplate) {
-    JTemplate = window.JTemplate = {}
+  JTemplate = window.JTemplate = {}
 } else {
-    JTemplate = window.JTemplate
+  JTemplate = window.JTemplate
 }
 /**
  * 封装自定义代码扩展接口
  */
 _.extend(JTemplate, {
-    // 已经初始化
-    _isInitialization: false,
-    _isLoadJavaScriptFile: false,
-    // 初始化表单
-    _init: function (template) {
-        if (this._isInitialization) return
-        this.$template = template
-        this.$vue = Vue
-        this.$request = request
-        this.$dialog = dialog
-        this.$common = common
-        this.$router = router
-        this.$store = store
-        this.$import = _import
-        this._ = _
-        this._isInitialization = true
-    },
+  // 已经初始化
+  _isInitialization: false,
+  _isLoadJavaScriptFile: false,
+  // 初始化表单
+  _init: function (template) {
+    if (this._isInitialization) return
+    this.$template = template
+    this.$vue = Vue
+    this.$request = request
+    this.$dialog = dialog
+    this.$common = common
+    this.$router = router
+    this.$store = store
+    this.$import = _import
+    this._ = _
+    this._isInitialization = true
+  },
 
-    // 页面加载
-    _onLoad: function (template) {
-        this._init(template)
-        if (_.isFunction(this.onLoad)) {
-            this.onLoad(template)
-        }
-    },
+  // 页面加载
+  _onLoad: function (template) {
+    this._init(template)
+    if (_.isFunction(this.onLoad)) {
+      this.onLoad(template)
+    }
+  },
 
-    // 加载按钮
-    _onLoadActions: function (template, action, button, type, row) {
-        if (_.isFunction(this.onLoadActions)) {
-            return this.onLoadActions(template, action, button, type, row)
-        }
-    },
-    // 按钮提交前事件
-    _beforeSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.beforeSubmit)) {
-            return this.beforeSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
+  // 加载按钮
+  _onLoadActions: function (template, action, button, type, row) {
+    if (_.isFunction(this.onLoadActions)) {
+      return this.onLoadActions(template, action, button, type, row)
+    }
+  },
+  // 按钮提交前事件
+  _beforeSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.beforeSubmit)) {
+      return this.beforeSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
 
-    // 按钮提交后事件
-    _afterSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.afterSubmit)) {
-            return this.afterSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
-    // 单元格自定义格式
-    _customFormatter: function (template, name, value, rowData, column) {
-        if (_.isFunction(this.customFormatter)) {
-            return this.customFormatter(template, name, value, rowData, column)
-        }
-    },
-    // 清理所有自定义事件
-    cleanEvents: function () {
-        this.onLoad = null
-        this.onLoadActions = null
-        this.onValidate = null
-        this.afterSubButton = null
-        this.beforeSubButton = null
-        this.summaryMethod = null
-        this.afterSubmit = null
-        this.beforeSubmit = null
-        this.customFormatter = null
-        this._isInitialization = false
+  // 按钮提交后事件
+  _afterSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.afterSubmit)) {
+      return this.afterSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
+  // 单元格自定义格式
+  _customFormatter: function (template, name, value, rowData, column) {
+    if (_.isFunction(this.customFormatter)) {
+      return this.customFormatter(template, name, value, rowData, column)
     }
+  },
+  // 清理所有自定义事件
+  cleanEvents: function () {
+    this.onLoad = null
+    this.onLoadActions = null
+    this.onValidate = null
+    this.afterSubButton = null
+    this.beforeSubButton = null
+    this.summaryMethod = null
+    this.afterSubmit = null
+    this.beforeSubmit = null
+    this.customFormatter = null
+    this._isInitialization = false
+  }
 })
 
 export default JTemplate

+ 100 - 72
src/business/platform/data/templaterender/utils/JTreeTemplate.js

@@ -13,86 +13,114 @@ import router from '@/router'
 // 定义全局
 var JTreeTemplate
 if (!window.JTreeTemplate) {
-    JTreeTemplate = window.JTreeTemplate = {}
+  JTreeTemplate = window.JTreeTemplate = {}
 } else {
-    JTreeTemplate = window.JTreeTemplate
+  JTreeTemplate = window.JTreeTemplate
 }
 /**
-   * 封装自定义代码扩展接口
-  */
+ * 封装自定义代码扩展接口
+ */
 _.extend(JTreeTemplate, {
-    // 已经初始化
-    _isInitialization: false,
-    _isLoadJavaScriptFile: false,
-    // 初始化表单
-    _init: function (template) {
-        if (this._isInitialization) return
-        this.$template = template
-        this.$vue = Vue
-        this.$request = request
-        this.$dialog = dialog
-        this.$common = common
-        this.$router = router
-        this.$store = store
-        this.$import = _import
-        this._ = _
-        this._isInitialization = true
-    },
+  // 已经初始化
+  _isInitialization: false,
+  _isLoadJavaScriptFile: false,
+  // 初始化表单
+  _init: function (template) {
+    if (this._isInitialization) return
+    this.$template = template
+    this.$vue = Vue
+    this.$request = request
+    this.$dialog = dialog
+    this.$common = common
+    this.$router = router
+    this.$store = store
+    this.$import = _import
+    this._ = _
+    this._isInitialization = true
+  },
 
-    // 页面加载
-    _onLoad: function (template) {
-        this._init(template)
-        if (_.isFunction(this.onLoad)) {
-            this.onLoad(template)
-        }
-    },
+  // 页面加载
+  _onLoad: function (template) {
+    this._init(template)
+    if (_.isFunction(this.onLoad)) {
+      this.onLoad(template)
+    }
+  },
 
-    // 加载按钮
-    _onLoadActions: function (template) {
-        if (_.isFunction(this.onLoadActions)) {
-            this.onLoadActions(template)
-        }
-    },
-    // 按钮提交前事件
-    _beforeSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.beforeSubmit)) {
-            return this.beforeSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
+  // 加载按钮
+  _onLoadActions: function (template) {
+    if (_.isFunction(this.onLoadActions)) {
+      this.onLoadActions(template)
+    }
+  },
+  // 按钮提交前事件
+  _beforeSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.beforeSubmit)) {
+      return this.beforeSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
 
-    // 按钮提交后事件
-    _afterSubmit: function (template, action, position, selection, data, callback) {
-        if (_.isFunction(this.afterSubmit)) {
-            return this.afterSubmit(template, action, position, selection, data, callback)
-        }
-        if (_.isFunction(callback)) {
-            const flag = true
-            callback(flag)
-        }
-    },
-    // 单元格自定义格式
-    _customFormatter: function (template, name, value, rowData, column) {
-        if (_.isFunction(this.customFormatter)) {
-            return this.customFormatter(template, name, value, rowData, column)
-        }
-    },
-    // 清理所有自定义事件
-    cleanEvents: function () {
-        this.onLoad = null
-        this.onLoadActions = null
-        this.onValidate = null
-        this.afterSubButton = null
-        this.beforeSubButton = null
-        this.summaryMethod = null
-        this.afterSubmit = null
-        this.beforeSubmit = null
-        this.customFormatter = null
-        this._isInitialization = false
+  // 按钮提交后事件
+  _afterSubmit: function (
+    template,
+    action,
+    position,
+    selection,
+    data,
+    callback
+  ) {
+    if (_.isFunction(this.afterSubmit)) {
+      return this.afterSubmit(
+        template,
+        action,
+        position,
+        selection,
+        data,
+        callback
+      )
+    }
+    if (_.isFunction(callback)) {
+      const flag = true
+      callback(flag)
+    }
+  },
+  // 单元格自定义格式
+  _customFormatter: function (template, name, value, rowData, column) {
+    if (_.isFunction(this.customFormatter)) {
+      return this.customFormatter(template, name, value, rowData, column)
     }
+  },
+  // 清理所有自定义事件
+  cleanEvents: function () {
+    this.onLoad = null
+    this.onLoadActions = null
+    this.onValidate = null
+    this.afterSubButton = null
+    this.beforeSubButton = null
+    this.summaryMethod = null
+    this.afterSubmit = null
+    this.beforeSubmit = null
+    this.customFormatter = null
+    this._isInitialization = false
+  }
 })
 
 export default JTreeTemplate

+ 38 - 18
src/business/platform/data/templaterender/utils/index.js

@@ -1,6 +1,10 @@
-
 import Utils from '@/utils/util'
-import { numberThousands, numberCurrency, numberPercent, parseNumber } from '@/business/platform/form/utils/number'
+import {
+  numberThousands,
+  numberCurrency,
+  numberPercent,
+  parseNumber
+} from '@/business/platform/form/utils/number'
 // import QueryBuilder from '@/components/ibps-query-builder/constants'
 import FormFieldUtil from '@/business/platform/form/utils/formFieldUtil'
 
@@ -51,19 +55,21 @@ export function buildFelds(fields, datasets) {
   const fieldMap = {}
   const columns = FormFieldUtil.getColumns(fields)
 
-  columns.forEach(field => {
+  columns.forEach((field) => {
     if (Utils.isNotEmpty(field.field_name)) {
       fieldMap[field.field_name.toLowerCase()] = field
     }
   })
   const rtn = []
-  datasets.forEach(dataset => {
+  datasets.forEach((dataset) => {
     let field = fieldMap[dataset.name]
     if (Utils.isNotEmpty(dataset.name)) {
       field = fieldMap[dataset.name.toLowerCase()]
     }
     if (Utils.isNotEmpty(field)) {
-      dataset.field_name = Utils.isNotEmpty(field.name) ? field.name.toLowerCase() : field.name
+      dataset.field_name = Utils.isNotEmpty(field.name)
+        ? field.name.toLowerCase()
+        : field.name
       dataset.form_field_name = field.name
       dataset.field_type = field.field_type
       dataset.field_options = field.field_options
@@ -106,7 +112,7 @@ export function buildDynamicParams(conditions) {
  * 构建label标题
  * @param {*} dataTemplate
  */
- export function buildLabelTitle(dataTemplate) {
+export function buildLabelTitle(dataTemplate) {
   if (Utils.isEmpty(dataTemplate)) {
     return ''
   }
@@ -117,7 +123,10 @@ export function buildDynamicParams(conditions) {
   // console.log(dataTitle,'dataTitledataTitledataTitle')
   const titleType = Utils.isNotEmpty(dataTitle) ? dataTitle.type : 'first'
   const dataTitleTitle = dataTitle ? dataTitle.title : ''
-  const lableKey = template.result_columns && template.result_columns.length > 0 ? template.result_columns[0].name : ''
+  const lableKey =
+    template.result_columns && template.result_columns.length > 0
+      ? template.result_columns[0].name
+      : ''
 
   return buildLinkLabelTitle(titleType, dataTitleTitle, lableKey)
 }
@@ -125,17 +134,18 @@ export function buildDynamicParams(conditions) {
  * 构建label标题
  * @param {*} dataTemplate
  */
- export function buildLinkLabelTitle(titleType = 'first', dataTitle, lableKey) {
+export function buildLinkLabelTitle(titleType = 'first', dataTitle, lableKey) {
   if (titleType === 'first') {
     return lableKey
   } else {
-    return function(data) {
+    return function (data) {
       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)) { // 对字段进行处理
+        if (/^\$(_widget_)/.test(n)) {
+          // 对字段进行处理
           const f = n.replace('$_widget_', '').split('#')
           a = data[f[0]] || ''
         }
@@ -154,7 +164,8 @@ export function filterNumber(data, fieldOptions = {}) {
   const type = fieldOptions.number_type || 'orig'
   if (type === 'orig') {
     return value
-  } else if (type === 'integer') { // 整型
+  } else if (type === 'integer') {
+    // 整型
     const val = value
     if (fieldOptions.number_format === 'thousands') {
       return numberThousands(val)
@@ -165,8 +176,13 @@ export function filterNumber(data, fieldOptions = {}) {
     } else {
       return val
     }
-  } else if (type === 'number') { // 数字
-    const val = parseNumber(value, fieldOptions.decimal_places, fieldOptions.decimal_scale)
+  } else if (type === 'number') {
+    // 数字
+    const val = parseNumber(
+      value,
+      fieldOptions.decimal_places,
+      fieldOptions.decimal_scale
+    )
     if (fieldOptions.number_format === 'thousands') {
       return numberThousands(val)
     } else if (fieldOptions.number_format === 'capital') {
@@ -175,8 +191,13 @@ export function filterNumber(data, fieldOptions = {}) {
       return numberPercent(val)
     }
     return val
-  } else if (type === 'currency') { // 货币
-    let val = parseNumber(value, fieldOptions.decimal_places, fieldOptions.decimal_scale)
+  } else if (type === 'currency') {
+    // 货币
+    let val = parseNumber(
+      value,
+      fieldOptions.decimal_places,
+      fieldOptions.decimal_scale
+    )
     if (fieldOptions.number_format === 'thousands') {
       val = numberThousands(val)
     } else if (fieldOptions.number_format === 'capital') {
@@ -184,9 +205,8 @@ export function filterNumber(data, fieldOptions = {}) {
     } else if (fieldOptions.number_format === 'percent') {
       val = numberPercent(val)
     }
-    return (fieldOptions.prefix || '') + (val) + (fieldOptions.suffix || '')
+    return (fieldOptions.prefix || '') + val + (fieldOptions.suffix || '')
   } else {
     return value
   }
 }
-