Commit e7f6f9de by qiaoyanqi

复制单据加忽略字段

parent d5d8caf5
...@@ -6,14 +6,23 @@ export default { ...@@ -6,14 +6,23 @@ export default {
let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) { let name = GMS.$hideContainer.addComponent(addInfoModal, {}, function (c) {
component = c; component = c;
c.bill = bill; c.bill = bill;
c.selectBill = bill.curForm.name; if(!param.param.viewName){
GAMS.Common.messagePrompt('请在设计期配置复制的模板名称。');
}
c.selectBill = param.param.viewName;
let obj = bill.getBuillData(param.param); let obj = bill.getBuillData(param.param);
if (obj.id) { if (obj.id) {
c.billId = obj.id; c.billId = obj.id;
//添加忽略字段,如果出现有引用关系的字段,需要置为空,不然会出问题
let ignoreTempFields = 'id,billCode,billState,flowState,BILLSTATEAUDIT,SHLLDEFINE,SHLLID,SQDH,';
if ('ignoreFields' in param.param && param.param.ignoreFields.length > 0) {
ignoreTempFields += param.param.ignoreFields
}
c.ignoreFields = ignoreTempFields.split(',');
c.modal_visible = true;
setTimeout(() => { setTimeout(() => {
c.getNewBillId(); c.getNewBillId();
}, 1000) }, 1000)
c.modal_visible = true;
} else { } else {
GAMS.Common.messagePrompt('请在单据中录入数据'); GAMS.Common.messagePrompt('请在单据中录入数据');
} }
......
...@@ -64,6 +64,7 @@ export default { ...@@ -64,6 +64,7 @@ export default {
bill: null, bill: null,
data: {}, data: {},
selectBill: "", selectBill: "",
ignoreFields:[],
}; };
}, },
created() {}, created() {},
...@@ -71,7 +72,8 @@ export default { ...@@ -71,7 +72,8 @@ export default {
props: {}, props: {},
methods: { methods: {
getNewBillId() { getNewBillId() {
let billdefine=this.bill.curForm.content.billdefine; let that = this;
let billdefine= this.bill.curForm.content.billdefine;
GAMS.Util.invokeServer({ GAMS.Util.invokeServer({
path: "/gms/bill/newed/" + billdefine, path: "/gms/bill/newed/" + billdefine,
type: "GET", type: "GET",
...@@ -79,15 +81,30 @@ export default { ...@@ -79,15 +81,30 @@ export default {
}) })
.then( .then(
function (data, textStatus, response) { function (data, textStatus, response) {
this.$refs.copyRefs.context.bill.getMasterData().setValue('id', data.content.id ? data.content.id : GAMS.Util.newId()); that.$nextTick(() => {
this.$refs.copyRefs.context.bill.getMasterData().setValue("billCode",data.content.billCode); //需要考虑其他忽略的字段
let tableObj = this.$refs.copyRefs.context.bill.getAllSubData(); //处理主表忽略字段置为空 id取一个新值
for(let i in tableObj){ that.$refs.copyRefs.context.bill.getMasterData().setValue('id', data.content.id ? data.content.id : GAMS.Util.newId());
tableObj[i].forEach(element => { that.$refs.copyRefs.context.bill.getMasterData().setValue("billCode",data.content.billCode);
element.setValue('id', ''); that.ignoreFields.forEach(v=> {
}); if(v && (v!='id'||v!='billCode')){
} that.$refs.copyRefs.context.bill.getMasterData().setValue(v,null);
console.log(tableObj); }
})
//处理子表忽略字段置为空
let tableObj = that.$refs.copyRefs.context.bill.getAllSubData();
if(tableObj){
for(let i in tableObj){
tableObj[i].forEach(element => {
that.ignoreFields.forEach(v=> {
if(v){
element.setValue(v, null);
}
})
});
}
}
})
}.bind(this) }.bind(this)
) )
.catch((XMLHttpRequest, textStatus, errorThrown) => {}); .catch((XMLHttpRequest, textStatus, errorThrown) => {});
......
...@@ -1125,16 +1125,10 @@ export default { ...@@ -1125,16 +1125,10 @@ export default {
"param": [ "param": [
{ {
"isRequired": false, "isRequired": false,
"type": "Boolean",
"title": "启用自动忽略字段",
"key": "isAutoIgnoreField"
},
{
"isRequired": false,
"title": "自定义忽略字段", "title": "自定义忽略字段",
"key": "ignoreFields", "key": "ignoreFields",
"type": "String", "type": "String",
}, }
] ]
}, },
"description": "", "description": "",
...@@ -1167,7 +1161,20 @@ export default { ...@@ -1167,7 +1161,20 @@ export default {
"discard": false, "discard": false,
"path": "单据/复制单据", "path": "单据/复制单据",
"extends": { "extends": {
"param": [] "param": [
{
"isRequired": false,
"title": "自定义忽略字段",
"key": "ignoreFields",
"type": "String",
},
{
"ref": "bill",
"type": "metaData",
"title": "选择复制单据",
"key": "viewName"
}
]
}, },
"description": "", "description": "",
"title": "复制单据[copyBillAction]", "title": "复制单据[copyBillAction]",
......
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