Commit 232e3b4e by cwq0219
2 parents e21b53b1 efbe6848
......@@ -9,8 +9,10 @@
},
"dependencies": {
"axios": "^0.18.0",
"glsx-vue-common": "^1.1.14",
"glsx-vue-common": "^1.2.1",
"blueimp-md5": "^2.10.0",
"glsx-vue-components": "^1.0.13",
"js-md5": "^0.7.3",
"node-sass": "^4.9.3",
"sass-loader": "^7.1.0",
"vee-validate": "^2.1.7",
......
import {
GlAxios
} from 'glsx-vue-common'
const path = '/glsx.accounts.admin.merchant.'
const __sGetList = `${path}search`
const __sDetail = `${path}detail`
const __sPersonal = `${path}personal`
const __sGroup = `${path}group`
const __sSaveMerchant = `${path}create`
const __sLevel = `${path}group.level`
// 获取商户列表(根据条件获取商户列表)
const getList = {
p: [__sGetList],
req: params => GlAxios.get(__sGetList, {
params
})
const methods = {
Search: `${path}search`,
Detail: `${path}detail`,
Personal: `${path}personal`,
Group: `${path}group`,
Create: `${path}create`,
GroupLevel: `${path}group.level`
}
// 获取商户详情(通过商户id获取商户详情)
const merchantDetail = {
p: [__sDetail],
req: params => GlAxios.get(__sDetail, {
params
})
}
// 获取员工信息(通过商户id获取员工信息)
const merchantPersonal = {
p: [__sPersonal],
req: params => GlAxios.get(__sPersonal, {
params
})
}
// 获取分组信息(通过商户id获取分组信息)
const merchantGroup = {
p: [__sGroup],
req: params => GlAxios.get(__sGroup, {
params
})
}
// 新增商户
const saveMerchant = {
p: [__sSaveMerchant],
req: params => GlAxios.get(__sSaveMerchant, {
params
})
}
// 根据分组跟商户查询父子商户
const merchantGroupLevel = {
p: [__sLevel],
req: params => GlAxios.get(__sLevel, {
params
})
}
export {
getList,
merchantDetail,
merchantPersonal,
merchantGroup,
saveMerchant,
merchantGroupLevel
methods
}
import {
getBusinessList
} from './businessManagement'
GlAxios
} from 'glsx-vue-common'
import { sign } from './sign'
import {
getList,
merchantDetail,
merchantPersonal,
merchantGroup,
saveMerchant,
merchantGroupLevel
methods as bizMethods
} from './bussinessListApi'
const request = {
req: params => {
const url = process.env.NODE_ENV === 'production' ? 'router' : params.methods
return GlAxios.get(url, { 'params': sign(params) })
}
}
export {
getBusinessList,
getList,
merchantDetail,
merchantPersonal,
merchantGroup,
saveMerchant,
merchantGroupLevel
bizMethods,
request
}
import MD5 from 'js-md5'
const sign = params => {
const secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const keys = Object.keys(params).sort()
var str = []
keys.forEach(e => {
str.push(e + params[e])
})
params.sign = MD5(secret + str.join('') + secret)
return params
}
export {
sign
}
......@@ -44,7 +44,7 @@
<script>
import SearchDialog from './SearchDialog'
import AddDialog from './AddDialog'
import { getList, saveMerchant } from '@/api/bussinessListApi'
import { bizMethods, request } from '@/api'
import notice from '@/common/notice'
export default {
name: 'businessList',
......@@ -149,7 +149,8 @@ export default {
// 接口请求-start
getList() {
const params = this.getParams()
getList.req(params).then(res => {
params.methods = bizMethods.Search
request.req(params).then(res => {
this.ListTableData.data = res.merchants
this.total = res.pagination.totalCount
this.reset(this.merchantSearch)
......@@ -160,7 +161,7 @@ export default {
})
},
saveMerchant() {
saveMerchant.req(this.merchantForm).then(res => {
request.req(this.merchantForm).then(res => {
notice.okTips()
this.reset(this.merchantForm)
}).catch(err => {
......
......@@ -54,7 +54,7 @@
>{{ errorBags.first('businessDescription') }}</span>
</gl-form-item>
<gl-form-item label="地址">
<city-area @cityArea="getCityArea"></city-area>
<city-area ref="c" :showCity="showCity" :eventBus="$root.eventBus" :validateCity="validateCity" @cityArea="getCityArea"></city-area>
</gl-form-item>
</gl-form>
<div
......@@ -77,7 +77,7 @@
<script>
import { CityArea } from '../components'
import addBusiness from './addBusiness'
import { jumpLink } from '../../../common/common.js'
// import { jumpLink } from '../../../common/common.js'
export default {
name: 'BusinessManagement',
components: {
......@@ -85,7 +85,6 @@ export default {
CityArea
},
data() {
const _this = this
return {
tableData: {
border: true,
......@@ -151,19 +150,45 @@ export default {
businessDescription: [{ required: true }]
},
// 商户分组组件数据
addDialogVisible: false
addDialogVisible: false,
// 省市区
showCity: [1, 1],
validateCity: [1, 1]
}
},
provide() {
return {
$validator: this.$validator
}
},
watch: {
dialogFormVisible(val) {
if (val) {
this.form = { businessName: '', businessDescription: '', area: '' }
} else {
this.$validator.errors.clear()
this.$refs['c'].$validator.errors.clear()
}
},
'this.$root.eventBus'(val) {
console.log(val,11212)
if (val) {
this.$root.eventBus.$emit('reset')
}
}
},
methods: {
// 显示隐藏弹窗
showDialog() {
this.dialogFormVisible = !this.dialogFormVisible
this.$validator.errors.clear()
},
// 提交表单
submit() {
this.$validator.validateAll().then((result) => {
if (result) {
Promise.all([
this.$refs['c'].$validator.validateAll(),
this.$validator.validateAll()
]).then((result) => {
if (result[0] && result[1]) {
console.log('提交成功')
console.log(this.form)
this.showDialog()
......
<template>
<!-- <div> -->
<gl-row
style="margin-left: 0"
:gutter="10"
>
<gl-col :span="8">
:gutter="10">
<gl-col :span="showCity[2] ? 8 : showCity[1] ? 12 : 24">
<gl-select
v-show="showCity[0]"
filterable
clearable
v-model="province"
name="province"
v-validate="validateCity[0] ? 'required' : false"
data-vv-as="省"
@change="selectProvince"
placeholder="请选择省"
>
placeholder="请选择省">
<gl-option
v-for="(item, k) in provinceList"
:key="k"
:label="item.provinceName"
:value="item.provinceId"
>
:value="item.provinceId">
</gl-option>
</gl-select>
<span v-show="errorBags.has('province')" class="error">{{ errorBags.first('province') }}</span>
</gl-col>
<gl-col :span="8">
<gl-col :span="showCity[2]? 8 : 12">
<gl-select
v-show="showCity[1]"
filterable
clearable
v-model="city"
name="city"
v-validate="validateCity[1] ? 'required' : false"
data-vv-as="市"
@change="selectCity"
placeholder="请选择市"
>
placeholder="请选择市">
<gl-option
v-for="item in cityList"
:key="item.cityId"
:label="item.cityName"
:value="item.cityId"
>
:value="item.cityId">
</gl-option>
</gl-select>
<span v-show="errorBags.has('city')" class="error">{{ errorBags.first('city') }}</span>
</gl-col>
<gl-col :span="8">
<gl-col :span="showCity[2]? 8 : 12">
<gl-select
v-show="showCity[2]"
filterable
clearable
v-model="area"
name="area"
v-validate="validateCity[2] ? 'required' : false"
data-vv-as="区"
@change="selectArea"
placeholder="请选择区"
>
placeholder="请选择区">
<gl-option
v-for="item in areaList"
:key="item.areaId"
:label="item.areaName"
:value="item.areaId"
>
:value="item.areaId">
</gl-option>
</gl-select>
<span v-show="errorBags.has('area')" class="error">{{ errorBags.first('area') }}</span>
</gl-col>
</gl-row>
<!-- </div> -->
</template>
<script>
export default {
name: 'CityArea',
inject: ['$validator'],
data() {
return {
AllData: [],
......@@ -72,72 +79,81 @@ export default {
city: '', // 市值
area: '', // 区值
mutIndex: [], // 存储下标
mutArray: [] //
mutArray: [] // 传值给父组件的数组
}
},
props: {
// value: Array
showCity: Array,
validateCity: Array,
eventBus: Object
},
mounted() {
const URL = ' http://192.168.3.171:7300/mock/5be17454f31545347559d499/config'
const getConfig = (url = URL + '/area_config') => {
return new Promise(resolve => {
const xhr = new XMLHttpRequest()
xhr.onreadystatechange = () => {
if (xhr.readyState === 4 && xhr.status === 200) {
resolve({ 'config': JSON.parse(xhr.responseText) })
}
watch: {
// 监听省市被clear清空市区数组
province(val) {
console.log(val)
!val ? this.cityList = [] && (this.areaList = []) : false
},
city(val) {
!val ? this.areaList = [] : false
},
eventBus: {
handler(__eventBus) {
if (__eventBus) {
__eventBus.$on('reset', () => {
console.log('虫豸')
})
}
xhr.open('GET', url)
xhr.send()
})
}
}
},
mounted() {
console.log(this.showCity)
// 初始化
getConfig().then(data => {
console.log(data.config)
this.AllData = JSON.parse(JSON.stringify(data.config.provinceInfoList))
this.$request({ url: 'http://192.168.3.171:7300/mock/5be17454f31545347559d499/config/area_config' }).then(data => {
this.AllData = JSON.parse(data.data).provinceInfoList
this.AllData.forEach(element => {
this.provinceList.push({ provinceId: element.provinceId, provinceName: element.provinceName })
})
this.getCity(0)
this.getArea(0, 0)
// this.getCity(0)
// this.getArea(0, 0)
})
},
methods: {
// 选择省
selectProvince(val) {
this.mutArray = [val, , ]
this.mutArray = [val, null, null]
this.AllData.forEach((element, index) => {
if (element.provinceId === val) {
this.mutIndex[0] = index
}
})
this.mutIndex[1] = ''
this.mutIndex[2] = ''
this.getCity(this.mutIndex[0])
this.getArea(this.mutIndex[0], 0)
// this.getArea(this.mutIndex[0], 0)
// 选择省清空已选的市区value
this.city = ''
this.area = ''
this.$emit('cityArea', this.mutArray)
},
// 选择市
selectCity(val) {
this.mutArray[1] = val
this.mutArray[2] = ''
this.mutArray[2] = null
const i = this.mutIndex[0]
this.AllData[i].cityInfoList.forEach((element, index) => {
if (element.cityId === val) {
this.mutIndex[1] = index
}
})
this.getArea(this.mutIndex[0], this.mutIndex[1])
val ? this.getArea(this.mutIndex[0], this.mutIndex[1]) : false
this.area = ''
val ? this.$emit('cityArea', this.mutArray) : false
val ? this.$emit('cityArea', this.mutArray) : false
},
// 选择区
selectArea(val) {
this.mutArray[2] = val
val ? this.$emit('cityArea', this.mutArray) : false
val ? this.$emit('cityArea', this.mutArray) : false
},
// 获取市
getCity(index) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!