Commit b51582e9 by 前端

Merge branch 'kyq_dev' into 'master'

src提交

See merge request !1
2 parents 945e0e26 f05ea3ce
import RequestMethods from './request.methods'
import axios from 'axios'
import qs from 'qs'
// import GlsxVueCommon from 'glsx-vue-common'
import sign from './sign'
import {
GlAxios
} from 'glsx-vue-common'
const request = (params = {}, method = RequestMethods.GET, noSignAttr = [], url = '') => {
params.source = 'glsx-oss-merchant-data'
params.appKey = '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime()
params.v = '1.0.0'
params.format = 'json'
// params.createBy = this.$get_session_config().user.id
var data = sign(params, noSignAttr)
if (url) {
return axios.post(`${url}/router?method=${method}`, qs.stringify(data))
}
return method === RequestMethods.GET ? GlAxios.get('router', {
params: sign(params, noSignAttr)
}) : GlAxios.post('router', data)
}
export default request
const RequestMethods = {
POST: 'post',
GET: 'get',
PUT: 'put',
DELETE: 'delete'
}
export default RequestMethods
import sha1 from 'sha1'
import qs from 'qs'
import _ from 'lodash'
const secret = window.location.href.includes('dj.glsx.com.cn') ? '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353' : 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const sign = (params, noSignAttr = []) => {
delete params.sign
var objStr = qs.stringify(_.cloneDeep(params), {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
export default sign
import request from './request'
const path = 'merchants.api.accountype.'
const accountApi = {
/** 账户类型分页数据*/
getPageApi(data = {}) {
data.method = `${path}page`
return request(data)
}
}
export { accountApi }
import request from './request'
const uploadApi = {
// 多文件上传接口
multipleUpload(data = {}) {
// 'http://192.168.1.182:8561/rop-scrm-renewal'
data.method = 'scrm.api.renewal.common.upload.common.multiple'
// return request(data, 'scrm.api.equity.common.upload.common.multiple', [], 'http://scrm.test.glsx.com.cn/rop-scrm-renewal')
return request(data, 'post')
}
}
export { uploadApi }
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import GlsxVueComponents from 'glsx-vue-components'
// import 'glsx-vue-components/dist/glsx-vue-components.css'
import { Request as request } from 'glsx-vue-common'
import '@/styles/index.css'
// 组件
import '@/components'
import { Util } from './common/util'
// import _ from 'lodash'
// import axios from 'axios'
Vue.prototype.btn_size = 'mini'
Vue.prototype.$Utils = Util
Vue.use(ElementUI)
var mixin = {
data() {
return {
eventBus: new Vue()
}
},
mounted() {
const _this = this
const theme = new this.$Theme()
const connection = this.$Penpal.connectToParent({
methods: {
setTheme(color) {
theme.change(color)
},
height() {
return document.height || document.body.offsetHeight // document.documentElement.clientHeight || document.body.clientHeight //
},
translate(params) {
_this.eventBus.$emit('params', params)
}
}
})
connection.promise.then(parent => {
const cfg = _this.$get_session_config()
_this.$$parent = parent
if (cfg) return
parent.getResources().then(config => {
_this.$set_session_config(config)
})
})
},
methods: {
/**
* 页面跳转方法 用法 :
* this.$root.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
* 或:
* this.$parent.to(['MOCK系统A', '一键导航', '导航数据', 'MOCK数据B', 'localhost'],'1123')
*
* @param {*} path 如: ['一级菜单名称','二级菜单名称','三级菜单名称','四级菜单名称','五级菜单名称']
* @param {*} params 传给下一个页面的参数
*/
to(path, params) {
if (this.$$parent) {
this.$$parent.to(path, params)
} else {
this.$$connection.promise.then(parent => {
parent.to(path, params)
})
}
},
close() {
this.$$parent.close()
}
}
}
const URL =
'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config'
const getConfig = (url = URL + '/renwal-config') => {
return new Promise((resolve, reject) => {
request({ url }).then(res => {
if (res.status === 'success') {
resolve({ vue: Vue, config: JSON.parse(res.data) })
} else {
reject('ERROR.')
}
})
})
}
/* eslint-disable no-new */
const render = App => {
window.vm = new Vue({
el: '#app',
mixins: [mixin],
render: h => h(App)
})
}
export default { render, getConfig }
import Vue from 'vue'
export const Util = {
getExplorer: function() {
var ua = navigator.userAgent.toLocaleLowerCase()
var browserType = null
if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
browserType = 'IE'
} else if (ua.match(/firefox/) != null) {
browserType = '火狐'
} else if (ua.match(/ubrowser/) != null) {
browserType = 'UC'
} else if (ua.match(/opera/) != null) {
browserType = '欧朋'
} else if (ua.match(/bidubrowser/) != null) {
browserType = '百度'
} else if (ua.match(/metasr/) != null) {
browserType = '搜狗'
} else if (
ua.match(/tencenttraveler/) != null ||
ua.match(/qqbrowse/) != null
) {
browserType = 'QQ'
} else if (ua.match(/maxthon/) != null) {
browserType = '遨游'
} else {
browserType = '谷歌'
}
return browserType
},
exportFn: function(url) {
console.log(url)
let browserType = getExplorer()
if (browserType == 'QQ') {
window.open(url)
return
}
let iframe = document.createElement('iframe')
console.log(iframe)
iframe.style.display = 'none'
iframe.src = url
document.body.appendChild(iframe)
console.log(document.body)
}
}
export const getExplorer = Util.getExplorer
export const exportFn = Util.exportFn
<!-- 表格+分页 -->
<template>
<div class="d2-table">
<el-table
:ref="tableParams.mutiSelectName + 'MutiTable' || 'MutiTable'"
:data="getListApi ? data : tableData"
:row-key="tableParams.mutiSelectUniqueKey || ''"
v-loading="loading"
border
:highlight-current-row="true"
:stripe="true"
@sort-change="sortChange"
@selection-change="handleSelect"
size="medium"
>
<el-table-column
v-if="tableParams.mutiSelectUniqueKey && tableParams.mutiSelectName"
type="selection"
width="55"
:reserve-selection="true"
>
</el-table-column>
<el-table-column
v-if="hasNum"
align="center"
width="60px"
label="序号"
type='index'
:index="index=>index+(page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1"
></el-table-column>
<el-table-column
v-for="(item, index) in tableParams.tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item.minWidth"
:align="item.align||'center'"
:sortable="item.sortable"
>
<template slot-scope="scope">
<slot
v-if="item.addHtml"
:name="item.addHtml"
:scope="scope.row"
:prop="item.prop"
:width="item.width"
></slot>
<template v-else-if="item.tagLabel">
<el-tag
v-if="!item.tagName"
:type="tableParams.tag.type[scope.row[item.prop]]"
v-text="tableParams.tag.label[scope.row[item.prop]]"
>
</el-tag>
<el-tag
v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]"
v-text="tableParams[item.tagName].label[scope.row[item.prop]]"
></el-tag>
</template>
<template v-else-if="item.formatter">
<span v-text="item.formatter(scope.row)"></span>
</template>
<template v-else-if="getListApi">
<span v-text="scope.row[item.prop]"></span>
</template>
<template v-else>
<span v-text="tableData[scope.$index][item.prop]"></span>
</template>
<template v-if="item.addSymbol">
<span v-text="item.addSymbol"></span>
</template>
</template>
</el-table-column>
<el-table-column
v-if="tableParams.tableOption"
label="操作"
:align="tableParams.tableOption.align||'center'"
:width="tableParams.tableOption.width||'200'"
fixed="right"
>
<template slot-scope="scope">
<slot
name="auth-button"
:scope="scope.row"
></slot>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="hasPage"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page[this.pageConf.pageNum]"
:page-sizes="[10,20,30,40]"
:page-size="page[this.pageConf.pageSize]"
:total="getListApi ? total : tableTotal"
:layout="layout"
>
</el-pagination>
</div>
</template>
<script>
export default {
name: 'd2-table',
data() {
return {
loading: false,
data: [],
// 页码
page: {},
total: 10,
// 排序
sortColum: '',
sort: '',
// 多选数组
mutiSelectArr: {}
}
},
props: {
// 搜索条件
searchForm: {
type: Object,
default: () => {}
},
// 表格数据-外部传入
tableData: {
type: Array,
default: () => []
},
tableTotal: {
type: Number,
default: 0
},
// 获取列表接口
getListApi: {
type: Function,
default: null
},
// 搜索前操作
beforeSearchFn: {
type: Function,
default: () => {
return new Promise((resolve, reject) => {
resolve()
})
}
},
// 分页,默认有
hasPage: {
type: Boolean,
default: true
},
pageConf: {
type: Object,
default: () => ({
pageSize: 'pageSize',
pageNum: 'pageNum',
totalCount: 'totalCount'
})
},
// 分页组件配置
layout: {
type: String,
default: 'sizes,total,->,prev,pager,next,jumper'
},
// 序号,默认有
hasNum: {
type: Boolean,
default: true
},
tableParams: {
type: Object,
default: () => {
return {
// 多选-判断来自哪个页面
// mutiSelectName: {
// type: String,
// default: ''
// },
// 多选-唯一标识
// mutiSelectUniqueKey: {
// type: String,
// default: ''
// },
// 搜索按钮id;new Date().getTime() + parseInt(Math.random() * 1000)
// btnId: {
// type: String,
// default: ''
// },
// 后端返回列表参数名
listName: {
type: String,
default: ''
},
// 标签-默认标签名为tag;若有多个,那么需要在表格栏的列中加“tagName”
// tag: {
// type: Array,
// default: () => []
// },
// 表格操作,默认没有
// tableOption: {
// type: Object,
// default: null
// },
// 表格栏
tableColumns: {
type: Array,
default: () => []
}
}
}
}
},
mounted() {
this.page = {}
this.page[this.pageConf.pageSize] = 10
this.page[this.pageConf.pageNum] = 1
const btn = document.getElementById(this.tableParams.btnId)
btn && btn.addEventListener('click', this.refreshEmit)
this.getListApi && this.refreshTable()
},
methods: {
// 排序
sortChange({ column, prop, order }) {
this.sortColum = order ? prop : ''
this.sort = order
this.refreshTable()
},
// 多选
handleSelect(val) {
this.mutiSelectArr[this.tableParams.mutiSelectName] = val
},
// 清空多选
clearMutiSelect() {
this.mutiSelectArr[this.tableParams.mutiSelectName] = []
this.$refs[this.tableParams.mutiSelectName + 'MutiTable'].clearSelection()
},
// 发布事件,以期查询条件改变后,页面图表需要刷新
refreshEmit() {
this.$emit('searchChange')
this.refreshTable(true, true)
},
refreshTable(clearMuti = true, resetPageNum = false) {
this.beforeSearchFn().then(res => {
// 清空多选
clearMuti && this.clearMutiSelect()
this.loading = true
resetPageNum && (this.page.pageNum = 1)
var params = {
...this.page,
...this.searchForm
}
if (this.sort) {
params.sortColum = this.sortColum
params.sort = this.sort === 'descending' ? 1 : 0
}
this.getListApi(params)
.then(res => {
console.log(res)
this.data = this.findVal(res, this.tableParams.listName)
this.total = this.findVal(res, this.pageConf.totalCount)
this.loading = false
})
.catch(() => {
this.loading = false
})
})
},
// 找返回值
findVal(res, rankStr, attr) {
var rankList = rankStr.split('.')
if (!rankStr) {
return res
}
return this.findVal(res[rankList[0]], rankList.splice(1).join('.'), attr)
},
// 每页条数
handleSizeChange(value) {
this.page[this.pageConf.pageSize] = value
this.getListApi
? this.refreshTable(false)
: this.$emit('refreshTable', this.page)
},
// 页码
handleCurrentChange(value) {
this.page[this.pageConf.pageNum] = value
this.getListApi
? this.refreshTable(false)
: this.$emit('refreshTable', this.page)
}
}
}
</script>
<style>
.a-click {
cursor: pointer;
}
.el-table{
margin-bottom: 16px;
}
.el-table .cell {
line-height: 14px;
}
.d2-table p {
margin: 10px 0;
}
</style>
import Vue from 'vue'
// 注意 有些组件使用异步加载会有影响
Vue.component('d2-table', () => import('./d2-table/index.vue'))
body {
overflow: auto;
height: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
}
html {
height: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#app {
height: 100%;
}
*,
*:before,
*:after {
-webkit-box-sizing: inherit;
box-sizing: inherit;
}
hr {
height: 1px;
border: 0px;
background-color: #e7eaec;
}
a,
a:focus,
a:hover {
cursor: pointer;
color: inherit;
outline: none;
text-decoration: none;
}
div:focus {
outline: none;
}
a:focus,
a:active {
outline: none;
}
a,
a:focus,
a:hover {
cursor: pointer;
color: inherit;
text-decoration: none;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.app-main {
overflow: auto;
}
.app-container {
padding: 20px;
}
.el-table--medium td {
padding: 4px 0 !important;
}
.el-table .cell {
padding: 0 0;
}
.dot {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 5px;
vertical-align: middle;
margin-right: 2px;
}
.statusText {
vertical-align: middle;
}
.w-300 {
width: 300px;
}
\ No newline at end of file
import App from './app.vue'
import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common'
base.getConfig().then(data => {
const { vue, config } = data
vue.use(GlsxVueCommon, config)
base.render(App)
})
<template>
<div id="app" class="outsider">
<gl-card class="index-card">
<div slot="header">
广联运营平台
</div>
<ul>
<li>
<a href="../insurance/customer.html" target="_self">
客户名单管理列表
</a>
</li>
<li>
<a href="../insurance/order.html" target="_self">
订单管理列表
</a>
</li>
</ul>
</gl-card>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style scoped>
.outsider{
background-color: #FFF;
padding: 20px 0px 40px 0px;
/* margin: 20px 20px; */
}
</style>
import App from './index.vue'
import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common'
base.getConfig().then(data => {
const { vue, config } = data
vue.use(GlsxVueCommon, config)
base.render(App)
})
<template>
<div>任务中心顶顶顶顶11111</div>
</template>
<script>
export default {}
</script>
<style>
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!