Commit 87c689f0 by 潘际乾

请求参数model提取至公共函数

parent c80b23ef
......@@ -13,25 +13,25 @@ export default {
return Api.post(this.declareParams.trnName+"/init",{params})
},
save(params){
return Api.post(this.declareParams.trnName+"/saveData", Utils.getRequestDataFn.call(this, params))
return Api.post(this.declareParams.trnName+"/saveData", this.wrapper(params))
},
exeuteCheck(rulePath,params){
return Api.post(this.declareParams.trnName+"/executeCheck/"+rulePath, Utils.getRequestDataFn.call(this, params))
return Api.post(this.declareParams.trnName+"/executeCheck/"+rulePath, this.wrapper(params))
},
executeDefault(rulePath,params)
{
return Api.post(this.declareParams.trnName+"/executeDefault/"+rulePath, Utils.getRequestDataFn.call(this, params))
return Api.post(this.declareParams.trnName+"/executeDefault/"+rulePath, this.wrapper(params))
},
executeRule(rulePath,params)
{
return Api.post(this.declareParams.trnName+"/executeRule/"+rulePath, Utils.getRequestDataFn.call(this, params))
return Api.post(this.declareParams.trnName+"/executeRule/"+rulePath, this.wrapper(params))
},
async checkAll(params){
const res = await Api.post(this.declareParams.trnName+"/checkAll", Utils.getRequestDataFn.call(this, params))
const res = await Api.post(this.declareParams.trnName+"/checkAll", this.wrapper(params))
return res
},
pedding(params){
return Api.post(this.declareParams.trnName+"/pending", Utils.getRequestDataFn.call(this, params))
return Api.post(this.declareParams.trnName+"/pending", this.wrapper(params))
},
async restoreDisplay()
{
......@@ -43,7 +43,7 @@ export default {
},
executeNotify(params)
{
return Api.post(this.declareParams.trnName+"/executeNotify", Utils.getRequestDataFn.call(this, params))
return Api.post(this.declareParams.trnName+"/executeNotify", this.wrapper(params))
},
}
}
\ No newline at end of file
......@@ -97,6 +97,26 @@ export default {
return "blur";
},
/**
* 以函数形式获取model(请求参数),保证取到的是最新赋值的
* @param {any} params 参数
* @returns
*/
wrapper(params) {
params = params || {}
const fn = async () => {
const that = this;
const data = await new Promise(resolve => {
// 保证前一次请求结果赋值VO完成
setTimeout(() => {
const d = Utils.flatObject(that.model)
resolve(d)
}, 0)
})
return {...data, params}
}
return fn;
},
/**
* 更新Model
* @param {any} data model数据
*/
......
......@@ -268,21 +268,21 @@ export default {
})
},
async BlurBennam(e) {
let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", Utils.getRequestDataFn.call(this))
let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", this.wrapper())
if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑
this.model.litp1.remark = rtnmsg.data.litp1_remark
}
},
async BlurAplname(e) {
let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", Utils.getRequestDataFn.call(this))
let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", this.wrapper())
if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑
this.model.litp1.remark = rtnmsg.data.litp1_remark
}
},
async BlurSignam(e) {
let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", Utils.getRequestDataFn.call(this))
let rtnmsg = await Api.post("ditopn/executeDefault/litp1.remark", this.wrapper())
if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑
this.model.litp1.remark = rtnmsg.data.litp1_remark
......@@ -297,14 +297,14 @@ export default {
let rtnmsg
if (cortyp == 'SWT'|| cortyp == 'FMT' || cortyp == 'CMT') {
this.model.setmod.msgmod.doccod = row.id
rtnmsg = await Api.post('cptopn/msgmod_butshw', { data: Utils.getRequestDataFn.call(this) })
rtnmsg = await Api.post('cptopn/msgmod_butshw', { data: this.wrapper() })
} else {
this.model.trnmod.trndoc.doccod = row.id
this.model.trnmod.trndoc.cortyp = cortyp
const params = {
index: index
}
rtnmsg = await Api.post("ditopn/executeDocpan", Utils.getRequestDataFn.call(this, params))
rtnmsg = await Api.post("ditopn/executeDocpan", this.wrapper(params))
}
if (rtnmsg.respCode == "AAAAAA") {
if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') {
......@@ -359,7 +359,7 @@ export default {
const params = {
index: index
}
let rtnmsg = await Api.post("ditopn/executeDocpanDetail", { ...Utils.getRequestDataFn.call(this), params })
let rtnmsg = await Api.post("ditopn/executeDocpanDetail", { ...this.wrapper(), params })
if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑
console.log("11111111111111111111111111111")
......
......@@ -142,22 +142,6 @@ export default class Utils {
return output.join('');
}
static getRequestDataFn(params) {
params = params||{}
const fn = async () => {
const that = this;
const data = await new Promise(resolve => {
// 保证前一次请求结果赋值VO完成
setTimeout(() => {
const d = Utils.flatObject(that.model)
resolve(d)
}, 0)
})
return {...data, params}
}
return fn;
}
static positioningErrorMsg(fieldErrors, formFields) {
let firstErrorItem = null
for (let i = 0; i < formFields.length; i++) {
......
......@@ -369,15 +369,13 @@ export default {
this.centerDialogVisible = false;
console.log(this.model);
this.model.trnmod.trndoc.doceot.splice(this.index, 1, this.dialog);
let res = Api.post(
"ditopn/executeRule/trnmod.trndoc.doccur.butaddok",
Utils.getRequestDataFn.call(this)
);
if (res.data.respCode == "AAAAAA") {
//TODO
} else {
this.$notify.error({ title: "错误", message: "服务请求失败!" });
}
this.executeRule("trnmod.trndoc.doccur.butaddok").then(res => {
if (res.data.respCode == "AAAAAA") {
//TODO
} else {
this.$notify.error({ title: "错误", message: "服务请求失败!" });
}
})
},
},
created: function () {},
......
......@@ -520,10 +520,7 @@ export default {
},
nom1CurEvent() {
const data = Utils.flatObject(this.model);
Api.post(
"ditopn/executeDefault/didgrp.cbs.nom1.cur",
Utils.getRequestDataFn.call(this)
).then((res) => {
this.executeDefault("didgrp.cbs.nom1.cur").then((res) => {
if ((res.respCode = "AAAAAA")) {
Utils.copyValueFromVO(this.model, res.data);
}
......
......@@ -399,6 +399,7 @@
</template>
<script>
import Api from "~/service/Api";
import Utils from "~/utils";
import CommonProcess from "~/mixin/CommonProcess";
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Ditopn/Event";
......@@ -426,6 +427,29 @@ export default {
// this.visiable = false;
// this.model.setmod.setfog.setfop[this.index] = this.dialog;
},
// 第二个表格
detail1(index, row) {
this.executeDefault("det").then(res=>{
this.dialogVisible = true;
this.dialog = row;
this.index = index;
})
},
dispDefault(){
this.executeDefault("ditopn/executeDefault/mac").then(res=>{
Utils.copyValueFromVO(this.model, res.data)
})
},
// 第三个表格
detail2(index, row) {
this.executeRule("ditopn/executeRule/det").then(res=>{
this.dialogVisible2 = true;
this.index = index;
this.dialog2 = row
})
},
},
created: function () {},
};
......
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