index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选start -->
  4. <div class="filter-container mb-10">
  5. <div class="left">
  6. <div>
  7. <span class="" style="margin-right: 30px">用户管理列表</span>
  8. <el-button :disabled="store.state.authorities.indexOf('新增')==-1" icon="el-icon-plus" type="success" @click="addItem()">
  9. 新增
  10. </el-button>
  11. </div>
  12. <div style="margin-top: 20px">
  13. <div class="filter-item">
  14. 账号:
  15. <el-input
  16. v-model="userName"
  17. placeholder="请输入内容"
  18. style="width: 180px"
  19. :disabled="store.state.authorities.indexOf('查询')==-1"
  20. ></el-input>
  21. </div>
  22. <div class="filter-item">
  23. 账号状态:
  24. <el-select
  25. v-model="status"
  26. placeholder="请选择"
  27. style="width: 150px"
  28. clearable
  29. :disabled="store.state.authorities.indexOf('查询')==-1"
  30. >
  31. <el-option label="正常" value="0"></el-option>
  32. <el-option label="停用" value="1"></el-option>
  33. </el-select>
  34. </div>
  35. <div class="filter-item planOutage">
  36. 选择时间范围:
  37. <el-date-picker
  38. v-model="dateTime"
  39. type="datetimerange"
  40. range-separator="至"
  41. start-placeholder="开始日期"
  42. end-placeholder="结束日期"
  43. style="width: auto"
  44. :disabled="store.state.authorities.indexOf('查询')==-1"
  45. ></el-date-picker>
  46. </div>
  47. <el-button
  48. :disabled="store.state.authorities.indexOf('查询')==-1"
  49. type="primary"
  50. icon="el-icon-search"
  51. class="search-button"
  52. @click="list()"
  53. >
  54. 查询
  55. </el-button>
  56. </div>
  57. </div>
  58. <!-- <div class="right">
  59. <el-button type="primary">导出</el-button>
  60. </div> -->
  61. </div>
  62. <!-- 筛选end -->
  63. <!-- 表格start -->
  64. <el-table :data="tableData" border stripe :header-cell-style="headClass">
  65. <!-- <el-table-column prop="xh" label="序号" width="70">
  66. </el-table-column> -->
  67. <el-table-column prop="nickName" label="用户名"></el-table-column>
  68. <el-table-column prop="userName" label="账号"></el-table-column>
  69. <el-table-column prop="sex" label="性别" width="100">
  70. <template #default="scope">
  71. <span>{{ scope.row.sex == 1 ? '男' : '女' }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="phonenumber" label="手机号码" min-width="120"></el-table-column>
  75. <el-table-column prop="createTime" label="创建时间" min-width="160"></el-table-column>
  76. <!-- <el-table-column
  77. prop="roles.roleName"
  78. label="角色名称"
  79. ></el-table-column> -->
  80. <el-table-column fixed="right" label="操作" width="180">
  81. <template #default="scope">
  82. <el-button
  83. @click="checkItem(scope.row)"
  84. type="text"
  85. size="small"
  86. class="delete-text"
  87. >
  88. 查看
  89. </el-button>
  90. <el-button
  91. :disabled="store.state.authorities.indexOf('修改')==-1"
  92. type="text"
  93. size="small"
  94. @click.prevent="editRow(scope.row)"
  95. >
  96. 编辑
  97. </el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <!-- 表格end -->
  102. <!-- 分页start -->
  103. <div class="paginationBlock">
  104. <el-pagination
  105. v-model:currentPage="currentPage"
  106. :page-sizes="[15, 20, 25, 30]"
  107. :page-size="pageSize"
  108. layout="total, sizes, prev, pager, next, jumper"
  109. :total="total"
  110. @size-change="handleSizeChange"
  111. @current-change="handleCurrentChange"
  112. background
  113. ></el-pagination>
  114. </div>
  115. <!-- 分页end -->
  116. <!--弹框组件开始-----------------------start-->
  117. <dialog-component
  118. :dialogTitle="dialogTitle"
  119. :itemInfo="tableItem"
  120. @closeDialog="closeDialog"
  121. :flag="showDialog"
  122. v-if="tableItem"
  123. ></dialog-component>
  124. <!--弹框组件开始-----------------------end-->
  125. </div>
  126. </template>
  127. <script>
  128. import { useStore } from 'vuex'
  129. import { defineComponent, ref, reactive, onMounted } from 'vue'
  130. import * as api from '@/api/systemManage/userManage.js'
  131. import { ElMessage } from 'element-plus'
  132. import DialogComponent from './dialogComponent'
  133. export default defineComponent({
  134. components: { DialogComponent },
  135. setup() {
  136. const store = useStore()
  137. const total = ref(0)
  138. const pageSize = ref(10)
  139. const currentPage = ref(1)
  140. const dateTime = ref('')
  141. const userName = ref('')
  142. const phone = ref('')
  143. const status = ref('')
  144. const role = ref('')
  145. const currentPage4 = ref(4)
  146. const dialogTitle = ref('')
  147. const showDialog = ref(false)
  148. const tableData = ref([])
  149. const siteIdArr=ref([])
  150. // // 表头样式设置
  151. const headClass = () => {
  152. return 'background:#FAFAFA;'
  153. }
  154. const handleSizeChange = (val) => {
  155. pageSize.value = val
  156. list()
  157. }
  158. const handleCurrentChange = (val) => {
  159. currentPage.value = val
  160. list()
  161. }
  162. //用户列表
  163. function list() {
  164. store.commit('TimeAll_function', dateTime.value)
  165. const time = store.state.Time_Data
  166. api
  167. .list({
  168. pageSize: pageSize.value,
  169. pageNum: currentPage.value,
  170. status: status.value,
  171. userName: userName.value,
  172. beginTime: time[0],
  173. endTime: time[1],
  174. // platformAreaName: platformAreaName.value,
  175. })
  176. .then((requset) => {
  177. if (requset.status === 'SUCCESS') {
  178. tableData.value = requset.data.rows
  179. total.value = requset.data.total
  180. } else {
  181. ElMessage.error(requset.msg)
  182. }
  183. })
  184. }
  185. const tableItem = reactive([])
  186. // 添加操作
  187. const addItem = () => {
  188. tableItem.value = {
  189. nickName: '',
  190. userName: '',
  191. sex: '1',
  192. phonenumber: '',
  193. createTime: '',
  194. roleName: '',
  195. password: '',
  196. }
  197. dialogTitle.value = '新增'
  198. showDialog.value = true
  199. }
  200. // 查看
  201. const checkItem = (row) => {
  202. siteIdArr.value=[]
  203. console.log(row)
  204. api.authRole({}, row.userId).then((requset) => {
  205. if (requset.status === 'SUCCESS') {
  206. tableItem.value.roleId= requset.data.user.roles[0].roleId
  207. var newArray= requset.data.userSite
  208. newArray.forEach(function(item){
  209. siteIdArr.value.push(item.siteId)
  210. })
  211. tableItem.value.siteId= siteIdArr.value
  212. } else {
  213. ElMessage.error(requset.msg)
  214. }
  215. })
  216. tableItem.value = row
  217. dialogTitle.value = '查看'
  218. showDialog.value = true
  219. }
  220. // 编辑操作
  221. const editRow = (row) => {
  222. siteIdArr.value=[]
  223. console.log(row)
  224. api.authRole({}, row.userId).then((requset) => {
  225. if (requset.status === 'SUCCESS') {
  226. tableItem.value.roleId= requset.data.user.roles[0].roleId
  227. var newArray= requset.data.userSite
  228. newArray.forEach(function(item){
  229. siteIdArr.value.push(item.siteId)
  230. })
  231. tableItem.value.siteId= siteIdArr.value
  232. } else {
  233. ElMessage.error(requset.msg)
  234. }
  235. })
  236. // tableItem.value = row
  237. tableItem.value={
  238. nickName:row.nickName,
  239. userName:row.userName,
  240. sex:row.sex,
  241. phonenumber:row.phonenumber,
  242. password:row.password,
  243. createTime:row.createTime,
  244. roleId:row.roleId,
  245. userId:row.userId
  246. }
  247. dialogTitle.value = '编辑'
  248. showDialog.value = true
  249. }
  250. // 关闭操作
  251. const closeDialog = () => {
  252. showDialog.value = false
  253. list()
  254. }
  255. onMounted(() => {
  256. list()
  257. })
  258. return {
  259. userName,
  260. phone,
  261. status,
  262. role,
  263. tableItem,
  264. currentPage4,
  265. dialogTitle,
  266. showDialog,
  267. tableData,
  268. total,
  269. pageSize,
  270. currentPage,
  271. dateTime,
  272. store,
  273. siteIdArr,
  274. list,
  275. handleSizeChange,
  276. handleCurrentChange,
  277. headClass,
  278. checkItem,
  279. addItem,
  280. editRow,
  281. closeDialog,
  282. }
  283. },
  284. })
  285. </script>
  286. <style lang="scss" scoped>
  287. </style>