index.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583
  1. <template>
  2. <div class="userRights">
  3. <float-panels title="浮动窗口" />
  4. <!-- 用户权限管理 -->
  5. <div class="filteroption">
  6. <div class="data_box">
  7. <input-item
  8. can-clear
  9. type="text"
  10. placeholder="请输入用户名"
  11. title="用户名:"
  12. nominate="realName"
  13. custom-style="display: inline-block;width:200px;margin-right:8px;"
  14. :value="realName"
  15. :max-length="50"
  16. :disabled="false"
  17. :required="false"
  18. @changeValue="onInput"
  19. />
  20. <input-item
  21. can-clear
  22. type="text"
  23. placeholder="请输入登录名"
  24. title="登录名:"
  25. nominate="username"
  26. custom-style="display: inline-block;width:200px;margin-right:8px;"
  27. :value="username"
  28. :max-length="50"
  29. :disabled="false"
  30. :required="false"
  31. @changeValue="onInput"
  32. />
  33. <div class="input_item">
  34. <span class="span_item">所属公司:</span>
  35. <el-cascader
  36. placeholder="请选择公司"
  37. size="small"
  38. custom-style="display: inline-block"
  39. :options="companyOptions"
  40. :value="companyId"
  41. :show-all-levels="false"
  42. :props="{ checkStrictly: true }"
  43. clearable
  44. @change="companyChange"
  45. />
  46. </div>
  47. <div class="input_item">
  48. <span class="span_item">所属部门:</span>
  49. <el-cascader
  50. placeholder="请选择部门"
  51. size="small"
  52. :show-all-levels="false"
  53. :options="deptOptions"
  54. :value="departmentId"
  55. :props="{ checkStrictly: true }"
  56. clearable
  57. @change="companyDept"
  58. />
  59. </div>
  60. <select-item
  61. can-clear
  62. placeholder="请选择启用状态"
  63. title="启用状态:"
  64. nominate="enableFlag"
  65. custom-style="display: inline-block;width:180px;margin-right:8px;"
  66. :value="enableFlag"
  67. :disabled="false"
  68. :required="false"
  69. :filterable="true"
  70. :options="statusOptions"
  71. @changeSelectValue="changeSelectValue"
  72. />
  73. <select-item
  74. can-clear
  75. placeholder="请选择锁定状态"
  76. title="锁定状态:"
  77. nominate="lockFlag"
  78. custom-style="display: inline-block;width:180px;margin-right:8px;"
  79. :value="lockFlag"
  80. :disabled="false"
  81. :required="false"
  82. :filterable="true"
  83. :options="lockOptions"
  84. @changeSelectValue="changeSelectValue"
  85. />
  86. <select-item
  87. can-clear
  88. placeholder="请选择审核状态"
  89. title="审核状态:"
  90. nominate="auditStatus"
  91. custom-style="display: inline-block;width:180px;"
  92. :value="auditStatus"
  93. :disabled="false"
  94. :required="false"
  95. :filterable="true"
  96. :options="auditOptions"
  97. @changeSelectValue="changeSelectValue"
  98. />
  99. </div>
  100. <div class="btn_box">
  101. <el-button type="primary" size="small" @click="onSubmit">查询用户</el-button>
  102. <!-- <el-button type="primary" size="small" @click="onSubmitAll">全部用户</el-button> -->
  103. <el-button type="primary" size="small" @click="handleAdded">新增用户</el-button>
  104. <!-- <el-button type="primary" size="small" @click="handleAddedCopy">复制用户</el-button> -->
  105. <el-button :disabled="disabledEdit" type="primary" size="small" @click="handleEdit">修改用户</el-button>
  106. <el-button type="primary" size="small" :disabled="multipleSelection.length === 0" @click="handleManyUser">删除用户</el-button>
  107. <!-- <el-button type="primary" size="small" :disabled="disabledEdit" @click="enableSettings">启用设置</el-button> -->
  108. <!-- <el-button type="primary" size="small">批量导入</el-button> -->
  109. <!-- <el-button type="primary" size="small" :disabled="disabledEdit" :style="disabledEdit ? 'background:#bec5c9;border-color: #bec5c9;' : ''" @click="roleBinding">角色绑定</el-button> -->
  110. <!-- <el-button type="primary" size="small" @click="userUnlock">用户解锁</el-button> -->
  111. <!-- <el-button type="primary" size="small" :disabled="multipleSelection.length !== 1" @click="roleBinding">角色绑定</el-button> -->
  112. <el-button type="primary" size="small" :disabled="multipleSelection.length === 0" @click="roleBinding">角色绑定</el-button>
  113. <el-button type="primary" size="small" :disabled="canAudit" @click="audit">审核</el-button>
  114. <!-- <el-button type="primary" size="small" @click="batchImport">批量导入</el-button> -->
  115. <el-button type="primary" size="small" @click="templateDownload">模版下载</el-button>
  116. <el-upload action="fakeaction" style="margin: 0 10px; display: inline-block" :http-request="batchImport" :show-file-list="false" :file-list="files" accept=".xls, .xlsx">
  117. <el-button size="small" type="primary">批量导入</el-button>
  118. </el-upload>
  119. <el-button type="primary" size="small" @click="exportDownload">导出</el-button>
  120. <!-- <el-button type="primary" size="small" :disabled="multipleSelection.length === 0" @click="resetPwd">重置密码</el-button> -->
  121. <el-button type="primary" size="small" :disabled="existEnableFlag" @click="handleAuthOperation('enable')">启用</el-button>
  122. <el-button type="primary" size="small" :disabled="existDisableFlag" @click="handleAuthOperation('disable')">禁用</el-button>
  123. <el-button type="primary" size="small" :disabled="existLockFlag" @click="handleAuthOperation('unlock')">解锁</el-button>
  124. <!-- <el-button type="primary" size="small" :disabled="multipleSelection.length === 0" @click="handleAuthOperation('lock')">锁定</el-button> -->
  125. <input id="file" ref="files" type="file" style="display: none;" @change="upload">
  126. </div>
  127. </div>
  128. <div class="tableheight">
  129. <table-item
  130. :table-data="list"
  131. :column="column"
  132. :for-id="true"
  133. :pagination="true"
  134. :pagesize="pagination.size"
  135. :currentpage="pagination.current"
  136. :border="true"
  137. :multiple="true"
  138. :total="pagination.total"
  139. :fixed="true"
  140. :isdelete="false"
  141. :is-select="false"
  142. :stripe="true"
  143. @handleCurrentChange="handleCurrentChange"
  144. @handleSizeChange="handleSizeChange"
  145. @handleSelectionChange="handleSelectionChange"
  146. @handleEdit="handleEdit"
  147. @rowDblclick="handleDbclick"
  148. />
  149. </div>
  150. <el-dialog v-dialogDrag :title="dialogTitle" :visible.sync="dialogVisible" width="800px">
  151. <div class="dialog_style">
  152. <MergeUser v-if="dialogVisible" ref="ruleForm" :data="editData" :company="departments" :tree-data="treeData" :options-role="role.optionsRole" @remind="remind" />
  153. </div>
  154. <span slot="footer" class="dialog-footer">
  155. <el-button @click="resetForm">取 消</el-button>
  156. <el-button type="primary" @click="submitForm">确 定</el-button>
  157. </span>
  158. </el-dialog>
  159. <el-dialog v-dialogDrag title="删除用户" :visible.sync="dialogDelete" width="500px">
  160. <span>确认是否删除用户?</span>
  161. <span slot="footer" class="dialog-footer">
  162. <el-button @click="dialogDelete = false">取 消</el-button>
  163. <el-button type="primary" @click="confirmDelete">确 定</el-button>
  164. </span>
  165. </el-dialog>
  166. <el-dialog v-dialogDrag title="角色权限绑定" :visible.sync="role.roleBind" width="500px" height="300px">
  167. <div style="height:200px;width:100%;">
  168. <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" />
  169. <SelectMultiple
  170. placeholder="请选择"
  171. title="角色复制:"
  172. nominate="copyRole"
  173. custom-style="display: inline-block; width: 80%; line-height: 32px;"
  174. :value="copyRole"
  175. :disabled="false"
  176. :required="false"
  177. :filterable="true"
  178. :collapsetags="true"
  179. :options="copyUsers"
  180. :clearable="true"
  181. @changeSelectMultipleValue="copyRoleChange"
  182. />
  183. <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=&quot;changeSelectMultipleValue&quot;" />
  184. </div>
  185. <span slot="footer" class="dialog-footer">
  186. <el-button @click="role.roleBind = false">取 消</el-button>
  187. <el-button type="primary" @click="confirmRoleBind">确 定</el-button>
  188. </span>
  189. </el-dialog>
  190. <el-dialog v-if="multipleSelection.length !=0" v-dialogDrag title="审核用户" :visible.sync="auditVisible" width="500px">
  191. <div class="user-base-info">
  192. <span class="audit-title">申请信息:</span>
  193. <div><span>登录名:</span><span>{{ multipleSelection[0].username }}</span></div>
  194. <div><span>用户名:</span><span>{{ multipleSelection[0].realName }}</span></div>
  195. <div><span>联系电话:</span><span>{{ multipleSelection[0].phone }}</span></div>
  196. <div><span>邮箱:</span><span>{{ multipleSelection[0].email }}</span></div>
  197. <div><span>部门:</span><span>{{ multipleSelection[0].deptName }}</span></div>
  198. <div><span>个性签名图片:</span><img :src="multipleSelection[0].esignature"></div>
  199. <div><span>用户头像:</span><img :src="multipleSelection[0].avatar"></div>
  200. <div><span>工作岗位:</span><span>{{ multipleSelection[0].job }}</span></div>
  201. <div><span>工作职责:</span><span>{{ multipleSelection[0].note }}</span></div>
  202. <div><span>申请说明:</span><span>{{ multipleSelection[0].applystate }}</span></div>
  203. <div><span>申请人:</span><span>{{ multipleSelection[0].createUserName }}</span></div>
  204. <div><span>申请时间:</span><span>{{ multipleSelection[0].createTime }}</span></div>
  205. </div>
  206. <div class="audit-info">
  207. <span class="audit-title">审核信息:</span>
  208. <el-form ref="auditForm" :model="auditInfo" :rules="auditRules" label-position="right" label-width="100px">
  209. <el-form-item style="margin-bottom: 15px" label="角色复制">
  210. <el-select
  211. v-model="copyRole"
  212. multiple
  213. style="width: 300px"
  214. placeholder="请选择需要复制的用户角色"
  215. filterable
  216. clearable
  217. collapse-tags
  218. @change="setCopyRoleId"
  219. >
  220. <el-option v-for="item in copyUsers" :key="item.id" :label="item.name" :value="item.id" />
  221. </el-select>
  222. </el-form-item>
  223. <el-form-item label="角色:" prop="roles" style="margin-bottom: 20px">
  224. <el-select v-model="auditInfo.roles" style="width: 300px" multiple>
  225. <template v-for="item in role.optionsRole">
  226. <el-option :key="item.id" :value="item.id" :label="item.name" />
  227. </template>
  228. </el-select>
  229. </el-form-item>
  230. <el-form-item label="审核状态:" prop="auditStatus" style="margin-bottom: 20px">
  231. <el-select v-model="auditInfo.auditStatus" style="width: 300px" placeholder="请选择审核状态">
  232. <el-option key="0" value="0" label="不同意" />
  233. <el-option key="2" value="2" label="同意" />
  234. </el-select>
  235. </el-form-item>
  236. <el-form-item label="审核说明:">
  237. <el-input v-model="auditInfo.auditState" style="width: 300px" type="textarea" placeholder="请输入审核说明" />
  238. </el-form-item>
  239. </el-form>
  240. </div>
  241. <span slot="footer" class="dialog-footer">
  242. <el-button @click="handleAuditBtnClick('cancel')">取 消</el-button>
  243. <el-button type="primary" @click="handleAuditBtnClick('confirm')">确 定</el-button>
  244. </span>
  245. </el-dialog>
  246. <el-dialog title="用户详情" :visible.sync="detailDialog" append-to-body>
  247. <el-collapse v-model="activeNames">
  248. <el-collapse-item title="基本信息" name="baseInfo">
  249. <el-row>
  250. <el-col :span="12" class="base-info">
  251. <el-row>
  252. <span class="title">申请人:</span><span>{{ detailInfo.createUserName }}</span>
  253. </el-row>
  254. <el-row>
  255. <span class="title">申请时间:</span><span>{{ detailInfo.createTime }}</span>
  256. </el-row>
  257. <el-row>
  258. <span class="title">登录名:</span><span>{{ detailInfo.username }}</span>
  259. </el-row>
  260. <el-row>
  261. <span class="title">用户名:</span><span>{{ detailInfo.realName }}</span>
  262. </el-row>
  263. <el-row>
  264. <span class="title">联系电话:</span><span>{{ detailInfo.phone }}</span>
  265. </el-row>
  266. <el-row>
  267. <span class="title">邮箱:</span><span>{{ detailInfo.email }}</span>
  268. </el-row>
  269. <el-row>
  270. <span class="title">单位:</span><span>{{ detailInfo.companyname }}</span>
  271. </el-row>
  272. <el-row>
  273. <span class="title">部门:</span><span>{{ detailInfo.deptName }}</span>
  274. </el-row>
  275. <el-row>
  276. <span class="title">工作岗位:</span><span>{{ detailInfo.job }}</span>
  277. </el-row>
  278. </el-col>
  279. <el-col :span="12" class="base-info">
  280. <el-row>
  281. <span class="title">个性签名图片:</span>
  282. <img v-if="detailInfo.esignature !== null" :src="detailInfo.esignature">
  283. </el-row>
  284. <el-row>
  285. <span class="title">用户头像:</span>
  286. <img v-if="detailInfo.avatar !== null" :src="detailInfo.avatar">
  287. </el-row>
  288. <el-row>
  289. <span class="title">工作职责:</span><span v-html="detailInfo.jobduties" />
  290. </el-row>
  291. </el-col>
  292. </el-row>
  293. </el-collapse-item>
  294. <el-collapse-item title="分配权限" name="authGruop">
  295. <el-row class="custom-row">
  296. <span class="title">角色:</span><span>{{ detailInfo.roleName }}</span>
  297. </el-row>
  298. </el-collapse-item>
  299. <el-collapse-item title="申请信息" name="applyInfo">
  300. <el-row class="custom-row">
  301. <span class="title">申请人:</span><span>{{ detailInfo.createUserName }}</span>
  302. </el-row>
  303. <el-row class="custom-row">
  304. <span class="title">申请时间:</span><span>{{ detailInfo.createTime }}</span>
  305. </el-row>
  306. <el-row class="custom-row">
  307. <span class="title">申请说明:</span><span>{{ detailInfo.applystate }}</span>
  308. </el-row>
  309. </el-collapse-item>
  310. <el-collapse-item title="审核信息" name="auditInfo">
  311. <el-row class="custom-row">
  312. <span class="title">审核人:</span><span>{{ detailInfo.auditorname }}</span>
  313. </el-row>
  314. <el-row class="custom-row">
  315. <span class="title">审核时间:</span><span>{{ detailInfo.audittime }}</span>
  316. </el-row>
  317. <el-row class="custom-row">
  318. <span class="title">审核说明:</span><span>{{ detailInfo.auditstate }}</span>
  319. </el-row>
  320. <el-row class="custom-row">
  321. <span class="title">审核意见:</span><span>{{ detailInfo.auditstatus | formatteAuditStatus }}</span>
  322. </el-row>
  323. </el-collapse-item>
  324. </el-collapse>
  325. </el-dialog>
  326. </div>
  327. </template>
  328. <script>
  329. import TableItem from '@/components/TableAuto'
  330. import InputItem from '@/components/FormItem/Input'
  331. import SelectItem from '@/components/FormItem/Select'
  332. import SelectMultiple from '@/components/FormItem/SelectMultiple'
  333. import MergeUser from './mergeUser/index'
  334. import { FloatPanels } from '@/layout/components/index'
  335. import { getUserList, deleteUser, roleBind, setUserUnlock, getCompanyTree, getRoleList, editUser, batchUser, initialPwd, downloadTemplate, auditUser, setUserLock, setUserDisable, setUserEnable } from '@/api/base'
  336. import { imageByName } from '@/api/ftp'
  337. export default {
  338. name: 'UserRights',
  339. components: { TableItem, InputItem, SelectItem, MergeUser, SelectMultiple, FloatPanels },
  340. filters: {
  341. formatteAuditStatus(val) {
  342. switch (val) {
  343. case '0':
  344. return '不同意'
  345. case '1':
  346. return '未审核'
  347. case '2':
  348. return '同意'
  349. }
  350. }
  351. },
  352. data() {
  353. const roleValidate = (rule, value, callback) => {
  354. console.log(value)
  355. if (value.length === 0) {
  356. return callback(new Error('角色不能为空!'))
  357. } else {
  358. callback()
  359. }
  360. }
  361. return {
  362. list: [],
  363. column: [
  364. {
  365. label: '登录名',
  366. width: 120,
  367. prop: 'username',
  368. sortable: true
  369. },
  370. {
  371. label: '用户名',
  372. width: 120,
  373. prop: 'realName',
  374. sortable: true
  375. },
  376. {
  377. label: '单位',
  378. // width: 120,
  379. prop: 'companyname',
  380. sortable: true
  381. },
  382. {
  383. label: '部门',
  384. // width: 120,
  385. prop: 'deptName',
  386. sortable: true
  387. },
  388. {
  389. label: '联系电话',
  390. width: 120,
  391. prop: 'phone',
  392. sortable: true
  393. },
  394. {
  395. label: '邮箱',
  396. // width: 120,
  397. prop: 'email',
  398. sortable: true
  399. },
  400. {
  401. label: '角色',
  402. width: 120,
  403. prop: 'roleName',
  404. sortable: true
  405. },
  406. {
  407. label: '工作岗位',
  408. width: 120,
  409. prop: 'job',
  410. sortable: true
  411. },
  412. // {
  413. // label: '创建类型',
  414. // // width: 120,
  415. // prop: 'createType',
  416. // sortable: true,
  417. // formatter: (row, column, cellValue, index) => {
  418. // if (cellValue === '0') return '自建'
  419. // if (cellValue === '1') return '申请'
  420. // }
  421. // },
  422. {
  423. label: '启用状态',
  424. width: 120,
  425. prop: 'enableFlag',
  426. formatter: (row, column, cellValue, index) => {
  427. if (cellValue === '0') return '禁用'
  428. if (cellValue === '1') return '启用'
  429. },
  430. sortable: true
  431. },
  432. {
  433. label: '锁定状态',
  434. width: 120,
  435. prop: 'lockFlag',
  436. sortable: true,
  437. formatter: (row, column, cellValue, index) => {
  438. if (cellValue === '0') return '锁定'
  439. if (cellValue === '1') return '正常'
  440. }
  441. },
  442. // {
  443. // label: '审核意见',
  444. // width: 120,
  445. // prop: 'auditstatus',
  446. // sortable: true,
  447. // formatter: (row, column, cellValue, index) => {
  448. // if (cellValue === '0') return '不同意'
  449. // if (cellValue === '1') return '未审核'
  450. // if (cellValue === '2') return '同意'
  451. // }
  452. // },
  453. {
  454. label: '申请/创建时间',
  455. width: 140,
  456. prop: 'createTime',
  457. sortable: true
  458. },
  459. {
  460. label: '申请/创建人',
  461. width: 120,
  462. prop: 'createUserName',
  463. sortable: true
  464. },
  465. {
  466. label: '最后登录时间',
  467. width: 140,
  468. prop: 'loginTime',
  469. sortable: true
  470. },
  471. {
  472. label: 'APP版本',
  473. width: 120,
  474. prop: 'nowVersion',
  475. sortable: true
  476. }
  477. ],
  478. // 获取前等待
  479. listLoading: true,
  480. multipleSelection: [],
  481. formInline: {
  482. user: '',
  483. region: ''
  484. },
  485. realName: '', // 用户名
  486. username: '', // 登录
  487. companyId: '', // 部门
  488. departmentId: '', // 部门
  489. enableFlag: '', // 启用状态
  490. lockFlag: '', // 锁定状态
  491. auditStatus: '', // 审核状态
  492. auditOptions: [
  493. {
  494. id: '',
  495. name: '全部'
  496. },
  497. {
  498. id: '0',
  499. name: '不同意'
  500. },
  501. {
  502. id: '2',
  503. name: '同意'
  504. }
  505. ], // 审核状态列表
  506. auditVisible: false,
  507. company: '',
  508. departments: [],
  509. treeData: [], // 公司、部门集合
  510. companyOptions: [], // 公司列表
  511. deptOptions: [], // 部门列表
  512. statusOptions: [
  513. {
  514. id: '',
  515. name: '全部'
  516. },
  517. {
  518. id: '0',
  519. name: '禁用'
  520. },
  521. {
  522. id: '1',
  523. name: '启动'
  524. }
  525. ], // 启用状态选项
  526. lockOptions: [
  527. {
  528. id: '',
  529. name: '全部'
  530. },
  531. {
  532. id: '0',
  533. name: '锁定'
  534. },
  535. {
  536. id: '1',
  537. name: '正常'
  538. }
  539. ], // 锁定状态选项
  540. dialogVisible: false,
  541. dialogTitle: '新增用户',
  542. editData: '',
  543. dialogDelete: false, // 删除
  544. enable: {
  545. enableSetting: false, // 启用设置
  546. optionsEnable: [
  547. {
  548. id: '1',
  549. name: '启用'
  550. },
  551. {
  552. id: '0',
  553. name: '不启用'
  554. }
  555. ],
  556. enableName: ''
  557. },
  558. role: {
  559. roleBind: false,
  560. roleName: '',
  561. optionsRole: []
  562. },
  563. auditRules: {
  564. roles: [{ required: true, validator: roleValidate, trigger: 'blur' }],
  565. auditStatus: [{ required: true, message: '审核状态不能为空', trigger: 'change' }]
  566. },
  567. // 审核信息
  568. auditInfo: {
  569. roles: undefined,
  570. auditStatus: undefined,
  571. auditState: undefined
  572. },
  573. files: [], // 上传文件
  574. roleId: [], // 角色编号集合
  575. userId: [], // 用户编号集合
  576. pagination: { current: 1, size: 20, total: 0 }, // 分页参数信息
  577. disabledEdit: true,
  578. detailDialog: false,
  579. detailInfo: {},
  580. activeNames: ['baseInfo'],
  581. copyRole: [], // 选择的复制角色用户
  582. copyUsers: [] // 用户列表
  583. }
  584. },
  585. computed: {
  586. canAudit() {
  587. console.log('账号:' + this.$store.state.user.username)
  588. return !(this.multipleSelection.length === 1 && this.multipleSelection[0].auditstatus === '1' && this.multipleSelection[0].auditor === this.$store.state.user.username)
  589. },
  590. existEnableFlag() {
  591. const selAry = this.multipleSelection
  592. const newAry = selAry.filter((item) => {
  593. return item.enableFlag === '0'
  594. })
  595. const enableFlag = selAry.length > 0 && newAry.length === selAry.length
  596. return !enableFlag
  597. },
  598. existDisableFlag() {
  599. const selAry = this.multipleSelection
  600. const newAry = selAry.filter((item) => {
  601. return item.enableFlag === '1'
  602. })
  603. const enableFlag = selAry.length > 0 && newAry.length === selAry.length
  604. return !enableFlag
  605. },
  606. existLockFlag() {
  607. const selAry = this.multipleSelection
  608. const newAry = selAry.filter((item) => {
  609. return item.lockFlag === '0'
  610. })
  611. const enableFlag = selAry.length > 0 && newAry.length === selAry.length
  612. return !enableFlag
  613. }
  614. },
  615. watch: {
  616. multipleSelection(value) {
  617. if (value.length !== 1 || value.some(item => item.auditstatus === '1')) this.disabledEdit = true
  618. else this.disabledEdit = false
  619. },
  620. '$store.state.user.applied': function(val) {
  621. if (val) {
  622. this.fetchData(this.pagination)
  623. }
  624. },
  625. auditVisible(val) {
  626. if (!val) {
  627. Object.keys(this.auditInfo).forEach(item => {
  628. this.auditInfo[item] = undefined
  629. })
  630. }
  631. }
  632. },
  633. created() {
  634. const that = this
  635. that.fetchData(this.pagination)
  636. that.getCompanyTreeInfo()
  637. that.getRoleInfo()
  638. // const data = param2Obj('https://fz.bajiaohua.cn/?crowdfundId=9')
  639. that.getCopyDeptUserList()
  640. // Enter事件监听
  641. document.onkeydown = function(e) {
  642. var key = window.event.keyCode
  643. if (key == 13) {
  644. that.onSubmit()
  645. }
  646. }
  647. console.log('/this', this.$store.state)
  648. },
  649. beforeDestroy() {
  650. document.onkeydown = ''
  651. },
  652. methods: {
  653. // 权限操作
  654. handleAuthOperation(type) {
  655. // const ids = {ids: this.multipleSelection.map(item => item.id).join(',')};
  656. const ids = new FormData()
  657. ids.append('ids', this.multipleSelection.map(item => item.id).join(','))
  658. const success = (resp, message) => {
  659. if (resp.code === 1) {
  660. this.$message({
  661. message: message,
  662. type: 'success'
  663. })
  664. }
  665. this.onSubmit()
  666. // this.fetchData(this.pagination)
  667. }
  668. switch (type) {
  669. case 'enable':
  670. setUserEnable(ids).then(res => success(res, '启用成功!'))
  671. break
  672. case 'disable':
  673. setUserDisable(ids).then(res => success(res, '禁用成功!'))
  674. break
  675. case 'unlock':
  676. setUserUnlock(ids).then(res => success(res, '解锁成功!'))
  677. break
  678. case 'lock':
  679. setUserLock(ids).then(res => success(res, '锁定成功!'))
  680. break
  681. }
  682. },
  683. // 双击table行
  684. handleDbclick(data) {
  685. console.log('双击查看')
  686. this.detailDialog = true
  687. this.detailInfo = data
  688. this.detailInfo.jobduties = ''
  689. // 对职责进行处理
  690. if (!this.strIsNull(this.detailInfo.note)) {
  691. this.detailInfo.jobduties = this.detailInfo.note.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ')
  692. }
  693. const arr = [this.detailInfo.avatar, this.detailInfo.esignature]
  694. arr.forEach((item, index) => {
  695. if (item === null) return
  696. imageByName(item).then(res => {
  697. if (res.status === 200) {
  698. index === 1 ? this.detailInfo.esignature = res.config.url : this.detailInfo.avatar = res.config.url
  699. }
  700. })
  701. })
  702. },
  703. // 审核用户
  704. audit() {
  705. this.auditVisible = true
  706. this.copyRole = []
  707. const arr = [this.multipleSelection[0].avatar, this.multipleSelection[0].esignature]
  708. arr.forEach((item, index) => {
  709. imageByName(item).then(res => {
  710. if (res.status === 200) {
  711. index === 1 ? this.multipleSelection[0].esignature = res.config.url : this.multipleSelection[0].avatar = res.config.url
  712. }
  713. })
  714. })
  715. // 审核页面,默认同意
  716. this.auditInfo.auditStatus = '2'
  717. },
  718. // 批量导入
  719. batchImport(params) {
  720. const { type } = params.file
  721. console.log(type)
  722. const types = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
  723. if (!types.includes(type)) {
  724. this.$message({
  725. type: 'error',
  726. message: '只能上传xlsx,xls文件'
  727. })
  728. return
  729. }
  730. const form = new FormData()
  731. form.append('templateServiceType', 'userService')
  732. form.append('file', params.file)
  733. batchUser(form).then(res => {
  734. if (res.code !== -1) {
  735. this.$message({
  736. message: '导入成功!',
  737. type: 'success'
  738. })
  739. // this.fetchData(this.pagination)
  740. this.onSubmit()
  741. } else {
  742. console.log('导入失败', res.message)
  743. this.$message({
  744. message: '导入失败!',
  745. type: 'error'
  746. })
  747. }
  748. })
  749. },
  750. // 重置密码
  751. resetPwd() {
  752. const data = {
  753. users: this.multipleSelection.map(item => {
  754. item.firstlog = 1
  755. return item
  756. })
  757. }
  758. initialPwd(data).then(res => {
  759. if (res.code !== -1) {
  760. this.$message({
  761. type: 'success',
  762. message: '重置密码成功'
  763. })
  764. }
  765. })
  766. },
  767. // 获取列表数据
  768. fetchData(data) {
  769. const that = this
  770. this.listLoading = true
  771. getUserList(data).then(res => {
  772. if (Array.isArray(res.result.records) && res.result.records.length >= 0) {
  773. this.list = res.result.records
  774. this.list.forEach((item, index) => {
  775. item.phone = that.strIsNull(item.phone) ? '' : item.phone // 联系电话
  776. item.email = that.strIsNull(item.email) ? '' : item.email // 邮箱
  777. item.job = that.strIsNull(item.job) ? '' : item.job // 工作岗位
  778. item.note = that.strIsNull(item.note) ? '' : item.note // 工作职责
  779. })
  780. // for(let i in)
  781. this.pagination.total = res.result.total
  782. this.listLoading = false
  783. if (this.$store.state.user.applied) this.$store.dispatch('user/finnishApply', false)
  784. }
  785. })
  786. },
  787. // 获取单位信息
  788. getCompanyTreeInfo() {
  789. const that = this
  790. getCompanyTree({}).then(res => {
  791. if (res.code === 1) {
  792. // 递归操作
  793. const resultData = res.result
  794. var treeArr = []
  795. that.companyOptions = []
  796. that.recursiveData('1', resultData, treeArr)
  797. that.treeData = treeArr
  798. // 所属公司
  799. that.companyOptionData(treeArr, that.companyOptions)
  800. }
  801. })
  802. },
  803. recursiveData(typestr, tdata, resData) {
  804. const that = this
  805. if (Array.isArray(tdata) && tdata.length > 0) {
  806. tdata.forEach(function(v, i) {
  807. // console.log('内页:' + JSON.stringify(v))
  808. resData[i] = {}
  809. if (typestr === '1') {
  810. resData[i].id = 'gs_' + v.id
  811. resData[i].icon = 'el-icon-s-home'
  812. resData[i].companyId = v.id
  813. resData[i].companyName = v.companyName
  814. resData[i].parentId = v.parentId
  815. resData[i].coding = v.coding
  816. resData[i].address = v.address
  817. resData[i].phone = v.phone
  818. resData[i].abbreviation = v.abbreviation
  819. resData[i].code = v.code
  820. resData[i].type = typestr
  821. }
  822. if (typestr === '2') {
  823. resData[i].id = 'bm_' + v.id
  824. resData[i].icon = 'el-icon-s-cooperation'
  825. resData[i].companyName = v.name
  826. resData[i].companyId = v.companyId
  827. resData[i].parentId = v.parentId
  828. resData[i].coding = v.coding
  829. resData[i].address = ''
  830. resData[i].phone = v.phone
  831. resData[i].abbreviation = v.shortName
  832. resData[i].code = v.code
  833. resData[i].statusFlag = v.statusFlag
  834. resData[i].type = typestr
  835. }
  836. var arr = []
  837. if (Array.isArray(v.subCompany) && v.subCompany.length > 0) {
  838. if (v.subCompany.length > 0) {
  839. // 部门
  840. that.recursiveData('1', v.subCompany, arr)
  841. }
  842. }
  843. if (Array.isArray(v.deptVos) && v.deptVos.length > 0) {
  844. if (v.deptVos.length > 0) {
  845. // 部门
  846. that.recursiveData('2', v.deptVos, arr)
  847. }
  848. }
  849. resData[i].children = arr
  850. })
  851. }
  852. },
  853. /**
  854. * @description 公司下拉选项
  855. */
  856. companyOptionData(tdata, resData) {
  857. const that = this
  858. if (Array.isArray(tdata) && tdata.length > 0) {
  859. tdata.forEach(function(v, i) {
  860. // console.log('内页:' + JSON.stringify(v))
  861. if (v.type === '1') {
  862. resData[i] = {}
  863. resData[i].value = v.id
  864. resData[i].label = v.companyName
  865. var arr = []
  866. if (v.children.length > 0) {
  867. that.companyOptionData(v.children, arr)
  868. if (Array.isArray(arr) && arr.length > 0) {
  869. resData[i].children = arr
  870. }
  871. }
  872. }
  873. })
  874. }
  875. },
  876. deptOptionData(tdata, resData) {
  877. const that = this
  878. if (Array.isArray(tdata) && tdata.length > 0) {
  879. tdata.forEach(function(v, i) {
  880. // console.log('内页:' + JSON.stringify(v))
  881. if (v.type === '2') {
  882. resData[i] = {}
  883. resData[i].value = v.id
  884. resData[i].label = v.companyName
  885. var arr = []
  886. if (v.children.length > 0) {
  887. that.deptOptionData(v.children, arr)
  888. if (Array.isArray(arr) && arr.length > 0) {
  889. resData[i].children = arr
  890. }
  891. }
  892. }
  893. })
  894. }
  895. },
  896. /**
  897. * @description 公司下拉
  898. */
  899. companyChange(value) {
  900. const that = this
  901. that.companyId = value
  902. const lastValue = value[value.length - 1]
  903. that.deptList = []
  904. deepTree(that.treeData, lastValue)
  905. that.deptOptions = []
  906. that.deptOptionData(that.deptList, that.deptOptions)
  907. // 递归树
  908. function deepTree(treeList, companyId) {
  909. for (let index = 0; index < treeList.length; index++) {
  910. const element = treeList[index]
  911. if (element.id == companyId && element.type == '1') {
  912. console.log('查询到了该节点')
  913. const _deptData = element.children.filter((item) => {
  914. return item.type == '2'
  915. })
  916. that.deptList = _deptData
  917. return true
  918. }
  919. console.log('遍历树')
  920. if (element.children && element.children.length) {
  921. if (deepTree(element.children, companyId)) {
  922. return true
  923. }
  924. }
  925. }
  926. }
  927. },
  928. /**
  929. * @description 部门下拉
  930. */
  931. companyDept(value) {
  932. const that = this
  933. that.departmentId = value
  934. },
  935. // 获取角色信息
  936. getRoleInfo() {
  937. getRoleList({ size: 10000 }).then(res => {
  938. this.role.optionsRole = res.result.records
  939. for (let i = 0; i < this.role.optionsRole.length; i++) {
  940. this.role.optionsRole[i].id = this.role.optionsRole[i].id.toString()
  941. this.role.optionsRole[i].name = this.role.optionsRole[i].roleName
  942. }
  943. })
  944. },
  945. // 审核弹窗按钮点击事件
  946. handleAuditBtnClick(type) {
  947. if (type === 'cancel') {
  948. this.auditVisible = false
  949. this.$refs.auditForm.clearValidate()
  950. } else {
  951. this.$refs.auditForm.validate(valid => {
  952. if (valid) {
  953. const copyData = JSON.parse(JSON.stringify(this.auditInfo))
  954. copyData.roles = copyData.roles.join(',')
  955. const data = Object.assign(copyData, this.multipleSelection[0])
  956. data.auditstate = data.auditState
  957. data.auditstatus = data.auditStatus
  958. auditUser(data).then((res) => {
  959. if (res.code === 1) {
  960. this.$message({
  961. type: 'success',
  962. message: '用户审核成功'
  963. })
  964. this.onSubmit()
  965. // this.fetchData(this.pagination)
  966. this.auditVisible = false
  967. }
  968. })
  969. } else {
  970. return false
  971. }
  972. })
  973. }
  974. },
  975. handleCurrentChange(currentPage) {
  976. // console.log('2222111')
  977. this.pagination.current = currentPage
  978. this.fetchData(this.pagination)
  979. },
  980. handleSizeChange(pagesize) {
  981. // console.log('aaaa')
  982. this.pagination.size = pagesize
  983. this.fetchData(this.pagination)
  984. },
  985. handleSelectionChange(value) {
  986. this.multipleSelection = value
  987. // console.log('1111', value)
  988. },
  989. // handleClick(value) {
  990. // console.log('查看', value)
  991. // },
  992. handleEdit() {
  993. console.log('编辑', this.multipleSelection)
  994. this.dialogTitle = '修改用户'
  995. this.dialogVisible = true
  996. this.editData = this.multipleSelection[0]
  997. // this.$refs.ruleForm.handleEdit(value)
  998. },
  999. // handleDelete(value) {
  1000. // console.log('删除', value)
  1001. // },
  1002. onSubmit() {
  1003. let lastCompanyId = ''
  1004. let lastDeptId = ''
  1005. // 部门
  1006. if (Array.isArray(this.companyId) && this.companyId.length > 0) {
  1007. const _department_companyId = this.companyId
  1008. lastCompanyId = (_department_companyId[_department_companyId.length - 1] + '').replace('gs_', '')
  1009. }
  1010. if (Array.isArray(this.departmentId) && this.departmentId.length > 0) {
  1011. const _department_parentId = this.departmentId
  1012. lastDeptId = (_department_parentId[_department_parentId.length - 1] + '').replace('bm_', '')
  1013. }
  1014. this.pagination.current = 1
  1015. let data = {
  1016. userLevel: '1', // 默认只展示为0的用户
  1017. realName: this.realName,
  1018. username: this.username,
  1019. companyId: lastCompanyId,
  1020. departmentId: lastDeptId,
  1021. enableFlag: this.enableFlag,
  1022. lockFlag: this.lockFlag,
  1023. auditstatus: this.auditStatus
  1024. }
  1025. data = Object.assign({}, data, this.pagination)
  1026. console.log('查询条件:' + JSON.stringify(data))
  1027. this.fetchData(data)
  1028. console.log('submit!')
  1029. },
  1030. onSubmitAll() {
  1031. this.fetchData(this.pagination)
  1032. },
  1033. handleAdded() {
  1034. console.log('新增')
  1035. // this.$refs.ruleForm.resetFields()
  1036. this.dialogTitle = '新增用户'
  1037. this.dialogVisible = true
  1038. this.editData = {}
  1039. },
  1040. /**
  1041. * @description 赋值新增 用户角色
  1042. */
  1043. handleAddedCopy() {
  1044. console.log('新增')
  1045. // this.$refs.ruleForm.resetFields()
  1046. this.dialogTitle = '复制新增用户'
  1047. this.dialogVisible = true
  1048. const roleIdAry = []
  1049. console.log('角色绑定', JSON.stringify(this.multipleSelection))
  1050. const currentUsers = this.multipleSelection
  1051. if (currentUsers.length !== 0) {
  1052. // 获取选中的角色数据
  1053. currentUsers.forEach(userinfo => {
  1054. const roleIdList = userinfo.roleIdList
  1055. if (!this.strIsNull(roleIdList)) {
  1056. const roleIds = roleIdList.split(',')
  1057. // 角色ID
  1058. roleIds.forEach(roleId => {
  1059. roleIdAry.push(roleId)
  1060. })
  1061. }
  1062. })
  1063. }
  1064. const roleIds = Array.from(new Set(roleIdAry))
  1065. this.editData = {
  1066. roles: roleIds
  1067. }
  1068. },
  1069. handleManyUser() {
  1070. console.log('批量删除')
  1071. if (this.multipleSelection.length > 0) {
  1072. this.dialogDelete = true
  1073. } else {
  1074. this.$message.error('请选择要删除的用户')
  1075. }
  1076. },
  1077. // 确认删除
  1078. confirmDelete() {
  1079. console.log('2222', this.multipleSelection)
  1080. const ids = []
  1081. for (let i = 0; i < this.multipleSelection.length; i++) {
  1082. ids.push(this.multipleSelection[i].id)
  1083. }
  1084. const data = {
  1085. ids: ids.toString()
  1086. }
  1087. const _this = this
  1088. deleteUser(data).then(res => {
  1089. if (res.code !== -1) {
  1090. _this.$message.success('删除成功')
  1091. _this.onSubmit()
  1092. }
  1093. })
  1094. this.dialogDelete = false
  1095. },
  1096. enableSettings() {
  1097. console.log('启用设置', this.multipleSelection)
  1098. if (this.multipleSelection.length === 1) {
  1099. this.enable.enableSetting = true
  1100. this.enable.enableName = this.multipleSelection[0].realName
  1101. this.enableFlag = this.multipleSelection[0].enableFlag
  1102. } else {
  1103. this.$message.error('请选择要启用的一个用户')
  1104. }
  1105. },
  1106. // 启用设置
  1107. confirmEnable() {
  1108. const data = new FormData()
  1109. data.append('id', this.multipleSelection[0].id)
  1110. data.append('enableFlag', this.enableFlag)
  1111. editUser(data).then(res => {
  1112. this.$message.success('设置成功')
  1113. // this.fetchData(this.pagination)
  1114. this.onSubmit()
  1115. })
  1116. this.enable.enableSetting = false
  1117. },
  1118. roleBinding() {
  1119. console.log('角色绑定', JSON.stringify(this.multipleSelection))
  1120. const currentUsers = this.multipleSelection
  1121. if (currentUsers.length !== 0) {
  1122. this.role.roleBind = true
  1123. const roleIdAry = []
  1124. const userIdAry = []
  1125. const userNameAry = []
  1126. // 获取选中的角色数据
  1127. currentUsers.forEach(userinfo => {
  1128. const roleIdList = userinfo.roleIdList
  1129. if (!this.strIsNull(roleIdList)) {
  1130. const roleIds = roleIdList.split(',')
  1131. // 角色ID
  1132. roleIds.forEach(roleId => {
  1133. roleIdAry.push(roleId)
  1134. })
  1135. }
  1136. // 用户编号
  1137. userIdAry.push(userinfo.id)
  1138. // 用户名称
  1139. userNameAry.push(userinfo.realName)
  1140. })
  1141. this.role.roleName = userNameAry.toString()
  1142. this.userId = userIdAry
  1143. this.roleId = Array.from(new Set(roleIdAry))
  1144. this.copyRole = []
  1145. console.log('角色:' + JSON.stringify(this.roleId) + ' 用户:' + JSON.stringify(this.userId) + ' ' + this.role.roleName)
  1146. // this.role.roleName = this.multipleSelection[0].realName
  1147. // console.log('32232', this.multipleSelection)
  1148. // this.roleId = this.multipleSelection[0].roleIdList
  1149. // ? this.multipleSelection[0].roleIdList.split(',')
  1150. // : []
  1151. } else {
  1152. this.$message.error('请选择至少一个用户')
  1153. }
  1154. // if (this.multipleSelection.length !== 1) {
  1155. // this.role.roleBind = true
  1156. // this.role.roleName = this.multipleSelection[0].realName
  1157. // console.log('32232', this.multipleSelection)
  1158. // this.roleId = this.multipleSelection[0].roleIdList
  1159. // ? this.multipleSelection[0].roleIdList.split(',')
  1160. // : []
  1161. // } else {
  1162. // this.$message.error('请选择要绑定的一个用户')
  1163. // }
  1164. },
  1165. // 角色绑定
  1166. confirmRoleBind() {
  1167. const data = {
  1168. userids: this.userId.toString(),
  1169. roles: this.roleId.toString()
  1170. }
  1171. console.log('参数:', JSON.stringify(data))
  1172. // return false
  1173. roleBind(data).then(res => {
  1174. if (res.code !== -1) {
  1175. this.$message.success('绑定成功')
  1176. // this.fetchData(this.pagination)
  1177. this.onSubmit()
  1178. }
  1179. })
  1180. this.role.roleBind = false
  1181. },
  1182. userUnlock() {
  1183. console.log('用户解锁')
  1184. if (this.multipleSelection.length !== 1) {
  1185. this.$message.error('请选择要绑定的一个用户')
  1186. }
  1187. const data = {
  1188. id: this.multipleSelection[0].id
  1189. }
  1190. setUserUnlock(data).then(res => {
  1191. this.$message.success(res.message)
  1192. })
  1193. },
  1194. templateDownload() {
  1195. const params = {
  1196. templateFlag: 0,
  1197. templateServiceType: 'userService'
  1198. }
  1199. downloadTemplate(params).then(res => {
  1200. console.log(res)
  1201. const blob = URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }))
  1202. const a = document.createElement('a')
  1203. a.href = blob
  1204. a.download = '批量账号创建模板.xlsx'
  1205. a.click()
  1206. })
  1207. },
  1208. /**
  1209. * 导出
  1210. */
  1211. exportDownload() {
  1212. debugger
  1213. const params = {
  1214. templateFlag: 1,
  1215. templateServiceType: 'userService'
  1216. }
  1217. let lastCompanyId = ''
  1218. let lastDeptId = ''
  1219. // 部门
  1220. if (Array.isArray(this.companyId) && this.companyId.length > 0) {
  1221. const _department_companyId = this.companyId
  1222. lastCompanyId = (_department_companyId[_department_companyId.length - 1] + '').replace('gs_', '')
  1223. }
  1224. if (Array.isArray(this.departmentId) && this.departmentId.length > 0) {
  1225. const _department_parentId = this.departmentId
  1226. lastDeptId = (_department_parentId[_department_parentId.length - 1] + '').replace('bm_', '')
  1227. }
  1228. const data = {
  1229. userLevel: '1', // 默认只展示为0的用户
  1230. realName: this.realName,
  1231. username: this.username,
  1232. companyId: lastCompanyId,
  1233. departmentId: lastDeptId,
  1234. enableFlag: this.enableFlag,
  1235. lockFlag: this.lockFlag,
  1236. auditstatus: this.auditStatus
  1237. }
  1238. if (this.strIsNull(data.realName)) {
  1239. delete data.realName
  1240. }
  1241. if (this.strIsNull(data.username)) {
  1242. delete data.username
  1243. }
  1244. if (this.strIsNull(data.departmentId)) {
  1245. delete data.departmentId
  1246. }
  1247. if (this.strIsNull(data.enableFlag)) {
  1248. delete data.enableFlag
  1249. }
  1250. if (this.strIsNull(data.lockFlag)) {
  1251. delete data.lockFlag
  1252. }
  1253. if (this.strIsNull(data.auditstatus)) {
  1254. delete data.auditstatus
  1255. }
  1256. const dto = {
  1257. dto: JSON.stringify(data)
  1258. }
  1259. const exportParams = Object.assign({}, dto, params)
  1260. console.log(exportParams)
  1261. downloadTemplate(exportParams).then(res => {
  1262. console.log(res)
  1263. const blob = URL.createObjectURL(new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }))
  1264. const a = document.createElement('a')
  1265. a.href = blob
  1266. a.download = '用户信息.xlsx'
  1267. a.click()
  1268. })
  1269. },
  1270. /**
  1271. * 输入框组件数据绑定方法事件
  1272. * @param {*} key
  1273. * @param {*} event
  1274. */
  1275. onInput(key, event) {
  1276. this[key] = event
  1277. },
  1278. /**
  1279. * 下拉选择组件数据绑定方法事件
  1280. */
  1281. changeSelectValue(key, event) {
  1282. this[key] = key === 'departmentId' ? event.toString() : event
  1283. // console.log('2222', this.roleId)
  1284. },
  1285. changeSelectMultipleValue(key, event) {
  1286. console.log('222222', key, event)
  1287. this[key] = event
  1288. },
  1289. // 提交
  1290. submitForm() {
  1291. this.$refs.ruleForm.submitForm()
  1292. // if (this.msg === '成功') {
  1293. // this.dialogVisible = false
  1294. // this.fetchData()
  1295. // }
  1296. },
  1297. // 取消重置表单
  1298. resetForm() {
  1299. this.$refs.ruleForm.resetFields()
  1300. this.dialogVisible = false
  1301. },
  1302. // 提示
  1303. remind(data) {
  1304. this.dialogVisible = false
  1305. // this.fetchData(this.pagination)
  1306. this.onSubmit()
  1307. },
  1308. // 批量上传
  1309. upload() {
  1310. const fileObj = document.getElementById('file').files // js 获取文件对象
  1311. const form = new FormData()
  1312. form.append('file', fileObj[0])
  1313. },
  1314. /**
  1315. * @description 获取用户信息
  1316. */
  1317. getCopyDeptUserList() {
  1318. const data = {
  1319. userLevel: 1,
  1320. current: 1,
  1321. size: 10000000
  1322. }
  1323. this.copyUsers = []
  1324. getUserList(data).then(res => {
  1325. // console.log(res);
  1326. res.result.records.forEach(item => {
  1327. this.copyUsers.push({
  1328. id: item.id,
  1329. name: item.realName,
  1330. roleIdList: item.roleIdList
  1331. })
  1332. })
  1333. })
  1334. },
  1335. /**
  1336. * @description 获取选中用户的角色,并赋值
  1337. */
  1338. copyRoleChange(key, event) {
  1339. console.log('copyRoleChange:', key, event)
  1340. this[key] = event
  1341. this.roleId = this.comCopyRole(event)
  1342. },
  1343. /**
  1344. * @description 获取选中用户的角色,并赋值
  1345. */
  1346. setCopyRoleId(roleAry) {
  1347. console.log('setCopyRoleId:' + roleAry)
  1348. this.auditInfo.roles = this.comCopyRole(roleAry)
  1349. },
  1350. /**
  1351. * @description 获取选择的用户
  1352. */
  1353. comCopyRole(roleAry) {
  1354. const that = this
  1355. // 筛选出角色
  1356. const roleUsers = that.copyUsers.filter((item, index) => {
  1357. return roleAry.includes(item.id)
  1358. })
  1359. const roleIdAry = []
  1360. // 获取选中的角色数据
  1361. roleUsers.forEach(userinfo => {
  1362. const roleIdList = userinfo.roleIdList
  1363. if (!that.strIsNull(roleIdList)) {
  1364. const roleIds = roleIdList.split(',')
  1365. // 角色ID
  1366. roleIds.forEach(roleId => {
  1367. roleIdAry.push(roleId)
  1368. })
  1369. }
  1370. })
  1371. const roleId = Array.from(new Set(roleIdAry))
  1372. return roleId
  1373. },
  1374. /*
  1375. * @description 判断字符串是否为空
  1376. */
  1377. strIsNull(strVal) {
  1378. strVal = strVal || ''
  1379. return (typeof (strVal) === 'undefined' || strVal == null || strVal == '' || strVal == 'null')
  1380. }
  1381. }
  1382. }
  1383. </script>
  1384. <style lang="scss" scoped>
  1385. .userRights{
  1386. height: 100%;
  1387. width: 100%;
  1388. padding: 5px;
  1389. .filteroption {
  1390. width:100%;
  1391. height:80px;
  1392. font-size: 14px;
  1393. display: flex;
  1394. flex-direction: column;
  1395. align-items: center;
  1396. justify-content: flex-start;
  1397. .data_box{
  1398. width: 100%;
  1399. height: 40px;
  1400. line-height: 40px;
  1401. display: flex;
  1402. flex-direction: row;
  1403. align-items: center;
  1404. justify-content: flex-start;
  1405. overflow: hidden;
  1406. .input_item{
  1407. height: 34px;
  1408. margin-right:8px;
  1409. width:300px;
  1410. display: inline-block;
  1411. // display: flex;
  1412. // flex-direction: row;
  1413. // align-items: center;
  1414. // justify-content: flex-start;
  1415. .span_item{
  1416. width: 74px;
  1417. float: left;
  1418. // border:1px red solid;
  1419. }
  1420. .el-cascader{
  1421. width: calc(100% - 74px);
  1422. // border:1px red solid;
  1423. }
  1424. }
  1425. }
  1426. .btn_box{
  1427. width: 100%;
  1428. height: 40px;
  1429. line-height: 40px;
  1430. overflow: hidden;
  1431. }
  1432. }
  1433. .tableheight{
  1434. margin-top: 4px;
  1435. height: calc(100% - 84px);
  1436. // border:1px red solid;
  1437. }
  1438. }
  1439. .el-select {
  1440. display: block;
  1441. }
  1442. .user-base-info {
  1443. > div {
  1444. display: flex;
  1445. flex-wrap: wrap;
  1446. margin-bottom: 10px;
  1447. > span {
  1448. &:nth-of-type(1) {
  1449. display: inline-block;
  1450. width: 100px;
  1451. text-align: right;
  1452. }
  1453. &:nth-of-type(2) {
  1454. width: calc(100% - 100px);
  1455. }
  1456. & + img {
  1457. width: calc(100% - 410px);
  1458. }
  1459. }
  1460. }
  1461. }
  1462. .audit-info {
  1463. > div {
  1464. display: flex;
  1465. align-items: center;
  1466. flex-wrap: wrap;
  1467. margin-bottom: 10px;
  1468. > span {
  1469. display: block;
  1470. width: 100px;
  1471. text-align: right;
  1472. }
  1473. }
  1474. }
  1475. .audit-title {
  1476. display: block;
  1477. text-align: center;
  1478. margin-bottom: 10px;
  1479. }
  1480. .base-info {
  1481. .el-row {
  1482. display: flex;
  1483. margin-bottom: 20px;
  1484. .title {
  1485. display: inline-block;
  1486. width: 100px;
  1487. text-align: right;
  1488. }
  1489. .title + span, img {
  1490. display: inline-block;
  1491. width: 380px;
  1492. }
  1493. img {
  1494. width: 120px;
  1495. }
  1496. }
  1497. }
  1498. .custom-row {
  1499. display: flex;
  1500. margin-bottom: 20px;
  1501. span {
  1502. display: inline-block;
  1503. width: 80%;
  1504. &.title {
  1505. width: 100px;
  1506. text-align: right;
  1507. }
  1508. }
  1509. }
  1510. /* 表单大小设置 */
  1511. </style>