12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583 |
- <template>
- <div class="userRights">
- <float-panels title="浮动窗口" />
-
- <div class="filteroption">
- <div class="data_box">
- <input-item
- can-clear
- type="text"
- placeholder="请输入用户名"
- title="用户名:"
- nominate="realName"
- custom-style="display: inline-block;width:200px;margin-right:8px;"
- :value="realName"
- :max-length="50"
- :disabled="false"
- :required="false"
- @changeValue="onInput"
- />
- <input-item
- can-clear
- type="text"
- placeholder="请输入登录名"
- title="登录名:"
- nominate="username"
- custom-style="display: inline-block;width:200px;margin-right:8px;"
- :value="username"
- :max-length="50"
- :disabled="false"
- :required="false"
- @changeValue="onInput"
- />
- <div class="input_item">
- <span class="span_item">所属公司:</span>
- <el-cascader
- placeholder="请选择公司"
- size="small"
- custom-style="display: inline-block"
- :options="companyOptions"
- :value="companyId"
- :show-all-levels="false"
- :props="{ checkStrictly: true }"
- clearable
- @change="companyChange"
- />
- </div>
- <div class="input_item">
- <span class="span_item">所属部门:</span>
- <el-cascader
- placeholder="请选择部门"
- size="small"
- :show-all-levels="false"
- :options="deptOptions"
- :value="departmentId"
- :props="{ checkStrictly: true }"
- clearable
- @change="companyDept"
- />
- </div>
- <select-item
- can-clear
- placeholder="请选择启用状态"
- title="启用状态:"
- nominate="enableFlag"
- custom-style="display: inline-block;width:180px;margin-right:8px;"
- :value="enableFlag"
- :disabled="false"
- :required="false"
- :filterable="true"
- :options="statusOptions"
- @changeSelectValue="changeSelectValue"
- />
- <select-item
- can-clear
- placeholder="请选择锁定状态"
- title="锁定状态:"
- nominate="lockFlag"
- custom-style="display: inline-block;width:180px;margin-right:8px;"
- :value="lockFlag"
- :disabled="false"
- :required="false"
- :filterable="true"
- :options="lockOptions"
- @changeSelectValue="changeSelectValue"
- />
- <select-item
- can-clear
- placeholder="请选择审核状态"
- title="审核状态:"
- nominate="auditStatus"
- custom-style="display: inline-block;width:180px;"
- :value="auditStatus"
- :disabled="false"
- :required="false"
- :filterable="true"
- :options="auditOptions"
- @changeSelectValue="changeSelectValue"
- />
- </div>
- <div class="btn_box">
- <el-button type="primary" size="small" @click="onSubmit">查询用户</el-button>
-
- <el-button type="primary" size="small" @click="handleAdded">新增用户</el-button>
-
- <el-button :disabled="disabledEdit" type="primary" size="small" @click="handleEdit">修改用户</el-button>
- <el-button type="primary" size="small" :disabled="multipleSelection.length === 0" @click="handleManyUser">删除用户</el-button>
-
-
-
-
-
- <el-button type="primary" size="small" :disabled="multipleSelection.length === 0" @click="roleBinding">角色绑定</el-button>
- <el-button type="primary" size="small" :disabled="canAudit" @click="audit">审核</el-button>
-
- <el-button type="primary" size="small" @click="templateDownload">模版下载</el-button>
- <el-upload action="fakeaction" style="margin: 0 10px; display: inline-block" :http-request="batchImport" :show-file-list="false" :file-list="files" accept=".xls, .xlsx">
- <el-button size="small" type="primary">批量导入</el-button>
- </el-upload>
- <el-button type="primary" size="small" @click="exportDownload">导出</el-button>
-
- <el-button type="primary" size="small" :disabled="existEnableFlag" @click="handleAuthOperation('enable')">启用</el-button>
- <el-button type="primary" size="small" :disabled="existDisableFlag" @click="handleAuthOperation('disable')">禁用</el-button>
- <el-button type="primary" size="small" :disabled="existLockFlag" @click="handleAuthOperation('unlock')">解锁</el-button>
-
- <input id="file" ref="files" type="file" style="display: none;" @change="upload">
- </div>
- </div>
- <div class="tableheight">
- <table-item
- :table-data="list"
- :column="column"
- :for-id="true"
- :pagination="true"
- :pagesize="pagination.size"
- :currentpage="pagination.current"
- :border="true"
- :multiple="true"
- :total="pagination.total"
- :fixed="true"
- :isdelete="false"
- :is-select="false"
- :stripe="true"
- @handleCurrentChange="handleCurrentChange"
- @handleSizeChange="handleSizeChange"
- @handleSelectionChange="handleSelectionChange"
- @handleEdit="handleEdit"
- @rowDblclick="handleDbclick"
- />
- </div>
- <el-dialog v-dialogDrag :title="dialogTitle" :visible.sync="dialogVisible" width="800px">
- <div class="dialog_style">
- <MergeUser v-if="dialogVisible" ref="ruleForm" :data="editData" :company="departments" :tree-data="treeData" :options-role="role.optionsRole" @remind="remind" />
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="resetForm">取 消</el-button>
- <el-button type="primary" @click="submitForm">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog v-dialogDrag title="删除用户" :visible.sync="dialogDelete" width="500px">
- <span>确认是否删除用户?</span>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogDelete = false">取 消</el-button>
- <el-button type="primary" @click="confirmDelete">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog v-dialogDrag title="角色权限绑定" :visible.sync="role.roleBind" width="500px" height="300px">
- <div style="height:200px;width:100%;">
- <input-item type="text" placeholder title="用户名:" custom-style="display: inline-block; width: 80%; line-height: 32px;" :value="role.roleName" :max-length="50" :disabled="true" :required="false" />
- <SelectMultiple
- placeholder="请选择"
- title="角色复制:"
- nominate="copyRole"
- custom-style="display: inline-block; width: 80%; line-height: 32px;"
- :value="copyRole"
- :disabled="false"
- :required="false"
- :filterable="true"
- :collapsetags="true"
- :options="copyUsers"
- :clearable="true"
- @changeSelectMultipleValue="copyRoleChange"
- />
- <SelectMultiple placeholder="请选择" title="角色:" nominate="roleId" custom-style="display: inline-block; width: 80%; line-height: 32px;" :value="roleId" :disabled="false" :required="false" :filterable="true" :options="role.optionsRole" @changeSelect="MultipleValue="changeSelectMultipleValue"" />
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="role.roleBind = false">取 消</el-button>
- <el-button type="primary" @click="confirmRoleBind">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog v-if="multipleSelection.length !=0" v-dialogDrag title="审核用户" :visible.sync="auditVisible" width="500px">
- <div class="user-base-info">
- <span class="audit-title">申请信息:</span>
- <div><span>登录名:</span><span>{{ multipleSelection[0].username }}</span></div>
- <div><span>用户名:</span><span>{{ multipleSelection[0].realName }}</span></div>
- <div><span>联系电话:</span><span>{{ multipleSelection[0].phone }}</span></div>
- <div><span>邮箱:</span><span>{{ multipleSelection[0].email }}</span></div>
- <div><span>部门:</span><span>{{ multipleSelection[0].deptName }}</span></div>
- <div><span>个性签名图片:</span><img :src="multipleSelection[0].esignature"></div>
- <div><span>用户头像:</span><img :src="multipleSelection[0].avatar"></div>
- <div><span>工作岗位:</span><span>{{ multipleSelection[0].job }}</span></div>
- <div><span>工作职责:</span><span>{{ multipleSelection[0].note }}</span></div>
- <div><span>申请说明:</span><span>{{ multipleSelection[0].applystate }}</span></div>
- <div><span>申请人:</span><span>{{ multipleSelection[0].createUserName }}</span></div>
- <div><span>申请时间:</span><span>{{ multipleSelection[0].createTime }}</span></div>
- </div>
- <div class="audit-info">
- <span class="audit-title">审核信息:</span>
- <el-form ref="auditForm" :model="auditInfo" :rules="auditRules" label-position="right" label-width="100px">
- <el-form-item style="margin-bottom: 15px" label="角色复制">
- <el-select
- v-model="copyRole"
- multiple
- style="width: 300px"
- placeholder="请选择需要复制的用户角色"
- filterable
- clearable
- collapse-tags
- @change="setCopyRoleId"
- >
- <el-option v-for="item in copyUsers" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- <el-form-item label="角色:" prop="roles" style="margin-bottom: 20px">
- <el-select v-model="auditInfo.roles" style="width: 300px" multiple>
- <template v-for="item in role.optionsRole">
- <el-option :key="item.id" :value="item.id" :label="item.name" />
- </template>
- </el-select>
- </el-form-item>
- <el-form-item label="审核状态:" prop="auditStatus" style="margin-bottom: 20px">
- <el-select v-model="auditInfo.auditStatus" style="width: 300px" placeholder="请选择审核状态">
- <el-option key="0" value="0" label="不同意" />
- <el-option key="2" value="2" label="同意" />
- </el-select>
- </el-form-item>
- <el-form-item label="审核说明:">
- <el-input v-model="auditInfo.auditState" style="width: 300px" type="textarea" placeholder="请输入审核说明" />
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="handleAuditBtnClick('cancel')">取 消</el-button>
- <el-button type="primary" @click="handleAuditBtnClick('confirm')">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog title="用户详情" :visible.sync="detailDialog" append-to-body>
- <el-collapse v-model="activeNames">
- <el-collapse-item title="基本信息" name="baseInfo">
- <el-row>
- <el-col :span="12" class="base-info">
- <el-row>
- <span class="title">申请人:</span><span>{{ detailInfo.createUserName }}</span>
- </el-row>
- <el-row>
- <span class="title">申请时间:</span><span>{{ detailInfo.createTime }}</span>
- </el-row>
- <el-row>
- <span class="title">登录名:</span><span>{{ detailInfo.username }}</span>
- </el-row>
- <el-row>
- <span class="title">用户名:</span><span>{{ detailInfo.realName }}</span>
- </el-row>
- <el-row>
- <span class="title">联系电话:</span><span>{{ detailInfo.phone }}</span>
- </el-row>
- <el-row>
- <span class="title">邮箱:</span><span>{{ detailInfo.email }}</span>
- </el-row>
- <el-row>
- <span class="title">单位:</span><span>{{ detailInfo.companyname }}</span>
- </el-row>
- <el-row>
- <span class="title">部门:</span><span>{{ detailInfo.deptName }}</span>
- </el-row>
- <el-row>
- <span class="title">工作岗位:</span><span>{{ detailInfo.job }}</span>
- </el-row>
- </el-col>
- <el-col :span="12" class="base-info">
- <el-row>
- <span class="title">个性签名图片:</span>
- <img v-if="detailInfo.esignature !== null" :src="detailInfo.esignature">
- </el-row>
- <el-row>
- <span class="title">用户头像:</span>
- <img v-if="detailInfo.avatar !== null" :src="detailInfo.avatar">
- </el-row>
- <el-row>
- <span class="title">工作职责:</span><span v-html="detailInfo.jobduties" />
- </el-row>
- </el-col>
- </el-row>
- </el-collapse-item>
- <el-collapse-item title="分配权限" name="authGruop">
- <el-row class="custom-row">
- <span class="title">角色:</span><span>{{ detailInfo.roleName }}</span>
- </el-row>
- </el-collapse-item>
- <el-collapse-item title="申请信息" name="applyInfo">
- <el-row class="custom-row">
- <span class="title">申请人:</span><span>{{ detailInfo.createUserName }}</span>
- </el-row>
- <el-row class="custom-row">
- <span class="title">申请时间:</span><span>{{ detailInfo.createTime }}</span>
- </el-row>
- <el-row class="custom-row">
- <span class="title">申请说明:</span><span>{{ detailInfo.applystate }}</span>
- </el-row>
- </el-collapse-item>
- <el-collapse-item title="审核信息" name="auditInfo">
- <el-row class="custom-row">
- <span class="title">审核人:</span><span>{{ detailInfo.auditorname }}</span>
- </el-row>
- <el-row class="custom-row">
- <span class="title">审核时间:</span><span>{{ detailInfo.audittime }}</span>
- </el-row>
- <el-row class="custom-row">
- <span class="title">审核说明:</span><span>{{ detailInfo.auditstate }}</span>
- </el-row>
- <el-row class="custom-row">
- <span class="title">审核意见:</span><span>{{ detailInfo.auditstatus | formatteAuditStatus }}</span>
- </el-row>
- </el-collapse-item>
- </el-collapse>
- </el-dialog>
- </div>
- </template>
- <script>
- import TableItem from '@/components/TableAuto'
- import InputItem from '@/components/FormItem/Input'
- import SelectItem from '@/components/FormItem/Select'
- import SelectMultiple from '@/components/FormItem/SelectMultiple'
- import MergeUser from './mergeUser/index'
- import { FloatPanels } from '@/layout/components/index'
- import { getUserList, deleteUser, roleBind, setUserUnlock, getCompanyTree, getRoleList, editUser, batchUser, initialPwd, downloadTemplate, auditUser, setUserLock, setUserDisable, setUserEnable } from '@/api/base'
- import { imageByName } from '@/api/ftp'
- export default {
- name: 'UserRights',
- components: { TableItem, InputItem, SelectItem, MergeUser, SelectMultiple, FloatPanels },
- filters: {
- formatteAuditStatus(val) {
- switch (val) {
- case '0':
- return '不同意'
- case '1':
- return '未审核'
- case '2':
- return '同意'
- }
- }
- },
- data() {
- const roleValidate = (rule, value, callback) => {
- console.log(value)
- if (value.length === 0) {
- return callback(new Error('角色不能为空!'))
- } else {
- callback()
- }
- }
- return {
- list: [],
- column: [
- {
- label: '登录名',
- width: 120,
- prop: 'username',
- sortable: true
- },
- {
- label: '用户名',
- width: 120,
- prop: 'realName',
- sortable: true
- },
- {
- label: '单位',
-
- prop: 'companyname',
- sortable: true
- },
- {
- label: '部门',
-
- prop: 'deptName',
- sortable: true
- },
- {
- label: '联系电话',
- width: 120,
- prop: 'phone',
- sortable: true
- },
- {
- label: '邮箱',
-
- prop: 'email',
- sortable: true
- },
- {
- label: '角色',
- width: 120,
- prop: 'roleName',
- sortable: true
- },
- {
- label: '工作岗位',
- width: 120,
- prop: 'job',
- sortable: true
- },
-
-
-
-
-
-
-
-
-
-
- {
- label: '启用状态',
- width: 120,
- prop: 'enableFlag',
- formatter: (row, column, cellValue, index) => {
- if (cellValue === '0') return '禁用'
- if (cellValue === '1') return '启用'
- },
- sortable: true
- },
- {
- label: '锁定状态',
- width: 120,
- prop: 'lockFlag',
- sortable: true,
- formatter: (row, column, cellValue, index) => {
- if (cellValue === '0') return '锁定'
- if (cellValue === '1') return '正常'
- }
- },
-
-
-
-
-
-
-
-
-
-
-
- {
- label: '申请/创建时间',
- width: 140,
- prop: 'createTime',
- sortable: true
- },
- {
- label: '申请/创建人',
- width: 120,
- prop: 'createUserName',
- sortable: true
- },
- {
- label: '最后登录时间',
- width: 140,
- prop: 'loginTime',
- sortable: true
- },
- {
- label: 'APP版本',
- width: 120,
- prop: 'nowVersion',
- sortable: true
- }
- ],
-
- listLoading: true,
- multipleSelection: [],
- formInline: {
- user: '',
- region: ''
- },
- realName: '',
- username: '',
- companyId: '',
- departmentId: '',
- enableFlag: '',
- lockFlag: '',
- auditStatus: '',
- auditOptions: [
- {
- id: '',
- name: '全部'
- },
- {
- id: '0',
- name: '不同意'
- },
- {
- id: '2',
- name: '同意'
- }
- ],
- auditVisible: false,
- company: '',
- departments: [],
- treeData: [],
- companyOptions: [],
- deptOptions: [],
- statusOptions: [
- {
- id: '',
- name: '全部'
- },
- {
- id: '0',
- name: '禁用'
- },
- {
- id: '1',
- name: '启动'
- }
- ],
- lockOptions: [
- {
- id: '',
- name: '全部'
- },
- {
- id: '0',
- name: '锁定'
- },
- {
- id: '1',
- name: '正常'
- }
- ],
- dialogVisible: false,
- dialogTitle: '新增用户',
- editData: '',
- dialogDelete: false,
- enable: {
- enableSetting: false,
- optionsEnable: [
- {
- id: '1',
- name: '启用'
- },
- {
- id: '0',
- name: '不启用'
- }
- ],
- enableName: ''
- },
- role: {
- roleBind: false,
- roleName: '',
- optionsRole: []
- },
- auditRules: {
- roles: [{ required: true, validator: roleValidate, trigger: 'blur' }],
- auditStatus: [{ required: true, message: '审核状态不能为空', trigger: 'change' }]
- },
-
- auditInfo: {
- roles: undefined,
- auditStatus: undefined,
- auditState: undefined
- },
- files: [],
- roleId: [],
- userId: [],
- pagination: { current: 1, size: 20, total: 0 },
- disabledEdit: true,
- detailDialog: false,
- detailInfo: {},
- activeNames: ['baseInfo'],
- copyRole: [],
- copyUsers: []
- }
- },
- computed: {
- canAudit() {
- console.log('账号:' + this.$store.state.user.username)
- return !(this.multipleSelection.length === 1 && this.multipleSelection[0].auditstatus === '1' && this.multipleSelection[0].auditor === this.$store.state.user.username)
- },
- existEnableFlag() {
- const selAry = this.multipleSelection
- const newAry = selAry.filter((item) => {
- return item.enableFlag === '0'
- })
- const enableFlag = selAry.length > 0 && newAry.length === selAry.length
- return !enableFlag
- },
- existDisableFlag() {
- const selAry = this.multipleSelection
- const newAry = selAry.filter((item) => {
- return item.enableFlag === '1'
- })
- const enableFlag = selAry.length > 0 && newAry.length === selAry.length
- return !enableFlag
- },
- existLockFlag() {
- const selAry = this.multipleSelection
- const newAry = selAry.filter((item) => {
- return item.lockFlag === '0'
- })
- const enableFlag = selAry.length > 0 && newAry.length === selAry.length
- return !enableFlag
- }
- },
- watch: {
- multipleSelection(value) {
- if (value.length !== 1 || value.some(item => item.auditstatus === '1')) this.disabledEdit = true
- else this.disabledEdit = false
- },
- '$store.state.user.applied': function(val) {
- if (val) {
- this.fetchData(this.pagination)
- }
- },
- auditVisible(val) {
- if (!val) {
- Object.keys(this.auditInfo).forEach(item => {
- this.auditInfo[item] = undefined
- })
- }
- }
- },
- created() {
- const that = this
- that.fetchData(this.pagination)
- that.getCompanyTreeInfo()
- that.getRoleInfo()
-
- that.getCopyDeptUserList()
-
- document.onkeydown = function(e) {
- var key = window.event.keyCode
- if (key == 13) {
- that.onSubmit()
- }
- }
- console.log('/this', this.$store.state)
- },
- beforeDestroy() {
- document.onkeydown = ''
- },
- methods: {
-
- handleAuthOperation(type) {
-
- const ids = new FormData()
- ids.append('ids', this.multipleSelection.map(item => item.id).join(','))
- const success = (resp, message) => {
- if (resp.code === 1) {
- this.$message({
- message: message,
- type: 'success'
- })
- }
- this.onSubmit()
-
- }
- switch (type) {
- case 'enable':
- setUserEnable(ids).then(res => success(res, '启用成功!'))
- break
- case 'disable':
- setUserDisable(ids).then(res => success(res, '禁用成功!'))
- break
- case 'unlock':
- setUserUnlock(ids).then(res => success(res, '解锁成功!'))
- break
- case 'lock':
- setUserLock(ids).then(res => success(res, '锁定成功!'))
- break
- }
- },
-
- handleDbclick(data) {
- console.log('双击查看')
- this.detailDialog = true
- this.detailInfo = data
- this.detailInfo.jobduties = ''
-
- if (!this.strIsNull(this.detailInfo.note)) {
- this.detailInfo.jobduties = this.detailInfo.note.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ')
- }
- const arr = [this.detailInfo.avatar, this.detailInfo.esignature]
- arr.forEach((item, index) => {
- if (item === null) return
- imageByName(item).then(res => {
- if (res.status === 200) {
- index === 1 ? this.detailInfo.esignature = res.config.url : this.detailInfo.avatar = res.config.url
- }
- })
- })
- },
-
- audit() {
- this.auditVisible = true
- this.copyRole = []
- const arr = [this.multipleSelection[0].avatar, this.multipleSelection[0].esignature]
- arr.forEach((item, index) => {
- imageByName(item).then(res => {
- if (res.status === 200) {
- index === 1 ? this.multipleSelection[0].esignature = res.config.url : this.multipleSelection[0].avatar = res.config.url
- }
- })
- })
-
- this.auditInfo.auditStatus = '2'
- },
-
- batchImport(params) {
- const { type } = params.file
- console.log(type)
- const types = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
- if (!types.includes(type)) {
- this.$message({
- type: 'error',
- message: '只能上传xlsx,xls文件'
- })
- return
- }
- const form = new FormData()
- form.append('templateServiceType', 'userService')
- form.append('file', params.file)
- batchUser(form).then(res => {
- if (res.code !== -1) {
- this.$message({
- message: '导入成功!',
- type: 'success'
- })
-
- this.onSubmit()
- } else {
- console.log('导入失败', res.message)
- this.$message({
- message: '导入失败!',
- type: 'error'
- })
- }
- })
- },
-
- resetPwd() {
- const data = {
- users: this.multipleSelection.map(item => {
- item.firstlog = 1
- return item
- })
- }
- initialPwd(data).then(res => {
- if (res.code !== -1) {
- this.$message({
- type: 'success',
- message: '重置密码成功'
- })
- }
- })
- },
-
- fetchData(data) {
- const that = this
- this.listLoading = true
- getUserList(data).then(res => {
- if (Array.isArray(res.result.records) && res.result.records.length >= 0) {
- this.list = res.result.records
- this.list.forEach((item, index) => {
- item.phone = that.strIsNull(item.phone) ? '' : item.phone
- item.email = that.strIsNull(item.email) ? '' : item.email
- item.job = that.strIsNull(item.job) ? '' : item.job
- item.note = that.strIsNull(item.note) ? '' : item.note
- })
-
- this.pagination.total = res.result.total
- this.listLoading = false
- if (this.$store.state.user.applied) this.$store.dispatch('user/finnishApply', false)
- }
- })
- },
-
- getCompanyTreeInfo() {
- const that = this
- getCompanyTree({}).then(res => {
- if (res.code === 1) {
-
- const resultData = res.result
- var treeArr = []
- that.companyOptions = []
- that.recursiveData('1', resultData, treeArr)
- that.treeData = treeArr
-
- that.companyOptionData(treeArr, that.companyOptions)
- }
- })
- },
- recursiveData(typestr, tdata, resData) {
- const that = this
- if (Array.isArray(tdata) && tdata.length > 0) {
- tdata.forEach(function(v, i) {
-
- resData[i] = {}
- if (typestr === '1') {
- resData[i].id = 'gs_' + v.id
- resData[i].icon = 'el-icon-s-home'
- resData[i].companyId = v.id
- resData[i].companyName = v.companyName
- resData[i].parentId = v.parentId
- resData[i].coding = v.coding
- resData[i].address = v.address
- resData[i].phone = v.phone
- resData[i].abbreviation = v.abbreviation
- resData[i].code = v.code
- resData[i].type = typestr
- }
- if (typestr === '2') {
- resData[i].id = 'bm_' + v.id
- resData[i].icon = 'el-icon-s-cooperation'
- resData[i].companyName = v.name
- resData[i].companyId = v.companyId
- resData[i].parentId = v.parentId
- resData[i].coding = v.coding
- resData[i].address = ''
- resData[i].phone = v.phone
- resData[i].abbreviation = v.shortName
- resData[i].code = v.code
- resData[i].statusFlag = v.statusFlag
- resData[i].type = typestr
- }
- var arr = []
- if (Array.isArray(v.subCompany) && v.subCompany.length > 0) {
- if (v.subCompany.length > 0) {
-
- that.recursiveData('1', v.subCompany, arr)
- }
- }
- if (Array.isArray(v.deptVos) && v.deptVos.length > 0) {
- if (v.deptVos.length > 0) {
-
- that.recursiveData('2', v.deptVos, arr)
- }
- }
- resData[i].children = arr
- })
- }
- },
-
- companyOptionData(tdata, resData) {
- const that = this
- if (Array.isArray(tdata) && tdata.length > 0) {
- tdata.forEach(function(v, i) {
-
- if (v.type === '1') {
- resData[i] = {}
- resData[i].value = v.id
- resData[i].label = v.companyName
- var arr = []
- if (v.children.length > 0) {
- that.companyOptionData(v.children, arr)
- if (Array.isArray(arr) && arr.length > 0) {
- resData[i].children = arr
- }
- }
- }
- })
- }
- },
- deptOptionData(tdata, resData) {
- const that = this
- if (Array.isArray(tdata) && tdata.length > 0) {
- tdata.forEach(function(v, i) {
-
- if (v.type === '2') {
- resData[i] = {}
- resData[i].value = v.id
- resData[i].label = v.companyName
- var arr = []
- if (v.children.length > 0) {
- that.deptOptionData(v.children, arr)
- if (Array.isArray(arr) && arr.length > 0) {
- resData[i].children = arr
- }
- }
- }
- })
- }
- },
-
- companyChange(value) {
- const that = this
- that.companyId = value
- const lastValue = value[value.length - 1]
- that.deptList = []
- deepTree(that.treeData, lastValue)
- that.deptOptions = []
- that.deptOptionData(that.deptList, that.deptOptions)
-
- function deepTree(treeList, companyId) {
- for (let index = 0; index < treeList.length; index++) {
- const element = treeList[index]
- if (element.id == companyId && element.type == '1') {
- console.log('查询到了该节点')
- const _deptData = element.children.filter((item) => {
- return item.type == '2'
- })
- that.deptList = _deptData
- return true
- }
- console.log('遍历树')
- if (element.children && element.children.length) {
- if (deepTree(element.children, companyId)) {
- return true
- }
- }
- }
- }
- },
-
- companyDept(value) {
- const that = this
- that.departmentId = value
- },
-
- getRoleInfo() {
- getRoleList({ size: 10000 }).then(res => {
- this.role.optionsRole = res.result.records
- for (let i = 0; i < this.role.optionsRole.length; i++) {
- this.role.optionsRole[i].id = this.role.optionsRole[i].id.toString()
- this.role.optionsRole[i].name = this.role.optionsRole[i].roleName
- }
- })
- },
-
- handleAuditBtnClick(type) {
- if (type === 'cancel') {
- this.auditVisible = false
- this.$refs.auditForm.clearValidate()
- } else {
- this.$refs.auditForm.validate(valid => {
- if (valid) {
- const copyData = JSON.parse(JSON.stringify(this.auditInfo))
- copyData.roles = copyData.roles.join(',')
- const data = Object.assign(copyData, this.multipleSelection[0])
- data.auditstate = data.auditState
- data.auditstatus = data.auditStatus
- auditUser(data).then((res) => {
- if (res.code === 1) {
- this.$message({
- type: 'success',
- message: '用户审核成功'
- })
- this.onSubmit()
-
- this.auditVisible = false
- }
- })
- } else {
- return false
- }
- })
- }
- },
- handleCurrentChange(currentPage) {
-
- this.pagination.current = currentPage
- this.fetchData(this.pagination)
- },
- handleSizeChange(pagesize) {
-
- this.pagination.size = pagesize
- this.fetchData(this.pagination)
- },
- handleSelectionChange(value) {
- this.multipleSelection = value
-
- },
-
-
-
- handleEdit() {
- console.log('编辑', this.multipleSelection)
- this.dialogTitle = '修改用户'
- this.dialogVisible = true
- this.editData = this.multipleSelection[0]
-
- },
-
-
-
- onSubmit() {
- let lastCompanyId = ''
- let lastDeptId = ''
-
- if (Array.isArray(this.companyId) && this.companyId.length > 0) {
- const _department_companyId = this.companyId
- lastCompanyId = (_department_companyId[_department_companyId.length - 1] + '').replace('gs_', '')
- }
- if (Array.isArray(this.departmentId) && this.departmentId.length > 0) {
- const _department_parentId = this.departmentId
- lastDeptId = (_department_parentId[_department_parentId.length - 1] + '').replace('bm_', '')
- }
- this.pagination.current = 1
- let data = {
- userLevel: '1',
- realName: this.realName,
- username: this.username,
- companyId: lastCompanyId,
- departmentId: lastDeptId,
- enableFlag: this.enableFlag,
- lockFlag: this.lockFlag,
- auditstatus: this.auditStatus
- }
- data = Object.assign({}, data, this.pagination)
- console.log('查询条件:' + JSON.stringify(data))
- this.fetchData(data)
- console.log('submit!')
- },
- onSubmitAll() {
- this.fetchData(this.pagination)
- },
- handleAdded() {
- console.log('新增')
-
- this.dialogTitle = '新增用户'
- this.dialogVisible = true
- this.editData = {}
- },
-
- handleAddedCopy() {
- console.log('新增')
-
- this.dialogTitle = '复制新增用户'
- this.dialogVisible = true
- const roleIdAry = []
- console.log('角色绑定', JSON.stringify(this.multipleSelection))
- const currentUsers = this.multipleSelection
- if (currentUsers.length !== 0) {
-
- currentUsers.forEach(userinfo => {
- const roleIdList = userinfo.roleIdList
- if (!this.strIsNull(roleIdList)) {
- const roleIds = roleIdList.split(',')
-
- roleIds.forEach(roleId => {
- roleIdAry.push(roleId)
- })
- }
- })
- }
- const roleIds = Array.from(new Set(roleIdAry))
- this.editData = {
- roles: roleIds
- }
- },
- handleManyUser() {
- console.log('批量删除')
- if (this.multipleSelection.length > 0) {
- this.dialogDelete = true
- } else {
- this.$message.error('请选择要删除的用户')
- }
- },
-
- confirmDelete() {
- console.log('2222', this.multipleSelection)
- const ids = []
- for (let i = 0; i < this.multipleSelection.length; i++) {
- ids.push(this.multipleSelection[i].id)
- }
- const data = {
- ids: ids.toString()
- }
- const _this = this
- deleteUser(data).then(res => {
- if (res.code !== -1) {
- _this.$message.success('删除成功')
- _this.onSubmit()
- }
- })
- this.dialogDelete = false
- },
- enableSettings() {
- console.log('启用设置', this.multipleSelection)
- if (this.multipleSelection.length === 1) {
- this.enable.enableSetting = true
- this.enable.enableName = this.multipleSelection[0].realName
- this.enableFlag = this.multipleSelection[0].enableFlag
- } else {
- this.$message.error('请选择要启用的一个用户')
- }
- },
-
- confirmEnable() {
- const data = new FormData()
- data.append('id', this.multipleSelection[0].id)
- data.append('enableFlag', this.enableFlag)
- editUser(data).then(res => {
- this.$message.success('设置成功')
-
- this.onSubmit()
- })
- this.enable.enableSetting = false
- },
- roleBinding() {
- console.log('角色绑定', JSON.stringify(this.multipleSelection))
- const currentUsers = this.multipleSelection
- if (currentUsers.length !== 0) {
- this.role.roleBind = true
- const roleIdAry = []
- const userIdAry = []
- const userNameAry = []
-
- currentUsers.forEach(userinfo => {
- const roleIdList = userinfo.roleIdList
- if (!this.strIsNull(roleIdList)) {
- const roleIds = roleIdList.split(',')
-
- roleIds.forEach(roleId => {
- roleIdAry.push(roleId)
- })
- }
-
- userIdAry.push(userinfo.id)
-
- userNameAry.push(userinfo.realName)
- })
- this.role.roleName = userNameAry.toString()
- this.userId = userIdAry
- this.roleId = Array.from(new Set(roleIdAry))
- this.copyRole = []
- console.log('角色:' + JSON.stringify(this.roleId) + ' 用户:' + JSON.stringify(this.userId) + ' ' + this.role.roleName)
-
-
-
-
-
- } else {
- this.$message.error('请选择至少一个用户')
- }
-
-
-
-
-
-
-
-
-
-
- },
-
- confirmRoleBind() {
- const data = {
- userids: this.userId.toString(),
- roles: this.roleId.toString()
- }
- console.log('参数:', JSON.stringify(data))
-
- roleBind(data).then(res => {
- if (res.code !== -1) {
- this.$message.success('绑定成功')
-
- this.onSubmit()
- }
- })
- this.role.roleBind = false
- },
- userUnlock() {
- console.log('用户解锁')
- if (this.multipleSelection.length !== 1) {
- this.$message.error('请选择要绑定的一个用户')
- }
- const data = {
- id: this.multipleSelection[0].id
- }
- setUserUnlock(data).then(res => {
- this.$message.success(res.message)
- })
- },
- templateDownload() {
- const params = {
- templateFlag: 0,
- templateServiceType: 'userService'
- }
- downloadTemplate(params).then(res => {
- console.log(res)
- const blob = URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }))
- const a = document.createElement('a')
- a.href = blob
- a.download = '批量账号创建模板.xlsx'
- a.click()
- })
- },
-
- exportDownload() {
- debugger
- const params = {
- templateFlag: 1,
- templateServiceType: 'userService'
- }
- let lastCompanyId = ''
- let lastDeptId = ''
-
- if (Array.isArray(this.companyId) && this.companyId.length > 0) {
- const _department_companyId = this.companyId
- lastCompanyId = (_department_companyId[_department_companyId.length - 1] + '').replace('gs_', '')
- }
- if (Array.isArray(this.departmentId) && this.departmentId.length > 0) {
- const _department_parentId = this.departmentId
- lastDeptId = (_department_parentId[_department_parentId.length - 1] + '').replace('bm_', '')
- }
- const data = {
- userLevel: '1',
- realName: this.realName,
- username: this.username,
- companyId: lastCompanyId,
- departmentId: lastDeptId,
- enableFlag: this.enableFlag,
- lockFlag: this.lockFlag,
- auditstatus: this.auditStatus
- }
- if (this.strIsNull(data.realName)) {
- delete data.realName
- }
- if (this.strIsNull(data.username)) {
- delete data.username
- }
- if (this.strIsNull(data.departmentId)) {
- delete data.departmentId
- }
- if (this.strIsNull(data.enableFlag)) {
- delete data.enableFlag
- }
- if (this.strIsNull(data.lockFlag)) {
- delete data.lockFlag
- }
- if (this.strIsNull(data.auditstatus)) {
- delete data.auditstatus
- }
- const dto = {
- dto: JSON.stringify(data)
- }
- const exportParams = Object.assign({}, dto, params)
- console.log(exportParams)
- downloadTemplate(exportParams).then(res => {
- console.log(res)
- const blob = URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }))
- const a = document.createElement('a')
- a.href = blob
- a.download = '用户信息.xlsx'
- a.click()
- })
- },
-
- onInput(key, event) {
- this[key] = event
- },
-
- changeSelectValue(key, event) {
- this[key] = key === 'departmentId' ? event.toString() : event
-
- },
- changeSelectMultipleValue(key, event) {
- console.log('222222', key, event)
- this[key] = event
- },
-
- submitForm() {
- this.$refs.ruleForm.submitForm()
-
-
-
-
- },
-
- resetForm() {
- this.$refs.ruleForm.resetFields()
- this.dialogVisible = false
- },
-
- remind(data) {
- this.dialogVisible = false
-
- this.onSubmit()
- },
-
- upload() {
- const fileObj = document.getElementById('file').files
- const form = new FormData()
- form.append('file', fileObj[0])
- },
-
- getCopyDeptUserList() {
- const data = {
- userLevel: 1,
- current: 1,
- size: 10000000
- }
- this.copyUsers = []
- getUserList(data).then(res => {
-
- res.result.records.forEach(item => {
- this.copyUsers.push({
- id: item.id,
- name: item.realName,
- roleIdList: item.roleIdList
- })
- })
- })
- },
-
- copyRoleChange(key, event) {
- console.log('copyRoleChange:', key, event)
- this[key] = event
- this.roleId = this.comCopyRole(event)
- },
-
- setCopyRoleId(roleAry) {
- console.log('setCopyRoleId:' + roleAry)
- this.auditInfo.roles = this.comCopyRole(roleAry)
- },
-
- comCopyRole(roleAry) {
- const that = this
-
- const roleUsers = that.copyUsers.filter((item, index) => {
- return roleAry.includes(item.id)
- })
- const roleIdAry = []
-
- roleUsers.forEach(userinfo => {
- const roleIdList = userinfo.roleIdList
- if (!that.strIsNull(roleIdList)) {
- const roleIds = roleIdList.split(',')
-
- roleIds.forEach(roleId => {
- roleIdAry.push(roleId)
- })
- }
- })
- const roleId = Array.from(new Set(roleIdAry))
- return roleId
- },
-
- strIsNull(strVal) {
- strVal = strVal || ''
- return (typeof (strVal) === 'undefined' || strVal == null || strVal == '' || strVal == 'null')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .userRights{
- height: 100%;
- width: 100%;
- padding: 5px;
- .filteroption {
- width:100%;
- height:80px;
- font-size: 14px;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: flex-start;
- .data_box{
- width: 100%;
- height: 40px;
- line-height: 40px;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: flex-start;
- overflow: hidden;
- .input_item{
- height: 34px;
- margin-right:8px;
- width:300px;
- display: inline-block;
- // display: flex;
- // flex-direction: row;
- // align-items: center;
- // justify-content: flex-start;
- .span_item{
- width: 74px;
- float: left;
- // border:1px red solid;
- }
- .el-cascader{
- width: calc(100% - 74px);
- // border:1px red solid;
- }
- }
- }
- .btn_box{
- width: 100%;
- height: 40px;
- line-height: 40px;
- overflow: hidden;
- }
- }
- .tableheight{
- margin-top: 4px;
- height: calc(100% - 84px);
- // border:1px red solid;
- }
- }
- .el-select {
- display: block;
- }
- .user-base-info {
- > div {
- display: flex;
- flex-wrap: wrap;
- margin-bottom: 10px;
- > span {
- &:nth-of-type(1) {
- display: inline-block;
- width: 100px;
- text-align: right;
- }
- &:nth-of-type(2) {
- width: calc(100% - 100px);
- }
- & + img {
- width: calc(100% - 410px);
- }
- }
- }
- }
- .audit-info {
- > div {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- margin-bottom: 10px;
- > span {
- display: block;
- width: 100px;
- text-align: right;
- }
- }
- }
- .audit-title {
- display: block;
- text-align: center;
- margin-bottom: 10px;
- }
- .base-info {
- .el-row {
- display: flex;
- margin-bottom: 20px;
- .title {
- display: inline-block;
- width: 100px;
- text-align: right;
- }
- .title + span, img {
- display: inline-block;
- width: 380px;
- }
- img {
- width: 120px;
- }
- }
- }
- .custom-row {
- display: flex;
- margin-bottom: 20px;
- span {
- display: inline-block;
- width: 80%;
- &.title {
- width: 100px;
- text-align: right;
- }
- }
- }
- /* 表单大小设置 */
- </style>
|