Commit 79f06e94 by cwq0219

产品功能管理

1 parent fdff2951
import request from './request' import request from './request'
const path = 'cn.com.glsx.merchants.' 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 = { export const productApi = {
/** 获取财务管理列表*/ /** 获取财务管理列表*/
......
import App from './index.vue'
import base from '@/base' import base from '@/base'
import GlsxVueCommon from 'glsx-vue-common' import GlsxVueCommon from 'glsx-vue-common'
base.getConfig().then(data => {
const Apps = require.context('./', false, /\.vue$/) const { vue, config } = data
Apps.keys().map(item => {
base.getConfig().then(data => {
const {
vue,
config
} = data
vue.use(GlsxVueCommon, config) vue.use(GlsxVueCommon, config)
base.render(Apps(item).default) base.render(App)
})
}) })
<!-- 所属客户群体 - 组件 -->
<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 \ 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 })
}
}
}
</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 \ No newline at end of file
...@@ -12,6 +12,29 @@ ...@@ -12,6 +12,29 @@
:searchSelectObj="searchSelectObj" :searchSelectObj="searchSelectObj"
:formData="searchFormData" :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 <el-button
size="small" size="small"
type="primary" type="primary"
...@@ -20,10 +43,11 @@ ...@@ -20,10 +43,11 @@
</glsx-combi-form> </glsx-combi-form>
<glsx-table <glsx-table
ref="functionTable" ref="functionTable"
:searchForm="searchForm" :searchForm="tableSearchForm"
:tableParams="tableParams" :tableParams="tableParams"
:pageConf="pageConf" :pageConf="pageConf"
:getListApi="getListApi" :getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
> >
<el-button <el-button
slot="auth-button" slot="auth-button"
...@@ -53,54 +77,73 @@ ...@@ -53,54 +77,73 @@
<script> <script>
import _ from 'lodash' 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 { export default {
name: 'functionList', name: 'functionList',
data() { data() {
return { return {
searchForm: { searchForm: {
functionName: '', functionName: '',
merchantName: '' merchantName: '',
ownCus: '1',
menu: '',
menuId: '',
ownCusSub: [],
productId: []
}, },
tableSearchForm: {},
searchSelectObj: { searchSelectObj: {
funcOrName: { funcOrName: {
attr: 'functionName', attr: 'functionName',
value: '' value: ''
} }
}, },
oldVal: {
productId: []
},
searchFormData: [{ searchFormData: [{
label: '产品', label: '产品',
name: 'productId', name: 'productId',
type: 'select', type: 'select',
multiple: true, multiple: true,
optionList: [], optionList: [],
optionId: 'confId', optionId: 'dictValue',
optionLabel: 'confLabel', optionLabel: 'dictLabel',
optionsName: 'productList' 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: '菜单', label: '菜单',
name: '', name: 'menu',
type: 'input', addHtml: 'menuTree'
isClear: true,
keyFn: this.keyDowmGetList
}, {
label: '功能属性类型',
name: '',
type: 'input',
isClear: true,
keyFn: this.keyDowmGetList
}, { }, {
label: '商户账户类型', label: '商户账户类型',
name: '', name: '',
type: 'input', type: 'select',
isClear: true, optionList: [],
keyFn: this.keyDowmGetList optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'accounTypetList'
}, { }, {
label: '所属客户群体', label: '所属客户群体',
name: '', name: 'ownCus',
type: 'input', // 下一级是否多选
isClear: true, multiple: true,
keyFn: this.keyDowmGetList addHtml: 'ownCusCom',
optionId: 'dictValue',
optionLabel: 'dictLabel'
}, { }, {
type: 'selectInput', type: 'selectInput',
selectName: 'funcOrName', selectName: 'funcOrName',
...@@ -117,7 +160,7 @@ export default { ...@@ -117,7 +160,7 @@ export default {
} }
}], }],
getListApi: functionApi.getListApi, getListApi: functionApi.getListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNumer', totalCount: 'data.totalCount' }, pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'data.totalCount' },
// 表格参数 // 表格参数
tableParams: { tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000), btnId: new Date().getTime() + parseInt(Math.random() * 1000),
...@@ -161,8 +204,8 @@ export default { ...@@ -161,8 +204,8 @@ export default {
name: 'productId', name: 'productId',
type: 'select', type: 'select',
optionList: [], optionList: [],
optionId: 'confId', optionId: 'dictValue',
optionLabel: 'confLabel', optionLabel: 'dictLabel',
optionsName: 'productList' optionsName: 'productList'
}, { }, {
label: '父级菜单', label: '父级菜单',
...@@ -188,34 +231,70 @@ export default { ...@@ -188,34 +231,70 @@ export default {
name: 'sort', name: 'sort',
type: 'input' type: 'input'
}], }],
treeDefaultProps: {
children: 'childlist',
label: 'menuName'
},
// 基本数据 // 基本数据
baseData: { baseData: {
productList: [{ menuTreeList: [],
confId: '1', productList: [],
confLabel: '产品1' accounTypetList: [],
funcAttrList: [],
ownCusList: [],
accountLevelList: [],
accountRoleList: [{
dictValue: '1',
dictLabel: '商户'
}, { }, {
confId: '2', dictValue: '2',
confLabel: '产品2' dictLabel: '门店'
}, {
confId: '3',
confLabel: '产品3'
}] }]
} }
} }
}, },
components: {
OwnCusCom,
SelectTree
},
mounted() { mounted() {
baseApi.getMenuTree().then(res => {
this.baseData.menuTreeList = res.data
console.log(this.baseData.menuTreeList)
})
this.getBaseData().then(res => {
this.getOptionsList('searchFormData') this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false) this.getOptionsList('editFormData', false)
})
}, },
methods: { 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() { keyDowmGetList() {
this.$refs.productTable.refreshTable() this.$refs.productTable.refreshTable()
}, },
getOptionsList(formName, hasAll = true) { getOptionsList(formName, hasAll = true) {
this[formName].forEach((item, index) => { 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])) 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] !== '全部') { if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {} const temp = {}
...@@ -237,6 +316,7 @@ export default { ...@@ -237,6 +316,7 @@ export default {
}, },
getParams() { getParams() {
var params = _.cloneDeep(this.searchForm) var params = _.cloneDeep(this.searchForm)
params.productId.includes('') && (params.productId = [])
const tempParams = this.getSelectInputParams() const tempParams = this.getSelectInputParams()
params = { params = {
...params, ...params,
...@@ -244,8 +324,18 @@ export default { ...@@ -244,8 +324,18 @@ export default {
} }
return params return params
}, },
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
},
handleTreeSelect(obj) {
this.searchForm[obj.targetItem.name] = obj.val.menuName
this.searchForm.menuId = obj.val.id
} }
} }
} }
......
...@@ -27,10 +27,11 @@ ...@@ -27,10 +27,11 @@
</el-row> </el-row>
<glsx-table <glsx-table
ref="menuTable" ref="menuTable"
:searchForm="searchForm" :searchForm="tableSearchForm"
:pageConf="pageConf" :pageConf="pageConf"
:tableParams="tableParams" :tableParams="tableParams"
:getListApi="getListApi" :getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
> >
<span slot="auth-button"> <span slot="auth-button">
<el-button type="text">修改</el-button> <el-button type="text">修改</el-button>
...@@ -61,7 +62,7 @@ ...@@ -61,7 +62,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { Util } from '@/common/util' import { Util } from '@/common/util'
import { menuApi } from '@/api/productManage' import { menuApi, baseApi } from '@/api/productManage'
export default { export default {
name: 'menuList', name: 'menuList',
data() { data() {
...@@ -70,15 +71,31 @@ export default { ...@@ -70,15 +71,31 @@ export default {
productId: [], productId: [],
menuName: '' menuName: ''
}, },
tableSearchForm: {},
oldVal: {
productId: []
},
searchFormData: [{ searchFormData: [{
label: '产品', label: '产品',
name: 'productId', name: 'productId',
type: 'select', type: 'select',
multiple: true, multiple: true,
optionList: [], optionList: [],
optionId: 'confId', optionId: 'id',
optionLabel: 'confLabel', optionLabel: 'productName',
optionsName: 'productList' 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: '菜单名称', label: '菜单名称',
name: 'menuName', name: 'menuName',
...@@ -107,7 +124,7 @@ export default { ...@@ -107,7 +124,7 @@ export default {
prop: 'menuUrl' prop: 'menuUrl'
}, { }, {
label: '父级菜单名', label: '父级菜单名',
prop: '' prop: 'parentid'
}, { }, {
label: '产品名称', label: '产品名称',
prop: '' prop: ''
...@@ -131,8 +148,8 @@ export default { ...@@ -131,8 +148,8 @@ export default {
name: 'productId', name: 'productId',
type: 'select', type: 'select',
optionList: [], optionList: [],
optionId: 'confId', optionId: 'id',
optionLabel: 'confLabel', optionLabel: 'productName',
optionsName: 'productList' optionsName: 'productList'
}, { }, {
label: '父级菜单', label: '父级菜单',
...@@ -156,28 +173,23 @@ export default { ...@@ -156,28 +173,23 @@ export default {
}], }],
// 基本数据 // 基本数据
baseData: { baseData: {
productList: [{ productList: []
confId: '1',
confLabel: '产品1'
}, {
confId: '2',
confLabel: '产品2'
}, {
confId: '3',
confLabel: '产品3'
}]
} }
} }
}, },
mounted() { mounted() {
baseApi.getAllProduct().then(res => {
console.log(res)
this.baseData.productList = res.data
this.getOptionsList('searchFormData') this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false) this.getOptionsList('editFormData', false)
})
}, },
methods: { methods: {
keyDowmGetList() { keyDowmGetList() {
this.$refs.productTable.refreshTable() this.$refs.menuTable.refreshTable()
}, },
getOptionsList(formName, hasAll = true) { getOptionsList(formName, hasAll = true) {
this[formName].forEach((item, index) => { this[formName].forEach((item, index) => {
...@@ -192,6 +204,13 @@ export default { ...@@ -192,6 +204,13 @@ export default {
} }
}) })
}, },
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = _.cloneDeep(this.searchForm)
this.tableSearchForm.productId.includes('') && (this.tableSearchForm.productId = [])
resolve()
})
},
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
} }
......
...@@ -68,8 +68,8 @@ export default { ...@@ -68,8 +68,8 @@ export default {
label: '产品名称', label: '产品名称',
name: 'productName', name: 'productName',
type: 'input', type: 'input',
isClear: true, isClear: true
keyFn: this.keyDowmGetList // keyFn: this.keyDowmGetList
}], }],
getListApi: productApi.getListApi, getListApi: productApi.getListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNumer', totalCount: 'data.totalCount' }, pageConf: { pageSize: 'pageSize', pageNum: 'pageNumer', totalCount: 'data.totalCount' },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!