Commit 468cb76e by 前端

车主优选代码

1 parent e8fe61e7
...@@ -1901,6 +1901,51 @@ ...@@ -1901,6 +1901,51 @@
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true "dev": true
}, },
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"optional": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"optional": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"optional": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"optional": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"optional": true
},
"ssri": { "ssri": {
"version": "8.0.1", "version": "8.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz", "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz",
...@@ -1909,6 +1954,28 @@ ...@@ -1909,6 +1954,28 @@
"requires": { "requires": {
"minipass": "^3.1.1" "minipass": "^3.1.1"
} }
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"optional": true,
"requires": {
"has-flag": "^4.0.0"
}
},
"vue-loader-v16": {
"version": "npm:vue-loader@16.8.3",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz",
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
"dev": true,
"optional": true,
"requires": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"loader-utils": "^2.0.0"
}
} }
} }
}, },
...@@ -13222,75 +13289,6 @@ ...@@ -13222,75 +13289,6 @@
} }
} }
}, },
"vue-loader-v16": {
"version": "npm:vue-loader@16.8.3",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz",
"integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
"dev": true,
"optional": true,
"requires": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"loader-utils": "^2.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"optional": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"optional": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"optional": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"optional": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"optional": true
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"optional": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"vue-router": { "vue-router": {
"version": "3.6.5", "version": "3.6.5",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.6.5.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.6.5.tgz",
......
...@@ -18,7 +18,6 @@ const getCategoryListApi = params => { ...@@ -18,7 +18,6 @@ const getCategoryListApi = params => {
reject() reject()
}) })
} }
console.log(params, '8888')
params.method = 'scrm.api.shopmall.discover.category.page' params.method = 'scrm.api.shopmall.discover.category.page'
return http({ return http({
url, url,
...@@ -48,9 +47,20 @@ const batchAddCategoryApi = params => { ...@@ -48,9 +47,20 @@ const batchAddCategoryApi = params => {
}) })
} }
export default { const batchDetailApi = params => {
params.method = 'scrm.api.shopmall.discover.category.detail'
return http({
url,
method: 'post',
data: params,
sign: true
})
}
export default {
addCategoryApi, addCategoryApi,
getCategoryListApi, getCategoryListApi,
delCategoryApi, delCategoryApi,
batchAddCategoryApi
}
\ No newline at end of file \ No newline at end of file
batchAddCategoryApi,
batchDetailApi
}
<template> <template>
<div class="category-list-ctnr"> <div class="category-list-ctnr">
<GLTabs class="tabs" v-model="activeName" :tabPaneList="tabPaneList" @tab-click="handleClick"></GLTabs> <GLTabs class="tabs" v-model="activeName" :tabPaneList="tabPaneList" @tab-click="handleClick"></GLTabs>
<pullDownNav @confirmDialog="handleEdit" @inputBlur="inputBlur" @delete="delCategory" v-model="curMainCategoryId" :tabList="mainCategoryList" :defaultProps="{id: 'id', name: 'categoryName'}"></pullDownNav> <template v-if="activeName ==1">
<pullDownNav @confirmDialog="handleEdit" @inputBlur="inputBlur" @delete="delCategory" v-model="curMainCategoryId"
:tabList="mainCategoryList" :defaultProps="{id: 'id', name: 'categoryName'}"></pullDownNav>
<div class="main-wrap"> <div class="main-wrap">
<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="editCategory">新增二级分类</el-button> <el-button class="operate-btn" type="primary" size="small" @click="editCategory">新增二级分类</el-button>
</div> </div>
<GLTable ref="categoryRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun"> <GLTable ref="categoryRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm"
<div slot="brandSlot"> :beforeSearchFn="beforeSearchFn" :tableParams="tableParams" :pageConf="pageConf"
@setTableFinishFun="setTableFinishFun">
<div slot="brandSlot">
<span>{{ brandList.slice(0, 3).join('、') }}</span> <span>{{ brandList.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('、')}} {{ brandList.join('、') }}
</span> </span>
<span class="more-brand" slot="reference">...[{{ brandList.length }}]</span> <span class="more-brand" slot="reference">...[{{ brandList.length }}]</span>
</el-popover> </el-popover>
</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>
</div> </div>
</div> </template>
<template v-if="activeName==2">
<ownerPreference></ownerPreference>
</template>
</div>
</template> </template>
<script> <script>
import url from '@/assets/empty.png' import url from '@/assets/empty.png'
import * as dayjs from 'dayjs' import * as dayjs from 'dayjs'
import pullDownNav from './components/pullDownNav' import pullDownNav from './components/pullDownNav'
export default { import ownerPreference from "views/category/ownerPreference";
name: 'App',
components:{ export default {
pullDownNav name: 'App',
}, components: {
data() { pullDownNav,
return { ownerPreference
activeName: '', },
curMainCategoryId: '', data() {
tabPaneList: [], return {
mainCategoryList: [], activeName: '',
brandList:['丰田','本田','一汽大众','奔驰','宝马','奥迪','比亚迪'], curMainCategoryId: '',
buttonList: [ tabPaneList: [],
{ mainCategoryList: [],
type: 'el-button', brandList: ['丰田', '本田', '一汽大众', '奔驰', '宝马', '奥迪', '比亚迪'],
name: '编辑', buttonList: [
attrs: { {
type: 'text', type: 'el-button',
fn: '编辑' name: '编辑',
}, attrs: {
listeners: { type: 'text',
click: row => this.editCategory(row.scope) fn: '编辑'
}
}, },
{ listeners: {
type: 'el-button', click: row => this.editCategory(row.scope)
name: '删除',
attrs: {
type: 'text',
fn: '删除'
},
listeners: {
click: row => this.delCategory(row.scope, 1)
}
} }
],
tableSearchForm: {
categoryName: '',
createDate: []
}, },
searchForm: {}, {
url: url, type: 'el-button',
searchFormData: [ name: '删除',
{ attrs: {
label: '分类名称', type: 'text',
name: 'categoryName', fn: '删除'
type: 'input'
}, },
{ listeners: {
label: '创建日期', click: row => this.delCategory(row.scope, 1)
name: 'createDate', }
type: 'datePicker', }
isClear: true, ],
customPickerOptions: { tableSearchForm: {
disabledDate(date) { categoryName: '',
const yesterday = new Date(new Date().setDate(new Date().getDate())) createDate: []
if (date > yesterday) { },
return true searchForm: {},
} url: url,
return false searchFormData: [
{
label: '分类名称',
name: 'categoryName',
type: 'input'
},
{
label: '创建日期',
name: 'createDate',
type: 'datePicker',
isClear: true,
customPickerOptions: {
disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate()))
if (date > yesterday) {
return true
} }
return false
} }
} }
], }
getListApi: this.$apis.category.getCategoryListApi, ],
tableParams: { getListApi: this.$apis.category.getCategoryListApi,
listName: 'list', tableParams: {
tableOption: true, listName: 'list',
tableColumns: [ tableOption: true,
{ tableColumns: [
label: '二级分类名称', {
prop: 'categoryName' label: '二级分类名称',
}, prop: 'categoryName'
{ },
label: '创建日期', {
prop: 'createdDate' label: '创建日期',
}, prop: 'createdDate'
{ },
label: '更新时间', {
prop: 'updatedDate' label: '更新时间',
}, prop: 'updatedDate'
{ },
label: '操作人', {
prop: 'updatedBy' label: '操作人',
}, prop: 'updatedBy'
] },
}, ]
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
}
},
created() {
this.getChannelList()
},
watch:{
curMainCategoryId:{
handler(){
this.handleSearch()
},
deep: true
}, },
activeName:{ pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total'}
handler(){ }
this.getMainCategory() },
}, created() {
deep: true this.getChannelList()
},
watch: {
curMainCategoryId: {
handler() {
this.handleSearch()
}, },
deep: true
}, },
mounted() {}, activeName: {
methods: { handler() {
//获取频道名称 this.getMainCategory()
getChannelList() { },
this.$apis.channel deep: true
},
},
mounted() {
},
methods: {
//获取频道名称
getChannelList() {
this.$apis.channel
.getChannelListApi({ .getChannelListApi({
pageSize: 100, pageSize: 100,
pageNum: 1 pageNum: 1
}) })
.then(res => { .then(res => {
if(res?.list?.length){ if (res?.list?.length) {
let tabPaneList = [] let tabPaneList = []
res.list.forEach(item => { res.list.forEach(item => {
if(item.channelType == 5 || item.channelType == 5){ if (item.channelType == 5 || item.channelType == 5) {
tabPaneList.push({label: item.channelName,name: item.channelType==5 ? 1 : 2 ,merchantChannelId: item.id}) tabPaneList.push({
} label: item.channelName,
name: item.channelType == 5 ? 1 : 2,
merchantChannelId: item.id
})
}
})
tabPaneList.push({
label: '车主优选',
name: 2
}) })
this.tabPaneList = tabPaneList this.tabPaneList = tabPaneList
this.activeName = tabPaneList[0].name this.activeName = tabPaneList[0].name
} }
}) })
}, },
getMainCategory(){ getMainCategory() {
const params = { const params = {
pageSize: 1000, pageSize: 1000,
pageNum: 1, pageNum: 1,
categoryLevel: 1, categoryLevel: 1,
categoryType: this.activeName categoryType: this.activeName
}
this.$apis.category.getCategoryListApi(params).then(res => {
if (res?.list?.length) {
this.mainCategoryList = res.list
this.curMainCategoryId = res.list[0].id
} else {
this.curMainCategoryId = ''
} }
this.$apis.category.getCategoryListApi(params).then(res => { })
if(res?.list?.length){ },
this.mainCategoryList = res.list inputBlur(e) {
this.curMainCategoryId = res.list[0].id this.addCategory(e.value)
}else{ },
this.curMainCategoryId = '' handleEdit(e) {
} this.addCategory(e.categoryName, e.id)
}) },
}, delCategory(e, type) {
inputBlur(e){ this.$confirm(`删除后数据将无法恢复,是否确认删除${e.categoryName}?`, '提示', {
this.addCategory(e.value) confirmButtonText: '确定',
}, cancelButtonText: '取消',
handleEdit(e){ type: 'warning',
this.addCategory(e.categoryName, e.id) callback: action => {
}, if (action == 'confirm') {
delCategory(e, type){ this.$apis.category.delCategoryApi({id: e.id}).then(res => {
this.$confirm(`删除后数据将无法恢复,是否确认删除${e.categoryName}?`, '提示', { if (res) {
confirmButtonText: '确定', this.$message.success('删除成功')
cancelButtonText: '取消', this.getMainCategory()
type: 'warning', if (type) {
callback: action => { this.handleSearch()
if (action == 'confirm') {
this.$apis.category.delCategoryApi({id: e.id}).then(res => {
if(res){
this.$message.success('删除成功')
this.getMainCategory()
if(type) {
this.handleSearch()
}
} }
}) }
} })
}
})
},
addCategory(val, id){
let params = {
categoryType: this.activeName,
categoryLevel: 1,
categoryName: val
}
if(id) params.id = id
this.$apis.category.addCategoryApi(params).then(res => {
if(res){
this.$message.success('新增成功')
this.getMainCategory()
} }
})
},
getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) {
params.beginCreateTime = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endCreateTime = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
}
params.categoryType = 1
params.categoryLevel = 2
params.parentCategoryId = this.curMainCategoryId
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
delete this.searchForm.createDate
resolve()
})
},
handleSearch() {
this.$refs.categoryRef.refreshTable()
},
handleReset() {
this.tableSearchForm = {
channelName: '',
createDate: []
} }
this.searchForm = {} })
this.handleSearch() },
}, addCategory(val, id) {
setTableFinishFun() { let params = {
//接收到的数据为空 categoryType: this.activeName,
this.$refs.categoryRef.data.length ? (this.$refs.categoryRef.tableHeightValues = '') : this.$refs.categoryRef.setTableHeightFun() categoryLevel: 1,
}, categoryName: val
editCategory(row={}) { }
if(!this.activeName) return this.$message.error('暂无频道') if (id) params.id = id
const target = this.mainCategoryList.find(item => item.id == this.curMainCategoryId) this.$apis.category.addCategoryApi(params).then(res => {
if(!target) return this.$message.error('请选择一级分类') if (res) {
const params = { this.$message.success('新增成功')
categoryType: this.activeName, this.getMainCategory()
parentCategoryId: target.id,
parentCategoryName: target.categoryName
}
if(row.id) {
params.id = row.id
params.name = row.categoryName
} }
const queryStr = encodeURIComponent(JSON.stringify(params)) })
this.$router.push({ path: `/category/add/`+queryStr,query: { $title: row.id ? '编辑二级分类' : '新增二级分类' }}) },
getParams() {
var params = JSON.parse(JSON.stringify(this.tableSearchForm))
if (this.tableSearchForm.createDate.length) {
params.beginCreateTime = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.endCreateTime = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
} }
params.categoryType = 1
params.categoryLevel = 2
params.parentCategoryId = this.curMainCategoryId
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.searchForm = this.getParams()
delete this.searchForm.createDate
resolve()
})
},
handleSearch() {
this.$refs.categoryRef.refreshTable()
},
handleReset() {
this.tableSearchForm = {
channelName: '',
createDate: []
}
this.searchForm = {}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.categoryRef.data.length ? (this.$refs.categoryRef.tableHeightValues = '') : this.$refs.categoryRef.setTableHeightFun()
},
editCategory(row = {}) {
if (!this.activeName) return this.$message.error('暂无频道')
const target = this.mainCategoryList.find(item => item.id == this.curMainCategoryId)
if (!target) return this.$message.error('请选择一级分类')
const params = {
categoryType: this.activeName,
parentCategoryId: target.id,
parentCategoryName: target.categoryName
}
if (row.id) {
params.id = row.id
params.name = row.categoryName
}
const queryStr = encodeURIComponent(JSON.stringify(params))
this.$router.push({path: `/category/add/` + queryStr, query: {$title: row.id ? '编辑二级分类' : '新增二级分类'}})
} }
} }
</script> }
</script>
<style scoped lang="scss"> <style scoped lang="scss">
.category-list-ctnr{ .category-list-ctnr {
.tabs{ .tabs {
margin-bottom: 16px; margin-bottom: 16px;
} }
.main-wrap{
background-color: #fff; .main-wrap {
padding: 20px; background-color: #fff;
padding: 20px;
} }
.more-brand{
color: #5850FF; .more-brand {
cursor: pointer; color: #5850FF;
cursor: pointer;
} }
} }
</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!