index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. <el-alert
  175. style="margin-bottom:20px;"
  176. type="info"
  177. title="员工登录入口链接:"
  178. :closable="false">
  179. <template>
  180. <span id="target">{{loginRoute}}</span>
  181. <el-button id="copy_btn"
  182. data-clipboard-action="copy"
  183. data-clipboard-target="#target"
  184. size="mini">复制链接
  185. </el-button>
  186. </template>
  187. </el-alert>
  188. <template>
  189. <div>
  190. <el-table
  191. :data="tableData"
  192. style="width: 100%;margin-bottom: 20px;"
  193. row-key="id"
  194. stripe
  195. default-expand-all
  196. >
  197. <!-- <el-table-column-->
  198. <!-- prop="id"-->
  199. <!-- label="ID"-->
  200. <!-- sortable-->
  201. <!-- width="180">-->
  202. <!-- <template slot-scope="scope">-->
  203. <!-- <span style="margin-left: 10px">{{ scope.row.id }}</span>-->
  204. <!-- </template>-->
  205. <!-- </el-table-column>-->
  206. <el-table-column prop="id" label="ID" width="100"></el-table-column>
  207. <el-table-column
  208. prop="title"
  209. label="登陆用户名"
  210. width="180">
  211. <template slot-scope="scope">
  212. <span style="margin-left: 10px">{{ scope.row.username }}</span>
  213. </template>
  214. </el-table-column>
  215. <el-table-column
  216. prop="title"
  217. label="账号名称"
  218. width="180">
  219. <template slot-scope="scope">
  220. <span style="margin-left: 10px">{{ scope.row.account }}</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.role }}</span>
  228. </template>
  229. </el-table-column>
  230. <el-table-column
  231. prop="mobile"
  232. label="手机号"
  233. width="180">
  234. <template slot-scope="scope">
  235. <span style="margin-left: 10px">{{ scope.row.mobile }}</span>
  236. </template>
  237. </el-table-column>
  238. <el-table-column
  239. prop="url"
  240. label="创建时间">
  241. <template slot-scope="scope">
  242. <span style="margin-left: 10px">{{ scope.row.created_at }}</span>
  243. </template>
  244. </el-table-column>
  245. <el-table-column
  246. prop="url"
  247. label="创建时间">
  248. <template slot-scope="scope">
  249. <span style="margin-left: 10px">{{ scope.row.created_at }}</span>
  250. </template>
  251. </el-table-column>
  252. <el-table-column
  253. prop="url"
  254. label="备注">
  255. <template slot-scope="scope">
  256. <span style="margin-left: 10px">{{ scope.row.remark }}</span>
  257. </template>
  258. </el-table-column>
  259. <el-table-column label="操作">
  260. <template slot-scope="scope">
  261. <el-button v-if="scope.row.is_default == 0 " type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px"
  262. @click="handleEdit(scope.row.id)">
  263. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  264. <img src="resources/img/mall/edit.png" alt="">
  265. </el-tooltip>
  266. </el-button>
  267. <el-button v-if="scope.row.is_default == 0 " style="margin-left: 10px;margin-top: 10px" type="text"
  268. class="set-el-button"
  269. size="mini" circle @click="handleDelete(scope.$index, scope.row)">
  270. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  271. <img src="resources/img/mall/del.png" alt="">
  272. </el-tooltip>
  273. </el-button>
  274. </template>
  275. </el-table-column>
  276. </el-table>
  277. <div style="text-align: right;margin: 20px 0;">
  278. <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
  279. </div>
  280. </div>
  281. </template>
  282. </div>
  283. <el-dialog :title="title" :visible.sync="dialogFormVisible_edit" :close-on-click-modal="false">
  284. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  285. <el-form-item label="账号名称" :label-width="formLabelWidth" prop="account">
  286. <el-input v-model="ruleForm.account"></el-input>
  287. </el-form-item>
  288. <el-form-item label="登录账号" :label-width="formLabelWidth" prop="username">
  289. <el-input v-model="ruleForm.username" ></el-input>
  290. </el-form-item>
  291. <el-form-item label="登录密码" :label-width="formLabelWidth" prop="password">
  292. <el-input v-model="ruleForm.password" type="password"></el-input>
  293. </el-form-item>
  294. <el-form-item label="手机号" :label-width="formLabelWidth" prop="mobile">
  295. <el-input v-model="ruleForm.mobile" ></el-input>
  296. </el-form-item>
  297. <el-form-item label="备注" :label-width="formLabelWidth" prop="remark">
  298. <el-input v-model="ruleForm.remark" ></el-input>
  299. </el-form-item>
  300. <el-form-item label="角色" :label-width="formLabelWidth" prop="role">
  301. <template>
  302. <el-select v-model="ruleForm.role" placeholder="请选择" @change="handleChange">
  303. <el-option
  304. v-for="item in role_list"
  305. :key="item.id"
  306. :label="item.title"
  307. :value="item.id"
  308. >
  309. </el-option>
  310. </el-select>
  311. </template>
  312. </el-form-item>
  313. <el-form-item>
  314. <el-button @click="dialogFormVisible_edit = false">取 消</el-button>
  315. <el-button type="primary" @click="postAdd('ruleForm')">确 定</el-button>
  316. </el-form-item>
  317. </el-form>
  318. </el-dialog>
  319. </el-card>
  320. </div>
  321. <!-- <script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script> -->
  322. <script src="/resources/unpkg/clipboard@1.5.12/dist/clipboard.min.js"></script>
  323. <script>
  324. new Vue({
  325. el: '#app',
  326. data() {
  327. return {
  328. tableData: [],
  329. dialogFormVisible_edit:false,
  330. dialogFormVisible_add:false,
  331. ruleForm: {
  332. id:'',
  333. account:'',
  334. username:'',
  335. password:'',
  336. remark:'',
  337. role_id:'',
  338. admin_role_id:'',
  339. mobile:'',
  340. },
  341. rules:{
  342. account: [
  343. { required: true, message: '请输入账号名称', trigger: 'blur' },
  344. {
  345. validator: (rule, value, callback) => {
  346. if(typeof(value)!='undefined'){
  347. var len = value.length;
  348. if (typeof(len) == 'undefined')
  349. {
  350. callback();
  351. }else{
  352. if(len>=3&&len<=20){
  353. callback();
  354. }else{
  355. callback('长度在 3 到 20 个字符');
  356. }
  357. }
  358. }
  359. }
  360. }
  361. ],
  362. username: [
  363. { required: true, message: '请输入登录账号', trigger: 'blur' },
  364. {
  365. validator: (rule, value, callback) => {
  366. if(typeof(value)!='undefined'){
  367. var len = value.length;
  368. if (typeof(len) == 'undefined')
  369. {
  370. callback();
  371. }else{
  372. if(len>=3&&len<=20){
  373. callback();
  374. }else{
  375. callback('长度在 3 到 20 个字符');
  376. }
  377. }
  378. }
  379. }
  380. }
  381. ],
  382. mobile: [{
  383. required: true,
  384. validator: (rule, value, callback) => {
  385. if(value==''){
  386. callback('请输入手机号');
  387. return
  388. }
  389. if(!(/^1\d{10}$/.test(value))){
  390. callback('手机号码有误,请重填');
  391. }
  392. callback();
  393. }
  394. }],
  395. password: [
  396. { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
  397. ],
  398. role: [
  399. { required: true, message: '请选择角色', trigger: 'blur' },
  400. ],
  401. },
  402. formLabelWidth: '120px',
  403. defaultProps: {
  404. children: 'children',
  405. label: 'label'
  406. },
  407. tree_data:[],
  408. checkedKey:[],
  409. role_list:[],
  410. title:'新增',
  411. loginRoute:'',
  412. page: 1,
  413. pageCount: 0,
  414. }
  415. },
  416. created() {
  417. this.loadList({});
  418. },
  419. methods: {
  420. loadList() {
  421. var params = {
  422. "r":'mall/account/index',
  423. "page":this.page
  424. }
  425. this.$request({
  426. params: params,
  427. }).then(e => {
  428. if(e.data.code==0){
  429. this.tableData = e.data.data.list
  430. this.loginRoute = e.data.data.url
  431. this.pageCount = e.data.data.page_count;
  432. }
  433. }).catch(e => {
  434. });
  435. },
  436. handleChange(value){
  437. this.ruleForm.role_id = value;
  438. },
  439. pagination(currentPage) {
  440. let self = this;
  441. self.page = currentPage;
  442. self.loadList();
  443. },
  444. handleEdit(id)
  445. {
  446. if( id != ''){
  447. this.title='编辑';
  448. }
  449. this.ruleForm.id = id
  450. this.dialogFormVisible_edit = true;
  451. this.$request({
  452. params: {
  453. r:'mall/account/edit',
  454. id:id
  455. },
  456. }).then(e => {
  457. if(e.data.code==0){
  458. this.ruleForm = e.data.data.data;
  459. this.role_list = e.data.data.role_list;
  460. if(this.ruleForm.admin_type != ''){
  461. this.ruleForm.admin_type = this.ruleForm.admin_type.toString();
  462. }
  463. this.ruleForm.password = '';
  464. }
  465. }).catch(e => {
  466. });
  467. },
  468. postAdd(formName){
  469. this.$refs[formName].validate((valid) => {
  470. if(valid){
  471. if(typeof(this.ruleForm.id)=='undefined'){
  472. if(typeof(this.ruleForm.password)=='undefined'){
  473. this.$message.error('请输入密码');
  474. return false ;
  475. }
  476. }
  477. this.$request({
  478. method:"post",
  479. params: {
  480. r:'mall/account/edit',
  481. },
  482. data:this.ruleForm
  483. }).then(e => {
  484. if(e.data.code==0){
  485. if(this.ruleForm.id){
  486. this.dialogFormVisible_edit = false;
  487. }else{
  488. this.dialogFormVisible_add = false;
  489. }
  490. this.$message({
  491. message: e.data.msg,
  492. type: 'success'
  493. });
  494. }else{
  495. this.$message.error(e.data.msg);
  496. }
  497. }).catch(e => {
  498. });
  499. }else {
  500. return false;
  501. }
  502. });
  503. },
  504. handleDelete(index, row) {
  505. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  506. this.ruleForm.id = row.id
  507. this.$request({
  508. params: {
  509. r: 'mall/account/del',
  510. id: row.id,
  511. status: -1,
  512. },
  513. }).then(e => {
  514. if (e.data.code == 0) {
  515. this.$message({
  516. message: e.data.msg,
  517. type: 'success'
  518. });
  519. location.reload();
  520. } else {
  521. this.$message({
  522. message: e.data.msg,
  523. type: 'error'
  524. });
  525. }
  526. }).catch(e => {
  527. });
  528. });
  529. },
  530. },
  531. });
  532. var clipboard = new Clipboard('#copy_btn');
  533. var self = this;
  534. clipboard.on('success', function (e) {
  535. self.ELEMENT.Message.success('复制成功');
  536. e.clearSelection();
  537. });
  538. clipboard.on('error', function (e) {
  539. self.ELEMENT.Message.success('复制失败,请手动复制');
  540. });
  541. </script>