index.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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="handleAdds">新增</el-button>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="table-body">
  174. <template>
  175. <template>
  176. <el-tabs v-model="activeName" @tab-click="handleClick">
  177. <el-tab-pane label="平台" name="1"></el-tab-pane>
  178. <el-tab-pane label="商城" name="2"></el-tab-pane>
  179. </el-tabs>
  180. </template>
  181. <div>
  182. <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" row-key="id" stripe lazy :load="loadData" :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
  183. <el-table-column prop="title" label="名称" width="300">
  184. <template slot-scope="scope">
  185. <span style="margin-left: 10px">{{ scope.row.title }}
  186. <i class="el-icon-circle-plus" @click="handleAdd(scope.$index, scope.row)"></i>
  187. </span>
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="url" label="路由">
  191. <template slot-scope="scope">
  192. <span style="margin-left: 10px">{{ scope.row.url }}</span>
  193. </template>
  194. </el-table-column>
  195. <el-table-column prop="status" label="状态">
  196. <template slot-scope="scope">
  197. <el-switch v-model="scope.row.status" :inactive-value="0" :active-value="1" active-color="#409EFF" inactive-color="#C0CCDA" @change="handleUpdate(scope.row)">
  198. </el-switch>
  199. </template>
  200. </el-table-column>
  201. <el-table-column
  202. prop="sort"
  203. label="序号"
  204. width="200">
  205. <template slot-scope="scope">
  206. <div v-if="sort_id != scope.row.id">
  207. <el-tooltip class="item" effect="dark" content="排序" placement="top">
  208. <span>{{scope.row.sort}}</span>
  209. </el-tooltip>
  210. <el-button class="edit-sort" type="text" @click="edit(scope.row,'sort')">
  211. <img src="resources/img/mall/order/edit.png" alt="">
  212. </el-button>
  213. </div>
  214. <div style="display: flex;align-items: center" v-else>
  215. <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="sort"></el-input>
  216. <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="cancelEdit('sort')"></el-button>
  217. <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="changeValue(scope.row)">
  218. </el-button>
  219. </div>
  220. </template>
  221. </el-table-column>
  222. <el-table-column label="操作">
  223. <template slot-scope="scope">
  224. <el-button type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px" @click="handleEdit(scope.$index, scope.row)">
  225. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  226. <img src="resources/img/mall/edit.png" alt="">
  227. </el-tooltip>
  228. </el-button>
  229. <el-button style="margin-left: 10px;margin-top: 10px" type="text" class="set-el-button" size="mini" circle @click="handleDelete(scope.$index, scope.row)">
  230. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  231. <img src="resources/img/mall/del.png" alt="">
  232. </el-tooltip>
  233. </el-button>
  234. </template>
  235. </el-table-column>
  236. </el-table>
  237. </div>
  238. </template>
  239. </div>
  240. <el-dialog title="新增" :visible.sync="dialogFormVisible_add_0">
  241. <el-form :model="form0" :rules="rules" ref="form0" @close="handleClose('form0')">
  242. <el-form-item label="父级菜单" :label-width="formLabelWidth">
  243. <el-select v-model="parent_title" placeholder="请选择" @change="handleChange">
  244. <el-option v-for="item,k in parent_list" :key="k" :label="item" :value="k">
  245. </el-option>
  246. </el-select>
  247. </el-form-item>
  248. <el-form-item label="名称" :label-width="formLabelWidth" prop="title">
  249. <el-input v-model="form0.title" autocomplete="off"></el-input>
  250. </el-form-item>
  251. <el-form-item label="路由" :label-width="formLabelWidth" prop="url">
  252. <el-input v-model="form0.url" autocomplete="off"></el-input>
  253. </el-form-item>
  254. <el-form-item label="图标" :label-width="formLabelWidth" prop="icon">
  255. <el-input v-model="form0.icon" autocomplete="off"></el-input>
  256. </el-form-item>
  257. <el-form-item label="开发可见" :label-width="formLabelWidth" prop="status">
  258. <el-switch v-model="form0.dev" :active-value="1" :inactive-value="0"></el-switch>
  259. </el-form-item>
  260. <el-form-item label="排序" :label-width="formLabelWidth" prop="sort">
  261. <el-input v-model="form0.sort" autocomplete="off"></el-input>
  262. </el-form-item>
  263. <el-form-item label="状态" :label-width="formLabelWidth" prop="status">
  264. <el-switch v-model="form0.status" :active-value="1" :inactive-value="0"></el-switch>
  265. </el-form-item>
  266. </el-form>
  267. <div slot="footer" class="dialog-footer">
  268. <el-button @click="dialogFormVisible_add_0 = false">取 消</el-button>
  269. <el-button type="primary" @click="postAdd0('form0')">确 定</el-button>
  270. </div>
  271. </el-dialog>
  272. <el-dialog title="新增" :visible.sync="dialogFormVisible_add">
  273. <el-form :model="form" :rules="rules" ref="form" @close="handleClose('form')">
  274. <el-form-item label="父级名称" :label-width="formLabelWidth">
  275. <el-select v-model="parent_title" placeholder="请选择" @change="handleChange">
  276. <el-option v-for="item,k in parent_list" :key="k" :label="item" :value="k">
  277. </el-option>
  278. </el-select>
  279. </el-form-item>
  280. <el-form-item label="名称" :label-width="formLabelWidth" prop="title">
  281. <el-input v-model="form.title" autocomplete="off"></el-input>
  282. </el-form-item>
  283. <el-form-item label="路由" :label-width="formLabelWidth" prop="url">
  284. <el-input v-model="form.url" autocomplete="off"></el-input>
  285. </el-form-item>
  286. <el-form-item label="图标" :label-width="formLabelWidth">
  287. <el-input v-model="form.icon" autocomplete="off"></el-input>
  288. </el-form-item>
  289. <el-form-item label="开发可见" :label-width="formLabelWidth">
  290. <el-switch v-model="form.dev" :active-value="1" :inactive-value="0"></el-switch>
  291. </el-form-item>
  292. <el-form-item label="排序" :label-width="formLabelWidth" prop="sort">
  293. <el-input v-model="form.sort" autocomplete="off"></el-input>
  294. </el-form-item>
  295. <el-form-item label="状态" :label-width="formLabelWidth">
  296. <el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
  297. </el-form-item>
  298. </el-form>
  299. <div slot="footer" class="dialog-footer">
  300. <el-button @click="dialogFormVisible_add = false">取 消</el-button>
  301. <el-button type="primary" @click="postAdd('form')">确 定</el-button>
  302. </div>
  303. </el-dialog>
  304. <el-dialog title="编辑" :visible.sync="dialogFormVisible_edit">
  305. <el-form :model="form" :rules="rules" ref="form">
  306. <el-form-item label="父级名称" :label-width="formLabelWidth" prop="parent_title">
  307. <el-select v-model="parent_title" placeholder="请选择" @change="handleChange">
  308. <el-option v-for="item,k in parent_list" :key="k" :label="item" :value="k">
  309. </el-option>
  310. </el-select>
  311. </el-form-item>
  312. <el-form-item label="名称" :label-width="formLabelWidth" prop="title">
  313. <el-input v-model="form.title" autocomplete="off"></el-input>
  314. </el-form-item>
  315. <el-form-item label="路由" :label-width="formLabelWidth" prop="url">
  316. <el-input v-model="form.url" autocomplete="off"></el-input>
  317. </el-form-item>
  318. <el-form-item label="图标" :label-width="formLabelWidth" prop="icon">
  319. <el-input v-model="form.icon" autocomplete="off"></el-input>
  320. </el-form-item>
  321. <el-form-item label="开发可见" :label-width="formLabelWidth" prop="dev">
  322. <el-switch v-model="form.dev" :active-value="1" :inactive-value="0"></el-switch>
  323. </el-form-item>
  324. <el-form-item label="排序" :label-width="formLabelWidth" prop="sort">
  325. <el-input v-model="form.sort" autocomplete="off"></el-input>
  326. </el-form-item>
  327. <el-form-item label="状态" :label-width="formLabelWidth" prop="status">
  328. <el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
  329. </el-form-item>
  330. </el-form>
  331. <div slot="footer" class="dialog-footer">
  332. <el-button @click="dialogFormVisible_edit=false">取 消</el-button>
  333. <el-button type="primary" @click="postEdit('form')">确 定</el-button>
  334. </div>
  335. </el-dialog>
  336. </el-card>
  337. </div>
  338. <script>
  339. new Vue({
  340. el: '#app',
  341. data() {
  342. return {
  343. activeName: "1",
  344. tableData: [],
  345. dialogFormVisible_edit: false,
  346. dialogFormVisible_add: false,
  347. dialogFormVisible_add_0: false,
  348. options: [],
  349. parent_list: [],
  350. parent_title: '',
  351. form0: {
  352. id: '',
  353. parent_title: '',
  354. title: '',
  355. app_id: "backend",
  356. cate_id: '1',
  357. addons_name: '',
  358. is_addon: 0,
  359. pid: 0,
  360. url: '',
  361. icon: '',
  362. dev: 0,
  363. sort: 999,
  364. status: 0,
  365. },
  366. rules: {
  367. title: [{
  368. required: true,
  369. message: '请输入名称',
  370. trigger: 'blur'
  371. },
  372. ],
  373. url: [{
  374. required: true,
  375. message: '请输入路由',
  376. trigger: 'blur'
  377. }, ],
  378. },
  379. form: {
  380. id: '',
  381. title: '',
  382. app_id: "backend",
  383. cate_id: '1',
  384. addons_name: '',
  385. is_addon: 0,
  386. pid: 0,
  387. url: '',
  388. icon: '',
  389. dev: 0,
  390. sort: 999,
  391. status: 0,
  392. },
  393. formLabelWidth: '120px',
  394. cate_id: 1,
  395. sort: 0,
  396. sort_id: 0,
  397. }
  398. },
  399. created() {
  400. this.loadList({});
  401. },
  402. methods: {
  403. loadList(params) {
  404. params['r'] = 'admin/menu/index';
  405. this.$request({
  406. params: params,
  407. }).then(e => {
  408. if (e.data.code == 0) {
  409. if(e.data.data.menus){
  410. let menus = e.data.data.menus;
  411. for(var i in menus) {
  412. if(menus[i]['child'].length!=0){
  413. menus[i].hasChildren = true;
  414. }
  415. }
  416. this.tableData = menus;
  417. }
  418. }
  419. }).catch(e => {});
  420. },
  421. handleChange(value) {
  422. this.form.pid = value;
  423. this.form0.pid = value;
  424. },
  425. handleClick(tab, event) {
  426. this.loadList({
  427. cate_id: tab.name
  428. });
  429. this.form.cate_id = tab.name
  430. this.form0.cate_id = tab.name
  431. this.cate_id = tab.name
  432. },
  433. handleEdit(index, row) {
  434. this.form.id = row.id
  435. this.$request({
  436. params: {
  437. r: 'admin/menu/edit',
  438. id: row.id,
  439. type: 'edit'
  440. },
  441. }).then(e => {
  442. if(e.data.code==0){
  443. this.dialogFormVisible_edit = true;
  444. this.parent_title = e.data.data.parent_title;
  445. this.parent_list = e.data.data.list;
  446. this.form = e.data.data.menus;
  447. this.form.cate_id = e.data.data.menus.cate_id.toString();
  448. }else{
  449. this.$message.error(e.data.msg);
  450. }
  451. }).catch(e => {});
  452. },
  453. handleAdd(index, row) {
  454. this.dialogFormVisible_add = true;
  455. this.$request({
  456. params: {
  457. r: 'admin/menu/edit',
  458. id: row.id,
  459. type: 'add',
  460. },
  461. }).then(e => {
  462. if (e.data.code == 0) {
  463. this.parent_title = e.data.data.parent_title;
  464. this.form.pid = row.id;
  465. this.form.title = '';
  466. this.form.url = '';
  467. this.form.icon = '';
  468. this.form.dev = 0;
  469. this.form.status = 0;
  470. this.form.sort = 999;
  471. this.parent_list = e.data.data.list;
  472. }
  473. }).catch(e => {});
  474. },
  475. handleAdds() {
  476. this.dialogFormVisible_add_0 = true;
  477. this.$request({
  478. params: {
  479. r:'admin/menu/add',
  480. id:'',
  481. type:'add',
  482. },
  483. }).then(e => {
  484. if (e.data.code == 0) {
  485. this.parent_title = e.data.data.parent_title;
  486. this.parent_list = e.data.data.list;
  487. this.form.pid = 0;
  488. this.form.title = '';
  489. this.form.url = '';
  490. this.form.icon = '';
  491. this.form.dev = 0;
  492. this.form.status = 0;
  493. this.form.sort = 999;
  494. }
  495. }).catch(e => {
  496. });
  497. },
  498. postEdit(formName){
  499. this.$refs[formName].validate((valid) => {
  500. if(valid){
  501. this.form.cate_id = this.activeName;
  502. this.$request({
  503. method:"post",
  504. params: {
  505. r:'admin/menu/edit',
  506. },
  507. data:this.form
  508. }).then(e => {
  509. if(e.data.code==0){
  510. if(this.form.id){
  511. this.dialogFormVisible_edit = false;
  512. }else{
  513. this.dialogFormVisible_add = false;
  514. }
  515. this.$message({
  516. message: e.data.msg,
  517. type: 'success'
  518. });
  519. }else{
  520. this.$message.error(e.data.msg);
  521. }
  522. }).catch(e => {
  523. });
  524. }
  525. });
  526. },
  527. postAdd(formName) {
  528. this.$refs[formName].validate((valid) => {
  529. if (valid) {
  530. this.form.cate_id = this.activeName;
  531. this.$request({
  532. method: "post",
  533. params: {
  534. r: 'admin/menu/add',
  535. },
  536. data: this.form
  537. }).then(e => {
  538. if (e.data.code == 0) {
  539. if (this.form.id) {
  540. this.dialogFormVisible_edit = false;
  541. } else {
  542. this.dialogFormVisible_add = false;
  543. }
  544. this.handleClose(formName);
  545. this.$message({
  546. message: e.data.msg,
  547. type: 'success'
  548. });
  549. }else{
  550. this.$message.error(e.data.msg);
  551. }
  552. }).catch(e => {});
  553. }
  554. });
  555. },
  556. postAdd0(formName) {
  557. this.$refs[formName].validate((valid) => {
  558. if (valid) {
  559. this.form.cate_id = this.activeName;
  560. this.$request({
  561. method: "post",
  562. params: {
  563. r: 'admin/menu/add',
  564. },
  565. data: this.form0
  566. }).then(e => {
  567. if (e.data.code == 0) {
  568. this.dialogFormVisible_add_0 = false;
  569. this.handleClose(formName);
  570. this.$message({
  571. message: e.data.msg,
  572. type: 'success'
  573. });
  574. }else{
  575. this.$message.error(e.data.msg);
  576. }
  577. }).catch(e => {});
  578. }
  579. });
  580. },
  581. handleDelete(index, row) {
  582. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  583. this.form.id = row.id
  584. this.$request({
  585. params: {
  586. r: 'admin/menu/del',
  587. id: row.id,
  588. status: -1,
  589. },
  590. }).then(e => {
  591. if (e.data.code == 0) {
  592. this.$message({
  593. message: e.data.msg,
  594. type: 'success'
  595. });
  596. location.reload();
  597. }else{
  598. this.$message({
  599. message: e.data.msg,
  600. type: 'error'
  601. });
  602. }
  603. }).catch(e => {});
  604. });
  605. },
  606. handleUpdate(row) {
  607. this.form.id = row.id
  608. this.$request({
  609. params: {
  610. r:'admin/menu/update-status',
  611. id:row.id,
  612. status:row.status,
  613. },
  614. }).then(e => {
  615. if (e.data.code == 0) {
  616. this.$message({
  617. message: e.data.msg,
  618. type: 'success'
  619. });
  620. }
  621. }).catch(e => {});
  622. },
  623. loadData(tree, treeNode, resolve) {
  624. this.$request({
  625. params: {
  626. r: 'admin/menu/index',
  627. pid: tree.id,
  628. cate_id: this.cate_id,
  629. },
  630. }).then(e => {
  631. if (e.data.code == 0) {
  632. let menus = e.data.data.menus;
  633. for(var i in menus) {
  634. if(menus[i]['child'].length!=0){
  635. menus[i].hasChildren = true;
  636. }
  637. }
  638. resolve(menus);
  639. }
  640. }).catch(e => {});
  641. },
  642. handleClose(formName){
  643. this.$refs[formName].resetFields();
  644. },
  645. changeValue(row){
  646. this.$request({
  647. params: {
  648. r:'admin/menu/update-sort',
  649. id:row.id,
  650. sort:this.sort,
  651. },
  652. }).then(e => {
  653. this.$message({
  654. message: e.data.msg,
  655. type: 'success'
  656. });
  657. row.sort = this.sort;
  658. this.sort_id=0;
  659. }).catch(e => {
  660. });
  661. },
  662. edit(row, type) {
  663. switch (type) {
  664. case 'sort':
  665. this.sort = row.sort;
  666. this.sort_id = row.id;
  667. break;
  668. }
  669. },
  670. cancelEdit(type) {
  671. switch (type) {
  672. case 'sort':
  673. this.sort = 0;
  674. this.sort_id = 0;
  675. break;
  676. }
  677. },
  678. },
  679. });
  680. </script>