Commit 87c689f0 by 潘际乾

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

parent c80b23ef
...@@ -13,25 +13,25 @@ export default { ...@@ -13,25 +13,25 @@ export default {
return Api.post(this.declareParams.trnName+"/init",{params}) return Api.post(this.declareParams.trnName+"/init",{params})
}, },
save(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){ 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) 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) 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){ 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 return res
}, },
pedding(params){ 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() async restoreDisplay()
{ {
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
}, },
executeNotify(params) 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 { ...@@ -97,6 +97,26 @@ export default {
return "blur"; 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 * 更新Model
* @param {any} data model数据 * @param {any} data model数据
*/ */
......
...@@ -268,21 +268,21 @@ export default { ...@@ -268,21 +268,21 @@ export default {
}) })
}, },
async BlurBennam(e) { 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") { if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑 //TODO 处理数据逻辑
this.model.litp1.remark = rtnmsg.data.litp1_remark this.model.litp1.remark = rtnmsg.data.litp1_remark
} }
}, },
async BlurAplname(e) { 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") { if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑 //TODO 处理数据逻辑
this.model.litp1.remark = rtnmsg.data.litp1_remark this.model.litp1.remark = rtnmsg.data.litp1_remark
} }
}, },
async BlurSignam(e) { 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") { if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑 //TODO 处理数据逻辑
this.model.litp1.remark = rtnmsg.data.litp1_remark this.model.litp1.remark = rtnmsg.data.litp1_remark
...@@ -297,14 +297,14 @@ export default { ...@@ -297,14 +297,14 @@ export default {
let rtnmsg let rtnmsg
if (cortyp == 'SWT'|| cortyp == 'FMT' || cortyp == 'CMT') { if (cortyp == 'SWT'|| cortyp == 'FMT' || cortyp == 'CMT') {
this.model.setmod.msgmod.doccod = row.id 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 { } else {
this.model.trnmod.trndoc.doccod = row.id this.model.trnmod.trndoc.doccod = row.id
this.model.trnmod.trndoc.cortyp = cortyp this.model.trnmod.trndoc.cortyp = cortyp
const params = { const params = {
index: index 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 (rtnmsg.respCode == "AAAAAA") {
if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') { if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') {
...@@ -359,7 +359,7 @@ export default { ...@@ -359,7 +359,7 @@ export default {
const params = { const params = {
index: index 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") { if (rtnmsg.respCode == "AAAAAA") {
//TODO 处理数据逻辑 //TODO 处理数据逻辑
console.log("11111111111111111111111111111") console.log("11111111111111111111111111111")
......
...@@ -142,22 +142,6 @@ export default class Utils { ...@@ -142,22 +142,6 @@ export default class Utils {
return output.join(''); 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) { static positioningErrorMsg(fieldErrors, formFields) {
let firstErrorItem = null let firstErrorItem = null
for (let i = 0; i < formFields.length; i++) { for (let i = 0; i < formFields.length; i++) {
......
...@@ -369,15 +369,13 @@ export default { ...@@ -369,15 +369,13 @@ export default {
this.centerDialogVisible = false; this.centerDialogVisible = false;
console.log(this.model); console.log(this.model);
this.model.trnmod.trndoc.doceot.splice(this.index, 1, this.dialog); this.model.trnmod.trndoc.doceot.splice(this.index, 1, this.dialog);
let res = Api.post( this.executeRule("trnmod.trndoc.doccur.butaddok").then(res => {
"ditopn/executeRule/trnmod.trndoc.doccur.butaddok", if (res.data.respCode == "AAAAAA") {
Utils.getRequestDataFn.call(this) //TODO
); } else {
if (res.data.respCode == "AAAAAA") { this.$notify.error({ title: "错误", message: "服务请求失败!" });
//TODO }
} else { })
this.$notify.error({ title: "错误", message: "服务请求失败!" });
}
}, },
}, },
created: function () {}, created: function () {},
......
...@@ -520,10 +520,7 @@ export default { ...@@ -520,10 +520,7 @@ export default {
}, },
nom1CurEvent() { nom1CurEvent() {
const data = Utils.flatObject(this.model); const data = Utils.flatObject(this.model);
Api.post( this.executeDefault("didgrp.cbs.nom1.cur").then((res) => {
"ditopn/executeDefault/didgrp.cbs.nom1.cur",
Utils.getRequestDataFn.call(this)
).then((res) => {
if ((res.respCode = "AAAAAA")) { if ((res.respCode = "AAAAAA")) {
Utils.copyValueFromVO(this.model, res.data); Utils.copyValueFromVO(this.model, res.data);
} }
......
...@@ -399,6 +399,7 @@ ...@@ -399,6 +399,7 @@
</template> </template>
<script> <script>
import Api from "~/service/Api"; import Api from "~/service/Api";
import Utils from "~/utils";
import CommonProcess from "~/mixin/CommonProcess"; import CommonProcess from "~/mixin/CommonProcess";
import CodeTable from "~/config/CodeTable"; import CodeTable from "~/config/CodeTable";
import Event from "~/model/Ditopn/Event"; import Event from "~/model/Ditopn/Event";
...@@ -426,6 +427,29 @@ export default { ...@@ -426,6 +427,29 @@ export default {
// this.visiable = false; // this.visiable = false;
// this.model.setmod.setfog.setfop[this.index] = this.dialog; // 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 () {}, 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