Commit e86bcbbe by cwq0219

树形选择框,所属客户群体

1 parent 84e3eb11
...@@ -23,6 +23,11 @@ export const productApi = { ...@@ -23,6 +23,11 @@ export const productApi = {
getListApi(data = {}) { getListApi(data = {}) {
data.method = `${path}product.findProductByPage` data.method = `${path}product.findProductByPage`
return request(data) return request(data)
},
/** 新增产品 */
saveProApi(data = {}) {
data.method = `${path}product.saveProduct`
return request(data)
} }
} }
// 菜单 // 菜单
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
<template> <template>
<div class="glsx-combi-form"> <div class="glsx-combi-form">
<el-form <el-form
:ref="formRef"
:inline="true" :inline="true"
v-model="formObj" :model="formObj"
:label-width="labelWidth" :label-width="labelWidth"
:rules="formRules" :rules="formRules"
size="small" size="small"
...@@ -25,6 +26,8 @@ ...@@ -25,6 +26,8 @@
:maxlength="item.maxlength" :maxlength="item.maxlength"
:clearable="item.isClear || false" :clearable="item.isClear || false"
:type="item.inputType || 'text'" :type="item.inputType || 'text'"
:style="{ width: item.width || 'auto' }"
:show-word-limit="item.showLimit || false"
@keydown.native="e => handleInputDown(e, item)" @keydown.native="e => handleInputDown(e, item)"
></el-input> ></el-input>
<!-- 选择-输入框 --> <!-- 选择-输入框 -->
...@@ -167,6 +170,10 @@ export default { ...@@ -167,6 +170,10 @@ export default {
}, },
props: { props: {
formRef: {
type: String,
default: 'formRef'
},
labelWidth: { labelWidth: {
type: String, type: String,
default: '85px' default: '85px'
......
...@@ -113,7 +113,7 @@ export default { ...@@ -113,7 +113,7 @@ export default {
return data[this.defaultProps.label].indexOf(query) !== -1 return data[this.defaultProps.label].indexOf(query) !== -1
}, },
handleNodeClick(val) { handleNodeClick(val) {
this.$emit('selected', { val: val, targetItem: this.targetItem }) this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName })
} }
} }
} }
......
...@@ -66,10 +66,19 @@ ...@@ -66,10 +66,19 @@
:formData="editFormData" :formData="editFormData"
:formRules="editRule" :formRules="editRule"
> >
<el-select
slot="parentid" <template
slot="menuTree"
slot-scope="scope" 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-combi-form>
</glsx-dialog> </glsx-dialog>
</div> </div>
...@@ -77,8 +86,8 @@ ...@@ -77,8 +86,8 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import OwnCusCom from './components/OwnCusCom' import OwnCusCom from '../components/OwnCusCom'
import SelectTree from './components/SelectTree' import SelectTree from '../components/SelectTree'
import { functionApi, baseApi } from '@/api/productManage' import { functionApi, baseApi } from '@/api/productManage'
export default { export default {
name: 'functionList', name: 'functionList',
...@@ -127,7 +136,8 @@ export default { ...@@ -127,7 +136,8 @@ export default {
}, { }, {
label: '菜单', label: '菜单',
name: 'menu', name: 'menu',
addHtml: 'menuTree' addHtml: 'menuTree',
formName: 'searchForm'
}, { }, {
label: '商户账户类型', label: '商户账户类型',
name: '', name: '',
...@@ -208,9 +218,10 @@ export default { ...@@ -208,9 +218,10 @@ export default {
optionLabel: 'dictLabel', optionLabel: 'dictLabel',
optionsName: 'productList' optionsName: 'productList'
}, { }, {
label: '父级菜单', label: '菜单',
name: 'parentid', name: 'menu',
addHtml: 'parentid' addHtml: 'menuTree',
formName: 'editForm'
}, { }, {
label: '功能名称', label: '功能名称',
name: '', name: '',
...@@ -334,8 +345,8 @@ export default { ...@@ -334,8 +345,8 @@ export default {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
}, },
handleTreeSelect(obj) { handleTreeSelect(obj) {
this.searchForm[obj.targetItem.name] = obj.val.menuName this[obj.formName][obj.targetItem.name] = obj.val.menuName
this.searchForm.menuId = obj.val.id this[obj.formName].menuId = obj.val.id
} }
} }
} }
......
...@@ -50,10 +50,22 @@ ...@@ -50,10 +50,22 @@
:formData="editFormData" :formData="editFormData"
:formRules="editRule" :formRules="editRule"
> >
<el-select <template
slot="parentid" slot="menuTree"
slot-scope="scope" 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-combi-form>
</glsx-dialog> </glsx-dialog>
</div> </div>
...@@ -62,6 +74,7 @@ ...@@ -62,6 +74,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { Util } from '@/common/util' import { Util } from '@/common/util'
import SelectTree from '../components/SelectTree'
import { menuApi, baseApi } from '@/api/productManage' import { menuApi, baseApi } from '@/api/productManage'
export default { export default {
name: 'menuList', name: 'menuList',
...@@ -81,8 +94,8 @@ export default { ...@@ -81,8 +94,8 @@ export default {
type: 'select', type: 'select',
multiple: true, multiple: true,
optionList: [], optionList: [],
optionId: 'id', optionId: 'dictValue',
optionLabel: 'productName', optionLabel: 'dictLabel',
optionsName: 'productList', optionsName: 'productList',
changeAttr: (value, targetItem) => { changeAttr: (value, targetItem) => {
if (value.includes('')) { if (value.includes('')) {
...@@ -139,52 +152,74 @@ export default { ...@@ -139,52 +152,74 @@ export default {
// 弹窗 // 弹窗
title: '创建菜单', title: '创建菜单',
editVisible: false, editVisible: false,
editForm: {}, editForm: {
menu: '',
menuId: ''
},
editRule: { editRule: {
productId: [{ required: true, message: '请选择产品', trigger: 'blur' }] productId: [{ required: true, message: '请选择产品', trigger: 'blur' }]
}, },
treeDefaultProps: {
children: 'childlist',
label: 'menuName'
},
editFormData: [{ editFormData: [{
label: '产品', label: '产品',
name: 'productId', name: 'productId',
width: '300px',
type: 'select', type: 'select',
optionList: [], optionList: [],
optionId: 'id', optionId: 'dictValue',
optionLabel: 'productName', optionLabel: 'dictLabel',
optionsName: 'productList' optionsName: 'productList'
}, { }, {
label: '父级菜单', label: '父级菜单',
name: 'parentid', name: 'menu',
addHtml: 'parentid' addHtml: 'menuTree',
formName: 'editForm'
}, { }, {
label: '菜单名称', label: '菜单名称',
name: 'menuName', name: 'menuName',
type: 'input', type: 'input',
width: '300px',
maxlength: 15 maxlength: 15
}, { }, {
label: '菜单地址', label: '菜单地址',
name: 'menuUrl', name: 'menuUrl',
width: '300px',
type: 'input' type: 'input'
}, { }, {
label: '菜单ICON' label: '菜单ICON',
name: '',
addHtml: 'menuIcon'
}, { }, {
label: '菜单排序值', label: '菜单排序值',
name: 'sort', name: 'sort',
width: '300px',
type: 'input' type: 'input'
}], }],
// 基本数据 // 基本数据
baseData: { baseData: {
productList: [] productList: [],
menuTreeList: []
} }
} }
}, },
components: {
SelectTree
},
mounted() { mounted() {
baseApi.getAllProduct().then(res => { baseApi.getAllDictApi({ dictType: 'product' }).then(res => {
console.log(res) // console.log(res)
this.baseData.productList = res.data this.baseData.productList = res.data
this.getOptionsList('searchFormData') this.getOptionsList('searchFormData')
this.getOptionsList('editFormData', false) this.getOptionsList('editFormData', false)
}) })
baseApi.getMenuTree().then(res => {
this.baseData.menuTreeList = res.data
})
}, },
methods: { methods: {
...@@ -213,6 +248,10 @@ export default { ...@@ -213,6 +248,10 @@ export default {
}, },
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible 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 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$/)
...@@ -11,12 +12,7 @@ Apps.keys().map(item => { ...@@ -11,12 +12,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)
}) })
}) })
// base.getConfig().then(data => {
// const { vue, config } = data
// vue.use(GlsxVueCommon, config)
// base.render(App)
// })
<!-- 产品列表 --> <!-- 产品列表 -->
<template> <template>
<div> <div class="prodect-list">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-button <el-button
...@@ -40,11 +40,13 @@ ...@@ -40,11 +40,13 @@
<glsx-dialog <glsx-dialog
:title="title" :title="title"
:isVisible="editVisible" :isVisible="editVisible"
@closeDialog="handleAdd" @closeDialog="handleEditClose"
@confirmDialog="handleAdd" @confirmDialog="handleEditConfirm"
> >
<glsx-combi-form <glsx-combi-form
ref="editFormRef"
labelWidth="100px" labelWidth="100px"
:formRef="editChildRef"
:formObj="editForm" :formObj="editForm"
:formData="editFormData" :formData="editFormData"
:formRules="editRule" :formRules="editRule"
...@@ -101,20 +103,29 @@ export default { ...@@ -101,20 +103,29 @@ export default {
// 弹窗 // 弹窗
title: '创建产品', title: '创建产品',
editVisible: false, editVisible: false,
editForm: {}, editChildRef: 'editChildRef',
editForm: {
productName: '',
productType: '',
productDetail: '',
productAddress: ''
},
editRule: { 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: [{ editFormData: [{
label: '产品名称', label: '产品名称',
name: 'productName', name: 'productName',
type: 'input', type: 'input',
maxlength: 15, maxlength: 15,
isClear: true width: '300px'
}, { }, {
label: '产品类型', label: '产品类型',
name: 'productType', name: 'productType',
type: 'select', type: 'select',
width: '300px',
optionList: [], optionList: [],
optionId: 'confId', optionId: 'confId',
optionLabel: 'confLabel', optionLabel: 'confLabel',
...@@ -124,12 +135,14 @@ export default { ...@@ -124,12 +135,14 @@ export default {
name: 'productDetail', name: 'productDetail',
type: 'input', type: 'input',
inputType: 'textarea', inputType: 'textarea',
maxlength: 50 maxlength: 50,
showLimit: true,
width: '300px'
}, { }, {
label: '产品地址', label: '产品地址',
name: 'productAddress', name: 'productAddress',
type: 'input', type: 'input',
isClear: true width: '300px'
}], }],
// 基本数据 // 基本数据
baseData: { baseData: {
...@@ -142,6 +155,9 @@ export default { ...@@ -142,6 +155,9 @@ export default {
}, { }, {
confId: '3', confId: '3',
confLabel: '企微小程序' confLabel: '企微小程序'
}, {
confId: '4',
confLabel: 'H5'
}] }]
} }
} }
...@@ -170,10 +186,35 @@ export default { ...@@ -170,10 +186,35 @@ export default {
}, },
handleAdd() { handleAdd() {
this.editVisible = !this.editVisible 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> </script>
<style scoped> <style>
.prodect-list .el-textarea__inner {
height: 80px;
}
</style> </style>
\ No newline at end of file \ 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!