Explorar el Código

部分功能代码审查,调整用户角色信息展示顺序

cfort hace 2 años
padre
commit
f9c2b6b053

+ 3 - 3
src/business/platform/form/constants/tableButtonTypes.js

@@ -6,10 +6,10 @@ const buttonTypes = {
         position: 'toolbar',
         scope: ['toolbar']
     },
-    'copyAdd': {
-        label: '复制添加',
+    'copy': {
+        label: '复制',
         style: 'primary',
-        icon: 'add',
+        icon: 'copy',
         position: 'toolbar',
         scope: ['toolbar']
     },

+ 104 - 407
src/business/platform/form/formrender/dynamic-form/dynamic-form-table.vue

@@ -2,22 +2,11 @@
     <div v-if="!tableHidden && dynamicShow" class="dynamic-form-table">
         <template v-if="columns && columns.length > 0">
             <!--================表内和弹窗模式=================================-->
-            <div
-                v-if="mode === 'inner' || mode === 'dialog'"
-                class="dynamic-form-table__inner panel panel-info"
-            >
+            <div v-if="mode === 'inner' || mode === 'dialog'" class="dynamic-form-table__inner panel panel-info">
                 <div class="panel-heading ibps-clearfix">
-                    <div
-                        v-if="!formDialogVisible"
-                        class="ibps-fl dynamic-form-table__label table-tetle-style"
-                    >
-                        {{ field.label }}
-                    </div>
+                    <div v-if="!formDialogVisible" class="ibps-fl dynamic-form-table__label table-tetle-style">{{ field.label }}</div>
                     <!--弹窗模式对话框-->
-                    <div
-                        v-if="toolbarButtons && toolbarButtons.length > 0"
-                        class="ibps-fr hidden-print"
-                    >
+                    <div v-if="toolbarButtons && toolbarButtons.length > 0" class="ibps-fr hidden-print">
                         <el-button-group>
                             <el-button
                                 v-for="(button, index) in toolbarButtons"
@@ -35,95 +24,40 @@
                     <el-table
                         ref="elTable"
                         :data="copDataModel"
-                        :header-cell-style="{
-                            color: '#000',
-                            'font-size': '14px',
-                            padding: '4px 0',
-                        }"
+                        :header-cell-style="{ color: '#000', 'font-size': '14px', padding: '4px 0' }"
                         :row-class-name="tableRowClassName"
                         :show-summary="showSummary"
                         :sum-text="sumText"
-                        :summary-method="
-                            hasSummaryMethod ? summaryMethod : null
-                        "
+                        :summary-method="hasSummaryMethod ? summaryMethod : null"
                         border
                         @selection-change="handleSelectionChange"
                     >
-                        <el-table-column
-                            v-if="!tableReadonly"
-                            type="selection"
-                            width="50"
-                        />
+                        <el-table-column v-if="!tableReadonly" type="selection" width="50" />
                         <el-table-column
                             v-if="field.field_options.index"
                             type="index"
-                            :label="
-                                field.field_options.index_name
-                                    ? field.field_options.index_name
-                                    : '序号'
-                            "
-                            :width="
-                                field.field_options.index_width
-                                    ? field.field_options.index_width
-                                    : 50
-                            "
+                            :label="field.field_options.index_name ? field.field_options.index_name : '序号'"
+                            :width="field.field_options.index_width ? field.field_options.index_width : 50"
                             :index="indexMethod"
                         />
                         <template v-for="(column, j) in displayColumns">
                             <el-table-column
-                                v-if="
-                                    !columnHidden(column) &&
-                                        column.field_type != 'desc' &&
-                                        column.label != ''
-                                "
+                                v-if="!columnHidden(column) && column.field_type != 'desc' && column.label != ''"
                                 :key="j"
                                 show-overflow-tooltip
                                 :prop="column.name"
-                                :width="
-                                    column.field_options.custom_class || null
-                                "
+                                :width="column.field_options.custom_class || null"
                             >
                                 <template slot="header">
-                                    {{
-                                        $utils.isNotEmpty(
-                                            column.field_options.units
-                                        )
-                                            ? column.label +
-                                                "(" +
-                                                column.field_options.units +
-                                                ")"
-                                            : column.label
-                                    }}
-                                    <ibps-help
-                                        v-if="
-                                            column &&
-                                                column.desc &&
-                                                descPosition === 'lableIcon'
-                                        "
-                                        type="tooltip"
-                                        :content="
-                                            $utils.formatText(column.desc)
-                                        "
-                                    />
+                                    {{ $utils.isNotEmpty(column.field_options.units) ? column.label + '(' + column.field_options.units + ')' : column.label }}
+                                    <ibps-help v-if="column && column.desc && descPosition === 'lableIcon'" type="tooltip" :content="$utils.formatText(column.desc)" />
                                 </template>
                                 <template slot-scope="scope">
-                                    <template
-                                        v-if="
-                                            copDataModelCont &&
-                                                copDataModelCont.length > 0 &&
-                                                dynamicShow
-                                        "
-                                    >
+                                    <template v-if="copDataModelCont && copDataModelCont.length > 0 && dynamicShow">
                                         <ibps-dynamic-form-table-item
                                             :ref="'formItem' + column.name"
                                             :key="scope.$index + j"
-                                            :models.sync="
-                                                copDataModelCont[
-                                                    scope.$index +
-                                                    (currentPage - 1) *
-                                                    pageSize
-                                                ]
-                                            "
+                                            :models.sync="copDataModelCont[scope.$index + (currentPage - 1) * pageSize]"
                                             :rights.sync="columnsRights"
                                             :form-data="models"
                                             :field="column"
@@ -146,70 +80,36 @@
                             fixed="right"
                             class-name="hidden-print"
                             label="操作栏目"
-                            :width="
-                                colWidth
-                                    ? colWidth
-                                    : manageButtons.length == 1
-                                        ? '85'
-                                        : '160'
-                            "
+                            :width="colWidth ? colWidth : (manageButtons.length == 1 ? '85' : '160')"
                         >
                             <template slot-scope="scope">
                                 <el-dropdown v-if="manageButtons.length > 3">
-                                    <ibps-icon
-                                        name="chevron-circle-down"
-                                        size="28"
-                                        class="hidden-print"
-                                    />
-                                    <el-dropdown-menu
-                                        slot="dropdown"
-                                        class="ibps-table-dropdown-menu"
-                                        style="margin-top: 0.02rem"
-                                    >
+                                    <ibps-icon name="chevron-circle-down" size="28" class="hidden-print" />
+                                    <el-dropdown-menu slot="dropdown" class="ibps-table-dropdown-menu" style="margin-top: 0.02rem">
                                         <ibps-toolbar
                                             :actions="manageButtons"
                                             :socpe="thatSocpe"
                                             :data="scope.row"
                                             position="manage"
                                             class="hidden-print"
-                                            @action-event="
-                                                (action) =>
-                                                    handleActionEvent(
-                                                        action,
-                                                        scope.$index
-                                                    )
-                                            "
+                                            @action-event="(action) => handleActionEvent(action, scope.$index)"
                                         />
                                     </el-dropdown-menu>
                                 </el-dropdown>
                                 <template v-else>
-                                    <template
-                                        v-for="(button, index) in manageButtons"
-                                    >
+                                    <template v-for="(button, index) in manageButtons">
                                         <el-link
                                             :key="index"
                                             :icon="button.icon"
                                             :type="button.type"
                                             :underline="false"
-                                            @click="
-                                                handleActionEvent(
-                                                    button,
-                                                    scope.$index
-                                                )
-                                            "
+                                            @click="handleActionEvent(button, scope.$index)"
                                         >{{ button.label }}</el-link>
                                         <!-- <el-button plain size="mini" :key="index" :type="button.type" @click="handleActionEvent(button, scope.$index)">
                                             {{ button.label }}
                                         </el-button> -->
                                         <!-- (manageButtons.length === 3 && index === 0) || index === 1 -->
-                                        <el-divider
-                                            v-if="
-                                                index !==
-                                                    manageButtons.length - 1
-                                            "
-                                            :key="index"
-                                            direction="vertical"
-                                        />
+                                        <el-divider v-if="index !== manageButtons.length - 1" :key="index" direction="vertical" />
                                     </template>
                                 </template>
                             </template>
@@ -217,10 +117,7 @@
                     </el-table>
                     <!-- 分页 -->
                     <el-pagination
-                        v-if="
-                            needPage !== 'N' &&
-                                (mode === 'dialog' || mode === 'inner')
-                        "
+                        v-if="needPage !== 'N' && (mode === 'dialog' || mode === 'inner')"
                         :current-page="currentPage"
                         :page-size="pageSize"
                         :page-sizes="pageSizeOptions"
@@ -236,53 +133,15 @@
             <template v-else-if="mode === 'block'">
                 <template v-if="dataModel && dataModel.length > 0">
                     <template v-for="(data, index) in dataModel">
-                        <div
-                            :key="index"
-                            class="dynamic-form-table__block panel panel-info"
-                        >
+                        <div :key="index" class="dynamic-form-table__block panel panel-info">
                             <div class="panel-heading ibps-clearfix">
                                 <!--块模式:工具栏-->
-                                <div class="ibps-fl dynamic-form-table__label">
-                                    <el-badge
-                                        v-if="field.field_options.index"
-                                        :value="index + 1"
-                                        type="primary"
-                                        style="top: 0.3em"
-                                    />{{ field.label }}
-                                </div>
-                                <div
-                                    v-if="
-                                        toolbarButtons &&
-                                            toolbarButtons.length > 0
-                                    "
-                                    class="ibps-fr"
-                                >
+                                <div class="ibps-fl dynamic-form-table__label"><el-badge v-if="field.field_options.index" :value="index + 1" type="primary" style="top: 0.3em" />{{ field.label }}</div>
+                                <div v-if="toolbarButtons && toolbarButtons.length > 0" class="ibps-fr">
                                     <el-button-group>
-                                        <template
-                                            v-for="(
-                                                button, b
-                                            ) in toolbarButtons"
-                                        >
-                                            <template
-                                                v-if="
-                                                    !(
-                                                        button.key ===
-                                                        'remove' &&
-                                                        dataModel.length === 1
-                                                    )
-                                                "
-                                            >
-                                                <el-button
-                                                    :key="b"
-                                                    :type="button.type"
-                                                    :icon="button.icon"
-                                                    @click="
-                                                        handleActionEvent(
-                                                            button,
-                                                            b
-                                                        )
-                                                    "
-                                                >
+                                        <template v-for="(button, b) in toolbarButtons">
+                                            <template v-if="!(button.key === 'remove' && dataModel.length === 1)">
+                                                <el-button :key="b" :type="button.type" :icon="button.icon" @click="handleActionEvent(button, b)">
                                                     {{ button.label }}
                                                 </el-button>
                                             </template>
@@ -314,12 +173,7 @@
             </template>
         </template>
 
-        <el-table
-            v-else
-            :data="[]"
-            empty-text="您尚未创建任何字段。请在表单中添加字段。"
-            border
-        />
+        <el-table v-else :data="[]" empty-text="您尚未创建任何字段。请在表单中添加字段。" border />
         <!--按钮支持自定义对话框-->
         <custom-dialog
             :visible="customDialogVisible"
@@ -366,10 +220,7 @@ import FormUtils from '../../utils/formUtil'
 import FormFieldUtil from '../../utils/formFieldUtil'
 
 import { hasPermission } from '@/business/platform/form/constants/tableButtonTypes'
-import {
-    defaultPageSize,
-    pageSizeOptions
-} from '@/business/platform/form/constants/fieldOptions'
+import { defaultPageSize, pageSizeOptions } from '@/business/platform/form/constants/fieldOptions'
 
 import CustomDialog from '@/business/platform/data/templaterender/custom-dialog/dialog'
 import FormrenderDialog from '@/business/platform/form/formrender/dialog'
@@ -380,12 +231,7 @@ import IbpsImport from '@/plugins/import'
 const JForm = window.JForm
 // 获取子表展示数据
 const getShowData = (data, current = 1, size = defaultPageSize) => {
-    return data && data.length
-        ? JSON.parse(JSON.stringify(data)).slice(
-            (current - 1) * size,
-            current * size
-        )
-        : []
+    return data && data.length ? JSON.parse(JSON.stringify(data)).slice((current - 1) * size, current * size) : []
 }
 
 export default {
@@ -422,12 +268,7 @@ export default {
         }
     },
     data () {
-        const {
-            page,
-            pageSize = defaultPageSize,
-            mode = 'inner',
-            colWidth
-        } = this.field.field_options || {}
+        const { page, pageSize = defaultPageSize, mode = 'inner', colWidth } = this.field.field_options || {}
         let initData = []
         if (page === 'N' || mode === 'block' || !this.value) {
             initData = this.value || []
@@ -486,8 +327,7 @@ export default {
         },
         fieldOptions () {
             const fieldOptions = this.field.field_options || {}
-            fieldOptions.default_value_type =
-                fieldOptions.default_value_type || 'fixed'
+            fieldOptions.default_value_type = fieldOptions.default_value_type || 'fixed'
             return fieldOptions
         },
         toolbarButtons () {
@@ -497,10 +337,7 @@ export default {
             return this.filterButtons('manage')
         },
         manageButtonWidth () {
-            return this.manageButtons.length > 2 ||
-                this.manageButtons.length === 1
-                ? 70
-                : 150
+            return this.manageButtons.length > 2 || this.manageButtons.length === 1 ? 70 : 150
         },
         mode () {
             return this.field.field_options.mode || 'inner'
@@ -548,12 +385,7 @@ export default {
                             traverse(child.fields)
                         })
                     } else {
-                        if (
-                            this.$utils.toBoolean(
-                                field.field_options.display,
-                                true
-                            )
-                        ) {
+                        if (this.$utils.toBoolean(field.field_options.display, true)) {
                             displayColumns.push(field)
                         }
                     }
@@ -576,9 +408,7 @@ export default {
             return bs
         },
         tableReadonly () {
-            return this.readonlyRights
-                ? true
-                : this.tableRights === FormOptions.t.PERMISSIONS.READ
+            return this.readonlyRights ? true : this.tableRights === FormOptions.t.PERMISSIONS.READ
         },
         tableHidden () {
             return this.tableRights === FormOptions.t.PERMISSIONS.HIDE
@@ -647,19 +477,10 @@ export default {
         // 字段权限
         fieldRights: {
             handler (fieldRights) {
-                if (
-                    this.$utils.isNotEmpty(fieldRights) &&
-                    this.$utils.isPlainObject(fieldRights)
-                ) {
-                    this.tableRights = this.getRealRights(
-                        fieldRights['rights'] || FormOptions.t.PERMISSIONS.EDIT
-                    )
-                    this.columnsRights = this.getColumnsRights(
-                        fieldRights['columns']
-                    )
-                    this.buttonsRights = this.getButtonsRights(
-                        fieldRights['buttons']
-                    )
+                if (this.$utils.isNotEmpty(fieldRights) && this.$utils.isPlainObject(fieldRights)) {
+                    this.tableRights = this.getRealRights(fieldRights['rights'] || FormOptions.t.PERMISSIONS.EDIT)
+                    this.columnsRights = this.getColumnsRights(fieldRights['columns'])
+                    this.buttonsRights = this.getButtonsRights(fieldRights['buttons'])
                 } else {
                     this.tableRights = FormOptions.t.PERMISSIONS.EDIT
                     this.columnsRights = this.getColumnsRights({})
@@ -688,7 +509,7 @@ export default {
             return (this.currentPage - 1) * this.pageSize + index + 1
         },
         /**
-         * 定义删除、增加 不做操作。修改时才做更新 ,分页修改时,根据页表修改。
+         * 定义删除、增加 不做操作。修改时才做更新,分页修改时,根据页表修改。
          */
         updateModel (key, val, index, page) {
             this.dataModel[(page - 1) * this.pageSize + index][key] = val
@@ -707,52 +528,33 @@ export default {
                 this.currentPage = 1
             } else {
                 // 其余逻辑(编辑、删除、整表赋值):操作后当前页大于总页数,替换为总页数,否则留在当前页
-                this.currentPage =
-                    this.currentPage > pageCount ? pageCount : this.currentPage
+                this.currentPage = this.currentPage > pageCount ? pageCount : this.currentPage
             }
-            this.copDataModel = this.getShowData(
-                val,
-                this.currentPage,
-                this.pageSize
-            )
+            this.copDataModel = this.getShowData(val, this.currentPage, this.pageSize)
             this.editFromType = ''
             this.$emit('update:value', val)
         },
         // 处理切换分页
         handleCurrentChange (val) {
             this.currentPage = val
-            this.copDataModel = this.getShowData(
-                this.dataModel,
-                this.currentPage,
-                this.pageSize
-            )
+            this.copDataModel = this.getShowData(this.dataModel, this.currentPage, this.pageSize)
         },
         // 处理切换分页大小
         handleSizeChange (val) {
             this.pageSize = val
             this.currentPage = 1
-            this.copDataModel = this.getShowData(
-                this.dataModel,
-                this.currentPage,
-                this.pageSize
-            )
+            this.copDataModel = this.getShowData(this.dataModel, this.currentPage, this.pageSize)
         },
         columnHidden (column) {
             // 是否隐藏
-            return (
-                this.columnsRights[column.name] ===
-                    FormOptions.t.PERMISSIONS.HIDE ||
-                column.field_type === 'hidden'
-            )
+            return this.columnsRights[column.name] === FormOptions.t.PERMISSIONS.HIDE || column.field_type === 'hidden'
         },
         /**
          * 获取真实的权限
          */
         getRealRights (rights) {
             if (this.tableReadonly) {
-                return rights === FormOptions.t.PERMISSIONS.HIDE
-                    ? rights
-                    : FormOptions.t.PERMISSIONS.READ
+                return rights === FormOptions.t.PERMISSIONS.HIDE ? rights : FormOptions.t.PERMISSIONS.READ
             } else {
                 return rights
             }
@@ -761,10 +563,7 @@ export default {
             const columnsRights = {}
             if (this.nameColumns && this.nameColumns.length > 0) {
                 this.nameColumns.forEach((column) => {
-                    columnsRights[column.name] = this.getRealRights(
-                        rights[column.name] ||
-                            FormUtils.getDefaultRigths(column)
-                    )
+                    columnsRights[column.name] = this.getRealRights(rights[column.name] || FormUtils.getDefaultRigths(column))
                 })
             }
             return columnsRights
@@ -774,8 +573,7 @@ export default {
                 const buttonsRights = {}
                 if (this.$utils.isNotEmpty(this.buttons)) {
                     this.buttons.forEach((button) => {
-                        buttonsRights[button.key] =
-                            FormOptions.t.PERMISSIONS.SHOW
+                        buttonsRights[button.key] = FormOptions.t.PERMISSIONS.SHOW
                     })
                 }
                 return buttonsRights
@@ -803,12 +601,8 @@ export default {
             this.buttons.forEach((button) => {
                 if (
                     hasPermission(button.key, position) && // 有位置权限
-                    (!button.position ||
-                        button.position === 'all' ||
-                        button.position === position) && // 有位置权限
-                    (this.$utils.isEmpty(this.buttonsRights[button.key]) ||
-                        this.buttonsRights[button.key] !==
-                            FormOptions.t.PERMISSIONS.HIDE) // 有按钮权限
+                    (!button.position || button.position === 'all' || button.position === position) && // 有位置权限
+                    (this.$utils.isEmpty(this.buttonsRights[button.key]) || this.buttonsRights[button.key] !== FormOptions.t.PERMISSIONS.HIDE) // 有按钮权限
                 ) {
                     const b = JSON.parse(JSON.stringify(button))
                     b.position = position
@@ -822,12 +616,8 @@ export default {
             this.buttons.forEach((button) => {
                 if (
                     hasPermission(button.key, position) && // 有位置权限
-                    (!button.position ||
-                        button.position === 'all' ||
-                        button.position === position) && // 有位置权限
-                    (this.$utils.isEmpty(this.buttonsRights[button.key]) ||
-                        this.buttonsRights[button.key] !==
-                            FormOptions.t.PERMISSIONS.HIDE) && // 有按钮权限
+                    (!button.position || button.position === 'all' || button.position === position) && // 有位置权限
+                    (this.$utils.isEmpty(this.buttonsRights[button.key]) || this.buttonsRights[button.key] !== FormOptions.t.PERMISSIONS.HIDE) && // 有按钮权限
                     button.key === 'consult'
                 ) {
                     // 原按钮权限限制 改为开放查阅按钮 modified by 林总
@@ -842,10 +632,7 @@ export default {
         handleActionEvent (button, buttonIndex) {
             // 起始下标
             const index = (this.currentPage - 1) * this.pageSize + buttonIndex
-            this.actionCode =
-                button.key === 'custom'
-                    ? button.code || button.key + index
-                    : button.key
+            this.actionCode = button.key === 'custom' ? button.code || button.key + index : button.key
             this.actionPosition = button.position || 'toolbar'
             this.actionButton = button
             // 前置事件
@@ -863,9 +650,9 @@ export default {
                             this.handleAdd()
                         }
                         break
-                    case 'copyAdd':
-                        // 复制添加数据,需要先选择数据,往最后添加数据
-                        this.handleCopyAddData(button, index)
+                    case 'copy':
+                        // 复制已有数据(尾部插入)
+                        this.handleCopyData(button, index)
                         break
                     case 'edit':
                         this.handleDialogMode(index)
@@ -895,19 +682,11 @@ export default {
             })
         },
         destoryTable () {
-            if (
-                this.$utils.isNotEmpty(window[this.mainCode + 'TableRefs']) &&
-                this.$utils.isNotEmpty(
-                    window[this.mainCode + 'TableRefs'][this.code]
-                )
-            ) {
+            if (this.$utils.isNotEmpty(window[this.mainCode + 'TableRefs']) && this.$utils.isNotEmpty(window[this.mainCode + 'TableRefs'][this.code])) {
                 window[this.mainCode + 'TableRefs'][this.code] = null
                 delete window[this.mainCode + 'TableRefs'][this.code]
             }
-            if (
-                this.$utils.isObject(window[this.mainCode + 'TableRefs']) &&
-                this.$utils.isEmpty(window[this.mainCode + 'TableRefs'])
-            ) {
+            if (this.$utils.isObject(window[this.mainCode + 'TableRefs']) && this.$utils.isEmpty(window[this.mainCode + 'TableRefs'])) {
                 window[this.mainCode + 'TableRefs'] = null
                 delete window[this.mainCode + 'TableRefs']
             }
@@ -917,9 +696,7 @@ export default {
             if (this.mode === 'dialog') {
                 this.handleDialogMode()
             } else {
-                const defaultValue = await FormUtils.getTableDefaultData(
-                    this.field
-                )
+                const defaultValue = await FormUtils.getTableDefaultData(this.field)
                 await this.addData(JSON.parse(JSON.stringify(defaultValue)))
             }
         },
@@ -935,29 +712,25 @@ export default {
                 this.$refs.elTable.doLayout()
             }
         },
-        // 新增所选择的数据
-        handleCopyAddData (button, index) {
+        // 复制已有数据
+        handleCopyData (button, index) {
             const position = button.position
             const selection = this.getSelection(position, index)
-            ActionUtils.selectedMultiRecord(selection)
-                .then((ids) => {
-                    var addDatas = []
-                    for (const i of selection) {
-                        const object = this.dataModel[i]
-                        delete object.$index
-                        delete object.id
-                        addDatas.push(object)
-                    }
-                    this.dataModel = JSON.parse(JSON.stringify([...this.dataModel, ...addDatas]))
-                    // 初始化运行公式计算
-                    this.initRunCalFormula(this.dataModel.length - 1)
-                    // 后置事件
-                    this.afterScript(this.actionCode, this.actionPosition)
-                    if (this.$refs.elTable) {
-                        this.$refs.elTable.doLayout()
-                    }
+            ActionUtils.selectedMultiRecord(selection).then((ids) => {
+                selection.forEach(i => {
+                    const obj = this.dataModel[i]
+                    delete obj.$index
+                    delete obj.id
+                    this.dataModel.push(obj)
                 })
-                .catch(() => {})
+                // 初始化运行公式计算
+                this.initRunCalFormula(this.dataModel.length - 1)
+                // 后置事件
+                this.afterScript(this.actionCode, this.actionPosition)
+                if (this.$refs.elTable) {
+                    this.$refs.elTable.doLayout()
+                }
+            }).catch(() => {})
         },
         /**
          * 获取选择的记录
@@ -965,10 +738,7 @@ export default {
         getSelection (position, index) {
             const selection = []
             if (position === 'toolbar' && this.mode !== 'block') {
-                if (
-                    this.multipleSelection &&
-                    this.multipleSelection.length > 0
-                ) {
+                if (this.multipleSelection && this.multipleSelection.length > 0) {
                     const startIndex = (this.currentPage - 1) * this.pageSize
                     this.multipleSelection.forEach((row) => {
                         selection.push(row.$index + startIndex)
@@ -982,31 +752,24 @@ export default {
         handleRemove (button, index) {
             const position = button.position
             const selection = this.getSelection(position, index)
-            ActionUtils.removeRecord(selection, '确定删除当前数据?', true)
-                .then((ids) => {
-                    for (let i = this.dataModel.length - 1; i >= 0; i--) {
-                        if (ids.indexOf(i) > -1) {
-                            this.dataModel.splice(i, 1)
-                        }
+            ActionUtils.removeRecord(selection, '确定删除当前数据?', true).then((ids) => {
+                for (let i = this.dataModel.length - 1; i >= 0; i--) {
+                    if (ids.indexOf(i) > -1) {
+                        this.dataModel.splice(i, 1)
                     }
-                    this.totalCount = this.dataModel.length
-                    // 后置事件
-                    this.afterScript(this.actionCode, position, {
-                        selection: selection,
-                        index: index
-                    })
+                }
+                this.totalCount = this.dataModel.length
+                // 后置事件
+                this.afterScript(this.actionCode, position, {
+                    selection: selection,
+                    index: index
                 })
-                .catch(() => {})
+            }).catch(() => {})
         },
         // 初始化运行公式计算
         initRunCalFormula (row) {
             // 不需要字段的进行公式计算 比如获取但其当前时间,随机数
-            FormUtils.runCalFormula(
-                this,
-                this.formula[FormUtils.NOT_NEED_FIELD],
-                this.mainCode,
-                row
-            )
+            FormUtils.runCalFormula(this, this.formula[FormUtils.NOT_NEED_FIELD], this.mainCode, row)
         },
         handleImport () {
             this.importTableDialogVisible = true
@@ -1052,9 +815,7 @@ export default {
                     ActionUtils.success('导入成功')
                 })
             } else {
-                const formData = FormUtils.getTableDefaultColumnData(
-                    this.field
-                )
+                const formData = FormUtils.getTableDefaultColumnData(this.field)
                 IbpsImport.xlsx(file, options).then(({ header, results }) => {
                     const columnMap = {}
                     this.nameColumns.forEach((column) => {
@@ -1066,10 +827,7 @@ export default {
                             if (columnMap[key]) {
                                 const column = columnMap[key]
                                 const name = column.name
-                                const value = this.importDataFormatter(
-                                    result[key],
-                                    column
-                                )
+                                const value = this.importDataFormatter(result[key], column)
                                 data[name] = value
                             }
                         }
@@ -1197,20 +955,10 @@ export default {
                 case 'select': // 下拉,单选,多选
                 case 'radio':
                 case 'checkbox':
-                    result = this.formatterOptions(
-                        value,
-                        fieldOptions['options'],
-                        'label',
-                        'val'
-                    )
+                    result = this.formatterOptions(value, fieldOptions['options'], 'label', 'val')
                     break
                 case 'switch': //
-                    result = this.formatterOptions(
-                        value,
-                        FormUtils.getSwitchOptions(this.field.field_options),
-                        'label',
-                        'val'
-                    )
+                    result = this.formatterOptions(value, FormUtils.getSwitchOptions(this.field.field_options), 'label', 'val')
                     break
                 default:
                     result = value
@@ -1240,18 +988,10 @@ export default {
                 case 'select': // 下拉,单选,多选
                 case 'radio':
                 case 'checkbox':
-                    result = this.formatterOptions(
-                        value,
-                        fieldOptions['options'],
-                        'val'
-                    )
+                    result = this.formatterOptions(value, fieldOptions['options'], 'val')
                     break
                 case 'switch': //
-                    result = this.formatterOptions(
-                        value,
-                        FormUtils.getSwitchOptions(fieldOptions),
-                        'val'
-                    )
+                    result = this.formatterOptions(value, FormUtils.getSwitchOptions(fieldOptions), 'val')
                     break
                 default:
                     result = value
@@ -1262,12 +1002,7 @@ export default {
         /**
          * 格式化选项
          */
-        formatterOptions (
-            value,
-            options,
-            valueKey = 'value',
-            labelKey = 'label'
-        ) {
+        formatterOptions (value, options, valueKey = 'value', labelKey = 'label') {
             const optionObj = {}
             options.map((option) => {
                 optionObj[option[valueKey]] = option[labelKey]
@@ -1284,9 +1019,7 @@ export default {
         },
         // =====================对话框模式数据处理   金源信通改=====================
         handleDialogMode (index) {
-            const data = this.$utils.isNotEmpty(index)
-                ? this.dataModel[index]
-                : {}
+            const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
             this.dialogFormData = {
                 responses: JSON.parse(JSON.stringify(data)),
                 // 表单字段权限
@@ -1299,18 +1032,7 @@ export default {
             }
             if (this.params.formAttrs) {
                 const formAttrs = this.params.formAttrs
-                const allowAttrs = [
-                    'inline',
-                    'labelPosition',
-                    'labelWidth',
-                    'labelWidthUnit',
-                    'size',
-                    'statusIcon',
-                    'descPosition',
-                    'read_style',
-                    'colon',
-                    'labelSuffix'
-                ]
+                const allowAttrs = ['inline', 'labelPosition', 'labelWidth', 'labelWidthUnit', 'size', 'statusIcon', 'descPosition', 'read_style', 'colon', 'labelSuffix']
                 for (const key in formAttrs) {
                     if (allowAttrs.indexOf(key) > -1) {
                         const val = formAttrs[key]
@@ -1346,9 +1068,7 @@ export default {
         // =====================对话框模式数据处理=  原====================
 
         handleEditMode (index) {
-            const data = this.$utils.isNotEmpty(index)
-                ? this.dataModel[index]
-                : {}
+            const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
             this.dialogFormData = {
                 responses: JSON.parse(JSON.stringify(data)),
                 // 表单字段权限
@@ -1361,18 +1081,7 @@ export default {
             }
             if (this.params.formAttrs) {
                 const formAttrs = this.params.formAttrs
-                const allowAttrs = [
-                    'inline',
-                    'labelPosition',
-                    'labelWidth',
-                    'labelWidthUnit',
-                    'size',
-                    'statusIcon',
-                    'descPosition',
-                    'read_style',
-                    'colon',
-                    'labelSuffix'
-                ]
+                const allowAttrs = ['inline', 'labelPosition', 'labelWidth', 'labelWidthUnit', 'size', 'statusIcon', 'descPosition', 'read_style', 'colon', 'labelSuffix']
                 for (const key in formAttrs) {
                     if (allowAttrs.indexOf(key) > -1) {
                         const val = formAttrs[key]
@@ -1415,11 +1124,7 @@ export default {
 
         async handleAddCustomDialog (button) {
             this.customDialogKey = button.dialog
-            this.customDialogDynamicParams =
-                await FormUtils.getLinkDynamicParams(
-                    button.custom,
-                    this.formData
-                )
+            this.customDialogDynamicParams = await FormUtils.getLinkDynamicParams(button.custom, this.formData)
             this.customDialogCustom = button.custom
             setTimeout(() => {
                 this.customDialogVisible = true
@@ -1430,9 +1135,7 @@ export default {
             if (this.$utils.isEmpty(linkLinkage)) {
                 return
             }
-            const defaultValue = await FormUtils.getTableDefaultData(
-                this.field
-            )
+            const defaultValue = await FormUtils.getTableDefaultData(this.field)
             for (let i = 0; i < datas.length; i++) {
                 const data = datas[i]
                 const model = JSON.parse(JSON.stringify(defaultValue))
@@ -1472,13 +1175,7 @@ export default {
             if (!callback) {
                 callback = () => {}
             }
-            JForm._beforeSubButton(
-                this,
-                this.actionCode,
-                button.position,
-                params,
-                callback
-            )
+            JForm._beforeSubButton(this, this.actionCode, button.position, params, callback)
         },
         // 后置脚本
         afterScript (action, position, params, callback) {
@@ -1590,7 +1287,7 @@ export default {
 
 .is-required:not(.is-no-asterisk) {
     .dynamic-form-table__label:before {
-        content: "*";
+        content: '*';
         color: #f56c6c;
         margin-right: 4px;
     }

+ 1 - 1
src/locales/en.json

@@ -752,7 +752,7 @@
 					"orgPath": "Org path",
 					"status": "Status",
 					"wcAccount": "WeChat account",
-					"job": "role"
+					"job": "Role"
 				},
 				"title": "Staff"
 			},

+ 1 - 1
src/store/modules/ibps/modules/user.js

@@ -168,7 +168,7 @@ export default {
          */
         getUserList ({ state, dispatch }, { first, second }) {
             const params = second ? `'%${second}%' or entity.id_ = '${first}'` : first ? `'%${first}%'` : '%%'
-            const sql = `select users.id_ as userId, users.name_ as userName, ifnull(users.mobile_, '') as phone, ifnull(group_concat(distinct positions.id_ order by positions.id_ separator ','), '') as positionId, ifnull(group_concat(distinct positions.name_ order by positions.id_ separator ','), '') as positions, ifnull(group_concat(distinct roles.id_ order by roles.id_ separator ','), '') as roleId, ifnull(group_concat(distinct roles.name_ order by roles.id_ separator ','), '') as roles, (select ifnull(people.qian_zi_tu_wen_, '') from t_ryjbqk as people where people.parent_id_ = users.id_) as signatureId, (select ifnull(files.file_name_, '') from ibps_file_attachment as files where files.id_ = signatureId) as signatureName from ibps_party_employee as users left join (select ur.user_id_, group_concat(distinct r.id_ order by r.id_ separator ',') as id_, group_concat(distinct r.name_ order by r.id_ separator ',') as name_ from ibps_party_user_role as ur join ibps_party_role as r on ur.role_id_ = r.id_ group by ur.user_id_) as roles on users.id_ = roles.user_id_ left join ibps_party_entity as positions on find_in_set(positions.id_, users.positions_) where exists (select 1 from ibps_party_entity as entity where find_in_set(entity.id_, users.positions_) and (entity.path_ like ${params})) group by users.id_`
+            const sql = `select users.id_ as userId, users.name_ as userName, ifnull(users.mobile_, '') as phone, ifnull(group_concat(distinct positions.id_ order by positions.id_ separator ','), '') as positionId, ifnull(group_concat(distinct positions.name_ order by positions.id_ separator ','), '') as positions, ifnull(group_concat(distinct roles.id_ order by roles.role_note_ asc separator ','), '') as roleId, ifnull(group_concat(distinct roles.name_ order by roles.role_note_ asc separator ','), '') as roles, (select ifnull(people.qian_zi_tu_wen_, '') from t_ryjbqk as people where people.parent_id_ = users.id_) as signatureId, (select ifnull(files.file_name_, '') from ibps_file_attachment as files where files.id_ = signatureId) as signatureName from ibps_party_employee as users left join (select ur.user_id_, r.role_note_, group_concat(distinct r.id_ order by r.id_ separator ',') as id_, group_concat(distinct r.name_ order by r.id_ separator ',') as name_ from ibps_party_user_role as ur join ibps_party_role as r on ur.role_id_ = r.id_ group by ur.user_id_) as roles on users.id_ = roles.user_id_ left join ibps_party_entity as positions on find_in_set(positions.id_, users.positions_) where exists (select 1 from ibps_party_entity as entity where find_in_set(entity.id_, users.positions_) and (entity.path_ like ${params})) group by users.id_`
             common.request('sql', sql).then(res => {
                 const { data = [] } = res.variables || {}
                 dispatch('ibps/param/setUserList', data, {

+ 63 - 83
src/views/platform/org/employee/list.vue

@@ -20,11 +20,11 @@
             @sort-change="handleSortChange"
             @pagination-change="handlePaginationChange"
         >
-            <template slot="roleName" slot-scope="roleName">
-                <span class="huanRow">{{roleName.row.roleName}}</span>
+            <template slot="roleName" slot-scope="scope">
+                <span class="wrap">{{ scope.row.roleName }}</span>
             </template>
-            <template slot="positionsPath" slot-scope="positionsPath">
-                <span class="huanRow">{{positionsPath.row.positionsPath}}</span>
+            <template slot="positionsPath" slot-scope="scope">
+                <span class="wrap">{{ scope.row.positionsPath }}</span>
             </template>
         </ibps-crud>
         <!-- 新增、编辑、明细 -->
@@ -120,7 +120,7 @@ export default {
                             'platform.org.employee.button.changePassword'
                         ),
                         icon: 'el-icon-refresh'
-                    },
+                    }
                     // { key: 'more', icon: 'ibps-icon-ellipsis-h' }
                 ],
                 searchForm: {
@@ -157,6 +157,14 @@ export default {
                         //     labelWidth: 70,
                         //     itemWidth: 150
                         // },
+                        {
+                            prop: 'Q^JOB_^SL',
+                            label: '角色',
+                            fieldType: 'select',
+                            options: this.roleList,
+                            labelWidth: 70,
+                            itemWidth: 150
+                        },
                         {
                             prop: ['Q^CREATE_TIME_^DL', 'Q^CREATE_TIME_^DG'],
                             label: this.$t('common.field.createTime'),
@@ -184,19 +192,21 @@ export default {
                         tags: genderOptions,
                         width: 90
                     },
+                    // { prop: 'wcAccount', label: this.$t('platform.org.employee.prop.wcAccount'),width:120},
                     {
                         prop: 'positionsPath',
                         label: this.$t('platform.org.employee.prop.orgPath'),
                         sortable: false,
-                        width: 200,
-                        slotName:"positionsPath"
+                        width: 240,
+                        slotName: 'positionsPath'
                     },
-                    { 
-                        prop: "roleName", 
+                    {
+                        prop: 'roleName',
                         label: this.$t('platform.org.employee.prop.job'),
-                        minWidth:200,
-                        slotName:"roleName"
-                    }, 
+                        sortable: false,
+                        minWidth: 200,
+                        slotName: 'roleName'
+                    },
                     {
                         prop: 'status',
                         label: this.$t('platform.org.employee.prop.status'),
@@ -315,16 +325,16 @@ export default {
             moreSearchParams: {},
             dialogMoreSearchVisible: false,
             positionsList: [],
-            roleList:[]
+            roleList: []
         }
     },
     created () {
-        Promise.all([this.getRole(),this.getOrg()]).then(([rep,res]) => {
+        const sql1 = 'select a.id_ as id_, a.name_ as name_, b.path_ as path_ from ibps_party_position a, ibps_party_entity b where a.id_ = b.id_'
+        const sql2 = 'select id_, name_ from ibps_party_role order by role_note_ asc'
+        Promise.all([this.getData(sql1, 'positionsList', 4), this.getData(sql2, 'roleList', 3)]).then(() => {
             this.loadData()
             this.loadDisplayField()
         })
-        // this.loadData()
-        // this.loadDisplayField()
     },
     methods: {
         ...mapMutations({
@@ -340,15 +350,16 @@ export default {
                 response.data.dataResult.forEach(item => {
                     if (item.positions) {
                         // 转换岗位名
-                        const name = this.getPositionsName(item.positions)
+                        const name = this.getTransformName(item.positions, 'positionsList')
                         this.$set(item, 'positionsName', name)
                         // 转换岗位路径
                         const path = this.getPositionsPath(item.positions)
+                        console.log(path)
                         this.$set(item, 'positionsPath', path)
                     }
                     if (item.job) {
                         // 转角色名
-                        const role = this.getRoleName(item.job)
+                        const role = this.getTransformName(item.job, 'roleList')
                         this.$set(item, 'roleName', role)
                     }
                 })
@@ -358,51 +369,36 @@ export default {
                 this.loading = false
             })
         },
-        getRoleName(val){
-            let name=''
-            let nameArr = []
-            let valArr = val.split(',')
-            if(valArr.length!=0){
-                valArr.forEach((item) => {
-                    let it = this.roleList.find(i => i.id_ === item)
-                    if(typeof it != 'undefined'){
-                        nameArr.push(it.name_)
-                    }
-                    
-                })
-                name = nameArr.join(',')
-            }
-            return name
-        },
-        getPositionsName (valueList) {
-            const postList = valueList.split(',')
-            const list = []
-            if (!postList.length) {
+        getTransformName (value, type) {
+            const dataList = value.split(',')
+            const result = []
+            if (!dataList.length) {
                 return ''
             }
-            postList.forEach((item) => {
-                const dataItem = this.positionsList.find(i => i.ID_ === item)
-                list.push(dataItem.NAME_)
+            console.log(this[type])
+            dataList.forEach(item => {
+                const dataItem = this[type].find(i => i.id_ === item)
+                result.push(dataItem.name_)
             })
-            return list.join(',')
+            return result.join(',')
         },
-        getPositionsPath (valueList) {
-            const postList = valueList.split(',')
-            const list = []
+        getPositionsPath (value) {
+            const postList = value.split(',')
+            const result = []
             if (!postList.length) {
                 return ''
             }
-            postList.forEach((item) => {
-                const temp = this.positionsList.find(i => i.ID_ === item)
-                const pathList = temp ? temp.PATH_.split('.') : []
+            postList.forEach(item => {
+                const temp = this.positionsList.find(i => i.id_ === item)
+                const pathList = temp ? temp.path_.split('.') : []
                 let p = ''
                 pathList.filter(i => i).forEach(k => {
-                    const t = this.positionsList.find(i => i.ID_ === k)
-                    p += `${t.NAME_}.`
+                    const t = this.positionsList.find(i => i.id_ === k)
+                    p += `${t.name_}.`
                 })
-                list.push(p)
+                result.push(p)
             })
-            return list.join('\r\n')
+            return result.join('\r\n')
         },
         /**
          * 获取格式化参数
@@ -591,35 +587,21 @@ export default {
                 this.$router.replace('/')
             })
         },
-        // 获取组织的数据
-        getOrg () {
-            return new Promise((resolve, reject) => {
-                const sql = `select a.ID_ as ID_, a.NAME_ as NAME_, b.path_ as PATH_ FROM ibps_party_position a, ibps_party_entity b where a.id_ = b.id_`
-                this.$common.request('sql', sql).then((res) => {
-                    const datas = res.variables.data
-                    datas.forEach((item, index) => {
-                        this.$set(item, 'value', item.ID_)
-                        this.$set(item, 'label', item.NAME_)
-                    })
-                    this.positionsList = datas
-                    this.listConfig.searchForm.forms[3].options = datas
-                    resolve()
-                })
-            })
-        },
-        // 获取角色的数据
-        getRole () {
+        // 获取组织/角色数据
+        getData (sql, type, index) {
             return new Promise((resolve, reject) => {
-                const sql = `select id_,name_ FROM ibps_party_role`
-                this.$common.request('sql', sql).then((res) => {
-                    const datas = res.variables.data
-                    datas.forEach((item, index) => {
+                this.$common.request('sql', sql).then(res => {
+                    const { data = [] } = res.variables || {}
+                    if (!data.length) {
+                        ActionUtils.errorMessage('获取数据失败!')
+                        return reject()
+                    }
+                    data.forEach(item => {
                         this.$set(item, 'value', item.id_)
                         this.$set(item, 'label', item.name_)
                     })
-                    this.roleList = datas
-
-                    // this.listConfig.searchForm.forms[3].options = datas
+                    this[type] = data
+                    this.listConfig.searchForm.forms[index].options = data
                     resolve()
                 })
             })
@@ -628,9 +610,7 @@ export default {
 }
 </script>
 <style scoped>
-.huanRow{
-    display: inline-block;
-    width: 100%;
-    white-space: pre-line;
-}
-</style>
+    .wrap{
+        white-space: pre-line;
+    }
+</style>