index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <el-card style="margin: 15px">
  3. <!-- 操作按钮区域 -->
  4. <div class="table-operator" style="margin: 5px 0;float: right">
  5. <a-button v-permission="['pc:system:menu:add']" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  6. <a-dropdown v-if="selectedRowKeys.length > 0">
  7. <a-menu slot="overlay">
  8. <a-menu-item key="1" v-permission="['pc:system:menu:remove']" @click="batchDel">
  9. <a-icon type="delete" />
  10. 删除
  11. </a-menu-item>
  12. </a-menu>
  13. <a-button style="margin-left: 8px">
  14. 批量操作
  15. <a-icon type="down" />
  16. </a-button>
  17. </a-dropdown>
  18. </div>
  19. <!-- 查询区域 -->
  20. <div class="table-page-search-wrapper">
  21. <a-form layout="inline" @keyup.enter.native="searchQuery">
  22. <a-form-item>
  23. <a-input
  24. v-model="queryParam.menuName"
  25. style="width: 150px"
  26. placeholder="菜单名称"
  27. />
  28. </a-form-item>
  29. <a-form-item>
  30. <a-button type="primary" @click="searchQuery">查询</a-button>
  31. <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
  32. </a-form-item>
  33. </a-form>
  34. </div>
  35. <!-- table区域-begin -->
  36. <div>
  37. <div class="ant-alert ant-alert-info" style="margin: 16px 0;">
  38. <i class="anticon anticon-info-circle ant-alert-icon" />
  39. 已选择&nbsp;<a style="font-weight: 600">{{
  40. selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  41. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  42. </div>
  43. <a-table
  44. ref="table"
  45. size="middle"
  46. bordered
  47. row-key="menuId"
  48. :columns="columns"
  49. :default-expanded-row-keys="[100]"
  50. :data-source="dataSource"
  51. :pagination="ipagination"
  52. :loading="loading"
  53. :row-selection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  54. @change="handleTableChange"
  55. >
  56. <template slot="menuType" slot-scope="text, record">
  57. <a-tag v-if="record.menuType === 'M'" color="#f50">
  58. 目录
  59. </a-tag>
  60. <a-tag v-if="record.menuType === 'C'" color="#2db7f5">
  61. 菜单
  62. </a-tag>
  63. <a-tag v-if="record.menuType === 'F'" color="#87d068">
  64. 按钮
  65. </a-tag>
  66. </template>
  67. <template slot="status" slot-scope="text, record">
  68. <a-switch
  69. v-if="JSPermission(['pc:system:menu:edit'])"
  70. :checked="record.status==='1'?false:true"
  71. checked-children="启用"
  72. un-checked-children="停用"
  73. @change="changeStatus({$event,record})"
  74. />
  75. <span v-else>{{ record.status==='1'?'停用':'启用' }}</span>
  76. </template>
  77. <span slot="action" slot-scope="text, record">
  78. <a-button v-permission="['pc:system:menu:edit']" size="small" type="primary" @click="handleEdit(record)">
  79. 编辑
  80. </a-button>
  81. <a-divider type="vertical" />
  82. <a-popconfirm
  83. v-permission="['pc:system:menu:remove']"
  84. title="确定删除吗?"
  85. @confirm="() => handleDelete(record.menuId)"
  86. >
  87. <a-button size="small" type="danger">
  88. 删除
  89. </a-button>
  90. </a-popconfirm>
  91. </span>
  92. </a-table>
  93. <check-and-edit-model ref="modalForm" @ok="modalFormOk" />
  94. </div>
  95. <!-- table区域-end -->
  96. <!-- 表单区域 -->
  97. </el-card>
  98. </template>
  99. <script>
  100. import { listMixin } from '@/mixin/listMixin'
  101. import columns from './indexColumns'
  102. import CheckAndEditModel from './CheckAndEditModel'
  103. import { httpAction } from '@/api/request'
  104. import JSPermission from '@/utils/JSPermission'
  105. export default {
  106. components: {
  107. CheckAndEditModel
  108. },
  109. mixins: [listMixin],
  110. data() {
  111. return {
  112. // 查询条件
  113. queryParam: {},
  114. // 表头
  115. columns: columns(this),
  116. url: {
  117. list: '/system/menu/tree',
  118. delete: '/system/menu/'
  119. }
  120. }
  121. },
  122. created() {
  123. },
  124. methods: {
  125. JSPermission,
  126. changeStatus({ $event, record }) {
  127. console.log($event, record)
  128. record.status = $event ? '0' : '1'
  129. httpAction('/system/menu', record, 'put').then((res) => {
  130. if (res.code === 200) {
  131. this.$message.success(res.msg)
  132. } else {
  133. console.log(res)
  134. }
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped>
  141. @import '~@/assets/less/common.less'
  142. </style>