Commit b14fe58b by 严立

列表查看公告详情方式优化 | 添加中标信息类型 | 供应商地址异常处理

parent 2da8c6e0
import iVue from '../../../main.js' import iVue from '../../../main.js'
import iHost from '../host.js' import iHost from '../host.js'
let timerClose = 0 let timerClose = 0
let loading = null let loading = null
let loadingFilter = [ let loadingFilter = [
'bid/order/queryState', // 查询支付状态 'bid/order/queryState', // 查询支付状态
'bid/common/getImgCode', // 获取图片验证 'bid/common/getImgCode', // 获取图片验证
] ]
let output = { let output = {
/** /**
* 请求拦截器 * 请求拦截器
* @function * @function
* @param {object} funcConfigure - 请求配置 * @param {object} funcConfigure - 请求配置
* @returns {boolean} * @returns {boolean}
*/ */
request: function (funXmlHttpRequest, funcConfigure, funcUrl) { request: function (funXmlHttpRequest, funcConfigure, funcUrl) {
funcUrl = funcUrl.replace(iHost.base, '') funcUrl = funcUrl.replace(iHost.base, '')
// 只有不被过滤的接口才会显示加载动画 // 只有不被过滤的接口才会显示加载动画
if (loadingFilter.indexOf(funcUrl) === -1) { if (loadingFilter.indexOf(funcUrl) === -1) {
if (loading === null) { if (loading === null) {
loading = iVue.$loading({ lock: false, text: 'Loading', spinner: 'el-icon-loading', background: 'rgba(255, 255, 255, 0.7)' }) loading = iVue.$loading({ lock: false, text: 'Loading', spinner: 'el-icon-loading', background: 'rgba(255, 255, 255, 0.7)' })
} }
if (timerClose !== 0) { if (timerClose !== 0) {
clearTimeout(timerClose) clearTimeout(timerClose)
} }
} }
// 默认添加 token 属性 // 默认添加 token 属性
if (funcConfigure.isToken) { if (funcConfigure.isToken) {
funXmlHttpRequest.setRequestHeader('token', localStorage.getItem('token')) funXmlHttpRequest.setRequestHeader('token', localStorage.getItem('token'))
} }
}, },
/** /**
* 响应拦截器 * 响应拦截器
* @function * @function
* @param {object} funcConfigure - 请求配置 * @param {object} funcConfigure - 请求配置
* @param {object} funcResult - 响应数据 * @param {object} funcResult - 响应数据
* @returns {boolean} * @returns {boolean}
*/ */
response: function (funcConfigure, funcResult) { response: function (funcConfigure, funcResult) {
if (loading) { if (loading) {
timerClose = setTimeout(() => { timerClose = setTimeout(() => {
if (loading) { if (loading) {
loading.close() loading.close()
} }
loading = null loading = null
clearTimeout(timerClose) clearTimeout(timerClose)
}, 500) }, 500)
} }
let funcDataType = '' let funcDataType = ''
try { try {
JSON.parse(funcResult) JSON.parse(funcResult)
funcDataType = 'object' funcDataType = 'object'
} }
catch (funcError) { catch (funcError) {
funcDataType = 'other' funcDataType = 'other'
} }
if (funcDataType === 'object') { if (funcDataType === 'object') {
let funcResultData = JSON.parse(funcResult) let funcResultData = JSON.parse(funcResult)
switch (Number(funcResultData.code)) { switch (Number(funcResultData.code)) {
case 10001: case 10001:
console.log('token overdue') console.log('token overdue')
this.$store.commit('isSignIn', false) this.$store.commit('isSignIn', false)
this.$store.commit('redirectPath', null) this.$store.commit('redirectPath', null)
localStorage.clear() localStorage.clear()
iVue.$router.push('/') iVue.$router.push('/')
return { state: false, response: { message: funcResultData.msg }} return { state: false, response: { message: funcResultData.msg }}
break break
// 请求正常直接返回 data 内容 // 请求正常直接返回 data 内容
case 200: case 200:
return { state: true, response: funcResultData.data} if (funcResultData.msg === '登录失效') {
break return { state: false, response: { message: funcResultData.msg }}
}
// 请求正常直接返回 data 内容 return { state: true, response: funcResultData.data}
case 400: break
return { state: false, response: { message: funcResultData.msg, data: funcResultData.data }}
break // 请求正常直接返回 data 内容
case 400:
// 请求异常返回 msg 错误提示 return { state: false, response: { message: funcResultData.msg, data: funcResultData.data }}
default: break
return { state: false, response: { message: funcResultData.msg }}
break // 请求异常返回 msg 错误提示
} default:
} return { state: false, response: { message: funcResultData.msg }}
return funcResult break
} }
} }
return funcResult
export default output }
}
export default output
import iHeader from './header.js' import iHeader from './header.js'
import iDataform from './dataform.js' import iDataform from './dataform.js'
import iConfigure from './configure.js' import iConfigure from './configure.js'
import iInterceptors from './interceptors.js' import iInterceptors from './interceptors.js'
import iVue from '../../../main.js' import iVue from '../../../main.js'
let output = { let output = {
/** /**
* 通用请求函数 * 通用请求函数
* @function * @function
* @param {string} funcUrl - 完整请求路径 * @param {string} funcUrl - 完整请求路径
* @param {object} funcData - 请求数据 * @param {object} funcData - 请求数据
* @param {string} funcType - 请求数据类型 * @param {string} funcType - 请求数据类型
* @param {string} funcMethod - 请求方法 * @param {string} funcMethod - 请求方法
* @param {object} funcOther - 其他配置 * @param {object} funcOther - 其他配置
*/ */
request: function (funcUrl, funcData, funcSendType, funcMethod, funcOther) { request: function (funcUrl, funcData, funcSendType, funcMethod, funcOther) {
// 获取默认请求设置 // 获取默认请求设置
let funcConfigure = JSON.parse(JSON.stringify(iConfigure)) let funcConfigure = JSON.parse(JSON.stringify(iConfigure))
Object.assign(funcConfigure, funcOther) Object.assign(funcConfigure, funcOther)
// 检查数据发放方式有效性 // 检查数据发放方式有效性
if (funcSendType && iConfigure.sendTypeEnumeration.indexOf(funcSendType.toLowerCase()) >= 0) { if (funcSendType && iConfigure.sendTypeEnumeration.indexOf(funcSendType.toLowerCase()) >= 0) {
funcConfigure.sendType = funcSendType.toLowerCase() funcConfigure.sendType = funcSendType.toLowerCase()
} }
// 检查请求方法字段有效性 // 检查请求方法字段有效性
if (funcMethod && iConfigure.methodEnumeration.indexOf(funcMethod) >= 0) { if (funcMethod && iConfigure.methodEnumeration.indexOf(funcMethod) >= 0) {
funcConfigure.method = funcMethod funcConfigure.method = funcMethod
} }
// get 请求需要将参数转换为 url 形式 // get 请求需要将参数转换为 url 形式
if (funcConfigure.method === 'get') { if (funcConfigure.method === 'get') {
// 设置数据类型 // 设置数据类型
funcData = iDataform(funcData, 'url') funcData = iDataform(funcData, 'url')
let funcPromise = new Promise(function (funcResolve, funcReject) { let funcPromise = new Promise(function (funcResolve, funcReject) {
let funcXMLHttpRequest = new XMLHttpRequest() let funcXMLHttpRequest = new XMLHttpRequest()
funcXMLHttpRequest.open(funcConfigure.method, funcUrl + funcData, true) funcXMLHttpRequest.open(funcConfigure.method, funcUrl + funcData, true)
// 请求之前修改 // 请求之前修改
iHeader(funcXMLHttpRequest, funcConfigure) iHeader(funcXMLHttpRequest, funcConfigure)
iInterceptors.request(funcXMLHttpRequest, funcConfigure, funcUrl) iInterceptors.request(funcXMLHttpRequest, funcConfigure, funcUrl)
funcXMLHttpRequest.send() funcXMLHttpRequest.send()
funcXMLHttpRequest.onreadystatechange = function () { funcXMLHttpRequest.onreadystatechange = function () {
if (funcXMLHttpRequest.readyState !== 4) { if (funcXMLHttpRequest.readyState !== 4) {
return return
} }
let funStatus = funcXMLHttpRequest.status let funStatus = funcXMLHttpRequest.status
if ((funStatus >= 200 && funStatus < 300) || funStatus === 304) { if ((funStatus >= 200 && funStatus < 300) || funStatus === 304) {
let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText) let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText)
if (funcInterceptorsResponse.state) { if (funcInterceptorsResponse.state) {
funcResolve(funcInterceptorsResponse.response) funcResolve(funcInterceptorsResponse.response)
} else { } else {
iVue.$message.error(funcInterceptorsResponse.response.message) iVue.$message.error(funcInterceptorsResponse.response.message)
} }
} else { } else {
let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText) let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText)
if (funcInterceptorsResponse.state) { if (funcInterceptorsResponse.state) {
funcResolve(funcInterceptorsResponse.response) funcResolve(funcInterceptorsResponse.response)
} else { } else {
iVue.$message.error(funcInterceptorsResponse.response.message) iVue.$message.error(funcInterceptorsResponse.response.message)
} }
} }
} }
}) })
return funcPromise return funcPromise
} }
if (funcConfigure.method === 'post') { if (funcConfigure.method === 'post') {
// 设置数据类型 // 设置数据类型
funcData = iDataform(funcData, funcConfigure.sendType) funcData = iDataform(funcData, funcConfigure.sendType)
let funcPromise = new Promise(function (funcResolve, funcReject) { let funcPromise = new Promise(function (funcResolve, funcReject) {
let funcXMLHttpRequest = new XMLHttpRequest() let funcXMLHttpRequest = new XMLHttpRequest()
funcXMLHttpRequest.open(funcConfigure.method, funcUrl, true) funcXMLHttpRequest.open(funcConfigure.method, funcUrl, true)
// 请求之前修改 // 请求之前修改
iHeader(funcXMLHttpRequest, funcConfigure) iHeader(funcXMLHttpRequest, funcConfigure)
iInterceptors.request(funcXMLHttpRequest, funcConfigure, funcUrl) iInterceptors.request(funcXMLHttpRequest, funcConfigure, funcUrl)
funcXMLHttpRequest.send(funcData) funcXMLHttpRequest.send(funcData)
funcXMLHttpRequest.onreadystatechange = function () { funcXMLHttpRequest.onreadystatechange = function () {
if (funcXMLHttpRequest.readyState !== 4) { if (funcXMLHttpRequest.readyState !== 4) {
return return
} }
let funStatus = funcXMLHttpRequest.status let funStatus = funcXMLHttpRequest.status
if ((funStatus >= 200 && funStatus < 300) || funStatus === 304) { if ((funStatus >= 200 && funStatus < 300) || funStatus === 304) {
let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText) let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText)
if (funcInterceptorsResponse.state) { if (funcInterceptorsResponse.state) {
funcResolve(funcInterceptorsResponse.response) funcResolve(funcInterceptorsResponse.response)
} else { } else {
console.log('funcReject') if (funcInterceptorsResponse.response.message !== '登录失效') {
iVue.$message.error(funcInterceptorsResponse.response.message) iVue.$message.error(funcInterceptorsResponse.response.message)
funcReject(funcInterceptorsResponse.response) }
} funcReject(funcInterceptorsResponse.response)
} else { }
let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText) } else {
if (funcInterceptorsResponse.state) { let funcInterceptorsResponse = iInterceptors.response(funcConfigure, funcXMLHttpRequest.responseText)
funcResolve(funcInterceptorsResponse.response) if (funcInterceptorsResponse.state) {
} else { funcResolve(funcInterceptorsResponse.response)
iVue.$message.error(funcInterceptorsResponse.response.message) } else {
} iVue.$message.error(funcInterceptorsResponse.response.message)
} }
} }
}) }
return funcPromise })
} return funcPromise
}, }
} },
}
export default output export default output
\ No newline at end of file
...@@ -1103,7 +1103,7 @@ ...@@ -1103,7 +1103,7 @@
} }
.bidding-news-detail-html { .bidding-news-detail-html {
width: 100%; width: 100%;
height: 40px; height: 38px;
margin-top: 20px; margin-top: 20px;
font-size: @fontSize01 !important; font-size: @fontSize01 !important;
overflow: hidden; overflow: hidden;
......
...@@ -230,11 +230,13 @@ ...@@ -230,11 +230,13 @@
'examineReason': funcResponse.reason, 'examineReason': funcResponse.reason,
} }
// 判断地址数据类型,同时兼容字符串与数组类型 if (funcResponse.receiveArea) {
if (Object.prototype.toString.call(funcResponse.receiveArea) === '[object String]') { // 判断地址数据类型,同时兼容字符串与数组类型
this.formInfo.receiveArea = JSON.parse(funcResponse.receiveArea).join(' ') if (Object.prototype.toString.call(funcResponse.receiveArea) === '[object String]') {
} else { this.formInfo.receiveArea = JSON.parse(funcResponse.receiveArea).join(' ')
this.formInfo.receiveArea = funcResponse.receiveArea.join(' ') } else {
this.formInfo.receiveArea = funcResponse.receiveArea.join(' ')
}
} }
console.log(this.formInfo) console.log(this.formInfo)
......
...@@ -852,7 +852,6 @@ ...@@ -852,7 +852,6 @@
* @returns * @returns
*/ */
onQuoteSubmit: function () { onQuoteSubmit: function () {
console.log(JSON.stringify(this.tableQuote))
if (this.tableQuote.length === 0) { if (this.tableQuote.length === 0) {
this.$message.error('请填写完整报价信息') this.$message.error('请填写完整报价信息')
return return
...@@ -893,7 +892,8 @@ ...@@ -893,7 +892,8 @@
'biddingOffers': JSON.stringify(funcQuoteData) 'biddingOffers': JSON.stringify(funcQuoteData)
} }
let funcOther = iRequest.request(iHost.base + 'bid/zBiddingProject/biddingOffer', funcParam, 'json', 'post') console.log('promise begin')
iRequest.request(iHost.base + 'bid/zBiddingProject/biddingOffer', funcParam, 'json', 'post')
.then((funcResponse) => { .then((funcResponse) => {
this.winQuote = false this.winQuote = false
this.$message({ message: '报价成功!', type: 'success' }) this.$message({ message: '报价成功!', type: 'success' })
......
...@@ -283,25 +283,26 @@ ...@@ -283,25 +283,26 @@
if (funcResponse.orderBilling) { if (funcResponse.orderBilling) {
this.isReceive = !Boolean(Number(funcResponse.orderBilling.receiveType)) this.isReceive = !Boolean(Number(funcResponse.orderBilling.receiveType))
this.componentReceive = { if (this.isReceive) {
'name': funcResponse.orderBilling.name, this.componentReceive = {
'phone': funcResponse.orderBilling.phone, 'name': funcResponse.orderBilling.name ? funcResponse.orderBilling.name : '暂无',
'area': '', 'phone': funcResponse.orderBilling.phone ? funcResponse.orderBilling.phone : '暂无',
'address': funcResponse.orderBilling.address, 'area': '',
} 'address': funcResponse.orderBilling.address ? funcResponse.orderBilling.address : '暂无',
}
// 判断地址数据类型,同时兼容字符串与数组类型 // 判断地址数据类型,同时兼容字符串与数组类型
if (Object.prototype.toString.call(funcResponse.orderBilling.area) === '[object String]') { if (funcResponse.orderBilling.area) {
this.componentReceive.area = JSON.parse(funcResponse.orderBilling.area).join(' ') if (Object.prototype.toString.call(funcResponse.orderBilling.area) === '[object String]') {
} else { this.componentReceive.area = JSON.parse(funcResponse.orderBilling.area).join(' ')
this.componentReceive.area = funcResponse.orderBilling.area.join(' ') } else {
this.componentReceive.area = funcResponse.orderBilling.area.join(' ')
}
}
} }
} else {
this.isReceive = false
} }
console.log(this.isReceive) console.log(this.componentProject.isPackage)
if (this.componentProject.isPackage) { if (this.componentProject.isPackage) {
// 多个合同 // 多个合同
let funcRawData = funcResponse.order.tenderPackages let funcRawData = funcResponse.order.tenderPackages
...@@ -313,6 +314,7 @@ ...@@ -313,6 +314,7 @@
'price': funcRawData[i].price, 'price': funcRawData[i].price,
} }
this.componentContract.push(funcItem) this.componentContract.push(funcItem)
console.log('this.componentContract', this.componentContract)
} }
} else { } else {
this.componentContract.push({ 'price': funcResponse.order.price }) this.componentContract.push({ 'price': funcResponse.order.price })
......
...@@ -469,7 +469,7 @@ ...@@ -469,7 +469,7 @@
* @returns * @returns
*/ */
reset: function () { reset: function () {
this.state = 3 this.state = 1
this.formRegister = { this.formRegister = {
// 基本信息 // 基本信息
companyName: '', companyName: '',
......
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 sign in to comment