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