Commit 95fca181 by 胡悦

Merge branch 'master' of 192.168.3.233:glsx-web/glsx-oss-account

2 parents 436c4193 e86bcbbe
import request from './request'
const path = 'cn.com.glsx.merchants.'
export const baseApi = {
// 获取所有产品
getAllProduct(data = {}) {
data.method = `${path}product.findProduct`
return request(data)
},
// 所有字典
getAllDictApi(data = {}) {
data.method = `${path}menu.findAllDictData`
return request(data)
},
// 所有菜单树
getMenuTree(data = {}) {
data.method = `${path}menu.findMerProMenuTreeRemote`
return request(data)
}
}
// 产品
export const productApi = {
/** 获取财务管理列表*/
getListApi(data = {}) {
data.method = `${path}product.findProductByPage`
return request(data)
},
/** 新增产品 */
saveProApi(data = {}) {
data.method = `${path}product.saveProduct`
return request(data)
}
}
// 菜单
......
......@@ -2,8 +2,9 @@
<template>
<div class="glsx-combi-form">
<el-form
:ref="formRef"
:inline="true"
v-model="formObj"
:model="formObj"
:label-width="labelWidth"
:rules="formRules"
size="small"
......@@ -25,6 +26,8 @@
:maxlength="item.maxlength"
:clearable="item.isClear || false"
:type="item.inputType || 'text'"
:style="{ width: item.width || 'auto' }"
:show-word-limit="item.showLimit || false"
@keydown.native="e => handleInputDown(e, item)"
></el-input>
<!-- 选择-输入框 -->
......@@ -167,6 +170,10 @@ export default {
},
props: {
formRef: {
type: String,
default: 'formRef'
},
labelWidth: {
type: String,
default: '85px'
......
<!-- 所属客户群体 - 组件 -->
<template>
<div class="flex">
<el-select
v-model="form[targetItem.name]"
:placeholder="'请选择'"
@change="handleTopChange"
>
<el-option
v-for="subItem in optionList"
:key="subItem[targetItem.optionId]"
:label="subItem[targetItem.optionLabel]"
:value="subItem[targetItem.optionId]"
></el-option>
</el-select>
<el-input
v-show="['3'].includes(form[targetItem.name])"
v-model="form.ownCusSub"
placeholder="请输入商户/门店ID"
></el-input>
<el-select
v-show="['1', '2', '4'].includes(form[targetItem.name])"
v-model="form.ownCusSub"
:multiple="targetItem.multiple || false"
>
<el-option
v-for="subItem in baseData[attrToList[form[targetItem.name]]]"
:key="subItem.dictValue"
:label="subItem.dictLabel"
:value="subItem.dictValue"
></el-option>
</el-select>
</div>
</template>
<script>
export default {
name: 'OwnCusCom',
data() {
return {
subVal: {
input: '',
mutiSelect: []
},
// 下拉框对应List
attrToList: {
'1': 'accounTypetList',
'2': 'accountLevelList',
'4': 'accountRoleList'
}
}
},
props: {
targetItem: {
type: Object,
default: () => { }
},
form: {
type: Object,
default: () => { }
},
optionList: {
type: Array,
default: () => []
},
baseData: {
type: Object,
default: () => { }
}
},
mounted() {
// console.log(this.targetItem)F
},
methods: {
handleTopChange() {
this.form.ownCusSub = ['3'].includes(this.form[this.targetItem.name]) ? '' : []
}
}
}
</script>
<style scoped>
.flex {
display: flex;
}
</style>
\ No newline at end of file
<!-- 树形搜索 -->
<template>
<div>
<el-popover
ref="popover"
placement="bottom-start"
trigger="click"
@show="onShowPopover"
@hide="onHidePopover"
>
<el-tree
ref="tree"
class="select-tree"
highlight-current
:style="`min-width: ${treeWidth}`"
:data="treeData"
:props="defaultProps"
:filter-node-method="handleFilterNode"
@node-click="handleNodeClick"
></el-tree>
<el-input
slot="reference"
ref="input"
v-model="form[targetItem.name]"
clearable
:style="`width: ${width}px`"
:class="{ 'rotate': showStatus }"
suffix-icon="el-icon-arrow-down"
:placeholder="'请选择' + targetItem.label"
>
</el-input>
</el-popover>
</div>
</template>
<script>
export default {
name: 'SelectTree',
data() {
return {
// 输入框显示值
labelModel: '',
// 树状菜单显示状态
showStatus: false,
treeWidth: 'auto'
}
},
props: {
// 输入框宽度
width: String,
form: {
type: Object,
default: () => { }
},
targetItem: {
type: Object,
default: () => { }
},
treeData: {
type: Array,
default: () => []
},
defaultProps: {
type: Object,
default: () => ({
parent: 'parentId',
value: 'rowGuid',
label: 'areaName',
children: 'children'
})
}
},
// watch: {
// labelModel(val) {
// if (!val) {
// this.valueModel = ''
// }
// this.$refs.tree.filter(val)
// },
// value(val) {
// this.labelModel = this.queryTree(this.data, val)
// }
// },
created() {
// 检测输入框原有值并显示对应 label
if (this.value) {
this.labelModel = this.queryTree(this.data, this.value)
}
// 获取输入框宽度同步至树状菜单宽度
this.$nextTick(() => {
this.treeWidth = `${(this.width || this.$refs.input.$refs.input.clientWidth) - 24}px`
})
},
mounted() { },
methods: {
// 显示时触发
onShowPopover() {
this.showStatus = true
// this.$refs.tree.filter(false)
},
// 隐藏时触发
onHidePopover() {
this.showStatus = false
},
// 树节点过滤方法
handleFilterNode(query, data) {
if (!query) return true
return data[this.defaultProps.label].indexOf(query) !== -1
},
handleNodeClick(val) {
this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName })
}
}
}
</script>
<style>
.el-input.el-input--suffix.rotate .el-input__suffix .el-icon-arrow-down {
transform: rotate(-180deg);
}
/* .select-tree {
max-height: 350px;
overflow-y: scroll;
} */
</style>
\ No newline at end of file
import App from './index.vue'
import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common'
const Apps = require.context('./', false, /\.vue$/)
Apps.keys().map(item => {
base.getConfig().then(data => {
const {
vue,
config
} = data
vue.use(GlsxVueCommon, config)
base.render(Apps(item).default)
})
base.getConfig().then(data => {
const { vue, config } = data
vue.use(GlsxVueCommon, config)
base.render(App)
})
......@@ -12,6 +12,29 @@
:searchSelectObj="searchSelectObj"
:formData="searchFormData"
>
<template
slot="menuTree"
slot-scope="scope"
>
<select-tree
:form="searchForm"
:targetItem="scope.scope"
:treeData="baseData.menuTreeList"
:defaultProps="treeDefaultProps"
@selected="handleTreeSelect"
></select-tree>
</template>
<template
slot="ownCusCom"
slot-scope="scope"
>
<own-cus-com
:targetItem="scope.scope"
:form="searchForm"
:optionList="baseData.ownCusList"
:baseData="baseData"
></own-cus-com>
</template>
<el-button
size="small"
type="primary"
......@@ -20,10 +43,11 @@
</glsx-combi-form>
<glsx-table
ref="functionTable"
:searchForm="searchForm"
:searchForm="tableSearchForm"
:tableParams="tableParams"
:pageConf="pageConf"
:getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
>
<el-button
slot="auth-button"
......@@ -42,10 +66,19 @@
:formData="editFormData"
:formRules="editRule"
>
<el-select
slot="parentid"
<template
slot="menuTree"
slot-scope="scope"
></el-select>
>
<select-tree
:form="editForm"
:targetItem="scope.scope"
:treeData="baseData.menuTreeList"
:defaultProps="treeDefaultProps"
@selected="handleTreeSelect"
></select-tree>
</template>
</glsx-combi-form>
</glsx-dialog>
</div>
......@@ -53,54 +86,74 @@
<script>
import _ from 'lodash'
import { functionApi } from '@/api/productManage'
import OwnCusCom from '../components/OwnCusCom'
import SelectTree from '../components/SelectTree'
import { functionApi, baseApi } from '@/api/productManage'
export default {
name: 'functionList',
data() {
return {
searchForm: {
functionName: '',
merchantName: ''
merchantName: '',
ownCus: '1',
menu: '',
menuId: '',
ownCusSub: [],
productId: []
},
tableSearchForm: {},
searchSelectObj: {
funcOrName: {
attr: 'functionName',
value: ''
}
},
oldVal: {
productId: []
},
searchFormData: [{
label: '产品',
name: 'productId',
type: 'select',
multiple: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'productList'
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'productList',
changeAttr: (value, targetItem) => {
if (value.includes('')) {
this.searchForm[targetItem.name] = !this.oldVal[targetItem.name].includes('') ? targetItem.optionList.map(item => item.id) : this.searchForm[targetItem.name].filter(item => item !== '')
} else {
if (this.oldVal[targetItem.name].includes('')) {
this.searchForm[targetItem.name] = []
} else if (value.length === (targetItem.optionList.length - 1)) {
this.searchForm[targetItem.name].push('')
}
}
this.oldVal[targetItem.name] = this.searchForm[targetItem.name]
}
}, {
label: '菜单',
name: '',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
}, {
label: '功能属性类型',
name: '',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
name: 'menu',
addHtml: 'menuTree',
formName: 'searchForm'
}, {
label: '商户账户类型',
name: '',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
type: 'select',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'accounTypetList'
}, {
label: '所属客户群体',
name: '',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
name: 'ownCus',
// 下一级是否多选
multiple: true,
addHtml: 'ownCusCom',
optionId: 'dictValue',
optionLabel: 'dictLabel'
}, {
type: 'selectInput',
selectName: 'funcOrName',
......@@ -117,7 +170,7 @@ export default {
}
}],
getListApi: functionApi.getListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNumer', totalCount: 'data.totalCount' },
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'data.totalCount' },
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
......@@ -161,13 +214,14 @@ export default {
name: 'productId',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'productList'
}, {
label: '父级菜单',
name: 'parentid',
addHtml: 'parentid'
label: '菜单',
name: 'menu',
addHtml: 'menuTree',
formName: 'editForm'
}, {
label: '功能名称',
name: '',
......@@ -188,34 +242,70 @@ export default {
name: 'sort',
type: 'input'
}],
treeDefaultProps: {
children: 'childlist',
label: 'menuName'
},
// 基本数据
baseData: {
productList: [{
confId: '1',
confLabel: '产品1'
menuTreeList: [],
productList: [],
accounTypetList: [],
funcAttrList: [],
ownCusList: [],
accountLevelList: [],
accountRoleList: [{
dictValue: '1',
dictLabel: '商户'
}, {
confId: '2',
confLabel: '产品2'
}, {
confId: '3',
confLabel: '产品3'
dictValue: '2',
dictLabel: '门店'
}]
}
}
},
components: {
OwnCusCom,
SelectTree
},
mounted() {
this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false)
baseApi.getMenuTree().then(res => {
this.baseData.menuTreeList = res.data
console.log(this.baseData.menuTreeList)
})
this.getBaseData().then(res => {
this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false)
})
},
methods: {
getBaseData() {
// 1.product(产品) 2.account_type(账户类型) 3.(functional_attributes) 功能属性 4.(owned_customer_group)所属客户群 5.channel渠道 6.account_level(商户层级)
return new Promise(resolve => {
Promise.all([
baseApi.getAllDictApi({ dictType: 'product' }),
baseApi.getAllDictApi({ dictType: 'account_type' }),
baseApi.getAllDictApi({ dictType: 'functional_attributes' }),
baseApi.getAllDictApi({ dictType: 'owned_customer_group' })],
baseApi.getAllDictApi({ dictType: 'account_level' })).then(([product, account, funcAttr, ownCus, accountLevel]) => {
this.baseData.productList = product.data
this.baseData.accounTypetList = account.data
this.baseData.funcAttrList = funcAttr.data
this.baseData.ownCusList = ownCus.data
this.baseData.accountLevelList = accountLevel.data
resolve()
})
})
},
keyDowmGetList() {
this.$refs.productTable.refreshTable()
},
getOptionsList(formName, hasAll = true) {
this[formName].forEach((item, index) => {
if (item.type === 'select') {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
this.$set(this[formName][index], 'optionList', _.cloneDeep(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
......@@ -237,6 +327,7 @@ export default {
},
getParams() {
var params = _.cloneDeep(this.searchForm)
params.productId.includes('') && (params.productId = [])
const tempParams = this.getSelectInputParams()
params = {
...params,
......@@ -244,8 +335,18 @@ export default {
}
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
handleAdd() {
this.editVisible = !this.editVisible
},
handleTreeSelect(obj) {
this[obj.formName][obj.targetItem.name] = obj.val.menuName
this[obj.formName].menuId = obj.val.id
}
}
}
......
......@@ -27,10 +27,11 @@
</el-row>
<glsx-table
ref="menuTable"
:searchForm="searchForm"
:searchForm="tableSearchForm"
:pageConf="pageConf"
:tableParams="tableParams"
:getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
>
<span slot="auth-button">
<el-button type="text">修改</el-button>
......@@ -49,10 +50,22 @@
:formData="editFormData"
:formRules="editRule"
>
<el-select
slot="parentid"
<template
slot="menuTree"
slot-scope="scope"
></el-select>
>
<select-tree
:form="editForm"
:targetItem="scope.scope"
:treeData="baseData.menuTreeList"
:defaultProps="treeDefaultProps"
@selected="handleTreeSelect"
></select-tree>
</template>
<template
slot="menuIcon"
slot-scope="scope"
></template>
</glsx-combi-form>
</glsx-dialog>
</div>
......@@ -61,7 +74,8 @@
<script>
import _ from 'lodash'
import { Util } from '@/common/util'
import { menuApi } from '@/api/productManage'
import SelectTree from '../components/SelectTree'
import { menuApi, baseApi } from '@/api/productManage'
export default {
name: 'menuList',
data() {
......@@ -70,15 +84,31 @@ export default {
productId: [],
menuName: ''
},
tableSearchForm: {},
oldVal: {
productId: []
},
searchFormData: [{
label: '产品',
name: 'productId',
type: 'select',
multiple: true,
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionsName: 'productList'
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'productList',
changeAttr: (value, targetItem) => {
if (value.includes('')) {
this.searchForm[targetItem.name] = !this.oldVal[targetItem.name].includes('') ? targetItem.optionList.map(item => item.id) : this.searchForm[targetItem.name].filter(item => item !== '')
} else {
if (this.oldVal[targetItem.name].includes('')) {
this.searchForm[targetItem.name] = []
} else if (value.length === (targetItem.optionList.length - 1)) {
this.searchForm[targetItem.name].push('')
}
}
this.oldVal[targetItem.name] = this.searchForm[targetItem.name]
}
}, {
label: '菜单名称',
name: 'menuName',
......@@ -107,7 +137,7 @@ export default {
prop: 'menuUrl'
}, {
label: '父级菜单名',
prop: ''
prop: 'parentid'
}, {
label: '产品名称',
prop: ''
......@@ -122,62 +152,79 @@ export default {
// 弹窗
title: '创建菜单',
editVisible: false,
editForm: {},
editForm: {
menu: '',
menuId: ''
},
editRule: {
productId: [{ required: true, message: '请选择产品', trigger: 'blur' }]
},
treeDefaultProps: {
children: 'childlist',
label: 'menuName'
},
editFormData: [{
label: '产品',
name: 'productId',
width: '300px',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'productList'
}, {
label: '父级菜单',
name: 'parentid',
addHtml: 'parentid'
name: 'menu',
addHtml: 'menuTree',
formName: 'editForm'
}, {
label: '菜单名称',
name: 'menuName',
type: 'input',
width: '300px',
maxlength: 15
}, {
label: '菜单地址',
name: 'menuUrl',
width: '300px',
type: 'input'
}, {
label: '菜单ICON'
label: '菜单ICON',
name: '',
addHtml: 'menuIcon'
}, {
label: '菜单排序值',
name: 'sort',
width: '300px',
type: 'input'
}],
// 基本数据
baseData: {
productList: [{
confId: '1',
confLabel: '产品1'
}, {
confId: '2',
confLabel: '产品2'
}, {
confId: '3',
confLabel: '产品3'
}]
productList: [],
menuTreeList: []
}
}
},
components: {
SelectTree
},
mounted() {
this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false)
baseApi.getAllDictApi({ dictType: 'product' }).then(res => {
// console.log(res)
this.baseData.productList = res.data
this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false)
})
baseApi.getMenuTree().then(res => {
this.baseData.menuTreeList = res.data
})
},
methods: {
keyDowmGetList() {
this.$refs.productTable.refreshTable()
this.$refs.menuTable.refreshTable()
},
getOptionsList(formName, hasAll = true) {
this[formName].forEach((item, index) => {
......@@ -192,8 +239,19 @@ export default {
}
})
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = _.cloneDeep(this.searchForm)
this.tableSearchForm.productId.includes('') && (this.tableSearchForm.productId = [])
resolve()
})
},
handleAdd() {
this.editVisible = !this.editVisible
},
handleTreeSelect(obj) {
this[obj.formName][obj.targetItem.name] = obj.val.menuName
this[obj.formName].menuId = obj.val.id
}
}
}
......
// import App from './index.vue'
import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common'
import notice from '@/common/notice'
const Apps = require.context('./', false, /\.vue$/)
......@@ -11,12 +12,7 @@ Apps.keys().map(item => {
config
} = data
vue.use(GlsxVueCommon, config)
vue.prototype.notice = notice
base.render(Apps(item).default)
})
})
// base.getConfig().then(data => {
// const { vue, config } = data
// vue.use(GlsxVueCommon, config)
// base.render(App)
// })
<!-- 产品列表 -->
<template>
<div>
<div class="prodect-list">
<el-row>
<el-col :span="12">
<el-button
......@@ -40,11 +40,13 @@
<glsx-dialog
:title="title"
:isVisible="editVisible"
@closeDialog="handleAdd"
@confirmDialog="handleAdd"
@closeDialog="handleEditClose"
@confirmDialog="handleEditConfirm"
>
<glsx-combi-form
ref="editFormRef"
labelWidth="100px"
:formRef="editChildRef"
:formObj="editForm"
:formData="editFormData"
:formRules="editRule"
......@@ -68,8 +70,8 @@ export default {
label: '产品名称',
name: 'productName',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
isClear: true
// keyFn: this.keyDowmGetList
}],
getListApi: productApi.getListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNumer', totalCount: 'data.totalCount' },
......@@ -101,20 +103,29 @@ export default {
// 弹窗
title: '创建产品',
editVisible: false,
editForm: {},
editChildRef: 'editChildRef',
editForm: {
productName: '',
productType: '',
productDetail: '',
productAddress: ''
},
editRule: {
productName: [{ required: true, message: '请输入产品名称', trigger: 'blur' }]
productName: [{ required: true, message: '请输入产品名称', trigger: 'blur' }],
productType: [{ required: true, message: '请选择产品类型', trigger: 'change' }],
productAddress: [{ required: true, message: '请输入产品地址', trigger: 'blur' }]
},
editFormData: [{
label: '产品名称',
name: 'productName',
type: 'input',
maxlength: 15,
isClear: true
width: '300px'
}, {
label: '产品类型',
name: 'productType',
type: 'select',
width: '300px',
optionList: [],
optionId: 'confId',
optionLabel: 'confLabel',
......@@ -124,12 +135,14 @@ export default {
name: 'productDetail',
type: 'input',
inputType: 'textarea',
maxlength: 50
maxlength: 50,
showLimit: true,
width: '300px'
}, {
label: '产品地址',
name: 'productAddress',
type: 'input',
isClear: true
width: '300px'
}],
// 基本数据
baseData: {
......@@ -142,6 +155,9 @@ export default {
}, {
confId: '3',
confLabel: '企微小程序'
}, {
confId: '4',
confLabel: 'H5'
}]
}
}
......@@ -170,10 +186,35 @@ export default {
},
handleAdd() {
this.editVisible = !this.editVisible
},
handleEditClose() {
this.editForm = {
productName: '',
productType: '',
productDetail: '',
productAddress: ''
}
this.$refs.editFormRef.$refs[this.editChildRef].clearValidate()
this.handleAdd()
},
handleEditConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
productApi.saveProApi({ productCode: '123', ...this.editForm }).then(res => {
console.log(res)
this.notice.okTips()
this.handleEditClose()
this.keyDowmGetList()
})
}
})
}
}
}
</script>
<style scoped>
<style>
.prodect-list .el-textarea__inner {
height: 80px;
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!