index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <div class="manage-root personnel-manage">
  3. <Header />
  4. <div class="manage-root-contain">
  5. <nav-menu class="manage-root-contain-left" :activeMenuIndex="activeMenuIndex"></nav-menu>
  6. <div class="manage-root-contain-right personnel-manage-right">
  7. <breadcrumb :breadcrumbList="breadcrumbList" class="breadcrumb-box"></breadcrumb>
  8. <div class="personal-inner">
  9. <div class="common-title-box">
  10. <h3>人员列表</h3>
  11. <div class="btn-box">
  12. <el-button type="primary" size="small" @click="handleEdit()">创建用户</el-button>
  13. </div>
  14. </div>
  15. <div class="search-box">
  16. <div class="search-item">
  17. <label>搜索</label>
  18. <el-input
  19. placeholder="输入搜索内容"
  20. v-model="searchInput" maxlength="200">
  21. <i slot="suffix" class="el-input__icon el-icon-search" @click="getList(1)" style="cursor: pointer;"></i>
  22. </el-input>
  23. </div>
  24. <div class="search-item">
  25. <label>账户类型</label>
  26. <el-select v-model="searchType" @change="getList(1)" placeholder="请选择">
  27. <el-option
  28. v-for="item in typeList"
  29. :key="item.account_type"
  30. :label="item.account_type_name"
  31. :value="item.account_type">
  32. </el-option>
  33. </el-select>
  34. </div>
  35. <div class="search-item">
  36. <label>状态</label>
  37. <el-select v-model="searchStatus" @change="getList(1)" placeholder="请选择">
  38. <el-option
  39. v-for="item in $searchStatusList"
  40. :key="item.status"
  41. :label="item.status_name"
  42. :value="item.status">
  43. </el-option>
  44. </el-select>
  45. </div>
  46. </div>
  47. <el-table
  48. class="search-table"
  49. :data="tableData"
  50. style="width: 100%"
  51. @sort-change="handleSort"
  52. :default-sort = dataSort
  53. :max-height="tableHeight">
  54. <el-table-column
  55. prop="user_name"
  56. label="用户名"
  57. sortable="custom"
  58. width="200"
  59. class-name="user-info">
  60. <template slot-scope="scope">
  61. <el-image
  62. class="touxiang"
  63. :src="scope.row.image_url?scope.row.image_url:require('../../assets/avatar.png')"
  64. fit="cover" style="width:24px;height:24px;margin-right:8px">
  65. </el-image>
  66. <!-- <img class="touxiang" :src="scope.row.image_url?scope.row.image_url:require('../../assets/avatar.png')" /> -->
  67. <span class="name">{{scope.row.user_name}}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column
  71. prop="real_name"
  72. label="真实姓名"
  73. width="112">
  74. </el-table-column>
  75. <el-table-column
  76. prop="sex_name"
  77. label="性别"
  78. width="56">
  79. </el-table-column>
  80. <el-table-column
  81. prop="account_type_name"
  82. label="账户类型"
  83. width="120" >
  84. </el-table-column>
  85. <el-table-column
  86. prop="email"
  87. label="邮箱"
  88. min-width="200">
  89. </el-table-column>
  90. <el-table-column
  91. prop="phone"
  92. label="手机号"
  93. width="144">
  94. </el-table-column>
  95. <el-table-column
  96. prop="status"
  97. label="状态"
  98. width="96" >
  99. <template slot-scope="scope">
  100. <div class="status-box">
  101. <span :style="{background:statusList[scope.row.status].bg}"></span>
  102. <b :style="{color:statusList[scope.row.status].color}">{{statusList[scope.row.status].text}}</b>
  103. </div>
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. prop="create_time"
  108. label="创建时间"
  109. sortable="custom"
  110. width="160">
  111. <template slot-scope="scope">
  112. {{scope.row.create_time?scope.row.create_time.substring(0,16):'-'}}
  113. </template>
  114. </el-table-column>
  115. <el-table-column
  116. fixed="right"
  117. label="操作"
  118. width="120">
  119. <template slot-scope="scope">
  120. <el-button
  121. @click.native.prevent="handleEdit(scope.row)"
  122. type="text"
  123. size="small"
  124. class="primary-btn">
  125. 编辑
  126. </el-button>
  127. <el-button
  128. @click.native.prevent="handleUp(scope.row, scope.$index)"
  129. type="text"
  130. size="small"
  131. class="primary-btn"
  132. v-if="scope.row.status===0">
  133. 开启
  134. </el-button>
  135. <el-button
  136. @click.native.prevent="handleUp(scope.row, scope.$index)"
  137. type="text"
  138. size="small"
  139. class="red-btn"
  140. v-else-if="scope.row.status===1">
  141. 停用
  142. </el-button>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <el-pagination
  147. background
  148. @size-change="handleSizeChange"
  149. @current-change="handleCurrentChange"
  150. :current-page="pageNumber"
  151. :page-sizes="[10, 20, 30, 40]"
  152. :page-size="pageSize"
  153. layout="total, prev, pager, next, sizes, jumper"
  154. :total="total_count">
  155. </el-pagination>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. </template>
  161. <script>
  162. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  163. //例如:import 《组件名称》from ‘《组件路径》';
  164. import Header from "../../components/Header.vue";
  165. import NavMenu from "../../components/NavMenu.vue"
  166. import Breadcrumb from '../../components/Breadcrumb.vue';
  167. import { getLogin } from "@/api/ajax";
  168. import { mapState } from 'vuex';
  169. export default {
  170. //import引入的组件需要注入到对象中才能使用
  171. components: { Header, NavMenu, Breadcrumb },
  172. props: {},
  173. data() {
  174. //这里存放数据
  175. return {
  176. activeMenuIndex: "people_manage",
  177. breadcrumbList:[
  178. {
  179. icon:'contacts-line',
  180. url:'',
  181. text:''
  182. },
  183. {
  184. icon:'',
  185. url:'',
  186. text:'系统用户'
  187. }
  188. ],
  189. searchInput: '',
  190. searchType: -1,
  191. searchStatus: -1,
  192. typeList:[
  193. {
  194. account_type:-1,
  195. account_type_name:'全部'
  196. }
  197. ],
  198. statusList:{
  199. 1:{
  200. text:'正常',
  201. bg:'#165DFF',
  202. color:''
  203. },
  204. 0:{
  205. text:'停用',
  206. bg:'#F53F3F',
  207. color:'#F53F3F'
  208. }
  209. },
  210. tableData:[
  211. // {
  212. // id:'1',
  213. // userName:'admin',
  214. // realName:'超级管理员',
  215. // sex:'0',
  216. // type:'0', // 0 管理员 1 平台管理员 2 内容管理员 3 财务管理员 4 兑换码管理员
  217. // email:'d.dkemi@kqtdgbo.tj',
  218. // phone:'13082684216',
  219. // status:'1',
  220. // data:'2018-02-03',
  221. // img:''
  222. // }
  223. ],
  224. pageSize: window.localStorage.getItem('pageSize')?Number(window.localStorage.getItem('pageSize')):10,
  225. pageNumber: window.localStorage.getItem('pageNumber')?Number(window.localStorage.getItem('pageNumber')):1,
  226. tableHeight: "", // 表格高度
  227. total_count: 0,
  228. dataSort: {}
  229. }
  230. },
  231. //计算属性 类似于data概念
  232. computed: {
  233. ...mapState(['$searchStatusList']),
  234. },
  235. //监控data中数据变化
  236. watch: {},
  237. //方法集合
  238. methods: {
  239. handleSort(value){
  240. let dataSort = {
  241. prop: value.prop,
  242. order: value.order
  243. }
  244. this.dataSort = dataSort
  245. this.getList()
  246. },
  247. // 查询列表
  248. getList(page){
  249. if(page){
  250. this.pageNumber = page
  251. }
  252. let MethodName = "/OrgServer/Manager/PageQuery/PageQuerySysUserList";
  253. let order_column_list = []
  254. if(this.dataSort != {}){
  255. if(this.dataSort.order=='descending'){
  256. order_column_list = [this.dataSort.prop + ':desc']
  257. }else if(this.dataSort.order=='ascending'){
  258. // 升序不传值
  259. order_column_list = [this.dataSort.prop]
  260. }else{
  261. order_column_list = ['create_time:desc']
  262. }
  263. }else{
  264. order_column_list = ['create_time:desc']
  265. }
  266. let data = {
  267. search_content:this.searchInput.trim(),
  268. account_type:this.searchType,
  269. status:this.searchStatus,
  270. page_capacity:this.pageSize,
  271. cur_page:this.pageNumber,
  272. order_column_list: order_column_list
  273. }
  274. getLogin(MethodName, data)
  275. .then((res) => {
  276. if(res.status===1){
  277. this.tableData = res.sys_user_list
  278. this.total_count = res.total_count
  279. }
  280. })
  281. .catch(() => {
  282. this.loading = false
  283. });
  284. },
  285. // 编辑账号
  286. handleEdit(row){
  287. // 根据登录用户判断当前用户是不是超管 在table里加上disabled
  288. // 点击时记录页码和每页条数
  289. window.localStorage.setItem('pageSize',this.pageSize)
  290. window.localStorage.setItem('pageNumber',this.pageNumber)
  291. if(row&&row.id){
  292. this.$router.push({
  293. path: "/editPerson",
  294. query: {
  295. id: row?row.id:''
  296. },
  297. });
  298. }else{
  299. this.$router.push({
  300. path: "/createPerson"
  301. });
  302. }
  303. },
  304. // 停用 启用
  305. handleUp(row, index) {
  306. let Mname = "/OrgServer/Manager/SysUserManager/EnableSysUser";
  307. let updataData = JSON.parse(JSON.stringify(row));
  308. let data = {
  309. id: row.id
  310. };
  311. if (row.status === 0) {
  312. // 下架状态
  313. data.is_enable = "true";
  314. updataData.status = 1;
  315. } else if (row.status === 1) {
  316. data.is_enable = "false";
  317. updataData.status = 0;
  318. }
  319. getLogin(Mname, data).then(res => {
  320. this.$message.success("操作成功");
  321. this.$set(this.tableData, index, updataData);
  322. this.getList()
  323. });
  324. },
  325. handleSizeChange(val) {
  326. this.pageSize = val
  327. this.pageNumber = 1
  328. this.getList()
  329. },
  330. handleCurrentChange(val) {
  331. this.pageNumber = val
  332. this.getList()
  333. },
  334. //计算table高度(动态设置table高度)
  335. getTableHeight() {
  336. let tableH = 370; //距离页面下方的高度
  337. let tableHeightDetil = window.innerHeight - tableH;
  338. if (tableHeightDetil <= 300) {
  339. this.tableHeight = 300;
  340. } else {
  341. this.tableHeight = window.innerHeight - tableH;
  342. }
  343. },
  344. // 用户类型列表
  345. getUserAccountTypeList(){
  346. let MethodName = "/OrgServer/DictManager/GetSysUserAccountTypeList";
  347. getLogin(MethodName, {})
  348. .then((res) => {
  349. if(res.status===1){
  350. this.typeList = this.typeList.concat(res.account_type_list)
  351. }
  352. })
  353. .catch(() => {
  354. this.loading = false
  355. });
  356. }
  357. },
  358. //生命周期 - 创建完成(可以访问当前this实例)
  359. created() {
  360. this.getTableHeight();
  361. this.getUserAccountTypeList()
  362. this.getList()
  363. },
  364. //生命周期 - 挂载完成(可以访问DOM元素)
  365. mounted() {
  366. },
  367. //生命周期-创建之前
  368. beforeCreated() { },
  369. //生命周期-挂载之前
  370. beforeMount() { },
  371. //生命周期-更新之前
  372. beforUpdate() { },
  373. //生命周期-更新之后
  374. updated() { },
  375. //生命周期-销毁之前
  376. beforeDestory() { },
  377. //生命周期-销毁完成
  378. destoryed() { },
  379. //如果页面有keep-alive缓存功能,这个函数会触发
  380. activated() { }
  381. }
  382. </script>
  383. <style lang="scss" scoped>
  384. /* @import url(); 引入css类 */
  385. </style>
  386. <style lang="scss">
  387. .personal-inner{
  388. .user-info{
  389. .cell{
  390. display: flex;
  391. align-items: center;
  392. .touxiang{
  393. width: 24px;
  394. height: 24px;
  395. border-radius: 50%;
  396. margin-right: 8px;
  397. }
  398. }
  399. }
  400. .type-info{
  401. background: #F2F3F5;
  402. border-radius: 2px;
  403. color: #1D2129;
  404. padding: 2px 8px 3px 8px;
  405. font-weight: 500;
  406. font-size: 14px;
  407. line-height: 22px;
  408. height: auto;
  409. border: none;
  410. }
  411. }
  412. </style>