| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <div class="app-list-content">
- <cl-crud @load="onLoad">
- <template #table-column-icon="{scope}">
- <icon-svg :name="scope.row.icon" size="20px"></icon-svg>
- </template>
- <!-- <template #table-column-perms="{scope}">
- <el-tag
- size="medium"
- v-for="(item, index) in scope.row.permList"
- :key="index"
- style="margin: 2px"
- >{{ item }}</el-tag
- >
- </template> -->
- <!--
- <template #table-column-router="{scope}">
- <el-link type="primary" :href="scope.row.router" v-if="scope.row.type == 1">{{
- scope.row.router
- }}</el-link>
- <span v-else>{{ scope.row.router }}</span>
- </template>
- <template #table-column-keepAlive="{scope}">
- <template v-if="scope.row.type == 1">
- <i class="el-icon-check" v-if="scope.row.keepAlive"></i>
- <i class="el-icon-close" v-else></i>
- </template>
- </template> -->
- <template #slot-column-op="{scope}">
- <el-button
- type="text"
- size="mini"
- @click="upsertAppend(scope.row)"
- v-if="scope.row.type != 2"
- >新增</el-button
- >
- </template>
- </cl-crud>
- <cl-context-menu ref="context-menu"></cl-context-menu>
- </div>
- </template>
- <script>
- import { deepTree } from '@/cool/utils/index';
- export default {
- data() {
- return {
- crud: null,
- parentArr: []
- };
- },
- methods: {
- onLoad({ ctx, app }) {
- this.crud = app;
- ctx.service(this.$service.sassAuth)
- .set('dict', {
- api: {
- page: 'authList',
- add: 'authAdd',
- update: 'authUpdate',
- delete: 'authDel'
- }
- })
- .set('table', {
- columns: [
- {
- prop: 'authName',
- label: '名称',
- width: 200
- },
- {
- prop: 'parentId',
- label: '父级ID',
- align: 'center',
- 'min-width': 160
- },
- {
- prop: 'frontUrl',
- label: '前端路由',
- align: 'center',
- 'min-width': 160
- },
- {
- prop: 'backUrl',
- label: '后端路由',
- align: 'center',
- 'min-width': 160
- }
- // {
- // prop: 'addTime',
- // label: '时间',
- // align: 'center',
- // sortable: true,
- // width: 180
- // }
- ],
- props: {
- 'row-key': 'id'
- },
- on: {
- 'row-click': (row, column) => {
- if (column.property && row.children) {
- app.refs('table').toggleRowExpansion(row);
- }
- },
- 'row-contextmenu': (row, column, event) => {
- let list = [
- {
- label: '编辑',
- callback: (e, close) => {
- app.edit(row);
- close();
- }
- },
- {
- label: '删除',
- callback: (e, close) => {
- app.delete(row);
- close();
- }
- }
- ];
- // if (row.type != 2) {
- // list.unshift({
- // label: '新增',
- // callback: (e, close) => {
- // this.upsertAppend(row);
- // close();
- // }
- // });
- // }
- this.$refs['context-menu'].open(event, {
- list
- });
- event.preventDefault();
- }
- },
- op: {
- props: {
- width: '200'
- },
- layout: ['slot-column-op', 'edit', 'delete']
- }
- })
- .set('upsert', {
- props: {
- width: '600px'
- },
- items: [
- {
- prop: 'parentId',
- label: '父权限',
- span: 24,
- component: {
- name: 'el-select',
- attrs: {
- placeholder: '请选择'
- },
- options: this.parentArr
- }
- // rules: {
- // required: true,
- // message: '级别不能为空'
- // }
- },
- {
- prop: 'name',
- label: '权限名',
- span: 24,
- component: {
- name: 'el-input',
- attrs: {
- placeholder: '请输入名称'
- }
- },
- rules: {
- required: true,
- message: '名称不能为空'
- }
- },
- {
- prop: 'frontUrl',
- label: '前端路由',
- span: 24,
- component: {
- name: 'el-input',
- attrs: {
- placeholder: '请输入'
- }
- },
- rules: {
- required: true,
- message: '前端路由不能为空'
- }
- },
- {
- prop: 'backUrl',
- label: '后端路由',
- span: 24,
- component: {
- name: 'el-input',
- attrs: {
- placeholder: '请输入'
- }
- }
- },
- {
- prop: 'endId',
- label: 'endId',
- span: 24,
- value: '1',
- hidden: true,
- component: {
- name: 'el-input',
- attrs: {
- placeholder: '请输入'
- }
- }
- }
- ]
- })
- .set('layout', [['refresh-btn', 'add-btn'], ['data-table']])
- .on('refresh', async (params, { next, render }) => {
- let { list } = await next(params);
- list = JSON.parse(JSON.stringify(list));
- list = list.map(e => {
- e.label = e.authName;
- e.value = e.id;
- return e;
- });
- this.crud.setData('upsert.items[prop:parentId].component.options', list);
- console.log(this.parentArr);
- })
- .done();
- app.refresh();
- },
- upsertAppend({ type, id }) {
- this.crud.append({
- parentId: id,
- type: type + 1
- });
- },
- setPermission({ id }) {
- this.crud.append({
- parentId: id,
- type: 2
- });
- },
- toUrl(url) {
- this.$router.push(url);
- }
- }
- };
- </script>
|