|
@ -1,4 +1,4 @@ |
|
|
import { initData, initData1 } from '@/api/data' |
|
|
import { initData } from '@/api/data' |
|
|
import Vue from 'vue' |
|
|
import Vue from 'vue' |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -10,8 +10,10 @@ function CRUD(options) { |
|
|
const defaultOptions = { |
|
|
const defaultOptions = { |
|
|
// 标题
|
|
|
// 标题
|
|
|
title: '', |
|
|
title: '', |
|
|
// 接口根路由
|
|
|
/** |
|
|
rootApi: 0, |
|
|
* 请求接口工具 |
|
|
|
|
|
*/ |
|
|
|
|
|
api: undefined, |
|
|
// 请求数据的url
|
|
|
// 请求数据的url
|
|
|
url: '', |
|
|
url: '', |
|
|
// 表格数据
|
|
|
// 表格数据
|
|
@ -118,23 +120,7 @@ function CRUD(options) { |
|
|
} |
|
|
} |
|
|
return new Promise((resolve) => { |
|
|
return new Promise((resolve) => { |
|
|
// 请求数据
|
|
|
// 请求数据
|
|
|
if (crud.rootApi) { |
|
|
initData(crud.api, crud.url, crud.getQueryParams()).then(data => { |
|
|
initData1(crud.url, crud.getQueryParams()).then(data => { |
|
|
|
|
|
crud.page.total = data.total |
|
|
|
|
|
if (data.list) { |
|
|
|
|
|
crud.data = data.list |
|
|
|
|
|
} else { |
|
|
|
|
|
crud.data = data |
|
|
|
|
|
} |
|
|
|
|
|
crud.resetDataStatus() |
|
|
|
|
|
// time 毫秒后显示表格
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
callVmHook(crud, CRUD.HOOK.afterRefresh) |
|
|
|
|
|
}, crud.time) |
|
|
|
|
|
resolve(data) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
initData(crud.url, crud.getQueryParams()).then(data => { |
|
|
|
|
|
crud.page.total = data.total |
|
|
crud.page.total = data.total |
|
|
if (data.list) { |
|
|
if (data.list) { |
|
|
crud.data = data.list |
|
|
crud.data = data.list |
|
@ -142,13 +128,9 @@ function CRUD(options) { |
|
|
crud.data = data |
|
|
crud.data = data |
|
|
} |
|
|
} |
|
|
crud.resetDataStatus() |
|
|
crud.resetDataStatus() |
|
|
// time 毫秒后显示表格
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
callVmHook(crud, CRUD.HOOK.afterRefresh) |
|
|
callVmHook(crud, CRUD.HOOK.afterRefresh) |
|
|
}, crud.time) |
|
|
|
|
|
resolve(data) |
|
|
resolve(data) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
@ -269,13 +251,10 @@ function CRUD(options) { |
|
|
* 执行编辑 |
|
|
* 执行编辑 |
|
|
*/ |
|
|
*/ |
|
|
doEdit() { |
|
|
doEdit() { |
|
|
console.log(581222) |
|
|
|
|
|
if (!callVmHook(crud, CRUD.HOOK.beforeSubmit)) { |
|
|
if (!callVmHook(crud, CRUD.HOOK.beforeSubmit)) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
console.log(crud.crudMethod, crud.form) |
|
|
|
|
|
crud.status.edit = CRUD.STATUS.PROCESSING |
|
|
crud.status.edit = CRUD.STATUS.PROCESSING |
|
|
|
|
|
|
|
|
crud.crudMethod.edit(crud.form).then(() => { |
|
|
crud.crudMethod.edit(crud.form).then(() => { |
|
|
crud.status.edit = CRUD.STATUS.NORMAL |
|
|
crud.status.edit = CRUD.STATUS.NORMAL |
|
|
crud.getDataStatus(crud.form.id).edit = CRUD.STATUS.NORMAL |
|
|
crud.getDataStatus(crud.form.id).edit = CRUD.STATUS.NORMAL |
|
@ -401,7 +380,6 @@ function CRUD(options) { |
|
|
*/ |
|
|
*/ |
|
|
resetDataStatus() { |
|
|
resetDataStatus() { |
|
|
const dataStatus = {} |
|
|
const dataStatus = {} |
|
|
|
|
|
|
|
|
function resetStatus(datas) { |
|
|
function resetStatus(datas) { |
|
|
datas.forEach(e => { |
|
|
datas.forEach(e => { |
|
|
dataStatus[e.id] = { |
|
|
dataStatus[e.id] = { |
|
|