index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <div class="app-container">
  3. <el-row>
  4. <el-col :span="24">
  5. <div class="cell">
  6. <div class="cell-title">
  7. <div class="title-left">
  8. <div class="title">账号管理</div>
  9. </div>
  10. <div class="title-right">
  11. <el-button type="primary" @click="add_account">添加账号</el-button>
  12. </div>
  13. </div>
  14. <div class="cell-body">
  15. <el-table :data="tableData" height="560" style="width: 100%" :cell-style="cell_style"
  16. :header-cell-style="header_cell_style">
  17. <el-table-column label="序号" align="center" width="100">
  18. <template slot-scope="scope">
  19. <span>{{(pagination.currentPage - 1) * pagination.pageSize + scope.$index + 1}}</span>
  20. </template>
  21. </el-table-column>
  22. <el-table-column label="手机" align="center">
  23. <template slot-scope="scope">
  24. <span>{{ scope.row.phone }}</span>
  25. </template>
  26. </el-table-column>
  27. <el-table-column label="姓名" align="center">
  28. <template slot-scope="scope">
  29. <span>{{ scope.row.name }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="角色" align="center">
  33. <template slot-scope="scope">
  34. {{scope.row.role}}
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="备注" align="center" width="200">
  38. <template slot-scope="scope">
  39. <span>{{ scope.row.comment }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="操作" align="center">
  43. <template slot-scope="scope">
  44. <el-button size="mini" class="btn-table"
  45. @click="edit_amount(scope.$index, scope.row)">修改</el-button>
  46. <el-button size="mini" class="btn-table" type="danger"
  47. @click="delete_amount(scope.$index, scope.row)">
  48. 删除</el-button>
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <div class="pagination-table">
  53. <el-pagination @current-change="currentPageChange"
  54. :current-page.sync="pagination.currentPage" :page-size="pagination.pageSize"
  55. layout="prev, pager, next, jumper" :total="pagination.total">
  56. </el-pagination>
  57. </div>
  58. </div>
  59. </div>
  60. </el-col>
  61. </el-row>
  62. <el-dialog title="添加账号" :visible.sync="dialogAddAcountFormVisible" :close-on-click-modal="false"
  63. :close-on-press-escape="false" @close="add_account_dialog_close">
  64. <el-form :model="formAddAcount">
  65. <el-form-item label="手机号:" :label-width="formLabelWidth" :required="true">
  66. <el-input v-model="formAddAcount.phone" autocomplete="off" placeholder="请输入手机号"></el-input>
  67. </el-form-item>
  68. <el-form-item label="用户名:" :label-width="formLabelWidth" :required="true">
  69. <el-input v-model="formAddAcount.username" autocomplete="off" placeholder="请输入用户名"></el-input>
  70. </el-form-item>
  71. <el-form-item label="角 色:" :label-width="formLabelWidth" :required="true">
  72. <el-checkbox-group v-model="formAddAcount.checkedRole" :min="0" :max="1">
  73. <el-checkbox v-for="(role, index) in formAddAcount.roles" :label="role" :key="index">{{role}}
  74. </el-checkbox>
  75. </el-checkbox-group>
  76. </el-form-item>
  77. <el-form-item label="备 注:" :label-width="formLabelWidth">
  78. <el-input type="textarea" v-model="formAddAcount.comment" placeholder="请输入备注信息"></el-input>
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button @click="dialogAddAcountFormVisible = false">取 消</el-button>
  83. <el-button type="primary" @click="dialogAddAcountFormVisible = false">确 认</el-button>
  84. </div>
  85. </el-dialog>
  86. <el-dialog title="修改账号" :visible.sync="dialogModifyAcountFormVisible" :close-on-click-modal="false"
  87. :close-on-press-escape="false" @close="modify_account_dialog_close">
  88. <el-form :model="formModifyAcount">
  89. <el-form-item label="手机号:" :label-width="formLabelWidth" :required="true">
  90. <el-input v-model="formModifyAcount.phone" autocomplete="off" placeholder="请输入手机号"></el-input>
  91. </el-form-item>
  92. <el-form-item label="用户名:" :label-width="formLabelWidth" :required="true">
  93. <el-input v-model="formModifyAcount.username" autocomplete="off" placeholder="请输入用户名"></el-input>
  94. </el-form-item>
  95. <el-form-item label="角 色:" :label-width="formLabelWidth" :required="true">
  96. <el-checkbox-group v-model="formModifyAcount.checkedRole" :min="0" :max="1">
  97. <el-checkbox v-for="(role, index) in formModifyAcount.roles" :label="role" :key="role">{{role}}
  98. </el-checkbox>
  99. </el-checkbox-group>
  100. </el-form-item>
  101. <el-form-item label="备 注:" :label-width="formLabelWidth">
  102. <el-input type="textarea" v-model="formModifyAcount.comment" placeholder="请输入备注信息"></el-input>
  103. </el-form-item>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button @click="dialogModifyAcountFormVisible = false">取 消</el-button>
  107. <el-button type="primary" @click="dialogModifyAcountFormVisible = false">确 认</el-button>
  108. </div>
  109. </el-dialog>
  110. <el-dialog custom-class="el-dialog-delete-account" :visible.sync="dialog_delete_account"
  111. :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
  112. <div slot="" class="del-account-body">
  113. <img src="../../icons/serveAC/del_warning.png" alt="">
  114. <div class="del-account-body-txt">是否确定将该【{{delete_account}}】从列表中移除?</div>
  115. </div>
  116. <div slot="footer" class="dialog-footer">
  117. <el-button @click="dialog_delete_account = false"> 否 </el-button>
  118. <el-button type="primary" @click="dialog_delete_account = false"> 是 </el-button>
  119. </div>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. const roleOptions = ['管理员', '浏览员'];
  125. export default {
  126. data() {
  127. return {
  128. dialogAddAcountFormVisible: false, // 添加账号对话框显示与隐藏
  129. formAddAcount: { // 添加账号对话框 数据
  130. phone: '',
  131. username: '',
  132. comment: '',
  133. checkedRole: [],
  134. roles: roleOptions
  135. },
  136. dialogModifyAcountFormVisible: false, // 修改账号对话框显示与隐藏
  137. formModifyAcount: { // 修改账号对话框 数据
  138. phone: '',
  139. username: '',
  140. comment: '',
  141. checkedRole: [],
  142. roles: roleOptions
  143. },
  144. dialog_delete_account: false,
  145. delete_account: '',
  146. formLabelWidth: '120px',
  147. // 表格单元格样式
  148. cell_style: {
  149. color: '#1A202B',
  150. 'font-size': '14px',
  151. 'font-family': 'Microsoft YaHei-3970(82674968)'
  152. },
  153. // 表格头部样式
  154. header_cell_style: {
  155. background: '#E6ECFE',
  156. color: '#1A202B',
  157. 'font-size': '16px',
  158. 'font-family': 'Microsoft YaHei-3970(82674968)'
  159. },
  160. tableData: [{
  161. name: '王小虎',
  162. phone: '18988888888',
  163. role: '管理员',
  164. comment: '此处是备注内容'
  165. }, {
  166. name: '王小虎',
  167. phone: '18988888888',
  168. role: '浏览员',
  169. comment: '此处是备注内容'
  170. }, {
  171. name: '王小虎',
  172. phone: '18988888888',
  173. role: '管理员',
  174. comment: '此处是备注内容'
  175. }, {
  176. name: '王小虎',
  177. phone: '18988888888',
  178. role: '管理员',
  179. comment: '此处是备注内容'
  180. }, {
  181. name: '王小虎',
  182. phone: '18988888888',
  183. role: '管理员',
  184. comment: '此处是备注内容'
  185. }, {
  186. name: '王小虎',
  187. phone: '18988888888',
  188. role: '管理员',
  189. comment: '此处是备注内容'
  190. }, {
  191. name: '王小虎',
  192. phone: '18988888888',
  193. role: '管理员',
  194. comment: '此处是备注内容'
  195. }, {
  196. name: '王小虎',
  197. phone: '18988888888',
  198. role: '管理员',
  199. comment: '此处是备注内容'
  200. }, {
  201. name: '王小虎',
  202. phone: '18988888888',
  203. role: '管理员',
  204. comment: '此处是备注内容'
  205. }, {
  206. name: '王小虎',
  207. phone: '18988888888',
  208. role: '管理员',
  209. comment: '此处是备注内容'
  210. }],
  211. // 分页参数
  212. pagination: {
  213. pageSize: 10,
  214. currentPage: 1,
  215. total: 100
  216. }
  217. }
  218. },
  219. mounted() {
  220. document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";
  221. },
  222. methods: {
  223. /**
  224. * 删除账号
  225. * @param {Object} index
  226. * @param {Object} row
  227. */
  228. delete_amount(index, row) {
  229. console.log(row);
  230. this.delete_account = row.name
  231. this.dialog_delete_account = true
  232. },
  233. /**
  234. * 修改账号
  235. * @param {Object} index
  236. * @param {Object} row
  237. */
  238. edit_amount(index, row) {
  239. this.dialogModifyAcountFormVisible = true
  240. this.formModifyAcount.phone = row.phone
  241. this.formModifyAcount.username = row.name
  242. this.formModifyAcount.checkedRole.push(row.role)
  243. this.formModifyAcount.comment = row.comment
  244. },
  245. /**
  246. * 添加账号
  247. */
  248. add_account() {
  249. this.dialogAddAcountFormVisible = true
  250. },
  251. /**
  252. * 添加账号对话框关闭时清理数据
  253. */
  254. add_account_dialog_close() {
  255. this.formAddAcount = {
  256. phone: '',
  257. username: '',
  258. comment: '',
  259. checkedRole: [],
  260. roles: roleOptions
  261. }
  262. },
  263. /**
  264. * 添加账号对话框关闭时清理数据
  265. */
  266. modify_account_dialog_close() {
  267. this.formModifyAcount = {
  268. phone: '',
  269. username: '',
  270. comment: '',
  271. checkedRole: [],
  272. roles: roleOptions
  273. }
  274. },
  275. /**
  276. * currentPage 改变时会触发
  277. * @param {Object} val
  278. */
  279. currentPageChange(val) {
  280. console.log('当前页:' + val);
  281. }
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. .app-container {
  287. background-color: #EFF2F7;
  288. padding: 10px;
  289. .el-row {
  290. .el-col {
  291. padding: 10px;
  292. .cell {
  293. padding: 30px;
  294. border-radius: 10px;
  295. background-color: #FFFFFF;
  296. .cell-title {
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: center;
  300. margin-bottom: 30px;
  301. padding-bottom: 30px;
  302. border-bottom: 1px solid #CCCCCC;
  303. .title-left {
  304. display: flex;
  305. align-items: center;
  306. .title {
  307. font-size: 22px;
  308. font-family: Microsoft YaHei-3970(82674968);
  309. font-weight: bold;
  310. color: #1A202B;
  311. }
  312. .title-detail {
  313. margin-left: 50px;
  314. font-size: 18px;
  315. font-family: Microsoft YaHei-3970(82674968);
  316. color: #1A202B;
  317. }
  318. }
  319. .title-right {
  320. display: flex;
  321. justify-content: space-between;
  322. align-items: center;
  323. .el-button {
  324. width: 110px;
  325. height: 46px;
  326. background: #2B4CFE;
  327. font-size: 18px;
  328. color: #FFFFFF;
  329. font-family: Microsoft YaHei-3970(82674968);
  330. border-radius: 5px;
  331. }
  332. .el-button--warning {
  333. background: #F88A64;
  334. }
  335. }
  336. }
  337. .cell-body {
  338. .btn-table {
  339. border-radius: 15px !important;
  340. border-color: #5488FE;
  341. background: #FFFFFF;
  342. color: #5488FE;
  343. }
  344. .pagination-table {
  345. display: flex;
  346. justify-content: flex-end;
  347. align-items: center;
  348. height: 30px;
  349. margin-top: 20px;
  350. padding-right: 100px;
  351. ::v-deep .el-pagination {
  352. display: flex;
  353. justify-content: flex-end;
  354. align-items: center;
  355. }
  356. ::v-deep .el-pagination ul {
  357. display: flex;
  358. }
  359. ::v-deep .el-pagination button,
  360. ::v-deep .el-pagination li {
  361. display: flex;
  362. justify-content: center;
  363. align-items: center;
  364. width: 50px;
  365. height: 36px;
  366. border: 1px solid #626262;
  367. border-radius: 3px;
  368. font-size: 14px;
  369. margin: 0 5px;
  370. }
  371. ::v-deep .el-pagination span {
  372. margin-left: 10px;
  373. }
  374. ::v-deep .el-pagination .el-pagination__jump {
  375. font-size: 16px;
  376. }
  377. ::v-deep .el-pagination .el-pagination__editor {
  378. width: 50px;
  379. height: 36px;
  380. margin: 0 5px;
  381. }
  382. ::v-deep .el-pagination .el-input__inner {
  383. width: 50px;
  384. height: 36px;
  385. border: 1px solid #626262;
  386. margin: -4px 0 0 0;
  387. }
  388. }
  389. }
  390. }
  391. }
  392. }
  393. ::v-deep .el-dialog {
  394. margin: 0 !important;
  395. width: 600px;
  396. height: 460px;
  397. background: #FFFFFF;
  398. box-shadow: 0px 0px 13px 0px rgba(0, 0, 0, 0.29);
  399. border-radius: 10px;
  400. position: absolute;
  401. top: 50%;
  402. left: 50%;
  403. transform: translate(-50%, -50%);
  404. .el-dialog__header {
  405. display: flex;
  406. align-items: center;
  407. width: 100%;
  408. height: 58px;
  409. padding: 30px;
  410. background: #E6EBFE;
  411. border-radius: 10px 10px 0px 0px;
  412. font-weight: bold;
  413. }
  414. .el-dialog__body {
  415. padding-bottom: 0;
  416. .el-form-item__label,
  417. .el-form-item__content {
  418. font-size: 16px;
  419. font-family: Microsoft YaHei-3970(82674968);
  420. color: #53575A;
  421. }
  422. .el-input__inner {
  423. width: 180px;
  424. }
  425. }
  426. // 删除对话框的样式
  427. .del-account-body {
  428. display: flex;
  429. flex-direction: column;
  430. justify-content: center;
  431. align-items: center;
  432. height: 180px;
  433. img {
  434. width: 72px;
  435. }
  436. .del-account-body-txt {
  437. height: 58px;
  438. line-height: 58px;
  439. font-size: 18px;
  440. font-family: Microsoft YaHei-3970(82674968);
  441. color: #333333;
  442. }
  443. }
  444. .el-dialog__footer {
  445. padding-bottom: 0 !important;
  446. text-align: center;
  447. .el-button.el-button--default {
  448. width: 75px;
  449. height: 40px;
  450. border: 1px solid #2B4CFE;
  451. border-radius: 6px;
  452. font-size: 16px;
  453. font-family: Microsoft YaHei-3970(82674968);
  454. color: #2B4CFE;
  455. }
  456. .el-button.el-button--primary {
  457. width: 75px;
  458. height: 40px;
  459. background: #2B4CFE;
  460. border-radius: 6px;
  461. font-size: 16px;
  462. font-family: Microsoft YaHei-3970(82674968);
  463. color: #FFFFFF;
  464. margin-left: 60px;
  465. }
  466. }
  467. }
  468. }
  469. </style>
  470. <style>
  471. .el-dialog-delete-account {
  472. height: 300px !important;
  473. width: 460px !important;
  474. }
  475. .el-dialog-delete-account .el-dialog__header {
  476. display: none !important;
  477. }
  478. </style>