Commit 84fadbde by zhangquan

案例管理接口联调

1 parent d6704bf3
import { http } from '@/main'
const url = 'rop-scrm-shopmall/router'
// 分页查询频道列表
const getCaseListApi = params => {
params.method = `scrm.api.shopmall.discover.case.page`
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const getVideoListApi = params => {
params.method = `scrm.api.shopmall.tencentcloudmedia.page`
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const delCaseApi = params => {
params.method = `scrm.api.shopmall.discover.case.delete`
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const addCaseApi = params => {
params.method = `scrm.api.shopmall.discover.case.insert.or.update`
return http({
url,
method: 'post',
data: params,
sign: true
})
}
const getCarSeriesApi= params => {
params.method = 'scrm.api.carlife.common.getCarBrandList'
return http({
url: 'rop-scrm-carlife/router',
method: 'GET',
data: params,
sign: true
})
}
const getCaseDetailApi = params => {
params.method = 'scrm.api.shopmall.discover.case.detail'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
export default {
getCaseListApi,
getVideoListApi,
delCaseApi,
addCaseApi,
getCarSeriesApi,
getCaseDetailApi
}
\ No newline at end of file \ No newline at end of file
...@@ -207,13 +207,5 @@ const getCouponconfig = params => { ...@@ -207,13 +207,5 @@ const getCouponconfig = params => {
}) })
} }
const getCarSeriesApi= params => {
params.method = 'scrm.api.carlife.common.getCarBrandList' export default { getCouponconfig, configCoupons, getDirectionalGiftListApi, deleteChannel, updownshelvesChannel, topshelvesChannel, goodsActivity, crowdfundingActivity, bulgeActivity, getTencentcloudmedialist, addChannelTopic, getTopicDetail, getChannelTopicList, getMerchantListApi, openSubscribe, selStoreConfig, getMerchantShare, configMerchant, getconfigMerchant }
return http({
url: 'rop-scrm-carlife/router',
method: 'POST',
data: params,
sign: true
})
}
export default { getCouponconfig, configCoupons, getDirectionalGiftListApi, deleteChannel, updownshelvesChannel, topshelvesChannel, goodsActivity, crowdfundingActivity, bulgeActivity, getTencentcloudmedialist, addChannelTopic, getTopicDetail, getChannelTopicList, getMerchantListApi, openSubscribe, selStoreConfig, getMerchantShare, configMerchant, getconfigMerchant, getCarSeriesApi }
<template> <template>
<div class="case-ctnr"> <div class="case-ctnr">
<div class="main-wrap"> <div class="main-wrap">
<div class="global-title">新增案例</div> <div class="global-title">{{formObj.id ? '编辑案例': '新增案例'}}</div>
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule"> <glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="videoCoverSlot"> <div slot="videoCoverSlot">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.videoCoverArr" @change="changeChannelImg"></glsx-preview> <glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.videoCoverArr" @change="changeChannelImg"></glsx-preview>
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
</el-radio-group> </el-radio-group>
<div v-if="formObj.brandType == 2"> <div v-if="formObj.brandType == 2">
<el-button class="el-icon-plus" size="small" @click="openBrandDialog">选择品牌</el-button> <el-button class="el-icon-plus" size="small" @click="openBrandDialog">选择品牌</el-button>
<div class="brand-wrap" v-if="brandList && brandList.length">
<div class="brand-item" v-for="item in brandList" :key="item.id">{{ item.name }}</div>
</div>
</div> </div>
</div> </div>
</glsx-combi-form> </glsx-combi-form>
...@@ -22,32 +25,32 @@ ...@@ -22,32 +25,32 @@
<el-button @click="handleCancel">取消</el-button> <el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button> <el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter> </GLFooter>
<GLDialog title="选择车系" <selectCarSeriesDialog v-if="dialogVisible" :listData="brandList" @confirmDialog="confirmDialog" @closeDialog="openBrandDialog" :dialogVisible="dialogVisible"></selectCarSeriesDialog>
mode="mid"
:visible.sync="dialogVisible"
:before-close="handleClose"
:close-on-click-modal="false"
@onOk="handleConfirm"
@onCancel="handleClose">
<div class="car-container">
</div>
</GLDialog>
</div> </div>
</template> </template>
<script> <script>
import glsxCombiForm from '@/components/glsx-combi-form' import glsxCombiForm from '@/components/glsx-combi-form'
import selectCarSeriesDialog from './components/selectCarSeriesDialog'
export default { export default {
name: 'add', name: 'add',
components: { components: {
glsxCombiForm glsxCombiForm,
selectCarSeriesDialog
}, },
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
formObj:{ formObj:{
id: '',
mediaId: '',
caseName: '',
coverUrl: '',
introduction: '',
brandType: 1, brandType: 1,
videoCoverArr: [] videoCoverArr: []
}, },
brandList: [],
posterOptions: { posterOptions: {
width: '104px', width: '104px',
height: '138px', height: '138px',
...@@ -55,31 +58,57 @@ export default { ...@@ -55,31 +58,57 @@ export default {
isClose: true isClose: true
}, },
myRule:{ myRule:{
title: [{ required: true, message: '请输入案例名称', trigger: 'blur' }], caseName: [{ required: true, message: '请输入案例名称', trigger: 'change' }],
channelStyle: [{ required: true, message: '请选择频道主题', trigger: 'change' }], mediaId: [{ required: true, message: '请选择视频', trigger: 'change' }],
coverUrl: [{ required: true, validator: (rule, value, callback) => {
if(this.formObj.videoCoverArr?.length!=1) {
callback(new Error(`请上传视频封面图`))
}else{
callback()
}
}, trigger: 'change' }],
introduction: [{ required: true, message: '请输入宣传文案', trigger: 'change' }],
brand: [{ required: true, validator: (rule, value, callback) => {
if(this.brandType!=1 && !this.brandList?.length) {
callback(new Error(`请选择品牌`))
}else{
callback()
}
}, trigger: 'blur' }],
}, },
formData:[ formData:[
{ {
label: '案例名称', label: '案例名称',
name: 'title', name: 'caseName',
type: 'input', type: 'input',
isDisabled: false isDisabled: false
}, },
{ {
label: '选择视频', label: '选择视频',
name: 'title', name: 'mediaId',
type: 'input', type: 'select',
isDisabled: false optionList:[],
optionId: 'id',
optionLabel: 'fileName',
isDisabled: false,
changeAttr:(id, row)=> {
const _target = row.optionList.find(item => item.id == id)
if(_target){
this.formObj.videoCoverArr = [_target.coverUrl]
this.formObj.introduction = _target.introduction
}
this.$refs.baseInfoRef.$refs.formRef.validateField('coverUrl')
}
}, },
{ {
label: '视频封面图', label: '视频封面图',
name: 'videoCover', name: 'coverUrl',
addHtml: 'videoCoverSlot' addHtml: 'videoCoverSlot'
}, },
{ {
label: '宣传文案', label: '宣传文案',
placeholder: '发现频道视频宣传语', placeholder: '发现频道视频宣传语',
name: 'title', name: 'introduction',
maxlength: 100, maxlength: 100,
type: 'input', type: 'input',
showLimit: true, showLimit: true,
...@@ -88,18 +117,76 @@ export default { ...@@ -88,18 +117,76 @@ export default {
}, },
{ {
label: '适用品牌', label: '适用品牌',
name: 'zone', name: 'brand',
addHtml: 'selectBrandSlot' addHtml: 'selectBrandSlot'
} }
], ],
} }
}, },
created(){
this.formObj.id = this.$route.query.id || ''
this.getVideoList()
this.getCaseDetailApi()
},
methods:{ methods:{
openBrandDialog(){ openBrandDialog(){
this.dialogVisible = !this.dialogVisible this.dialogVisible = !this.dialogVisible
}, },
getVideoList(){
this.$apis.case.getVideoListApi({pageSize: 10000, currentPage: 1}).then(res => {
if(res?.list?.length) {
const _target = this.formData.find(item => item.name == 'mediaId')
_target.optionList = res.list
}
})
},
changeChannelImg(val){ changeChannelImg(val){
console.log(val) this.$refs.baseInfoRef.$refs.formRef.validateField('coverUrl')
},
handleSave(){
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if(valid){
let params = JSON.parse(JSON.stringify(this.formObj))
params.coverUrl = this.formObj.videoCoverArr[0]
if(params.brandType == 2){
params.brandList = this.brandList.map(item => {
return { brandId: item.id , brandName: item.name}
})
}
delete params.videoCoverArr
delete params.brandType
if(!params.id) delete params.id
this.$apis.case.addCaseApi(params).then(res => {
console.log(res)
if(res){
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
},
handleCancel(){
this.$router.back()
},
confirmDialog(e){
this.brandList = e
this.$refs.baseInfoRef.$refs.formRef.validateField('brand')
this.openBrandDialog()
},
getCaseDetailApi(){
this.$apis.case.getCaseDetailApi({id: this.$route.query.id}).then(res => {
console.log(res)
if(res){
const attrList = ['id', 'mediaId', 'caseName', 'introduction']
attrList.forEach(key =>{
this.formObj[key] = res[key]
})
this.formObj.videoCoverArr = [res.coverUrl]
this.formObj.brandType = res.brandList?.length > 0 ? 2 : 1
this.brandList = res.brandList.map(item => ({id: item.brandId, name: item.brandName})) || []
}
})
} }
} }
} }
...@@ -110,6 +197,27 @@ export default { ...@@ -110,6 +197,27 @@ export default {
padding: 20px; padding: 20px;
background-color: #fff; background-color: #fff;
margin-bottom: 16px; margin-bottom: 16px;
.brand-wrap{
margin-top: 8px;
width: 580px;
height: 80px;
background: #FFFFFF;
border: 1px solid #E8E8EA;
border-radius: 4px;
padding: 6px 8px;
overflow-y: auto;
.brand-item{
display: inline-block;
padding: 0 8px;
height: 24px;
color: #666666;
line-height: 24px;
background: #FAFBFE;
border: 1px solid #E5E5E5;
border-radius: 4px;
margin-right: 4px;
}
}
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template>
<GLDialog title="选择品牌"
mode="mid"
:visible.sync="dialogVisible"
:before-close="handleClose"
:close-on-click-modal="false"
@onOk="handleConfirm"
@onCancel="handleClose">
<el-checkbox-group v-model="checkedList">
<el-checkbox v-for="item in carSeriesList" :key="item.id" :label="item.id">{{item.name}}</el-checkbox>
</el-checkbox-group>
</GLDialog>
</template>
<script>
export default {
name: 'selectCarSeriesDialog',
data() {
return {
checkedList:[],
carSeriesList: []
}
},
props: {
dialogVisible:{
type: Boolean,
default: false
},
listData:{
type: Array
}
},
created(){
this.checkedList = this?.listData.map(item => item.id)
this.getCarSeriesList()
},
mounted() {
},
methods: {
getCarSeriesList(){
this.$apis.case.getCarSeriesApi({}).then(res => {
if(res?.length){
console.log(res)
this.carSeriesList = res
}
})
},
handleClose(){
this.$emit('closeDialog')
},
handleConfirm(){
let list = []
this.carSeriesList.forEach(item =>{
if(this.checkedList.includes(item.id)) list.push(item)
})
this.$emit('confirmDialog', list)
}
}
}
</script>
<style lang="scss" scoped>
.el-checkbox{
display: block;
height: 32px;
line-height: 32px;
}
</style>
\ No newline at end of file \ No newline at end of file
...@@ -3,40 +3,60 @@ ...@@ -3,40 +3,60 @@
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm> <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="operate-wrap"> <div class="operate-wrap">
<span class="table-title">频道管理列表</span> <span class="table-title">频道管理列表</span>
<el-button class="operate-btn" type="primary" size="small" @click="handleAdd">新增案例</el-button> <el-button class="operate-btn" type="primary" size="small" @click="addCase()">新增案例</el-button>
</div> </div>
<GLTable ref="channelRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun"> <GLTable ref="caseRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
<div slot="brandSlot"> <div slot="imageSlot" class="table-image" slot-scope="scope">
<span>{{ brandList.slice(0, 3).join('、') }}</span> <el-popover placement="top" width="160" trigger="hover" popper-class="table-popover-block">
<img class="table-popover-img" :src="scope.scope.coverUrl" />
<img class="img-36 pointer" slot="reference" :src="scope.scope.coverUrl" />
</el-popover>
</div>
<div slot="brandSlot" slot-scope="scope">
<template v-if="scope.scope.brandList && scope.scope.brandList.length > 3">
<span>{{ filterBrand(scope.scope).slice(0, 3).join('、') }}</span>
<el-popover <el-popover
placement="top" placement="top"
width="400" width="400"
trigger="hover"> trigger="hover">
<span> <span>
{{brandList.join('、')}} {{scope.scope.brandList.join('、')}}
</span> </span>
<span class="more-brand" slot="reference">...[{{ brandList.length }}]</span> <span class="more-brand" slot="reference">...[{{ scope.scope.brandList.length }}]</span>
</el-popover> </el-popover>
</template>
<template v-else>
<span v-if="!scope.scope.brandList || !scope.scope.brandList.length">--</span>
<span>{{ filterBrand(scope.scope).join('、') }}</span>
</template>
</div> </div>
<div class="table-btns" slot="auth-button" slot-scope="scope"> <div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton> <GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</div> </div>
</GLTable> </GLTable>
<el-dialog class="image-dialog" :visible.sync="previewVideoVisible" width="30%">
<big-View ref="viewForm" v-if="previewVideoVisible" :dialogSrc="previewVideoUrl" dialogType="video"></big-View>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import * as dayjs from 'dayjs' import bigView from '@/components/big-view'
export default { export default {
name: 'App', name: 'App',
components: {
bigView
},
data() { data() {
return { return {
brandList:['丰田','本田','一汽大众','奔驰','宝马','奥迪','比亚迪'],
tableSearchForm: { tableSearchForm: {
channelName: '', caseName: '',
brandName: '',
createDate: [] createDate: []
}, },
previewVideoUrl: '',
previewVideoVisible: false,
buttonList: [ buttonList: [
{ {
type: 'el-button', type: 'el-button',
...@@ -46,7 +66,7 @@ ...@@ -46,7 +66,7 @@
fn: '预览' fn: '预览'
}, },
listeners: { listeners: {
click: row => this.updateStatus(row.scope.id, 1) click: row => this.previewFn(row.scope)
} }
}, },
{ {
...@@ -68,7 +88,7 @@ ...@@ -68,7 +88,7 @@
fn: '删除' fn: '删除'
}, },
listeners: { listeners: {
click: row => this.updateStatus(row.scope.id, 1) click: row => this.delCase(row.scope)
} }
} }
], ],
...@@ -77,7 +97,7 @@ ...@@ -77,7 +97,7 @@
searchFormData: [ searchFormData: [
{ {
label: '案例名称', label: '案例名称',
name: 'channelName', name: 'caseName',
type: 'input' type: 'input'
}, },
{ {
...@@ -97,25 +117,23 @@ ...@@ -97,25 +117,23 @@
}, },
{ {
label: '适用品牌', label: '适用品牌',
name: 'channelName', name: 'brandName',
type: 'input' type: 'input'
}, },
], ],
getListApi: this.$apis.channel.getChannelListApi, getListApi: this.$apis.case.getCaseListApi,
tableParams: { tableParams: {
listName: 'list', listName: 'list',
tableOption: true, tableOption: true,
tableColumns: [ tableColumns: [
{ {
label: '案例名称', label: '案例名称',
prop: 'channelName', prop: 'caseName'
formatter: cellValue => {
return cellValue.channelName || '--'
}
}, },
{ {
label: '缩略图', label: '缩略图',
addHtml: 'imageSlot' addHtml: 'imageSlot',
width: 150
}, },
{ {
label: '适用品牌', label: '适用品牌',
...@@ -123,21 +141,15 @@ ...@@ -123,21 +141,15 @@
}, },
{ {
label: '创建日期', label: '创建日期',
prop: 'createdDate', prop: 'createdDate'
formatter: cellValue => {
return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss')
}
}, },
{ {
label: '更新时间', label: '更新时间',
prop: 'createdDate', prop: 'updatedDate'
formatter: cellValue => {
return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss')
}
}, },
{ {
label: '操作人', label: '操作人',
prop: 'channelName' prop: 'updatedBy'
}, },
] ]
}, },
...@@ -147,13 +159,20 @@ ...@@ -147,13 +159,20 @@
created() {}, created() {},
mounted() {}, mounted() {},
methods: { methods: {
filterBrand({brandList}){
return brandList?.map(item => item.brandName) || []
},
previewFn(row){
console.log(this.previewVideoUrl)
this.previewVideoUrl = row?.mediaInfo?.mediaUrl
this.previewVideoVisible = true
},
getParams() { getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm)) var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) { if (this.tableSearchForm.createDate.length) {
params.createdDateStrat = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00' params.beginCreateTime = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.createdDateEnd = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59' params.endCreateTime = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
} }
return params return params
}, },
beforeSearchFn() { beforeSearchFn() {
...@@ -164,11 +183,12 @@ ...@@ -164,11 +183,12 @@
}) })
}, },
handleSearch() { handleSearch() {
this.$refs.channelRef.refreshTable() this.$refs.caseRef.refreshTable()
}, },
handleReset() { handleReset() {
this.tableSearchForm = { this.tableSearchForm = {
channelName: '', caseName: '',
brandName: '',
createDate: [] createDate: []
} }
this.searchForm = {} this.searchForm = {}
...@@ -176,16 +196,27 @@ ...@@ -176,16 +196,27 @@
}, },
setTableFinishFun() { setTableFinishFun() {
//接收到的数据为空 //接收到的数据为空
this.$refs.channelRef.data.length ? (this.$refs.channelRef.tableHeightValues = '') : this.$refs.channelRef.setTableHeightFun() this.$refs.caseRef.data.length ? (this.$refs.caseRef.tableHeightValues = '') : this.$refs.caseRef.setTableHeightFun()
}, },
addCase(val) { addCase(row={}, type) {
this.$router.push({ this.$router.push({
path: `/case/add?id=${val.id}&channelType=${val.channelType}&$title=频道设置` path: `/case/add?id=${row.id || ''}&$title=${type ? '编辑': '新增'}案例`
}) })
}, },
handleAdd(){ delCase({id, caseName}){
this.$router.push({ this.$confirm(`确定删除${caseName}吗`, '提示', {
path: `/case/add` confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis.case.delCaseApi({id}).then(res => {
if(res){
this.$message.success('删除成功')
}
})
}
}
}) })
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</div> </div>
<div slot="goodsInfoSlot" class="goods-wrap"> <div slot="goodsInfoSlot" class="goods-wrap">
<glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="goodsFormObj" :formData="goodsFormData" :formRules="goodsRule"> <glsx-combi-form :isInline="false" ref="goodsInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="goodsFormObj" :formData="goodsFormData" :formRules="goodsRule">
<div slot="selectGoodsSlot"> <div slot="uploadSlot">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.videoCoverArr" @change="changeChannelImg"></glsx-preview> <glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.videoCoverArr" @change="changeChannelImg"></glsx-preview>
</div> </div>
</glsx-combi-form> </glsx-combi-form>
...@@ -45,7 +45,14 @@ ...@@ -45,7 +45,14 @@
</el-select> </el-select>
</div> </div>
</div> </div>
<div slot="categorySlot">
<brandCascader v-model="brandId"></brandCascader>
</div>
</glsx-combi-form> </glsx-combi-form>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<GLDialog title="选择车系" <GLDialog title="选择车系"
mode="mid" mode="mid"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
...@@ -60,13 +67,16 @@ ...@@ -60,13 +67,16 @@
</template> </template>
<script> <script>
import glsxCombiForm from '@/components/glsx-combi-form' import glsxCombiForm from '@/components/glsx-combi-form'
import brandCascader from './components/brandCascader'
export default { export default {
name: 'add', name: 'add',
components: { components: {
glsxCombiForm glsxCombiForm,
brandCascader
}, },
data() { data() {
return { return {
brandId:'',
goodsFormObj:{ goodsFormObj:{
}, },
...@@ -79,7 +89,7 @@ export default { ...@@ -79,7 +89,7 @@ export default {
goodsFormData:[ goodsFormData:[
{ {
label: '商品图', label: '商品图',
addHtml: 'selectGoodsSlot', addHtml: 'uploadSlot',
isDisabled: false isDisabled: false
}, },
{ {
...@@ -149,7 +159,7 @@ export default { ...@@ -149,7 +159,7 @@ export default {
{ {
label: '关联商品分类', label: '关联商品分类',
name: 'title', name: 'title',
addHtml: 'selectBrandSlot' addHtml: 'categorySlot'
} }
], ],
selectedtableParams: { selectedtableParams: {
...@@ -178,6 +188,9 @@ export default { ...@@ -178,6 +188,9 @@ export default {
methods:{ methods:{
openBrandDialog(){ openBrandDialog(){
this.dialogVisible = !this.dialogVisible this.dialogVisible = !this.dialogVisible
},
handleSave(){
console.log(this.brandId)
} }
} }
} }
......
<template>
<div>
<div class="select-input-box" ref="cascaderRef" @click="switchBrand">
<div class="selectd-name">
{{curBrand[defaultProps.label]}}
</div>
<div>
<i v-show="!brandTree" class="el-icon-arrow-up" style="color:#909399"></i>
<i v-show="brandTree" class="el-icon-arrow-down" style="color:#909399"></i>
</div>
<div :class="['tree-box', {'arrowUp': arrowUp}]" v-show="brandTree">
<el-tree :default-expanded-keys="expandedList" accordion empty-text="暂无数据" class="filter-tree" :data="brandListTree" :props="defaultProps" node-key="id" ref="tree">
<div :class="['custom-tree-node',{'active': data.id == curBrand.id && node.level==2}]" slot-scope="{ node, data }" @click="selectBrand(node)" >
<span>{{ node.label }}</span>
</div>
</el-tree>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'selectBrand',
data() {
return {
brandTree: false,
arrowUp: false,
curBrand: {},
defaultProps: {
children: 'children',
label: 'label'
},
expandedList:[]
}
},
model: {
prop: 'value', // 默认是value
event: 'changeBrand', // 默认是input
},
props: {
value: {
type: String
},
brandListTree: {
type: Array,
default: ()=>{
return [{
id: 1,
label: '一级 1',
children: [{
id: 4,
label: '二级 1-1'
}]
}, {
id: 2,
label: '一级 2',
children: [{
id: 5,
label: '二级 2-1'
}, {
id: 6,
label: '二级 2-2'
}]
}, {
id: 3,
label: '一级 3',
children: [{
id: 7,
label: '二级 3-1'
}, {
id: 8,
label: '二级 3-2',
}]
}]
}
}
},
// watch: {
// value:{
// handler(nVal, oVal){
// console.log(nVal)
// },
// deep: true
// }
// },
mounted() {
document.addEventListener("click", this.eventListener);
},
beforeDestroy(){
document.removeEventListener("click", this.eventListener);
},
methods: {
eventListener(e){
if (!this.$refs?.cascaderRef?.contains(e.target)) this.brandTree = false;
},
// 显示隐藏
switchBrand() {
let distance = 0
try {
distance = window.innerHeight - this.$refs.cascaderRef.getBoundingClientRect().y -this.$refs.cascaderRef.getBoundingClientRect().height
} catch (error) {
console.log(error)
}
this.arrowUp = distance < 100 //判断是否向上展示
this.brandTree = !this.brandTree
this.$emit('clickBrand', this.brandTree)
},
selectBrand(e){
if(e.level==2) {
this.curBrand = e.data
this.$emit('changeBrand', this.curBrand.id)
}
}
}
}
</script>
<style lang="scss" scoped>
.select-input-box {
width: 100%;
height: 32px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #e5e5e5;
box-sizing: border-box;
padding: 8px;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
.selectd-name{
font-weight: 400;
font-size: 14px;
color: #666666;
}
}
.tree-box {
margin-top: 10px;
padding: 10px;
box-shadow: 0 6px 20px 0 #7a7a7a33;
border-radius: 4px;
background: #ffffff;
position: absolute;
width: 100%;
top: 100%;
box-sizing: border-box;
left: 0;
z-index: 20;
max-height: 300px;
overflow-y: auto;
.filter-tree {
.custom-tree-node{
width: 100%;
&:hover{
background-color: #F5F7FA;
}
}
.active{
color: #5850FF;
background: #5850ff1f!important;
}
/deep/ .el-tree-node:focus > .el-tree-node__content {
background-color: transparent !important;
}
/deep/ .el-tree-node__children .el-tree-node:hover > .el-tree-node__content {
background-color: transparent !important;
}
}
}
.arrowUp{
top: unset;
bottom: calc(100% + 8px);
box-shadow: 0 -6px 20px 0 #7a7a7a33;
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="nav">
<div style="display: inline-block;">
<div class="nav-item" :ref="'navRef'+index" v-for="(item,index) in rowList" :key="item.id" @click="selectNav(item)" :class="{'cur-nav':curNavId==item.id}">{{ item.name }}<i class="el-icon-close del-icon" @click.stop="delNav(item)"></i></div>
</div>
<div v-if="showInput" class="input-area"><el-input maxLength="15" ref="addInput" @blur="inputBlur" v-model="configName" class="input"></el-input></div>
<div v-else class="nav-item add-icon" style="cursor: pointer;" @click="addNav"><i class="el-icon-plus border"></i></div>
<div v-if="colList && colList.length" class="nav-item pull-btn" style="cursor: pointer;">
<i class="el-icon-arrow-down border"></i>
<div class="pull-down-wrap">
<div class="pull-down-item" @click="selectNav(item, 'sort')" :class="{'cur-nav':curNavId==item.id}" v-for="item in colList" :key="item.id">{{ item.name }}<i class="el-icon-close del-icon" @click.stop="delNav(item)"></i></div>
</div>
</div>
</div>
</template>
<script>
export default{
name: 'nav',
data(){
return {
curNavId: '',
rowList: [{
id: 1,
name: '你好'
},{
id: 2,
name: '你好啥事'
},{
id: 3,
name: '你好事实上'
}]
}
},
methods:{
selectNav(item){
this.curNavId = item.id
},
delNav(item){
},
inputBlur(){
},
addNav(){
}
}
}
</script>
<style scoped lang="scss">
.nav{
.input-area{
display: inline-block;
height: 40px;
line-height: 40px;
border-radius: 4px 4px 0 0;
margin-right: 1px;
.input{
width: 245px;
/deep/ .el-input__inner{
vertical-align: baseline;
box-sizing: border-box;
border: none;
}
}
}
.nav-item{
display: inline-block;
padding: 0 20px;
height: 40px;
line-height: 40px;
background-color: #F8F8F8;
border-radius: 4px 4px 0 0;
margin-right: 1px;
color: #666666;
letter-spacing: 0;
text-align: center;
cursor: pointer;
.del-icon{
font-size: 12px;
color: #666;
margin-left: 12px;
}
}
.cur-nav{
background-color: #fff;
color: #5850FF;
font-weight: 500;
}
.add-icon, .pull-btn{
width: 50px;
box-sizing: border-box;
padding: 0;
position: relative;
.border{
border: 1px dashed #999;
color: #999;
}
}
.pull-btn{
&:hover{
.pull-down-wrap{
display: block;
}
}
.pull-down-wrap{
display: none;
position: absolute;
width: 200px;
max-height: 200px;
overflow-y: auto;
right: 0;
background-color: #fff;
z-index: 2;
box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px 0 #00000014, 0 9px 28px 8px #0000000d;
border-radius: 4px;
.pull-down-item{
height: 36px;
line-height: 36px;
font-weight: 400;
padding: 0 15px;
font-size: 14px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: #666666;
background-color: #F8F8F8;
&:hover{
background-color: #f5f7fa;
}
}
.cur-nav{
background-color: #fff;
color: #5850FF;
font-weight: 500;
}
}
}
}
</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!