提交 a365a295 authored 作者: 徐立's avatar 徐立

添加model层

上级 71f9c6df
import {apiRequest} from "@/utils/request";
import {Base16Encode} from "@/components/Base16/index"
import baseX from 'base-x'
var BASE16 = '0123456789abcdef'
var bs16 = baseX(BASE16)
const api="/DataColumnApi"
export default {
namespace: 'DataColumn',
state: {
list: [],
refs: [],
},
effects: {
*clear({ payload, callback }, { call, put }) {
yield put({
type: 'list',
payload: [],
});
if (callback) callback();
},
*autoCreate({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/autoCreate" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getBatchOptions({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getBatchOptions" ,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+"/getList" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},*getOptions({ payload, callback }, { call, put }) {
if(payload.filterSql){
payload.filterSql=Base16Encode(payload.filterSql)
}
const response = yield call(apiRequest,api+"/getOptions" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getLabels({ payload, callback }, { call, put }) {
if(payload.allValues){
payload.allValues=Base16Encode(payload.allValues)
}
const response = yield call(apiRequest,api+"/getLabels" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getSqlOptions({ payload, callback }, { call, put }) {
if(payload.allValues){
payload.allValues=Base16Encode(payload.allValues)
}
const response = yield call(apiRequest,api+"/getSqlOptions" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getSqlLabels({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/getSqlLabels" ,payload);
if(payload.allValues){
payload.allValues=Base16Encode(payload.allValues)
}
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*getSqlData({ payload, callback }, { call, put }) {
if(payload.sqlKey){
payload.sqlKey=Base16Encode(payload.sqlKey)
}
if(payload.allValues){
payload.allValues=Base16Encode(payload.allValues)
}
const response = yield call(apiRequest,api+"/getSqlData" ,payload);
if(!response){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*add({ payload, callback }, { call, put }) {
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+"/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()
}
},*deleteReference({ payload, callback }, { call, put }) {
const response = yield call(apiRequest,api+"/deleteReference" ,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 };
},
},
};
import { apiRequest } from '@/utils/request';
const api = '/DataObjApi';
export default {
namespace: 'formList',
state: {
list: [],
data: {
list: [],
pagination: {},
},
},
effects: {
*clear({ payload, callback }, { call, put }) {
yield put({
type: 'clearAll',
payload: {},
});
},
*getHead({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, '/DataColumnApi/getHeaderList', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*getAppId({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, '/UnifiedAppFormApi/getDetailByCode', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*getBatchOptions({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, '/DataColumnApi/getBatchOptions', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*getGroupList({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, '/DataColumnApi/getGroupList', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*getObjDetail({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, '/DataObjApi/getDetail', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*fetch({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getFormDataPage', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
yield put({
type: 'page',
payload: response,
});
if(callback){callback({
list: response.rows,
pagination: {
current: response.pageNo,
pageSize: response.pageSize,
total: response.total,
},
})}
},
*add({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/addFormData', {
data: JSON.stringify(payload.params),
isAdd: payload.isAdd,
objId: payload.objId,
});
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*delete({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/deleteFormData', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
*getDetail({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api + '/getFormData', payload);
if (!response) {
yield put({ type: 'nom' });
return;
}
if (callback) callback(response);
},
},
reducers: {
clearAll(state, action) {
return {
...state,
data: {
list: [],
pagination: {},
},
};
},
list(state, action) {
return {
...state,
list: action.payload,
};
},
page(state, { payload }) {
return {
...state,
data: {
list: payload.rows,
pagination: {
current: payload.pageNo,
pageSize: payload.pageSize,
total: payload.total,
},
},
};
},
nom(state, action) {
return { ...state };
},
},
};
import {apiRequest} from "@/utils/request";
const api="/SqlManageEntityApi"
export default {
namespace: 'SqlManageEntity',
state: {
data: {
list: [],
pagination: {},
},
},
effects: {
*find({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api+"/find",payload);
if (response==null){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback(response);
},
*add({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api+"/add",payload);
if (response==null){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if (callback) callback({suc:true});
},
*fetch({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api+"/getPage",payload);
if (response==null){yield put({type: 'nom'});return }
yield put({
type: 'list',
payload: response,
});
},*remove({ payload, callback }, { call, put }) {
const response = yield call(apiRequest, api+"/remove",payload);
if (response==null){yield put({type: 'nom'});return }
yield put({
type: 'nom',
payload: response,
});
if(callback){
callback()
}
},
},
reducers: {
list(state, { payload }) {
return {
...state,
data:{
list: payload.rows,
pagination: {
current:payload.pageNo,
pageSize:payload.pageSize,
total:payload.total,
},
}
};
},
nom(state, action) {
return {...state, status: "ok" };
},
},
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论