Commit 05ec0231 by cwq0219

产品,菜单,功能

1 parent 7391b7ed
...@@ -13,7 +13,17 @@ export const baseApi = { ...@@ -13,7 +13,17 @@ export const baseApi = {
}, },
// 所有菜单树 // 所有菜单树
getMenuTree(data = {}) { getMenuTree(data = {}) {
data.method = `${path}menu.findMerProMenuTreeRemote` data.method = `${path}menu.findMerProMenuTree`
return request(data)
},
// 图片上传
upload(url, data = {}) {
data.method = 'glsx.accounts.biz.common.pictureUpload'
return request(data, 'post', ['file'], url)
},
// 获取ICON
getIcon(data = {}) {
data.method = `${path}menu.findMerchantFile`
return request(data) return request(data)
} }
} }
...@@ -27,15 +37,35 @@ export const productApi = { ...@@ -27,15 +37,35 @@ export const productApi = {
/** 新增产品 */ /** 新增产品 */
saveProApi(data = {}) { saveProApi(data = {}) {
data.method = `${path}product.saveProduct` data.method = `${path}product.saveProduct`
return request(data) return request(data, 'post')
},
/** 编辑产品 */
updateProApi(data = {}) {
data.method = `${path}product.updateProduct`
return request(data, 'post')
} }
} }
// 菜单 // 菜单
export const menuApi = { export const menuApi = {
/** 获取财务管理列表*/ /** 获取财务管理列表*/
getListApi(data = {}) { getListApi(data = {}) {
data.method = `${path}menu.findMerProMenuByPageRemote` data.method = `${path}menu.findMerProMenuByPage`
return request(data) return request(data)
},
/** 新增菜单 */
saveMenuApi(data = {}) {
data.method = `${path}menu.saveMerchantProductMenu`
return request(data, 'post')
},
// 更新菜单
updateMenuApi(data = {}) {
data.method = `${path}menu.updateMerchantProductMenu`
return request(data, 'post')
},
// 删除菜单
deleteMenuApi(data = {}) {
data.method = `${path}menu.deleteMerchantProductMenu`
return request(data, 'post')
} }
} }
...@@ -45,5 +75,15 @@ export const functionApi = { ...@@ -45,5 +75,15 @@ export const functionApi = {
getListApi(data = {}) { getListApi(data = {}) {
data.method = `${path}menu.findMerchantFunction` data.method = `${path}menu.findMerchantFunction`
return request(data) return request(data)
},
/** 新增功能 */
saveFunApi(data = {}) {
data.method = `${path}menu.saveMerchantFunction`
return request(data, 'post')
},
/** 编辑功能 */
updateFunApi(data = {}) {
data.method = `${path}menu.updateMerchantFunction`
return request(data, 'post')
} }
} }
import RequestMethods from './request.methods' import RequestMethods from './request.methods'
import axios from 'axios'
import qs from 'qs'
// import GlsxVueCommon from 'glsx-vue-common' // import GlsxVueCommon from 'glsx-vue-common'
import sign from './sign' import sign from './sign'
import { import {
GlAxios GlAxios
} from 'glsx-vue-common' } from 'glsx-vue-common'
const request = (params = {}, method = RequestMethods.GET, noSignAttr = []) => { const request = (params = {}, method = RequestMethods.GET, noSignAttr = [], url = '') => {
params.source = 'glsx-oss-merchant-data' params.source = 'glsx-oss-merchant-data'
params.appKey = '48e5e13229b82c1b4e6e8c96151f0637' params.appKey = '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime() params.timestamp = new Date().getTime()
...@@ -12,6 +14,9 @@ const request = (params = {}, method = RequestMethods.GET, noSignAttr = []) => { ...@@ -12,6 +14,9 @@ const request = (params = {}, method = RequestMethods.GET, noSignAttr = []) => {
params.format = 'json' params.format = 'json'
// params.createBy = this.$get_session_config().user.id // params.createBy = this.$get_session_config().user.id
var data = sign(params, noSignAttr) var data = sign(params, noSignAttr)
if (url) {
return axios.post(`${url}/router?method=${method}`, qs.stringify(data))
}
return method === RequestMethods.GET ? GlAxios.get('router', { return method === RequestMethods.GET ? GlAxios.get('router', {
params: sign(params, noSignAttr) params: sign(params, noSignAttr)
}) : GlAxios.post('router', data) }) : GlAxios.post('router', data)
......
...@@ -18,8 +18,13 @@ ...@@ -18,8 +18,13 @@
:label="item.label ? (item.label + ':') : ''" :label="item.label ? (item.label + ':') : ''"
:prop="item.name" :prop="item.name"
> >
<slot
v-if="item.addHtml"
:name="item.addHtml"
:scope="item"
></slot>
<el-input <el-input
v-if="item.type === 'input'" v-else-if="item.type === 'input'"
:placeholder="item.placeholder || ('请输入' + item.label)" :placeholder="item.placeholder || ('请输入' + item.label)"
v-model.trim="formObj[item.name]" v-model.trim="formObj[item.name]"
:disabled="item.isDisabled" :disabled="item.isDisabled"
...@@ -145,11 +150,6 @@ ...@@ -145,11 +150,6 @@
:picker-options="pickerOption[item.pickerOptions]" :picker-options="pickerOption[item.pickerOptions]"
> >
</el-date-picker> </el-date-picker>
<slot
v-if="item.addHtml"
:name="item.addHtml"
:scope="item"
></slot>
</el-form-item> </el-form-item>
</template> </template>
<slot></slot> <slot></slot>
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<template> <template>
<div class="flex"> <div class="flex">
<el-select <el-select
v-model="form[targetItem.name]" v-model="form[targetItem.firstVal]"
:placeholder="'请选择'" :placeholder="'请选择'"
@change="handleTopChange" @change="handleFirstChange('')"
> >
<el-option <el-option
v-for="subItem in optionList" v-for="subItem in optionList"
...@@ -14,17 +14,19 @@ ...@@ -14,17 +14,19 @@
></el-option> ></el-option>
</el-select> </el-select>
<el-input <el-input
v-show="['3'].includes(form[targetItem.name])" v-show="[3].includes(form[targetItem.firstVal])"
v-model="form.ownCusSub" v-model="subVal.input"
placeholder="请输入商户/门店ID" placeholder="请输入商户/门店ID"
@change="handleFirstChange"
></el-input> ></el-input>
<el-select <el-select
v-show="['1', '2', '4'].includes(form[targetItem.name])" v-show="[1, 2, 4].includes(form[targetItem.firstVal])"
v-model="form.ownCusSub" v-model="subVal.mutiSelect"
:multiple="targetItem.multiple || false" :multiple="targetItem.multiple || false"
@change="handleFirstChange"
> >
<el-option <el-option
v-for="subItem in baseData[attrToList[form[targetItem.name]]]" v-for="subItem in baseData[attrToList[form[targetItem.firstVal]]]"
:key="subItem.dictValue" :key="subItem.dictValue"
:label="subItem.dictLabel" :label="subItem.dictLabel"
:value="subItem.dictValue" :value="subItem.dictValue"
...@@ -71,12 +73,18 @@ export default { ...@@ -71,12 +73,18 @@ export default {
}, },
mounted() { mounted() {
// console.log(this.targetItem)F // console.log(this.targetItem)
}, },
methods: { methods: {
handleTopChange() { handleFirstChange(val) {
this.form.ownCusSub = ['3'].includes(this.form[this.targetItem.name]) ? '' : [] if (!val) {
this.subVal = {
input: '',
mutiSelect: []
}
}
this.$emit('changeSecond', { val: val, targetItem: this.targetItem })
} }
} }
} }
......
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
<el-input <el-input
slot="reference" slot="reference"
ref="input" ref="input"
v-model="form[targetItem.name]" v-model="form[targetItem.nameLabel]"
clearable clearable
:style="`width: ${width}px`" :style="`width: ${width}px`"
:class="{ 'rotate': showStatus }" :class="{ 'rotate': showStatus }"
suffix-icon="el-icon-arrow-down" suffix-icon="el-icon-arrow-down"
:placeholder="'请选择' + targetItem.label" :placeholder="'请选择' + targetItem.label"
@change="handleClear"
> >
</el-input> </el-input>
</el-popover> </el-popover>
...@@ -65,24 +66,32 @@ export default { ...@@ -65,24 +66,32 @@ export default {
type: Object, type: Object,
default: () => ({ default: () => ({
parent: 'parentId', parent: 'parentId',
value: 'rowGuid', value: 'id',
label: 'areaName', label: 'menuName',
children: 'children' children: 'childlist'
}) })
} }
}, },
// watch: { watch: {
// labelModel(val) { labelModel(val) {
// if (!val) { if (!val) {
// this.valueModel = '' this.valueModel = ''
// } }
// this.$refs.tree.filter(val) this.$refs.tree.filter(val)
// }, },
// value(val) { value(val) {
// this.labelModel = this.queryTree(this.data, val) this.labelModel = this.queryTree(this.data, val)
// } },
// }, form(val) {
console.log(val)
// this.labelModel = this.form[this.targetItem.name]
if (this.form[this.targetItem.name]) {
this.form[this.targetItem.nameLabel] = this.queryTree(this.treeData, this.form[this.targetItem.name])
// this.$refs.tree.filter(this.form[this.targetItem.nameLabel])
}
}
},
created() { created() {
// 检测输入框原有值并显示对应 label // 检测输入框原有值并显示对应 label
...@@ -95,13 +104,17 @@ export default { ...@@ -95,13 +104,17 @@ export default {
}) })
}, },
mounted() { }, mounted() {
if (this.form[this.targetItem.name]) {
this.form[this.targetItem.nameLabel] = this.queryTree(this.treeData, this.form[this.targetItem.name])
}
},
methods: { methods: {
// 显示时触发 // 显示时触发
onShowPopover() { onShowPopover() {
this.showStatus = true this.showStatus = true
// this.$refs.tree.filter(false) this.$refs.tree.filter(false)
}, },
// 隐藏时触发 // 隐藏时触发
onHidePopover() { onHidePopover() {
...@@ -114,6 +127,24 @@ export default { ...@@ -114,6 +127,24 @@ export default {
}, },
handleNodeClick(val) { handleNodeClick(val) {
this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName }) this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName })
},
handleClear(val) {
this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName })
},
// 搜索树状数据中的 ID
queryTree(tree, id) {
let stark = []
stark = stark.concat(tree)
while (stark.length) {
const temp = stark.shift()
if (temp[this.defaultProps.children]) {
stark = stark.concat(temp[this.defaultProps.children])
}
if (temp[this.defaultProps.value] === id) {
return temp[this.defaultProps.label]
}
}
return
} }
} }
} }
......
import App from './index.vue' 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'
import notice from '@/common/notice'
base.getConfig().then(data => { base.getConfig().then(data => {
const { vue, config } = data const { vue, config } = data
vue.use(GlsxVueCommon, config) vue.use(GlsxVueCommon, config)
vue.prototype.notice = notice
base.render(App) base.render(App)
}) })
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
<own-cus-com <own-cus-com
:targetItem="scope.scope" :targetItem="scope.scope"
:form="searchForm" :form="searchForm"
:optionList="baseData.ownCusList" :optionList="baseData.searchOwnCusList"
:baseData="baseData" :baseData="baseData"
@changeSecond="changeOwnSecond"
></own-cus-com> ></own-cus-com>
</template> </template>
<el-button <el-button
...@@ -51,23 +52,26 @@ ...@@ -51,23 +52,26 @@
> >
<el-button <el-button
slot="auth-button" slot="auth-button"
slot-scope="scope"
type="text" type="text"
@click="handleFunEdit(scope.scope)"
>编辑</el-button> >编辑</el-button>
</glsx-table> </glsx-table>
<glsx-dialog <glsx-dialog
:title="title" :title="editForm.id ? '编辑功能' : '创建功能'"
width="760px" width="760px"
:isVisible="editVisible" :isVisible="editVisible"
@closeDialog="handleAdd" @closeDialog="handleClose"
@confirmDialog="handleAdd" @confirmDialog="handleConfirm"
> >
<glsx-combi-form <glsx-combi-form
ref="editFormRef"
labelWidth="130px" labelWidth="130px"
:formRef="editChildRef"
:formObj="editForm" :formObj="editForm"
:formData="editFormData" :formData="editFormData"
:formRules="editRule" :formRules="editRule"
> >
<template <template
slot="menuTree" slot="menuTree"
slot-scope="scope" slot-scope="scope"
...@@ -108,11 +112,12 @@ export default { ...@@ -108,11 +112,12 @@ export default {
searchForm: { searchForm: {
functionName: '', functionName: '',
merchantName: '', merchantName: '',
ownCus: '1', ownCus: 1,
menu: '',
menuId: '', menuId: '',
ownCusSub: [], menuName: '',
productId: [] ownedCusgroupType: '',
ownedCusgroupValue: '',
productIds: []
}, },
tableSearchForm: {}, tableSearchForm: {},
searchSelectObj: { searchSelectObj: {
...@@ -122,11 +127,11 @@ export default { ...@@ -122,11 +127,11 @@ export default {
} }
}, },
oldVal: { oldVal: {
productId: [] productIds: []
}, },
searchFormData: [{ searchFormData: [{
label: '产品', label: '产品',
name: 'productId', name: 'productIds',
type: 'select', type: 'select',
multiple: true, multiple: true,
optionList: [], optionList: [],
...@@ -135,7 +140,7 @@ export default { ...@@ -135,7 +140,7 @@ export default {
optionsName: 'productList', optionsName: 'productList',
changeAttr: (value, targetItem) => { changeAttr: (value, targetItem) => {
if (value.includes('')) { 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 !== '') this.searchForm[targetItem.name] = !this.oldVal[targetItem.name].includes('') ? targetItem.optionList.map(item => item[targetItem.optionId]) : this.searchForm[targetItem.name].filter(item => item !== '')
} else { } else {
if (this.oldVal[targetItem.name].includes('')) { if (this.oldVal[targetItem.name].includes('')) {
this.searchForm[targetItem.name] = [] this.searchForm[targetItem.name] = []
...@@ -144,28 +149,35 @@ export default { ...@@ -144,28 +149,35 @@ export default {
} }
} }
this.oldVal[targetItem.name] = this.searchForm[targetItem.name] this.oldVal[targetItem.name] = this.searchForm[targetItem.name]
this.tableSearchForm[targetItem.name] = this.searchForm[targetItem.name].includes('') ? [] : this.searchForm[targetItem.name]
} }
}, { }, {
label: '菜单', label: '菜单',
name: 'menu', name: 'menuId',
nameLabel: 'menuName',
addHtml: 'menuTree', addHtml: 'menuTree',
formName: 'searchForm' formName: 'searchForm'
}, { },
label: '商户账户类型', // {
name: '', // label: '商户账户类型',
type: 'select', // name: '',
optionList: [], // type: 'select',
optionId: 'dictValue', // optionList: [],
optionLabel: 'dictLabel', // optionId: 'dictValue',
optionsName: 'accounTypetList' // optionLabel: 'dictLabel',
}, { // optionsName: 'accounTypetList'
// },
{
label: '所属客户群体', label: '所属客户群体',
name: 'ownCus', name: 'ownCus',
firstVal: 'ownedCusgroupType',
secondVal: 'ownedCusgroupValue',
// 下一级是否多选 // 下一级是否多选
multiple: true, multiple: true,
addHtml: 'ownCusCom', addHtml: 'ownCusCom',
optionId: 'dictValue', optionId: 'dictValue',
optionLabel: 'dictLabel' optionLabel: 'dictLabel',
formName: 'searchForm'
}, { }, {
type: 'selectInput', type: 'selectInput',
selectName: 'funcOrName', selectName: 'funcOrName',
...@@ -215,47 +227,73 @@ export default { ...@@ -215,47 +227,73 @@ export default {
}] }]
}, },
// 弹窗 // 弹窗
title: '创建产品', title: '创建功能',
editVisible: false, editVisible: false,
editChildRef: 'editChildRef',
editForm: {}, editForm: {},
editRule: { editRule: {
productName: [{ required: true, message: '请输入产品名称', trigger: 'blur' }] productId: [{ required: true, message: '请选择产品名称', trigger: 'change' }],
menuId: [{ required: true, message: '请选择菜单', trigger: 'change' }],
functionName: [{ required: true, message: '请输入功能名称', trigger: 'blur' }],
functionAttributeName: [{ required: true, message: '请输入功能属性名', trigger: 'blur' }],
functionType: [{ required: true, message: '请选择功能属性类型', trigger: 'change' }],
// productId: [{ required: true, message: '请输入产品名称', trigger: 'blur' }],
functionValue: [{ required: true, message: '请输入功能值', trigger: 'blur' }],
sort: [{ required: true, message: '请输入排序值', trigger: 'blur' }]
}, },
editFormData: [{ editFormData: [{
label: '产品', label: '产品',
name: 'productId', name: 'productId',
type: 'select', type: 'select',
width: '400px',
optionList: [], optionList: [],
optionId: 'dictValue', optionId: 'dictValue',
optionLabel: 'dictLabel', optionLabel: 'dictLabel',
optionsName: 'productList' optionsName: 'productList'
}, { }, {
label: '菜单', label: '菜单',
name: 'menu', name: 'menuId',
nameLabel: 'menuName',
addHtml: 'menuTree', addHtml: 'menuTree',
formName: 'editForm' formName: 'editForm'
}, { }, {
label: '功能名称', label: '功能名称',
name: '', name: 'functionName',
width: '400px',
type: 'input', type: 'input',
maxlength: 15 maxlength: 15
}, { }, {
label: '功能属性名', label: '功能属性名',
name: '', name: 'functionAttributeName ',
width: '400px',
type: 'input' type: 'input'
}, { }, {
label: '功能属性类型',
name: 'functionType',
width: '400px',
type: 'select',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'funcAttrList'
}, {
label: '所属客户群体', label: '所属客户群体',
name: 'ownCus', name: 'ownCus',
firstVal: 'ownedCusgroupType',
secondVal: 'ownedCusgroupValue',
addHtml: 'ownCusCom', addHtml: 'ownCusCom',
optionId: 'dictValue', optionId: 'dictValue',
optionLabel: 'dictLabel' optionLabel: 'dictLabel',
formName: 'editForm'
}, { }, {
label: '功能值', label: '功能值',
name: '', name: 'functionValue',
width: '400px',
type: 'input' type: 'input'
}, { }, {
label: '排序值', label: '排序值',
name: 'sort', name: 'sort',
width: '400px',
type: 'input' type: 'input'
}], }],
treeDefaultProps: { treeDefaultProps: {
...@@ -268,6 +306,7 @@ export default { ...@@ -268,6 +306,7 @@ export default {
productList: [], productList: [],
accounTypetList: [], accounTypetList: [],
funcAttrList: [], funcAttrList: [],
searchOwnCusList: [],
ownCusList: [], ownCusList: [],
accountLevelList: [], accountLevelList: [],
accountRoleList: [{ accountRoleList: [{
...@@ -305,12 +344,17 @@ export default { ...@@ -305,12 +344,17 @@ export default {
baseApi.getAllDictApi({ dictType: 'product' }), baseApi.getAllDictApi({ dictType: 'product' }),
baseApi.getAllDictApi({ dictType: 'account_type' }), baseApi.getAllDictApi({ dictType: 'account_type' }),
baseApi.getAllDictApi({ dictType: 'functional_attributes' }), baseApi.getAllDictApi({ dictType: 'functional_attributes' }),
baseApi.getAllDictApi({ dictType: 'owned_customer_group' })], baseApi.getAllDictApi({ dictType: 'owned_customer_group' }),
baseApi.getAllDictApi({ dictType: 'account_level' })).then(([product, account, funcAttr, ownCus, accountLevel]) => { baseApi.getAllDictApi({ dictType: 'account_level' })]).then(([product, account, funcAttr, ownCus, accountLevel]) => {
this.baseData.productList = product.data this.baseData.productList = product.data
this.baseData.accounTypetList = account.data this.baseData.accounTypetList = account.data
this.baseData.funcAttrList = funcAttr.data this.baseData.funcAttrList = funcAttr.data
this.baseData.ownCusList = ownCus.data this.baseData.ownCusList = ownCus.data
this.baseData.searchOwnCusList = ownCus.data
this.baseData.searchOwnCusList.unshift({
dictValue: '',
dictLabel: '全部'
})
this.baseData.accountLevelList = accountLevel.data this.baseData.accountLevelList = accountLevel.data
resolve() resolve()
}) })
...@@ -343,7 +387,7 @@ export default { ...@@ -343,7 +387,7 @@ export default {
}, },
getParams() { getParams() {
var params = _.cloneDeep(this.searchForm) var params = _.cloneDeep(this.searchForm)
params.productId.includes('') && (params.productId = []) params.productIds.includes('') && (params.productIds = [])
const tempParams = this.getSelectInputParams() const tempParams = this.getSelectInputParams()
params = { params = {
...params, ...params,
...@@ -360,9 +404,35 @@ export default { ...@@ -360,9 +404,35 @@ export default {
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
}, },
handleFunEdit(row) {
this.editForm = _.cloneDeep(row)
this.handleAdd()
},
handleClose() {
this.editForm = {}
this.$refs.editFormRef.$refs[this.editChildRef].clearValidate()
this.handleAdd()
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var apiName = this.editForm.id ? 'updateFunApi' : 'saveFunApi'
functionApi[apiName](this.editForm).then(res => {
if (res.code === '0') {
this.notice.okTips()
this.handleClose()
this.keyDowmGetList()
}
})
}
})
},
handleTreeSelect(obj) { handleTreeSelect(obj) {
this[obj.formName][obj.targetItem.name] = obj.val.menuName this[obj.formName][obj.targetItem.nameLabel] = obj.val ? obj.val.menuName : ''
this[obj.formName].menuId = obj.val.id this[obj.formName][obj.targetItem.name] = obj.val ? obj.val.id : ''
},
changeOwnSecond(obj) {
this[obj.targetItem.formName][obj.targetItem.secondVal] = obj.val
} }
} }
} }
......
// import App from './index.vue' // 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'
import notice from '@/common/notice'
const Apps = require.context('./', false, /\.vue$/) const Apps = require.context('./', false, /\.vue$/)
console.log('00000000000000')
Apps.keys().map(item => { Apps.keys().map(item => {
console.log(item) console.log(item)
...@@ -13,6 +13,7 @@ Apps.keys().map(item => { ...@@ -13,6 +13,7 @@ Apps.keys().map(item => {
config config
} = data } = data
vue.use(GlsxVueCommon, config) vue.use(GlsxVueCommon, config)
vue.prototype.notice = notice
base.render(Apps(item).default) base.render(Apps(item).default)
}) })
}) })
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
<template> <template>
<div> <div>
<el-row> <el-row>
<el-col :span="8"> <el-col
:span="4"
style="padding-top: 16px;"
>
<el-button <el-button
icon="el-icon-plus" icon="el-icon-plus"
@click="handleAdd" @click="handleAdd"
...@@ -10,7 +13,7 @@ ...@@ -10,7 +13,7 @@
</el-col> </el-col>
<el-col <el-col
style="text-align: right;" style="text-align: right;"
:span="16" :span="20"
> >
<glsx-combi-form <glsx-combi-form
ref="showSearch" ref="showSearch"
...@@ -20,7 +23,7 @@ ...@@ -20,7 +23,7 @@
<el-button <el-button
size="small" size="small"
type="primary" type="primary"
:id="tableParams.btnId" @click="keyDowmGetList"
>查询</el-button> >查询</el-button>
</glsx-combi-form> </glsx-combi-form>
</el-col> </el-col>
...@@ -33,19 +36,30 @@ ...@@ -33,19 +36,30 @@
:getListApi="getListApi" :getListApi="getListApi"
:beforeSearchFn="beforeSearchFn" :beforeSearchFn="beforeSearchFn"
> >
<span slot="auth-button"> <span
<el-button type="text">修改</el-button> slot="auth-button"
<el-button type="text">删除</el-button> slot-scope="scope"
>
<el-button
type="text"
@click="handleEdit(scope.scope)"
>修改</el-button>
<el-button
type="text"
@click="handleDelete(scope.scope)"
>删除</el-button>
</span> </span>
</glsx-table> </glsx-table>
<glsx-dialog <glsx-dialog
:title="title" :title="editForm.menuCode ? '编辑菜单' : '创建菜单'"
:isVisible="editVisible" :isVisible="editVisible"
@closeDialog="handleAdd" @closeDialog="handleClose"
@confirmDialog="handleAdd" @confirmDialog="handleConfirm"
> >
<glsx-combi-form <glsx-combi-form
labelWidth="100px" ref="editFormRef"
labelWidth="120px"
:formRef="editChildRef"
:formObj="editForm" :formObj="editForm"
:formData="editFormData" :formData="editFormData"
:formRules="editRule" :formRules="editRule"
...@@ -56,6 +70,7 @@ ...@@ -56,6 +70,7 @@
> >
<select-tree <select-tree
:form="editForm" :form="editForm"
:width="'300'"
:targetItem="scope.scope" :targetItem="scope.scope"
:treeData="baseData.menuTreeList" :treeData="baseData.menuTreeList"
:defaultProps="treeDefaultProps" :defaultProps="treeDefaultProps"
...@@ -65,7 +80,27 @@ ...@@ -65,7 +80,27 @@
<template <template
slot="menuIcon" slot="menuIcon"
slot-scope="scope" slot-scope="scope"
></template> >
<el-select
v-model="editForm[scope.scope.name]"
placeholder="请选择icon"
style="width: 300px"
>
<el-option
v-for="item in scope.scope.optionList"
:key="item[scope.scope.optionId]"
:label="item[scope.scope.optionLabel]"
:value="item[scope.scope.optionId]"
style="height: 100px;"
>
<el-image
style="width: 100px; height: 100px"
:src="item[scope.scope.optionLabel]"
fit="contain"
></el-image>
</el-option>
</el-select>
</template>
</glsx-combi-form> </glsx-combi-form>
</glsx-dialog> </glsx-dialog>
</div> </div>
...@@ -81,16 +116,18 @@ export default { ...@@ -81,16 +116,18 @@ export default {
data() { data() {
return { return {
searchForm: { searchForm: {
productId: [], productIds: [],
menuName: '' menuName: ''
}, },
tableSearchForm: {}, tableSearchForm: {
productIds: []
},
oldVal: { oldVal: {
productId: [] productIds: []
}, },
searchFormData: [{ searchFormData: [{
label: '产品', label: '产品',
name: 'productId', name: 'productIds',
type: 'select', type: 'select',
multiple: true, multiple: true,
optionList: [], optionList: [],
...@@ -99,7 +136,7 @@ export default { ...@@ -99,7 +136,7 @@ export default {
optionsName: 'productList', optionsName: 'productList',
changeAttr: (value, targetItem) => { changeAttr: (value, targetItem) => {
if (value.includes('')) { 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 !== '') this.searchForm[targetItem.name] = !this.oldVal[targetItem.name].includes('') ? targetItem.optionList.map(item => item[targetItem.optionId]) : this.searchForm[targetItem.name].filter(item => item !== '')
} else { } else {
if (this.oldVal[targetItem.name].includes('')) { if (this.oldVal[targetItem.name].includes('')) {
this.searchForm[targetItem.name] = [] this.searchForm[targetItem.name] = []
...@@ -108,6 +145,7 @@ export default { ...@@ -108,6 +145,7 @@ export default {
} }
} }
this.oldVal[targetItem.name] = this.searchForm[targetItem.name] this.oldVal[targetItem.name] = this.searchForm[targetItem.name]
this.tableSearchForm[targetItem.name] = this.searchForm[targetItem.name].includes('') ? [] : this.searchForm[targetItem.name]
} }
}, { }, {
label: '菜单名称', label: '菜单名称',
...@@ -117,7 +155,7 @@ export default { ...@@ -117,7 +155,7 @@ export default {
keyFn: this.keyDowmGetList keyFn: this.keyDowmGetList
}], }],
getListApi: menuApi.getListApi, getListApi: menuApi.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),
...@@ -137,7 +175,7 @@ export default { ...@@ -137,7 +175,7 @@ export default {
prop: 'menuUrl' prop: 'menuUrl'
}, { }, {
label: '父级菜单名', label: '父级菜单名',
prop: 'parentid' prop: 'parentId'
}, { }, {
label: '产品名称', label: '产品名称',
prop: '' prop: ''
...@@ -152,15 +190,24 @@ export default { ...@@ -152,15 +190,24 @@ export default {
// 弹窗 // 弹窗
title: '创建菜单', title: '创建菜单',
editVisible: false, editVisible: false,
editChildRef: 'editChildRef',
editForm: { editForm: {
menu: '', parentName: '',
menuId: '' parentId: ''
}, },
editRule: { editRule: {
productId: [{ required: true, message: '请选择产品', trigger: 'blur' }] productId: [{ required: true, message: '请选择产品', trigger: 'change' }],
parentId: [{ required: true, message: '请选择父级菜单', trigger: 'change' }],
menuName: [{ required: true, message: '请输入菜单名称', trigger: 'change' }],
menuUrl: [{ required: true, message: '请输入菜单地址', trigger: 'change' }],
iconId: [{ required: true, message: '请上传菜单ICON', trigger: 'change' }],
sort: [{ required: true, message: '请选择产品排序值', trigger: 'change' }],
menuPosition: [{ required: true, message: '请输入菜单位置', trigger: 'change' }]
}, },
treeDefaultProps: { treeDefaultProps: {
parent: 'parentId',
children: 'childlist', children: 'childlist',
value: 'id',
label: 'menuName' label: 'menuName'
}, },
editFormData: [{ editFormData: [{
...@@ -174,7 +221,8 @@ export default { ...@@ -174,7 +221,8 @@ export default {
optionsName: 'productList' optionsName: 'productList'
}, { }, {
label: '父级菜单', label: '父级菜单',
name: 'menu', name: 'parentId',
nameLabel: 'parentName',
addHtml: 'menuTree', addHtml: 'menuTree',
formName: 'editForm' formName: 'editForm'
}, { }, {
...@@ -190,18 +238,36 @@ export default { ...@@ -190,18 +238,36 @@ export default {
type: 'input' type: 'input'
}, { }, {
label: '菜单ICON', label: '菜单ICON',
name: '', name: 'iconId',
addHtml: 'menuIcon' type: 'select',
addHtml: 'menuIcon',
optionList: [],
optionId: 'id',
optionLabel: 'fileUrl',
optionsName: 'iconList'
}, { }, {
label: '菜单排序值', label: '菜单排序值',
name: 'sort', name: 'sort',
width: '300px', width: '100px',
type: 'input' type: 'select',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'sortList'
}, {
label: '',
name: 'menuPosition',
width: '200px',
type: 'input',
maxlength: 3,
placeholder: '请输入菜单位置'
}], }],
// 基本数据 // 基本数据
baseData: { baseData: {
productList: [], productList: [],
menuTreeList: [] menuTreeList: [],
sortList: [],
iconList: []
} }
} }
}, },
...@@ -211,14 +277,24 @@ export default { ...@@ -211,14 +277,24 @@ export default {
}, },
mounted() { mounted() {
baseApi.getAllDictApi({ dictType: 'product' }).then(res => { Promise.all([
// console.log(res) baseApi.getAllDictApi({ dictType: 'product' }),
this.baseData.productList = res.data baseApi.getAllDictApi({ dictType: 'sort_value' }),
baseApi.getIcon({ fileType: 2 })]).then(([product, sort, icon]) => {
this.baseData.productList = product.data
this.baseData.sortList = sort.data
this.baseData.iconList = icon.data
this.getOptionsList('searchFormData') this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false) this.getOptionsList('editFormData', false)
}) })
baseApi.getMenuTree().then(res => { baseApi.getMenuTree().then(res => {
// console.log(res.data)
this.baseData.menuTreeList = res.data this.baseData.menuTreeList = res.data
this.baseData.menuTreeList.unshift({
id: ' ',
menuName: '无(表示顶级菜单)',
childlist: []
})
}) })
}, },
...@@ -242,16 +318,59 @@ export default { ...@@ -242,16 +318,59 @@ export default {
beforeSearchFn() { beforeSearchFn() {
return new Promise(resolve => { return new Promise(resolve => {
this.tableSearchForm = _.cloneDeep(this.searchForm) this.tableSearchForm = _.cloneDeep(this.searchForm)
this.tableSearchForm.productId.includes('') && (this.tableSearchForm.productId = []) resolve(this.tableSearchForm)
resolve()
}) })
}, },
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
this.$refs.editFormRef && (this.$refs.editFormRef.$refs[this.editChildRef].clearValidate())
},
handleConfirm() {
// console.log(this.editForm)
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var apiName = this.editForm.menuCode ? 'updateMenuApi' : 'saveMenuApi'
menuApi[apiName](this.editForm).then(res => {
console.log(res)
if (res.code === '0') {
this.notice.okTips()
this.keyDowmGetList()
this.handleClose()
}
})
}
})
},
handleClose() {
this.editForm = {
parentName: '',
parentId: ''
}
this.$refs.editFormRef.$refs[this.editChildRef].clearValidate()
this.handleAdd()
},
handleEdit(row) {
// console.log(row)
this.editForm = _.cloneDeep(row)
this.handleAdd()
},
handleDelete(row) {
this.$confirm('是否删除菜单?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error'
}).then(() => {
menuApi.deleteMenuApi({ id: row.id }).then(res => {
if (res.code === '0') {
this.notice.okTips()
this.keyDowmGetList()
}
})
}).catch(() => { })
}, },
handleTreeSelect(obj) { handleTreeSelect(obj) {
this[obj.formName][obj.targetItem.name] = obj.val.menuName this[obj.formName][obj.targetItem.nameLabel] = obj.val ? obj.val.menuName : ''
this[obj.formName].menuId = obj.val.id this[obj.formName][obj.targetItem.name] = obj.val ? obj.val.id : ''
} }
} }
} }
......
...@@ -34,11 +34,13 @@ ...@@ -34,11 +34,13 @@
> >
<el-button <el-button
slot="auth-button" slot="auth-button"
slot-scope="scope"
type="text" type="text"
@click="handleProEdit(scope.scope)"
>修改</el-button> >修改</el-button>
</glsx-table> </glsx-table>
<glsx-dialog <glsx-dialog
:title="title" :title="editForm.productCode ? '编辑产品' : '创建产品'"
:isVisible="editVisible" :isVisible="editVisible"
@closeDialog="handleEditClose" @closeDialog="handleEditClose"
@confirmDialog="handleEditConfirm" @confirmDialog="handleEditConfirm"
...@@ -58,7 +60,7 @@ ...@@ -58,7 +60,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { productApi } from '@/api/productManage' import { productApi, baseApi } from '@/api/productManage'
export default { export default {
name: 'productList', name: 'productList',
data() { data() {
...@@ -74,7 +76,7 @@ export default { ...@@ -74,7 +76,7 @@ export default {
// keyFn: this.keyDowmGetList // keyFn: this.keyDowmGetList
}], }],
getListApi: productApi.getListApi, getListApi: productApi.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),
...@@ -127,8 +129,8 @@ export default { ...@@ -127,8 +129,8 @@ export default {
type: 'select', type: 'select',
width: '300px', width: '300px',
optionList: [], optionList: [],
optionId: 'confId', optionId: 'dictValue',
optionLabel: 'confLabel', optionLabel: 'dictLabel',
optionsName: 'productTypeList' optionsName: 'productTypeList'
}, { }, {
label: '产品说明', label: '产品说明',
...@@ -146,25 +148,13 @@ export default { ...@@ -146,25 +148,13 @@ export default {
}], }],
// 基本数据 // 基本数据
baseData: { baseData: {
productTypeList: [{ productTypeList: []
confId: '1',
confLabel: 'web'
}, {
confId: '2',
confLabel: '微信小程序'
}, {
confId: '3',
confLabel: '企微小程序'
}, {
confId: '4',
confLabel: 'H5'
}]
} }
} }
}, },
mounted() { mounted() {
this.getOptionsList('editFormData', false) this.getProductType()
}, },
methods: { methods: {
...@@ -184,9 +174,20 @@ export default { ...@@ -184,9 +174,20 @@ export default {
} }
}) })
}, },
getProductType() {
baseApi.getAllDictApi({ dictType: 'product_type' }).then(res => {
this.baseData.productTypeList = res.data
this.getOptionsList('editFormData', false)
})
},
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
}, },
handleProEdit(row) {
this.editForm = _.clone(row)
console.log(row)
this.handleAdd()
},
handleEditClose() { handleEditClose() {
this.editForm = { this.editForm = {
productName: '', productName: '',
...@@ -200,11 +201,16 @@ export default { ...@@ -200,11 +201,16 @@ export default {
handleEditConfirm() { handleEditConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => { this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) { if (valid) {
productApi.saveProApi({ productCode: '123', ...this.editForm }).then(res => { // productApi.saveProApi({ productCode: '123', ...this.editForm }).then(res => {
console.log(this.editForm)
var apiName = this.editForm.productCode ? 'updateProApi' : 'saveProApi'
productApi[apiName](this.editForm).then(res => {
console.log(res) console.log(res)
this.notice.okTips() this.notice.okTips()
this.handleEditClose() this.handleEditClose()
this.keyDowmGetList() this.keyDowmGetList()
}).catch(errMsg => {
this.notice.errorTips(errMsg)
}) })
} }
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!