这里是目录! 一、初始化页面 1. 有 avue ,js 补 option 2.显隐列 二、弹窗 三、启用、禁用、删除
一、初始化页面
< template>
< basic- container> < avue- crud: table- loading= "loading" : data= "tableData" : option= "option" v- model= "form" : page. sync= "page" @row- del= "rowDel" @search- change= "searchChange" @selection- change= "selectionChange" @search- reset= "searchReset" ref= "crud" @on- load= "onLoad" @current- change= "currentChange" @size- change= "sizeChange" @refresh- change= "refreshChange" : permission= "permissionList" > < template slot= "menuLeft" > < ! -- 左菜单左上角- 新增 -- > < el- buttontype= "primary" icon= "el-icon-plus" size= "small" @click= "rowAdd" > 新 增< / el- button> < ! -- 左菜单左上角- 删除 -- > < el- buttontype= "danger" size= "small" icon= "el-icon-delete" plain@click= "handleBtn('delete')" > 删 除< / el- button> < el- buttontype= "default" size= "small" plain@click= "handleBtn('enable')" > 启 用< / el- button> < el- buttontype= "default" size= "small" plain@click= "handleBtn('disable')" > 停 用< / el- button> < / template> < ! -- 导航类型 -- > < template slot- scope= "{ row }" slot= "navigationType" > { { navigationTypeData ( row) } } < / template> < template slot- scope= "{ row }" slot= "menu" > < el- button type= "text" size= "small" @click= "rowEdit(row)" > 编辑< / el- button> < el- button type= "text" size= "small" @click= "rowDel(row)" > 删除< / el- button> < / template> < ! -- 显隐列设置 -- > < template slot= "menuRight" > < showHidden: column. sync= "option.column" moduleType= "TASK" : constData. sync= "constOptionData" > < / showHidden> < / template> < / avue- crud> < / template> < script>
import { startMapAction } from '@/views/base/map/http/request' ;
import detailForm from '@/ components/ detail- form/ index. vue';
import { getStore } from '@/utils/store' ;
import showHidden from '@/ components/ table- implicit/ index. vue';
let customConstant = [ 'code' , 'name' , 'priority' , 'isOnLoad' ,
] ;
export default {
components: { detailForm, showHidden, } , data ( ) { return { page: { pageSize: 10 , currentPage: 1 , total: 0 , } , loading: false, form: { } , query: { } , search: { } , selectionList: [ ] , constOptionData: [ ] , tableData: [ ] , addDrawer: false, editDrawer: false, } ; } , created ( ) { let column = localStorage. getItem ( this. $route. path) ; if ( column) { this. option. column = JSON. parse ( column) ; console. log ( this. option) ; } this. constOptionData = customConstant; if ( getStore ( { name: 'TASK' } ) ) { let data = getStore ( { name: 'TASK' } ) ; data. forEach ( ( item) = > { this. option. column. forEach ( ( chileItem) = > { if ( item. prop == = chileItem. prop) { chileItem. hide = item. hide; } } ) ; } ) ; } } , methods: { onLoad ( page, params = { } ) { this. loading = true; chargeStationPage ( page. currentPage, page. pageSize, Object. assign ( params, this. query) ) . then ( ( res) = > { this. page. total = res. data. total; console. log ( '列表被打印啦:' , res) ; this. tableData = res. data. records; this. loading = false; } ) ; } , searchChange ( params, done) { this. query = params; this. page. currentPage = 1 ; this. onLoad ( this. page, this. query) ; done ( ) ; } , currentChange ( currentPage) { this. page. currentPage = currentPage; } , sizeChange ( pageSize) { this. page. pageSize = pageSize; } , refreshChange ( ) { this. onLoad ( this. page, this. query) ; } , searchReset ( ) { this. query = { } ; this. search = { } ; this. onLoad ( this. page) ; } , selectionChange ( list) { this. selectionList = list; } , } ,
} ;
< / script> < style scoped> < / style>
1. 有 avue ,js 补 option
return { option: { menu: true, selection: true, tip: false, searchLabelWidth: 90 , labelWidth: 120 , menuAlign: 'center' , menuWidth: '160' , grid: false, searchMenuPosition: 'right' , searchMenuSpan: 6 , border: true, viewBtn: false, copyBtn: false, addBtn: false, editBtn: false, delBtn: false, editBtnIcon: ' ' , delBtnIcon: ' ' , updateBtnIcon: ' ' , cancelBtnIcon: ' ' , saveBtn: false, cancelBtn: false, dialogWidth: 600 , reserveSelection: true, columnBtn: false, searchBtnText: '查询' , emptyBtnText: '重置' , column: [ { label: '编号' , prop: 'code' , width: 120 , span: 20 , labelWidth: '180' , align: 'center' , row: true, hide: false, showColumn: true, search: false, disabled: true, slot: true, sortable: true, } , { label: '地图名称' , prop: 'codeOrName' , search: true, searchLabel: '地图' , searchPlaceholder: '请输入名称' , searchSpan: 6 , showColumn: true, slot: true, sortable: true, minWidth: '100' , } , { label: '名称' , prop: 'name' , width: 120 , span: 20 , labelWidth: '180' , row: true, hide: false, showColumn: true, align: 'center' , search: false, slot: true, sortable: true, } , { label: '类型' , prop: 'type' , span: 20 , labelWidth: '180' , row: true, hide: false, showColumn: true, align: 'center' , search: true, slot: true, sortable: true, type: 'select' , dicUrl: '/ api/ dict/ list? code= charge_station', props: { label: 'label' , value: 'value' , } , } , { label: '优先级' , prop: 'priority' , width: 100 , span: 20 , labelWidth: '180' , row: true, hide: false, showColumn: true, align: 'center' , search: false, slot: true, sortable: true, } , {