index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <style>
  2. .table-body {
  3. padding: 20px 20px;
  4. background-color: #fff;
  5. }
  6. .table-body .top-input{
  7. margin-top: 34px;
  8. }
  9. .input-item {
  10. width: 200px;
  11. margin-right: 20px;
  12. }
  13. .input-item .el-input__inner {
  14. border-right: 0;
  15. }
  16. .input-item .el-input__inner:hover {
  17. border: 1px solid #dcdfe6;
  18. border-right: 0;
  19. outline: 0;
  20. }
  21. .input-item .el-input__inner:focus {
  22. border: 1px solid #dcdfe6;
  23. border-right: 0;
  24. outline: 0;
  25. }
  26. .input-item .el-input-group__append {
  27. background-color: #fff;
  28. border-left: 0;
  29. width: 10%;
  30. padding: 0;
  31. }
  32. .input-item .el-input-group__append .el-button {
  33. padding: 0;
  34. }
  35. .input-item .el-input-group__append .el-button {
  36. margin: 0;
  37. }
  38. /* #app .table-body .el-table .el-button {
  39. border-radius: 16px;
  40. } */
  41. .create {
  42. height: 36px;
  43. line-height: 36px;
  44. float: right;
  45. color: #BCBCBC;
  46. margin-left: 20px;
  47. }
  48. .name {
  49. cursor: pointer;
  50. color: #49A9FF;
  51. }
  52. .el-input-group__append {
  53. /* background-color: #fff; */
  54. }
  55. /* 卡片 */
  56. .plugin-list {
  57. margin: 0 0 0 -20px;
  58. /* padding-right: 100px; */
  59. display: flex;
  60. flex-wrap:wrap;
  61. }
  62. .plugin-list .plugin-item{
  63. width: 20%;
  64. min-width: 400px;
  65. }
  66. .plugin-item {
  67. border: 1px solid #ebebeb;
  68. background: #FFFFFF;
  69. box-shadow: 3px 5px 15px rgba(80, 80, 80, 0.16);
  70. opacity: 1;
  71. border-radius: 5px;
  72. padding: 20px;
  73. margin: 0 0 20px 20px;
  74. transition: 250ms;
  75. position: relative;
  76. /* min-width: 300px; */
  77. }
  78. .plugin-item .item-status{
  79. position: absolute;
  80. top: 0;
  81. right: 0;
  82. width: 94px;
  83. height: 30px;
  84. background: #E8EAEC;
  85. opacity: 1;
  86. border-radius: 0px 5px 0px 5px;
  87. font-size: 14px;
  88. font-family: Microsoft YaHei;
  89. font-weight: 400;
  90. line-height: 30px;
  91. color: #9398A4;
  92. text-align: center;
  93. }
  94. .item-status-permanent{
  95. width: 94px;
  96. }
  97. .item-status-effective{
  98. width: 164px;
  99. }
  100. .plugin-item .item-info{
  101. display: flex;
  102. align-items: center;
  103. }
  104. /* .plugin-item .item-info .item-right{
  105. min-width: 500px;
  106. } */
  107. .plugin-item .item-btns{
  108. display: flex;
  109. align-items: center;
  110. justify-content:flex-end;
  111. margin-top: 12px;
  112. }
  113. .plugin-item .mall-logo{
  114. width: 70px;
  115. height: 70px;
  116. margin-right: 12px;
  117. }
  118. .plugin-item .mall-logo img{
  119. width: 100%;
  120. height: 100%;
  121. display: block;
  122. border-radius: 50%;
  123. }
  124. .plugin-item .display-name {
  125. font-size: 18pt;
  126. margin-top: 10px;
  127. margin-bottom: 4px;
  128. font-family: Microsoft YaHei;
  129. font-weight: bold;
  130. line-height: 30px;
  131. color: #3F495D;
  132. opacity: 1;
  133. width: 200px;
  134. white-space:nowrap;
  135. overflow:hidden;
  136. text-overflow:ellipsis;
  137. }
  138. .plugin-item .name {
  139. color: #909399;
  140. }
  141. .plugin-item:hover {
  142. cursor: pointer;
  143. border-color: #bfddff;
  144. }
  145. /* .plugin-item:hover .display-name {
  146. color: #409EFF;
  147. } */
  148. .plugin-item .plugin-option-btn {
  149. height: 25px;
  150. width: 25px;
  151. font-size: 12px;
  152. padding: 0;
  153. }
  154. .plugin-item .detail-option.detail-option {
  155. color: #909399;
  156. background: #F2F6FC;
  157. }
  158. .plugin-item .detail-option:hover {
  159. color: #fff;
  160. background: #909399;
  161. }
  162. </style>
  163. <div id="app" v-cloak>
  164. <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  165. <div slot="header">
  166. <div>
  167. <span>账号列表</span>
  168. <div style="float: right; margin: -5px 0">
  169. <el-button type="primary" size="small" @click="handleEdit('')">新增</el-button>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="table-body">
  174. <template>
  175. <div>
  176. <el-table
  177. :data="tableData"
  178. style="width: 100%;margin-bottom: 20px;"
  179. row-key="id"
  180. stripe
  181. default-expand-all
  182. >
  183. <el-table-column
  184. prop="id"
  185. label="ID"
  186. sortable
  187. width="180">
  188. <template slot-scope="scope">
  189. <span style="margin-left: 10px">{{ scope.row.id }}</span>
  190. </template>
  191. </el-table-column>
  192. <el-table-column
  193. prop="title"
  194. label="账号名称"
  195. width="180">
  196. <template slot-scope="scope">
  197. <span style="margin-left: 10px">{{ scope.row.username }}</span>
  198. </template>
  199. </el-table-column>
  200. <el-table-column
  201. prop="mobile"
  202. label="手机号"
  203. width="180">
  204. <template slot-scope="scope">
  205. <span>{{ scope.row.mobile }}</span>
  206. </template>
  207. </el-table-column>
  208. <el-table-column
  209. prop="url"
  210. label="类型">
  211. <template slot-scope="scope">
  212. <span style="margin-left: 10px">{{ admin_type_map[scope.row.admin_type] }}</span>
  213. </template>
  214. </el-table-column>
  215. <el-table-column
  216. prop="url"
  217. label="角色">
  218. <template slot-scope="scope">
  219. <span v-if="scope.row.admin_type==2||scope.row.admin_type==3" style="margin-left: 10px">{{ scope.row.role }}</span>
  220. <span v-if="scope.row.admin_type==1" style="margin-left: 10px">--</span>
  221. </template>
  222. </el-table-column>
  223. <el-table-column
  224. prop="url"
  225. label="创建时间">
  226. <template slot-scope="scope">
  227. <span style="margin-left: 10px">{{ scope.row.created_at }}</span>
  228. </template>
  229. </el-table-column>
  230. <el-table-column
  231. prop="url"
  232. label="备注">
  233. <template slot-scope="scope">
  234. <span style="margin-left: 10px">{{ scope.row.remark }}</span>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="操作">
  238. <template slot-scope="scope">
  239. <el-button type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px"
  240. @click="handleEdit(scope.row.id)">
  241. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  242. <img src="resources/img/mall/edit.png" alt="">
  243. </el-tooltip>
  244. </el-button>
  245. <el-button v-if="scope.row.username!='admin'" style="margin-left: 10px;margin-top: 10px" type="text"
  246. class="set-el-button"
  247. size="mini" circle @click="handleDelete(scope.$index, scope.row)">
  248. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  249. <img src="resources/img/mall/del.png" alt="">
  250. </el-tooltip>
  251. </el-button>
  252. </template>
  253. </el-table-column>
  254. </el-table>
  255. <div style="text-align: right;margin: 20px 0;">
  256. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  257. </div>
  258. </div>
  259. </template>
  260. </div>
  261. <el-dialog :title="title" :visible.sync="dialogFormVisible_edit">
  262. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  263. <el-form-item label="账号名称" :label-width="formLabelWidth" prop="account">
  264. <el-input v-model="ruleForm.account"></el-input>
  265. </el-form-item>
  266. <el-form-item label="登录账号" :label-width="formLabelWidth" prop="username">
  267. <el-input v-model="ruleForm.username" ></el-input>
  268. </el-form-item>
  269. <el-form-item label="登录密码" :label-width="formLabelWidth" prop="password">
  270. <el-input v-model="ruleForm.password" type="password"></el-input>
  271. </el-form-item>
  272. <el-form-item label="手机号" :label-width="formLabelWidth" prop="mobile">
  273. <el-input v-model="ruleForm.mobile" ></el-input>
  274. </el-form-item>
  275. <el-form-item label="商城数量" :label-width="formLabelWidth" prop="mall_num">
  276. <el-input v-model="ruleForm.mall_num" type="number" :disabled = "isMallNum"></el-input>
  277. <el-checkbox v-model="isMax" @change="changeIsMax">永久</el-checkbox>
  278. </el-form-item>
  279. <el-form-item label="账户有效期" prop="expired_at" :label-width="formLabelWidth" ref="expired_at">
  280. <el-date-picker v-model="ruleForm.expired_at" :disabled = "isDisabled" type="datetime" placeholder="选择日期时间"></el-date-picker>
  281. <br/>
  282. <el-checkbox v-model="isCheckExpired" @change="checkExpiredAt">永久</el-checkbox>
  283. </el-form-item>
  284. <el-form-item label="备注" :label-width="formLabelWidth" prop="remark">
  285. <el-input v-model="ruleForm.remark" ></el-input>
  286. </el-form-item>
  287. <el-form-item label="管理员类型" :label-width="formLabelWidth" prop="admin_type">
  288. <template>
  289. <el-radio v-model="ruleForm.admin_type" label="1">超级管理员</el-radio>
  290. <el-radio v-model="ruleForm.admin_type" label="2">管理员</el-radio>
  291. </template>
  292. </el-form-item>
  293. <el-form-item label="角色" :label-width="formLabelWidth" prop="role" v-if="ruleForm.admin_type==2">
  294. <template>
  295. <el-select v-model="ruleForm.role" placeholder="请选择" @change="handleChange">
  296. <el-option
  297. v-for="item in role_list"
  298. :key="item.id"
  299. :label="item.title"
  300. :value="item.id"
  301. >
  302. </el-option>
  303. </el-select>
  304. </template>
  305. </el-form-item>
  306. <el-form-item>
  307. <el-button @click="dialogFormVisible_edit = false">取 消</el-button>
  308. <el-button type="primary" @click="postAdd('ruleForm')">确 定</el-button>
  309. </el-form-item>
  310. </el-form>
  311. </el-dialog>
  312. </el-card>
  313. </div>
  314. <script>
  315. new Vue({
  316. el: '#app',
  317. data() {
  318. return {
  319. admin_type_map:{
  320. 1:'超级管理员',
  321. 2:'管理员',
  322. 3:'操作员',
  323. },
  324. tableData: [],
  325. dialogFormVisible_edit:false,
  326. dialogFormVisible_add:false,
  327. isCheckExpired:false,
  328. isDisabled:false,
  329. isMallNum:false,
  330. isMax:false,
  331. ruleForm: {
  332. id:'',
  333. account:'',
  334. username:'',
  335. password:'',
  336. remark:'',
  337. admin_type:"",
  338. role_id:0,
  339. admin_role_id:'',
  340. mobile:'',
  341. },
  342. rules:{
  343. account: [
  344. { required: true, message: '请输入账号名称', trigger: 'blur' },
  345. // { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
  346. ],
  347. username: [
  348. { required: true, message: '请输入登录账号', trigger: 'blur' },
  349. // { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' }
  350. ],
  351. password: [
  352. { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
  353. ],
  354. remark: [
  355. { min: 1, max: 200, message: '长度在 1 到 200 个字符', trigger: 'blur' }
  356. ],
  357. admin_type: [
  358. { required: true, message: '请选择管理员类型', trigger: 'blur' },
  359. ],
  360. role: [
  361. { required: true, message: '请选择角色', trigger: 'blur' },
  362. ],
  363. mobile: [{
  364. required: true,
  365. validator: (rule, value, callback) => {
  366. if(value==''){
  367. callback('请输入手机号');
  368. return
  369. }
  370. if(!(/^1\d{10}$/.test(value))){
  371. callback('手机号码有误,请重填');
  372. }
  373. callback();
  374. }
  375. }],
  376. },
  377. formLabelWidth: '120px',
  378. defaultProps: {
  379. children: 'children',
  380. label: 'label'
  381. },
  382. tree_data:[],
  383. checkedKey:[],
  384. role_list:[],
  385. title:'新增',
  386. page: 1,
  387. pageCount: 0
  388. }
  389. },
  390. created() {
  391. this.loadList();
  392. },
  393. methods: {
  394. loadList() {
  395. this.$request({
  396. params: {
  397. r: 'admin/account/index',
  398. 'page': this.page
  399. },
  400. }).then(e => {
  401. if(e.data.code==0){
  402. this.tableData = e.data.data.list
  403. this.pageCount = e.data.data.page_count;
  404. }
  405. }).catch(e => {
  406. });
  407. },
  408. handleChange(value){
  409. this.ruleForm.role_id = value;
  410. },
  411. handleEdit(id)
  412. {
  413. if( id != ''){
  414. this.title='编辑';
  415. }
  416. this.ruleForm.id = id
  417. this.dialogFormVisible_edit = true;
  418. this.$request({
  419. params: {
  420. r:'admin/account/edit',
  421. id:id
  422. },
  423. }).then(e => {
  424. if(e.data.code==0){
  425. if(e.data.data.data!=''){
  426. this.ruleForm = e.data.data.data;
  427. }
  428. this.role_list = e.data.data.role_list;
  429. if(this.ruleForm.admin_type != ''){
  430. this.ruleForm.admin_type = this.ruleForm.admin_type.toString();
  431. }
  432. this.ruleForm.password = '';
  433. if (this.ruleForm.expired_at == 0) {
  434. this.isDisabled = true;
  435. this.isCheckExpired = true;
  436. }
  437. if(this.ruleForm.mall_num == -1){
  438. this.isMallNum = true;
  439. this.isMax = true;
  440. }
  441. }else{
  442. this.$message.error(e.data.msg);
  443. }
  444. }).catch(e => {
  445. });
  446. },
  447. postAdd(formName){
  448. this.$refs[formName].validate((valid) => {
  449. if(valid){
  450. if(typeof(this.ruleForm.id)=='undefined'){
  451. if(typeof(this.ruleForm.password)=='undefined'){
  452. this.$message.error('请输入密码');
  453. return false ;
  454. }
  455. }
  456. this.$request({
  457. method:"post",
  458. params: {
  459. r:'admin/account/edit',
  460. },
  461. data:this.ruleForm
  462. }).then(e => {
  463. if(e.data.code==0){
  464. this.dialogFormVisible_edit = false;
  465. this.$message({
  466. message: e.data.msg,
  467. type: 'success'
  468. });
  469. location.reload();
  470. }else{
  471. this.$message.error(e.data.msg);
  472. }
  473. }).catch(e => {
  474. });
  475. }else {
  476. return false;
  477. }
  478. });
  479. },
  480. handleDelete(index, row) {
  481. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  482. this.ruleForm.id = row.id
  483. this.$request({
  484. params: {
  485. r: 'admin/account/del',
  486. id: row.id,
  487. status: -1,
  488. },
  489. }).then(e => {
  490. if (e.data.code == 0) {
  491. this.$message({
  492. message: e.data.msg,
  493. type: 'success'
  494. });
  495. location.reload();
  496. }else{
  497. this.$message({
  498. message: e.data.msg,
  499. type: 'error'
  500. });
  501. }
  502. }).catch(e => {
  503. });
  504. });
  505. },
  506. checkExpiredAt(value) {
  507. this.isCheckExpired = value;
  508. if (value) {
  509. this.ruleForm.expired_at = 0;
  510. this.isDisabled = true;
  511. } else {
  512. this.ruleForm.expired_at = new Date();
  513. this.isDisabled = false;
  514. }
  515. this.$refs['expired_at'].clearValidate();
  516. },
  517. changeIsMax(value){
  518. this.isMax = value
  519. if(value){
  520. this.ruleForm.mall_num = -1
  521. this.isMallNum = true;
  522. }else{
  523. this.ruleForm.mall_num = 0;
  524. this.isMallNum = false;
  525. }
  526. this.$refs['mall_num'].clearValidate();
  527. },
  528. pagination(currentPage) {
  529. let self = this;
  530. self.page = currentPage;
  531. self.loadList();
  532. },
  533. },
  534. });
  535. </script>