account.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="form-wrapper">
  3. <el-form
  4. class="search-box"
  5. ref="form"
  6. :model="form"
  7. :inline="true"
  8. >
  9. <div class="block-title">
  10. 查询条件
  11. </div>
  12. <el-form-item
  13. label="登录账号"
  14. prop="loginName">
  15. <el-input v-model="form.loginName"></el-input>
  16. </el-form-item>
  17. <el-form-item
  18. label="手机号"
  19. prop="phone">
  20. <el-input v-model="form.phone"></el-input>
  21. </el-form-item>
  22. <div class="btn-wrap">
  23. <el-button
  24. @click="reset"
  25. >
  26. 重置
  27. </el-button>
  28. <el-button
  29. type="primary"
  30. @click="getAccountList"
  31. >
  32. 搜索
  33. </el-button>
  34. <el-button
  35. type="primary"
  36. size="mini"
  37. @click="showDialog('add')"
  38. >
  39. 新增账号
  40. </el-button>
  41. </div>
  42. </el-form>
  43. <div class="table-box">
  44. <!-- <div class="block-title">
  45. 账号列表
  46. </div> -->
  47. <el-table
  48. border
  49. stripe
  50. v-loading="loading"
  51. :data="tableData"
  52. >
  53. <!-- <el-table-column
  54. prop="id"
  55. label="ID"
  56. >
  57. </el-table-column> -->
  58. <el-table-column
  59. prop="loginName"
  60. label="账号名"
  61. >
  62. </el-table-column>
  63. <el-table-column
  64. prop="name"
  65. label="姓名"
  66. >
  67. </el-table-column>
  68. <el-table-column
  69. prop="roles"
  70. label="角色"
  71. >
  72. <template slot-scope="scope">
  73. <el-tag
  74. v-for="(item,index) in scope.row.roleList"
  75. :key="index"
  76. >
  77. {{ item.name }}
  78. </el-tag>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. prop="type"
  83. label="用户属性"
  84. width="100"
  85. >
  86. <template slot-scope="scope">
  87. <span>{{ scope.row.type === 2 ? '组内员工' : scope.row.type === 1 ? '管理员' : '员工' }}</span>
  88. </template>
  89. </el-table-column>
  90. <!-- <el-table-column
  91. prop="creator"
  92. label="创建人">
  93. </el-table-column> -->
  94. <el-table-column
  95. label="上次登录时间"
  96. width="140"
  97. >
  98. <template slot-scope="scope">
  99. {{ scope.row.lastLoginTime | formatTime }}
  100. </template>
  101. </el-table-column>
  102. <el-table-column
  103. label="创建时间"
  104. width="140"
  105. >
  106. <template slot-scope="scope">
  107. {{ scope.row.createTime | formatTime }}
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. prop="phone"
  112. label="电话"
  113. >
  114. </el-table-column>
  115. <!-- 雷锋纪念馆定制 -->
  116. <!-- <el-table-column
  117. width="120"
  118. label="状态">
  119. <template slot-scope="scope">
  120. <span>{{ scope.row.isUse ? '已激活' : '已禁用' }}</span>
  121. <el-button
  122. type="text"
  123. size="small"
  124. @click="offSale(scope.row)"
  125. class="offSale-btn"
  126. v-if="scope.row.isUse"
  127. >
  128. <i class="iconfont icon-offSale"></i>禁用
  129. </el-button>
  130. <el-button
  131. type="text"
  132. size="small"
  133. @click="onSale(scope.row)"
  134. class="onSale-btn"
  135. v-else
  136. >
  137. <i class="iconfont icon-onSale"></i>激活
  138. </el-button>
  139. </template>
  140. </el-table-column> -->
  141. <el-table-column
  142. fixed="right"
  143. label="操作"
  144. width="120"
  145. >
  146. <template slot-scope="scope">
  147. <el-button
  148. type="text"
  149. size="small"
  150. @click="showDialog('edit',scope.row)"
  151. >
  152. 编辑
  153. </el-button>
  154. <el-button
  155. type="text"
  156. size="small"
  157. @click="deleteAccount(scope.row.id)"
  158. >
  159. 删除
  160. </el-button>
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. <el-pagination
  165. background
  166. :page-size="form.pageSize"
  167. :current-page.sync="form.pageNum"
  168. :page-sizes="[10, 20, 50, 100]"
  169. @size-change="handleSizeChange"
  170. @current-change="handlePage"
  171. layout="total, sizes, prev, pager, next, jumper"
  172. :total="total"
  173. >
  174. </el-pagination>
  175. </div>
  176. <ElDialog
  177. :title="dialogType === 'add' ? '新增账户' : '编辑账户'"
  178. width="660px"
  179. v-model="dialogVisible">
  180. <EditDialog
  181. :scenic-list="scenicList"
  182. :dialog-type="dialogType"
  183. :account-item="curItem"
  184. @updateList="handleUpdate"
  185. ></EditDialog>
  186. </ElDialog>
  187. </div>
  188. </template>
  189. <script>
  190. import { getAccountList, deleteAccount, updateAccount } from '@/api/systemSetting/account'
  191. import ElDialog from '@/components/Dialog'
  192. import EditDialog from './account/EditDialog'
  193. import moment from 'moment'
  194. export default {
  195. components: {
  196. ElDialog,
  197. EditDialog
  198. },
  199. created () {
  200. this.getAccountList()
  201. },
  202. data () {
  203. return {
  204. projectName: process.env.VUE_APP_PROJECT,
  205. loading: false,
  206. dialogType: 'add',
  207. dialogVisible: false,
  208. tableData: [],
  209. scenicList: [],
  210. total: 0,
  211. form: {
  212. export: false,
  213. pageNum: 1,
  214. pageSize: 10,
  215. loginName: '',
  216. name: '',
  217. phone: ''
  218. },
  219. // 当前账号对象
  220. curItem: {}
  221. }
  222. },
  223. methods: {
  224. reset () {
  225. this.form.loginName = ''
  226. this.form.phone = ''
  227. },
  228. showDialog (type, item) {
  229. this.dialogType = type
  230. this.curItem = item
  231. this.dialogVisible = true
  232. },
  233. handleSizeChange (size) {
  234. this.pageSize = size
  235. this.getAccountList()
  236. },
  237. getAccountList () {
  238. this.loading = true
  239. getAccountList(this.form).then(res => {
  240. this.tableData = res?.data?.records || []
  241. this.total = res?.data?.total || 0
  242. }).finally(() => {
  243. this.loading = false
  244. })
  245. },
  246. deleteAccount (id) {
  247. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  248. confirmButtonText: '确定',
  249. cancelButtonText: '取消',
  250. type: 'warning'
  251. }).then(() => {
  252. deleteAccount(id).then(res => {
  253. this.$message.success('删除成功')
  254. this.getAccountList()
  255. })
  256. })
  257. },
  258. handlePage (pageNum) {
  259. this.form.pageNum = pageNum
  260. this.getAccountList()
  261. },
  262. offSale (data) {
  263. let form = Object.assign({}, data)
  264. form.isUse = 0
  265. updateAccount(form).then(res => {
  266. this.$message.success('操作成功')
  267. this.getAccountList()
  268. })
  269. },
  270. onSale (data) {
  271. if (moment().isAfter(data.use_end_time)) {
  272. this.$alert('请先修改账号过期时间', '账号已过期', {
  273. confirmButtonText: '知道了'
  274. })
  275. } else {
  276. let form = Object.assign({}, data)
  277. form.isUse = 1
  278. updateAccount(form).then(res => {
  279. this.$message.success('操作成功')
  280. this.getAccountList()
  281. })
  282. }
  283. },
  284. handleChange (data) {
  285. let form = Object.assign({}, data)
  286. if (data.workStatus) {
  287. form.workStatus = 1
  288. } else {
  289. form.workStatus = 0
  290. }
  291. updateAccount(form).then(res => {
  292. this.$message.success('操作成功')
  293. this.getAccountList()
  294. })
  295. },
  296. handleChange2 (data) {
  297. let form = Object.assign({}, data)
  298. if (data.onDuty) {
  299. form.onDuty = 1
  300. } else {
  301. form.onDuty = 0
  302. }
  303. updateAccount(form).then(res => {
  304. this.$message.success('操作成功')
  305. this.getAccountList()
  306. })
  307. },
  308. handleUpdate () {
  309. this.$store.dispatch('getAccount')
  310. this.getAccountList()
  311. }
  312. }
  313. }
  314. </script>
  315. <style scoped>
  316. .offSale-btn{
  317. color: #F56C6C
  318. }
  319. .onSale-btn{
  320. color: #67C23A
  321. }
  322. </style>