@aliedu/app-self-check
Version:
应用自检模块
142 lines (129 loc) • 4.9 kB
JavaScript
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
export default {
state: {
fileTitle: '点击右侧按钮上传',
errMessage: '',
isClickUpload: false,
fileInfo: {}
},
reducers: {
initDefaultState: function initDefaultState(prevState) {
prevState.fileTitle = '点击右侧按钮上传';
prevState.errMessage = '';
prevState.isClickUpload = false;
prevState.fileInfo = {};
},
getFileTitle: function getFileTitle(prevState, payLoad) {
prevState.fileTitle = payLoad;
prevState.isClickUpload = true;
},
getErrMessage: function getErrMessage(prevState, payLoad) {
prevState.errMessage = payLoad;
},
deletFile: function deletFile(prevState) {
prevState.isClickUpload = false;
prevState.fileTitle = '点击右侧按钮上传';
prevState.errMessage = '';
prevState.fileInfo = {};
},
setFileInfo: function setFileInfo(prevState, payLoad) {
prevState.fileInfo = payLoad;
}
},
effects: function effects(dispatch) {
return {
downloadFile: function downloadFile() {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
window.location.href = 'https://cube-prod.oss-cn-hangzhou.aliyuncs.com/%E5%AE%89%E5%85%A8%E6%B5%8B%E8%AF%95%E6%8A%A5%E5%91%8A-%E6%A8%A1%E6%9D%BF.doc';
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
successUpload: function successUpload(payLoad) {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return dispatch.StepThreeModel.getFileTitle(payLoad.name);
case 2:
_context2.next = 4;
return dispatch.StepThreeModel.setFileInfo(payLoad.response.data);
case 4:
_context2.next = 6;
return dispatch.StepThreeModel.getErrMessage('');
case 6:
dispatch.BtnOperaModel.changeNextStatu();
case 7:
case "end":
return _context2.stop();
}
}
}, _callee2);
}))();
},
commitSafeCheck: function commitSafeCheck(payLoad, stateData) {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
var res;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return API.application.appSelfCheck.commitSafeCheck.request({}, {
appCode: stateData.IndexModel.appCode,
safeReportFileDTO: stateData.StepThreeModel.fileInfo
});
case 2:
res = _context3.sent;
if (res.success) {
_context3.next = 5;
break;
}
return _context3.abrupt("return");
case 5:
return _context3.abrupt("return", res);
case 6:
case "end":
return _context3.stop();
}
}
}, _callee3);
}))();
},
errorUpload: function errorUpload(payLoad) {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
console.log(JSON.stringify(payLoad), '失败回调');
_context4.next = 3;
return dispatch.StepThreeModel.getFileTitle(payLoad.name);
case 3:
_context4.next = 5;
return dispatch.StepThreeModel.getErrMessage(payLoad.response.errMessage);
case 5:
_context4.next = 7;
return dispatch.BtnOperaModel.nextStatuFalse();
case 7:
case "end":
return _context4.stop();
}
}
}, _callee4);
}))();
}
};
}
};