index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. <template>
  2. <div class="app-container">
  3. <div class="mymain-container">
  4. <div class="btn-group clearfix">
  5. <div class="fl">
  6. <el-button size="small" type="primary" icon="el-icon-plus" @click="addOrEditParent('add')"
  7. >添加菜单</el-button
  8. >
  9. </div>
  10. </div>
  11. <div class="table">
  12. <el-table
  13. v-loading="listLoading"
  14. :data="dataList"
  15. row-key="moduleId"
  16. border
  17. default-expand-all
  18. :tree-props="{ children: 'pages' }"
  19. >
  20. <el-table-column prop="moduleName" label="菜单名称" min-width="150" />
  21. <el-table-column prop="url" label="菜单URL" min-width="150" />
  22. <el-table-column prop="fullUrl" label="菜单全URL" min-width="200" />
  23. <el-table-column align="center" prop="icon" label="菜单图标">
  24. <template slot-scope="scope">
  25. <i :class="scope.row.icon" style="font-size: 18px" />
  26. </template>
  27. </el-table-column>
  28. <el-table-column align="center" prop="status" label="状态">
  29. <template slot-scope="scope">
  30. <span>{{ ['显示', '不显示'][[true, false].indexOf(scope.row.status)] || '' }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column align="center" prop="isCache" label="状态">
  34. <template slot-scope="scope">
  35. <span>{{ ['缓存', '不缓存'][[1, 0].indexOf(scope.row.isCache)] || '' }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column align="center" prop="sortNum" label="排序" />
  39. <el-table-column align="right" label="操作" width="150" fixed="right">
  40. <template slot-scope="scope">
  41. <el-button type="primary" size="mini" icon="el-icon-plus"
  42. @click="addOrEditChild('add', scope.row.moduleId)" />
  43. <el-button type="primary" size="mini" icon="el-icon-edit"
  44. @click="addOrEditChild('edit', scope.row.moduleId)" />
  45. <el-popconfirm style="margin-left: 10px" title="确定删除吗?" @confirm="handleDelete(scope.row.moduleId)">
  46. <el-button slot="reference" size="mini" icon="el-icon-delete" />
  47. </el-popconfirm>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </div>
  52. </div>
  53. <!-- 新增编辑 一级菜单 -->
  54. <el-dialog
  55. :title="addParentFormType == 'add' ? '添加一级菜单' : '编辑一级菜单'"
  56. :visible.sync="addParentFormVisible"
  57. :show-close="false"
  58. width="60%"
  59. :close-on-click-modal="false"
  60. >
  61. <el-form
  62. ref="addParentForm"
  63. :model="addParentForm"
  64. :rules="addParentFormRules"
  65. label-position="left"
  66. label-width="120px"
  67. >
  68. <el-form-item label="类型" prop="type">
  69. <el-radio-group v-model="addParentForm.type">
  70. <el-radio v-for="item in menuTypeList" :key="item.label" :label="item.label">
  71. {{ item.value }}
  72. </el-radio>
  73. </el-radio-group>
  74. </el-form-item>
  75. <el-form-item label="一级菜单" prop="oneMenu">
  76. <el-input v-model="addParentForm.oneMenu" type="text" placeholder="请输入一级菜单名称" show-word-limit />
  77. </el-form-item>
  78. <el-form-item label="CODE" prop="code">
  79. <el-input v-model="addParentForm.code" placeholder="请输入CODE" />
  80. </el-form-item>
  81. <el-form-item label="URL" prop="url">
  82. <el-input v-model="addParentForm.url" placeholder="请输入URL" />
  83. </el-form-item>
  84. <el-form-item label="全URL" prop="fullUrl">
  85. <el-input v-model="addParentForm.fullUrl" placeholder="请输入全URL" />
  86. </el-form-item>
  87. <el-form-item label="图标">
  88. <div class="iconInput">
  89. <div v-if="addParentForm.icon" class="icon"><i :class="addParentForm.icon" /></div>
  90. <el-input v-model="addParentForm.icon" placeholder="请选择图标" />
  91. <el-button type="primary" @click="toChooseIcon(1)">选择</el-button>
  92. </div>
  93. </el-form-item>
  94. <el-form-item label="排序" prop="sort">
  95. <el-input v-model.number="addParentForm.sort" placeholder="请输入排序" />
  96. </el-form-item>
  97. <el-form-item label="是否显示" prop="status">
  98. <el-switch v-model="addParentForm.status" :active-value="true" :inactive-value="false" active-color="#13ce66"
  99. inactive-color="#ff4949" />
  100. </el-form-item>
  101. <el-form-item label="是否缓存页面" prop="isCache">
  102. <el-switch v-model="addParentForm.isCache" :active-value="1" :inactive-value="0" active-color="#13ce66"
  103. inactive-color="#ff4949" />
  104. </el-form-item>
  105. </el-form>
  106. <div v-if="addParentForm.type === 2">
  107. <el-button style="margin-bottom: 10px" type="primary" size="small" @click="hasShowTable">新增</el-button>
  108. <zj-table
  109. ref="tableEl"
  110. :is-drop="true"
  111. :columns="columns"
  112. :table-data="tableData"
  113. :table-attributes="{
  114. border: true
  115. }"
  116. />
  117. </div>
  118. <div slot="footer" class="dialog-footer">
  119. <el-button @click="cancelAddParentForm">取 消</el-button>
  120. <el-button type="primary" @click="submitAddParentForm">确 定</el-button>
  121. </div>
  122. </el-dialog>
  123. <!-- 新增编辑 二级菜单 -->
  124. <el-dialog
  125. :title="addChildFormType == 'add' ? '添加二级菜单' : '编辑二级菜单'"
  126. :visible.sync="addChildFormVisible"
  127. :show-close="false"
  128. width="60%"
  129. :close-on-click-modal="false"
  130. >
  131. <el-form
  132. ref="addChildForm"
  133. :model="addChildForm"
  134. :rules="addChildFormRules"
  135. label-position="left"
  136. label-width="120px"
  137. >
  138. <el-form-item label="类型" prop="type">
  139. <el-radio-group v-model="addChildForm.type">
  140. <el-radio v-for="item in menuTypeList" :key="item.label" :label="item.label">
  141. {{ item.value }}
  142. </el-radio>
  143. </el-radio-group>
  144. </el-form-item>
  145. <el-form-item label="上级菜单" prop="oneMenu">
  146. <el-cascader
  147. v-model="addChildForm.oneMenu"
  148. style="width: 100%"
  149. :options="[{ moduleId: '0', moduleName: '设定一级' }, ...dataList]"
  150. :props="{ checkStrictly: true, value: 'moduleId', label: 'moduleName' }"
  151. filterable
  152. clearable
  153. />
  154. </el-form-item>
  155. <el-form-item label="二级菜单" prop="twoMenu">
  156. <el-input v-model="addChildForm.twoMenu" type="text" placeholder="请输入二级菜单名称" show-word-limit />
  157. </el-form-item>
  158. <el-form-item label="CODE" prop="code">
  159. <el-input v-model="addChildForm.code" placeholder="请输入CODE" />
  160. </el-form-item>
  161. <el-form-item label="URL" prop="url">
  162. <el-input v-model="addChildForm.url" placeholder="请输入URL" />
  163. </el-form-item>
  164. <el-form-item label="全URL" prop="fullUrl">
  165. <el-input v-model="addChildForm.fullUrl" placeholder="请输入全URL" />
  166. </el-form-item>
  167. <el-form-item label="图标" prop="icon">
  168. <div class="iconInput">
  169. <div v-if="addChildForm.icon" class="icon"><i :class="addChildForm.icon" /></div>
  170. <el-input v-model="addChildForm.icon" placeholder="请选择图标" />
  171. <el-button type="primary" @click="toChooseIcon(2)">选择</el-button>
  172. </div>
  173. </el-form-item>
  174. <el-form-item label="排序" prop="sort">
  175. <el-input v-model.number="addChildForm.sort" placeholder="请输入排序" />
  176. </el-form-item>
  177. <el-form-item label="是否显示" prop="status">
  178. <el-switch v-model="addChildForm.status" :active-value="true" :inactive-value="false" active-color="#13ce66"
  179. inactive-color="#ff4949" />
  180. </el-form-item>
  181. <el-form-item label="是否缓存页面" prop="isCache">
  182. <el-switch v-model="addChildForm.isCache" :active-value="1" :inactive-value="0" active-color="#13ce66"
  183. inactive-color="#ff4949" />
  184. </el-form-item>
  185. </el-form>
  186. <div v-if="addChildForm.type === 2">
  187. <el-button style="margin-bottom: 10px" type="primary" size="small" @click="hasShowTable">新增</el-button>
  188. <zj-table
  189. ref="tableEl"
  190. :is-drop="true"
  191. :columns="columns"
  192. :table-data="tableData"
  193. :table-attributes="{
  194. border: true
  195. }"
  196. />
  197. </div>
  198. <div slot="footer" class="dialog-footer">
  199. <el-button @click="cancelAddChildForm">取 消</el-button>
  200. <el-button type="primary" @click="submitAddChildForm">确 定</el-button>
  201. </div>
  202. </el-dialog>
  203. <el-dialog
  204. :title="formData.moduleId ? '编辑' : '新增'"
  205. :visible.sync="dialogVisible"
  206. :show-close="false"
  207. width="40%"
  208. :close-on-click-modal="false"
  209. >
  210. <el-form ref="formData" :model="formData" :rules="formDataRules" label-position="left" label-width="100px">
  211. <el-form-item label="code" prop="code">
  212. <el-input v-model="formData.code" placeholder="请输入类型" clearable></el-input>
  213. </el-form-item>
  214. <el-form-item label="名称" prop="moduleName">
  215. <el-input v-model="formData.moduleName" placeholder="请输入接口名称" clearable></el-input>
  216. </el-form-item>
  217. </el-form>
  218. <span slot="footer" class="dialog-footer">
  219. <el-button
  220. @click="
  221. dialogVisible = false
  222. chongzhi()
  223. "
  224. >取 消</el-button
  225. >
  226. <el-button type="primary" @click="addOperative">确 定</el-button>
  227. </span>
  228. </el-dialog>
  229. <!-- 选择图标 -->
  230. <el-dialog
  231. title="选择图标"
  232. :visible.sync="isChooseIconDialog"
  233. :show-close="true"
  234. width="600px"
  235. :close-on-click-modal="false"
  236. >
  237. <div class="iconList">
  238. <div v-for="(item, index) in iconList" :key="index" class="item" @click="chooseIcon(item.value)">
  239. <i :class="item.value" />
  240. </div>
  241. </div>
  242. </el-dialog>
  243. </div>
  244. </template>
  245. <script>
  246. import { mapGetters } from 'vuex'
  247. import { getToken } from '@/utils/auth'
  248. import { getMenuList, addMenu, editMenu, deleteMenu, getMenuDetail } from '@/api/setting'
  249. import iconList from '@/const/iconList.js'
  250. export default {
  251. data() {
  252. return {
  253. baseURL: process.env.VUE_APP_BASE_API,
  254. myHeaders: { 'x-token': getToken() },
  255. dataList: [], // 列表数据
  256. listLoading: true, // 列表加载loading
  257. screenForm: {
  258. // 筛选表单数据
  259. keyword: '' // 关键词
  260. },
  261. editParentId: null,
  262. addParentFormType: 'add',
  263. addParentFormVisible: false,
  264. addParentForm: {
  265. oneMenu: '',
  266. code: '',
  267. url: '',
  268. fullUrl: '',
  269. icon: '',
  270. sort: 0,
  271. flag: '',
  272. type: 1,
  273. status: true,
  274. isCache: 1
  275. },
  276. addParentFormRules: {
  277. type: [{ required: true, message: '请选择类型', trigger: 'change' }],
  278. oneMenu: [{ required: true, message: '请填写一级菜单名称', trigger: 'blur' }],
  279. code: [{ required: true, message: '请填写菜单CODE', trigger: 'blur' }],
  280. url: [{ required: true, message: '请填写菜单URL', trigger: 'blur' }],
  281. icon: [{ required: true, message: '请选择图标', trigger: 'blur' }],
  282. flag: [{ required: true, message: '请选择所属', trigger: 'blur' }]
  283. },
  284. editChildId: null,
  285. addChildFormType: 'add',
  286. addChildFormVisible: false,
  287. addChildForm: {
  288. oneMenu: '',
  289. twoMenu: '',
  290. code: '',
  291. url: '',
  292. fullUrl: '',
  293. icon: '',
  294. sort: 0,
  295. flag: '',
  296. type: 1,
  297. status: true,
  298. isCache: 1
  299. },
  300. addChildFormRules: {
  301. type: [{ required: true, message: '请选择类型', trigger: 'change' }],
  302. oneMenu: [{ required: true, message: '请选择一级菜单', trigger: 'change' }],
  303. twoMenu: [{ required: true, message: '请填写二级菜单', trigger: 'blur' }],
  304. code: [{ required: true, message: '请填写菜单CODE', trigger: 'blur' }],
  305. url: [{ required: true, message: '请填写菜单URL', trigger: 'blur' }],
  306. flag: [{ required: true, message: '请选择所属', trigger: 'blur' }]
  307. },
  308. isChooseIconDialog: false,
  309. iconList: iconList,
  310. chooseIconType: null,
  311. menuTypeList: [
  312. {
  313. label: 1,
  314. value: '目录'
  315. },
  316. {
  317. label: 2,
  318. value: '页面'
  319. },
  320. {
  321. label: 4,
  322. value: '外链'
  323. }
  324. ],
  325. tableData: [],
  326. dialogVisible: false,
  327. formData: {
  328. code: '',
  329. moduleName: '',
  330. },
  331. formDataRules: {
  332. code: [{ required: true, message: '请选择类型', trigger: 'blur' }],
  333. moduleName: [{ required: true, message: '请选择类型', trigger: 'blur' }]
  334. },
  335. operateType: null
  336. }
  337. },
  338. computed: {
  339. ...mapGetters(['userid', 'name']),
  340. isAdmin() {
  341. const type = JSON.parse(localStorage.getItem('supply_user')).type
  342. return type === 2
  343. },
  344. columns() {
  345. return [
  346. {
  347. columnAttributes: {
  348. label: '名称',
  349. prop: 'moduleName'
  350. }
  351. },
  352. {
  353. columnAttributes: {
  354. label: 'code',
  355. prop: 'code'
  356. }
  357. },
  358. {
  359. columnAttributes: {
  360. label: '操作',
  361. prop: ''
  362. },
  363. render: (h, { row, column, $index }) => {
  364. return (
  365. <div style="padding-left:10px">
  366. <el-button
  367. size="mini"
  368. type="text"
  369. onClick={() => {
  370. getMenuDetail({ moduleId: row.moduleId }).then(res => {
  371. this.formData = {
  372. ...this.formData,
  373. ...res.data
  374. }
  375. this.dialogVisible = true
  376. })
  377. }}
  378. >
  379. 编辑
  380. </el-button>
  381. <el-popconfirm
  382. title="确定删除吗?"
  383. onConfirm={() => {
  384. deleteMenu({ id: row.moduleId }).then(res => {
  385. this.$successMsg('删除成功')
  386. getMenuDetail({ moduleId: this.operateType === 1 ? this.editParentId : this.editChildId }).then(
  387. res => {
  388. this.tableData = res.data.childList
  389. }
  390. )
  391. })
  392. }}
  393. >
  394. <el-button slot="reference" type="text" size="mini">
  395. 删除
  396. </el-button>
  397. </el-popconfirm>
  398. </div>
  399. )
  400. }
  401. }
  402. ]
  403. }
  404. },
  405. created() {
  406. this.getList()
  407. },
  408. methods: {
  409. getList() {
  410. this.listLoading = true
  411. getMenuList({
  412. adminUserId: this.userid,
  413. flag: 'menu'
  414. })
  415. .then(res => {
  416. this.dataList = this.recursionFn(res.data)
  417. console.log(this.dataList)
  418. })
  419. .finally(() => {
  420. this.listLoading = false
  421. })
  422. },
  423. recursionFn(arr) {
  424. if (!arr.length) return
  425. for (let i = 0; i < arr.length; i++) {
  426. if (arr[i].children.length) {
  427. arr[i].pages = []
  428. arr[i].controls = []
  429. for (let j = 0; j < arr[i].children.length; j++) {
  430. if ([1, 2, 4].includes(arr[i].children[j].type)) {
  431. arr[i].pages.push(arr[i].children[j])
  432. }
  433. if ([3].includes(arr[i].children[j].type)) {
  434. arr[i].controls.push(arr[i].children[j])
  435. }
  436. }
  437. this.recursionFn(arr[i].children)
  438. }
  439. }
  440. return arr || []
  441. },
  442. // 打开 新增编辑 一级菜单
  443. addOrEditParent(type, cid) {
  444. this.addParentFormType = type
  445. this.addParentFormVisible = true
  446. this.operateType = 1
  447. if (type == 'edit') {
  448. this.editParentId = cid
  449. getMenuDetail({ moduleId: cid }).then(res => {
  450. this.addParentForm = {
  451. oneMenu: res.data.moduleName,
  452. code: res.data.code,
  453. url: res.data.url,
  454. fullUrl: res.data.fullUrl,
  455. icon: res.data.icon,
  456. sort: res.data.sortNum,
  457. flag: res.data.flag,
  458. type: res.data.type,
  459. status: res.data.status,
  460. isCache: res.data.isCache,
  461. childList: res.data.childList
  462. }
  463. })
  464. }
  465. },
  466. // 取消 新增编辑 一级菜单
  467. cancelAddParentForm() {
  468. this.addParentFormVisible = false
  469. this.tableData = []
  470. this.$refs.addParentForm.resetFields()
  471. },
  472. // 提交 一级菜单
  473. submitAddParentForm() {
  474. this.$refs.addParentForm.validate(valid => {
  475. if (valid) {
  476. const params = {
  477. moduleName: this.addParentForm.oneMenu,
  478. code: this.addParentForm.code,
  479. url: this.addParentForm.url,
  480. fullUrl: this.addParentForm.fullUrl,
  481. icon: this.addParentForm.icon,
  482. sortNum: this.addParentForm.sort,
  483. flag: this.addParentForm.flag,
  484. parentId: 0,
  485. type: this.addParentForm.type,
  486. status: this.addParentForm.status,
  487. isCache: this.addParentForm.isCache
  488. }
  489. if (this.addParentFormType == 'edit') {
  490. params.moduleId = this.editParentId
  491. editMenu(params).then(res => {
  492. this.cancelAddParentForm()
  493. this.getList()
  494. this.$successMsg('编辑成功')
  495. })
  496. } else {
  497. // params.type = 2;
  498. addMenu(params).then(res => {
  499. this.cancelAddParentForm()
  500. this.getList()
  501. this.$successMsg('添加成功')
  502. })
  503. }
  504. }
  505. })
  506. },
  507. // 打开 新增编辑 二级菜单
  508. addOrEditChild(type, cid) {
  509. this.addChildFormType = type
  510. this.addChildFormVisible = true
  511. this.operateType = 2
  512. if (type == 'add') {
  513. this.addChildForm.oneMenu = cid
  514. }
  515. if (type == 'edit') {
  516. this.editChildId = cid
  517. getMenuDetail({ moduleId: cid }).then(res => {
  518. this.addChildForm = {
  519. oneMenu: res.data.parentId,
  520. twoMenu: res.data.moduleName,
  521. code: res.data.code,
  522. url: res.data.url,
  523. fullUrl: res.data.fullUrl,
  524. icon: res.data.icon,
  525. sort: res.data.sortNum,
  526. flag: res.data.flag,
  527. type: res.data.type,
  528. status: res.data.status,
  529. isCache: res.data.isCache,
  530. childList: res.data.childList
  531. }
  532. this.tableData = res.data.childList
  533. })
  534. }
  535. },
  536. addOperative() {
  537. this.$refs.formData.validate(valid => {
  538. if (valid) {
  539. const params = {
  540. parentId: this.editChildId,
  541. moduleId: this.formData.moduleId || '',
  542. moduleName: this.formData.moduleName,
  543. code: this.formData.code,
  544. type: 3,
  545. childList: this.formData.childList || null,
  546. }
  547. if (this.formData.moduleId) {
  548. params.parentId = null
  549. editMenu(params).then(res => {
  550. this.dialogVisible = false
  551. this.$successMsg('编辑成功')
  552. this.chongzhi()
  553. getMenuDetail({ moduleId: this.operateType === 1 ? this.editParentId : this.editChildId }).then(res => {
  554. this.tableData = res.data.childList
  555. })
  556. })
  557. } else {
  558. addMenu(params).then(res => {
  559. this.dialogVisible = false
  560. this.$successMsg('添加成功')
  561. this.chongzhi()
  562. getMenuDetail({ moduleId: this.operateType === 1 ? this.editParentId : this.editChildId }).then(res => {
  563. this.tableData = res.data.childList
  564. })
  565. })
  566. }
  567. }
  568. })
  569. },
  570. chongzhi() {
  571. this.formData = {
  572. code: '',
  573. moduleName: '',
  574. }
  575. },
  576. hasShowTable() {
  577. this.dialogVisible = true
  578. },
  579. // 取消 新增编辑 二级菜单
  580. cancelAddChildForm() {
  581. this.addChildFormVisible = false
  582. this.tableData = []
  583. this.$refs.addChildForm.resetFields()
  584. },
  585. // 提交 二级菜单
  586. submitAddChildForm() {
  587. this.$refs.addChildForm.validate(valid => {
  588. if (valid) {
  589. let params = {}
  590. let parentId = null
  591. if (this.addChildForm.oneMenu instanceof Array) {
  592. parentId = this.addChildForm.oneMenu[this.addChildForm.oneMenu.length - 1] || 0
  593. } else {
  594. parentId = this.addChildForm.oneMenu || 0
  595. }
  596. if (this.addChildFormType == 'edit') {
  597. params = {
  598. parentId,
  599. moduleId: this.editChildId,
  600. moduleName: this.addChildForm.twoMenu,
  601. code: this.addChildForm.code,
  602. url: this.addChildForm.url,
  603. fullUrl: this.addChildForm.fullUrl,
  604. icon: this.addChildForm.icon,
  605. sortNum: this.addChildForm.sort,
  606. flag: this.addChildForm.flag,
  607. type: this.addChildForm.type,
  608. status: this.addChildForm.status,
  609. isCache: this.addChildForm.isCache
  610. }
  611. editMenu(params).then(res => {
  612. this.cancelAddChildForm()
  613. this.getList()
  614. this.$successMsg('编辑成功')
  615. })
  616. } else {
  617. params = {
  618. parentId,
  619. moduleName: this.addChildForm.twoMenu,
  620. code: this.addChildForm.code,
  621. url: this.addChildForm.url,
  622. fullUrl: this.addChildForm.fullUrl,
  623. icon: this.addChildForm.icon,
  624. sortNum: this.addChildForm.sort,
  625. flag: this.addChildForm.flag,
  626. type: this.addChildForm.type,
  627. status: this.addChildForm.status,
  628. isCache: this.addChildForm.isCache
  629. }
  630. addMenu(params).then(res => {
  631. this.cancelAddChildForm()
  632. this.getList()
  633. this.$successMsg('添加成功')
  634. })
  635. }
  636. }
  637. })
  638. },
  639. // 操作 - 删除
  640. handleDelete(id) {
  641. deleteMenu({ id: id }).then(res => {
  642. this.getList()
  643. this.$successMsg()
  644. })
  645. },
  646. // 去选择图标
  647. toChooseIcon(type) {
  648. this.chooseIconType = type
  649. this.isChooseIconDialog = true
  650. },
  651. // 选择图标
  652. chooseIcon(value) {
  653. if (this.chooseIconType === 1) {
  654. this.addParentForm.icon = value
  655. } else if (this.chooseIconType > 1) {
  656. this.addChildForm.icon = value
  657. }
  658. this.isChooseIconDialog = false
  659. }
  660. }
  661. }
  662. </script>
  663. <style scoped lang="scss">
  664. .iconList {
  665. display: flex;
  666. flex-wrap: wrap;
  667. max-height: 40vh;
  668. overflow-y: scroll;
  669. .item {
  670. width: 40px;
  671. height: 40px;
  672. text-align: center;
  673. line-height: 40px;
  674. cursor: pointer;
  675. i {
  676. font-size: 18px;
  677. }
  678. &:hover {
  679. background: #f5f5f5;
  680. i {
  681. color: #409eff;
  682. }
  683. }
  684. }
  685. }
  686. .iconInput {
  687. display: flex;
  688. .icon {
  689. margin-right: 10px;
  690. border-radius: 4px;
  691. border: 1px solid #dcdfe6;
  692. box-sizing: border-box;
  693. color: #606266;
  694. width: 40px;
  695. height: 40px;
  696. text-align: center;
  697. line-height: 40px;
  698. flex-shrink: 0;
  699. i {
  700. font-size: 18px;
  701. }
  702. }
  703. input {
  704. flex: 1;
  705. }
  706. button {
  707. margin-left: 10px;
  708. }
  709. }
  710. </style>
  711. <style lang="scss">
  712. .el-image-viewer__wrapper .el-icon-circle-close {
  713. color: #ffffff !important;
  714. font-size: 60px;
  715. }
  716. .el-table__row.expanded {
  717. background: #f5f5f5;
  718. }
  719. // th {
  720. // text-align: center !important;
  721. // }
  722. </style>