Commit b02fe999 by qiaoyanqi

保存。上张下张index

parent 0cd90f43
...@@ -11,14 +11,10 @@ export default { ...@@ -11,14 +11,10 @@ export default {
if (param) { if (param) {
bill.setControlsSate(param["_control_name_"], 'enable',false); bill.setControlsSate(param["_control_name_"], 'enable',false);
bill.runFormulaCheckData(param.param, function (msg) { bill.runFormulaCheckData(param.param, function (msg) {
if (msg.length == 0) { if (msg.length == 0) {//缓存数据
if (param.param && param.param.hasOwnProperty('cacheData') && !param.param.cacheData) { let obj = bill.getBuillData();
this.saveData(bill, param); obj.billDefine = param.define;
} else { this.execuFormula(obj, param);//点击确定,执行公式
let obj = bill.getBuillData();
obj.billDefine = param.define;
this.execuFormula(obj, param);//点击确定,执行公式
}
} else { } else {
GMS.$http.post(`/baseData/data/list`, { GMS.$http.post(`/baseData/data/list`, {
pagination: false, pagination: false,
...@@ -39,94 +35,6 @@ export default { ...@@ -39,94 +35,6 @@ export default {
GAMS.Common.messagePrompt('缺少参数'); GAMS.Common.messagePrompt('缺少参数');
} }
}, },
saveData(bill, param) {
let that = this;
let buidData = bill.getBuillData();
console.log('buidData:', buidData);
let controlArr = bill.action.filter(
(v) => v.execute == "searchBillAction"
);
let detailData = [];
let arrApi1 = [];
if (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/ig, "").replace(/_R/ig, "").replace(/_A/ig, "");
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/ig, "").replace(/_R/ig, "").replace(/_A/ig, "");
arrApi1.push(that.searchBillObj(billDefine, billId));
}
}
}
})
}
if (arrApi1.length > 0) {
Promise.all(arrApi1).then((list) => {
detailData = list;
that.saveAsync(buidData, detailData, param, bill);
})
} else {
that.saveAsync(buidData, detailData, param, bill);
}
},
saveAsync(buidData, detailData, param, bill) {
let postData = {
data: buidData,
detailData: detailData
}
let url = `/rbc/bill/action/saveExpenceAccount/${param.define}`;
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.$emit('saveSuccess',buidData,param);
}else{
response.data.msg && GMS.vbus.$Message.error(response.data.msg);
}
}
).catch()
},
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;
}
obj.billDefine = billDefine;
resolve(obj);
}).catch((error) => {
reject(error)
})
})
},
execuFormula(buidData, param) { execuFormula(buidData, param) {
let postData = { let postData = {
data: buidData data: buidData
......
import { getUUID } from "../query-actions/util/lib"; import errorMessageUtil from "./util/errorMessageUtil";
export default { export default {
execute: function (bill, param) { execute: function (bill, param) {
if (bill) { if (bill) {
// const masterData = bill.getMasterData() bill.runFormulaCheckData(param, (msg) => {
// // 驳回状态
// // 此时保存创建一张新单据
// if (masterData.getValue('billState') == 91) {
// ;[
// 'billCode',
// 'billState',
// 'flowFinishTime',
// 'flowProcessId',
// 'flowState',
// 'flowSubmitTime',
// 'orgCode',
// 'createTime',
// 'modifyTime',
// ].forEach((key) => {
// if (masterData.getValue(key))
// masterData.setValue(key, '')
// bill.billdata.masterFiled[key] = ''
// })
// masterData.setValue('orgId', '00000000-0000-0000-000000000000')
// masterData.setValue('recver', 0)
// masterData.setValue('id', getUUID())
// }
bill.runFormulaCheckData(param, function (msg) {
if (msg.length == 0) { if (msg.length == 0) {
let postData = { bill.setControlsSate(param["_control_name_"], "enable", false);
actions: "bill.Basic.save" 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 controlArr = bill.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));
}
} }
bill.setControlsSate(param["_control_name_"], 'enable', false) }
});
bill.executeServerAction(postData, function (code, data) { }
bill.setControlsSate(param["_control_name_"], 'enable', true) if (arrApi1.length > 0) {
console.log('code',code) Promise.all(arrApi1).then((list) => {
console.log('data',data) detailData = list;
if (code === 200) { that.saveAsync(buidData, detailData, param, bill);
const id = data.content.billData.id });
GMS.vbus.$emit('change-form-state', { state: 'readOnly', billId: id }) } else {
GMS.vbus.$Message.success("保存成功"); that.saveAsync(buidData, detailData, param, bill);
} else if (code === 201) { }
GMS.vbus.$Message.error(data.message); },
} else if (code === 202) { searchBillObj(billDefine, billId, BILLDETAILOBJ) {
if (data.responseJSON.message && data.responseJSON.message.startsWith("FLOW-")) { return new Promise((resolve, reject) => {
GMS.vbus.$Message.error({ GMS.$http.get(`/gms/bill/${billDefine}/${billId}?withSubs=true`)
content: data.responseJSON.message, .then((data) => {
duration: 3 let obj = BILLDETAILOBJ;
}); if (data.status == 200 && data.data.code == 0) {
} else { if (!BILLDETAILOBJ) {
GMS.vbus.$Message.error("保存单据异常请联系管理员"); obj = data.data.content;
}
} }
}) obj.recver = data.data.content && data.data.content.recver;
}
obj.billDefine = billDefine;
resolve(obj);
})
.catch((error) => {
reject(error);
});
});
},
saveAsync(buidData, detailData, param, bill) {
let postData = {
data: buidData,
detailData: detailData,
};
//executed/bill.CCSPD/bill.Basic.save?transmission=total
let url = `/rbc/bill/action/rbcbillsave/${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);
const id = response.data.content.billData.id;
GMS.vbus.$Message.success("保存成功");
GMS.vbus.$emit('change-form-state', { state: 'readOnly', billId: id})
GMS.vbus.$emit("saveSuccess", buidData, param);
} else { } else {
GMS.vbus.$Modal.warning({ response.data.message && GMS.vbus.$Message.error({
title: '信息错误', content: errorMessageUtil.saveAction.getErrorMessage(response.data.message),
content: msg duration: 3
}); });
} }
}) })
} .catch((error) => {});
} },
} }
\ No newline at end of file
import _ from 'lodash'
/**
* 按钮报错信息处理
*
* @author fengjiansheng
* @date 2022-02-09
*/
export default {
saveAction: {
commonMessage: "保存失败,请联系系统管理员。",
customMessageList: [
{
preMessage: "More than one row with the given identifier was found",
convertMessage: "保存失败,基础数据存在多条相同记录,基础数据标识:"
}
],
getErrorBaseDataName(a) {
if (!a || !_.isString(a)) {
return "";
}
let reg = /(?<=datamodel\.).*?(?=;)/;
let targetString = a.match(reg);
return targetString ? targetString[0] : "";
},
getErrorMessage(a) {
if (!a || !_.isString(a)) {
return this.commonMessage;
}
let errorPreMessage = "";
for (let i = 0; i < this.customMessageList.length; i++) {
if (a.indexOf(this.customMessageList[i].preMessage) > -1) {
errorPreMessage = this.customMessageList[i].convertMessage;
break;
}
}
return errorPreMessage === "" ? this.commonMessage : errorPreMessage + this.getErrorBaseDataName(a);
}
}
}
\ No newline at end of file
...@@ -144,7 +144,6 @@ export default { ...@@ -144,7 +144,6 @@ export default {
}); });
GMS.vbus.$on("saveSuccess", (res, param) => { GMS.vbus.$on("saveSuccess", (res, param) => {
//自己扩展的保存 //自己扩展的保存
GMS.vbus.$Message.success("保存成功");
this.initBill(res, param, true); this.initBill(res, param, true);
}); });
GMS.vbus.$on("resetBillData", this.changeData); GMS.vbus.$on("resetBillData", this.changeData);
......
...@@ -1185,11 +1185,6 @@ export default { ...@@ -1185,11 +1185,6 @@ export default {
"path": "单据/缓存单据数据", "path": "单据/缓存单据数据",
"extends": { "extends": {
"param": [{ "param": [{
"cacheData": true,
"type": "Boolean",
"title": "是否缓存数据",
"key": "cacheData"
}, {
"clearable": true, "clearable": true,
"ref": "gams2.bill", "ref": "gams2.bill",
"type": "select", "type": "select",
......
...@@ -4,7 +4,7 @@ export default { ...@@ -4,7 +4,7 @@ export default {
execute(context, param) { execute(context, param) {
GMS.queryObject = {//上张下张用 GMS.queryObject = {//上张下张用
currentDataQueryConditionSet: context.currentDataQueryConditionSet, currentDataQueryConditionSet: context.currentDataQueryConditionSet,
index: context.selects[0]._index, index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
templateName:param.viewName, templateName:param.viewName,
isReadOnly:false isReadOnly:false
} }
......
...@@ -8,7 +8,7 @@ export default { ...@@ -8,7 +8,7 @@ export default {
} }
GMS.queryObject = {//上张下张用 GMS.queryObject = {//上张下张用
currentDataQueryConditionSet: context.currentDataQueryConditionSet, currentDataQueryConditionSet: context.currentDataQueryConditionSet,
index: context.selects[0]._index, index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
templateName:param.viewName, templateName:param.viewName,
isReadOnly:true isReadOnly:true
} }
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
} }
GMS.queryObject = {//上张下张用 GMS.queryObject = {//上张下张用
currentDataQueryConditionSet: context.currentDataQueryConditionSet, currentDataQueryConditionSet: context.currentDataQueryConditionSet,
index: context.selects[0]._index, index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
templateName: context.selects[0][param.viewName], templateName: context.selects[0][param.viewName],
isReadOnly: true, isReadOnly: true,
} }
......
...@@ -8,7 +8,7 @@ export default { ...@@ -8,7 +8,7 @@ export default {
} }
GMS.queryObject = {//上张下张用 GMS.queryObject = {//上张下张用
currentDataQueryConditionSet: context.currentDataQueryConditionSet, currentDataQueryConditionSet: context.currentDataQueryConditionSet,
index: context.selects[0]._index, index: context.selects[0]._index||(context.selects[0]._serialIndex)*1-1,
templateName:param.viewName, templateName:param.viewName,
isReadOnly:true isReadOnly:true
} }
......
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