Commit 02c2cc97 authored by 何虹's avatar 何虹 💬

本次提交的说明

parent f7ac309c
......@@ -17,6 +17,7 @@
"build-bundle": "vue-cli-service build --target lib --name hs-sky-ui ./src/packages/index.js"
},
"dependencies": {
"hs-util-js":"^1.0.2",
"axios": "^0.19.2",
"babel-preset-es2015": "^6.24.1",
"core-js": "^3.6.4",
......
<template>
<div
:id='elId'
class="common"
>
<slot></slot>
<hs-jsoneditor
v-model='jsoneditorVisible'
:elInfo='elInfo'
v-bind="$attrs"
v-on="$listeners"
></hs-jsoneditor>
<!-- <jsoneditor
v-model='jsoneditorVisible'
:elInfo='elInfo'
v-bind="$attrs"
v-on="$listeners"
>
</jsoneditor> -->
</div>
</template>
<script>
import commonboxUc from './commonboxUc.js'
export default {
mixins: [commonboxUc],
props: {
elInfo: {}
},
name: 'common-component'
}
</script>
<style scoped>
.common {
width: 100%;
height: 100%;
}
</style>
\ No newline at end of file
import uuidv1 from 'uuid/v1'
export default {
data() {
return {
elId: '',
outBoxDom: null,
jsoneditorVisible: false
}
},
created() {
this.initElid()
},
mounted() {
this.initElid()
setTimeout(() => {
this.showEditJsonDialog()
}, 2000)
},
destroyed() {
if (this.outBoxDom) {
this.outBoxDom.removeEventListener('mousedown', this.boxEventMouse)
this.outBoxDom = null
}
this.chart = null
},
beforeDestroy() {
clearInterval(this.timer)// 清除定时器
this.timer = null
if (this.chart) {
this.chart.clear()
this.chart.dispose()
this.chart = null
}
},
methods: {
initElid() {
if (!this.elId) {
this.elId = uuidv1() // 获取随机id
}
},
boxEventMouse(event) {
const that = this
event.stopPropagation()
if (event.shiftKey && event.altKey && !event.ctrlKey) {
that.jsoneditorVisible = true
}
},
// 弹出可编辑的弹框
showEditJsonDialog() {
this.outBoxDom = document.getElementById(this.elId)
this.outBoxDom && this.outBoxDom.addEventListener('mousedown', this.boxEventMouse)
}
}
}
This diff is collapsed.
This diff is collapsed.
class TableHandle {
constructor() {
this.moduleName = 'TableHandle'
}
/**
*把index1 和 index2交换
* @param {*} arr 数据源
* @param {*} index1
* @param {*} index2
*/
swapArr(arr, index1, index2) {
arr[index1] = arr.splice(index2, 1, arr[index1])[0]
return arr
}
// 向前移动一格
moveUp(arrayData, index1, order = 'order') {
if (index1 >= arrayData.length) return arrayData
let index2 = index1 - 1
if (index2 < 0) {
index2 = arrayData.length - 1
}
const index1Order = arrayData[index1][order]
const index2Order = arrayData[index2][order]
arrayData[index1][order] = index2Order
arrayData[index2][order] = index1Order
// 再交换两个元素的位置
this.swapArr(arrayData, index1, index2)
}
// 向下移动一格
moveDown(arrayData, index1, order = 'order') {
if (index1 >= arrayData.length) return arrayData
let index2 = index1 + 1
if (arrayData.length <= index2) {
index2 = 0
}
const index1Order = arrayData[index1][order]
const index2Order = arrayData[index2][order]
arrayData[index1][order] = index2Order
arrayData[index2][order] = index1Order
// 再交换两个元素的位置
this.swapArr(arrayData, index1, index2)
}
/**
* 向下移动逻辑 有两种复杂情况
* 如果移动行中有最后一项和第一项(0,1,8,9) 这种情况移动顺序是1,0,9,8
* 1,3,5,6 这种移动顺序是 6,5,3,1
* @param {*} array
* @param {*} listIndex
* @param {*} order
*/
batchDown(array, listIndex, order = 'order') {
// 同时包含第一项和最后一项时
const list = []
const itemLast = listIndex[listIndex.length - 1]
const lastIndex = listIndex.length - 1
listIndex.forEach((item, index) => {
if (item - itemLast === index - lastIndex) {
list.push(listIndex[index])
}
})
const max = Math.min(...list)
const maxIndex = listIndex.findIndex(x => x === max)
const spliceList = listIndex.splice(maxIndex, lastIndex)
spliceList.reverse()
let listIndexReverse = listIndex// listIndex.reverse()
if (listIndex.includes(0) && listIndex.includes(array.length - 1)) {
listIndexReverse = listIndex
} else {
listIndexReverse = listIndex.reverse()
}
listIndexReverse.push(...spliceList)
listIndexReverse.forEach(index => {
this.moveDown(array, index, order)
})
}
/**
* 向上移动 也有两种复杂情况
* 如果移动行中有最后一项和第一项(0,1,8,9) 这种情况移动顺序是8,9,0,1
* 1,3,5,6 这种移动顺序是 1,3,5,6
* @param {*} array
* @param {*} listIndex
* @param {*} order
*/
batchUp(array, listIndex, order = 'order') {
// 同时包含第一项和最后一项时
const list = []
const item0 = listIndex[0]
listIndex.forEach((item, index) => {
if (index - item0 === listIndex[index]) {
list.push(listIndex[index])
}
})
const max = Math.max(...list)
const maxIndex = listIndex.findIndex(x => x === max)
const spliceList = listIndex.splice(0, maxIndex + 1)
if (listIndex.includes(0) && listIndex.includes(array.length - 1)) {
const index1 = listIndex.shift()
listIndex.push(index1)
}
listIndex.push(...spliceList)
listIndex.forEach(index => {
this.moveUp(array, index, order)
})
}
batchTop(array, listIndex, order = 'order') {
listIndex.forEach((x, index) => {
let l = x - index
while (l > 0 && x > 0) {
this.moveUp(array, x, order)
x--
l--
}
})
}
batchBottom(array, listIndex, order = 'order') {
listIndex.reverse()
const arrayLength = array.length
listIndex.forEach((x, index) => {
const ducex = arrayLength - x - 1
let l = ducex - index
while (l > 0 && x >= 0) {
this.moveDown(array, x, order)
x++
l--
}
})
}
}
// const list = [{ order: 1, name: 1 }, { order: 2, name: 2 }, { order: 3, name: 3 }, { order: 4, name: 4 }, { order: 5, name: 5 }, { order: 6, name: 6 }, { order: 7, name: 7 }]
// const t = new TableHandle()
// // t.batchTop(list, [0, 3, 5, 6])
// // console.log(list)
// t.batchBottom(list, [1, 2, 3])
// console.log(list)
export default new TableHandle()
......@@ -70,7 +70,7 @@
</div>
</template>
<script>
import commonUtility from '../funTools/commonUtility'
import hsUtil from 'hs-util-js'
import _ from 'lodash'
import Sortable from 'sortablejs'
import commonMixins from '../ucClass/commonMixins'
......@@ -206,7 +206,7 @@ export default {
this.tableDataLeft = this.removeUniq(this.tableDataLeft, isSelectedList)
},
async showDialog() {
const getClientWidth = commonUtility.getClientWidth()
const getClientWidth = hsUtil.System.getClientWidth()
this.tableWith = getClientWidth / 2 + 'px'
// 弹出之前做逻辑判断
const { value } = this.configData
......@@ -458,7 +458,7 @@ export default {
selectIndexData.push(index)
}
})
commonUtility.tableHandle.batchUp(this.tableDataRight, selectIndexData)
hsUtil.TableHandle.batchUp(this.tableDataRight, selectIndexData)
},
/**
* 下移动
......@@ -470,7 +470,7 @@ export default {
selectIndexData.push(index)
}
})
commonUtility.tableHandle.batchDown(this.tableDataRight, selectIndexData)
hsUtil.TableHandle.batchDown(this.tableDataRight, selectIndexData)
}
}
}
......
......@@ -179,7 +179,7 @@
<script>
import { videoPlayer } from 'vue-video-player'
import commonUtility from '../funTools/commonUtility'
import hsUtil from 'hs-util-js'
import 'video.js/dist/video-js.css'
import _ from 'lodash'
import axios from 'axios'
......@@ -383,7 +383,7 @@ export default {
initConfig() {
const { config } = this.allSourceData
const configData = Object.assign(this.configData_, _.cloneDeep(config))
const { appCode } = commonUtility.getSysParams()
const { appCode } = hsUtil.System.getSysParams()
configData.appCode = configData.appCode || appCode
return configData
},
......
......@@ -197,7 +197,7 @@
<script>
import uuidv1 from 'uuid/v1'
import mockData from '../common/initDbConfigDataJson'
import commonUtility from '../funTools/commonUtility'
import hsUtil from 'hs-util-js'
import lookPageLog from '../common/lookPageLog.vue'
import asyncFormPropSet from '../common/asyncFormPropSet.vue'
import tbaleColumsSet from '../common/tbaleColumsSet.vue'
......@@ -333,7 +333,6 @@ export default {
mockData: this.controlInfo.isMock ? 1 : 0,
controlType: this.elInfo.el || ''
}
// rootHttpClient.WebChartConfigModule
this.$listeners.webChartConfigSave(data).then(() => {
this.$message.success('设置成功')
if (flage === 'columnStyleSet') {
......@@ -368,7 +367,6 @@ export default {
mockData: this.controlInfo.isMock ? 1 : 0
}
return this.$listeners.webChartConfigSave(data)
//return rootHttpClient.WebChartConfigModule.webChartConfigSave(data)
},
editAnyncColums() {
this.dialogVisibleAsyncFormColumn = true
......@@ -438,12 +436,6 @@ export default {
this.getPageInfo()
this.isrequest = !this.isrequest
})
// rootHttpClient.WebChartConfigModule.webChartConfigRevert(parm).then(
// res => {
// this.getPageInfo()
// this.isrequest = !this.isrequest
// }
// )
},
execSql() {
const data = {
......@@ -453,9 +445,6 @@ export default {
this.$listeners.execSql(data).then(res => {
this.editor2.set(res)
})
// rootHttpClient.WebChartConfigModule.execSql(data).then(res => {
// this.editor2.set(res)
// })
},
getPageInfo(info = this.elInfo) {
const { position, pageName, appCode } = info
......@@ -464,8 +453,7 @@ export default {
appCode: appCode,
pageName: pageName
}
//rootHttpClient.WebChartConfigModule.webChartConfigQuery(data)
this.$listeners.webChartConfigQuery(data).then(
this.$listeners.webChartConfigQuery(data).then(
res => {
const data = res.data
if (data && data.length) {
......@@ -510,7 +498,6 @@ export default {
pageName: this.controlInfo.pageName
}
this.$listeners.saveAsDataToLocal(data)
//rootHttpClient.WebChartConfigModule.saveAsDataToLocal(data)
},
dialogClose() {
this.dialogVisible = false
......@@ -520,7 +507,7 @@ export default {
dialogOpen() {
this.revertVersion = false
// 初始化appCode pageName 等等
const { appCode, pageName } = commonUtility.getUrlParams()
const { appCode, pageName } = hsUtil.System.getUrlParams()
this.controlInfo.appCode = appCode
this.controlInfo.pageName = pageName
this.controlInfo.controlName = this.elInfo.position
......@@ -602,9 +589,6 @@ export default {
this.$listeners.webChartConfigSave(data_).then(() => {
this.$message.success('设置成功')
})
// rootHttpClient.WebChartConfigModule.webChartConfigSave(data_).then(() => {
// this.$message.success('设置成功')
// })
},
setJson(data) {
const { config, sourceData } = JSON.parse(JSON.stringify(data))
......
......@@ -2,19 +2,16 @@
<div style='width:100%;height:100%'>
<div :id="elId"
style='width:100%;height:100%;'></div>
<jsoneditor
v-model='jsoneditorVisible'
:elInfo='elInfo'
:layout='layout'
:jsoneditorCloseAfter='jsoneditorCloseAfter'
:jsoneditorOpenAfter='jsoneditorOpenAfter'
>
</jsoneditor>
<hs-jsoneditor
v-model='jsoneditorVisible'
:elInfo='elInfo'
v-bind="$attrs"
v-on="$listeners"
></hs-jsoneditor>
</div>
</template>
<script>
import jsoneditor from '../common/jsoneditor'
import mockData from '../common/initDbConfigDataJson'
import ucComponent from '../ucClass/uc_component'
import echartResize from './echartResize'
......@@ -22,9 +19,6 @@ import _ from 'lodash'
import DataTool from './dataTool'
export default {
mixins: [ucComponent, echartResize],
components: {
jsoneditor
},
name: 'hs-line-bar',
props: {
elInfo: {
......
......@@ -72,7 +72,7 @@
</template>
<script>
import commonMixins from '../ucClass/commonMixins'
import commonUtility from '../funTools/commonUtility'
import hsUtil from 'hs-util-js'
export default {
mixins: [commonMixins],
name: 'lookup-component',
......@@ -460,7 +460,7 @@ export default {
selectIndexData.push(index)
}
})
commonUtility.tableHandle.batchUp(list, selectIndexData)
hsUtil.TableHandle.batchUp(list, selectIndexData)
},
/**
* 下移动
......@@ -473,7 +473,7 @@ export default {
selectIndexData.push(index)
}
})
commonUtility.tableHandle.batchDown(list, selectIndexData)
hsUtil.TableHandle.batchDown(list, selectIndexData)
}
}
}
......
......@@ -16,7 +16,6 @@
<el-button slot="append" icon="el-icon-search" @click='showDialog' ></el-button>
</el-input>
</div>
<el-dialog
@open='openDialog'
:close-on-click-modal='false'
......@@ -121,7 +120,7 @@
</div>
</template>
<script>
import commonUtility from '../funTools/commonUtility'
import hsUtil from 'hs-util-js'
import commonMixins from '../ucClass/commonMixins'
import _ from 'lodash'
export default {
......@@ -366,7 +365,7 @@ export default {
},
async showDialog() {
console.log('showDialog')
const getClientWidth = commonUtility.getClientWidth()
const getClientWidth = hsUtil.System.getClientWidth()
this.tableWithLeft = getClientWidth / 2 + 'px'
this.tableWithRight = getClientWidth / 2 - 66 + 'px'
if (this.value) {
......@@ -582,7 +581,7 @@ export default {
selectIndexData.push(index)
}
})
commonUtility.tableHandle.batchUp(this.rightTabeData, selectIndexData)
hsUtil.TableHandle.batchUp(this.rightTabeData, selectIndexData)
},
/**
* 下移动
......@@ -594,7 +593,7 @@ export default {
selectIndexData.push(index)
}
})
commonUtility.tableHandle.batchDown(this.rightTabeData, selectIndexData)
hsUtil.TableHandle.batchDown(this.rightTabeData, selectIndexData)
}
},
mounted() {}
......
......@@ -338,7 +338,6 @@ import tableDeatil from './tableDetail'
import childItem from './ItemComponentChild'
import tbaleColumsSet from '../common/tbaleColumsSet'
import tableTool from './tableColumsTrans'
import ucComponent from '../ucClass/uc_component'
import rowTable from './rowTable'
import { add } from 'mathjs'
import commonMixins from '../ucClass/commonMixins'
......@@ -717,7 +716,7 @@ export default {
paramsData.json_data = JSON.stringify(sourceData)
paramsData.is_mock = 1
paramsData.query_sql = ''
} else if(Array.isArray(resData)&& resData.length){
} else if (Array.isArray(resData) && resData.length) {
paramsData = resData[0]
}
const { query_sql, json_config, json_data, is_mock } = paramsData
......
import axios from 'axios'
import { Notification, Loading } from 'element-ui'
import hsUtil from 'hs-util-js'
import store from '@/store/storeAll'
import httpClient from './startUp'
let fullLoading
function showLoading() {
fullLoading = Loading.service({
lock: true,
text: '加载中...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0)'
})
setTimeout(_ => {
fullLoading.close()
}, 10000)
}
function closeLoading() {
fullLoading && fullLoading.close()
}
let loading_request_count = 0
function show_full_screen_loading() {
if (loading_request_count === 0) {
showLoading()
}
loading_request_count++
}
function hide_full_screen_loading() {
if (loading_request_count <= 0) return
loading_request_count--
if (loading_request_count === 0) {
closeLoading()
}
}
// 增加一个response拦截器
axios.interceptors.response.use(
function(response) {
hide_full_screen_loading()
if (response.data) {
const { error_detail, error_title } = response.data
if (error_title || error_detail) {
Notification.error({
title: '错误信息!',
dangerouslyUseHTMLString: true,
duration: 100000,
message: `<div>
<textarea style="border:0;border-radius:5px;background-color:rgba(241,241,241,.98);width: 300px;height: 400px;padding: 10px;resize: none;position: relative;right: 36px;">
${error_title}
${error_detail}
</textarea>
</div>` // error_detail || error_title,
})
} else { // 此处做优化 只有不出错的时候才返回response
return response
}
} else { // 此处做优化 只有不出错的时候才返回response
return response
}
},
async function(error) {
hide_full_screen_loading()
// 如果返回的code中token 过期了则刷新token
const code = error.response && error.response.status
const resData = (error.response && error.response.data) || {}
if (code === 401 && resData.error_type === 'expired' && self !== top) { // 401时过期了把请求缓存起来,等待webframe刷新token后再统一请求!
return httpClient.tokenModule.hand401Meaage(error.response.config)
} else {
response_error_del(error)
return Promise.reject(error)
}
}
)
function dyncInnerErrorDel(error) {
if (error.message === 'Network Error') {
Notification.error({
title: '错误信息!',
message: '网络连接错误!请检查您的网络是否正常!',
type: 'warning'
})
}
if (error.response && typeof error.response.data === 'string') {
Notification.error({
title: '错误信息!',
dangerouslyUseHTMLString: true,
type: 'warning',
duration: 100000,
message: `<div>
<textarea style="border:0;border-radius:5px;background-color:rgba(241,241,241,.98);width: 300px;height: 400px;padding: 10px;resize: none;position: relative;right: 36px;">
${error.response.data}
</textarea>
</div>`
})
}
if (error.response && typeof error.response.data === 'object') {
const { error_detail, error_title } = error.response.data
Notification.error({
title: '错误信息!',
dangerouslyUseHTMLString: true,
duration: 100000,
message: `<div>
<textarea style="border:0;border-radius:5px;background-color:rgba(241,241,241,.98);width: 300px;height: 400px;padding: 10px;resize: none;position: relative;right: 36px;">
${error_title}
${error_detail}
</textarea>
</div>`
})
}
}
function response_error_del(error) {
const { response, code } = error
const { status, statusText, data } = response || {}
let error_title = '错误信息'
let error_detail = ''
if (!response && !code) {
// 没网的情况
error_title = '网络连接失败,请检查网络!'
error_detail = '尝试关闭网站重新登陆!'
} else if (code === 'ECONNABORTED') {
error_title = '请求超时ECONNABORTED'
error_detail = 'Uncaught (in promise) Error: timeout of 60000ms exceeded'
} else if (status === 504) {
error_title = '请求超时504'
error_detail = data
} else if (status === 404) {
error_title = '404资源请求路径找不到'
error_detail = response.request.responseURL
} else if (status === 401 && statusText === 'UNAUTHORIZED') {
if (self !== top) parent.postMessage('login', '*')
sessionStorage.removeItem('header')
error_detail = 'UNAUTHORIZED-未授权401'
error_title = '身份验证失败,请重新登录!'
} else {
if (data.message) {
error_title = data.message
} else if (data instanceof Blob) {
// 这条判断是解决 下载文件返回流的情况 要把流转成json
const reader = new FileReader()
reader.readAsText(data)
const dealFileReader = async function() {
const result = await new Promise(function(resolve, reject) {
reader.onload = e => {
resolve(JSON.parse(e.target.result))
}
})
error_title = result.error_title ? result.error_title : '服务器异常'
error_detail = result.error_detail
if (sessionStorage['platform']) {
store.commit('set_error_info', { error_title, error_detail })
} else {
hsUtil.IframeMessage.sendErrorToWebframe({ error_title, error_detail })
}
}
dealFileReader()
return
} else if (Object.keys(data).length === 4) {
error_title = data.error_title ? data.error_title : '服务器异常'
error_detail = data.error_detail
} else {
error_title = '服务器内部错误'
error_detail = data
}
}
if (sessionStorage['platform'] || top === self) {
store.commit('set_error_info', { error_title, error_detail })
} else {
hsUtil.IframeMessage.sendErrorToWebframe({ error_title, error_detail })
}
}
axios.interceptors.request.use(
async config => {
// 设置token信息
// config.headers['refreshToken'] = sessionStorage['refresh_token']
config.headers['Authorization'] = sessionStorage['token']
config.headers['tenant'] = 'wms'
if (config.url.indexOf('no_loading') !== -1) {
} else {
if (config.url.startsWith('http:') || config.url.startsWith('https:')) {
// 俺啥都不干
} else {
config.url = config.url.replace('//', '/')
}
show_full_screen_loading()
}
if (config.url.includes('?&')) {
config.url = config.url.replace('?&', '?')
}
return config
},
err => {
hide_full_screen_loading()
return Promise.reject(err)
}
)
import { TOOL_PROXY, GQL_PROXY, COMMON_UTIL_PROXY } from './commonProxy'
export const WEB_QUERY = `${TOOL_PROXY}/web_query/`
export const WEB_QUERY_QUERY = `${TOOL_PROXY}/web_query/query/`
export const WEB_QUERY_QUERY_VALUE = `${TOOL_PROXY}/web_query/query_value/`
export const WEB_QUERY_PAGE = `${TOOL_PROXY}/web_chart_config/query_page/`
export const SQL_GQL = `${GQL_PROXY}/sql_gql/`
export const SQL_GQL_SAVE = `${GQL_PROXY}/sql_gql/save/`
export const TOOL_API = `${TOOL_PROXY}/api/`
// 单据流
export const AUDIT_BILLS = `${COMMON_UTIL_PROXY}/audit_bills/`
export const UN_AUDIT_BILLS = `${COMMON_UTIL_PROXY}/un_audit_bills/`
export const CLOSE_BILLS = `${COMMON_UTIL_PROXY}/close_bills/`
export const UN_CLOSE_BILLS = `${COMMON_UTIL_PROXY}/un_close_bills/`
export const SEND_BILLS = `${COMMON_UTIL_PROXY}/send_bills/`
export const UN_SEND_BILLS = `${COMMON_UTIL_PROXY}/un_send_bills/`
export const REJECT_BILLS = `${COMMON_UTIL_PROXY}/reject_bills/`
export const OAUTH_PROXY = 'OAUTH_PROXY'// `http://${api}/HSRight/api/`
export const TOOL_PROXY = 'TOOL_PROXY' // `http://${api}/Tool/api/`
export const HSRIGHT_TOOL_PROXY = 'HSRIGHT_TOOL_PROXY'// `http://${api}/HSRightTool/api/`
export const COMMON_UTIL_PROXY = 'COMMON_UTIL_PROXY' // `http://${api}/CommonUtil/api/`
export const COMMON_PROXY = 'COMMON_PROXY' // `http://${api}/`
export const GQL_PROXY = 'GQL_PROXY'// `http://${api}/GQL/api/`
export const FILE_RESOURCE_PROXY = 'FILE_RESOURCE_PROXY'// `http://${api}/fileresource/api/`
import { AUDIT_BILLS, UN_AUDIT_BILLS, CLOSE_BILLS, UN_CLOSE_BILLS, SEND_BILLS, UN_SEND_BILLS, REJECT_BILLS } from '../common/commonModule'
// 单据流类
class Billflow {
constructor(requestClient) {
this.requestClient = requestClient
this.moduleName = 'BillflowModule'
}
billHandleCommon(obj) {
const { data, type } = obj
let url = ''
switch (type) {
case 'billAudit':
url = `${AUDIT_BILLS}`
break
case 'billUnAudit':
url = `${UN_AUDIT_BILLS}`
break
case 'billSend':
url = `${SEND_BILLS}`
break
case 'billUnSend':
url = `${UN_SEND_BILLS}`
break
case 'billClose':
url = `${CLOSE_BILLS}`
break
case 'billUnClose':
url = `${UN_CLOSE_BILLS}`
break
case 'billReject':
url = `${REJECT_BILLS}`
break
}
return this.requestClient.post(url, data)
}
}
export default Billflow
import { COMMON_UTIL_PROXY } from '../common/commonProxy'
class Ref {
constructor(requestClient) {
this.moduleName = 'RefModule'
this.requestClient = requestClient
}
refItems(constId, parms) {
const url = `${COMMON_UTIL_PROXY}/ref/items/${constId}/`
return this.requestClient.get(url, parms)
}
refTable(tableName, columns, parms) {
const url = `${COMMON_UTIL_PROXY}/ref/table/${tableName}/${columns}/`
return this.requestClient.get(url, parms)
}
}
export default Ref
import { TOOL_API } from '../common/commonModule'
class RestFul {
constructor(requestClient) {
this.requestClient = requestClient
this.moduleName = 'RestFulModule'
}
query(data) {
const { tableName, appCode, group, parms, bodyData } = data
let url = `${TOOL_API}${appCode}/${tableName}/`
if (group) { // 非标准保存
url = `${url}${group}/`
}
if (bodyData) {
return this.requestClient.pust(url, bodyData, parms)
} else {
return this.requestClient.get(url, parms)
}
}
save(data) {
const { tableName, appCode, bodyData, group, parms } = data
let url = `${TOOL_API}${appCode}/${tableName}/`
if (group) { // 非标准保存
url = `${url}${group}/`
}
return this.requestClient.post(url, bodyData, parms)
}
queryOne(data) {
const { tableName, id, appCode, parms, group, bodyData } = data
let url_ = `${TOOL_API}${appCode}/${tableName}/${id}/`
if (group) {
url_ = `${url_}${group}/`
}
if (bodyData) {
return this.requestClient.put(url_, bodyData, parms)
} else {
return this.requestClient.get(url_, parms)
}
}
put(data) {
const { tableName, appCode, bodyData, group, parms } = data
let url = `${TOOL_API}${appCode}/${tableName}/`
if (group) { // 非标准保存
url = `${url}${group}/`
}
return this.requestClient.put(url, bodyData, parms)
}
queryList(data) {
const { tableName, appCode, parms, group, bodyData } = data
let url_ = `${TOOL_API}${appCode}/${tableName}/`
if (group) {
url_ = `${url_}${group}/`
}
parms.fuzzy = 1
if (bodyData) {
return this.requestClient.put(url_, bodyData, parms)
} else {
return this.requestClient.get(url_, parms)
}
}
deleteList(data) {
const { tableName, appCode, bodyData, parms } = data
const url_ = `${TOOL_API}${appCode}/${tableName}/`
return this.requestClient.delete(url_, bodyData, parms)
}
}
export default RestFul
import { TOOL_PROXY, FILE_RESOURCE_PROXY } from '../common/commonProxy'
class System {
constructor(requestClient, restfulClient) {
this.moduleName = 'SystemModule'
this.requestClient = requestClient
this.restfulClient = restfulClient
}
// 获取number个id
getNewId (number = 100) {
return this.requestClient.get(`${TOOL_PROXY}/common/new_id/${number}/`)
}
// 获取 动态中的action列表
queryBillpbWebDyncCode (data) {
const { appCode, pageName } = data
const params = {
parms: {
app_code: appCode,
page_name: pageName,
usable: 1
},
appCode: 'queryBi',
tableName: 'pbWebDyncCode'
}
return this.restfulClient.query(params)
}
// 获取 动态中的action列表
saveBillpbWebDyncCode (data) {
const params = {
bodyData: data,
appCode: 'queryBi',
tableName: 'pbWebDyncCode'
}
return this.restfulClient.save(params)
}
// 打印
printTask (data) {
const url = `${TOOL_PROXY}/common/print_task/`
return this.requestClient.post(url, data)
}
typePrintTask (data) {
const url = `${TOOL_PROXY}/common/print_task_by_bill_type/`
return this.requestClient.post(url, data)
}
// 上传文件
uploadFile (formData, app_code, tenant_code, config = {}) {
const parms = {
tenant_code
}
return this.requestClient.post(`${FILE_RESOURCE_PROXY}/file/${app_code}/`, formData, parms, null, config)
}
importExcel (data) {
data.group = 'import_excel'
return this.restfulClient.save(data)
}
exportExcelData (data) {
data.group = 'ExportExcel'
return this.restfulClient.queryList(data)
}
}
export default System
import jwtDecode from 'jwt-decode'
const fefresh_token_api = '/OAUTH_PROXY/token/fresh_token/'
const token_api = '/OAUTH_PROXY/token/'
class Token {
constructor(requestClient) {
this.moduleName = 'tokenModule'
this.subscribers = []
this.isRefreshing = false
this.requestClient = requestClient
// 监听消息webframe 发来的消息 设置token 并且刷新队列
window.addEventListener('message', (e) => {
if (self === top) return
if (!e.data) return
var type = e.data.type
var data = e.data.data
if (type === 'setToken') {
console.log('设置webframe传递过来的token', data)
// 设置token
this.setIframeToken(data)
// 通知本页面的请求重新请求
this.onAccessTokenFetched(data.token)
// 解决弹出框里面的iframe过期问题
this.notifyChildUpdateToken()
}
}, false)
}
setIframeToken(data) {
var token = data.token
sessionStorage['token'] = token
sessionStorage['refresh_token'] = data.refresh_token
}
// 恢复状态
cleanStatus() {
this.isRefreshing = false
this.subscribers = []
}
// 刷新token
async fefreshToken(token = sessionStorage['refresh_token']) {
const result = await this.requestClient.post(fefresh_token_api, {
refresh_token: token
})
const { access_token, token_type, refresh_token } = result.data
sessionStorage['refresh_token'] = refresh_token
sessionStorage['token'] = token_type + ' ' + access_token
return result
}
// 把当前请求推入到数组中存储起来
addSubscriber(callback) {
this.subscribers.push(callback)
}
// token刷新成功后 把存储起来的请求执行一次
onAccessTokenFetched(token) {
this.subscribers.forEach((callback) => {
callback(token)
})
this.cleanStatus()
}
async getToken() {
const result = await this.requestClient.post(token_api, {
'username': 'huansi',
'password': 'huansi',
company_code: 'hnchishan',
'company_id': '11',
'company_name': ''
}, {
tenant: 'wms',
type: '1'
})
}
// 处理401函数
hand401Meaage(config) {
if (!this.isRefreshing) {
this.isRefreshing = true
top.postMessage({
type: 'freshToken'
}, '*')
}
// 这个Promise函数很关键
const retryOriginalRequest = new Promise((resolve) => {
this.addSubscriber(() => {
resolve(this.requestClient.requestConfig(config))
})
})
return retryOriginalRequest
}
// 处理401函数
hand401MeaageWebframe(config) {
if (!this.isRefreshing) {
// 异步处理 token刷新成功后把缓存的请求全部刷新
this.fefreshToken().then(res => {
this.onAccessTokenFetched(res)
})
}
// 这个Promise函数很关键
const retryOriginalRequest = new Promise((resolve) => {
this.addSubscriber(() => {
resolve(this.requestClient.requestConfig(config))
})
})
return retryOriginalRequest
}
// 判断token是否过期
checkTokenExpire() {
const BearerToken = sessionStorage['token']
if (!BearerToken) return true
const access_token = BearerToken.slice(7, BearerToken.length)
const decodeTokenInfo = jwtDecode(access_token)
const { exp } = decodeTokenInfo
const now = Math.round(new Date() / 1000)
return now - exp > 0
}
// 判断过期自动刷新
async checkTokenRefreshToken() {
const resultCheck = this.checkTokenExpire()
if (resultCheck) {
await this.fefreshToken()
}
}
// 更新子iframe
async updateChildIframeToken() {
const resultCheck = this.checkTokenExpire()
if (resultCheck) {
await this.fefreshToken()
this.notifyChildUpdateToken()
}
}
notifyChildUpdateToken() {
const refresh_token = sessionStorage['refresh_token']
const token = sessionStorage['token']
const iframes = Array.from(document.getElementsByTagName('iframe'))
iframes.forEach(item => {
this.postMessageBycontentWindow(item.contentWindow, {
type: 'setToken',
data: {
refresh_token: refresh_token,
token: token
}
})
})
}
postMessageBycontentWindow(contentWindow, message) {
contentWindow.postMessage(message, '*')
}
}
export default Token
import { WEB_QUERY, WEB_QUERY_QUERY, WEB_QUERY_QUERY_VALUE, WEB_QUERY_PAGE } from '../common/commonModule'
import hsUtil from 'hs-util-js'
const urlParam = hsUtil.System.getUrlParams()
const { user_id } = hsUtil.System.parseGlobalParams()
class Control {
constructor(requestClient) {
this.requestClient = requestClient
this.moduleName = 'WebChartConfigModule'
}
// 处理传入的data 如果有appCode,pageName dbName
packParamHandle(parms) {
const { appCode, pageName, dbName, dbCode, userId } = parms
if (!appCode) {
parms.appCode = urlParam.appCode
}
if (!pageName) {
parms.pageName = urlParam.pageName
}
if (!dbName) {
parms.dbName = urlParam.dbName || ''
}
if (!dbCode) {
parms.dbCode = urlParam.dbCode || ''
}
if (!userId) {
parms.userId = user_id || 1
}
}
// 保存控件配置
/**
* sAppCode:页面appCode
* sPage:页面名称
* sControl:控件名称
* sControlType: 类型
* sQuerySql: sql语句
* bMockData: 是否是模拟数据
* iUserId:用户id
* db_name: 数据库名
* db_code:数据库code
* sConfig:控件配置
* sData: 数据
* @param {*} data
*/
webChartConfigSave(param) { // routerParms: page路由 position位置 other参数, sConfig 配置json sData 数据json
this.packParamHandle(param)
const { appCode, pageName, controlName, controlType, querySql, mockData, userId, dbName, dbCode, config, data } = param
const postData = {
exec_sql: `EXEC dbo.spappWebChartConfig_Save @sAppCode='${appCode}',@sPage='${pageName}',@sControl='${controlName}',@sControlType='${controlType || ''}',@sConfig=:sConfig,@sData=:sData,@sQuerySql='${querySql || ''}',@bMockData='${mockData || ''}',@iUserId=${userId || 1}`,
db_name: dbName,
db_code: dbCode,
param: {
sConfig: JSON.stringify(config),
sData: JSON.stringify(data)
}
}
return this.requestClient.post(WEB_QUERY, postData)
}
// 查询配置
/**
* sAppCode:页面appCode
* sPage:页面名称
* sControl:控件名称
* sControlType: 类型
* sQuerySql: sql语句
* bMockData: 是否是模拟数据
* iUserId:用户id
* db_name: 数据库名
* db_code:数据库code
* sConfig:控件配置
* sData: 数据
* @param {*} data
*/
webChartConfigQuery(data) {
this.packParamHandle(data)
const { appCode, pageName, controlName, userId, dbName, dbCode } = data
const postData = {
exec_sql: `EXEC dbo.spappWebChartConfig_Query @sAppCode='${appCode}',@sPage='${pageName}',@sControl='${controlName}',@iUserId='${userId}'`,
db_name: dbName,
db_code: dbCode
}
return this.requestClient.post(WEB_QUERY_QUERY, postData)
}
// 获取将要另存到本地的配置
webChartConfigSaveAs(data) {
this.packParamHandle(data)
const { appCode, pageName, dbName, dbCode } = data
const postData = {
exec_sql: `EXEC dbo.spappWebChartConfig_SaveAs @sAppCode='${appCode}',@sPage='${pageName}'`,
db_name: dbName,
db_code: dbCode
}
return this.requestClient.post(WEB_QUERY_QUERY_VALUE, postData)
}
// 另存配置
async saveAsDataToLocal(data) {
this.packParamHandle(data)
const { appCode, pageName } = data
const res = await this.webChartConfigSaveAs(data)
if (!res) return
this.download(`spappWebChartConfig_Upgrade_${appCode}_${pageName}.sql`, res.data)
}
download(name, data) {
var urlObject = window.URL || window.webkitURL || window
var downloadData = new Blob([data])
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a')
save_link.href = urlObject.createObjectURL(downloadData)
save_link.download = name
this.fake_click(save_link)
}
fake_click(obj) {
var ev = document.createEvent('MouseEvents')
ev.initMouseEvent(
'click', true, false, window, 0, 0, 0, 0, 0
, false, false, false, false, 0, null
)
obj.dispatchEvent(ev)
}
// 直接执行sql语句
execSql(data) {
this.packParamHandle(data)
const { execSql, dbName, dbCode } = data
const postData = {
exec_sql: execSql,
db_name: dbName,
db_code: dbCode
}
return this.requestClient.post(WEB_QUERY_QUERY, postData)
}
webChartConfigQueryLog(data) {
this.packParamHandle(data)
const { appCode, pageName, controlName, dbName, dbCode } = data
const postData = {
exec_sql: `EXEC dbo.spappWebChartConfig_QueryLog @sAppCode='${appCode}',@sPageName='${pageName}',@sControlName='${controlName}'`,
db_name: dbName,
db_code: dbCode
}
return this.requestClient.post(WEB_QUERY_QUERY, postData)
}
webChartConfigRevert(data) {
this.packParamHandle(data)
const { appCode, pageName, dbName, dbCode, controlName, version } = data
const postData = {
exec_sql: `EXEC dbo.spappWebChartConfig_Revert @sAppCode='${appCode}',@sPageName='${pageName}',@sControlName='${controlName}',@iVersion='${version}'`,
db_name: dbName,
db_code: dbCode
}
return this.requestClient.post(WEB_QUERY, postData)
}
// 控件配置查询
webControlQuery(data) {
this.packParamHandle(data)
const { dbName, pageName, param, appCode, controlName, returnType, dbCode, userId } = data
const postData = {
db_name: dbName,
app_code: appCode,
page: pageName,
param: JSON.stringify(param || {}),
control_name: controlName,
return_type: returnType || 3,
db_code: dbCode,
user_id: userId
}
return this.requestClient.post(WEB_QUERY_PAGE, postData)
}
}
export default Control
import { WEB_QUERY_QUERY, WEB_QUERY_PAGE } from '../common/commonModule'
class WebQuery {
constructor(requestClient) {
this.requestClient = requestClient
this.moduleName = 'webQuery'
}
webQuery(data, params, header) {
return this.requestClient.post(WEB_QUERY_QUERY, data, params, header)
}
queryPage(data, params, header) {
return this.requestClient.post(WEB_QUERY_PAGE, data, params, header)
}
}
export default WebQuery
import axios from 'axios'
class Root {
filterEmptyValue(obj) {
if (!obj) return
const emptyValues = [null, undefined, 'null', 'undefined', NaN]
for (const k in obj) {
if (emptyValues.includes(obj[k])) {
console.log(`数据中有空值${k}`, obj[k])
delete obj[k]
} else if (typeof obj[k] === 'object') {
return this.filterEmptyValue(obj[k])
}
}
}
get(url, params, headers, config) {
return this.request('get', url, null, params, headers, config)
}
post(url, data, params, headers, config) {
return this.request('post', url, data, params, headers, config)
}
put(url, data, params, headers, config) {
return this.request('put', url, data, params, headers, config)
}
delete(url, data, params, headers, config) {
return this.request('delete', url, data, params, headers, config)
}
requestConfig(config) {
return axios(config)
}
request(method, url, data, params, headers = null, config = {}) {
this.filterEmptyValue(data)
// 公共头设置
const aixosCtx = { method, url, ...config }
params && (aixosCtx.params = params)
if (aixosCtx.params && aixosCtx.params.token) delete aixosCtx.params.token
if (aixosCtx.params && aixosCtx.params._user_info) delete aixosCtx.params._user_info
data && (aixosCtx.data = data)
headers && (aixosCtx.headers = headers)
const result = axios(aixosCtx)
return result
}
}
export default Root
import Root from './root'
import Billflow from './packages/modules/billflow'
import WebChartConfig from './packages/modules/webChartConfig'
import Restful from './packages/modules/restful'
import System from './packages/modules/system'
import TokenTool from './packages/modules/tokenTool'
import WebQueryClient from './packages/modules/webQueryClient'
import Ref from './packages/modules/ref'
const root = new Root()
const restful = new Restful(root)
const webQueryClient = new WebQueryClient(root)
const billflow = new Billflow(root)
const system = new System(root, restful)
const tokenTool = new TokenTool(root)
const webChartConfig = new WebChartConfig(root)
const ref = new Ref(root)
const list = [webQueryClient, billflow, system, tokenTool, webChartConfig, restful, ref]
const api = {
}
list.forEach(item => {
api[item.moduleName] = item
})
const root_prototype = root.__proto__
const root_prototype_keys = Object.getOwnPropertyNames(root_prototype)
root_prototype_keys.forEach(k => {
if (k !== 'constructor') {
api[`${k}`] = root_prototype[k]
}
})
export default api
import Vue from 'vue'
import ElementUI from 'element-ui'
Vue.use(ElementUI)
import 'element-ui/lib/theme-chalk/index.css'
const requireComponent_ = require.context('./', true, /index.vue$/)
const obj = {}
const install = function(Vue) {
......@@ -16,5 +12,16 @@ const install = function(Vue) {
}
})
}
// if (typeof window !== 'undefined' && window.Vue || Vue) {
// install(window.Vue || Vue);
// }
// requireComponent_.keys().forEach(fileName => {
// const componentConfig = requireComponent_(fileName)
// const { name } = componentConfig.default
// if (name) {
// Vue.component(name, componentConfig.default || componentConfig)
// obj[name] = componentConfig
// }
// })
obj.install = install
export default obj
This diff is collapsed.
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