linweizeng 2 лет назад
Родитель
Сommit
3a46703ab7

+ 182 - 229
src/business/platform/form/formbuilder/right-aside/editors/editor-field-selector.vue

@@ -1,107 +1,72 @@
 <template>
-  <div class="panel panel-default">
-    <div class="panel-heading">参数设置</div>
-    <div class="panel-body">
-      <el-form-item v-if="types.includes('selector_type')" label-width="110px">
-        <template slot="label">选择器类型<help-tip prop="selectorType" /></template>
-        <el-select
-          v-model="fieldOptions.selector_type"
-          style="width:100%;"
-          @change="(val)=>selectorChange(val)"
-        >
-          <el-option
-            v-for="option in selectorTypeOptions"
-            :key="option.value"
-            :value="option.value"
-            :label="option.label"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item v-if="types.includes('multiple')">
-        <template slot="label">是否多选<help-tip prop="multiple" /></template>
-        <el-switch
-          v-model="fieldOptions.multiple"
-          @change="setDefaultValue"
-        />
-      </el-form-item>
-      <!--TODO:选择器范围-->
-      <el-form-item v-if="types.includes('selector_type')" label-width="95px">
-        <template slot="label">选择范围<help-tip prop="checkScope" /></template>
-        <el-button
-          icon="el-icon-s-tools"
-          :disabled="(fieldOptions.selector_type==='user'&&fieldOptions.filter.length===4)||(fieldOptions.selector_type!=='user'&&fieldOptions.filter.length===1)"
-          type="primary"
-          size="mini"
-          style="font-size:14px;"
-          plain
-          @click="addScope"
-        >
-          设置
-        </el-button>
-      </el-form-item>
-      <!--范围  -->
-      <el-form-item label-width="95px">
-        <div v-for="(filter,i) in fieldOptions.filter" :key="i" class="list-scope-group-item">
-          <el-row>
-            <!-- <el-col :span="filter.type==='role'?6:filter.type==='user'?18:12"> -->
-            <el-col :span="18">
-              <el-tag v-if="$utils.isNotEmpty(filter.userType)" effect="plain">
-                {{ filter.userType|optionsFilter(partyTypeOptions,'label') }}
-              </el-tag>
-              <el-tag v-if="$utils.isNotEmpty(filter.descVal)" effect="plain" style="margin-left:2px;">
-                {{ filter.descVal|optionsFilter(selectorScopeOption,'label') }}
-              </el-tag>
+    <div class="panel panel-default">
+        <div class="panel-heading">参数设置</div>
+        <div class="panel-body">
+            <el-form-item v-if="types.includes('selector_type')" label-width="110px">
+                <template slot="label">选择器类型<help-tip prop="selectorType" /></template>
+                <el-select v-model="fieldOptions.selector_type" style="width: 100%" @change="(val) => selectorChange(val)">
+                    <el-option v-for="option in selectorTypeOptions" :key="option.value" :value="option.value" :label="option.label" />
+                </el-select>
+            </el-form-item>
+            <el-form-item v-if="types.includes('multiple')">
+                <template slot="label">是否多选<help-tip prop="multiple" /></template>
+                <el-switch v-model="fieldOptions.multiple" @change="setDefaultValue" />
+            </el-form-item>
+            <el-form-item v-if="types.includes('multiple')">
+                <template slot="label">是否过滤</template>
+                <el-switch v-model="fieldOptions.filtrate" @change="setDefaultValue" />
+            </el-form-item>
+            <!--TODO:选择器范围-->
+            <el-form-item v-if="types.includes('selector_type')" label-width="95px">
+                <template slot="label">选择范围<help-tip prop="checkScope" /></template>
+                <el-button icon="el-icon-s-tools" :disabled="(fieldOptions.selector_type === 'user' && fieldOptions.filter.length === 4) || (fieldOptions.selector_type !== 'user' && fieldOptions.filter.length === 1)" type="primary" size="mini" style="font-size: 14px" plain @click="addScope"> 设置 </el-button>
+            </el-form-item>
+            <!--范围  -->
+            <el-form-item label-width="95px">
+                <div v-for="(filter, i) in fieldOptions.filter" :key="i" class="list-scope-group-item">
+                    <el-row>
+                        <!-- <el-col :span="filter.type==='role'?6:filter.type==='user'?18:12"> -->
+                        <el-col :span="18">
+                            <el-tag v-if="$utils.isNotEmpty(filter.userType)" effect="plain">
+                                {{ filter.userType | optionsFilter(partyTypeOptions, 'label') }}
+                            </el-tag>
+                            <el-tag v-if="$utils.isNotEmpty(filter.descVal)" effect="plain" style="margin-left: 2px">
+                                {{ filter.descVal | optionsFilter(selectorScopeOption, 'label') }}
+                            </el-tag>
 
-              <el-button-group class="actions">
-                <el-button size="small" type="text" title="设置" icon="ibps-icon-cog" @click="settingButton(i)" />
-                <el-button size="small" type="text" title="删除" icon="el-icon-delete" @click="removeButton(i)" />
-              </el-button-group>
-              <!-- <el-tag v-if="filter.type!=='role'&&$utils.isNotEmpty(filter.includeSub)" effect="plain" style="margin-left:2px;">
+                            <el-button-group class="actions">
+                                <el-button size="small" type="text" title="设置" icon="ibps-icon-cog" @click="settingButton(i)" />
+                                <el-button size="small" type="text" title="删除" icon="el-icon-delete" @click="removeButton(i)" />
+                            </el-button-group>
+                            <!-- <el-tag v-if="filter.type!=='role'&&$utils.isNotEmpty(filter.includeSub)" effect="plain" style="margin-left:2px;">
                 {{ filter.includeSub?'含子集':'不含子集' }}
               </el-tag> -->
-            </el-col>
-            <!-- <el-col :span="4">
+                        </el-col>
+                        <!-- <el-col :span="4">
               <el-button-group class="actions">
                 <el-button size="small" type="text" title="设置" icon="ibps-icon-cog" @click="settingButton(i)" />
                 <el-button size="small" type="text" title="删除" icon="el-icon-delete" @click="removeButton(i)" />
               </el-button-group>
             </el-col> -->
-          </el-row>
-        </div>
-      </el-form-item>
-      <el-form-item v-if="types.includes('store')">
-        <template slot="label">存储格式<help-tip prop="selectorStore" /></template>
-        <el-select
-          v-model="fieldOptions.store"
-          style="width:100%;"
-          @change="selectorStoreValue"
-        >
-          <el-option
-            v-for="store in selectorStoreOptions"
-            :key="store.value"
-            :value="store.value"
-            :label="store.label"
-          />
-        </el-select>
-      </el-form-item>
-      <el-form-item v-if="fieldOptions.store==='bind'">
-        <template slot="label">绑定值<help-tip :prop="fieldOptions.selector_type==='user'?'bind':'bindOther'" /></template>
-        <el-select
-          v-model="fieldOptions.bind"
-          style="width:100%;"
-        >
-          <el-option
-            v-for="store in bindValueOptions"
-            :key="store.value"
-            :value="store.value"
-            :label="store.label"
-          />
-        </el-select></el-form-item>
-      <el-form-item v-if="fieldOptions.store==='bind'">
-        <template slot="label">存储字段<help-tip prop="bindFiled" /></template>
-        <ibps-bo-select v-model="fieldItem.bindFiled" :data="boFields" placeholder="请绑定属性" empty-text="未设置存储字段" @change="changeBoName" />
+                    </el-row>
+                </div>
+            </el-form-item>
+            <el-form-item v-if="types.includes('store')">
+                <template slot="label">存储格式<help-tip prop="selectorStore" /></template>
+                <el-select v-model="fieldOptions.store" style="width: 100%" @change="selectorStoreValue">
+                    <el-option v-for="store in selectorStoreOptions" :key="store.value" :value="store.value" :label="store.label" />
+                </el-select>
+            </el-form-item>
+            <el-form-item v-if="fieldOptions.store === 'bind'">
+                <template slot="label">绑定值<help-tip :prop="fieldOptions.selector_type === 'user' ? 'bind' : 'bindOther'" /></template>
+                <el-select v-model="fieldOptions.bind" style="width: 100%">
+                    <el-option v-for="store in bindValueOptions" :key="store.value" :value="store.value" :label="store.label" /> </el-select
+            ></el-form-item>
+            <el-form-item v-if="fieldOptions.store === 'bind'">
+                <template slot="label">存储字段<help-tip prop="bindFiled" /></template>
+                <ibps-bo-select v-model="fieldItem.bindFiled" :data="boFields" placeholder="请绑定属性" empty-text="未设置存储字段" @change="changeBoName" />
 
-        <!-- <ibps-tree-select
+                <!-- <ibps-tree-select
           v-model="fieldOptions.bindFiled"
           :data="boTreeData"
           :props="props"
@@ -112,22 +77,11 @@
           clearable
           filterable
         /> -->
-      </el-form-item>
+            </el-form-item>
+        </div>
+        <!-- // 设置 -->
+        <setting-optional-scope :title="title" :visible="settingOptionalScopeVisible" :data="editData" :bo-data="boData" :readonly="readonly" :button-key="buttonKey" :existing-type-scope="existingTypeScope" :selector-type="fieldOptions.selector_type" @callback="setDataTemplateScopeAttr" @close="(visible) => (settingOptionalScopeVisible = visible)" />
     </div>
-    <!-- // 设置 -->
-    <setting-optional-scope
-      :title="title"
-      :visible="settingOptionalScopeVisible"
-      :data="editData"
-      :bo-data="boData"
-      :readonly="readonly"
-      :button-key="buttonKey"
-      :existing-type-scope="existingTypeScope"
-      :selector-type="fieldOptions.selector_type"
-      @callback="setDataTemplateScopeAttr"
-      @close="visible => settingOptionalScopeVisible = visible"
-    />
-  </div>
 </template>
 <script>
 import { partyTypeOptions } from '@/business/platform/org/employee/constants'
@@ -139,130 +93,129 @@ import IbpsBoSelect from '@/business/platform/bo/def/select'
 import EditorMixin from '../mixins/editor'
 
 export default {
-  components: {
-    settingOptionalScope,
-    // IbpsTreeSelect
-    IbpsBoSelect
-  },
-  mixins: [EditorMixin],
-  props: {
-    types: {
-      type: String,
-      default: 'selector_type,multiple,store'
-    }
-  },
-  data() {
-    return {
-      settingOptionalScopeVisible: false,
-      partyTypeOptions: partyTypeOptions,
-      selectorScopeOption: selectorScopeOption,
-      selectorTypeOptions: selectorTypeOptions,
-      selectorStoreOptions: selectorStoreOptions,
-      bindValueOptions: bindValueEmployeeOptions,
-      editData: {},
-      props: {
-        children: 'children',
-        label: 'name'
-      },
-      editIndex: 0,
-      buttonKey: 'add',
-      readonly: true,
-      title: '添加范围',
-      existingTypeScope: []
-    }
-  },
-  // computed: {
-  //   boTreeData() {
-  //     return TreeUtils.transformToTreeFormat(this.boData, {
-  //       idKey: 'id',
-  //       pIdKey: 'parentId'
-  //     })
-  //   }
-  // },
-  methods: {
-    changeBoName(value, data) {
-      if (data.data.key === 'id' || data.data.key === 'parentId') {
-        this.$message({
-          title: '提示',
-          message: '此字段不能用作存储!',
-          type: 'warning'
-        })
-        return false
-      }
-      this.fieldOptions.bindFiled = data.data.key
-      // this.fieldOptions.attrType = data.attrType
-      // this.fieldOptions.isSub = data.attrType === 'subField'
-      // this.fieldOptions.code = data.tableName
-      // this.fieldOptions.tableName = data.tableName
-      // console.info(data, this.fieldOptions, '=>>选择器关联表单字段详细信息')
-      return true
+    components: {
+        settingOptionalScope,
+        // IbpsTreeSelect
+        IbpsBoSelect
     },
-    selectorStoreValue(val) {
-      // if (val !== 'bind') {
-      //   this.fieldOptions.bind = ''
-      // this.fieldOptions.bindFiled = ''
-      // }
-      // this.fieldOptions.attrType = ''
-      // this.fieldOptions.tableName = ''
-      // this.fieldOptions.isSub = false
-    },
-    selectorChange(val) {
-      this.setDefaultValue()
-      this.bindValueOptions = val === 'user' ? bindValueEmployeeOptions : bindValueOtherOptions
-      this.fieldOptions.bind = 'id'
-      // this.fieldOptions.bindFiled = ''
-      this.fieldItem.bindFiled = ''
-      this.fieldOptions.filter = []
-      this.fieldOptions.store = 'id'
-    },
-    setDataTemplateScopeAttr(data) {
-      this.buttonKey === 'add' ? this.fieldOptions.filter = [...this.fieldOptions.filter, ...data] : this.fieldOptions.filter[this.editIndex] = data[0]
-    },
-    settlingDefaultValue() {
-      if (this.fieldOptions.default_value_type === 'fixed') {
-        this.fieldOptions.default_value = ''
-      }
-      this.fieldOptions.filter = []
-    },
-    addScope() {
-      this.readonly = false
-      this.editData = {}
-      this.buttonKey = 'add'
-      this.title = '添加范围'
-      this.setTypeOptions()
-      this.settingOptionalScopeVisible = true
-    },
-    // 设置按钮
-    settingButton(i) {
-      this.readonly = false
-      this.buttonKey = 'setting'
-      this.title = '编辑范围'
-      this.setTypeOptions()
-      this.editData = this.fieldOptions.filter[i]
-      this.editIndex = i
-      this.settingOptionalScopeVisible = true
+    mixins: [EditorMixin],
+    props: {
+        types: {
+            type: String,
+            default: 'selector_type,multiple,store'
+        }
     },
-    // 设置类型切换值
-    setTypeOptions() {
-      const existingTypeScope = []
-      const typeScope = []
-      this.fieldOptions.filter.forEach(f => {
-        existingTypeScope.push(f.userType)
-      })
-      // 根据已选范围动态调整范围下拉数据
-      const partyTypeOptions = JSON.parse(JSON.stringify(this.partyTypeOptions))
-      partyTypeOptions.forEach((f, i) => {
-        if (!existingTypeScope.includes(f.value)) {
-          typeScope.push(f)
+    data() {
+        return {
+            settingOptionalScopeVisible: false,
+            partyTypeOptions: partyTypeOptions,
+            selectorScopeOption: selectorScopeOption,
+            selectorTypeOptions: selectorTypeOptions,
+            selectorStoreOptions: selectorStoreOptions,
+            bindValueOptions: bindValueEmployeeOptions,
+            editData: {},
+            props: {
+                children: 'children',
+                label: 'name'
+            },
+            editIndex: 0,
+            buttonKey: 'add',
+            readonly: true,
+            title: '添加范围',
+            existingTypeScope: []
         }
-      })
-      this.existingTypeScope = typeScope
     },
-    // 删除按钮
-    removeButton(i) {
-      this.fieldOptions.filter.splice(i, 1)
+    // computed: {
+    //   boTreeData() {
+    //     return TreeUtils.transformToTreeFormat(this.boData, {
+    //       idKey: 'id',
+    //       pIdKey: 'parentId'
+    //     })
+    //   }
+    // },
+    methods: {
+        changeBoName(value, data) {
+            if (data.data.key === 'id' || data.data.key === 'parentId') {
+                this.$message({
+                    title: '提示',
+                    message: '此字段不能用作存储!',
+                    type: 'warning'
+                })
+                return false
+            }
+            this.fieldOptions.bindFiled = data.data.key
+            // this.fieldOptions.attrType = data.attrType
+            // this.fieldOptions.isSub = data.attrType === 'subField'
+            // this.fieldOptions.code = data.tableName
+            // this.fieldOptions.tableName = data.tableName
+            // console.info(data, this.fieldOptions, '=>>选择器关联表单字段详细信息')
+            return true
+        },
+        selectorStoreValue(val) {
+            // if (val !== 'bind') {
+            //   this.fieldOptions.bind = ''
+            // this.fieldOptions.bindFiled = ''
+            // }
+            // this.fieldOptions.attrType = ''
+            // this.fieldOptions.tableName = ''
+            // this.fieldOptions.isSub = false
+        },
+        selectorChange(val) {
+            this.setDefaultValue()
+            this.bindValueOptions = val === 'user' ? bindValueEmployeeOptions : bindValueOtherOptions
+            this.fieldOptions.bind = 'id'
+            // this.fieldOptions.bindFiled = ''
+            this.fieldItem.bindFiled = ''
+            this.fieldOptions.filter = []
+            this.fieldOptions.store = 'id'
+        },
+        setDataTemplateScopeAttr(data) {
+            this.buttonKey === 'add' ? (this.fieldOptions.filter = [...this.fieldOptions.filter, ...data]) : (this.fieldOptions.filter[this.editIndex] = data[0])
+        },
+        settlingDefaultValue() {
+            if (this.fieldOptions.default_value_type === 'fixed') {
+                this.fieldOptions.default_value = ''
+            }
+            this.fieldOptions.filter = []
+        },
+        addScope() {
+            this.readonly = false
+            this.editData = {}
+            this.buttonKey = 'add'
+            this.title = '添加范围'
+            this.setTypeOptions()
+            this.settingOptionalScopeVisible = true
+        },
+        // 设置按钮
+        settingButton(i) {
+            this.readonly = false
+            this.buttonKey = 'setting'
+            this.title = '编辑范围'
+            this.setTypeOptions()
+            this.editData = this.fieldOptions.filter[i]
+            this.editIndex = i
+            this.settingOptionalScopeVisible = true
+        },
+        // 设置类型切换值
+        setTypeOptions() {
+            const existingTypeScope = []
+            const typeScope = []
+            this.fieldOptions.filter.forEach((f) => {
+                existingTypeScope.push(f.userType)
+            })
+            // 根据已选范围动态调整范围下拉数据
+            const partyTypeOptions = JSON.parse(JSON.stringify(this.partyTypeOptions))
+            partyTypeOptions.forEach((f, i) => {
+                if (!existingTypeScope.includes(f.value)) {
+                    typeScope.push(f)
+                }
+            })
+            this.existingTypeScope = typeScope
+        },
+        // 删除按钮
+        removeButton(i) {
+            this.fieldOptions.filter.splice(i, 1)
+        }
     }
-  }
-
 }
 </script>

+ 6 - 0
src/business/platform/form/formrender/dynamic-form/dynamic-form-field.vue

@@ -383,6 +383,7 @@
             :type="fieldOptions.selector_type"
             :filter="fieldOptions.filter"
             :multiple="multiple"
+            :filtrate="filtrate"
             :store="fieldOptions.store || 'id'"
             :disabled="fieldType === 'currentUser' || fieldType === 'currentOrg' || fieldType === 'currentPosition' ? true : readonly"
             :readonly-text="readonlyText ? 'text' : null"
@@ -898,6 +899,11 @@
                 return this.$utils.toBoolean(this.fieldOptions['multiple'], false)
             },
 
+            // 是否过滤
+            filtrate() {
+                return this.$utils.toBoolean(this.fieldOptions['filtrate'] || false, false)
+            },
+
             operation_status() {
                 return this.fieldOptions['operation_status']
             },

+ 157 - 152
src/business/platform/org/employee/dialog.vue

@@ -1,161 +1,166 @@
 <template>
-  <ibps-selector-dialog
-    :value="selectedValue"
-    :visible="selectorVisible"
-    v-bind="$props"
-    :class="className"
-    @input="value => selectedValue = value"
-    @remove-select="setSelectRow"
-    @close="handleClose"
-    @action-event="handleActionEvent"
-  >
-    <template slot-scope="scope">
-      <ibps-selector-panel
-        ref="panel"
-        v-bind="scope"
-        :party-type-id="partyTypeId"
-        :seeting-search-party-type="seetingSearchPartyType"
-        :current-org-id="currentOrgId"
-        :script="script"
-        :is-super-init-tree="isSuperInitTree"
-        :show-tree="showTree"
-        :is-use-scope="isUseScope"
-        :party-type-scope="partyTypeScope"
-        :custom-party-type-options="customPartyTypeOptions"
-        @selected="value => selectedValue = value"
-        @change-party-type="changePartyType"
-      />
-    </template>
-  </ibps-selector-dialog>
+    <ibps-selector-dialog
+        :value="selectedValue"
+        :visible="selectorVisible"
+        v-bind="$props"
+        :class="className"
+        @input="value => selectedValue = value"
+        @remove-select="setSelectRow"
+        @close="handleClose"
+        @action-event="handleActionEvent"
+    >
+        <template slot-scope="scope">
+            <ibps-selector-panel
+                ref="panel"
+                v-bind="scope"
+                :party-type-id="partyTypeId"
+                :seeting-search-party-type="seetingSearchPartyType"
+                :current-org-id="currentOrgId"
+                :script="script"
+                :is-super-init-tree="isSuperInitTree"
+                :show-tree="showTree"
+                :is-use-scope="isUseScope"
+                :party-type-scope="partyTypeScope"
+                :custom-party-type-options="customPartyTypeOptions"
+                :filtrate="filtrate"
+                @selected="value => selectedValue = value"
+                @change-party-type="changePartyType"
+            />
+        </template>
+    </ibps-selector-dialog>
 </template>
 <script>
 import IbpsSelectorDialog from '@/components/ibps-selector/dialog'
 import IbpsSelectorPanel from './panel'
 export default {
-  components: {
-    IbpsSelectorDialog,
-    IbpsSelectorPanel
-  },
-  props: {
-    className: String,
-    filter: {
-      type: Array,
-      default: () => []
-    },
-    isUseScope: { // 是否启用范围
-      type: Boolean,
-      default: false
-    },
-    partyTypeScope: String,
-    visible: Boolean, // 是否可见
-    seetingSearchPartyType: String,
-    script: String,
-    partyTypeId: [String, Number],
-    currentOrgId: [String, Number],
-    showTree: {
-      type: Boolean,
-      default: true
-    },
-    customPartyTypeOptions: [Object, Array],
-    title: { // 标题
-      type: String,
-      default: '选择指定人员'
-    },
-    marginTop: { // Dialog CSS 中的 margin-top 值
-      type: String,
-      default: '5vh'
-    },
-    width: { // 宽
-      type: String,
-      default: '60%'
-    },
-    height: { // 高
-      type: String,
-      default: '415px'
-    },
-    closeOnClickModal: { // 是否可以通过点击 modal 关闭 Dialog
-      type: Boolean,
-      default: false
-    },
-    closeOnPressEscape: { // 是否可以通过按下 ESC 关闭 Dialog
-      type: Boolean,
-      default: false
-    },
-    showClose: { // 是否显示关闭按钮
-      type: Boolean,
-      default: true
-    },
-    beforeClose: { // 关闭前的回调,会暂停 Dialog 的关闭
-      type: Function
-    },
-    fullscreen: { // 是否为全屏 Dialog
-      type: Boolean,
-      default: false
-    },
-    labelKey: { // 展示的值
-      type: String,
-      default: 'name'
-    },
-    valueKey: { // 唯一存储的值
-      type: String,
-      default: 'id'
-    },
-    value: { // value
-      type: [Object, Array],
-      default() { return this.multiple ? [] : {} }
-    },
-    cleanClose: { // 按钮清空并关闭
-      type: Boolean,
-      default: false
-    },
-    isSuperInitTree: Object,
-    buttons: { // 按钮组
-      type: Array
-    },
-    confirmButtonText: {
-      type: String,
-      default: '选择'
-    },
-    cleanButtonText: String,
-    cancelButtonText: String,
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
-    }
-  },
-  data() {
-    return {
-      selectorVisible: false,
-      selectedValue: this.multiple ? [] : {}
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.selectorVisible = this.visible
-      },
-      immediate: true
-    },
-    value() {
-      this.selectedValue = this.value
-    }
-  },
-  methods: {
-    setSelectRow() {
-      this.$refs['panel'].setSelectRow()
-    },
-    handleClose(visible) {
-      this.$emit('close', visible)
-    },
-    handleActionEvent(key, data) {
-      if (key === 'clean') {
-        this.setSelectRow()
-      }
-      this.$emit('action-event', key, data)
-    },
-    changePartyType(value) {
-      this.$emit('change-party-type', value)
+    components: {
+        IbpsSelectorDialog,
+        IbpsSelectorPanel
+    },
+    props: {
+        className: String,
+        filter: {
+            type: Array,
+            default: () => []
+        },
+        isUseScope: { // 是否启用范围
+            type: Boolean,
+            default: false
+        },
+        partyTypeScope: String,
+        visible: Boolean, // 是否可见
+        seetingSearchPartyType: String,
+        script: String,
+        partyTypeId: [String, Number],
+        currentOrgId: [String, Number],
+        showTree: {
+            type: Boolean,
+            default: true
+        },
+        customPartyTypeOptions: [Object, Array],
+        title: { // 标题
+            type: String,
+            default: '选择指定人员'
+        },
+        marginTop: { // Dialog CSS 中的 margin-top 值
+            type: String,
+            default: '5vh'
+        },
+        width: { // 宽
+            type: String,
+            default: '60%'
+        },
+        height: { // 高
+            type: String,
+            default: '415px'
+        },
+        closeOnClickModal: { // 是否可以通过点击 modal 关闭 Dialog
+            type: Boolean,
+            default: false
+        },
+        closeOnPressEscape: { // 是否可以通过按下 ESC 关闭 Dialog
+            type: Boolean,
+            default: false
+        },
+        showClose: { // 是否显示关闭按钮
+            type: Boolean,
+            default: true
+        },
+        beforeClose: { // 关闭前的回调,会暂停 Dialog 的关闭
+            type: Function
+        },
+        fullscreen: { // 是否为全屏 Dialog
+            type: Boolean,
+            default: false
+        },
+        labelKey: { // 展示的值
+            type: String,
+            default: 'name'
+        },
+        valueKey: { // 唯一存储的值
+            type: String,
+            default: 'id'
+        },
+        value: { // value
+            type: [Object, Array],
+            default () { return this.multiple ? [] : {} }
+        },
+        cleanClose: { // 按钮清空并关闭
+            type: Boolean,
+            default: false
+        },
+        isSuperInitTree: Object,
+        buttons: { // 按钮组
+            type: Array
+        },
+        confirmButtonText: {
+            type: String,
+            default: '选择'
+        },
+        cleanButtonText: String,
+        cancelButtonText: String,
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        filtrate: {
+            type: Boolean,
+            default: false
+        }
+    },
+    data () {
+        return {
+            selectorVisible: false,
+            selectedValue: this.multiple ? [] : {}
+        }
+    },
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.selectorVisible = this.visible
+            },
+            immediate: true
+        },
+        value () {
+            this.selectedValue = this.value
+        }
+    },
+    methods: {
+        setSelectRow () {
+            this.$refs['panel'].setSelectRow()
+        },
+        handleClose (visible) {
+            this.$emit('close', visible)
+        },
+        handleActionEvent (key, data) {
+            if (key === 'clean') {
+                this.setSelectRow()
+            }
+            this.$emit('action-event', key, data)
+        },
+        changePartyType (value) {
+            this.$emit('change-party-type', value)
+        }
     }
-  }
 }
 </script>

+ 34 - 12
src/business/platform/org/employee/mixins/panelTree.js

@@ -183,11 +183,7 @@ export default {
             }
             getOrgTreeData(params).then(res => {
                 this.loadingTree = false
-                let arr = JSON.parse(JSON.stringify(res.data))
-                //筛选客户 不要了
-                if (arr[0].id != '0' && this.orgAddIndex == 'qita') {
-                    arr = arr.filter(item => item.id !== '1041786072788369408')
-                }
+                const arr = JSON.parse(JSON.stringify(res.data))
                 let treeData
                 if (this.$utils.isNotEmpty(this.isSuperInitTree)) {
                     if (!this.isSuperInitTree.initNode && node.level !== 0) {
@@ -238,29 +234,36 @@ export default {
                 params.includeSub = false
             }
             getPositionTreeData(params).then(response => {
+                const data = response.data
+                data.forEach((item) => {
+                    if (item.name === '岗位树') {
+                        item.name = '部门树'
+                        item.title = '部门树'
+                    }
+                })
                 this.loadingTree = false
                 this.hiddenTree = false
                 // 普通模式
                 if (!this.isUseScope) {
                     if (!init) {
-                        const data = response.data
+                        // const data = response.data
                         this.treeData = TreeUtils.transformToTreeFormat(data)
                         this.setTree(true, this.treeData)
                     }
-                    this.treeDatas = response.data
+                    this.treeDatas = data
                 } else {
                     // 选择器范围模式
                     if (resetParams) {
-                        const data = response.data
+                        // const data = response.data
                         this.treeData = TreeUtils.transformToTreeFormat(data)
                         this.setTree(true, this.treeData)
                     } else {
                         if (!init) {
-                            const data = response.data
+                            // const data = response.data
                             this.treeData = TreeUtils.transformToTreeFormat(data)
                             this.setTree(true, this.treeData)
                         }
-                        this.treeDatas = response.data
+                        this.treeDatas = data
                     }
                 }
             }).catch(() => {
@@ -300,12 +303,31 @@ export default {
                 getPositionTreeData(params).then(res => {
                     this.loadingTree = false
                     const arr = JSON.parse(JSON.stringify(res.data))
+                    arr.forEach((item) => {
+                        if (item.name === '岗位树') {
+                            item.name = '部门树'
+                            item.title = '部门树'
+                        }
+                    })
+                    let arrList
+                    const frist = this.$store.getters.level.first || ''
+                    if (type === '1' && this.filtrate && frist) {
+                        const showBoo = arr.some((item) => item.id === frist)
+                        if (showBoo) {
+                            arrList = arr.filter((item) => item.id === frist)
+                        } else {
+                            arrList = arr
+                        }
+                    } else {
+                        arrList = arr
+                    }
+
                     let treeData
                     if (this.$utils.isEmpty(node.data)) {
-                        treeData = arr
+                        treeData = arrList
                         resolve(this.toTree(treeData))
                     } else {
-                        treeData = type !== '2' ? arr : this.filterPositionTreeChildren(arr, 'root')
+                        treeData = type !== '2' ? arrList : this.filterPositionTreeChildren(arrList, 'root')
                         resolve(this.toTree(treeData))
                     }
                 }).catch(res => {

+ 6 - 2
src/business/platform/org/employee/panel.vue

@@ -98,6 +98,10 @@ export default {
     props: {
         value: [Object, Array],
         multiple: Boolean,
+        filtrate: {
+            type: Boolean,
+            default: false
+        },
         seetingSearchPartyType: String, // 设置查询用户类型
         height: {
             type: String
@@ -254,7 +258,7 @@ export default {
     mounted () {
         if (this.showTree) {
             if (this.isUseScope) return
-            this.loadTreeData(false)
+            this.loadTreeData(true)
         } else {
             this.loadListData()
         }
@@ -415,7 +419,7 @@ export default {
             // 选择器范围模式函数回调
             this.moreSearchParams = {}
             // 普通模式与选择器范围模式切换调用
-            !this.isUseScope ? this.loadTreeData(false) : null
+            !this.isUseScope ? this.loadTreeData() : null
             this.scriptExecuteTime = false // 初始化脚本类型时的函数调用
             this.$emit('change-party-type', value)
         },

+ 290 - 285
src/business/platform/org/employee/selector.vue

@@ -1,24 +1,25 @@
 <template>
-  <div>
-    <ibps-selector
-      v-bind="$props"
-      :items="items"
-      @click="handleSelectorClick"
-      @remove="handleSelectorRemove"
-    />
-    <!-- 选择器 -->
-    <ibps-employee-selector-dialog
-      :visible="selectorVisible"
-      :value="selectorValue"
-      :multiple="multiple"
-      :class="className"
-      :party-type-id="partyTypeId"
-      :current-org-id="currentOrgId"
-      :customPartyTypeOptions="customPartyTypeOptions"
-      @close="visible => selectorVisible = visible"
-      @action-event="handleSelectorActionEvent"
-    />
-  </div>
+    <div>
+        <ibps-selector
+            v-bind="$props"
+            :items="items"
+            @click="handleSelectorClick"
+            @remove="handleSelectorRemove"
+        />
+        <!-- 选择器 -->
+        <ibps-employee-selector-dialog
+            :visible="selectorVisible"
+            :value="selectorValue"
+            :multiple="multiple"
+            :filtrate="filtrate"
+            :class="className"
+            :party-type-id="partyTypeId"
+            :current-org-id="currentOrgId"
+            :custom-party-type-options="customPartyTypeOptions"
+            @close="visible => selectorVisible = visible"
+            @action-event="handleSelectorActionEvent"
+        />
+    </div>
 </template>
 <script>
 import { get } from '@/api/platform/org/employee'
@@ -30,288 +31,292 @@ import IbpsSelector from '@/components/ibps-selector/selector'
 import IbpsEmployeeSelectorDialog from './dialog'
 
 export default {
-  components: {
-    IbpsSelector,
-    IbpsEmployeeSelectorDialog
-  },
-  inject: {
-    elForm: {
-      default: ''
+    components: {
+        IbpsSelector,
+        IbpsEmployeeSelectorDialog
     },
-    elFormItem: {
-      default: ''
-    }
-  },
-  mixins: [emitter],
-  props: {
-    className: String,
-    partyTypeId: [String, Number],
-    currentOrgId: [String, Number],
-    value: {
-      type: [String, Number, Array]
-    },
-    // 存储类型 :
-    // ①、id:只存储id 字符串,
-    // ②、json: json字符串,
-    // ③、array:存储数组数据(完整数据,包含key和value)。
-    // ④、bind:绑定ID,需要回调和返回
-    store: {
-      type: String,
-      default: 'id',
-      validator: function(value) {
-        return ['id', 'json', 'array', 'arrayId', 'bind'].indexOf(value) !== -1
-      }
-    },
-    storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
-      type: String,
-      default: ','
-    },
-    placeholder: { // 输入框占位文本
-      type: String,
-      default: '请选择用户'
-    },
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
-    },
-    labelKey: { // 展示的值
-      type: String,
-      default: 'name'
-    },
-    valueKey: { // 存储唯一值
-      type: String,
-      default: 'id'
-    },
-    disabled: { // 禁用
-      type: Boolean,
-      default: false
+    inject: {
+        elForm: {
+            default: ''
+        },
+        elFormItem: {
+            default: ''
+        }
     },
-    disabledIcon: { // 禁用有图标
-      type: Boolean,
-      default: false
+    mixins: [emitter],
+    props: {
+        className: String,
+        partyTypeId: [String, Number],
+        currentOrgId: [String, Number],
+        value: {
+            type: [String, Number, Array]
+        },
+        // 存储类型 :
+        // ①、id:只存储id 字符串,
+        // ②、json: json字符串,
+        // ③、array:存储数组数据(完整数据,包含key和value)。
+        // ④、bind:绑定ID,需要回调和返回
+        store: {
+            type: String,
+            default: 'id',
+            validator: function (value) {
+                return ['id', 'json', 'array', 'arrayId', 'bind'].indexOf(value) !== -1
+            }
+        },
+        storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
+            type: String,
+            default: ','
+        },
+        placeholder: { // 输入框占位文本
+            type: String,
+            default: '请选择用户'
+        },
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        filtrate: {
+            type: Boolean,
+            default: false
+        },
+        labelKey: { // 展示的值
+            type: String,
+            default: 'name'
+        },
+        valueKey: { // 存储唯一值
+            type: String,
+            default: 'id'
+        },
+        disabled: { // 禁用
+            type: Boolean,
+            default: false
+        },
+        disabledIcon: { // 禁用有图标
+            type: Boolean,
+            default: false
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        },
+        readonlyText: {
+            type: String,
+            default: 'original'
+        },
+        customPartyTypeOptions: [Object, Array]
     },
-    readonly: {
-      type: Boolean,
-      default: false
+    data () {
+        return {
+            selectorVisible: false,
+            selectorValue: this.multiple ? [] : {},
+            cacheData: {},
+            bindIdValue: ''
+        }
     },
-    readonlyText: {
-      type: String,
-      default: 'original'
+    computed: {
+        items () {
+            if (this.$utils.isEmpty(this.selectorValue)) return []
+            if (this.multiple) {
+                return this.selectorValue.map(data => {
+                    return data[this.labelKey]
+                })
+            } else {
+                return [this.selectorValue[this.labelKey]]
+            }
+        }
     },
-    customPartyTypeOptions: [Object, Array],
-  },
-  data() {
-    return {
-      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 data[this.labelKey]
-        })
-      } else {
-        return [this.selectorValue[this.labelKey]]
-      }
-    }
-  },
-  watch: {
-    value: {
-      handler(val, oldVal) {
-        this.initData()
-        if (!valueEquals(val, oldVal)) {
-          this.dispatch('ElFormItem', 'el.form.change', val)
+    watch: {
+        value: {
+            handler (val, oldVal) {
+                this.initData()
+                if (!valueEquals(val, oldVal)) {
+                    this.dispatch('ElFormItem', 'el.form.change', val)
+                }
+            },
+            immediate: true
         }
-      },
-      immediate: true
-    }
-  },
-  methods: {
+    },
+    methods: {
     /**
      * 初始化数据
      */
-    initData() {
-      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 {
-          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 () {
+            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 {
+                    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
-        try {
-          const data = this.$utils.parseData(value)
-          if (this.multiple) {
-            return data.map((d) => {
-              return d[this.valueKey]
-            })
-          } else {
-            return [data]
-          }
-        } catch (error) {
-          console.warn(error)
-          return []
-        }
-      } else if (this.store === 'id') { // id
-        return this.$utils.isString(value) ? 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]
-            o[this.labelKey] = v[this.labelKey]
-            res.push(o)
-          })
-          return JSON.stringify(res)
-        } else {
-          const o = {}
-          o[this.valueKey] = value[this.valueKey]
-          o[this.labelKey] = value[this.labelKey]
-          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)
+        getArrayValue (value, bindId) {
+            if (this.$utils.isEmpty(value)) {
+                return []
+            }
+            if (this.store === 'json') { // json
+                try {
+                    const data = this.$utils.parseData(value)
+                    if (this.multiple) {
+                        return data.map((d) => {
+                            return d[this.valueKey]
+                        })
+                    } else {
+                        return [data]
+                    }
+                } catch (error) {
+                    console.warn(error)
+                    return []
+                }
+            } else if (this.store === 'id') { // id
+                return this.$utils.isString(value) ? 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]
+                        o[this.labelKey] = v[this.labelKey]
+                        res.push(o)
+                    })
+                    return JSON.stringify(res)
+                } else {
+                    const o = {}
+                    o[this.valueKey] = value[this.valueKey]
+                    o[this.labelKey] = value[this.labelKey]
+                    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) {
-      remoteRequest('employee' + this.valueKey, id, () => {
-        return this.getRemoteByIdFunc(id)
-      }).then(response => {
-        const data = response.data
-        this.cacheData[data[this.valueKey]] = data
-        this.setSelectorValue(data[this.valueKey])
-      }).catch(() => {
-      })
-    },
-    getRemoteByIdFunc(id) {
-      return new Promise((resolve, reject) => {
-        if (this.valueKey === 'id') {
-          get({
-            employeeId: id
-          }).then(response => {
-            resolve(response)
-          }).catch((error) => {
-            reject(error)
-          })
-        } else if (this.valueKey === 'account') {
-          getByAccount({
-            'account': id
-          }).then(response => {
-            resolve(response)
-          }).catch((error) => {
-            reject(error)
-          })
-        }
-      })
-    },
-    // ===================事件处理=========
+        getDataInfo (id) {
+            remoteRequest('employee' + this.valueKey, id, () => {
+                return this.getRemoteByIdFunc(id)
+            }).then(response => {
+                const data = response.data
+                this.cacheData[data[this.valueKey]] = data
+                this.setSelectorValue(data[this.valueKey])
+            }).catch(() => {
+            })
+        },
+        getRemoteByIdFunc (id) {
+            return new Promise((resolve, reject) => {
+                if (this.valueKey === 'id') {
+                    get({
+                        employeeId: id
+                    }).then(response => {
+                        resolve(response)
+                    }).catch((error) => {
+                        reject(error)
+                    })
+                } else if (this.valueKey === 'account') {
+                    getByAccount({
+                        'account': id
+                    }).then(response => {
+                        resolve(response)
+                    }).catch((error) => {
+                        reject(error)
+                    })
+                }
+            })
+        },
+        // ===================事件处理=========
 
-    handleSelectorClick() {
-      this.selectorVisible = true
-      this.initData()
-    },
-    handleSelectorRemove(index) {
-      if (this.multiple) {
-        this.selectorValue.splice(index, 1)
-      } else {
-        this.selectorValue = {}
-      }
-      this.handleInput()
-    },
+        handleSelectorClick () {
+            this.selectorVisible = true
+            this.initData()
+        },
+        handleSelectorRemove (index) {
+            if (this.multiple) {
+                this.selectorValue.splice(index, 1)
+            } else {
+                this.selectorValue = {}
+            }
+            this.handleInput()
+        },
 
-    handleSelectorActionEvent(buttonKey, data) {
-      switch (buttonKey) {
-        case 'confirm':// 确定
-          this.selectorVisible = false
-          this.selectorValue = data
-          this.setCacheData() // 设置缓存数据
-          this.handleInput()
-          break
-      }
-    },
-    handleInput() {
-      this.$emit('input', this.getValue())
-      // 提供一个返回实体,提供调用
-      this.$emit('callback', this.selectorValue)
-    }
+        handleSelectorActionEvent (buttonKey, data) {
+            switch (buttonKey) {
+                case 'confirm':// 确定
+                    this.selectorVisible = false
+                    this.selectorValue = data
+                    this.setCacheData() // 设置缓存数据
+                    this.handleInput()
+                    break
+            }
+        },
+        handleInput () {
+            this.$emit('input', this.getValue())
+            // 提供一个返回实体,提供调用
+            this.$emit('callback', this.selectorValue)
+        }
 
-  }
+    }
 }
 </script>

+ 132 - 127
src/business/platform/org/position/dialog.vue

@@ -1,137 +1,142 @@
 <template>
-  <ibps-selector-dialog
-    :value="selectedValue"
-    :visible="selectorVisible"
-    v-bind="$props"
-    @input="value => selectedValue = value"
-    @remove-select="removeSelect"
-    @close="handleClose"
-    @action-event="handleActionEvent"
-  >
-    <template slot-scope="scope">
-      <ibps-selector-panel
-        ref="panel"
-        v-bind="scope"
-        :party-type-id="partyTypeId"
-        :current-org-id="currentOrgId"
-        :script="script"
-        :is-use-scope="isUseScope"
-        :party-type="partyType"
-        @selected="value => selectedValue = value"
-      />
-    </template>
-  </ibps-selector-dialog>
+    <ibps-selector-dialog
+        :value="selectedValue"
+        :visible="selectorVisible"
+        v-bind="$props"
+        @input="value => selectedValue = value"
+        @remove-select="removeSelect"
+        @close="handleClose"
+        @action-event="handleActionEvent"
+    >
+        <template slot-scope="scope">
+            <ibps-selector-panel
+                ref="panel"
+                v-bind="scope"
+                :party-type-id="partyTypeId"
+                :current-org-id="currentOrgId"
+                :script="script"
+                :is-use-scope="isUseScope"
+                :party-type="partyType"
+                :filtrate="filtrate"
+                @selected="value => selectedValue = value"
+            />
+        </template>
+    </ibps-selector-dialog>
 </template>
 <script>
 import IbpsSelectorDialog from '@/components/ibps-selector/dialog'
 import IbpsSelectorPanel from './panel'
 
 export default {
-  components: {
-    IbpsSelectorDialog,
-    IbpsSelectorPanel
-  },
-  props: {
-    visible: Boolean, // 是否可见
-    script: String,
-    isUseScope: { // 是否启用范围
-      type: Boolean,
-      default: false
-    },
-    partyTypeId: [String, Number],
-    currentOrgId: [String, Number],
-    title: { // 标题
-      type: String,
-      default: '岗位选择器'
-    },
-    marginTop: { // Dialog CSS 中的 margin-top 值
-      type: String,
-      default: '5vh'
-    },
-    width: { // 宽
-      type: String,
-      default: '40%'
-    },
-    height: { // 高
-      type: String,
-      default: '415px'
-    },
-    closeOnClickModal: { // 是否可以通过点击 modal 关闭 Dialog
-      type: Boolean,
-      default: false
-    },
-    closeOnPressEscape: { // 是否可以通过按下 ESC 关闭 Dialog
-      type: Boolean,
-      default: false
-    },
-    showClose: { // 是否显示关闭按钮
-      type: Boolean,
-      default: true
-    },
-    beforeClose: { // 关闭前的回调,会暂停 Dialog 的关闭
-      type: Function
-    },
-    fullscreen: { // 是否为全屏 Dialog
-      type: Boolean,
-      default: false
-    },
-    labelKey: { // 展示的值
-      type: String,
-      default: 'name'
-    },
-    value: { // value
-      type: [Object, Array],
-      default() { return this.multiple ? [] : {} }
-    },
-    cleanClose: { // 按钮清空并关闭
-      type: Boolean,
-      default: false
-    },
-    buttons: { // 按钮组
-      type: Array
-    },
-    confirmButtonText: {
-      type: String,
-      default: '选择'
-    },
-    cleanButtonText: String,
-    cancelButtonText: String,
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
-    },
-    partyType: String
-  },
-  data() {
-    return {
-      selectorVisible: false,
-      selectedValue: this.multiple ? [] : {}
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.selectorVisible = this.visible
-      },
-      immediate: true
-    },
-    value() {
-      this.selectedValue = this.value
-    }
-  },
-  methods: {
-    removeSelect(arr) {
-      this.$refs['panel'].setChecked(arr, false)
-    },
-    handleClose(visible) {
-      this.$emit('close', visible)
-    },
-    handleActionEvent(key, data) {
-      this.$emit('action-event', key, data)
-      if (key === 'clean') {
-        this.$refs['panel'].cleanData(this.multiple)
-      }
+    components: {
+        IbpsSelectorDialog,
+        IbpsSelectorPanel
+    },
+    props: {
+        visible: Boolean, // 是否可见
+        script: String,
+        isUseScope: { // 是否启用范围
+            type: Boolean,
+            default: false
+        },
+        partyTypeId: [String, Number],
+        currentOrgId: [String, Number],
+        title: { // 标题
+            type: String,
+            default: '岗位选择器'
+        },
+        marginTop: { // Dialog CSS 中的 margin-top 值
+            type: String,
+            default: '5vh'
+        },
+        width: { // 宽
+            type: String,
+            default: '40%'
+        },
+        height: { // 高
+            type: String,
+            default: '415px'
+        },
+        closeOnClickModal: { // 是否可以通过点击 modal 关闭 Dialog
+            type: Boolean,
+            default: false
+        },
+        closeOnPressEscape: { // 是否可以通过按下 ESC 关闭 Dialog
+            type: Boolean,
+            default: false
+        },
+        showClose: { // 是否显示关闭按钮
+            type: Boolean,
+            default: true
+        },
+        beforeClose: { // 关闭前的回调,会暂停 Dialog 的关闭
+            type: Function
+        },
+        fullscreen: { // 是否为全屏 Dialog
+            type: Boolean,
+            default: false
+        },
+        labelKey: { // 展示的值
+            type: String,
+            default: 'name'
+        },
+        value: { // value
+            type: [Object, Array],
+            default () { return this.multiple ? [] : {} }
+        },
+        cleanClose: { // 按钮清空并关闭
+            type: Boolean,
+            default: false
+        },
+        buttons: { // 按钮组
+            type: Array
+        },
+        confirmButtonText: {
+            type: String,
+            default: '选择'
+        },
+        cleanButtonText: String,
+        cancelButtonText: String,
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        filtrate: {
+            type: Boolean,
+            default: false
+        },
+        partyType: String
+    },
+    data () {
+        return {
+            selectorVisible: false,
+            selectedValue: this.multiple ? [] : {}
+        }
+    },
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.selectorVisible = this.visible
+            },
+            immediate: true
+        },
+        value () {
+            this.selectedValue = this.value
+        }
+    },
+    methods: {
+        removeSelect (arr) {
+            this.$refs['panel'].setChecked(arr, false)
+        },
+        handleClose (visible) {
+            this.$emit('close', visible)
+        },
+        handleActionEvent (key, data) {
+            this.$emit('action-event', key, data)
+            if (key === 'clean') {
+                this.$refs['panel'].cleanData(this.multiple)
+            }
+        }
     }
-  }
 }
 </script>

+ 362 - 351
src/business/platform/org/position/panel.vue

@@ -1,13 +1,9 @@
 <template>
-  <div>
-    <div v-if="toolbars" ref="toolbar" class="ibps-tree-toolbar">
-      <ibps-toolbar
-        :actions="toolbars"
-        type="icon"
-        @action-event="handleTreeAction"
-      />
-    </div>
-    <!-- <div ref="searchForm" class="ibps-tree-search-form">
+    <div>
+        <div v-if="toolbars" ref="toolbar" class="ibps-tree-toolbar">
+            <ibps-toolbar :actions="toolbars" type="icon" @action-event="handleTreeAction" />
+        </div>
+        <!-- <div ref="searchForm" class="ibps-tree-search-form">
       <el-row style="padding-right:12px;" :gutter="5">
         <el-col :span="21">
           <el-input v-model="filterText" placeholder="请输入岗位名称" clearable />
@@ -17,76 +13,58 @@
         </el-col>
       </el-row>
     </div> -->
-    <div
-      :style="{ height:(tableHeight)+'px'}"
-    >
-      <el-scrollbar
-        style="height: 100%;"
-        wrap-class="ibps-tree-wrapper ibps-scrollbar-wrapper"
-      >
-        <!-- 多选-->
-        <el-tree
-          v-if="multiple"
-          ref="elTree"
-          v-loading="loading"
-          :data="treeData"
-          :expand-on-click-node="false"
-          :props="{ children: 'children', label: 'name',isLeaf: 'leaf'}"
-          :load="loadTreeNode"
-          :lazy="lazyTree"
-          :show-checkbox="multiple"
-          :check-strictly="true"
-          :filter-node-method="filterNode"
-          node-key="id"
-          pid-key="parentId"
-          :default-expanded-keys="defaultExpandedKeys"
-          :default-expand-all="defaultExpandAll"
-          highlight-current
-          check-on-click-node
-          @check-change="handleCheckChange"
-        />
-        <!-- 单选-->
-        <el-tree
-          v-else
-          ref="elTree"
-          v-loading="loading"
-          :data="treeData"
-          :expand-on-click-node="false"
-          :props="{ children: 'children', label: 'name',isLeaf: 'leaf'}"
-          :load="loadTreeNode"
-          :lazy="lazyTree"
-          node-key="id"
-          pid-key="parentId"
-          :default-expanded-keys="defaultExpandedKeys"
-          :default-expand-all="defaultExpandAll"
-          highlight-current
-          :show-checkbox="multiple"
-          @node-click="onNodeClick"
-        >
-          <span slot-scope="{ node, data }" class="custom-tree-node">
-            <el-radio
-              v-model="radio"
-              :label="data[pkKey]"
-              :disabled="data.disabled"
-              @change="changeRadio(data)"
-            >{{ node.label }}</el-radio>
-          </span>
-        </el-tree>
-      </el-scrollbar>
+        <div :style="{ height: tableHeight + 'px' }">
+            <el-scrollbar style="height: 100%" wrap-class="ibps-tree-wrapper ibps-scrollbar-wrapper">
+                <!-- 多选-->
+                <el-tree
+                    v-if="multiple"
+                    ref="elTree"
+                    v-loading="loading"
+                    :data="treeData"
+                    :expand-on-click-node="false"
+                    :props="{ children: 'children', label: 'name', isLeaf: 'leaf' }"
+                    :load="loadTreeNode"
+                    :lazy="lazyTree"
+                    :show-checkbox="multiple"
+                    :check-strictly="true"
+                    :filter-node-method="filterNode"
+                    node-key="id"
+                    pid-key="parentId"
+                    :default-expanded-keys="defaultExpandedKeys"
+                    :default-expand-all="defaultExpandAll"
+                    highlight-current
+                    check-on-click-node
+                    @check-change="handleCheckChange"
+                />
+                <!-- 单选-->
+                <el-tree
+                    v-else
+                    ref="elTree"
+                    v-loading="loading"
+                    :data="treeData"
+                    :expand-on-click-node="false"
+                    :props="{ children: 'children', label: 'name', isLeaf: 'leaf' }"
+                    :load="loadTreeNode"
+                    :lazy="lazyTree"
+                    node-key="id"
+                    pid-key="parentId"
+                    :default-expanded-keys="defaultExpandedKeys"
+                    :default-expand-all="defaultExpandAll"
+                    highlight-current
+                    :show-checkbox="multiple"
+                    @node-click="onNodeClick"
+                >
+                    <span slot-scope="{ node, data }" class="custom-tree-node">
+                        <el-radio v-model="radio" :label="data[pkKey]" :disabled="data.disabled" @change="changeRadio(data)">{{ node.label }}</el-radio>
+                    </span>
+                </el-tree>
+            </el-scrollbar>
+        </div>
+        <more-search ref="moreSearch" :title="title" :visible="dialogFormVisible" :party-type="partyType" @callback="search" @close="(visible) => (dialogFormVisible = visible)" @action-event="handleMoreSearchAction" />
     </div>
-    <more-search
-      ref="moreSearch"
-      :title="title"
-      :visible="dialogFormVisible"
-      :party-type="partyType"
-      @callback="search"
-      @close="visible => dialogFormVisible = visible"
-      @action-event="handleMoreSearchAction"
-    />
-  </div>
 </template>
 <script>
-import { getScriptValue } from '@/api/platform/form/formDef'// 脚本
+import { getScriptValue } from '@/api/platform/form/formDef' // 脚本
 import { findTreeData as getTreeData } from '@/api/platform/org/position'
 // import { findTreeData as getPositionTreeData } from '@/api/platform/org/entity'
 
@@ -94,283 +72,316 @@ import MoreSearch from './more-search'
 import TreeUtils from '@/utils/tree'
 
 export default {
-  components: {
-    MoreSearch
-  },
-  props: {
-    value: [Object, Array],
-    multiple: Boolean,
-    height: {
-      type: String,
-      default: '400px'
-    },
-    partyTypeId: { // 类型节点ID
-      type: [String, Number],
-      default: ''
-    },
-    currentOrgId: { // 用户组ID
-      type: [String, Number],
-      default: ''
+    components: {
+        MoreSearch
     },
-    script: String,
-    isUseScope: { // 是否启用范围
-      type: Boolean,
-      default: false
+    props: {
+        value: [Object, Array],
+        multiple: Boolean,
+        height: {
+            type: String,
+            default: '400px'
+        },
+        partyTypeId: {
+            // 类型节点ID
+            type: [String, Number],
+            default: ''
+        },
+        currentOrgId: {
+            // 用户组ID
+            type: [String, Number],
+            default: ''
+        },
+        script: String,
+        isUseScope: {
+            // 是否启用范围
+            type: Boolean,
+            default: false
+        },
+        partyType: {
+            // 类型节点ID
+            type: String,
+            default: 'position'
+        },
+        filtrate: {
+            type: Boolean,
+            default: false
+        }
     },
-    partyType: { // 类型节点ID
-      type: String,
-      default: 'position'
-    }
-  },
-  data() {
-    return {
-      parentId: '0',
-      defaultExpandAll: false,
-      lazyTree: true,
-      defaultExpandedKeys: ['0'],
-      moreSearchParams: {},
-
-      radio: '',
-      pkKey: 'id', // 主键  如果主键不是pk需要传主键
-      loading: false,
-      dialogFormVisible: false,
-      filterText: '',
-      title: '更多查询',
-      // 树配置
-      treeData: [],
-      toolbars: [{
-        key: 'refresh'
-      }, {
-        key: 'expand'
-      }, {
-        key: 'compress'
-      }]
+    data () {
+        return {
+            parentId: '0',
+            defaultExpandAll: false,
+            lazyTree: true,
+            defaultExpandedKeys: ['0'],
+            moreSearchParams: {},
 
-    }
-  },
-  computed: {
-    tableHeight() {
-      const h = this.height.substr(0, this.height.length - 2)
-      return parseInt(h) - 10
-    }
-  },
-  watch: {
-    filterText(val) {
-      this.$refs.elTree.filter(val)
-    }
-  },
-  methods: {
-    setChecked(data, selected) {
-      if (data !== undefined) {
-        this.$refs['elTree'].setChecked(data, selected)
-      } else {
-        this.radio = ''
-      }
-    },
-    cleanData(multiple) {
-      if (multiple) {
-        this.$refs['elTree'].setCheckedKeys([])
-      } else {
-        this.radio = ''
-      }
-    },
-    // 加载岗位树
-    loadTreeNode(node, resolve) {
-      this.loading = true
-      let params = {}
-      const type = this.partyTypeId !== '' ? this.partyTypeId : '1'
-      if (this.isUseScope) {
-        params.type = type
-        params.includeSub = type === '1'
-        if (type === '2') {
-          params.partyId = node.level === 0 ? null : node.data.id
-        }
-        if (type === '3') {
-          params.partyId = this.currentOrgId
+            radio: '',
+            pkKey: 'id', // 主键  如果主键不是pk需要传主键
+            loading: false,
+            dialogFormVisible: false,
+            filterText: '',
+            title: '更多查询',
+            // 树配置
+            treeData: [],
+            toolbars: [
+                {
+                    key: 'refresh'
+                },
+                {
+                    key: 'expand'
+                },
+                {
+                    key: 'compress'
+                }
+            ]
         }
-        if (type === '1') {
-          params.posId = node.level === 0 ? null : node.data.id
+    },
+    computed: {
+        tableHeight () {
+            const h = this.height.substr(0, this.height.length - 2)
+            return parseInt(h) - 10
         }
-        // TODO: 用户选择器的岗位懒加载,待岗位选择器处理完整后统一处理。2类型有问题!
-        //  脚本类型初始化
-        if (type === 'script') {
-          this.getScriptData(this.script)
-          this.loading = false
-          return
+    },
+    watch: {
+        filterText (val) {
+            this.$refs.elTree.filter(val)
         }
-      } else {
-        params.type = '1'
-        params.posId = node.level === 0 ? null : node.data.id
-      }
-      if (this.moreSearchParams) {
-        Object.assign(params, this.moreSearchParams)
-      }
-      if (this.$utils.isEmpty(node.data) || node.data.id === '0') {
-        getTreeData(params).then(res => {
-          this.loading = false
-          const arr = JSON.parse(JSON.stringify(res.data))
-          //岗位数改成部门树
-          // 岗位数改成部门树
-          let arrOne = []
-          let arrTwo = []
-          arr.forEach((item) => {
-            if (item.name === '岗位树') {
-                item.name = '部门树'
-                arrOne[0] = item
+    },
+    methods: {
+        setChecked (data, selected) {
+            if (data !== undefined) {
+                this.$refs['elTree'].setChecked(data, selected)
             } else {
-                 arrTwo.push(item)
+                this.radio = ''
             }
-           })
-           let treeData
-           if (type === '2' || type === '3') {
-              arrTwo.forEach((item) => {
-                item.leaf = true
-              })
-              this.treeData = arrTwo
-           } else {
-               if (this.$utils.isEmpty(node.data)) {
-                   treeData = arr
-                   resolve(this.toTree(treeData))
-               } else {
-                   treeData = type === '1' ? arr : this.filterTreeChildren(arr, 'root')
-                   resolve(this.toTree(treeData))
-               }
-           }
-        }).catch(res => {
-          this.loading = false
-          resolve([])
-        })
-      } else if (node.data.id !== '0') {
-        if (type === '2') {
-          params = {}
-          params.type = '1'
-          params.posId = node.data.id
-        }
-        getTreeData(params).then(res => {
-          this.loading = false
-          const arr = JSON.parse(JSON.stringify(res.data))
-          resolve(this.toTree(arr))
-        }).catch(res => {
-          this.loading = false
-          resolve([])
-        })
-      }
-    },
-    toTree(data) {
-      return TreeUtils.transformToTreeFormat(data, {
-        idKey: 'id',
-        pIdKey: 'parentId',
-        childrenKey: 'children'
-      })
-    },
-    // 根据渲染的数据范围类型,筛选目标节点
-    filterTreeChildren(treeData, treeScope, nodeId) {
-      const data = []
-      // 返回设置的范围节点
-      if (treeScope === 'root') {
-        const currentOrgIds = this.currentOrgId.split(',')
-        treeData.forEach(f => {
-          if (currentOrgIds.includes(f.id)) {
-            f.leaf = true
-            data.push(f)
-          }
-        })
-      }
-      return data
-    },
-    // 脚本函数
-    getScriptData(scriptValue) {
-      getScriptValue({
-        script: scriptValue,
-        vars: ''
-      }).then(response => {
-        const data = JSON.parse(response.data)
-        this.treeData = TreeUtils.transformToTreeFormat(data.data)
-      })
-    },
-    filterNode(value, data) {
-      if (!value) return true
-      return data.name.indexOf(value) !== -1
-    },
+        },
+        cleanData (multiple) {
+            if (multiple) {
+                this.$refs['elTree'].setCheckedKeys([])
+            } else {
+                this.radio = ''
+            }
+        },
+        // 加载岗位树
+        loadTreeNode (node, resolve) {
+            this.loading = true
+            let params = {}
+            const type = this.partyTypeId !== '' ? this.partyTypeId : '1'
+            if (this.isUseScope) {
+                params.type = type
+                params.includeSub = type === '1'
+                if (type === '2') {
+                    params.partyId = node.level === 0 ? null : node.data.id
+                }
+                if (type === '3') {
+                    params.partyId = this.currentOrgId
+                }
+                if (type === '1') {
+                    params.posId = node.level === 0 ? null : node.data.id
+                }
+                // TODO: 用户选择器的岗位懒加载,待岗位选择器处理完整后统一处理。2类型有问题!
+                //  脚本类型初始化
+                if (type === 'script') {
+                    this.getScriptData(this.script)
+                    this.loading = false
+                    return
+                }
+            } else {
+                params.type = '1'
+                params.posId = node.level === 0 ? null : node.data.id
+            }
+            if (this.moreSearchParams) {
+                Object.assign(params, this.moreSearchParams)
+            }
+            if (this.$utils.isEmpty(node.data) || node.data.id === '0') {
+                getTreeData(params)
+                    .then((res) => {
+                        this.loading = false
+                        const arr = JSON.parse(JSON.stringify(res.data))
+                        // 岗位数改成部门树
+                        // 岗位数改成部门树
+                        const arrOne = []
+                        const arrTwo = []
+                        arr.forEach((item) => {
+                            if (item.name === '岗位树') {
+                                item.name = '部门树'
+                                arrOne[0] = item
+                            } else {
+                                arrTwo.push(item)
+                            }
+                        })
+                        let treeData
+                        if (type === '2' || type === '3') {
+                            arrTwo.forEach((item) => {
+                                item.leaf = true
+                            })
+                            this.treeData = arrTwo
+                        } else {
+                            let arrList
+                            const frist = this.$store.getters.level.first || ''
+                            if (type === '1' && this.filtrate && frist) {
+                                const showBoo = arr.some((item) => item.id === frist)
+                                console.log(this.filtrate, showBoo)
+                                if (showBoo) {
+                                    arrList = arr.filter((item) => item.id === frist)
+                                } else {
+                                    arrList = arr
+                                }
+                            } else {
+                                arrList = arr
+                            }
 
-    /**
-     * 处理更多查询弹窗
-     */
-    handleMoreSearch() {
-      this.dialogFormVisible = true
-    },
-    /**
-     * 更多查询
-     */
-    handleMoreSearchAction(data) {
-      this.loading = true
-      this.moreSearchParams = data
-      getTreeData(data).then(response => {
-        const data = response.data
-        this.treeData = TreeUtils.transformToTreeFormat(data)
-        this.loading = false
-      }).catch(() => {
-        this.loading = false
-      })
-    },
-    /**
-     * 查询
-     */
-    search() {
-      const node = this.$refs.elTree.getNode(this.parentId) // 通过节点id找到对应树节点对象
-      node.loaded = false
-      node.expand()
-    },
-    refreshTree() {
-      this.parentId = '0'
-      this.search()
-    },
-    /**
-     * 重置查询条件
-     */
-    reset() {
-      this.$refs['crud'].handleReset()
-    },
-    handleTreeAction(action, position, selection, data) {
-      const command = action.key
-      if (position === 'toolbar' && command === 'refresh') {
-        this.refreshTree()
-      }
-      if (command === 'expand') {
-        this.expandCompressTree(true)
-      } else if (command === 'compress') {
-        this.expandCompressTree(false)
-      }
-    },
-    expandCompressTree(expanded) {
-      for (let i = 0; i < this.$refs.elTree.store._getAllNodes().length; i++) {
-        this.$refs.elTree.store._getAllNodes()[i].expanded = expanded
-      }
-    },
-    handleCheckChange(data, checked) {
-      if (data.id === 0 || data.id === '0') return
-      let val = JSON.parse(JSON.stringify(this.value))
-      if (checked) {
-        const index = val.find((v) => {
-          return v[this.pkKey] === data[this.pkKey]
-        })
-        if (!index) { val.push(data) }
-      } else {
-        val = val.filter((v) => {
-          return v[this.pkKey] !== data[this.pkKey]
-        })
-      }
-      this.$emit('selected', val)
-    },
-    changeRadio(data) {
-      if (data.id === 0 || data.id === '0') return
-      this.$emit('selected', data)
-    },
-    onNodeClick(data, node, obj) {
-      this.radio = data[this.pkKey]
-      this.$emit('selected', data)
+                            if (this.$utils.isEmpty(node.data)) {
+                                treeData = arrList
+                                resolve(this.toTree(treeData))
+                            } else {
+                                treeData = type === '1' ? arrList : this.filterTreeChildren(arrList, 'root')
+                                resolve(this.toTree(treeData))
+                            }
+                        }
+                    })
+                    .catch((res) => {
+                        this.loading = false
+                        resolve([])
+                    })
+            } else if (node.data.id !== '0') {
+                if (type === '2') {
+                    params = {}
+                    params.type = '1'
+                    params.posId = node.data.id
+                }
+                getTreeData(params)
+                    .then((res) => {
+                        this.loading = false
+                        const arr = JSON.parse(JSON.stringify(res.data))
+                        resolve(this.toTree(arr))
+                    })
+                    .catch((res) => {
+                        this.loading = false
+                        resolve([])
+                    })
+            }
+        },
+        toTree (data) {
+            return TreeUtils.transformToTreeFormat(data, {
+                idKey: 'id',
+                pIdKey: 'parentId',
+                childrenKey: 'children'
+            })
+        },
+        // 根据渲染的数据范围类型,筛选目标节点
+        filterTreeChildren (treeData, treeScope, nodeId) {
+            const data = []
+            // 返回设置的范围节点
+            if (treeScope === 'root') {
+                const currentOrgIds = this.currentOrgId.split(',')
+                treeData.forEach((f) => {
+                    if (currentOrgIds.includes(f.id)) {
+                        f.leaf = true
+                        data.push(f)
+                    }
+                })
+            }
+            return data
+        },
+        // 脚本函数
+        getScriptData (scriptValue) {
+            getScriptValue({
+                script: scriptValue,
+                vars: ''
+            }).then((response) => {
+                const data = JSON.parse(response.data)
+                this.treeData = TreeUtils.transformToTreeFormat(data.data)
+            })
+        },
+        filterNode (value, data) {
+            if (!value) return true
+            return data.name.indexOf(value) !== -1
+        },
+
+        /**
+         * 处理更多查询弹窗
+         */
+        handleMoreSearch () {
+            this.dialogFormVisible = true
+        },
+        /**
+         * 更多查询
+         */
+        handleMoreSearchAction (data) {
+            this.loading = true
+            this.moreSearchParams = data
+            getTreeData(data)
+                .then((response) => {
+                    const data = response.data
+                    this.treeData = TreeUtils.transformToTreeFormat(data)
+                    this.loading = false
+                })
+                .catch(() => {
+                    this.loading = false
+                })
+        },
+        /**
+         * 查询
+         */
+        search () {
+            const node = this.$refs.elTree.getNode(this.parentId) // 通过节点id找到对应树节点对象
+            node.loaded = false
+            node.expand()
+        },
+        refreshTree () {
+            this.parentId = '0'
+            this.search()
+        },
+        /**
+         * 重置查询条件
+         */
+        reset () {
+            this.$refs['crud'].handleReset()
+        },
+        handleTreeAction (action, position, selection, data) {
+            const command = action.key
+            if (position === 'toolbar' && command === 'refresh') {
+                this.refreshTree()
+            }
+            if (command === 'expand') {
+                this.expandCompressTree(true)
+            } else if (command === 'compress') {
+                this.expandCompressTree(false)
+            }
+        },
+        expandCompressTree (expanded) {
+            for (let i = 0; i < this.$refs.elTree.store._getAllNodes().length; i++) {
+                this.$refs.elTree.store._getAllNodes()[i].expanded = expanded
+            }
+        },
+        handleCheckChange (data, checked) {
+            if (data.id === 0 || data.id === '0') return
+            let val = JSON.parse(JSON.stringify(this.value))
+            if (checked) {
+                const index = val.find((v) => {
+                    return v[this.pkKey] === data[this.pkKey]
+                })
+                if (!index) {
+                    val.push(data)
+                }
+            } else {
+                val = val.filter((v) => {
+                    return v[this.pkKey] !== data[this.pkKey]
+                })
+            }
+            this.$emit('selected', val)
+        },
+        changeRadio (data) {
+            if (data.id === 0 || data.id === '0') return
+            this.$emit('selected', data)
+        },
+        onNodeClick (data, node, obj) {
+            this.radio = data[this.pkKey]
+            this.$emit('selected', data)
+        }
     }
-  }
 }
 </script>
 <style lang="scss" scoped>
@@ -379,19 +390,19 @@ $border-color: #e5e6e7;
     border: 1px solid $border-color;
     height: 30px;
     padding: 5px;
-  }
-  .ibps-tree-search-form {
+}
+.ibps-tree-search-form {
     padding: 5px;
     border-right: 1px solid $border-color;
     background: #ffffff;
-  }
-  .ibps-tree-main {
+}
+.ibps-tree-main {
     border: 1px solid $border-color;
-  }
-  .ibps-tree-wrapper {
+}
+.ibps-tree-wrapper {
     background: #ffffff;
     .el-tree > .el-tree-node {
-      display: inline-block;
+        display: inline-block;
     }
-  }
+}
 </style>

+ 269 - 264
src/business/platform/org/position/selector.vue

@@ -1,20 +1,21 @@
 <template>
-  <div>
-    <ibps-selector
-      v-bind="$props"
-      :items="items"
-      @click="handleSelectorClick"
-      @remove="handleSelectorRemove"
-    />
-    <!-- 选择器 -->
-    <ibps-position-selector-dialog
-      :visible="selectorVisible"
-      :value="selectorValue"
-      :multiple="multiple"
-      @close="visible => selectorVisible = visible"
-      @action-event="handleSelectorActionEvent"
-    />
-  </div>
+    <div>
+        <ibps-selector
+            v-bind="$props"
+            :items="items"
+            @click="handleSelectorClick"
+            @remove="handleSelectorRemove"
+        />
+        <!-- 选择器 -->
+        <ibps-position-selector-dialog
+            :visible="selectorVisible"
+            :value="selectorValue"
+            :multiple="multiple"
+            :filtrate="filtrate"
+            @close="visible => selectorVisible = visible"
+            @action-event="handleSelectorActionEvent"
+        />
+    </div>
 </template>
 <script>
 import { get, getByAlias } from '@/api/platform/org/position'
@@ -24,272 +25,276 @@ import { remoteRequest } from '@/utils/remote'
 import IbpsSelector from '@/components/ibps-selector/selector'
 import IbpsPositionSelectorDialog from './dialog'
 export default {
-  components: {
-    IbpsSelector,
-    IbpsPositionSelectorDialog
-  },
-  inject: {
-    elForm: {
-      default: ''
+    components: {
+        IbpsSelector,
+        IbpsPositionSelectorDialog
     },
-    elFormItem: {
-      default: ''
-    }
-  },
-  mixins: [emitter],
-  props: {
-    value: {
-      type: [String, Number, Array]
-    },
-    // 存储类型 :
-    // ①、id:只存储id 字符串,
-    // ②、json: json字符串,
-    // ③、 array:存储数组数据(完整数据,包含key和value)。
-    // ④、 bind:绑定ID,需要回调和返回
-    store: {
-      type: String,
-      default: 'id',
-      validator: function(value) {
-        return ['id', 'json', 'array', 'arrayId', 'bind'].indexOf(value) !== -1
-      }
-    },
-    storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
-      type: String,
-      default: ','
-    },
-    placeholder: { // 输入框占位文本
-      type: String,
-      default: '请选择岗位'
+    inject: {
+        elForm: {
+            default: ''
+        },
+        elFormItem: {
+            default: ''
+        }
     },
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
+    mixins: [emitter],
+    props: {
+        value: {
+            type: [String, Number, Array]
+        },
+        // 存储类型 :
+        // ①、id:只存储id 字符串,
+        // ②、json: json字符串,
+        // ③、 array:存储数组数据(完整数据,包含key和value)。
+        // ④、 bind:绑定ID,需要回调和返回
+        store: {
+            type: String,
+            default: 'id',
+            validator: function (value) {
+                return ['id', 'json', 'array', 'arrayId', 'bind'].indexOf(value) !== -1
+            }
+        },
+        storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
+            type: String,
+            default: ','
+        },
+        placeholder: { // 输入框占位文本
+            type: String,
+            default: '请选择岗位'
+        },
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        filtrate: {
+            type: Boolean,
+            default: false
+        },
+        labelKey: { // 展示的值
+            type: String,
+            default: 'name'
+        },
+        valueKey: { // 存储唯一值
+            type: String,
+            default: 'id'
+        },
+        disabled: { // 禁用
+            type: Boolean,
+            default: false
+        }
     },
-    labelKey: { // 展示的值
-      type: String,
-      default: 'name'
+    data () {
+        return {
+            selectorVisible: false,
+            selectorValue: this.multiple ? [] : {},
+            cacheData: {},
+            bindIdValue: ''
+        }
     },
-    valueKey: { // 存储唯一值
-      type: String,
-      default: 'id'
+    computed: {
+        items () {
+            if (this.$utils.isEmpty(this.selectorValue)) return []
+            if (this.multiple) {
+                return this.selectorValue.map(data => {
+                    return data[this.labelKey]
+                })
+            } else {
+                return [this.selectorValue[this.labelKey]]
+            }
+        }
     },
-    disabled: { // 禁用
-      type: Boolean,
-      default: false
-    }
-  },
-  data() {
-    return {
-      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 data[this.labelKey]
-        })
-      } else {
-        return [this.selectorValue[this.labelKey]]
-      }
-    }
-  },
-  watch: {
-    value: {
-      handler(val, oldVal) {
-        this.initData()
-        if (!valueEquals(val, oldVal)) {
-          this.dispatch('ElFormItem', 'el.form.change', val)
+    watch: {
+        value: {
+            handler (val, oldVal) {
+                this.initData()
+                if (!valueEquals(val, oldVal)) {
+                    this.dispatch('ElFormItem', 'el.form.change', val)
+                }
+            },
+            immediate: true
         }
-      },
-      immediate: true
-    }
-  },
-  methods: {
+    },
+    methods: {
     /**
      * 初始化数据
      */
-    initData() {
-      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 {
-          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 () {
+            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 {
+                    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
-        try {
-          const data = this.$utils.parseData(value)
-          if (this.multiple) {
-            return data.map((d) => {
-              return d[this.valueKey]
-            })
-          } else {
-            return [data]
-          }
-        } catch (error) {
-          console.warn(error)
-          return []
-        }
-      } else if (this.store === 'id') { // id
-        return this.$utils.isString(value) ? 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]
-            o[this.labelKey] = v[this.labelKey]
-            res.push(o)
-          })
-          return JSON.stringify(res)
-        } else {
-          const o = {}
-          o[this.valueKey] = value[this.valueKey]
-          o[this.labelKey] = value[this.labelKey]
-          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)
+        getArrayValue (value, bindId) {
+            if (this.$utils.isEmpty(value)) {
+                return []
+            }
+            if (this.store === 'json') { // json
+                try {
+                    const data = this.$utils.parseData(value)
+                    if (this.multiple) {
+                        return data.map((d) => {
+                            return d[this.valueKey]
+                        })
+                    } else {
+                        return [data]
+                    }
+                } catch (error) {
+                    console.warn(error)
+                    return []
+                }
+            } else if (this.store === 'id') { // id
+                return this.$utils.isString(value) ? 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]
+                        o[this.labelKey] = v[this.labelKey]
+                        res.push(o)
+                    })
+                    return JSON.stringify(res)
+                } else {
+                    const o = {}
+                    o[this.valueKey] = value[this.valueKey]
+                    o[this.labelKey] = value[this.labelKey]
+                    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) {
-      remoteRequest('position' + this.valueKey, id, () => {
-        return this.getRemoteByIdFunc(id)
-      }).then(data => {
-        this.cacheData[data[this.valueKey]] = data
-        this.setSelectorValue(data[this.valueKey])
-      }).catch(() => {
-      })
-    },
-    getRemoteByIdFunc(id) {
-      return new Promise((resolve, reject) => {
-        if (this.valueKey === 'id') {
-          get({
-            positionId: id
-          }).then(response => {
-            resolve(response.data)
-          }).catch(() => {
-          })
-        } else if (this.valueKey === 'alias') {
-          getByAlias({
-            posAlias: id
-          }).then(response => {
-            const data = response.data
-            data[this.valueKey] = data['posAlias']
-            resolve(data)
-          }).catch(() => {
-          })
-        }
-      })
-    },
+        getDataInfo (id) {
+            remoteRequest('position' + this.valueKey, id, () => {
+                return this.getRemoteByIdFunc(id)
+            }).then(data => {
+                this.cacheData[data[this.valueKey]] = data
+                this.setSelectorValue(data[this.valueKey])
+            }).catch(() => {
+            })
+        },
+        getRemoteByIdFunc (id) {
+            return new Promise((resolve, reject) => {
+                if (this.valueKey === 'id') {
+                    get({
+                        positionId: id
+                    }).then(response => {
+                        resolve(response.data)
+                    }).catch(() => {
+                    })
+                } else if (this.valueKey === 'alias') {
+                    getByAlias({
+                        posAlias: id
+                    }).then(response => {
+                        const data = response.data
+                        data[this.valueKey] = data['posAlias']
+                        resolve(data)
+                    }).catch(() => {
+                    })
+                }
+            })
+        },
 
-    // ===================事件处理=========
+        // ===================事件处理=========
 
-    handleSelectorClick() {
-      this.selectorVisible = true
-      this.initData()
-    },
-    handleSelectorRemove(index) {
-      if (this.multiple) {
-        this.selectorValue.splice(index, 1)
-      } else {
-        this.selectorValue = {}
-      }
-      this.handleInput()
-    },
+        handleSelectorClick () {
+            this.selectorVisible = true
+            this.initData()
+        },
+        handleSelectorRemove (index) {
+            if (this.multiple) {
+                this.selectorValue.splice(index, 1)
+            } else {
+                this.selectorValue = {}
+            }
+            this.handleInput()
+        },
 
-    handleSelectorActionEvent(buttonKey, data) {
-      switch (buttonKey) {
-        case 'confirm':// 确定
-          this.selectorVisible = false
-          this.selectorValue = data
-          this.setCacheData() // 设置缓存数据
-          this.handleInput()
-          break
-      }
-    },
-    handleInput() {
-      this.$emit('input', this.getValue())
-      // 提供一个返回实体,提供调用
-      this.$emit('callback', this.selectorValue)
-    }
+        handleSelectorActionEvent (buttonKey, data) {
+            switch (buttonKey) {
+                case 'confirm':// 确定
+                    this.selectorVisible = false
+                    this.selectorValue = data
+                    this.setCacheData() // 设置缓存数据
+                    this.handleInput()
+                    break
+            }
+        },
+        handleInput () {
+            this.$emit('input', this.getValue())
+            // 提供一个返回实体,提供调用
+            this.$emit('callback', this.selectorValue)
+        }
 
-  }
+    }
 }
 </script>

+ 239 - 255
src/business/platform/org/selector/dialog.vue

@@ -1,61 +1,41 @@
 <template>
-  <div>
-    <!--用户选择器-->
-    <ibps-employee-selector-dialog
-      v-if="type === 'employee' || type === 'user'"
-      :visible="employeeSelectorVisible"
-      :value="selectorValue"
-      :multiple="multiple"
-      :custom-party-type-options="customPartyTypeOptions"
-      :current-org-id="currentOrgId"
-      :party-type-id="partyTypeId"
-      :script="script"
-      :party-type-scope="partyTypeScope"
-      :is-use-scope="true"
-      @close="closeDialog"
-      @change-party-type="changePartyType"
-      @action-event="handleSelectorActionEvent"
-    />
-    <!--组织选择器-->
-    <ibps-org-selector-dialog
-      v-else-if="type === 'org'"
-      :visible="orgSelectorVisible"
-      :current-org-id="currentOrgId"
-      :party-type-id="partyTypeId"
-      :script="script"
-      :is-use-scope="true"
-      :value="selectorValue"
-      :multiple="multiple"
-      @close="closeDialog"
-      @action-event="handleSelectorActionEvent"
-    />
-    <!--岗位选择器-->
-    <ibps-position-selector-dialog
-      v-else-if="type === 'position'"
-      :visible="positionSelectorVisible"
-      :current-org-id="currentOrgId"
-      :party-type-id="partyTypeId"
-      :script="script"
-      :is-use-scope="true"
-      :value="selectorValue"
-      :multiple="multiple"
-      @close="closeDialog"
-      @action-event="handleSelectorActionEvent"
-    />
-    <!--角色选择器-->
-    <ibps-role-selector-dialog
-      v-else-if="type === 'role'"
-      :visible="roleSelectorVisible"
-      :current-org-id="currentOrgId"
-      :party-type-id="partyTypeId"
-      :script="script"
-      :is-use-scope="true"
-      :value="selectorValue"
-      :multiple="multiple"
-      @close="closeDialog"
-      @action-event="handleSelectorActionEvent"
-    />
-  </div>
+    <div>
+        <!--用户选择器-->
+        <ibps-employee-selector-dialog
+            v-if="type === 'employee' || type === 'user'"
+            :visible="employeeSelectorVisible"
+            :value="selectorValue"
+            :multiple="multiple"
+            :filtrate="filtrate"
+            :custom-party-type-options="customPartyTypeOptions"
+            :current-org-id="currentOrgId"
+            :party-type-id="partyTypeId"
+            :script="script"
+            :party-type-scope="partyTypeScope"
+            :is-use-scope="true"
+            @close="closeDialog"
+            @change-party-type="changePartyType"
+            @action-event="handleSelectorActionEvent"
+        />
+        <!--组织选择器-->
+        <ibps-org-selector-dialog v-else-if="type === 'org'" :visible="orgSelectorVisible" :current-org-id="currentOrgId" :party-type-id="partyTypeId" :script="script" :is-use-scope="true" :value="selectorValue" :multiple="multiple" @close="closeDialog" @action-event="handleSelectorActionEvent" />
+        <!--岗位选择器-->
+        <ibps-position-selector-dialog
+            v-else-if="type === 'position'"
+            :visible="positionSelectorVisible"
+            :current-org-id="currentOrgId"
+            :party-type-id="partyTypeId"
+            :script="script"
+            :is-use-scope="true"
+            :value="selectorValue"
+            :multiple="multiple"
+            :filtrate="filtrate"
+            @close="closeDialog"
+            @action-event="handleSelectorActionEvent"
+        />
+        <!--角色选择器-->
+        <ibps-role-selector-dialog v-else-if="type === 'role'" :visible="roleSelectorVisible" :current-org-id="currentOrgId" :party-type-id="partyTypeId" :script="script" :is-use-scope="true" :value="selectorValue" :multiple="multiple" @close="closeDialog" @action-event="handleSelectorActionEvent" />
+    </div>
 </template>
 <script>
 import IbpsEmployeeSelectorDialog from '@/business/platform/org/employee/dialog'
@@ -65,214 +45,218 @@ import IbpsRoleSelectorDialog from '@/business/platform/org/role/dialog'
 import { partyTypeOptions } from '../employee/constants'
 
 export default {
-  components: {
-    IbpsEmployeeSelectorDialog,
-    IbpsOrgSelectorDialog,
-    IbpsPositionSelectorDialog,
-    IbpsRoleSelectorDialog
-  },
-  props: {
-    filter: {
-      type: Array,
-      default: () => []
+    components: {
+        IbpsEmployeeSelectorDialog,
+        IbpsOrgSelectorDialog,
+        IbpsPositionSelectorDialog,
+        IbpsRoleSelectorDialog
     },
-    visible: {
-      type: Boolean
-    },
-    type: {
-      type: String
-    },
-    value: {
-      type: [String, Number, Array, Object]
-    },
-    multiple: {
-      type: Boolean,
-      default: false
-    },
-    formData: Object
-  },
-  data() {
-    return {
-      employeeSelectorVisible: false,
-      orgSelectorVisible: false,
-      positionSelectorVisible: false,
-      roleSelectorVisible: false,
-      partyTypeOptions: partyTypeOptions,
-      customPartyTypeOptions: [],
-      // 用户选择器条件
-      condition: {
-        org: {
-          partyTypeId: '',
-          currentOrgId: '',
-          script: ''
+    props: {
+        filter: {
+            type: Array,
+            default: () => []
         },
-        position: {
-          partyTypeId: '',
-          currentOrgId: '',
-          script: ''
+        visible: {
+            type: Boolean
         },
-        role: {
-          partyTypeId: '',
-          currentOrgId: '',
-          script: ''
+        type: {
+            type: String
         },
-        group: {
-          partyTypeId: '',
-          currentOrgId: '',
-          script: ''
+        value: {
+            type: [String, Number, Array, Object]
+        },
+        multiple: {
+            type: Boolean,
+            default: false
+        },
+        formData: Object,
+        filtrate: {
+            type: Boolean,
+            default: false
         }
-      },
-      // 传递参数
-      partyTypeId: '',
-      currentOrgId: '',
-      script: '',
-      partyTypeScope: ''
-    }
-  },
-  computed: {
-    selectorValue() {
-      return this.value
-    }
-  },
-  watch: {
-    visible(value) {
-      this.dialogVisible(value)
-    },
-    filter: {
-      handler(val, oldVal) {
-        this.filterScope(val)
-      },
-      immediate: true,
-      deep: true
-    }
-  },
-  methods: {
-    dialogVisible(visible = false) {
-      this.filterScope(this.filter)
-      if (this.type === 'employee' || this.type === 'user') {
-        this.employeeSelectorVisible = visible
-      } else if (this.type === 'org') {
-        this.orgSelectorVisible = visible
-      } else if (this.type === 'position') {
-        this.positionSelectorVisible = visible
-      } else if (this.type === 'role') {
-        this.roleSelectorVisible = visible
-      }
-    },
-    closeDialog() {
-      this.$emit('close', false)
     },
-    handleSelectorActionEvent(buttonKey, data) {
-      this.$emit('action-event', buttonKey, data, this.type)
-    },
-    changePartyType(val) {
-      const params = this.condition[val]
-      this.partyTypeScope = val
-      this.partyTypeId = params.partyTypeId
-      this.currentOrgId = params.currentOrgId
-      this.script = params.script
-      // console.info(this.partyTypeId, this.currentOrgId, '==>>11')
-    },
-    filterScope(val) {
-      const existingTypeScope = []
-      const typeScope = []
-      // console.info(val)
-      val.forEach(v => {
-        existingTypeScope.push(v.userType)
-        this.filterSelectorType(v)
-      })
-      // 根据设置得范围类型切换选择器左树(或右树)下拉类型数据
-      const partyTypeOptions = JSON.parse(JSON.stringify(this.partyTypeOptions))
-      partyTypeOptions.forEach((f, i) => {
-        if (existingTypeScope.includes(f.value)) {
-          typeScope.push(f)
+    data () {
+        return {
+            employeeSelectorVisible: false,
+            orgSelectorVisible: false,
+            positionSelectorVisible: false,
+            roleSelectorVisible: false,
+            partyTypeOptions: partyTypeOptions,
+            customPartyTypeOptions: [],
+            // 用户选择器条件
+            condition: {
+                org: {
+                    partyTypeId: '',
+                    currentOrgId: '',
+                    script: ''
+                },
+                position: {
+                    partyTypeId: '',
+                    currentOrgId: '',
+                    script: ''
+                },
+                role: {
+                    partyTypeId: '',
+                    currentOrgId: '',
+                    script: ''
+                },
+                group: {
+                    partyTypeId: '',
+                    currentOrgId: '',
+                    script: ''
+                }
+            },
+            // 传递参数
+            partyTypeId: '',
+            currentOrgId: '',
+            script: '',
+            partyTypeScope: ''
         }
-      })
-      this.customPartyTypeOptions = typeScope
-      // 初始化查询范围条件
-      if (this.$utils.isNotEmpty(typeScope)) {
-        this.currentOrgId = this.condition[typeScope[0].value].currentOrgId
-        this.partyTypeId = this.condition[typeScope[0].value].partyTypeId
-        this.script = this.condition[typeScope[0].value].script
-      }
-    },
-    // 根据选择器类型分发筛选条件并储存
-    filterSelectorType(val) {
-      switch (val.type) {
-        case 'user':
-          this.getUserSelectorCondition(val, val.userType)
-          break
-        case 'org':
-          this.getOrgSelectorCondition(val)
-          break
-        case 'position':
-          this.getPositionSelectorCondition(val)
-          break
-        case 'role':
-          this.getRoleSelectorCondition(val)
-          break
-      }
     },
-    getUserSelectorCondition(val, type) {
-      this.condition[type] ? this.condition[type].partyTypeId = val.descVal : null
-      switch (val.descVal) {
-        case '1':
-          break
-        case '2':
-        case '3':
-          this.condition[type].currentOrgId = val.partyId
-          break
-        case 'script':
-          this.condition[type].script = val.scriptContent
-          break
-      }
-    },
-    // 获取组织选择器条件
-    getOrgSelectorCondition(val) {
-      this.partyTypeId = val.descVal
-      switch (val.descVal) {
-        case '1':
-          break
-        case '2':
-        case '3':
-          this.currentOrgId = val.partyId
-          break
-        case 'script':
-          this.script = val.scriptContent
-          break
-      }
+    computed: {
+        selectorValue () {
+            return this.value
+        }
     },
-    // 获取岗位选择器条件
-    getPositionSelectorCondition(val) {
-      this.partyTypeId = val.descVal
-      switch (val.descVal) {
-        case '1':
-          break
-        case '2':
-        case '3':
-          this.currentOrgId = val.partyId
-          break
-        case 'script':
-          this.script = val.scriptContent
-          break
-      }
+    watch: {
+        visible (value) {
+            this.dialogVisible(value)
+        },
+        filter: {
+            handler (val, oldVal) {
+                this.filterScope(val)
+            },
+            immediate: true,
+            deep: true
+        }
     },
-    // 获取角色选择器条件
-    getRoleSelectorCondition(val) {
-      // console.info(val, '=>>获取角色选择器条件')
-      this.partyTypeId = val.descVal
-      switch (val.descVal) {
-        case '1':
-          break
-        case '2':
-        case '3':
-          this.currentOrgId = val.partyId
-          break
-        case 'script':
-          this.script = val.scriptContent
-          break
-      }
+    methods: {
+        dialogVisible (visible = false) {
+            this.filterScope(this.filter)
+            if (this.type === 'employee' || this.type === 'user') {
+                this.employeeSelectorVisible = visible
+            } else if (this.type === 'org') {
+                this.orgSelectorVisible = visible
+            } else if (this.type === 'position') {
+                this.positionSelectorVisible = visible
+            } else if (this.type === 'role') {
+                this.roleSelectorVisible = visible
+            }
+        },
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        handleSelectorActionEvent (buttonKey, data) {
+            this.$emit('action-event', buttonKey, data, this.type)
+        },
+        changePartyType (val) {
+            const params = this.condition[val]
+            this.partyTypeScope = val
+            this.partyTypeId = params.partyTypeId
+            this.currentOrgId = params.currentOrgId
+            this.script = params.script
+            // console.info(this.partyTypeId, this.currentOrgId, '==>>11')
+        },
+        filterScope (val) {
+            const existingTypeScope = []
+            const typeScope = []
+            // console.info(val)
+            val.forEach((v) => {
+                existingTypeScope.push(v.userType)
+                this.filterSelectorType(v)
+            })
+            // 根据设置得范围类型切换选择器左树(或右树)下拉类型数据
+            const partyTypeOptions = JSON.parse(JSON.stringify(this.partyTypeOptions))
+            partyTypeOptions.forEach((f, i) => {
+                if (existingTypeScope.includes(f.value)) {
+                    typeScope.push(f)
+                }
+            })
+            this.customPartyTypeOptions = typeScope
+            // 初始化查询范围条件
+            if (this.$utils.isNotEmpty(typeScope)) {
+                this.currentOrgId = this.condition[typeScope[0].value].currentOrgId
+                this.partyTypeId = this.condition[typeScope[0].value].partyTypeId
+                this.script = this.condition[typeScope[0].value].script
+            }
+        },
+        // 根据选择器类型分发筛选条件并储存
+        filterSelectorType (val) {
+            switch (val.type) {
+                case 'user':
+                    this.getUserSelectorCondition(val, val.userType)
+                    break
+                case 'org':
+                    this.getOrgSelectorCondition(val)
+                    break
+                case 'position':
+                    this.getPositionSelectorCondition(val)
+                    break
+                case 'role':
+                    this.getRoleSelectorCondition(val)
+                    break
+            }
+        },
+        getUserSelectorCondition (val, type) {
+            this.condition[type] ? (this.condition[type].partyTypeId = val.descVal) : null
+            switch (val.descVal) {
+                case '1':
+                    break
+                case '2':
+                case '3':
+                    this.condition[type].currentOrgId = val.partyId
+                    break
+                case 'script':
+                    this.condition[type].script = val.scriptContent
+                    break
+            }
+        },
+        // 获取组织选择器条件
+        getOrgSelectorCondition (val) {
+            this.partyTypeId = val.descVal
+            switch (val.descVal) {
+                case '1':
+                    break
+                case '2':
+                case '3':
+                    this.currentOrgId = val.partyId
+                    break
+                case 'script':
+                    this.script = val.scriptContent
+                    break
+            }
+        },
+        // 获取岗位选择器条件
+        getPositionSelectorCondition (val) {
+            this.partyTypeId = val.descVal
+            switch (val.descVal) {
+                case '1':
+                    break
+                case '2':
+                case '3':
+                    this.currentOrgId = val.partyId
+                    break
+                case 'script':
+                    this.script = val.scriptContent
+                    break
+            }
+        },
+        // 获取角色选择器条件
+        getRoleSelectorCondition (val) {
+            // console.info(val, '=>>获取角色选择器条件')
+            this.partyTypeId = val.descVal
+            switch (val.descVal) {
+                case '1':
+                    break
+                case '2':
+                case '3':
+                    this.currentOrgId = val.partyId
+                    break
+                case 'script':
+                    this.script = val.scriptContent
+                    break
+            }
+        }
     }
-  }
 }
 </script>

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

@@ -20,6 +20,7 @@
             :value="selectorValue"
             :filter="filter"
             :multiple="multiple"
+            :filtrate="filtrate"
             @close="visible=>selectorVisible=visible"
             @action-event="handleSelectorActionEvent"
         />
@@ -81,6 +82,10 @@ export default {
             type: Boolean,
             default: false
         },
+        filtrate: {
+            type: Boolean,
+            default: false
+        },
         placeholder: { // 输入框占位文本
             type: String,
             default: '请选择'