Commit 24b8df4e by 潘际乾

Api请求提取至函数

parent 60046d42
......@@ -9,7 +9,8 @@
</template>
<script>
import Api from "~/service/Api"
import { getCodetable } from "~/service/business/codeTable"
export default {
props: {
value: {
......@@ -115,7 +116,7 @@ export default {
if(args.lang == "ZH"){
args.lang = "CN";
}
Api.post("getCodetable",args).then(rtnmsg=>{
getCodetable(args).then(rtnmsg=>{
if(rtnmsg.respCode==SUCCESS){
this.dbCodeList=rtnmsg.data
}
......
......@@ -31,7 +31,8 @@
</template>
<script>
import Api from "~/service/Api"
import { getCodetable } from "~/service/business/codeTable"
export default {
props: {
value: {
......@@ -132,7 +133,7 @@ export default {
if(args.lang == "ZH"){
args.lang = "CN";
}
Api.post("getCodetable",args).then(rtnmsg=>{
getCodetable(args).then(rtnmsg=>{
if(rtnmsg.respCode==SUCCESS){
this.dbCodeList=rtnmsg.data
}
......
......@@ -41,5 +41,8 @@ export default {
unfold: "Unfold",
reset: "Reset",
toolBar: "ToolBar"
},
other: {
please_enter: 'Please enter the '
}
};
......@@ -41,5 +41,8 @@ export default {
unfold: "展开",
reset: "重置",
toolBar: "工具条"
},
other: {
please_enter: '请输入'
}
};
import Vue from "vue"
import Api from "~/service/Api"
import { display } from "~/service/business/file"
import Utils from "../utils"
export default {
data() {
},
created(){
if(this.root){
created() {
if (this.root) {
//非顶级vue实例,不需要执行
return;
}
if(this.codes){
Vue.set(this.codes,"codeSet",{})
if (this.codes) {
Vue.set(this.codes, "codeSet", {})
}
},
mounted() {
//this.restoreDisplay()
},
methods: {
updapteValueSet(values){
if(!values){
updateValueSet(values) {
if (!values) {
return
}
//顶级实例,进入设置
if(!this.root){
for(let key in values){
Vue.set(this.codes.codeSet,key,values[key])
if (!this.root) {
for (let key in values) {
Vue.set(this.codes.codeSet, key, values[key])
}
}
else{
this.root.updapteValueSet(values)
else {
this.root.updateValueSet(values)
}
},
//获取后台setValues、setCodeValues传来的动态码,并自动转为码表值
getValues(key){
getValues(key) {
let arr = this.codes.codeSet[key]
if(!arr)
if (!arr)
return undefined
return arr.map(item=>{
let itemArr = item.split("\t")
if(itemArr.length > 1)
return {label:item,value:itemArr[0]}
return arr.map(item => {
let itemArr = item.split("\t")
if (itemArr.length > 1)
return { label: item, value: itemArr[0] }
else
return {label:itemArr[0],value:itemArr[0]}
return { label: itemArr[0], value: itemArr[0] }
})
},
showBackendErrors(fieldErrors){
showBackendErrors(fieldErrors) {
// 清除之前的校验状态
if(!this.getRoot().$refs.modelForm){
if (!this.getRoot().$refs.modelForm) {
return
}
this.getRoot().$refs.modelForm.clearValidate();
const fields = this.getRoot().$refs.modelForm.fields;
Utils.positioningErrorMsg(fieldErrors, fields);
const tab = Utils.positioningErrorMsg(fieldErrors, fields);
return tab;
},
loading(text){
loading(text) {
const loading = this.$loading({
lock: true,
text,
......@@ -66,48 +65,47 @@ export default {
});
return loading
},
getRoot(){
getRoot() {
return (this.root || this)
},
async init(params) {
const loading = this.loading("交易加载中")
let rtnmsg = await Api.post(this.declareParams.trnName + "/init", { params })
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
let rtnmsg = await Api.post(this.requestPrefix + "/init", { params })
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
}
loading.close()
return rtnmsg
},
async save(params) {
const loading = this.loading("正在保存交易")
let rtnmsg = await Api.post(this.declareParams.trnName + "/saveData", this.wrapper(params))
let rtnmsg = await Api.post(this.requestPrefix + "/saveData", this.wrapper(params))
loading.close()
return rtnmsg
},
async executeCheck(rulePath,params){
async executeCheck(rulePath, params) {
const loading = this.loading("校验进行中")
let rtnmsg = await Api.post(this.declareParams.trnName+"/executeCheck/"+rulePath, this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
let rtnmsg = await Api.post(this.requestPrefix + "/executeCheck/" + rulePath, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
loading.close()
return rtnmsg
},
async executeDefault(rulePath, params) {
let rtnmsg = await Api.post(this.declareParams.trnName + "/executeDefault/" + rulePath, this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
let rtnmsg = await Api.post(this.requestPrefix + "/executeDefault/" + rulePath, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
return rtnmsg
},
async executeRule(rulePath, params,delayCb) {
async executeRule(rulePath, params, delayCb) {
const loading = this.loading("正在请求数据")
let rtnmsg = await Api.post(this.declareParams.trnName + "/executeRule/" + rulePath, this.wrapper(params,delayCb))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
let rtnmsg = await Api.post(this.requestPrefix + "/executeRule/" + rulePath, this.wrapper(params, delayCb))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
this.showBackendErrors(rtnmsg.fieldErrors)
}
loading.close()
......@@ -115,18 +113,18 @@ export default {
},
async checkAll(params) {
const loading = this.loading("正在校验数据")
const rtnmsg = await Api.post(this.declareParams.trnName + "/checkAll", this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
const rtnmsg = await Api.post(this.requestPrefix + "/checkAll", this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
}
loading.close()
return rtnmsg
},
async pedding(params) {
const loading = this.loading("正在暂存数据")
const rtnmsg = await Api.post(this.declareParams.trnName + "/pending", this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
const rtnmsg = await Api.post(this.requestPrefix + "/pending", this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
}
loading.close()
return rtnmsg
......@@ -136,19 +134,18 @@ export default {
if (!inr)
return
const loading = this.loading("快照数据加载中")
let data = await Api.post("display/" + inr)
if(data.data)
{
let data = await display(inr)
if (data.data) {
Utils.copyValueFromVO(this.model, JSON.parse(data.data))
}else{
this.$notify.error({title: '错误',message: '快照文件加载失败!'});
} else {
this.$notify.error({ title: '错误', message: '快照文件加载失败!' });
}
loading.close()
},
async executeNotify(params) {
const rtnmsg = await Api.post(this.declareParams.trnName + "/executeNotify", this.wrapper(params))
if(rtnmsg.respCode == SUCCESS){
this.updapteValueSet(rtnmsg.codeSet)
const rtnmsg = await Api.post(this.requestPrefix + "/executeNotify", this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.updateValueSet(rtnmsg.codeSet)
}
return rtnmsg
},
......
export default{
data(){
export default {
data() {
return {
version:"1.0",
trnName:"",
version: "1.0",
trnName: "",
}
},
computed:{
declareParams(){
computed: {
declareParams() {
return {
version: this.version,
// 交易名
trnName: this.root ? this.root.trnName : this.trnName,
// 交易类型(进口、出口、买方、卖方等,为模块划分做准备)
trnType: this.getTrnType()
}
},
requestPrefix() {
return `/${this.declareParams.trnType}/${this.declareParams.trnName}`
}
},
methods: {
getTrnType() {
const type = this.root ? this.root.trnType : this.trnType
return type ? type : 'business'
}
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import Utils from "../utils"
export default {
methods: {
globalSearch(key){
return Api.post("report/globalSearch?key="+encodeURI(key));
return Api.post("/business/report/globalSearch?key="+encodeURI(key));
}
}
}
\ No newline at end of file
import Api from "~/service/Api"
import { rejrow } from "~/service/business/trnrel"
import Utils from "~/utils/index"
export default {
async onSeaown() {
......@@ -237,7 +238,7 @@ export default {
console.log(this.getSelectedData())
this.model.trncorco.selinr['rows'] = this.getSelectedData();
let rtnmsg = await Api.post("trnrel/rejrow", this.wrapper())
let rtnmsg = await rejrow(this.wrapper())
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
// var cacheFileName = rtnmsg.data.cacheFileName;
......
......@@ -2,7 +2,7 @@ import axios from 'axios'
import { MessageBox } from 'element-ui'
import RequestManager from './RequestManager.js';
export const BASE_HOST = "/gjjs/business/"
export const BASE_HOST = "/gjjs"
export const BASE_URI=BASE_HOST+"";
const instance = axios.create({
......
import Api from '~/service/Api'
export function getCodetable(data) {
return Api.post('/business/getCodetable', data)
}
import Api from "~/service/Api"
export function display(inr, data) {
return Api.post(`/business/display/${inr}`, data)
}
export function getPdf(data) {
return Api.post('/business/pdf', data)
}
import Api from "~/service/Api"
export function rejrow(data) {
return Api.post('/business/trnrel/rejrow', data)
}
\ No newline at end of file
import Api from "~/service/Api"
export function all(data) {
return Api.post("/report/task/all", data)
}
\ No newline at end of file
......@@ -47,7 +47,7 @@ export default {
},
created:async function(){
console.log("进入bddsel交易");
let rtnmsg = await Api.post("bddsel/init",{params:{}})
let rtnmsg = await this.init({})
if(rtnmsg.retcod == SUCCESS)
{
//TODO 处理数据逻辑
......
......@@ -154,7 +154,7 @@ export default {
},
created: async function () {
console.log("进入bdtudp交易");
let rtnmsg = await Api.post("bdtudp/init", { params: {} });
let rtnmsg = await this.init({})
if (rtnmsg.respCode == SUCCESS) {
//更新数据
Utils.copyValueFromVO(this.model, rtnmsg.data);
......
......@@ -24,7 +24,7 @@
</div>
</template>
<script>
import Api from "~/service/Api";
import { getCodetable } from "~/service/business/codeTable"
import CodeTable from "~/config/CodeTable";
import Bopsel from "~/model/Bopsel";
import commonProcess from "~/mixin/commonProcess";
......@@ -96,7 +96,7 @@ export default {
console.log("进入bopsel交易");
// 查询码表
Api.post("getCodetable", { tbl: "BOPTYP", lang: "EN" }).then((res) => {
getCodetable({ tbl: "BOPTYP", lang: "EN" }).then((res) => {
if (res.respCode == SUCCESS) {
this.codes.boptyp = res.data;
}
......
......@@ -71,7 +71,7 @@ export default {
},
created:async function(){
console.log("进入brtlat交易");
let rtnmsg = await Api.post("brtlat/init",{params:{}})
let rtnmsg = await this.init({})
if(rtnmsg.respCode == SUCCESS)
{
//TODO 处理数据逻辑
......
......@@ -156,7 +156,6 @@ export default {
},
created: async function () {
console.log("进入cptadv交易");
// let rtnmsg = await Api.post("cptadv/init",{params:{}});
let rtnmsg = await this.init(this.$route.query);
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
......
......@@ -80,7 +80,6 @@ export default {
methods: {},
created: async function () {
console.log("进入cptati交易");
// let rtnmsg = await Api.post("cptati/init",{params:{}});
let rtnmsg = await this.init(this.$route.query);
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
......
......@@ -85,7 +85,6 @@ export default {
},
created: async function () {
console.log("进入cptato交易");
// let rtnmsg = await Api.post("cptato/init",{params:{}});
let rtnmsg = await this.init(this.$route.query);
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
......
......@@ -201,7 +201,6 @@ export default {
},
created: async function () {
console.log("进入cptopn交易");
// let rtnmsg = await Api.post("cptopn/init", { params: {} });
let rtnmsg = await this.init(this.$route.query);
if (rtnmsg.respCode == SUCCESS) {
Utils.copyValueFromVO(this.model,rtnmsg.data)
......
......@@ -14,7 +14,7 @@
</div>
</template>
<script>
import Api from "~/service/Api"
import { getCodetable } from "~/service/business/codeTable"
import CodeTable from "~/config/CodeTable"
import Diasel from "~/model/Diasel"
import commonProcess from "~/mixin/commonProcess"
......@@ -60,12 +60,12 @@ export default {
created:async function(){
console.log("进入diasel交易");
// 查询码表
Api.post("getCodetable", { tbl:'DIATXT',lang:'EN' }).then((res) => {
getCodetable({ tbl:'DIATXT',lang:'EN' }).then((res) => {
if (res.respCode == SUCCESS) {
this.codes.diatxt = res.data;
}
});
Api.post("getCodetable", { tbl:'BUSTXT',lang:'EN' }).then((res) => {
getCodetable({ tbl:'BUSTXT',lang:'EN' }).then((res) => {
if (res.respCode == SUCCESS) {
this.codes.bustxt = res.data;
}
......
......@@ -2032,7 +2032,6 @@ export default {
methods: {},
created: async function () {
console.log("进入ditame交易");
//let rtnmsg = await Api.post("ditame/init", { params: {} });
let rtnmsg = await this.init(this.$route.query);
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
......
......@@ -52,7 +52,7 @@ export default {
methods: {},
created: async function () {
console.log("进入ditsel交易");
let rtnmsg = await Api.post("ditsel/init", { params: {} });
let rtnmsg = await this.init({})
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
Utils.copyValueFromVO(this.model, rtnmsg.data);
......
......@@ -145,7 +145,7 @@ export default {
},
created: async function() {
console.log("进入infpta交易");
let rtnmsg = await Api.post("infpta/init", { params: {} });
let rtnmsg = await this.init({})
if (rtnmsg.respCode == SUCCESS) {
//TODO 处理数据逻辑
this.updateModel(rtnmsg.data);
......
......@@ -494,7 +494,7 @@ export default {
},
async show(idx,row){
var params = {selDst:"recpan.smhstm",selIds:[idx+1],selBtnId:"A"}
let rtnmsg = await Api.post(`trnrel/executeRule/recpan.smhstm`, this.wrapper(params))
let rtnmsg = await Api.post(`/business/trnrel/executeRule/recpan.smhstm`, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.title = "面函"
let viewurl = "/#/docpan/show";
......
......@@ -492,7 +492,7 @@ export default {
},
async show(idx,row){
var params = {selDst:"recpan.smhstm",selIds:[idx+1],selBtnId:"A"}
let rtnmsg = await Api.post(`trnrel/executeRule/recpan.smhstm`, this.wrapper(params))
let rtnmsg = await Api.post(`/business/trnrel/executeRule/recpan.smhstm`, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.title = "面函"
let viewurl = "/#/docpan/show";
......
......@@ -25,7 +25,7 @@
</template>
<script>
import Api from "~/service/Api";
import { getPdf } from "~/service/business/file";
export default {
data() {
......@@ -47,7 +47,7 @@ export default {
];
});
if (this.model.docXML != "")
Api.post("pdf", { xml: this.model.docXML, doclang: window.sessionStorage.docuil }).then((res) => {
getPdf({ xml: this.model.docXML, doclang: window.sessionStorage.docuil }).then((res) => {
if (res.respCode == SUCCESS) {
this.pdf ="data:application/pdf;base64,"+ res.data;
}
......
......@@ -48,7 +48,7 @@
<script>
import CellHeaderVue from "./common/CellHeader.vue";
import axios from "axios";
import { all } from "~/service/report";
export default {
name: "TaskStatistics",
......@@ -84,7 +84,7 @@ export default {
};
},
created() {
axios.get('/gjjs/report/task/all').then(res => {
all().then(res => {
console.log(res);
})
}
......
......@@ -463,14 +463,14 @@ export default {
let rtnmsg
if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') {
this.model.setmod.msgmod.doccod = row.id
rtnmsg = await Api.post(`${this.declareParams.trnName}/msgmod_butshw`, this.wrapper())
rtnmsg = await Api.post(`${this.requestPrefix}/msgmod_butshw`, this.wrapper())
} else {
this.model.trnmod.trndoc.doccod = row.id
this.model.trnmod.trndoc.cortyp = cortyp
const params = {
index: index
}
rtnmsg = await Api.post(`${this.declareParams.trnName}/executeDocpan`, this.wrapper(params))
rtnmsg = await Api.post(`${this.requestPrefix}/executeDocpan`, this.wrapper(params))
}
if (rtnmsg.respCode == SUCCESS) {
if (cortyp == 'SWT' || cortyp == 'FMT' || cortyp == 'CMT') {
......@@ -523,7 +523,7 @@ export default {
const params = {
index: index
}
let rtnmsg = await Api.post(`${this.declareParams.trnName}/executeDocpanDetail`, this.wrapper(params))
let rtnmsg = await Api.post(`${this.requestPrefix}/executeDocpanDetail`, this.wrapper(params))
if (rtnmsg.respCode == SUCCESS) {
this.title = row.pandsc
this.centerDialogVisible = 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