users.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. <template>
  2. <div>
  3. <el-card class="box-card" style="height: calc(100vh - 92px);">
  4. <div slot="header" style="height: 20px;">
  5. <span style="float: left;">
  6. <i class="icon icon-table2"></i>
  7. </span>
  8. <el-breadcrumb class="heading" style="float: left; margin-left: 5px">
  9. <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
  10. <el-breadcrumb-item :to="{ path: '/system/users' }">用户管理</el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <span style="float: right;">
  13. <el-button size="mini" type="primary" style="margin-left:10px; margin-top: -4px;" @click="opendatadialog(1,null,-1);resetForm('organizeform')">新增用户</el-button>
  14. </span>
  15. <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
  16. <el-form-item label="账号">
  17. <el-input size="mini" style="width: 165px;" v-model="keyword" placeholder="请输入账号"></el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-dropdown split-button type="primary" size="mini" @click="seachdata" @command="searchCommand">
  21. 查询
  22. <el-dropdown-menu slot="dropdown">
  23. <!-- <el-dropdown-item command="search">高级查询</el-dropdown-item> -->
  24. <el-dropdown-item command="clear">查询重置</el-dropdown-item>
  25. </el-dropdown-menu>
  26. </el-dropdown>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. <el-table :data="list" border>
  31. <el-table-column label="操作" align="center">
  32. <template slot-scope="scope">
  33. <el-button size="small" @click="opendatadialog(2,scope.row,scope.$index);" type="text" icon="el-icon-edit"
  34. title="编辑"></el-button>
  35. <el-button size="small" type="text" style="margin-left:3px" icon="el-icon-delete" title="删除" @click="deletedata(scope.row)"></el-button>
  36. <!-- <el-button size="small" type="text" style="margin-left:1px" title="权限" @click="permission(scope.row)"><i class="icon icon-lock"></i></el-button> -->
  37. <el-button size="small" type="text" style="margin-left:3px" title="密码重置" @click="resetpwd(scope.row)">
  38. <i class="icon icon-spinner11"></i>
  39. </el-button>
  40. <el-button size="small" type="text" style="margin-left:3px" title="设置角色" @click="roleset(scope.row)">
  41. <i class="icon icon-users"></i>
  42. </el-button>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="Username" align="center" label="账号" show-overflow-tooltip></el-table-column>
  46. <el-table-column prop="Realname" align="center" label="用户名"></el-table-column>
  47. <el-table-column prop="Departmentname" align="center" label="所属组织"></el-table-column>
  48. <!-- <el-table-column prop="RealnameRole" align="center" label="角色"></el-table-column> -->
  49. <el-table-column prop="Telephone" align="center" label="手机" show-overflow-tooltip></el-table-column>
  50. <el-table-column label="座机" align="center" prop="Mobile" show-overflow-tooltip></el-table-column>
  51. <el-table-column v-if="this.appclient != 'lims'" prop="Description" align="center" label="备注"
  52. show-overflow-tooltip></el-table-column>
  53. </el-table>
  54. </el-card>
  55. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
  56. :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="currentItemCount">
  57. </el-pagination>
  58. <el-dialog :title="dialogtitle" :visible.sync="datadialogVisible" width="720px">
  59. <el-form :model="userform" :rules="rulesuser" ref="userform" label-width="100px">
  60. <el-row>
  61. <el-col :span="24">
  62. <el-form-item label="账号/Email" prop="username" required>
  63. <el-input v-model="userform.username" auto-complete="off" :disabled="disabledserial"></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="24">
  67. <el-form-item label="用户名" required prop="realname">
  68. <el-input v-model="userform.realname"></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="12">
  72. <el-form-item label="所属组织" required>
  73. <el-cascader :options="orgtreelist" :props="orgtreeprops" change-on-select :show-all-levels="false"
  74. v-model="selectedorg" placeholder="请选择组织"></el-cascader>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="24">
  78. <el-form-item label="手机" prop="telephone">
  79. <el-input v-model="userform.telephone" auto-complete="off"></el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="24">
  83. <el-form-item label="座机" prop="mobile">
  84. <el-input v-model="userform.mobile" auto-complete="off"></el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="24">
  88. <el-form-item v-if="this.appclient != 'lims'" label="备注">
  89. <el-input type="textarea" v-model="userform.description" auto-complete="off"></el-input>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="24">
  93. <el-form-item v-if=" this.appclient== 'lims'" label="签名">
  94. <!-- <el-input type="textarea" v-model="userform.description" auto-complete="off"></el-input> -->
  95. <el-upload style="margin-top: 10px;" class="usersignimg-uploader" :action="imghost + '/api/limsupload/usersignimg'"
  96. :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
  97. <img v-if="imageUrl" :src="imageUrl" class="uploadusersignimg">
  98. <i v-else class="el-icon-plus usersignimg-uploader-icon"></i>
  99. </el-upload>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. </el-form>
  104. <div slot="footer" class="dialog-footer">
  105. <el-button @click="datadialogVisible = false">取 消</el-button>
  106. <el-button type="primary" @click="savedata('userform')">确 定</el-button>
  107. </div>
  108. </el-dialog>
  109. <el-dialog :title="rolesettitle" :visible.sync="rolesetVisible">
  110. <el-checkbox :indeterminate="isrolecheckall" v-model="roleCheckAll" @change="handleCheckAllChange">全选</el-checkbox>
  111. <div style="margin-top:20px;">
  112. <el-checkbox-group v-model="selectedrole">
  113. <el-checkbox v-for="role in rolelist" @change="handlecheckedrolechange" :label="role.Id" :value="role.Id" :key="role.Id">{{role.Realname}}</el-checkbox>
  114. </el-checkbox-group>
  115. </div>
  116. <div slot="footer">
  117. <el-button @click="rolesetVisible = false">取消</el-button>
  118. <el-button type="primary" @click="rolesave()">确定</el-button>
  119. </div>
  120. </el-dialog>
  121. <el-dialog :title="permissiondialogtitle" :visible.sync="permissiondatadialogVisible" top="5vh">
  122. <el-col :span="6" style="margin-right: 10px">
  123. <div class="userpermisstreediv">
  124. <el-tree style="border: 0" node-key="id" show-checkbox :data="orgtreelist" :props="orgtreeprops"
  125. :default-expanded-keys="userdepartment" @check-change="userpermissorgcheckedchange" ref="userpermisstree">
  126. </el-tree>
  127. </div>
  128. </el-col>
  129. <el-col :span="17">
  130. <el-form ref="alertform">
  131. <el-form-item>
  132. <div class="userpermissdiv">
  133. <el-checkbox-group v-model="userpermissdevicesselects">
  134. <el-checkbox v-for="item in equipdeviceslist" :label="item.Id+''" :key="item.Id">{{item.Code}}</el-checkbox>
  135. </el-checkbox-group>
  136. </div>
  137. </el-form-item>
  138. </el-form>
  139. </el-col>
  140. <div slot="footer" class="dialog-footer" style="margin-top:-35px;">
  141. <el-button @click="permissiondatadialogVisible = false">取 消</el-button>
  142. <el-button type="primary" @click="savepermission()">确 定</el-button>
  143. </div>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import {
  149. mapGetters
  150. } from 'vuex'
  151. export default {
  152. name: 'users',
  153. data() {
  154. var checkusername = (rule, value, callback) => {
  155. if (!value) {
  156. callback(new Error('请输入账号'))
  157. } else {
  158. if (this.appclient == 'lims') { //大港油田lims系统不用邮箱
  159. callback()
  160. }
  161. let re = /^([a-zA-Z0-9]+[_|-|.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|-|.|-]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/
  162. if (!re.test(value)) {
  163. callback(new Error('请输入正确的邮箱地址'))
  164. } else {
  165. callback()
  166. }
  167. }
  168. }
  169. return {
  170. downloading: '',
  171. imghost: "",
  172. organdialogVisible: false,
  173. currentItemCount: 0,
  174. currentItemCount2: 0,
  175. currentItemCount3: 0,
  176. currentPage: 1,
  177. size: 10,
  178. rolesettitle: '',
  179. rolesetVisible: false,
  180. roleCheckAll: false,
  181. isrolecheckall: false,
  182. selectedrole: [],
  183. bossSelect: [],
  184. list: [],
  185. rolelist: [],
  186. mustrolelist: [],
  187. keyword: '',
  188. datadialogVisible: false,
  189. dialogtitle: '',
  190. disabledserial: false,
  191. IsInnerOrganize: 1,
  192. appclient: '',
  193. userform: {
  194. username: '',
  195. realname: '',
  196. telephone: '',
  197. mobile: '',
  198. sign: '',
  199. description: '',
  200. id: 0,
  201. departmentid: '',
  202. departmentname: '',
  203. RealnameRole: '',
  204. GroupId: '',
  205. GroupName: '',
  206. },
  207. rulesuser: {
  208. username: [{
  209. validator: checkusername,
  210. trigger: 'blur'
  211. }],
  212. realname: [{
  213. required: true,
  214. message: '用户名',
  215. trigger: 'blur'
  216. }]
  217. },
  218. imageUrl: "",
  219. operatingitem: 0,
  220. permissiondialogtitle: '',
  221. permissiondatadialogVisible: false,
  222. isfristchecked: false, // 过滤点击树时出现的多次触发选择事件
  223. userpermisstreedata: [], // 组织tree 数据
  224. userpermissdevicesselects: [], // 设备批量设置所选设备
  225. equipdeviceslist: [], // 批量设置设备设备所有数据
  226. equipalllist: [], // 设备所有数据
  227. checkedarr: [], // 树形控件多选框
  228. orgtreelist: [],
  229. orgtreeprops: {
  230. value: 'id',
  231. label: 'Fullname',
  232. children: 'children'
  233. },
  234. rolelistcheckall: [],
  235. selectedorg: [],
  236. userdepartment: [],
  237. ischeckbj: false, // 过滤字段勾选时触发的选中事件
  238. }
  239. },
  240. computed: mapGetters({
  241. authUser: 'authUser'
  242. }),
  243. created() {
  244. this.appclient = process.env.appclient
  245. this.imghost = process.env.limsimgserverhost;
  246. this.getorgtreelist()
  247. this.initData()
  248. // this.loadequipsall()
  249. this.userdepartment.push(parseInt(this.authUser.Profile.DepartmentId))
  250. this.selectedorg = [parseInt(this.authUser.Profile.DepartmentId)]
  251. },
  252. methods: {
  253. initData() {
  254. let _this = this
  255. // paginate
  256. const params = {
  257. _currentPage: this.currentPage,
  258. _size: this.size,
  259. keyword: this.keyword
  260. }
  261. // request
  262. this.$axios.get('users/list', {
  263. params
  264. })
  265. .then(res => {
  266. // response
  267. _this.list = res.data.items
  268. _this.currentItemCount = res.data.currentItemCount
  269. })
  270. .catch(err => {
  271. // handle error
  272. console.error(err)
  273. })
  274. this.$axios.get('role/list', {})
  275. .then(res => {
  276. // response
  277. _this.rolelist = res.data.items
  278. _this.roleItemCount = res.data.currentItemCount
  279. for (var i = 0; i < _this.roleItemCount; i++) {
  280. _this.rolelistcheckall.push(_this.rolelist[i].Id)
  281. }
  282. })
  283. .catch(err => {
  284. // handle error
  285. console.error(err)
  286. })
  287. },
  288. handleAvatarSuccess(res, file) {
  289. this.userform.sign = res
  290. this.imageUrl = URL.createObjectURL(file.raw);
  291. },
  292. beforeAvatarUpload(file) {
  293. console.log(file);
  294. const isimg = file.type.indexOf("image/") === 0;
  295. const isLt50k = file.size / 1024 / 50 < 1;
  296. if (!isimg) {
  297. this.$message.error("上传图片只能是 图片 格式!");
  298. return false;
  299. }
  300. if (!isLt50k) {
  301. this.$message.error("上传图片大小不能超过 50kb!");
  302. return false;
  303. }
  304. return true;
  305. },
  306. roleset(val) {
  307. this.rolesettitle = '用户(' + val.Realname + ')-角色管理'
  308. this.rolesetVisible = true
  309. this.selecteduserid = val.Id + ''
  310. this.selectedrole = []
  311. let _this = this
  312. // request
  313. this.$axios.get('users/getuserrole/' + this.selecteduserid, {})
  314. .then(res => {
  315. console.log("-------res----",res.data)
  316. _this.mustrolelist = []
  317. // response
  318. for (let i = 0; i < res.data.length; i++) {
  319. if (_this.roleisexist(parseInt(res.data[i]))) {
  320. _this.selectedrole.push(parseInt(res.data[i]))
  321. }
  322. let flag = false
  323. let rdx = 0
  324. for (rdx = 0; rdx < _this.rolelist.length; rdx++) {
  325. if (parseInt(_this.rolelist[rdx].Id) == parseInt(res.data[i])) {
  326. flag = true;
  327. break;
  328. }
  329. }
  330. if (!flag) {
  331. _this.mustrolelist.push(parseInt(res.data[i]))
  332. }
  333. }
  334. let checkedCount = this.selectedrole.length
  335. this.roleCheckAll = checkedCount === this.rolelist.length
  336. this.isrolecheckall = checkedCount > 0 && checkedCount < this.rolelist.length
  337. })
  338. .catch(err => {
  339. // handle error
  340. console.error(err)
  341. })
  342. },
  343. rolesave() {
  344. let _this = this
  345. for (let mdx in this.mustrolelist) {
  346. if (this.selectedrole.indexOf(this.mustrolelist[mdx]) == -1) {
  347. this.selectedrole.push(parseInt(this.mustrolelist[mdx]))
  348. }
  349. }
  350. let rolestring = this.selectedrole.join(',')
  351. // request
  352. this.$axios.put('users/setuserrole/' + this.selecteduserid + '_' + rolestring, {})
  353. .then(res => {
  354. // response
  355. if (res.data.code === 0) {
  356. _this.$message({
  357. type: 'success',
  358. message: res.data.message
  359. })
  360. // 更新界面
  361. this.list = []
  362. this.initData()
  363. this.rolesetVisible = false
  364. } else {
  365. _this.$message({
  366. type: 'warning',
  367. message: res.data.message
  368. })
  369. }
  370. })
  371. .catch(err => {
  372. // handle error
  373. console.error(err)
  374. })
  375. },
  376. handlecheckedrolechange() {
  377. let checkedCount = this.selectedrole.length
  378. this.roleCheckAll = checkedCount === this.rolelist.length
  379. this.isrolecheckall = checkedCount > 0 && checkedCount < this.rolelist.length
  380. },
  381. handleCheckAllChange(val) {
  382. this.selectedrole = val ? this.rolelistcheckall : []
  383. this.isrolecheckall = false
  384. },
  385. roleisexist(val) {
  386. for (let i = 0; i < this.rolelist.length; i++) {
  387. if (this.rolelist[i].Id === val) {
  388. return true
  389. }
  390. }
  391. return false
  392. },
  393. // loadequipsall() {
  394. // // toggle loading
  395. // let _this = this
  396. // // request
  397. // this.$axios.get('equipment/alllist', null)
  398. // .then(res => {
  399. // // response
  400. // _this.equipalllist = res.data.items
  401. // _this.equipdeviceslist = res.data.items
  402. // })
  403. // .catch(err => {
  404. // // handle error
  405. // console.error(err)
  406. // this.loading = false
  407. // })
  408. // },
  409. seachdata() {
  410. this.list = []
  411. this.currentPage = 1
  412. this.initData()
  413. },
  414. searchCommand(command) {
  415. if (command == 'clear') {
  416. this.clearSearch()
  417. }
  418. },
  419. handleSizeChange(value) {
  420. this.list = []
  421. this.size = value
  422. this.currentPage = 1
  423. this.initData()
  424. },
  425. handleCurrentChange(value) {
  426. this.currentPage = value
  427. this.list = []
  428. this.initData()
  429. },
  430. jstimehandle(val) {
  431. val = val.replace('T', ' ')
  432. return val.substring(0, 19)
  433. },
  434. opendatadialog(item, v, index) {
  435. let _this = this
  436. this.operatingitem = item
  437. this.datadialogVisible = true
  438. this.clearuserForm()
  439. if (item === 1) {
  440. this.dialogtitle = '新增用户'
  441. this.disabledserial = false
  442. } else if (item === 2) {
  443. this.$axios.get('organizes/parentlist/' + v.Departmentid, {})
  444. .then(res => {
  445. if (res.data.code === 0) {
  446. _this.dialogtitle = `编辑用户信息(${v.Realname})`
  447. _this.disabledserial = true
  448. _this.userform.username = v.Username
  449. _this.userform.realname = v.Realname + ''
  450. _this.userform.telephone = v.Telephone
  451. _this.userform.mobile = v.Mobile
  452. _this.userform.description = v.Description
  453. _this.userform.role = v.Roleid + ''
  454. _this.userform.id = v.Id
  455. // 选中状态
  456. _this.selectedorg = []
  457. let pidarr = res.data.message.split(',')
  458. for (var i = pidarr.length - 1; i >= 0; i--) {
  459. if (pidarr[i] !== '0') {
  460. _this.selectedorg.push(parseInt(pidarr[i]))
  461. }
  462. }
  463. } else {
  464. _this.$message({
  465. type: 'warning',
  466. message: '出现错误!'
  467. })
  468. this.datadialogVisible = false
  469. }
  470. })
  471. .catch(err => {
  472. // handle error
  473. console.error(err)
  474. })
  475. }
  476. },
  477. savedata(formName) {
  478. let _this = this
  479. if (this.selectedorg.length === 0) {
  480. _this.$message({
  481. type: 'warning',
  482. message: '请选择所属组织!'
  483. })
  484. return
  485. }
  486. this.$refs[formName].validate((valid) => {
  487. if (valid) {
  488. this.userform.departmentid = this.selectedorg[this.selectedorg.length - 1] + ''
  489. if (_this.operatingitem === 1) {
  490. _this.$axios.post('users', _this.userform)
  491. .then(res => {
  492. // response
  493. if (res.data.code === 0) {
  494. _this.$message({
  495. type: 'success',
  496. message: res.data.message
  497. })
  498. this.list = []
  499. _this.datadialogVisible = false
  500. this.initData()
  501. } else {
  502. _this.$message({
  503. type: 'warning',
  504. message: res.data.message
  505. })
  506. }
  507. })
  508. .catch(err => {
  509. // handle error
  510. console.error(err)
  511. })
  512. } else if (_this.operatingitem === 2) {
  513. _this.$axios.put('users/' + _this.userform.id, _this.userform)
  514. .then(res => {
  515. // response
  516. if (res.data.code === 0) {
  517. _this.$message({
  518. type: 'success',
  519. message: res.data.message
  520. })
  521. this.list = []
  522. _this.datadialogVisible = false
  523. // 更新界面
  524. this.initData()
  525. } else {
  526. _this.$message({
  527. type: 'warning',
  528. message: res.data.message
  529. })
  530. }
  531. })
  532. .catch(() => {})
  533. }
  534. } else {
  535. return false
  536. }
  537. })
  538. },
  539. deletedata(val) {
  540. let _this = this
  541. _this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  542. confirmButtonText: '确定',
  543. cancelButtonText: '取消',
  544. type: 'warning'
  545. }).then(() => {
  546. _this.$axios.delete('users/' + val.Id, null)
  547. .then(res => {
  548. // response
  549. if (res.data.code === 0) {
  550. _this.$message({
  551. type: 'success',
  552. message: res.data.message
  553. })
  554. this.list = []
  555. // 更新界面
  556. this.initData()
  557. } else {
  558. _this.$message({
  559. type: 'warning',
  560. message: res.data.message
  561. })
  562. }
  563. })
  564. .catch(() => {})
  565. }).catch(() => {})
  566. },
  567. resetForm(formName) {
  568. // this.$refs[formName].resetFields()
  569. },
  570. clearuserForm() {
  571. this.userform = {
  572. username: '',
  573. realname: '',
  574. telephone: '',
  575. mobile: '',
  576. description: ''
  577. }
  578. },
  579. permission(v) {
  580. let _this = this
  581. _this.ischeckbj = true // 过滤字段勾选时触发的选中事件
  582. this.userpermissdevicesselects = []
  583. this.permissiondialogtitle = `用户权限设置(${v.Realname})`
  584. this.permissiondatadialogVisible = true
  585. this.userform.id = v.Id
  586. this.$axios.get('users/permission/' + v.Id, null)
  587. .then(res => {
  588. // response
  589. res.data.forEach((item, k) => {
  590. this.userpermissdevicesselects.push(item)
  591. })
  592. _this.getorgbyeid(res.data + '')
  593. })
  594. .catch(err => {
  595. // handle error
  596. console.error(err)
  597. })
  598. },
  599. getorgbyeid(v) {
  600. let _this = this
  601. this.$axios.put('equipment/getorgidsbyeqids', {
  602. EquipmentIds: v
  603. })
  604. .then(res => {
  605. // response
  606. setTimeout(function () {
  607. setTimeout(function () {
  608. _this.ischeckbj = false
  609. }, 300)
  610. // 清空树选择框
  611. _this.$refs.userpermisstree.setCheckedKeys(res.data)
  612. }, 100)
  613. })
  614. .catch(err => {
  615. // handle error
  616. console.error(err)
  617. })
  618. },
  619. savepermission() {
  620. let _this = this
  621. _this.$axios.put('users/permission/' + this.userform.id, {
  622. channelids: this.userpermissdevicesselects + ''
  623. })
  624. .then(res => {
  625. // response
  626. if (res.data.code === 0) {
  627. _this.$message({
  628. type: 'success',
  629. message: res.data.message
  630. })
  631. _this.permissiondatadialogVisible = false
  632. } else {
  633. _this.$message({
  634. type: 'warning',
  635. message: res.data.message
  636. })
  637. }
  638. })
  639. .catch(() => {})
  640. },
  641. resetpwd(val) {
  642. let _this = this
  643. _this.$confirm(`此操作将重置用户(${val.Realname})的密码为123456, 是否继续?`, '提示', {
  644. confirmButtonText: '确定',
  645. cancelButtonText: '取消',
  646. type: 'warning'
  647. }).then(() => {
  648. _this.$axios.put('users/resetpwd/' + val.Id, null)
  649. .then(res => {
  650. // response
  651. if (res.data.code === 0) {
  652. _this.$message({
  653. type: 'success',
  654. message: res.data.message
  655. })
  656. } else {
  657. _this.$message({
  658. type: 'warning',
  659. message: res.data.message
  660. })
  661. }
  662. })
  663. .catch(() => {})
  664. }).catch(() => {})
  665. },
  666. // 选择组织树时触发
  667. userpermissorgcheckedchange(data, checked, indeterminate) {
  668. let _this = this
  669. if (!_this.ischeckbj) {
  670. if (!_this.isfristchecked) {
  671. _this.isfristchecked = true
  672. setTimeout(function () {
  673. _this.isfristchecked = false
  674. _this.checkorgusermanage()
  675. }, 100)
  676. }
  677. }
  678. },
  679. checkorgusermanage() {
  680. let orgids = []
  681. let selectnodes = this.$refs.userpermisstree.getCheckedNodes()
  682. selectnodes.forEach(row => {
  683. orgids.push(row.id)
  684. })
  685. const params = {
  686. orgids: orgids
  687. }
  688. let _this = this
  689. this.$axios.get('equipment/getidsbyoid', {
  690. params
  691. })
  692. .then(res => {
  693. // response
  694. _this.userpermissdevicesselects = []
  695. if (res.data) {
  696. _this.equipdeviceslist = res.data
  697. res.data.forEach(row => {
  698. _this.userpermissdevicesselects.push(row.Id)
  699. })
  700. } else {
  701. _this.equipdeviceslist = _this.equipalllist
  702. }
  703. })
  704. .catch(err => {
  705. // handle error
  706. console.error(err)
  707. this.loading = false
  708. })
  709. },
  710. getorgtreelist() {
  711. let _this = this
  712. // request
  713. let params = {
  714. IsInnerOrganize: 1
  715. }
  716. _this.$axios.get('organizes/list', {
  717. params
  718. })
  719. .then(res => {
  720. _this.orgtreelist = window.toolfun_gettreejson(res.data.items, 'Id', 'Parentid', 'Id,Fullname')
  721. })
  722. .catch(err => {
  723. // handle error
  724. console.error(err)
  725. })
  726. },
  727. clearSearch() {
  728. this.keyword = ''
  729. this.list = []
  730. this.initData()
  731. }
  732. }
  733. }
  734. </script>
  735. <style lang="scss">
  736. .el-pagination {
  737. margin: 1rem 0 2rem;
  738. text-align: right;
  739. }
  740. .triggerone {
  741. font-size: 13px;
  742. margin-left: 80px;
  743. }
  744. .plab {
  745. font-size: 13px;
  746. color: #999;
  747. }
  748. .userpermisstreediv {
  749. border: 1px #CCCCCC solid;
  750. overflow: auto;
  751. height: 328px;
  752. margin-right: 5px;
  753. }
  754. .userpermissdiv {
  755. margin-left: 1px;
  756. border: 1px #CCCCCC solid;
  757. overflow: auto;
  758. height: 320px;
  759. padding: 4px;
  760. }
  761. .userpermissdiv .el-checkbox {
  762. margin-top: 5px;
  763. margin-left: 15px;
  764. }
  765. .usersignimg-uploader .el-upload {
  766. border: 1px dashed #63b8ff;
  767. cursor: pointer;
  768. position: relative;
  769. overflow: hidden;
  770. }
  771. .usersignimg-uploader .el-upload:hover {
  772. border-color: #228b22;
  773. }
  774. .usersignimg-uploader-icon {
  775. font-size: 28px;
  776. color: #63b8ff;
  777. width: 66px;
  778. height: 66px;
  779. line-height: 66px;
  780. text-align: center;
  781. }
  782. .usersignimg-uploader-icon:hover {
  783. color: #228b22;
  784. }
  785. .uploadusersignimg {
  786. width: 66px;
  787. height: 66px;
  788. display: block;
  789. }
  790. </style>