Commit 5aa422f0 by qiaoyanqi

上海报销save

parent 9f16c271
/**
* 只用于上海报销单的保存
* 与正常财务保存(CW_saveAction)不同的是,此保存(saveAction_SH_BXD)扩展了保存成功后,
* 跳转详情界面或者审核界面的逻辑
* @author qiaoyanqi
* @date 2022-06-02
*/
import errorMessageUtil from "./util/errorMessageUtil";
export default {
execute: function (bill, param) {
if (bill) {
bill.runFormulaCheckData(param, (msg) => {
if (msg.length == 0) {
bill.setControlsSate(param["_control_name_"], "enable", false);
this.saveData(bill, param);
} else {
GMS.vbus.$Modal.warning({
title: "信息错误",
content: msg,
});
}
});
}
},
saveData(bill, param) {
let that = this;
let buidData = bill.getBuillData();
console.log("buidData:", buidData);
let action = bill.curForm.content.actions;
let controlArr = action.filter((v) => v.execute == "searchBillAction");
let detailData = [];
let arrApi1 = [];
if (
controlArr.length > 0 &&
controlArr[0].param.field &&
controlArr[0].param.field.length > 0
) {
let tableList = controlArr[0].param.field.map((v) => v.targetTableName);
tableList = Array.from(new Set(tableList));
tableList.forEach((v) => {
if (buidData.hasOwnProperty(v)) {
for (let i = 0; i < bill.getSubData(v).length; i++) {
let rowDataObject = bill.getSubDataRow(v, i);
let obj = rowDataObject.getValue("currentRowData");
if (obj && obj.BILLDETAILOBJ) {
let billId = obj.BILLID;
let billName = obj.BILLNAME;
let billDefine = billName
.replace(/_E/gi, "")
.replace(/_R/gi, "")
.replace(/_A/gi, "");
arrApi1.push(
that.searchBillObj(billDefine, billId, obj.BILLDETAILOBJ)
);
} else {
let billId = rowDataObject.getData().BILLID.value;
let billName = rowDataObject.getData().BILLNAME.value;
let billDefine = billName
.replace(/_E/gi, "")
.replace(/_R/gi, "")
.replace(/_A/gi, "");
arrApi1.push(that.searchBillObj(billDefine, billId));
}
}
}
});
}
if (arrApi1.length > 0) {
Promise.all(arrApi1).then((list) => {
detailData = list;
that.saveAsync(buidData, detailData, param, bill);
}).catch(error=>{
console.log(error);
});
} else {
that.saveAsync(buidData, detailData, param, bill);
}
},
searchBillObj(billDefine, billId, BILLDETAILOBJ) {
return new Promise((resolve, reject) => {
GMS.$http.get(`/gms/bill/${billDefine}/${billId}?withSubs=true`)
.then((data) => {
let obj = BILLDETAILOBJ;
if (data.status == 200 && data.data.code == 0) {
if (!BILLDETAILOBJ) {
obj = data.data.content;
}
obj.recver = data.data.content && data.data.content.recver;
}
if(billDefine){
obj.billDefine = billDefine;
}
resolve(obj);
})
.catch((error) => {
reject(error);
});
});
},
saveAsync(buidData, detailData, param, bill) {
let postData = {
data: buidData,
detailData: detailData,
};
let url = `/rbc/bill/action/executed/${param.define}/bill.Basic.save?transmission=total`;
GMS.$http
.post(url, JSON.stringify(postData), {
headers: {
post: {
"Content-Type": "application/json",
},
},
})
.then(function (response) {
bill.setControlsSate(param["_control_name_"], "enable", true);
if (response.data.code == 0) {
//存储返回回来的创建时间、修改时间
bill.getMasterData().setValue("createTime", response.data.content.billData.createTime);
bill.getMasterData().setValue("modifyTime", response.data.content.billData.modifyTime);
bill.getMasterData().setValue("recver", response.data.content.billData.recver);
bill.getMasterData().setValue("billCode", response.data.content.billData.billCode);
GMS.vbus.$Message.success("保存成功");
GMS.vbus.$emit("saveEcho", buidData, param);
} else {
response.data.message && GMS.vbus.$Message.error({
content: errorMessageUtil.saveAction.getErrorMessage(response.data.message),
duration: 3
});
}
})
.catch((error) => {
console.log(error)
bill.setControlsSate(param["_control_name_"], "enable", true);
GMS.vbus.$Message.error({
content: errorMessageUtil.saveAction.getCommonMessage(),
duration: 3
});
});
},
}
......@@ -2088,6 +2088,28 @@ export default {
},
{
"discard": false,
"path": "上海报销/专用",
"extends": {
"param": [
{
"ref": "bill",
"type": "metaData",
"title": "编辑成功跳转页面",
"key": "viewName"
}, {
"ref": "bill",
"type": "metaData",
"title": "审核成功跳转页面",
"key": "approveViewName"
}
]
},
"description": "",
"title": "上海报销_保存[saveAction_SH_BXD]",
"value": "saveAction_SH_BXD"
},
{
"discard": false,
"path": "报销/通用",
"extends": {
"param": [
......
......@@ -46,6 +46,7 @@ import GH_agreeAction from './actions/labourUnion/gh_agreeAction.js';
import GH_rejectAction from './actions/labourUnion/gh_rejectAction.js';
import GH_submitAction from './actions/labourUnion/gh_submitAction.js';
import GH_retrieveAction from './actions/labourUnion/gh_retrieveAction.js';
import saveAction_SH_BXD from './actions/saveAction_SH_BXD.js';
//queryAction
import leafletGenerationAction from './query-actions/leafletGenerationAction.js'
......@@ -277,7 +278,8 @@ export default {
GH_rejectAction,
GH_submitAction,
GH_retrieveAction,
DEQKD_batchEditorAction
DEQKD_batchEditorAction,
saveAction_SH_BXD
},
billControl: {
applyDetail,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment