优化代码

This commit is contained in:
java110 2021-08-25 12:06:38 +08:00
parent 799ab1c9fb
commit c36b14c1b5
5 changed files with 47 additions and 8 deletions

View File

@ -66,7 +66,7 @@
};
//发送get请求
vc.http.apiGet('/oaWorkflow/queryOaWorkflowFormData',
vc.http.apiGet('/oaWorkflow/queryOaWorkflowUserHisTaskFormData',
param,
function (json, res) {
var _newOaWorkflowFinishInfo = JSON.parse(json);

View File

@ -45,11 +45,47 @@
},
_initForm: function () {
const container = document.querySelector('#form');
FormViewer.createForm({
const form = FormViewer.createForm({
container,
schema: $that.newOaWorkflowFormInfo.formJson
});
console.log(form);
form.then((_from) => {
_from.on('submit', (event) => {
$that._submitFormData(event.data, event.errors);
})
})
},
_submitFormData(_data, _err) {
if (Object.keys(_err).length != 0) {
return;
}
console.log('我要的数据', _data);
_data.flowId = $that.newOaWorkflowFormInfo.flowId;
vc.http.apiPost(
'/oaWorkflow/saveOaWorkflowFormData',
JSON.stringify(_data),
{
emulateJSON: true
},
function (json, res) {
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
vc.toast('提交成功');
vc.emit('newOaWorkflow', 'switch', 'newOaWorkflowPool')
return;
}
vc.toast(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
}
}
});
})(window.vc);

View File

@ -66,7 +66,7 @@
};
//发送get请求
vc.http.apiGet('/oaWorkflow/queryOaWorkflowFormData',
vc.http.apiGet('/oaWorkflow/queryOaWorkflowUserTaskFormData',
param,
function (json, res) {
var _newOaWorkflowUndoInfo = JSON.parse(json);

View File

@ -1126,23 +1126,23 @@
}
if (validate.required && (typeof value === 'undefined' || value === '')) {
errors = [...errors, 'Field is required.'];
errors = [...errors, '此项必填.'];
}
if ('min' in validate && value && value < validate.min) {
errors = [...errors, `Field must have minimum value of ${validate.min}.`];
errors = [...errors, `此项值不得小于 ${validate.min}.`];
}
if ('max' in validate && value && value > validate.max) {
errors = [...errors, `Field must have maximum value of ${validate.max}.`];
errors = [...errors, `此项值不得大于 ${validate.max}.`];
}
if ('minLength' in validate && value && value.trim().length < validate.minLength) {
errors = [...errors, `Field must have minimum length of ${validate.minLength}.`];
errors = [...errors, `此项字数不得少于 ${validate.minLength}.`];
}
if ('maxLength' in validate && value && value.trim().length > validate.maxLength) {
errors = [...errors, `Field must have maximum length of ${validate.maxLength}.`];
errors = [...errors, `此项字数不得大于 ${validate.maxLength}.`];
}
return errors;

View File

@ -17,6 +17,9 @@
vc.on('newOaWorkflow', 'listNewOaWorkflow', function (_param) {
vc.component._listNewOaWorkflows(DEFAULT_PAGE, DEFAULT_ROWS);
});
vc.on('newOaWorkflow','switch',function(_switchValue){
$that.swatch(_switchValue);
})
},
methods: {
swatch: function (_value) {