一、api.js
import { request } from '@/api/service'
const apiPrefix = '接口地址'
export function GetList (query) {
return request({
url: apiPrefix + '/list',
method: 'get',
params: query
}).then(ret => {
ret.data = ret.data ? ret.data : {}
ret.data.current = ret.result.current
ret.data.size = ret.result.size
ret.data.total = ret.result.total
ret.data.records = ret.result.records
return ret
})
}
export function AddObj (obj) {
return request({
url: apiPrefix + '/add',
method: 'post',
data: obj
})
}
export function UpdateObj (obj) {
console.log(obj)
return request({
url: apiPrefix + '/edit',
method: 'put',
data: obj
})
}
export function DelObj (id) {
return request({
url: apiPrefix + '/delete',
method: 'delete',
params: { id }
})
}
export function GetObj (id) {
return request({
url: apiPrefix + '/queryById',
method: 'get',
params: { id }
})
}
export function BatchDel (ids) {
return request({
url: apiPrefix +'/deleteBatch',
method: 'delete',
data: { ids }
})
}
二、crud.js
import { request } from '@/api/service'
export const crudOptions = (vm) => {
return {
rowHandle: {
width: 230,
edit: {show:true,text: '编辑'},
view: {show:true,text: '查看'},
remove: {show:true,text: '删除'}
},
options:{
height: '100%'
},
columns: [
{
title: '基本标识',
key: 'id',
width: 50,
sortable: false,
show:true,
type: 'int',
form: {
disabled: true