提交 4716008b authored 作者: 徐立's avatar 徐立

新增model层

上级 76b10528
import { apiRequest } from '../utils/request';
const api = '/DataObjApi';
import {Base16Encode} from "../Base16/index"
import baseX from 'base-x'
var BASE16 = '0123456789abcdef'
var bs16 = baseX(BASE16)
export default {
namespace: 'DataObj',
state: {
list: [],
data: {
list: [],
pagination: {},
},
code: {
list: [],
pagination: {},
},
},
effects: {
*importAnalyse({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/importAnalyse', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*importDataQuery({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/importDataQuery', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*importExecute({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/importExecute', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getAll({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api+'/getAll', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*getStatistics({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getStatistics', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getExportInfo({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getExportInfo', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*changeCatalogue({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/changeCatalogue', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*findByCode({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/findByCode', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*findByName({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/findByName', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*find({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/find', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*add({ payload, callback }, { call, put }) {
if(payload.sqlScript){
payload.sqlScript=Base16Encode(payload.sqlScript)
}
const response = yield call(apiRequest, api + '/add', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*fetch({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getPage', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'page',
payload: { ...response, isMain: payload.isMain },
});
},
*getTableList({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getTableList', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*createTableByName({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/createTableByName', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*remove({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/remove', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) {
callback();
}
},
*open({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/open', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) {
callback();
}
},
*createTabel({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/createTable', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'nom',
payload: response,
});
if (callback) {
callback();
}
},
},
reducers: {
list(state, action) {
return {
...state,
list: action.payload,
};
},
page(state, { payload }) {
if (payload.isMain) {
return {
...state,
data: {
list: payload.rows,
pagination: {
current: payload.pageNo,
pageSize: payload.pageSize,
total: payload.total,
},
},
};
} else {
return {
...state,
code: {
list: payload.rows,
pagination: {
current: payload.pageNo,
pageSize: payload.pageSize,
total: payload.total,
},
},
};
}
},
nom(state, action) {
return { ...state };
},
},
};
import {apiRequest} from "../utils/request";
import {Base16Encode} from "../Base16/index"
import baseX from 'base-x'
var BASE16 = '0123456789abcdef'
var bs16 = baseX(BASE16)
const api="/DataRightApi"
export default {
namespace: 'DataRight',
state: {
list: [],
},
effects: {
*clear({ payload, callback }, { call, put }) {
yield put({
type: 'list',
payload: [],
});
if (callback) callback();
},
*add({ payload, callback }, { call, put }) {
if(payload.filterSql){
payload.filterSql=Base16Encode(payload.filterSql)
}
const response = yield call(apiRequest,api+"/add" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*addBatch({ payload, callback }, { call, put }) {
if(payload.filterSql){
payload.filterSql=Base16Encode(payload.filterSql)
}
const response = yield call(apiRequest,api+"/addBatch" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getUserRight({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getUserRight" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getUserColumnRight({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getUserColumnRight" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*fetch({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getList" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'list',
payload: {list:response,isReference:payload.isReference},
});
if(callback)callback(response)
},*remove({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/remove" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
},
*open({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/open" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
},
*addReference({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/addReference" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
},
},
reducers: {
list(state, action) {
if(action.payload.isReference){
return {
...state,
refs: action.payload.list,
};
}else{
return {
...state,
list: action.payload.list,
};
}
},
page(state, { payload }) {
return {
...state,
data:{
list: payload.rows,
pagination: {
current:payload.pageNo,
pageSize:payload.pageSize,
total:payload.total,
},
}
};
},
nom(state, action) {
return {...state };
},
},
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论