Преглед изворни кода

merge multipleSearch:列表查询条件支持多选

cfort пре 2 година
родитељ
комит
95dcafb35a

+ 54 - 11
src/business/platform/data/components/search-form/index.vue

@@ -42,7 +42,9 @@
                     :disabled="item.disabled"
                     :placeholder="item.placeholder"
                     :style="itemStyle + (item.itemWidth ? `width: ${item.itemWidth}px;` : 'width: 150px')"
+                    multiple
                     clearable
+                    collapse-tags
                     @keyup.enter.native.stop="handleEnter"
                 >
                     <el-option
@@ -175,7 +177,7 @@
                     v-model="params[item.modelValue]"
                     :type-key="item.field_options.dictionary"
                     style="width: 150px;"
-                    :multiple="false"
+                    :multiple="true"
                     :disabled="item.disabled"
                     clearable
                 />
@@ -188,11 +190,12 @@
                     :size="item.size ? item.size : 'mini'"
                     :type="item.selectorType||'user'"
                     :placeholder="item.placeholder"
-                    :multiple="false"
+                    :multiple="true"
                     :store="'id'"
                     :disabled="item.disabled"
                     :filter="item.field_options.filter || []"
                     :filtrate="true"
+                    :temp-search="true"
                 />
                 <!--自定义对话框-->
                 <ibps-custom-dialog
@@ -202,11 +205,12 @@
                     :disabled="item.disabled"
                     :template-key="item.field_options.dialog"
                     style="width: 150px;"
-                    :multiple="false"
+                    :multiple="true"
                     :store="item.field_options.store"
                     :icon="item.field_options.icon?'ibps-icon-'+item.field_options.icon:'ibps-icon-search'"
                     :type="item.field_options.dialog_type||'dialog'"
                     :dynamic-params="getLinkDynamicParams(item.field_options,params)"
+                    :temp-search="true"
                 />
                 <!-- 关联数据-->
                 <ibps-link-data
@@ -215,7 +219,7 @@
                     :size="item.size ? item.size : 'mini'"
                     :template-key="item.field_options.linkdata"
                     style="width: 150px;"
-                    :multiple="item.field_options.multiple === 'Y'"
+                    :multiple="true"
                     :dynamic-params="getLinkDynamicParams(item.field_options,params)"
                     :value-key="getLinkValueKey(item.field_options)"
                     :label-type="getLinkLabelType(item.field_options)"
@@ -361,20 +365,59 @@ export default {
          */
         getSearcFormData () {
             const { params, nameParams, datePrefix, format } = this
-            const formattedForm = {}
+            // TODO: 过滤多余筛选条件数据
+            // const allKey = Object.keys(params)
+            const formattedForm = {
+                arg: {
+                    relation: 'AND',
+                    parameters: []
+                }
+            }
             Object.keys(params).forEach(v => {
                 if (v && v.indexOf(datePrefix) === -1) {
                     const val = format[v] ? format[v](params[v], v) : params[v]
-                    if (this.$utils.isNotEmpty(val) && !Array.isArray(val)) {
-                        let key = v
-                        if (nameParams[v]) {
-                            key = nameParams[v]
+                    if (this.$utils.isNotEmpty(val)) {
+                        const key = nameParams[v] || v
+                        if (!Array.isArray(val)) {
+                            const valArr = val.split(',')
+                            if (valArr.length > 1) {
+                                const parameters = valArr.map(i => ({
+                                    key,
+                                    value: i,
+                                    param: this.$utils.guid()
+                                }))
+                                formattedForm.arg.parameters.push({
+                                    relation: 'OR',
+                                    parameters
+                                })
+                            } else {
+                                const o = {
+                                    relation: 'AND',
+                                    parameters: [
+                                        {
+                                            key,
+                                            value: val,
+                                            param: this.$utils.guid()
+                                        }
+                                    ]
+                                }
+                                formattedForm.arg.parameters.push(o)
+                            }
+                        } else {
+                            const parameters = val.map(i => ({
+                                key,
+                                value: i,
+                                param: this.$utils.guid()
+                            }))
+                            formattedForm.arg.parameters.push({
+                                relation: 'OR',
+                                parameters
+                            })
                         }
-                        formattedForm[key] = val
                     }
                 }
             })
-            return formattedForm
+            return formattedForm.arg.parameters.length ? formattedForm : {}
         },
         /**
          *重置表单

+ 17 - 2
src/business/platform/data/templaterender/components/print.vue

@@ -19,7 +19,7 @@
                     <template v-for="(o, i) in modelList">
                         <div v-if="item[o.value]" :class="$style.item" :style="`width: ${o.width};`">
                             <span :class="$style.name">{{ o.label }}:</span>
-                            <span :class="$style.value">{{ item[o.value] }}</span>
+                            <span :class="$style.value">{{ item[o.value] | dateFormat(o) }}</span>
                         </div>
                     </template>
                     <vue-barcode
@@ -51,7 +51,7 @@
             },
             title: {
                 type: String,
-                default: '标签打印'
+                default: '标签打印(实际效果以打印页面为准)'
             },
             list: {
                 type: Array,
@@ -62,6 +62,15 @@
                 default: '物料'
             }
         },
+        filters: {
+            dateFormat (v, o) {
+                const s = ['daoKuRiQi', 'youXiaoQi']
+                if (s.includes(o.value)) {
+                    return v.replace(/-/g, '.')
+                }
+                return v
+            }
+        },
         components: {
             vueEasyPrint: () => import('vue-easy-print'),
             VueBarcode: () => import('vue-barcode')
@@ -156,11 +165,17 @@
                 }
             }
             .barcode {
+                width: 100%;
                 position: absolute;
                 text-align: center;
                 bottom: 4px;
                 left: 0;
                 right: 0;
+                :global {
+                    .vue-barcode-element {
+                        width: 100% !important;
+                    }
+                }
             }
             &:last-child {
                 margin-bottom: 0;

+ 438 - 433
src/business/platform/data/templaterender/custom-dialog/index.vue

@@ -1,31 +1,32 @@
 <template>
-  <div>
-    <ibps-selector
-      v-bind="$props"
-      :icon="icon"
-      :items="items"
-      :multiple="multiple"
-      :disabled="disabled"
-      :readonly="readonly"
-      :size="size"
-      :readonly-text="readonlyText"
-      @click="handleSelectorClick"
-      @remove="handleSelectorRemove"
-      v-on="$listeners"
-    />
-    <data-template-dialog
-      :visible.sync="selectorVisible"
-      :data="dataTemplate"
-      :dynamic-params="dynamicParams"
-      :multiple="multiple"
-      :value="selectorValue"
-      :label-key="labelKey"
-      :preview="false"
-      type="dialog"
-      @close="visible=>selectorVisible =visible"
-      @action-event="handleSelectorActionEvent"
-    />
-  </div>
+    <div>
+        <ibps-selector
+            v-bind="$props"
+            :icon="icon"
+            :items="items"
+            :multiple="multiple"
+            :disabled="disabled"
+            :readonly="readonly"
+            :size="size"
+            :readonly-text="readonlyText"
+            :temp-search="tempSearch"
+            @click="handleSelectorClick"
+            @remove="handleSelectorRemove"
+            v-on="$listeners"
+        />
+        <data-template-dialog
+            :visible.sync="selectorVisible"
+            :data="dataTemplate"
+            :dynamic-params="dynamicParams"
+            :multiple="multiple"
+            :value="selectorValue"
+            :label-key="labelKey"
+            :preview="false"
+            type="dialog"
+            @close="visible=>selectorVisible =visible"
+            @action-event="handleSelectorActionEvent"
+        />
+    </div>
 </template>
 <script>
 import { getByKey, transferByIds, queryDataById } from '@/api/platform/data/dataTemplate'
@@ -39,434 +40,438 @@ import { buildLabelTitle } from '../utils'
 import { TRANSFER_DATA } from '@/constant'
 
 export default {
-  components: {
-    DataTemplateDialog,
-    IbpsSelector
-  },
-  mixins: [emitter],
-  props: {
-    value: { // value
-      type: [String, Number, Object, Array],
-      default() {
-        return this.multiple ? [] : {}
-      }
-    },
-    templateKey: { // 数据模版key
-      type: String
-    },
-    dynamicParams: { // 动态参数
-      type: Object
-    },
-    // 存储类型 ,
-    // ①、id:只存储id 字符串,
-    // ②、json: json字符串,
-    store: {
-      type: String,
-      default: 'id',
-      validator: function(value) {
-        return ['id', 'json'].indexOf(value) !== -1
-      }
-    },
-    storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
-      type: String,
-      default: ','
-    },
-    placeholder: { // 输入框占位文本
-      type: String,
-      default: '请选择'
-    },
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
-    },
-    disabled: { // 禁用
-      type: Boolean,
-      default: false
-    },
-    size: {
-      type: String,
-      default: 'mini'
-    },
-    readonly: { // 只读
-      type: Boolean,
-      default: false
-    },
-    readonlyText: { // 只读样式
-      type: String,
-      default: 'text'
-    },
-    icon: {
-      type: String,
-      default: 'search-plus'
-    }
-  },
-  data() {
-    return {
-      initialization: false,
-      dataTemplate: {},
-      labelKey: '',
-      valueKey: '',
-      selectorVisible: false,
-      selectorValue: this.multiple ? [] : {},
-      cacheData: {},
-      bindIdValue: ''
-    }
-  },
-  computed: {
-    items() {
-      if (this.$utils.isEmpty(this.selectorValue)) return []
-      if (this.multiple) {
-        return this.selectorValue.map(data => {
-          return this.handleLabel(data)
-        })
-      } else {
-        return [this.handleLabel(this.selectorValue)]
-      }
-    }
-  },
-  watch: {
-    value: {
-      handler(val, oldVal) {
-        this.initData()
-        if (!valueEquals(val, oldVal)) {
-          this.dispatch('ElFormItem', 'el.form.change', val)
+    components: {
+        DataTemplateDialog,
+        IbpsSelector
+    },
+    mixins: [emitter],
+    props: {
+        value: { // value
+            type: [String, Number, Object, Array],
+            default () {
+                return this.multiple ? [] : {}
+            }
+        },
+        templateKey: { // 数据模版key
+            type: String
+        },
+        dynamicParams: { // 动态参数
+            type: Object
+        },
+        // 存储类型 ,
+        // ①、id:只存储id 字符串,
+        // ②、json: json字符串,
+        store: {
+            type: String,
+            default: 'id',
+            validator: function (value) {
+                return ['id', 'json'].indexOf(value) !== -1
+            }
+        },
+        storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
+            type: String,
+            default: ','
+        },
+        placeholder: { // 输入框占位文本
+            type: String,
+            default: '请选择'
+        },
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        disabled: { // 禁用
+            type: Boolean,
+            default: false
+        },
+        size: {
+            type: String,
+            default: 'mini'
+        },
+        readonly: { // 只读
+            type: Boolean,
+            default: false
+        },
+        readonlyText: { // 只读样式
+            type: String,
+            default: 'text'
+        },
+        icon: {
+            type: String,
+            default: 'search-plus'
+        },
+        tempSearch: { // 是否是数据模板使用的筛选条件
+            type: Boolean,
+            default: false
         }
-      },
-      immediate: true
     },
-    templateKey: {
-      handler(val, oldVal) {
-        if (val !== oldVal && val) {
-          this.loadTemplateData()
-        } else {
-          this.dataTemplate = {}
+    data () {
+        return {
+            initialization: false,
+            dataTemplate: {},
+            labelKey: '',
+            valueKey: '',
+            selectorVisible: false,
+            selectorValue: this.multiple ? [] : {},
+            cacheData: {},
+            bindIdValue: ''
         }
-      },
-      immediate: true
     },
-    dynamicParams(val, oldVal) {
-      if (val !== oldVal) {
-        this.initData()
-      }
-    }
-  },
-  beforeDestroy() {
-    this.dataTemplate = {}
-    this.cacheData = {}
-  },
-  methods: {
-    loadTemplateData() {
-      this.initialization = false
-      if (this.$utils.isEmpty(this.templateKey)) {
-        return
-      }
-      remoteRequest('dataTemplate', this.templateKey, () => {
-        return this.getRemoteDataTemplateFunc(this.templateKey)
-      }).then(data => {
-        this.initialization = true
-        this.dataTemplate = this.$utils.parseData(data)
-        this.dataTemplate.showType === 'compose' ? this.initDataTemplate(this.dataTemplate.composeType === 'treeList' ? this.dataTemplate.templates[1].attrs.bind_template_key : this.dataTemplate.templates[0].attrs.bind_template_key) : this.initDataTemplate()
-      }).catch(() => {
-      })
-    },
-    getRemoteDataTemplateFunc(templateKey) {
-      return new Promise((resolve, reject) => {
-        getByKey({ dataTemplateKey: templateKey }).then(response => {
-          resolve(response.data)
-        }).catch((error) => {
-          reject(error)
-        })
-      })
+    computed: {
+        items () {
+            if (this.$utils.isEmpty(this.selectorValue)) return []
+            if (this.multiple) {
+                return this.selectorValue.map(data => {
+                    return this.handleLabel(data)
+                })
+            } else {
+                return [this.handleLabel(this.selectorValue)]
+            }
+        }
     },
-    initDataTemplate(key) {
-      if (this.$utils.isEmpty(key)) {
-        this.valueKey = this.dataTemplate.unique
-        this.labelKey = buildLabelTitle(this.dataTemplate)
-        this.initData()
-      } else {
-        remoteRequest('dataTemplate', key, () => {
-          return this.getRemoteDataTemplateFunc(key)
-        }).then(res => {
-          this.initialization = true
-          const data = this.$utils.parseData(res)
-          this.valueKey = data.unique
-          this.labelKey = buildLabelTitle(data)
-          this.initData()
-        }).catch(() => {
-        })
-      }
+    watch: {
+        value: {
+            handler (val, oldVal) {
+                this.initData()
+                if (!valueEquals(val, oldVal)) {
+                    this.dispatch('ElFormItem', 'el.form.change', val)
+                }
+            },
+            immediate: true
+        },
+        templateKey: {
+            handler (val, oldVal) {
+                if (val !== oldVal && val) {
+                    this.loadTemplateData()
+                } else {
+                    this.dataTemplate = {}
+                }
+            },
+            immediate: true
+        },
+        dynamicParams (val, oldVal) {
+            if (val !== oldVal) {
+                this.initData()
+            }
+        }
     },
-    handleLabel(data) {
-      const config = this.labelKey
-      if (typeof config === 'function') {
-        return config(data)
-      } else if (typeof config === 'string') {
-        return data[config]
-      } else if (typeof config === 'undefined') {
-        const dataProp = data['name']
-        return dataProp === undefined ? '' : dataProp
-      }
+    beforeDestroy () {
+        this.dataTemplate = {}
+        this.cacheData = {}
     },
-    /**
+    methods: {
+        loadTemplateData () {
+            this.initialization = false
+            if (this.$utils.isEmpty(this.templateKey)) {
+                return
+            }
+            remoteRequest('dataTemplate', this.templateKey, () => {
+                return this.getRemoteDataTemplateFunc(this.templateKey)
+            }).then(data => {
+                this.initialization = true
+                this.dataTemplate = this.$utils.parseData(data)
+                this.dataTemplate.showType === 'compose' ? this.initDataTemplate(this.dataTemplate.composeType === 'treeList' ? this.dataTemplate.templates[1].attrs.bind_template_key : this.dataTemplate.templates[0].attrs.bind_template_key) : this.initDataTemplate()
+            }).catch(() => {
+            })
+        },
+        getRemoteDataTemplateFunc (templateKey) {
+            return new Promise((resolve, reject) => {
+                getByKey({ dataTemplateKey: templateKey }).then(response => {
+                    resolve(response.data)
+                }).catch((error) => {
+                    reject(error)
+                })
+            })
+        },
+        initDataTemplate (key) {
+            if (this.$utils.isEmpty(key)) {
+                this.valueKey = this.dataTemplate.unique
+                this.labelKey = buildLabelTitle(this.dataTemplate)
+                this.initData()
+            } else {
+                remoteRequest('dataTemplate', key, () => {
+                    return this.getRemoteDataTemplateFunc(key)
+                }).then(res => {
+                    this.initialization = true
+                    const data = this.$utils.parseData(res)
+                    this.valueKey = data.unique
+                    this.labelKey = buildLabelTitle(data)
+                    this.initData()
+                }).catch(() => {
+                })
+            }
+        },
+        handleLabel (data) {
+            const config = this.labelKey
+            if (typeof config === 'function') {
+                return config(data)
+            } else if (typeof config === 'string') {
+                return data[config]
+            } else if (typeof config === 'undefined') {
+                const dataProp = data['name']
+                return dataProp === undefined ? '' : dataProp
+            }
+        },
+        /**
      * 初始化数据
      */
-    initData(init = true) {
-      const data = this.getArrayValue(this.value)
-      this.selectorValue = this.multiple ? [] : {}
-      if (this.$utils.isEmpty(data)) {
-        return
-      }
-      data.forEach(v => {
-        if (this.cacheData[v]) {
-          this.setSelectorValue(v)
-        } else {
-          if (init && this.initialization) {
-            this.getDataInfo(v)
-          }
-        }
-      })
-    },
-    setCacheData() {
-      if (this.$utils.isEmpty(this.selectorValue)) return
-      const data = this.multiple ? this.selectorValue : [this.selectorValue]
-      data.forEach(v => {
-        this.cacheData[v[this.valueKey]] = v
-      })
-    },
-    setSelectorValue(v) {
-      if (this.multiple) {
-        this.selectorValue.push(this.cacheData[v])
-      } else {
-        this.selectorValue = JSON.parse(JSON.stringify(this.cacheData[v]))
-      }
-    },
-    /**
+        initData (init = true) {
+            const data = this.getArrayValue(this.value)
+            this.selectorValue = this.multiple ? [] : {}
+            if (this.$utils.isEmpty(data)) {
+                return
+            }
+            data.forEach(v => {
+                if (this.cacheData[v]) {
+                    this.setSelectorValue(v)
+                } else {
+                    if (init && this.initialization) {
+                        this.getDataInfo(v)
+                    }
+                }
+            })
+        },
+        setCacheData () {
+            if (this.$utils.isEmpty(this.selectorValue)) return
+            const data = this.multiple ? this.selectorValue : [this.selectorValue]
+            data.forEach(v => {
+                this.cacheData[v[this.valueKey]] = v
+            })
+        },
+        setSelectorValue (v) {
+            if (this.multiple) {
+                this.selectorValue.push(this.cacheData[v])
+            } else {
+                this.selectorValue = JSON.parse(JSON.stringify(this.cacheData[v]))
+            }
+        },
+        /**
      * 获得数组数据
      */
-    getArrayValue(value, bindId) {
-      if (this.$utils.isEmpty(value)) {
-        return []
-      }
-      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)
-          return data.map((d) => {
-            return d[this.valueKey]
-          })
-        } catch (error) {
-          console.error(error)
-          return []
-        }
-      } else if (this.store === 'id') { // id
-        return value.split(this.storeSeparator)
-      } else if (this.store === 'bind') { // 绑定id
-        if (this.$utils.isEmpty(bindId)) {
-          return []
-        }
-        return bindId.split(this.storeSeparator)
-      } else { // array
-        return value.map((d) => {
-          return d[this.valueKey]
-        })
-      }
-    },
-    getStoreValue(value) {
-      const res = []
-      if (this.store === 'json') { // json
-        if (this.$utils.isEmpty(value)) {
-          return ''
-        }
-        if (this.multiple) {
-          value.forEach(v => {
-            const o = {}
-            o[this.valueKey] = v[this.valueKey]
-            if (typeof this.labelKey === 'string') {
-              o[this.labelKey] = v[this.labelKey]
-              o['#title#'] = v[this.labelKey]
-            } else {
-              o['#title#'] = this.labelKey(v)
+        getArrayValue (value, bindId) {
+            if (this.$utils.isEmpty(value)) {
+                return []
             }
-            res.push(o)
-          })
-          return JSON.stringify(res)
-        } else {
-          const o = {}
-          o[this.valueKey] = value[this.valueKey]
-          if (typeof this.labelKey === 'string') {
-            o[this.labelKey] = value[this.labelKey]
-            o['#title#'] = value[this.labelKey]
-          } else {
-            o['#title#'] = this.labelKey(value)
-          }
-          return JSON.stringify(o)
-        }
-      } else if (this.store === 'id') { // id
-        if (this.$utils.isEmpty(value)) {
-          return ''
-        }
-        if (this.multiple) {
-          value.forEach(v => {
-            res.push(v[this.valueKey])
-          })
-        } else {
-          res.push(value[this.valueKey])
-        }
-        return res.join(this.storeSeparator)
-      } else if (this.store === 'bind') { // 绑定id
-        const res = []
-        const bindIdValue = []
-        value.forEach(v => {
-          bindIdValue.push(v[this.valueKey])
-          res.push(v[this.labelKey])
-        })
-        this.bindIdValue = bindIdValue.join(this.storeSeparator)
+            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)
+                    return data.map((d) => {
+                        return d[this.valueKey]
+                    })
+                } catch (error) {
+                    console.error(error)
+                    return []
+                }
+            } else if (this.store === 'id') { // id
+                return value.split(this.storeSeparator)
+            } else if (this.store === 'bind') { // 绑定id
+                if (this.$utils.isEmpty(bindId)) {
+                    return []
+                }
+                return bindId.split(this.storeSeparator)
+            } else { // array
+                return value.map((d) => {
+                    return d[this.valueKey]
+                })
+            }
+        },
+        getStoreValue (value) {
+            const res = []
+            if (this.store === 'json') { // json
+                if (this.$utils.isEmpty(value)) {
+                    return ''
+                }
+                if (this.multiple) {
+                    value.forEach(v => {
+                        const o = {}
+                        o[this.valueKey] = v[this.valueKey]
+                        if (typeof this.labelKey === 'string') {
+                            o[this.labelKey] = v[this.labelKey]
+                            o['#title#'] = v[this.labelKey]
+                        } else {
+                            o['#title#'] = this.labelKey(v)
+                        }
+                        res.push(o)
+                    })
+                    return JSON.stringify(res)
+                } else {
+                    const o = {}
+                    o[this.valueKey] = value[this.valueKey]
+                    if (typeof this.labelKey === 'string') {
+                        o[this.labelKey] = value[this.labelKey]
+                        o['#title#'] = value[this.labelKey]
+                    } else {
+                        o['#title#'] = this.labelKey(value)
+                    }
+                    return JSON.stringify(o)
+                }
+            } else if (this.store === 'id') { // id
+                if (this.$utils.isEmpty(value)) {
+                    return ''
+                }
+                if (this.multiple) {
+                    value.forEach(v => {
+                        res.push(v[this.valueKey])
+                    })
+                } else {
+                    res.push(value[this.valueKey])
+                }
+                return res.join(this.storeSeparator)
+            } else if (this.store === 'bind') { // 绑定id
+                const res = []
+                const bindIdValue = []
+                value.forEach(v => {
+                    bindIdValue.push(v[this.valueKey])
+                    res.push(v[this.labelKey])
+                })
+                this.bindIdValue = bindIdValue.join(this.storeSeparator)
 
-        return res.join(this.storeSeparator)
-      } else { // 数组 array
-        return value || []
-      }
-    },
-    getValue() {
-      return this.getStoreValue(this.selectorValue)
-    },
-    /**
+                return res.join(this.storeSeparator)
+            } else { // 数组 array
+                return value || []
+            }
+        },
+        getValue () {
+            return this.getStoreValue(this.selectorValue)
+        },
+        /**
     * 通过ID获取数据
      */
-    getDataInfo(id) {
-      if (TRANSFER_DATA === 'transfer') {
-        this.getTransferData(id)
-      } else {
-        this.getRemoteData(id)
-      }
-    },
-    getTransferData(id) {
-      remoteTransRequest('dataTemplate:' + this.templateKey, id).then(idset => {
-        const ids = Array.from(idset)
-        remoteRequest('dataTemplateIds', ids, () => {
-          return this.getRemoteTransFunc(ids)
-        }).then(response => {
-          if (this.$utils.isNotEmpty(response) && this.$utils.isNotEmpty(response.data)) {
-            const responseData = response.data
-            const dataKey = id
-            const data = responseData[dataKey] ? responseData[dataKey] : {}
-            let key = id
-            if (this.$utils.isNotEmpty(data[this.valueKey])) {
-              key = data[this.valueKey]
+        getDataInfo (id) {
+            if (TRANSFER_DATA === 'transfer') {
+                this.getTransferData(id)
+            } else {
+                this.getRemoteData(id)
             }
-            this.cacheData[key] = data
-            this.initData(false)
-          }
-        }).catch(() => {
-        })
-      })
-    },
-    getRemoteTransFunc(ids) {
-      return new Promise((resolve, reject) => {
-        transferByIds({
-          'templateKey': this.templateKey,
-          'ids': ids
-        }).then(response => {
-          resolve(response)
-        }).catch((error) => {
-          reject(error)
-        })
-      })
-    },
+        },
+        getTransferData (id) {
+            remoteTransRequest('dataTemplate:' + this.templateKey, id).then(idset => {
+                const ids = Array.from(idset)
+                remoteRequest('dataTemplateIds', ids, () => {
+                    return this.getRemoteTransFunc(ids)
+                }).then(response => {
+                    if (this.$utils.isNotEmpty(response) && this.$utils.isNotEmpty(response.data)) {
+                        const responseData = response.data
+                        const dataKey = id
+                        const data = responseData[dataKey] ? responseData[dataKey] : {}
+                        let key = id
+                        if (this.$utils.isNotEmpty(data[this.valueKey])) {
+                            key = data[this.valueKey]
+                        }
+                        this.cacheData[key] = data
+                        this.initData(false)
+                    }
+                }).catch(() => {
+                })
+            })
+        },
+        getRemoteTransFunc (ids) {
+            return new Promise((resolve, reject) => {
+                transferByIds({
+                    'templateKey': this.templateKey,
+                    'ids': ids
+                }).then(response => {
+                    resolve(response)
+                }).catch((error) => {
+                    reject(error)
+                })
+            })
+        },
 
-    /**
+        /**
      * 通过ID获取数据
      */
-    getRemoteData(id) {
-      const params = {
-        key: this.templateKey,
-        id: id
-      }
-      if (this.$utils.isNotEmpty(this.dynamicParams)) {
-        params['dynamicParams'] = JSON.stringify(this.dynamicParams)
-      }
-      remoteRequest('dataTemplate', params, () => {
-        return this.getRemoteDataTemplateByIdFunc(params)
-      }).then(responseData => {
-        if (this.$utils.isNotEmpty(responseData) && this.$utils.isNotEmpty(responseData.data)) {
-          const data = responseData.data[0]
-          let key = id
-          if (this.$utils.isNotEmpty(data[this.valueKey])) {
-            key = data[this.valueKey]
-          }
-          this.cacheData[key] = data
-          this.initData(false)
-        }
-      }).catch(() => {
-      })
-    },
-    getRemoteDataTemplateByIdFunc(params) {
-      return new Promise((resolve, reject) => {
-        queryDataById(params).then(response => {
-          resolve(response.data)
-        }).catch((error) => {
-          reject(error)
-        })
-      })
-    },
-    // ===================事件处理=========
+        getRemoteData (id) {
+            const params = {
+                key: this.templateKey,
+                id: id
+            }
+            if (this.$utils.isNotEmpty(this.dynamicParams)) {
+                params['dynamicParams'] = JSON.stringify(this.dynamicParams)
+            }
+            remoteRequest('dataTemplate', params, () => {
+                return this.getRemoteDataTemplateByIdFunc(params)
+            }).then(responseData => {
+                if (this.$utils.isNotEmpty(responseData) && this.$utils.isNotEmpty(responseData.data)) {
+                    const data = responseData.data[0]
+                    let key = id
+                    if (this.$utils.isNotEmpty(data[this.valueKey])) {
+                        key = data[this.valueKey]
+                    }
+                    this.cacheData[key] = data
+                    this.initData(false)
+                }
+            }).catch(() => {
+            })
+        },
+        getRemoteDataTemplateByIdFunc (params) {
+            return new Promise((resolve, reject) => {
+                queryDataById(params).then(response => {
+                    resolve(response.data)
+                }).catch((error) => {
+                    reject(error)
+                })
+            })
+        },
+        // ===================事件处理=========
 
-    handleSelectorClick() {
-      if (this.$utils.isEmpty(this.templateKey)) {
-        this.$message.closeAll()
-        this.$message({
-          message: '请绑定自定义对话框',
-          type: 'warning'
-        })
-        return
-      }
-      this.selectorVisible = true
-      this.initData()
-    },
-    handleSelectorRemove(index) {
-      if (this.multiple) {
-        this.selectorValue.splice(index, 1)
-      } else {
-        this.selectorValue = {}
-      }
-      const val = this.getValue()
-      this.handleInput(val)
-      this.emitChange(val)
-    },
+        handleSelectorClick () {
+            if (this.$utils.isEmpty(this.templateKey)) {
+                this.$message.closeAll()
+                this.$message({
+                    message: '请绑定自定义对话框',
+                    type: 'warning'
+                })
+                return
+            }
+            this.selectorVisible = true
+            this.initData()
+        },
+        handleSelectorRemove (index) {
+            if (this.multiple) {
+                this.selectorValue.splice(index, 1)
+            } else {
+                this.selectorValue = {}
+            }
+            const val = this.getValue()
+            this.handleInput(val)
+            this.emitChange(val)
+        },
 
-    handleSelectorActionEvent(buttonKey, data) {
-      let val
-      switch (buttonKey) {
-        case 'ok':// 确定
-          this.selectorVisible = false
-          this.selectorValue = data
-          this.setCacheData() // 设置缓存数据
-          val = this.getValue()
-          this.handleInput(val)
-          this.emitChange(val)
-          break
-        case 'cleanClose': // 清空关闭
-          this.selectorVisible = false
-          this.selectorValue = this.multiple ? [] : {}
-          this.handleInput('')
-          this.emitChange('')
-          break
-        case 'cancel':// 取消
-          this.selectorVisible = false
-          break
+        handleSelectorActionEvent (buttonKey, data) {
+            let val
+            switch (buttonKey) {
+                case 'ok':// 确定
+                    this.selectorVisible = false
+                    this.selectorValue = data
+                    this.setCacheData() // 设置缓存数据
+                    val = this.getValue()
+                    this.handleInput(val)
+                    this.emitChange(val)
+                    break
+                case 'cleanClose': // 清空关闭
+                    this.selectorVisible = false
+                    this.selectorValue = this.multiple ? [] : {}
+                    this.handleInput('')
+                    this.emitChange('')
+                    break
+                case 'cancel':// 取消
+                    this.selectorVisible = false
+                    break
         // TODO:自定义按钮事件处理
-      }
-    },
-    emitChange(val) {
-      if (!valueEquals(this.value, val)) {
-        this.$emit('change', val, this.selectorValue)
-        this.$emit('change-link-data', val, this.selectorValue)
-      }
-    },
-    handleInput(val) {
-      this.$emit('input', val, this.selectorValue)
-      this.$emit('change-link-attr', val, this.selectorValue)
+            }
+        },
+        emitChange (val) {
+            if (!valueEquals(this.value, val)) {
+                this.$emit('change', val, this.selectorValue)
+                this.$emit('change-link-data', val, this.selectorValue)
+            }
+        },
+        handleInput (val) {
+            this.$emit('input', val, this.selectorValue)
+            this.$emit('change-link-attr', val, this.selectorValue)
+        }
     }
-  }
 }
 </script>

+ 482 - 480
src/business/platform/data/templaterender/link-data/index.vue

@@ -12,12 +12,14 @@
                 :multiple="multiple"
                 :placeholder="placeholder"
                 style="width: 100%"
+                allow-create
+                collapse-tags
                 @focus="focusData"
                 @change="changeData"
                 @clear="clearData"
                 v-on="$listeners"
-                allow-create
-                @blur="e => {selectData = e.target.value}">
+                @blur="e => {selectData = e.target.value}"
+            >
                 <el-option
                     v-for="(item, i) in selectDataOptions"
                     :key="i"
@@ -70,525 +72,525 @@
     />
 </template>
 <script>
-    import { getByKey, queryDataTable } from '@/api/platform/data/dataTemplate'
-    import ActionUtils from '@/utils/action'
-    import { remoteRequest } from '@/utils/remote'
-    import { getDynamicParamsConditions, buildLabelTitle, buildLinkLabelTitle } from '../utils'
-    import TreeUtils from '@/utils/tree'
-    import IbpsTreeSelect from '@/components/ibps-tree-select'
+import { getByKey, queryDataTable } from '@/api/platform/data/dataTemplate'
+import ActionUtils from '@/utils/action'
+import { remoteRequest } from '@/utils/remote'
+import { getDynamicParamsConditions, buildLabelTitle, buildLinkLabelTitle } from '../utils'
+import TreeUtils from '@/utils/tree'
+import IbpsTreeSelect from '@/components/ibps-tree-select'
 
-    export default {
-        components: {
-            IbpsTreeSelect
-        },
-        props: {
-            value: {
-                type: [String, Number, Array, Object],
-                default: ''
-            },
-            templateKey: {
-                // 数据模版key
-                type: String
-            },
-            allowEmptyDynamicParams: {
-                type: Boolean,
-                default: false
-            },
-            hasDynamicParams: {
-                type: Boolean,
-                default: false
-            },
-            dynamicParams: {
-                // 动态参数
-                type: Object
-            },
-            data: {
-                type: Array
-            },
-            multiple: {
-                // 是否多选
-                type: Boolean,
-                default: false
-            },
-            structure: {
-                type: String,
-                default: 'list'
-            },
-            valueKey: {
-                // 值key
-                type: String
-            },
-            labelType: {
-                // 文本类型
-                type: String,
-                default: 'first'
-            },
-            labelKey: {
-                // 文本key
-                type: [String, Function]
-            },
-            config: {
-                // 配置
-                type: Object
-            },
-            disabled: {
-                // 是否禁用
-                type: Boolean,
-                default: false
-            },
-            readonly: {
-                // 是否只读
-                type: Boolean,
-                default: false
-            },
-            placeholder: {
-                // 输入框占位文本
-                type: String,
-                default: '请选择'
-            },
-            emptyText: {
-                type: String,
-                default: '暂无数据'
-            },
-            store: {
-                // 存储类型 对应[多选]有效,array 数组。string 字符串类型
-                type: String,
-                default: 'string',
-                validator: function (value) {
-                    return ['array', 'string'].indexOf(value) !== -1
-                }
-            },
-            storeSeparator: {
-                // 存储值分割符,对于设置字符串类型的分隔符
-                type: String,
-                default: ','
-            },
-            clearable: {
-                type: Boolean,
-                default: true
-            },
-            filterable: {
-                type: Boolean,
-                default: true
-            },
-            readonlyText: {
-                // 只读样式
-                type: String,
-                default: 'original'
-            }
+export default {
+    components: {
+        IbpsTreeSelect
+    },
+    props: {
+        value: {
+            type: [String, Number, Array, Object],
+            default: ''
         },
-        data() {
-            return {
-                dataTemplate: {},
-                template: {},
-                loading: false,
-                initLoading: true,
-                initValue: '',
-                pkKey: this.valueKey,
-                props: {
-                    children: 'children',
-                    label: this.labelKey
-                },
-                listData: [],
-                selectData: this.multiple ? [] : '',
-                treeData: [],
-                treeDataOptions: [],
-                dynamicConditions: {},
-                showEmptyText: this.emptyText,
-                selectDataOptions: [],
-                pagination: {
-                    page: 1,
-                    limit: 100,
-                    count: 0
-                }
+        templateKey: {
+            // 数据模版key
+            type: String
+        },
+        allowEmptyDynamicParams: {
+            type: Boolean,
+            default: false
+        },
+        hasDynamicParams: {
+            type: Boolean,
+            default: false
+        },
+        dynamicParams: {
+            // 动态参数
+            type: Object
+        },
+        data: {
+            type: Array
+        },
+        multiple: {
+            // 是否多选
+            type: Boolean,
+            default: false
+        },
+        structure: {
+            type: String,
+            default: 'list'
+        },
+        valueKey: {
+            // 值key
+            type: String
+        },
+        labelType: {
+            // 文本类型
+            type: String,
+            default: 'first'
+        },
+        labelKey: {
+            // 文本key
+            type: [String, Function]
+        },
+        config: {
+            // 配置
+            type: Object
+        },
+        disabled: {
+            // 是否禁用
+            type: Boolean,
+            default: false
+        },
+        readonly: {
+            // 是否只读
+            type: Boolean,
+            default: false
+        },
+        placeholder: {
+            // 输入框占位文本
+            type: String,
+            default: '请选择'
+        },
+        emptyText: {
+            type: String,
+            default: '暂无数据'
+        },
+        store: {
+            // 存储类型 对应[多选]有效,array 数组。string 字符串类型
+            type: String,
+            default: 'string',
+            validator: function (value) {
+                return ['array', 'string'].indexOf(value) !== -1
             }
         },
-        computed: {
-            pidKey() {
-                return this.config ? this.config.parentId || '' : ''
-            },
-            selectMode() {
-                return this.config ? this.config.selectMode || 'any' : 'any'
-            },
-            displayMode() {
-                return this.config ? this.config.displayMode || 'path' : 'path'
-            },
-            separator() {
-                return this.config ? this.config.split || '/' : '/'
+        storeSeparator: {
+            // 存储值分割符,对于设置字符串类型的分隔符
+            type: String,
+            default: ','
+        },
+        clearable: {
+            type: Boolean,
+            default: true
+        },
+        filterable: {
+            type: Boolean,
+            default: true
+        },
+        readonlyText: {
+            // 只读样式
+            type: String,
+            default: 'original'
+        }
+    },
+    data () {
+        return {
+            dataTemplate: {},
+            template: {},
+            loading: false,
+            initLoading: true,
+            initValue: '',
+            pkKey: this.valueKey,
+            props: {
+                children: 'children',
+                label: this.labelKey
+            },
+            listData: [],
+            selectData: this.multiple ? [] : '',
+            treeData: [],
+            treeDataOptions: [],
+            dynamicConditions: {},
+            showEmptyText: this.emptyText,
+            selectDataOptions: [],
+            pagination: {
+                page: 1,
+                limit: 100,
+                count: 0
             }
+        }
+    },
+    computed: {
+        pidKey () {
+            return this.config ? this.config.parentId || '' : ''
         },
-        watch: {
-            selectData(val, oldVal) {
-                this.$emit('input', this.getStoreValue(val))
-            },
-            templateKey: {
-                handler(val, oldVal) {
-                    if (val !== oldVal && val) {
-                        this.loadTemplateData()
-                    } else {
-                        this.treeData = []
-                        this.treeDataOptions = []
-                        this.selectDataOptions = []
-                    }
-                },
-                immediate: true
-            },
-            dynamicParams: {
-                handler(val, oldVal) {
-                    if (!this.valueEquals(val, oldVal) && this.hasDynamicParams) {
-                        this.treeData = []
-                        this.treeDataOptions = []
-                        this.selectDataOptions = []
-                        this.clearData()
-                    }
-                },
-                immediate: true
-            },
-            structure: {
-                handler(val, oldVal) {
-                    if (val !== oldVal && val) {
-                        this.loadTemplateData()
-                    }
-                },
-                immediate: true
-            },
-            emptyText(val, oldVal) {
-                if (this.$utils.isEmpty(this.templateKey)) {
-                    this.showEmptyText = '请设置关联数据'
+        selectMode () {
+            return this.config ? this.config.selectMode || 'any' : 'any'
+        },
+        displayMode () {
+            return this.config ? this.config.displayMode || 'path' : 'path'
+        },
+        separator () {
+            return this.config ? this.config.split || '/' : '/'
+        }
+    },
+    watch: {
+        selectData (val, oldVal) {
+            this.$emit('input', this.getStoreValue(val))
+        },
+        templateKey: {
+            handler (val, oldVal) {
+                if (val !== oldVal && val) {
+                    this.loadTemplateData()
                 } else {
-                    this.showEmptyText = val
+                    this.treeData = []
+                    this.treeDataOptions = []
+                    this.selectDataOptions = []
                 }
             },
-            multiple(val, oldVal) {
-                if (val !== oldVal && !this.initLoading) {
-                    this.initData()
+            immediate: true
+        },
+        dynamicParams: {
+            handler (val, oldVal) {
+                if (!this.valueEquals(val, oldVal) && this.hasDynamicParams) {
+                    this.treeData = []
+                    this.treeDataOptions = []
+                    this.selectDataOptions = []
+                    this.clearData()
                 }
             },
-            value: {
-                handler(val, oldVal) {
-                    if (val !== oldVal && !this.initLoading) {
-                        this.initData()
-                        this.changeLinkAttr()
-                    }
-                },
-                immediate: true
-            },
-            labelKey: {
-                handler(val, oldVal) {
-                    if (val !== oldVal && val) {
-                        this.props.label = buildLinkLabelTitle(this.labelType, this.labelKey, this.labelKey)
-                    }
-                },
-                immediate: true
+            immediate: true
+        },
+        structure: {
+            handler (val, oldVal) {
+                if (val !== oldVal && val) {
+                    this.loadTemplateData()
+                }
             },
-            valueKey: {
-                handler(val, oldVal) {
-                    if (val !== oldVal && val) {
-                        this.pkKey = this.valueKey
-                    }
-                },
-                immediate: true
+            immediate: true
+        },
+        emptyText (val, oldVal) {
+            if (this.$utils.isEmpty(this.templateKey)) {
+                this.showEmptyText = '请设置关联数据'
+            } else {
+                this.showEmptyText = val
             }
         },
-        created() {
-            this.defaultPagination = JSON.parse(JSON.stringify(this.pagination))
-        },
-        beforeDestroy() {
-            this.listData = null
-            this.treeData = null
-            this.treeDataOptions = null
-            this.selectDataOptions = null
-        },
-        methods: {
-            valueEquals(obj1, obj2) {
-                const o1 = obj1 instanceof Object
-                const o2 = obj2 instanceof Object
-                // 判断是不是对象
-                if (!o1 || !o2) {
-                    return obj1 === obj2
-                }
-
-                if (Object.keys(obj1).length !== Object.keys(obj2).length) {
-                    return false
-                }
-
-                for (var o in obj1) {
-                    const t1 = obj1[o] instanceof Object
-                    const t2 = obj2[o] instanceof Object
-                    if (t1 && t2) {
-                        return this.valueEquals(obj1[o], obj2[o])
-                    } else if (obj1[o] !== obj2[o]) {
-                        return false
-                    }
+        multiple (val, oldVal) {
+            if (val !== oldVal && !this.initLoading) {
+                this.initData()
+            }
+        },
+        value: {
+            handler (val, oldVal) {
+                if (val !== oldVal && !this.initLoading) {
+                    this.initData()
+                    this.changeLinkAttr()
                 }
-                return true
             },
-            labelFilter(item, key) {
-                const opt = this.treeDataOptions.find(opt => {
-                    return opt.value === item[this.pkKey]
-                })
-                // 添加个年份的判断
-                if (key === 'label' && opt && opt[key] && opt[key].slice(5, 10) === '01-01') {
-                    if (opt[key].slice(5, 10) == '00:00:00') return (opt[key] = opt[key].slice(0, 4))
-                    else if (this.props['label'] === 'nian_fen_') return (opt[key] = opt[key].slice(0, 4))
+            immediate: true
+        },
+        labelKey: {
+            handler (val, oldVal) {
+                if (val !== oldVal && val) {
+                    this.props.label = buildLinkLabelTitle(this.labelType, this.labelKey, this.labelKey)
                 }
-                return opt ? opt[key] : ''
             },
-            getTreeData(id) {
-                return this.treeData.find(opt => {
-                    return opt[this.pkKey] === id
-                })
-            },
-            loadMore() {
-                this.pagination.page = this.pagination.page + 1
-                const pageSize = this.pagination.limit * this.pagination.page
-                if (pageSize >= this.pagination.count) {
-                    return
-                }
-                const data = this.treeData.slice(pageSize, pageSize + this.pagination.limit + 1)
-                if (this.$utils.isNotEmpty(data)) {
-                    data.forEach(d => {
-                        this.selectDataOptions.push(d)
-                    })
+            immediate: true
+        },
+        valueKey: {
+            handler (val, oldVal) {
+                if (val !== oldVal && val) {
+                    this.pkKey = this.valueKey
                 }
             },
-            loadTemplateData() {
-                if (this.$utils.isEmpty(this.templateKey)) {
-                    return
+            immediate: true
+        }
+    },
+    created () {
+        this.defaultPagination = JSON.parse(JSON.stringify(this.pagination))
+    },
+    beforeDestroy () {
+        this.listData = null
+        this.treeData = null
+        this.treeDataOptions = null
+        this.selectDataOptions = null
+    },
+    methods: {
+        valueEquals (obj1, obj2) {
+            const o1 = obj1 instanceof Object
+            const o2 = obj2 instanceof Object
+            // 判断是不是对象
+            if (!o1 || !o2) {
+                return obj1 === obj2
+            }
+
+            if (Object.keys(obj1).length !== Object.keys(obj2).length) {
+                return false
+            }
+
+            for (var o in obj1) {
+                const t1 = obj1[o] instanceof Object
+                const t2 = obj2[o] instanceof Object
+                if (t1 && t2) {
+                    return this.valueEquals(obj1[o], obj2[o])
+                } else if (obj1[o] !== obj2[o]) {
+                    return false
                 }
-                this.loading = true
-                remoteRequest('dataTemplate', this.templateKey, () => {
-                    return this.getRemoteDataTemplateFunc(this.templateKey)
-                }).then(response => {
-                    this.loading = false
-                    this.dataTemplate = this.$utils.parseData(response.data)
-                    this.template = this.dataTemplate.templates[0]
-                    this.initDataTemplate()
-                    this.loadTreeData(true)
+            }
+            return true
+        },
+        labelFilter (item, key) {
+            const opt = this.treeDataOptions.find(opt => {
+                return opt.value === item[this.pkKey]
+            })
+            // 添加个年份的判断
+            if (key === 'label' && opt && opt[key] && opt[key].slice(5, 10) === '01-01') {
+                if (opt[key].slice(5, 10) == '00:00:00') return (opt[key] = opt[key].slice(0, 4))
+                else if (this.props['label'] === 'nian_fen_') return (opt[key] = opt[key].slice(0, 4))
+            }
+            return opt ? opt[key] : ''
+        },
+        getTreeData (id) {
+            return this.treeData.find(opt => {
+                return opt[this.pkKey] === id
+            })
+        },
+        loadMore () {
+            this.pagination.page = this.pagination.page + 1
+            const pageSize = this.pagination.limit * this.pagination.page
+            if (pageSize >= this.pagination.count) {
+                return
+            }
+            const data = this.treeData.slice(pageSize, pageSize + this.pagination.limit + 1)
+            if (this.$utils.isNotEmpty(data)) {
+                data.forEach(d => {
+                    this.selectDataOptions.push(d)
                 })
-            },
-            getRemoteDataTemplateFunc(templateKey) {
-                return new Promise((resolve, reject) => {
-                    getByKey({ dataTemplateKey: templateKey }).then(response => {
-                        resolve(response)
-                    }).catch(error => {
-                        reject(error)
-                    })
+            }
+        },
+        loadTemplateData () {
+            if (this.$utils.isEmpty(this.templateKey)) {
+                return
+            }
+            this.loading = true
+            remoteRequest('dataTemplate', this.templateKey, () => {
+                return this.getRemoteDataTemplateFunc(this.templateKey)
+            }).then(response => {
+                this.loading = false
+                this.dataTemplate = this.$utils.parseData(response.data)
+                this.template = this.dataTemplate.templates[0]
+                this.initDataTemplate()
+                this.loadTreeData(true)
+            })
+        },
+        getRemoteDataTemplateFunc (templateKey) {
+            return new Promise((resolve, reject) => {
+                getByKey({ dataTemplateKey: templateKey }).then(response => {
+                    resolve(response)
+                }).catch(error => {
+                    reject(error)
                 })
-            },
-            initDataTemplate() {
-                this.pkKey = this.$utils.isEmpty(this.valueKey) ? this.dataTemplate.unique || 'id_' : this.valueKey
-                this.props.label = this.buildLabelTitle(this.labelKey)
-                this.dynamicConditions = getDynamicParamsConditions(this.dataTemplate)
-            },
-            buildLabelTitle(labelKey) {
-                if (this.$utils.isEmpty(labelKey)) {
-                    return buildLabelTitle(this.dataTemplate)
-                } else {
-                    return buildLinkLabelTitle(this.labelType, labelKey, labelKey)
-                }
-            },
-            focusData(event) {
-                if (!event.sourceCapabilities) return // 如果是勾选或反选下拉选项
-                if (!event.target.value) {
-                    // 输入框没有搜索条件时触发
-                    this.loadTreeData()
-                }
-            },
-            loadTreeData(init = false) {
-                if (init) {
-                    this.listData = []
-                    this.treeData = []
-                    this.treeDataOptions = []
-                    this.selectDataOptions = []
-                    this.initLoading = true
-                }
-                if (this.$utils.isEmpty(this.templateKey)) {
-                    this.showEmptyText = '请设置关联数据'
-                    this.initLoading = false
-                    return
-                }
-                // 遍历所有条件
-                if (this.$utils.isNotEmpty(this.dynamicConditions) && !this.allowEmptyDynamicParams) {
-                    for (const key in this.dynamicConditions) {
-                        const value = this.dynamicParams[key]
-                        if (this.$utils.isEmpty(value)) {
-                            this.listData = []
-                            this.treeData = []
-                            this.treeDataOptions = []
-                            this.selectDataOptions = []
-                            this.showEmptyText = '请输入或选择过滤条件'
-                            this.initLoading = false
-                            return
-                        }
+            })
+        },
+        initDataTemplate () {
+            this.pkKey = this.$utils.isEmpty(this.valueKey) ? this.dataTemplate.unique || 'id_' : this.valueKey
+            this.props.label = this.buildLabelTitle(this.labelKey)
+            this.dynamicConditions = getDynamicParamsConditions(this.dataTemplate)
+        },
+        buildLabelTitle (labelKey) {
+            if (this.$utils.isEmpty(labelKey)) {
+                return buildLabelTitle(this.dataTemplate)
+            } else {
+                return buildLinkLabelTitle(this.labelType, labelKey, labelKey)
+            }
+        },
+        focusData (event) {
+            if (!event.sourceCapabilities) return // 如果是勾选或反选下拉选项
+            if (!event.target.value) {
+                // 输入框没有搜索条件时触发
+                this.loadTreeData()
+            }
+        },
+        loadTreeData (init = false) {
+            if (init) {
+                this.listData = []
+                this.treeData = []
+                this.treeDataOptions = []
+                this.selectDataOptions = []
+                this.initLoading = true
+            }
+            if (this.$utils.isEmpty(this.templateKey)) {
+                this.showEmptyText = '请设置关联数据'
+                this.initLoading = false
+                return
+            }
+            // 遍历所有条件
+            if (this.$utils.isNotEmpty(this.dynamicConditions) && !this.allowEmptyDynamicParams) {
+                for (const key in this.dynamicConditions) {
+                    const value = this.dynamicParams[key]
+                    if (this.$utils.isEmpty(value)) {
+                        this.listData = []
+                        this.treeData = []
+                        this.treeDataOptions = []
+                        this.selectDataOptions = []
+                        this.showEmptyText = '请输入或选择过滤条件'
+                        this.initLoading = false
+                        return
                     }
                 }
-                if (this.$utils.isEmpty(this.template)) {
-                    this.showEmptyText = '加载中...'
-                    this.initLoading = false
-                    return
-                }
+            }
+            if (this.$utils.isEmpty(this.template)) {
                 this.showEmptyText = '加载中...'
-                const p = this.getFormatParams()
-                remoteRequest('dataTemplate', p, () => {
-                    return this.getRemoteQueryDataTableFunc(p)
-                }).then(response => {
-                    this.showEmptyText = this.emptyText
-                    const responseData = response.data
-                    const data = responseData.dataResult || []
+                this.initLoading = false
+                return
+            }
+            this.showEmptyText = '加载中...'
+            const p = this.getFormatParams()
+            remoteRequest('dataTemplate', p, () => {
+                return this.getRemoteQueryDataTableFunc(p)
+            }).then(response => {
+                this.showEmptyText = this.emptyText
+                const responseData = response.data
+                const data = responseData.dataResult || []
 
-                    if (this.structure === 'list') {
-                        // 处理分页
-                        this.handlerPagination(JSON.parse(JSON.stringify(this.defaultPagination)))
-                        this.pagination.count = data.length
-                        this.selectDataOptions = data.slice(this.pagination.page - 1, this.pagination.limit + 1)
+                if (this.structure === 'list') {
+                    // 处理分页
+                    this.handlerPagination(JSON.parse(JSON.stringify(this.defaultPagination)))
+                    this.pagination.count = data.length
+                    this.selectDataOptions = data.slice(this.pagination.page - 1, this.pagination.limit + 1)
 
-                        this.treeData = data
-                    } else {
-                        this.treeData = TreeUtils.transformToTreeFormat(data, {
-                            idKey: this.pkKey,
-                            pIdKey: this.pidKey
-                        })
-                    }
+                    this.treeData = data
+                } else {
+                    this.treeData = TreeUtils.transformToTreeFormat(data, {
+                        idKey: this.pkKey,
+                        pIdKey: this.pidKey
+                    })
+                }
 
-                    this.listData = data
-                    this.treeDataOptions = this.buildTreeDataOptions(data)
+                this.listData = data
+                this.treeDataOptions = this.buildTreeDataOptions(data)
 
-                    if (init) {
-                        this.initLoading = false
-                        this.initData()
-                        this.changeLinkAttr()
-                    }
-                    this.$emit('load-data', this.listData)
-                }).catch(() => {
-                    this.showEmptyText = '加载数据出错了'
-                    this.loading = false
+                if (init) {
                     this.initLoading = false
-                })
-            },
-            buildTreeDataOptions(data) {
-                const cont = data.map(item => {
-                    let labelData = ''
-                    if (typeof this.props.label === 'string') {
-                        labelData = item[this.props.label]
-                    } else {
-                        let labs = this.labelKey.split('$_widget_')
-                        for (let i in labs) {
-                            if (labs[i]) {
-                                let src = labs[i].split('#')
-                                labelData = labelData + item[src[0]] + src[1]
-                            }
-                        }
-                    }
-                    return {
-                        value: item[this.pkKey],
-                        label: labelData
-                    }
-                })
-                return cont
-            },
-            getRemoteQueryDataTableFunc(p) {
-                return new Promise((resolve, reject) => {
-                    queryDataTable(p).then(response => {
-                        resolve(response)
-                    }).catch(error => {
-                        reject(error)
-                    })
-                })
-            },
-            handlerPagination(pagination) {
-                this.pagination = pagination
-            },
-            /**
-             * 获取格式化参数
-             */
-            getFormatParams() {
-                let formParams = {}
-                if (this.$refs['searchForm']) {
-                    formParams = this.$refs['searchForm'].getSearcFormData() || {}
+                    this.initData()
+                    this.changeLinkAttr()
                 }
-                const responseData = JSON.parse(JSON.stringify(this.template))
-
-                responseData.datasetKey = this.dataTemplate.datasetKey
-                responseData.unique = this.pkKey
-                responseData['key'] = this.templateKey
-                responseData['dynamic_params'] = this.dynamicParams
-                formParams['response_data'] = JSON.stringify(responseData)
-                formParams['filter_condition_key'] = this.filterConditionKey || ''
-                return ActionUtils.formatParams(formParams)
-            },
-            initData() {
-                if (this.multiple) {
-                    this.selectData = this.getArrayValue()
+                this.$emit('load-data', this.listData)
+            }).catch(() => {
+                this.showEmptyText = '加载数据出错了'
+                this.loading = false
+                this.initLoading = false
+            })
+        },
+        buildTreeDataOptions (data) {
+            const cont = data.map(item => {
+                let labelData = ''
+                if (typeof this.props.label === 'string') {
+                    labelData = item[this.props.label]
                 } else {
-                    this.selectData = this.value
+                    const labs = this.labelKey.split('$_widget_')
+                    for (const i in labs) {
+                        if (labs[i]) {
+                            const src = labs[i].split('#')
+                            labelData = labelData + item[src[0]] + src[1]
+                        }
+                    }
                 }
-                this.initSelectDataOptions()
-            },
-            initSelectDataOptions() {
-                if (this.$utils.isEmpty(this.selectDataOptions) || this.$utils.isEmpty(this.selectData)) return
-                if (this.multiple) {
-                    this.selectData.forEach(data => {
-                        this.setSelectDataOptions(data)
-                    })
-                } else {
-                    this.setSelectDataOptions(this.selectData)
+                return {
+                    value: item[this.pkKey],
+                    label: labelData
                 }
-            },
-            setSelectDataOptions(v) {
-                const data = this.selectDataOptions.find(item => {
-                    return item[this.valueKey] === v
+            })
+            return cont
+        },
+        getRemoteQueryDataTableFunc (p) {
+            return new Promise((resolve, reject) => {
+                queryDataTable(p).then(response => {
+                    resolve(response)
+                }).catch(error => {
+                    reject(error)
                 })
-                if (!data) {
-                    // bug 2022-03-09 nichuqia modified
-                    // this.selectDataOptions.push(this.getTreeData(v))
-                }
-            },
-            getArrayValue() {
+            })
+        },
+        handlerPagination (pagination) {
+            this.pagination = pagination
+        },
+        /**
+         * 获取格式化参数
+         */
+        getFormatParams () {
+            let formParams = {}
+            if (this.$refs['searchForm']) {
+                formParams = this.$refs['searchForm'].getSearcFormData() || {}
+            }
+            const responseData = JSON.parse(JSON.stringify(this.template))
+
+            responseData.datasetKey = this.dataTemplate.datasetKey
+            responseData.unique = this.pkKey
+            responseData['key'] = this.templateKey
+            responseData['dynamic_params'] = this.dynamicParams
+            formParams['response_data'] = JSON.stringify(responseData)
+            formParams['filter_condition_key'] = this.filterConditionKey || ''
+            return ActionUtils.formatParams(formParams)
+        },
+        initData () {
+            if (this.multiple) {
+                this.selectData = this.getArrayValue()
+            } else {
+                this.selectData = this.value
+            }
+            this.initSelectDataOptions()
+        },
+        initSelectDataOptions () {
+            if (this.$utils.isEmpty(this.selectDataOptions) || this.$utils.isEmpty(this.selectData)) return
+            if (this.multiple) {
+                this.selectData.forEach(data => {
+                    this.setSelectDataOptions(data)
+                })
+            } else {
+                this.setSelectDataOptions(this.selectData)
+            }
+        },
+        setSelectDataOptions (v) {
+            const data = this.selectDataOptions.find(item => {
+                return item[this.valueKey] === v
+            })
+            if (!data) {
+                // bug 2022-03-09 nichuqia modified
+                // this.selectDataOptions.push(this.getTreeData(v))
+            }
+        },
+        getArrayValue () {
+            if (this.store === 'string') {
+                return this.$utils.isNotEmpty(this.value) ? this.value.split(this.storeSeparator) : []
+            } else {
+                return this.value || []
+            }
+        },
+        getStoreValue (val) {
+            if (this.multiple) {
                 if (this.store === 'string') {
-                    return this.$utils.isNotEmpty(this.value) ? this.value.split(this.storeSeparator) : []
+                    return this.$utils.isNotEmpty(val) ? val.join(this.storeSeparator) : ''
                 } else {
-                    return this.value || []
-                }
-            },
-            getStoreValue(val) {
-                if (this.multiple) {
-                    if (this.store === 'string') {
-                        return this.$utils.isNotEmpty(val) ? val.join(this.storeSeparator) : ''
-                    } else {
-                        return val || []
-                    }
-                } else {
-                    return val
-                }
-            },
-            getSelectedData(val) {
-                if (this.$utils.isEmpty(val) || this.$utils.isEmpty(this.listData)) {
-                    return {}
+                    return val || []
                 }
-                const data = this.listData.find(d => {
-                    if (d[this.pkKey] === val) {
-                        return d
-                    }
-                })
-                return data
-            },
-            clearData() {
-                const val = ''
-                this.$emit('input', this.getStoreValue(val))
-                this.changeData(val)
-                this.changeLinkAttr()
-            },
-            changeData(val) {
-                if (!this.multiple && this.getSelectedData(val)) {
-                    this.$emit('change-link-data', val, this.getSelectedData(val))
-                }
-            },
-            changeLinkAttr() {
-                if (!this.multiple) {
-                    this.$emit('change-link-attr', this.value, this.getSelectedData(this.value))
+            } else {
+                return val
+            }
+        },
+        getSelectedData (val) {
+            if (this.$utils.isEmpty(val) || this.$utils.isEmpty(this.listData)) {
+                return {}
+            }
+            const data = this.listData.find(d => {
+                if (d[this.pkKey] === val) {
+                    return d
                 }
+            })
+            return data
+        },
+        clearData () {
+            const val = ''
+            this.$emit('input', this.getStoreValue(val))
+            this.changeData(val)
+            this.changeLinkAttr()
+        },
+        changeData (val) {
+            if (!this.multiple && this.getSelectedData(val)) {
+                this.$emit('change-link-data', val, this.getSelectedData(val))
+            }
+        },
+        changeLinkAttr () {
+            if (!this.multiple) {
+                this.$emit('change-link-attr', this.value, this.getSelectedData(this.value))
             }
         }
     }
+}
 </script>

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

@@ -940,7 +940,7 @@ export default {
             this.beforeScript(command, position, selection, data, () => {
                 let src = ''
                 this.readonly = false
-                const { first = '' } = this.$store.getters.level || {}
+                const { first = '', second = '' } = this.$store.getters.level || {}
                 switch (buttonType) {
                     case 'search': // 查询
                         ActionUtils.setFirstPagination(this.pagination)
@@ -1006,7 +1006,7 @@ export default {
                                 this.$message.warning('请先配置对应报表路径!')
                                 return
                             }
-                            src = `${this.$reportPath.replace('show', 'pdf')}${button.reportPath}&id_=${selection}&org_=${first}`
+                            src = `${this.$reportPath.replace('show', 'pdf')}${button.reportPath}&id_=${selection}&org_=${first}&second_=${second}`
                             // console.log(src)
                             this.$common.preview(this, src)
                         }
@@ -1017,7 +1017,7 @@ export default {
                             return
                         }
                         this.$common.snapshoot({
-                            url: this.$getReportFile(button.reportPath, `id_=${selection}&org_=${first}`),
+                            url: this.$getReportFile(button.reportPath, `id_=${selection}&org_=${first}&second_=${second}`),
                             name: selection,
                             type: 'pdf'
                         }).then((res) => {

+ 7 - 1
src/business/platform/org/selector/index.vue

@@ -9,6 +9,7 @@
             :disabled="disabled"
             :disabled-icon="disabledIcon"
             :show-placeholder="showPlaceholder"
+            :temp-search="tempSearch"
             @click="handleSelectorClick"
             @remove="handleSelectorRemove"
         />
@@ -122,7 +123,12 @@ export default {
             type: Boolean,
             default: false
         },
-        formData: Object
+        formData: Object,
+        tempSearch: { // 是否是数据模板使用的筛选条件
+            type: Boolean,
+            default: false
+        }
+
     },
     data () {
         return {

+ 220 - 209
src/components/ibps-selector/selector.vue

@@ -1,232 +1,243 @@
 <template>
-  <div
-    class="el-selector"
-    @click="handleFocus"
-  >
     <div
-      v-if="selected && selected.length >0"
-      ref="tags"
-      :style="{ 'max-width': inputWidth + 'px', width: '100%',overflow: 'hidden','white-space': 'ellipsis',  'word-break': 'break-all','text-overflow': 'ellipsis'}"
-      class="el-selector__tags"
+        class="el-selector"
+        @click="handleFocus"
     >
-      <transition-group @after-leave="resetInputHeight">
-        <template v-for="(item,index) in selected">
-
-          <el-tag
-            type='primary'
-            v-if="$utils.isNotEmpty(item) "
-            :key="item+index"
-            :closable="!selectDisabled"
-            :size="collapseTagSize"
-            disable-transitions
-            @close="deleteTag(index)"
-          >
-            <span class="el-selector__tags-text">{{ item }}</span>
-          </el-tag>
-        </template>
-      </transition-group>
+        <div
+            v-if="selected && selected.length >0"
+            ref="tags"
+            :style="{ 'max-width': inputWidth + 'px', width: '100%',overflow: 'hidden','white-space': 'ellipsis', 'word-break': 'break-all','text-overflow': 'ellipsis'}"
+            class="el-selector__tags"
+        >
+            <transition-group @after-leave="resetInputHeight">
+                <template v-for="(item, index) in selected">
+                    <template v-if="$utils.isNotEmpty(item)">
+                        <!-- 第一个选中值一直显示为内容,非列表查询条件一直显示为内容 -->
+                        <el-tag
+                            v-if="index === 0 || !tempSearch"
+                            :key="item + index"
+                            type="primary"
+                            :closable="!selectDisabled"
+                            :size="collapseTagSize"
+                            disable-transitions
+                            @close="deleteTag(index)"
+                        >
+                            <span class="el-selector__tags-text">{{ item }}</span>
+                        </el-tag>
+                        <el-tag
+                            v-else-if="tempSearch && index === 1"
+                            :key="item + index"
+                            :size="collapseTagSize"
+                            type="primary"
+                        >
+                            <span class="el-selector__tags-text">+ {{ selected.length - 1 }}</span>
+                        </el-tag>
+                    </template>
+                </template>
+            </transition-group>
+        </div>
+        <el-input
+            ref="reference"
+            v-model="selectedLabel"
+            :disabled="selectDisabled"
+            :validate-event="false"
+            :size="selectSize"
+            :placeholder="currentPlaceholder"
+            type="text"
+            :class="inputClass"
+            @focus="handleFocus"
+            @mouseenter.native="inputHovering = true"
+            @mouseleave.native="inputHovering = false"
+        >
+            <i v-if="prefixIconClass" slot="prefix" :class="prefixIconClass" />
+        </el-input>
     </div>
-    <el-input
-      ref="reference"
-      v-model="selectedLabel"
-      :disabled="selectDisabled"
-      :validate-event="false"
-      :size="selectSize"
-      :placeholder="currentPlaceholder"
-      type="text"
-      :class="inputClass"
-      @focus="handleFocus"
-      @mouseenter.native="inputHovering = true"
-      @mouseleave.native="inputHovering = false"
-    >
-      <i v-if="prefixIconClass" slot="prefix" :class="prefixIconClass" />
-    </el-input>
-  </div>
 
 </template>
 <script>
 import { addResizeListener, removeResizeListener } from '@/plugins/element-ui/src/utils/resize-event'
 import emitter from '@/plugins/element-ui/src/mixins/emitter'
 const sizeMap = {
-  'medium': 36,
-  'small': 32,
-  'mini': 28
+    'medium': 36,
+    'small': 32,
+    'mini': 28
 }
 
 export default {
-  name: 'ibps-selector',
-  mixins: [emitter],
-  props: {
-    items: {
-      type: Array
-    },
-    placeholder: {
-      type: String,
-      default: '请选择'
-    },
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
-    },
-    icon: {
-      type: String,
-      default: 'el-icon-plus'
-    },
-    disabledIcon: {
-      type: Boolean,
-      default: false
-    },
-    disabled: {
-      type: Boolean,
-      default: false
-    },
-    readonly: {
-      type: Boolean,
-      default: false
-    },
-    showPlaceholder: { // 是否显示占位符
-      type: Boolean,
-      default: false
-    },
-    /**
-     * 只读样式 【text original】
-     */
-    readonlyText: {
-      type: String,
-      default: 'original'
-    },
-    inputBorderStyle: {
-      type: String
-    },
-    size: {
-      type: String,
-      default: 'mini'
-    }
-  },
-  data() {
-    return {
-      query: '',
-      inputLength: 20,
-      inputWidth: 0,
-      inputHovering: false,
-      selected: []
-    }
-  },
-  computed: {
-    hasValue() {
-      return this.items && this.items.length > 0
-    },
-    selectedLabel() {
-      return this.hasValue ? ' ' : ''
-    },
-    prefixIconClass() {
-      let classes = ['el-selector__caret', 'el-input__icon']
-      if ((this.disabled || this.readonly) && !this.disabledIcon) {
-        return
-      }
-
-      if (this.hasValue) {
-        classes = [...classes, this.icon, 'is-show-close']
-      } else {
-        classes.push(this.icon)
-      }
-      return classes
-    },
-    inputClass() {
-      let classes = []
-      if (this.readonlyText === 'text') {
-        classes = ['el-selector__readonly-text']
-      }
-      if (this.inputBorderStyle) {
-        classes = [...classes, 'el-selector__' + this.inputBorderStyle]
-      }
-      return classes
-    },
-    selectDisabled() {
-      return this.disabled || (this.elForm || {}).disabled
-    },
-    selectSize() {
-      return this.size || (this.elFormItem || {}).elFormItemSize || (this.$ELEMENT || {}).size
+    name: 'ibps-selector',
+    mixins: [emitter],
+    props: {
+        items: {
+            type: Array
+        },
+        placeholder: {
+            type: String,
+            default: '请选择'
+        },
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        icon: {
+            type: String,
+            default: 'el-icon-plus'
+        },
+        disabledIcon: {
+            type: Boolean,
+            default: false
+        },
+        disabled: {
+            type: Boolean,
+            default: false
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        },
+        showPlaceholder: { // 是否显示占位符
+            type: Boolean,
+            default: false
+        },
+        /**
+         * 只读样式 【text original】
+         */
+        readonlyText: {
+            type: String,
+            default: 'original'
+        },
+        inputBorderStyle: {
+            type: String
+        },
+        size: {
+            type: String,
+            default: 'mini'
+        },
+        tempSearch: { // 是否是数据模板使用的筛选条件
+            type: Boolean,
+            default: false
+        }
     },
-    collapseTagSize() {
-      return ['small', 'mini'].indexOf(this.selectSize) > -1
-        ? 'mini'
-        : 'small'
+    data () {
+        return {
+            query: '',
+            inputLength: 20,
+            inputWidth: 0,
+            inputHovering: false,
+            selected: []
+        }
     },
-    currentPlaceholder() {
-      if (!this.showPlaceholder && (this.readonly || this.selectDisabled)) {
-        return ''
-      }
+    computed: {
+        hasValue () {
+            return this.items && this.items.length > 0
+        },
+        selectedLabel () {
+            return this.hasValue ? ' ' : ''
+        },
+        prefixIconClass () {
+            let classes = ['el-selector__caret', 'el-input__icon']
+            if ((this.disabled || this.readonly) && !this.disabledIcon) {
+                return
+            }
 
-      if (!this.items || (Array.isArray(this.items) && this.items.length === 0)) {
-        return this.placeholder
-      } else {
-        return ''
-      }
-    }
-  },
-  watch: {
-    items(val) {
-      if(val){
-      this.setSelected()
-      }
-    }
-  },
-  mounted() {
-    addResizeListener(this.$el, this.handleResize)
+            if (this.hasValue) {
+                classes = [...classes, this.icon, 'is-show-close']
+            } else {
+                classes.push(this.icon)
+            }
+            return classes
+        },
+        inputClass () {
+            let classes = []
+            if (this.readonlyText === 'text') {
+                classes = ['el-selector__readonly-text']
+            }
+            if (this.inputBorderStyle) {
+                classes = [...classes, 'el-selector__' + this.inputBorderStyle]
+            }
+            return classes
+        },
+        selectDisabled () {
+            return this.disabled || (this.elForm || {}).disabled
+        },
+        selectSize () {
+            return this.size || (this.elFormItem || {}).elFormItemSize || (this.$ELEMENT || {}).size
+        },
+        collapseTagSize () {
+            return ['small', 'mini'].indexOf(this.selectSize) > -1 ? 'mini' : 'small'
+        },
+        currentPlaceholder () {
+            if (!this.showPlaceholder && (this.readonly || this.selectDisabled)) {
+                return ''
+            }
 
-    const reference = this.$refs.reference
-    this.$nextTick(() => {
-      if (reference && reference.$el) {
-        this.inputWidth = reference.$el.getBoundingClientRect().width
-      }
-    })
-    this.setSelected()
-  },
-  beforeDestroy() {
-    removeResizeListener(this.$el, this.handleResize)
-  },
-  methods: {
-    setSelected() {
-      const result = []
-      if (Array.isArray(this.items)) {
-        this.items.forEach(item => {
-          result.push(item)
-        })
-      }
-      this.selected = result
-      if (this.multiple) {
-        this.$nextTick(this.resetInputHeight)
-      }
-    },
-    resetInputWidth() {
-      if (!this.$refs.reference) return
-      this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width
-    },
-    resetInputHeight() {
-      this.$nextTick(() => {
-        if (!this.$refs.reference) return
-        const inputEl = this.$refs.reference.$refs.input
-        const tags = this.$refs.tags
-        let height = sizeMap[this.selectSize] || 40
-        if (this.selected.length !== 0) {
-          height = Math.max((tags.clientHeight + (tags.clientHeight > height ? 6 : 0)), height)
+            if (!this.items || (Array.isArray(this.items) && this.items.length === 0)) {
+                return this.placeholder
+            } else {
+                return ''
+            }
         }
-        inputEl.style.height = `${height}px`
-      })
-    },
-    handleResize() {
-      this.resetInputWidth()
-      if (this.multiple) this.resetInputHeight()
     },
-    handleFocus() {
-      if (this.disabled) return
-      this.$refs.reference.blur()
-      this.$emit('click')
+    watch: {
+        items (val) {
+            if (val) {
+                this.setSelected()
+            }
+        }
     },
-    deleteTag(index) {
-      this.$emit('remove', index)
+    mounted () {
+        addResizeListener(this.$el, this.handleResize)
+        const reference = this.$refs.reference
+        this.$nextTick(() => {
+            if (reference && reference.$el) {
+                this.inputWidth = reference.$el.getBoundingClientRect().width
+            }
+        })
+        this.setSelected()
+    },
+    beforeDestroy () {
+        removeResizeListener(this.$el, this.handleResize)
+    },
+    methods: {
+        setSelected () {
+            const result = []
+            if (Array.isArray(this.items)) {
+                this.items.forEach(item => {
+                    result.push(item)
+                })
+            }
+            this.selected = result
+            if (this.multiple) {
+                this.$nextTick(this.resetInputHeight)
+            }
+        },
+        resetInputWidth () {
+            if (!this.$refs.reference) return
+            this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width
+        },
+        resetInputHeight () {
+            this.$nextTick(() => {
+                if (!this.$refs.reference) return
+                const inputEl = this.$refs.reference.$refs.input
+                const tags = this.$refs.tags
+                let height = sizeMap[this.selectSize] || 40
+                if (this.selected.length !== 0) {
+                    height = Math.max((tags.clientHeight + (tags.clientHeight > height ? 6 : 0)), height)
+                }
+                inputEl.style.height = `${height}px`
+            })
+        },
+        handleResize () {
+            this.resetInputWidth()
+            if (this.multiple) this.resetInputHeight()
+        },
+        handleFocus () {
+            if (this.disabled) return
+            this.$refs.reference.blur()
+            this.$emit('click')
+        },
+        deleteTag (index) {
+            this.$emit('remove', index)
+        }
     }
-  }
 }
 </script>

+ 1 - 1
src/utils/action.js

@@ -263,7 +263,7 @@ const action = {
         const results = {}
         if (params) {
             results.parameters = Object.keys(params).map((k) => {
-                return {
+                return k === 'arg' ? params[k] : {
                     'key': k,
                     'value': params[k]
                 }