| | |
| | | <template>
|
| | | <div>
|
| | | <div class="body" :style="{height:mainHeight+'px'}">
|
| | | <div style="display: flex">
|
| | | <!-- background:rgba(248,248,250,1);-->
|
| | | <div style="width: 300px;margin: 10px 10px 0 0;background: #fff">
|
| | |
|
| | | <div style="margin: 20px 10px 0 10px;display: flex;justify-content: space-between;">
|
| | | <div style="display: flex;">
|
| | | <div
|
| | | style="width: 5px;height: 100%;border-radius: 5px;"
|
| | | :style="{background:$store.state.settings.theme}"
|
| | | />
|
| | | <div style="margin-left: 8px;">组织架构</div>
|
| | | </div>
|
| | |
|
| | | <!-- <div style="margin-right:10px">-->
|
| | | <!-- <i class="el-icon-plus" style="cursor: pointer;color: #999" />-->
|
| | | <!-- </div>-->
|
| | |
|
| | | </div>
|
| | |
|
| | | <el-tree
|
| | | ref="treeLeftRef"
|
| | | key="treeLeftKey"
|
| | | style="padding: 10px;overflow: auto;"
|
| | | :style="{height:(tableHeight+180)+'px'}"
|
| | | :data="treeLeft"
|
| | | node-key="torg_code"
|
| | | highlight-current
|
| | | :props="defaultPropsLeft"
|
| | | :default-expand-all="true"
|
| | | :expand-on-click-node="false"
|
| | | @node-click="nodeClick"
|
| | | />
|
| | |
|
| | | </div>
|
| | |
|
| | | <div style="width: calc(100% - 300px)">
|
| | | <div class="bodyTopButtonGroup" style="justify-content: space-between">
|
| | | <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
|
| | | <el-button v-waves type="success" icon="el-icon-download" @click="$router.push('./../systemSetting/dataImport?fileCode=3')">导入</el-button>
|
| | | </div>
|
| | |
|
| | | <div class="bodyTopFormGroup">
|
| | | <el-form
|
| | | ref="form"
|
| | | :model="form"
|
| | | label-width="100px"
|
| | | inline
|
| | | style="display: flex;"
|
| | | >
|
| | | <div class="elForm">
|
| | | <el-form-item label="用户编码" style=" display: flex;">
|
| | | <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />
|
| | | </el-form-item>
|
| | | <el-form-item label="用户名称" style=" display: flex;">
|
| | | <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />
|
| | | </el-form-item>
|
| | | <!-- <el-form-item label="用户编码" style=" display: flex;">-->
|
| | | <!-- <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />-->
|
| | | <!-- </el-form-item>-->
|
| | | <!-- <el-form-item v-show="isExpandForm" label="用户名称" style=" display: flex;">-->
|
| | | <!-- <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />-->
|
| | | <!-- </el-form-item>-->
|
| | | <!-- <el-form-item v-show="isExpandForm" label="用户编码" style=" display: flex;">-->
|
| | | <!-- <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />-->
|
| | | <!-- </el-form-item>-->
|
| | | <!-- <el-form-item v-show="isExpandForm" label="用户名称" style=" display: flex;">-->
|
| | | <!-- <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />-->
|
| | | <!-- </el-form-item>-->
|
| | | <!-- <el-form-item v-show="isExpandForm" label="用户编码" style=" display: flex;">-->
|
| | | <!-- <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />-->
|
| | | <!-- </el-form-item>-->
|
| | | <!-- <el-form-item v-show="isExpandForm" label="用户名称" style=" display: flex;">-->
|
| | | <!-- <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />-->
|
| | | <!-- </el-form-item>-->
|
| | | </div>
|
| | | <div
|
| | | class="bodySearchReset"
|
| | | :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
|
| | | >
|
| | | <el-button v-waves type="primary" icon="el-icon-search" @click="getUserData">查询</el-button>
|
| | | <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
|
| | | </div>
|
| | | </el-form>
|
| | | <div
|
| | | class="bodyTopFormExpand"
|
| | | style="height: 5px;"
|
| | | >
|
| | | <!-- <svg-icon-->
|
| | | <!-- v-show="mouseHoverType==='mouseout'"-->
|
| | | <!-- style="cursor: pointer"-->
|
| | | <!-- :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
|
| | | <!-- @mouseenter="mouseHoverType=$event.type"-->
|
| | | <!-- />-->
|
| | | <!-- <svg-icon-->
|
| | | <!-- v-show="mouseHoverType==='mouseenter'"-->
|
| | | <!-- style="cursor: pointer"-->
|
| | | <!-- :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
|
| | | <!-- @click="isExpandForm=!isExpandForm"-->
|
| | | <!-- @mouseout="mouseHoverType=$event.type"-->
|
| | | <!-- />-->
|
| | | </div>
|
| | | </div>
|
| | |
|
| | | <div class="elTableDiv">
|
| | | <el-table
|
| | | ref="tableDataRef"
|
| | | class="tableFixed"
|
| | | :data="tableData"
|
| | | :height="isExpandForm?tableHeight:(tableHeight+80)+'px'"
|
| | | border
|
| | | row-class-name="custom-row"
|
| | | :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+80)+'px',}"
|
| | | highlight-current-row
|
| | | :header-cell-style="this.$headerCellStyle"
|
| | | :cell-style="this.$cellStyle"
|
| | | @sort-change="sortChange"
|
| | | >
|
| | | <el-table-column
|
| | | prop="rowNum"
|
| | | width="50"
|
| | | fixed
|
| | | label="序号"
|
| | | />
|
| | | <el-table-column
|
| | | prop="usercode"
|
| | | label="用户编码"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | />
|
| | | <el-table-column
|
| | | prop="username"
|
| | | label="用户名称"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | />
|
| | | <el-table-column
|
| | | prop="storg_name"
|
| | | label="所属组织"
|
| | | show-overflow-tooltip
|
| | | sortable="custom"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | <div v-if="row.storg_name">{{ row.storg_name }}</div>
|
| | | <div v-else>/</div>
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="status"
|
| | | label="状态"
|
| | | show-overflow-tooltip
|
| | | sortable="custom"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | <el-tag v-if="row.status==='Y'" size="small" type="success">在职</el-tag>
|
| | | <el-tag v-if="row.status==='N'" size="small" type="danger">离职</el-tag>
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="email"
|
| | | label="邮箱"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.email ? row.email : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="mobile"
|
| | | label="号码"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.mobile ? row.mobile : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="postname"
|
| | | label="岗位"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.postname ? row.postname : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="rolename"
|
| | | label="角色"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.rolename ? row.rolename : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="group_name"
|
| | | label="班组"
|
| | | sortable="custom"
|
| | | show-overflow-tooltip
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | {{ row.group_name ? row.group_name : '/' }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | prop="createusername"
|
| | | label="创建人员"
|
| | | sortable="custom"
|
| | | />
|
| | | <el-table-column
|
| | | prop="lm_date"
|
| | | label="创建时间"
|
| | | width="160"
|
| | | sortable="custom"
|
| | | />
|
| | | <el-table-column
|
| | | label="操作"
|
| | | width="120"
|
| | | fixed="right"
|
| | | >
|
| | | <template slot-scope="{row}">
|
| | | <div class="operationClass">
|
| | | <el-tooltip class="item" effect="dark" content="编辑" placement="top">
|
| | | <i
|
| | | v-if="row.usercode!=='9999'"
|
| | | class="el-icon-edit-outline"
|
| | | :style="{color:$store.state.settings.theme}"
|
| | | @click="edit('edit',row)"
|
| | | />
|
| | | </el-tooltip>
|
| | | <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
|
| | | <i
|
| | | v-if="row.usercode!=='9999'"
|
| | | class="el-icon-delete"
|
| | | :style="{color:$store.state.settings.theme}"
|
| | | @click="del(row)"
|
| | | />
|
| | | </el-tooltip>
|
| | | </div>
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | | </div>
|
| | | <!--分页-->
|
| | | <pagination
|
| | | :total="total"
|
| | | :page.sync="form.page"
|
| | | :limit.sync="form.rows"
|
| | | align="right"
|
| | | layout="total,prev, pager, next,sizes,jumper"
|
| | | popper-class="select_bottom"
|
| | | @pagination="getUserData"
|
| | | />
|
| | | </div>
|
| | |
|
| | | </div>
|
| | |
|
| | | </div>
|
| | |
|
| | | <el-dialog
|
| | | v-el-drag-dialog
|
| | | :title="operation==='add'?'新增':'编辑'"
|
| | | :visible.sync="dialogVisible"
|
| | | width="800px"
|
| | | :close-on-click-modal="false"
|
| | | top="15vh"
|
| | | @closed="handleClose"
|
| | | @close="handleClose"
|
| | | >
|
| | | <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
|
| | | <el-form-item label="用户编码" prop="usercode">
|
| | | <el-input v-model="dialogForm.usercode" :disabled="operation!=='add'" style="width: 200px" />
|
| | | </el-form-item>
|
| | | <el-form-item label="用户名称" prop="username">
|
| | | <el-input v-model="dialogForm.username" style="width: 200px" />
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item label="用户密码" prop="password">
|
| | | <el-input v-model="dialogForm.password" style="width: 200px" />
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item label="所属组织" prop="storg_code">
|
| | | <el-cascader
|
| | | ref="cascader"
|
| | | v-model="dialogForm.storg_code"
|
| | | :options="cascaderOptions"
|
| | | filterable
|
| | | :props="defaultProps"
|
| | | :show-all-levels="false"
|
| | | />
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item label="手机号" prop="mobile">
|
| | | <el-input v-model="dialogForm.mobile" style="width: 200px" />
|
| | | </el-form-item>
|
| | | <el-form-item label="邮箱" prop="email">
|
| | | <el-input v-model="dialogForm.email" style="width: 200px" />
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item required label="用户状态">
|
| | | <el-radio-group v-model="dialogForm.status" style="width: 200px;">
|
| | | <el-radio label="Y">在职</el-radio>
|
| | | <el-radio label="N">离职</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item prop="post_code" label="岗位">
|
| | | <el-select
|
| | | v-model="dialogForm.post_code"
|
| | | style="width:490px"
|
| | | placeholder="请选择"
|
| | | multiple
|
| | | filterable
|
| | | clearable
|
| | | collapse-tags
|
| | | :popper-append-to-body="false"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in postArr"
|
| | | :key="item.postcode"
|
| | | :label="item.postname"
|
| | | :value="item.postcode"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | |
|
| | | <el-form-item prop="role_code" label="角色">
|
| | | <el-select
|
| | | v-model="dialogForm.role_code"
|
| | | style="width:490px"
|
| | | multiple
|
| | | filterable
|
| | | clearable
|
| | | collapse-tags
|
| | | placeholder="请选择"
|
| | | :popper-append-to-body="false"
|
| | | >
|
| | | <el-option
|
| | | v-for="item in roleArr"
|
| | | :key="item.rolecode"
|
| | | :label="item.rolename"
|
| | | :value="item.rolecode"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | | <el-form-item prop="group_code" label="班组">
|
| | | <el-select
|
| | | v-model="dialogForm.group_code"
|
| | | style="width: 490px"
|
| | | placeholder="请选择"
|
| | | :popper-append-to-body="false"
|
| | | multiple
|
| | | filterable
|
| | | collapse-tags
|
| | | clearable
|
| | | >
|
| | | <el-option
|
| | | v-for="item in groupArr"
|
| | | :key="item.usergroupcode"
|
| | | :label="item.usergroupname"
|
| | | :value="item.usergroupcode"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | |
|
| | | </el-form>
|
| | | <span slot="footer" class="dialog-footer">
|
| | | <div class="footerButton">
|
| | | <el-button v-waves @click="dialogVisibleCancel">取 消</el-button>
|
| | | <el-button
|
| | | v-waves
|
| | | type="primary"
|
| | | :loading="$store.state.app.buttonIsDisabled"
|
| | | :disabled="$store.state.app.buttonIsDisabled"
|
| | | @click="dialogVisibleConfirm"
|
| | | >确 定</el-button>
|
| | | </div>
|
| | | </span>
|
| | | </el-dialog>
|
| | |
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import Pagination from '@/components/Pagination'
|
| | | import {
|
| | | AddUpdateUserSave,
|
| | | DeleteUserSave, UserData
|
| | | } from '@/api/basicSettings'
|
| | | import { validateCode } from '@/utils/global'
|
| | | import elDragDialog from '@/directive/el-drag-dialog'
|
| | | import waves from '@/directive/waves'
|
| | | import arrayToTree from 'array-to-tree'
|
| | | import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData'
|
| | |
|
| | | export default {
|
| | | name: 'PersonList',
|
| | | components: {
|
| | | Pagination
|
| | | },
|
| | | directives: { elDragDialog, waves },
|
| | | data() {
|
| | | const validateMobile = (rule, value, callback) => {
|
| | | if (!value) {
|
| | | callback()
|
| | | // return callback(new Error('请输入电话号码'))
|
| | | } else {
|
| | | const mobile = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ // 长号
|
| | | const mobile2 = /^[0-9]{6}$/ // 短号
|
| | | if (mobile.test(value) || mobile2.test(value)) {
|
| | | callback()
|
| | | // return callback(new Error('电话号码不符合规则'))
|
| | | } else {
|
| | | return callback(new Error('电话号码不符合规则'))
|
| | | // callback()
|
| | | }
|
| | | }
|
| | | }
|
| | | const validateEmail = (rule, value, callback) => {
|
| | | if (!value) {
|
| | | callback()
|
| | | // return callback(new Error('请输入电子邮箱'))
|
| | | } else {
|
| | | const email = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/
|
| | | if (email.test(value)) {
|
| | | callback()
|
| | | } else {
|
| | | return callback(new Error('电子邮箱不符合规则'))
|
| | | }
|
| | | }
|
| | | }
|
| | | return {
|
| | | mouseHoverType: 'mouseout',
|
| | | isExpandForm: false,
|
| | | mainHeight: 0,
|
| | | tableHeight: 0,
|
| | | form: {
|
| | | usercode: '',
|
| | | username: '',
|
| | | storgcode: '', // 组织编码
|
| | | prop: 'lm_date', // 排序字段
|
| | | order: 'desc', // 排序字段
|
| | | page: 1, // 第几页
|
| | | rows: 20 // 每页多少条
|
| | | },
|
| | | total: 10,
|
| | | tableData: [],
|
| | | dialogVisible: false,
|
| | | dialogForm: {
|
| | | usercode: '', // 用户编码
|
| | | username: '', // 用户名称
|
| | | post_code: [], // 岗位
|
| | | role_code: [], // 角色
|
| | | group_code: [], // 班组
|
| | | password: '123456', // 密码
|
| | | storg_code: '', // 所属组织
|
| | | mobile: '', // 号码
|
| | | email: '', // 邮箱
|
| | | status: 'Y'// 状态
|
| | | },
|
| | | operation: '',
|
| | | dialogFormRules: {
|
| | | usercode: [
|
| | | { required: true, validator: validateCode, trigger: ['blur', 'change'] }
|
| | | ],
|
| | | username: [
|
| | | { required: true, message: '请输入组织名称', trigger: ['blur', 'change'] }
|
| | | ],
|
| | | password: [
|
| | | { required: true, message: '请输入用户密码', trigger: ['blur', 'change'] }
|
| | | ],
|
| | | mobile: [
|
| | | { required: false, validator: validateMobile, trigger: ['blur', 'change'] }
|
| | | ],
|
| | | email: [
|
| | | { required: false, validator: validateEmail, trigger: ['blur', 'change'] }
|
| | | ],
|
| | | storg_code: [
|
| | | { required: true, message: '请选择所属组织', trigger: ['blur', 'change'] }
|
| | | ]
|
| | | },
|
| | | defaultProps: {
|
| | | checkStrictly: true,
|
| | | expandTrigger: 'hover',
|
| | | value: 'torg_code',
|
| | | label: 'torg_name'
|
| | | },
|
| | | Options: [],
|
| | | cascaderOptions: [],
|
| | |
|
| | | postArr: [],
|
| | | roleArr: [],
|
| | | groupArr: [],
|
| | |
|
| | | defaultPropsLeft: {
|
| | | children: 'children',
|
| | | label: 'torg_name'
|
| | | },
|
| | | treeLeft: []
|
| | |
|
| | | }
|
| | | },
|
| | | activated() {
window.addEventListener('resize', this.getHeight)
this.getHeight()
},
created() {
|
| | | this.getUserData()
|
| | | },
|
| | | mounted() {
|
| | | window.addEventListener('resize', this.getHeight)
|
| | | this.getHeight()
|
| | |
|
| | | this.getPrentOrganization()
|
| | | this.getAllSelectData()
|
| | | },
|
| | | methods: {
|
| | | // 组织架构大列表查询
|
| | | async getUserData() {
|
| | | const res = await UserData(this.form)
|
| | | this.tableData = res.data
|
| | | this.total = res.count
|
| | | },
|
| | | // 组织架构级联选择器
|
| | | async getPrentOrganization() {
|
| | | const { data: res } = await PrentOrganization()
|
| | | this.Options = res
|
| | | this.cascaderOptions = arrayToTree(res, {
|
| | | parentProperty: 'parent_id',
|
| | | customID: 'torg_code',
|
| | | childrenProperty: 'children'
|
| | | })
|
| | | this.$nextTick(() => {
|
| | | this.treeLeft = this.cascaderOptions
|
| | | this.$forceUpdate()
|
| | | })
|
| | | },
|
| | | // 岗位 角色 班组
|
| | | async getAllSelectData() {
|
| | | const { data: res1 } = await PostPermissions()
|
| | | this.postArr = res1
|
| | |
|
| | | const { data: res2 } = await RolePermissions()
|
| | | this.roleArr = res2
|
| | |
|
| | | const { data: res3 } = await GroupsPermissions()
|
| | | this.groupArr = res3
|
| | | },
|
| | |
|
| | | // 排序改变时
|
| | | sortChange({ column, prop, order }) {
|
| | | if (order === 'descending') {
|
| | | order = 'desc'
|
| | | } else if (order === 'ascending') {
|
| | | order = 'asc'
|
| | | } else {
|
| | | order = 'desc'
|
| | | }
|
| | | this.form.order = order
|
| | | this.form.prop = prop
|
| | | this.getUserData()
|
| | | },
|
| | | nodeClick(obj, Node, VueComponent) {
|
| | | this.form.storgcode = obj.torg_code
|
| | | this.getUserData()
|
| | | },
|
| | | // 重置
|
| | | reset() {
|
| | | this.form.usercode = ''
|
| | | this.form.username = ''
|
| | | this.form.storgcode = ''
|
| | | this.$refs.treeLeftRef.setCurrentKey(null)
|
| | | this.getUserData()
|
| | | },
|
| | | // 新增按钮
|
| | | add(operation) {
|
| | | this.operation = operation
|
| | | this.dialogVisible = true
|
| | | this.dialogForm.OperType = 'Add'
|
| | | },
|
| | | // 修改按钮
|
| | | async edit(operation, row) {
|
| | | this.operation = operation
|
| | | this.dialogVisible = true
|
| | | this.dialogForm.OperType = 'Update'
|
| | |
|
| | | // this.cascaderOptions = this.filterChildren(this.cascaderOptions, row.storg_code)
|
| | | this.$nextTick(() => {
|
| | | this.dialogForm.usercode = row.usercode
|
| | | this.dialogForm.username = row.username
|
| | | this.dialogForm.password = row.password
|
| | | this.dialogForm.mobile = row.mobile
|
| | | this.dialogForm.email = row.email
|
| | | this.dialogForm.status = row.status
|
| | | this.dialogForm.storg_code = this.findParent([], row.storg_code, this.cascaderOptions).reverse()
|
| | |
|
| | | this.dialogForm.post_code = row.post_code ? row.post_code.split(',') : []
|
| | | this.dialogForm.role_code = row.role_code ? row.role_code.split(',') : []
|
| | | this.dialogForm.group_code = row.group_code ? row.group_code.split(',') : []
|
| | | })
|
| | | },
|
| | | filterChildren(treeData, code) {
|
| | | treeData.forEach(item => {
|
| | | if (code.split(',').includes(item.torg_code)) {
|
| | | item.disabled = true
|
| | | if (item.children && item.children.length > 0) {
|
| | | this.filterChildren(item.children, item.children.map(it => it.torg_code).join(','))
|
| | | }
|
| | | } else {
|
| | | if (item.children && item.children.length > 0) {
|
| | | this.filterChildren(item.children, code)
|
| | | }
|
| | | }
|
| | | })
|
| | | return treeData
|
| | | },
|
| | | // parents:用于返回的数组,childNode:要查询的节点,treeData:json树形数据
|
| | | findParent(parents, childNode, treeData) {
|
| | | // console.log(parents, childNode, treeData, 2)
|
| | |
|
| | | for (let i = 0; i < treeData.length; i++) {
|
| | | // 父节点查询条件
|
| | | if (treeData[i].torg_code === childNode) {
|
| | | // 如果找到结果,保存当前节点
|
| | | parents.push(treeData[i].torg_code)
|
| | | // 用当前节点再去原数据查找当前节点的父节点
|
| | | this.findParent(parents, treeData[i].parent_id, this.cascaderOptions)
|
| | | break
|
| | | } else {
|
| | | if (treeData[i].children instanceof Array) {
|
| | | // 没找到,遍历该节点的子节点
|
| | | this.findParent(parents, childNode, treeData[i].children)
|
| | | }
|
| | | }
|
| | | }
|
| | | return parents
|
| | | },
|
| | | // 删除按钮
|
| | | async del(row) {
|
| | | this.$confirm('是否确认删除?', '提示', {
|
| | | confirmButtonText: '确定',
|
| | | cancelButtonText: '取消',
|
| | | type: 'warning'
|
| | | }).then(() => {
|
| | | DeleteUserSave({ usercode: row.usercode }).then(res => {
|
| | | if (res.code === '200') {
|
| | | this.$notify.success('删除成功!')
|
| | | if (this.form.page > 1 && this.tableData.length === 1) {
|
| | | this.form.page--
|
| | | }
|
| | | this.getUserData()
|
| | | }
|
| | | })
|
| | | }).catch(() => {
|
| | | this.$notify.info('已取消删除')
|
| | | })
|
| | | },
|
| | | // 对话框关闭事件
|
| | | handleClose() {
|
| | | this.dialogForm.usercode = ''
|
| | | this.dialogForm.username = ''
|
| | | this.dialogForm.status = 'Y'
|
| | |
|
| | | this.dialogForm.post_code = []
|
| | | this.dialogForm.role_code = []
|
| | | this.dialogForm.group_code = []
|
| | | this.dialogForm.password = '123456'
|
| | | this.dialogForm.mobile = ''
|
| | | this.dialogForm.email = ''
|
| | |
|
| | | // this.dialogForm.storg_code = ''
|
| | |
|
| | | this.$refs.cascader.checkedValue = ''
|
| | | this.$refs.dialogForm.clearValidate()
|
| | | },
|
| | | // 对话框取消
|
| | | dialogVisibleCancel() {
|
| | | this.dialogVisible = false
|
| | | },
|
| | | // 对话框确认
|
| | | dialogVisibleConfirm() {
|
| | | this.$refs.dialogForm.validate(valid => {
|
| | | if (valid) {
|
| | | this.$store.state.app.buttonIsDisabled = true
|
| | | this.dialogForm.group_code = this.dialogForm.group_code.join(',')
|
| | | this.dialogForm.post_code = this.dialogForm.post_code.join(',')
|
| | | this.dialogForm.role_code = this.dialogForm.role_code.join(',')
|
| | | this.dialogForm.storg_code = this.dialogForm.storg_code[this.dialogForm.storg_code.length - 1]
|
| | | AddUpdateUserSave(this.dialogForm).then(res => {
|
| | | if (res.code === '200') {
|
| | | this.$notify.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
|
| | | this.dialogVisible = false
|
| | | this.$store.state.app.buttonIsDisabled = false
|
| | | this.getUserData()
|
| | | } else {
|
| | | this.$store.state.app.buttonIsDisabled = false
|
| | | this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
|
| | | }
|
| | | })
|
| | | }
|
| | | })
|
| | | },
|
| | | // 获取页面高度
|
| | | getHeight() {
|
| | | this.$nextTick(() => {
|
| | | this.mainHeight = window.innerHeight - 85
|
| | | this.tableHeight = this.mainHeight - 280
|
| | | this.$refs.tableDataRef.doLayout()
|
| | | })
|
| | | }
|
| | | }
|
| | | }
|
| | | </script>
|
| | | <template> |
| | | <div> |
| | | <div class="body" :style="{height:mainHeight+'px'}"> |
| | | <div style="display: flex"> |
| | | <!-- background:rgba(248,248,250,1);--> |
| | | <div style="width: 220px;margin: 10px 10px 0 0;background: #fff"> |
| | | |
| | | <div style="margin: 20px 10px 0 10px;display: flex;justify-content: space-between;"> |
| | | <div style="display: flex;"> |
| | | <div |
| | | style="width: 5px;height: 100%;border-radius: 5px;" |
| | | :style="{background:$store.state.settings.theme}" |
| | | /> |
| | | <div style="margin-left: 8px;">组织架构</div> |
| | | </div> |
| | | |
| | | <!-- <div style="margin-right:10px">--> |
| | | <!-- <i class="el-icon-plus" style="cursor: pointer;color: #999" />--> |
| | | <!-- </div>--> |
| | | |
| | | </div> |
| | | |
| | | <el-tree |
| | | ref="treeLeftRef" |
| | | key="treeLeftKey" |
| | | style="padding: 10px;overflow: auto;" |
| | | :style="{height:(tableHeight+180)+'px'}" |
| | | :data="treeLeft" |
| | | node-key="torg_code" |
| | | highlight-current |
| | | :props="defaultPropsLeft" |
| | | :default-expand-all="true" |
| | | :expand-on-click-node="false" |
| | | @node-click="nodeClick" |
| | | /> |
| | | |
| | | </div> |
| | | |
| | | <div style="width: calc(100% - 220px)"> |
| | | <div class="bodyTopButtonGroup" style="justify-content: space-between"> |
| | | <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button> |
| | | <el-button v-waves type="success" icon="el-icon-download" @click="$router.push('./../systemSetting/dataImport?fileCode=3')">导入</el-button> |
| | | </div> |
| | | |
| | | <div class="bodyTopFormGroup"> |
| | | <el-form |
| | | ref="form" |
| | | :model="form" |
| | | label-width="100px" |
| | | inline |
| | | style="display: flex;" |
| | | > |
| | | <div class="elForm"> |
| | | <el-form-item label="用户编码" style=" display: flex;"> |
| | | <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" style=" display: flex;"> |
| | | <el-input v-model="form.username" placeholder="请输入" style="width: 200px" /> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="用户编码" style=" display: flex;">--> |
| | | <!-- <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item v-show="isExpandForm" label="用户名称" style=" display: flex;">--> |
| | | <!-- <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item v-show="isExpandForm" label="用户编码" style=" display: flex;">--> |
| | | <!-- <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item v-show="isExpandForm" label="用户名称" style=" display: flex;">--> |
| | | <!-- <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item v-show="isExpandForm" label="用户编码" style=" display: flex;">--> |
| | | <!-- <el-input v-model="form.usercode" placeholder="请输入" style="width: 200px" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item v-show="isExpandForm" label="用户名称" style=" display: flex;">--> |
| | | <!-- <el-input v-model="form.username" placeholder="请输入" style="width: 200px" />--> |
| | | <!-- </el-form-item>--> |
| | | </div> |
| | | <div |
| | | class="bodySearchReset" |
| | | :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}" |
| | | > |
| | | <el-button v-waves type="primary" icon="el-icon-search" @click="getUserData">查询</el-button> |
| | | <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">重置</el-button> |
| | | </div> |
| | | </el-form> |
| | | <div |
| | | class="bodyTopFormExpand" |
| | | style="height: 5px;" |
| | | > |
| | | <!-- <svg-icon--> |
| | | <!-- v-show="mouseHoverType==='mouseout'"--> |
| | | <!-- style="cursor: pointer"--> |
| | | <!-- :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"--> |
| | | <!-- @mouseenter="mouseHoverType=$event.type"--> |
| | | <!-- />--> |
| | | <!-- <svg-icon--> |
| | | <!-- v-show="mouseHoverType==='mouseenter'"--> |
| | | <!-- style="cursor: pointer"--> |
| | | <!-- :icon-class="!isExpandForm?'doubleDown':'doubleUp'"--> |
| | | <!-- @click="isExpandForm=!isExpandForm"--> |
| | | <!-- @mouseout="mouseHoverType=$event.type"--> |
| | | <!-- />--> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="elTableDiv"> |
| | | <el-table |
| | | ref="tableDataRef" |
| | | class="tableFixed" |
| | | :data="tableData" |
| | | :height="isExpandForm?tableHeight:(tableHeight+80)+'px'" |
| | | border |
| | | row-class-name="custom-row" |
| | | :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+80)+'px',}" |
| | | highlight-current-row |
| | | :header-cell-style="this.$headerCellStyle" |
| | | :cell-style="this.$cellStyle" |
| | | @sort-change="sortChange" |
| | | > |
| | | <el-table-column |
| | | prop="rowNum" |
| | | width="50" |
| | | fixed |
| | | label="序号" |
| | | /> |
| | | <el-table-column |
| | | prop="usercode" |
| | | label="用户编码" |
| | | sortable="custom" |
| | | min-width="105" |
| | | show-overflow-tooltip |
| | | /> |
| | | <el-table-column |
| | | prop="username" |
| | | label="用户名称" |
| | | min-width="105" |
| | | sortable="custom" |
| | | show-overflow-tooltip |
| | | /> |
| | | <el-table-column |
| | | prop="storg_name" |
| | | label="所属组织" |
| | | min-width="105" |
| | | show-overflow-tooltip |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <div v-if="row.storg_name">{{ row.storg_name }}</div> |
| | | <div v-else>/</div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="status" |
| | | min-width="105" |
| | | label="状态" |
| | | show-overflow-tooltip |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-tag v-if="row.status==='Y'" size="small" type="success">在职</el-tag> |
| | | <el-tag v-if="row.status==='N'" size="small" type="danger">离职</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column |
| | | prop="payrate" |
| | | min-width="105" |
| | | label="薪资类型" |
| | | show-overflow-tooltip |
| | | sortable="custom" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.payrate ? PayRateArr.find(i=>i.code === row.payrate).name : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column |
| | | prop="email" |
| | | label="邮箱" |
| | | min-width="105" |
| | | sortable="custom" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.email ? row.email : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="mobile" |
| | | label="号码" |
| | | min-width="105" |
| | | sortable="custom" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.mobile ? row.mobile : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="postname" |
| | | label="岗位" |
| | | sortable="custom" |
| | | min-width="105" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.postname ? row.postname : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="rolename" |
| | | label="角色" |
| | | sortable="custom" |
| | | min-width="105" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.rolename ? row.rolename : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="group_name" |
| | | label="班组" |
| | | min-width="105" |
| | | sortable="custom" |
| | | show-overflow-tooltip |
| | | > |
| | | <template slot-scope="{row}"> |
| | | {{ row.group_name ? row.group_name : '/' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="createusername" |
| | | label="创建人员" |
| | | sortable="custom" |
| | | min-width="105" |
| | | /> |
| | | <el-table-column |
| | | prop="lm_date" |
| | | label="创建时间" |
| | | width="160" |
| | | sortable="custom" |
| | | /> |
| | | <el-table-column |
| | | label="操作" |
| | | width="80" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <div class="operationClass"> |
| | | <el-tooltip class="item" effect="dark" content="编辑" placement="top"> |
| | | <i |
| | | v-if="row.usercode!=='9999'" |
| | | class="el-icon-edit-outline" |
| | | :style="{color:$store.state.settings.theme}" |
| | | @click="edit('edit',row)" |
| | | /> |
| | | </el-tooltip> |
| | | <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top"> |
| | | <i |
| | | v-if="row.usercode!=='9999'" |
| | | class="el-icon-delete" |
| | | :style="{color:$store.state.settings.theme}" |
| | | @click="del(row)" |
| | | /> |
| | | </el-tooltip> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | <!--分页--> |
| | | <pagination |
| | | :total="total" |
| | | :page.sync="form.page" |
| | | :limit.sync="form.rows" |
| | | align="right" |
| | | layout="total,prev, pager, next,sizes,jumper" |
| | | popper-class="select_bottom" |
| | | @pagination="getUserData" |
| | | /> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <el-dialog |
| | | v-el-drag-dialog |
| | | :title="operation==='add'?'新增':'编辑'" |
| | | :visible.sync="dialogVisible" |
| | | width="800px" |
| | | :close-on-click-modal="false" |
| | | top="15vh" |
| | | @closed="handleClose" |
| | | @close="handleClose" |
| | | > |
| | | <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px"> |
| | | <el-form-item label="用户编码" prop="usercode"> |
| | | <el-input v-model="dialogForm.usercode" :disabled="operation!=='add'" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="用户名称" prop="username"> |
| | | <el-input v-model="dialogForm.username" style="width: 200px" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="用户密码" prop="password"> |
| | | <el-input v-model="dialogForm.password" style="width: 200px" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="所属组织" prop="storg_code"> |
| | | <el-cascader |
| | | ref="cascader" |
| | | v-model="dialogForm.storg_code" |
| | | :options="cascaderOptions" |
| | | filterable |
| | | :props="defaultProps" |
| | | :show-all-levels="false" |
| | | /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="手机号" prop="mobile"> |
| | | <el-input v-model="dialogForm.mobile" style="width: 200px" /> |
| | | </el-form-item> |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="dialogForm.email" style="width: 200px" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item required label="用户状态"> |
| | | <el-radio-group v-model="dialogForm.status" style="width: 200px;"> |
| | | <el-radio label="Y">在职</el-radio> |
| | | <el-radio label="N">离职</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | |
| | | <el-form-item prop="payrate" label="薪资类型"> |
| | | <el-select |
| | | v-model="dialogForm.payrate" |
| | | style="width:200px" |
| | | placeholder="请选择" |
| | | :popper-append-to-body="false" |
| | | > |
| | | <el-option |
| | | v-for="item in PayRateArr" |
| | | :key="item.code" |
| | | :label="item.name" |
| | | :value="item.code" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item prop="post_code" label="岗位"> |
| | | <el-select |
| | | v-model="dialogForm.post_code" |
| | | style="width:490px" |
| | | placeholder="请选择" |
| | | multiple |
| | | filterable |
| | | clearable |
| | | collapse-tags |
| | | :popper-append-to-body="false" |
| | | > |
| | | <el-option |
| | | v-for="item in postArr" |
| | | :key="item.postcode" |
| | | :label="item.postname" |
| | | :value="item.postcode" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item prop="role_code" label="角色"> |
| | | <el-select |
| | | v-model="dialogForm.role_code" |
| | | style="width:490px" |
| | | multiple |
| | | filterable |
| | | clearable |
| | | collapse-tags |
| | | placeholder="请选择" |
| | | :popper-append-to-body="false" |
| | | > |
| | | <el-option |
| | | v-for="item in roleArr" |
| | | :key="item.rolecode" |
| | | :label="item.rolename" |
| | | :value="item.rolecode" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item prop="group_code" label="班组"> |
| | | <el-select |
| | | v-model="dialogForm.group_code" |
| | | style="width: 490px" |
| | | placeholder="请选择" |
| | | :popper-append-to-body="false" |
| | | multiple |
| | | filterable |
| | | collapse-tags |
| | | clearable |
| | | > |
| | | <el-option |
| | | v-for="item in groupArr" |
| | | :key="item.usergroupcode" |
| | | :label="item.usergroupname" |
| | | :value="item.usergroupcode" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <div class="footerButton"> |
| | | <el-button v-waves @click="dialogVisibleCancel">取 消</el-button> |
| | | <el-button |
| | | v-waves |
| | | type="primary" |
| | | :loading="$store.state.app.buttonIsDisabled" |
| | | :disabled="$store.state.app.buttonIsDisabled" |
| | | @click="dialogVisibleConfirm" |
| | | >确 定</el-button> |
| | | </div> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import Pagination from '@/components/Pagination' |
| | | import { |
| | | AddUpdateUserSave, |
| | | DeleteUserSave, UserData |
| | | } from '@/api/basicSettings' |
| | | import { validateCode } from '@/utils/global' |
| | | import elDragDialog from '@/directive/el-drag-dialog' |
| | | import waves from '@/directive/waves' |
| | | import arrayToTree from 'array-to-tree' |
| | | import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData' |
| | | |
| | | export default { |
| | | name: 'PersonList', |
| | | components: { |
| | | Pagination |
| | | }, |
| | | directives: { elDragDialog, waves }, |
| | | data() { |
| | | const validateMobile = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback() |
| | | // return callback(new Error('请输入电话号码')) |
| | | } else { |
| | | const mobile = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ // 长号 |
| | | const mobile2 = /^[0-9]{6}$/ // 短号 |
| | | if (mobile.test(value) || mobile2.test(value)) { |
| | | callback() |
| | | // return callback(new Error('电话号码不符合规则')) |
| | | } else { |
| | | return callback(new Error('电话号码不符合规则')) |
| | | // callback() |
| | | } |
| | | } |
| | | } |
| | | const validateEmail = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback() |
| | | // return callback(new Error('请输入电子邮箱')) |
| | | } else { |
| | | const email = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/ |
| | | if (email.test(value)) { |
| | | callback() |
| | | } else { |
| | | return callback(new Error('电子邮箱不符合规则')) |
| | | } |
| | | } |
| | | } |
| | | return { |
| | | mouseHoverType: 'mouseout', |
| | | isExpandForm: false, |
| | | mainHeight: 0, |
| | | tableHeight: 0, |
| | | form: { |
| | | usercode: '', |
| | | username: '', |
| | | storgcode: '', // 组织编码 |
| | | prop: 'lm_date', // 排序字段 |
| | | order: 'desc', // 排序字段 |
| | | page: 1, // 第几页 |
| | | rows: 20 // 每页多少条 |
| | | }, |
| | | total: 10, |
| | | tableData: [], |
| | | dialogVisible: false, |
| | | dialogForm: { |
| | | usercode: '', // 用户编码 |
| | | username: '', // 用户名称 |
| | | post_code: [], // 岗位 |
| | | role_code: [], // 角色 |
| | | group_code: [], // 班组 |
| | | password: '123456', // 密码 |
| | | storg_code: '', // 所属组织 |
| | | mobile: '', // 号码 |
| | | email: '', // 邮箱 |
| | | status: 'Y', // 状态 |
| | | payrate: ''// 薪资类型 |
| | | }, |
| | | operation: '', |
| | | dialogFormRules: { |
| | | usercode: [ |
| | | { required: true, validator: validateCode, trigger: ['blur', 'change'] } |
| | | ], |
| | | username: [ |
| | | { required: true, message: '请输入组织名称', trigger: ['blur', 'change'] } |
| | | ], |
| | | password: [ |
| | | { required: true, message: '请输入用户密码', trigger: ['blur', 'change'] } |
| | | ], |
| | | mobile: [ |
| | | { required: false, validator: validateMobile, trigger: ['blur', 'change'] } |
| | | ], |
| | | email: [ |
| | | { required: false, validator: validateEmail, trigger: ['blur', 'change'] } |
| | | ], |
| | | storg_code: [ |
| | | { required: true, message: '请选择所属组织', trigger: ['blur', 'change'] } |
| | | ], |
| | | payrate: [ |
| | | { required: true, message: '请选择薪资类型', trigger: ['blur', 'change'] } |
| | | ] |
| | | }, |
| | | defaultProps: { |
| | | checkStrictly: true, |
| | | expandTrigger: 'hover', |
| | | value: 'torg_code', |
| | | label: 'torg_name' |
| | | }, |
| | | Options: [], |
| | | cascaderOptions: [], |
| | | |
| | | postArr: [], |
| | | roleArr: [], |
| | | groupArr: [], |
| | | PayRateArr: [ |
| | | { code: 'S', name: '计件' }, |
| | | { code: 'T', name: '计时' }, |
| | | { code: 'M', name: '按月' } |
| | | ], |
| | | |
| | | defaultPropsLeft: { |
| | | children: 'children', |
| | | label: 'torg_name' |
| | | }, |
| | | treeLeft: [] |
| | | |
| | | } |
| | | }, |
| | | activated() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | }, |
| | | created() { |
| | | this.getUserData() |
| | | }, |
| | | mounted() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | |
| | | this.getPrentOrganization() |
| | | this.getAllSelectData() |
| | | }, |
| | | methods: { |
| | | // 组织架构大列表查询 |
| | | async getUserData() { |
| | | const res = await UserData(this.form) |
| | | this.tableData = res.data |
| | | this.total = res.count |
| | | }, |
| | | // 组织架构级联选择器 |
| | | async getPrentOrganization() { |
| | | const { data: res } = await PrentOrganization() |
| | | this.Options = res |
| | | this.cascaderOptions = arrayToTree(res, { |
| | | parentProperty: 'parent_id', |
| | | customID: 'torg_code', |
| | | childrenProperty: 'children' |
| | | }) |
| | | this.$nextTick(() => { |
| | | this.treeLeft = this.cascaderOptions |
| | | this.$forceUpdate() |
| | | }) |
| | | }, |
| | | // 岗位 角色 班组 |
| | | async getAllSelectData() { |
| | | const { data: res1 } = await PostPermissions() |
| | | this.postArr = res1 |
| | | |
| | | const { data: res2 } = await RolePermissions() |
| | | this.roleArr = res2 |
| | | |
| | | const { data: res3 } = await GroupsPermissions() |
| | | this.groupArr = res3 |
| | | }, |
| | | |
| | | // 排序改变时 |
| | | sortChange({ column, prop, order }) { |
| | | if (order === 'descending') { |
| | | order = 'desc' |
| | | } else if (order === 'ascending') { |
| | | order = 'asc' |
| | | } else { |
| | | order = 'desc' |
| | | } |
| | | this.form.order = order |
| | | this.form.prop = prop |
| | | this.getUserData() |
| | | }, |
| | | nodeClick(obj, Node, VueComponent) { |
| | | this.form.storgcode = obj.torg_code |
| | | this.getUserData() |
| | | }, |
| | | // 重置 |
| | | reset() { |
| | | this.form.usercode = '' |
| | | this.form.username = '' |
| | | this.form.storgcode = '' |
| | | this.$refs.treeLeftRef.setCurrentKey(null) |
| | | this.getUserData() |
| | | }, |
| | | // 新增按钮 |
| | | add(operation) { |
| | | this.operation = operation |
| | | this.dialogVisible = true |
| | | this.dialogForm.OperType = 'Add' |
| | | }, |
| | | // 修改按钮 |
| | | async edit(operation, row) { |
| | | this.operation = operation |
| | | this.dialogVisible = true |
| | | this.dialogForm.OperType = 'Update' |
| | | |
| | | // this.cascaderOptions = this.filterChildren(this.cascaderOptions, row.storg_code) |
| | | this.$nextTick(() => { |
| | | this.dialogForm.usercode = row.usercode |
| | | this.dialogForm.username = row.username |
| | | this.dialogForm.password = row.password |
| | | this.dialogForm.mobile = row.mobile |
| | | this.dialogForm.email = row.email |
| | | this.dialogForm.status = row.status |
| | | this.dialogForm.payrate = row.payrate |
| | | this.dialogForm.storg_code = this.findParent([], row.storg_code, this.cascaderOptions).reverse() |
| | | |
| | | this.dialogForm.post_code = row.post_code ? row.post_code.split(',') : [] |
| | | this.dialogForm.role_code = row.role_code ? row.role_code.split(',') : [] |
| | | this.dialogForm.group_code = row.group_code ? row.group_code.split(',') : [] |
| | | }) |
| | | }, |
| | | filterChildren(treeData, code) { |
| | | treeData.forEach(item => { |
| | | if (code.split(',').includes(item.torg_code)) { |
| | | item.disabled = true |
| | | if (item.children && item.children.length > 0) { |
| | | this.filterChildren(item.children, item.children.map(it => it.torg_code).join(',')) |
| | | } |
| | | } else { |
| | | if (item.children && item.children.length > 0) { |
| | | this.filterChildren(item.children, code) |
| | | } |
| | | } |
| | | }) |
| | | return treeData |
| | | }, |
| | | // parents:用于返回的数组,childNode:要查询的节点,treeData:json树形数据 |
| | | findParent(parents, childNode, treeData) { |
| | | // console.log(parents, childNode, treeData, 2) |
| | | |
| | | for (let i = 0; i < treeData.length; i++) { |
| | | // 父节点查询条件 |
| | | if (treeData[i].torg_code === childNode) { |
| | | // 如果找到结果,保存当前节点 |
| | | parents.push(treeData[i].torg_code) |
| | | // 用当前节点再去原数据查找当前节点的父节点 |
| | | this.findParent(parents, treeData[i].parent_id, this.cascaderOptions) |
| | | break |
| | | } else { |
| | | if (treeData[i].children instanceof Array) { |
| | | // 没找到,遍历该节点的子节点 |
| | | this.findParent(parents, childNode, treeData[i].children) |
| | | } |
| | | } |
| | | } |
| | | return parents |
| | | }, |
| | | // 删除按钮 |
| | | async del(row) { |
| | | this.$confirm('是否确认删除?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | DeleteUserSave({ usercode: row.usercode }).then(res => { |
| | | if (res.code === '200') { |
| | | this.$notify.success('删除成功!') |
| | | if (this.form.page > 1 && this.tableData.length === 1) { |
| | | this.form.page-- |
| | | } |
| | | this.getUserData() |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | this.$notify.info('已取消删除') |
| | | }) |
| | | }, |
| | | // 对话框关闭事件 |
| | | handleClose() { |
| | | this.dialogForm.usercode = '' |
| | | this.dialogForm.username = '' |
| | | this.dialogForm.status = 'Y' |
| | | |
| | | this.dialogForm.post_code = [] |
| | | this.dialogForm.role_code = [] |
| | | this.dialogForm.group_code = [] |
| | | this.dialogForm.password = '123456' |
| | | this.dialogForm.mobile = '' |
| | | this.dialogForm.email = '' |
| | | this.dialogForm.payrate = '' |
| | | |
| | | // this.dialogForm.storg_code = '' |
| | | |
| | | this.$refs.cascader.checkedValue = '' |
| | | this.$refs.dialogForm.clearValidate() |
| | | }, |
| | | // 对话框取消 |
| | | dialogVisibleCancel() { |
| | | this.dialogVisible = false |
| | | }, |
| | | // 对话框确认 |
| | | dialogVisibleConfirm() { |
| | | this.$refs.dialogForm.validate(valid => { |
| | | if (valid) { |
| | | this.$store.state.app.buttonIsDisabled = true |
| | | this.dialogForm.group_code = this.dialogForm.group_code.join(',') |
| | | this.dialogForm.post_code = this.dialogForm.post_code.join(',') |
| | | this.dialogForm.role_code = this.dialogForm.role_code.join(',') |
| | | this.dialogForm.storg_code = this.dialogForm.storg_code[this.dialogForm.storg_code.length - 1] |
| | | AddUpdateUserSave(this.dialogForm).then(res => { |
| | | if (res.code === '200') { |
| | | this.$notify.success(this.operation === 'add' ? '添加成功!' : '修改成功!') |
| | | this.dialogVisible = false |
| | | this.$store.state.app.buttonIsDisabled = false |
| | | this.getUserData() |
| | | } else { |
| | | this.$store.state.app.buttonIsDisabled = false |
| | | this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!') |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // 获取页面高度 |
| | | getHeight() { |
| | | this.$nextTick(() => { |
| | | this.mainHeight = window.innerHeight - 85 |
| | | this.tableHeight = this.mainHeight - 280 |
| | | this.$refs.tableDataRef.doLayout() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |