Commit ff436a7a by 杨北旺

分类联调

1 parent b66f21d0
......@@ -83,7 +83,42 @@ const getStrategyDetailApi = params => {
sign: true
})
}
// 新增or更新攻略分类
const addOrEditClass = params => {
params.method = `${defaultPath}category.insert.or.update`
return http({
url,
data: params,
sign: true
})
}
// 攻略分类置顶
const classSetToTop = params => {
params.method = `${defaultPath}category.top.set`
return http({
url,
data: params,
sign: true
})
}
// 攻略分类删除
const deleteclass = params => {
params.method = `${defaultPath}category.delete`
return http({
url,
data: params,
sign: true
})
}
// 分类列表
const classList = params => {
params.method = `${defaultPath}category.page`
return http({
url,
data: params,
sign: true
})
}
export default {
getListApi,
updateMainFlagApi,
......@@ -92,5 +127,9 @@ export default {
topStrategyApi,
exportListApi,
addStrategyApi,
getStrategyDetailApi
getStrategyDetailApi,
addOrEditClass,
classSetToTop,
classList,
deleteclass
}
\ No newline at end of file
......@@ -6,12 +6,12 @@
<el-button size="small" type="primary" @click="addClass(1)">新增</el-button>
</div>
</div>
<GLTable ref="tableRef" :pageConf="pageConf" :searchForm="searchFormObj" :tableParams="tableParams" :beforeSearchFn="beforeSearchFn">
<GLTable ref="tableRef" :getListApi="getListApi" :pageConf="pageConf" :searchForm="searchFormObj" :tableParams="tableParams" :beforeSearchFn="beforeSearchFn">
<div slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
<GLDialog class="dialog_wrap" okText="提交" :title="modalTitle" mode="mid" :visible.sync="isVisible" :show-close="showClose" :before-close="handleClose" @onOk="onOk" @onCancel="handleClose" :close-on-click-modal="false">
<GLDialog class="dialog_wrap" okText="提交" :title="modalTitle" mode="mid" :visible.sync="isVisible" :show-close="showClose" :before-close="handleClose" @onOk="toAddCategory" @onCancel="handleClose" :close-on-click-modal="false">
<div class="wrap">
<div class="labelName">
<span class="require">*</span>
......@@ -23,20 +23,21 @@
<el-dialog title="提示" width="576px" @close="cancelTop" :visible.sync="dialogVisible">
<div class="warning_body">
<div class="header">
<i class="el-icon-warning"></i>
<i style="color:#5850FF" class="el-icon-warning"></i>
<span class="title">确定置顶此分类?</span>
<span class="cont">置顶后,分类数据在列表栏和小程序攻略专区里均优先展示</span>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button :size="size" @click="cancelTop">取 消</el-button>
<el-button :size="size" type="primary" @click="handleTop">确 定</el-button>
<el-button :size="size" type="primary" @click="toSetTopCategory">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import util from '@/util/util'
export default {
name: 'classManagerIndex',
data() {
......@@ -49,11 +50,14 @@ export default {
tableColumns: [
{
label: '分类名称',
prop: 'strategyName'
prop: 'categoryName'
},
{
label: '创建时间',
prop: 'createdDate'
prop: 'createdDate',
formatter: cellValue => {
return cellValue.createdDate ? util.dateFormat(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss') : '-'
}
}
]
},
......@@ -77,7 +81,7 @@ export default {
fn: '删除'
},
listeners: {
click: row => this.delClass(row.scope)
click: row => this.toDeleteCategory(row.scope.id)
}
},
{
......@@ -88,42 +92,95 @@ export default {
fn: '置顶'
},
listeners: {
click: row => this.topClass(row.scope)
click: row => this.topClass(row.scope.id)
}
}
],
isVisible: false,
modalTitle: '新增',
categoryName: '',
dialogVisible: false
dialogVisible: false,
getListApi: this.$apis.strategy.classList
}
},
components: {},
mounted() {},
mounted() {
console.log(util.dateFormat(1702518870000))
},
methods: {
topClass() {},
delClass() {},
addClass(type) {
topClass(id) {
this.topId = id
this.dialogVisible = true
},
addClass(type, row) {
this.isVisible = true
this.modalTitle = type == 2 ? '编辑' : '新增'
if (type == 2) {
this.categoryName = row.categoryName
this.editId = row.id
}
},
handleClose() {
this.isVisible = false
},
onOk() {
this.handleClose()
},
intClassName(e) {
this.categoryName = e
},
cancelTop() {
this.dialogVisible = false
},
handleTop() {
this.cancelTop()
// 添加分类
toAddCategory() {
if (!this.categoryName) return this.$message.error('请输入分类名称')
let query = {
categoryName: this.categoryName
}
if (this.editId) query.id = this.editId
this.$apis.strategy.addOrEditClass(query).then(res => {
if (res) {
this.$message.success('操作成功')
this.$refs.tableRef.refreshTable()
this.handleClose()
this.categoryName = ''
}
})
},
// 删除分类
toDeleteCategory(id) {
if (!id) return
this.$confirm('是否删除该分类', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis.strategy.deleteclass({ id }).then(res => {
if (res) {
this.$message.success('删除成功')
this.$refs.tableRef.refreshTable()
}
})
}
}
})
},
// 置顶分类
toSetTopCategory() {
if (!this.topId) return
const query = {
id: this.topId,
topFlag: 1
}
this.$apis.strategy.classSetToTop(query).then(res => {
if (res) {
this.$message.success('置顶成功')
this.$refs.tableRef.refreshTable()
this.cancelTop()
}
})
}
}
}
......
<!-- 秒杀活动 -->
<template>
<div class="ctnr">
<div class="global-title">基础信息</div>
<div class="main">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px"
defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="coverSlot">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverArr"
@change="changeChannelImg"></glsx-preview>
</div>
<div slot="richTextSlot">
<textBox @change="writeChange" ref="textBox" @forbid="forbidEdit"></textBox>
</div>
</glsx-combi-form>
<div class="ctnr">
<div class="global-title">基础信息</div>
<div class="main">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<div slot="coverSlot">
<glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverArr" @change="changeChannelImg"></glsx-preview>
</div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
<div slot="richTextSlot">
<textBox @change="writeChange" ref="textBox" @forbid="forbidEdit"></textBox>
</div>
</glsx-combi-form>
</div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
</div>
</template>
<script>
......@@ -28,127 +26,146 @@ import textBox from '@/components/text-box'
import preview from '@/components/preview'
export default {
name: 'add',
data() {
return {
myRule: {
strategyName: [{required: true, message: '请输入攻略名称', trigger: 'change'}],
categoryName: [{required: true, message: '请选择分类名称', trigger: 'change'}],
strategyImg: [{
required: true, validator: (rule, value, callback) => {
if (this.formObj.coverArr?.length != 1) {
callback(new Error(`请上传分类图标`))
} else {
callback()
}
}, trigger: 'change'
}],
content: [{required: true, message: '请输入攻略内容', trigger: 'change'}],
},
formObj: {
id: '',
coverArr: [],
strategyImg: '',
strategyName: '',
content: '',
categoryName:''
},
formData: [
{
label: '攻略名称',
name: 'strategyName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
{
label: '分类名称',
name: 'categoryName',
type: 'select',
isDisabled: false
name: 'add',
data() {
return {
myRule: {
strategyName: [{ required: true, message: '请输入攻略名称', trigger: 'change' }],
categoryName: [{ required: true, message: '请选择分类名称', trigger: 'change' }],
strategyImg: [
{
required: true,
validator: (rule, value, callback) => {
if (this.formObj.coverArr?.length != 1) {
callback(new Error(`请上传分类图标`))
} else {
callback()
}
},
{
label: '攻略宣传图',
name: 'strategyImg',
addHtml: 'coverSlot'
},
{
label: '攻略内容',
addHtml: 'richTextSlot'
}
trigger: 'change'
}
],
}
content: [{ required: true, message: '请输入攻略内容', trigger: 'change' }]
},
formObj: {
id: '',
coverArr: [],
strategyImg: '',
strategyName: '',
content: '',
categoryId: ''
},
formData: [
{
label: '攻略名称',
name: 'strategyName',
maxlength: 20,
showLimit: true,
type: 'input',
isDisabled: false
},
{
label: '分类名称',
name: 'categoryId',
type: 'select',
isDisabled: false,
isClear: true,
optionList: [],
optionId: 'id',
optionLabel: 'categoryName',
optionsName: 'categoryList'
},
{
label: '攻略宣传图',
name: 'strategyImg',
addHtml: 'coverSlot'
},
{
label: '攻略内容',
addHtml: 'richTextSlot'
}
]
}
},
components: {
glsxCombiForm,
glsxPreview: preview,
textBox
},
created() {
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
console.log(this.routeInfo)
if (this.routeInfo.id) {
this.getDetail()
}
this.getCategoryList()
},
mounted() {},
methods: {
writeChange(val) {
this.formObj.content = val
},
components: {
glsxCombiForm,
glsxPreview: preview,
textBox
getDetail() {
this.$apis.strategy.getStrategyDetailApi({ id: this.routeInfo.id }).then(res => {
if (res) {
console.log(res)
for (const key in this.formObj) {
if (key != 'coverArr') {
this.formObj[key] = res[key]
}
}
this.$refs.textBox.setEdit(res.content)
this.formObj.coverArr = res.strategyImg ? [res.strategyImg] : []
}
})
},
created() {
const urlParam = this.$route.params
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id))
console.log(this.routeInfo)
if(this.routeInfo.id) {
this.getDetail()
handleSave() {
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if (valid) {
let params = utils.deepClone(this.formObj)
params.strategyImg = params.coverArr[0]
params.mainFlag = 1
if (!params.id) delete params.id
delete params.coverArr
console.log(params);
this.$apis.strategy.addStrategyApi(params).then(res => {
console.log(res)
if (res) {
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
},
mounted() {
handleCancel() {
this.$router.back()
},
methods: {
writeChange(val) {
this.formObj.content = val
},
getDetail(){
this.$apis.strategy.getStrategyDetailApi({id: this.routeInfo.id}).then(res => {
if(res) {
console.log(res)
for(const key in this.formObj) {
if(key!='coverArr'){
this.formObj[key] = res[key]
}
}
this.$refs.textBox.setEdit(res.content)
this.formObj.coverArr = res.strategyImg ? [res.strategyImg] : []
}
})
},
handleSave() {
this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
if (valid) {
let params = utils.deepClone(this.formObj)
params.strategyImg = params.coverArr[0]
params.mainFlag = 1
if(!params.id) delete params.id
delete params.coverArr
this.$apis.strategy.addStrategyApi(params).then(res => {
console.log(res)
if(res) {
this.$message.success('操作成功')
this.handleCancel()
}
})
}
})
},
handleCancel() {
this.$router.back()
//获取分类列表
getCategoryList() {
this.$apis.strategy.classList({ pageNum: 1, pageSize: 99999 }).then(res => {
if (res) {
const Index = this.formData.findIndex(item => item.name === 'categoryId')
this.formData[Index].optionList = res.list
}
})
}
}
}
</script>
<style scoped lang="scss">
.ctnr{
.main{
background-color: #fff;
padding: 32px 20px;
margin-bottom: 16px;
}
.ctnr {
.main {
background-color: #fff;
padding: 32px 20px;
margin-bottom: 16px;
}
}
</style>
\ No newline at end of file
......@@ -51,6 +51,10 @@ export default {
addHtml: 'imgSlot',
},
{
label: '分类名称',
prop: 'categoryName'
},
{
label: '浏览量/次',
prop: 'viewAmount',
addHtml: 'linkText'
......@@ -194,7 +198,8 @@ export default {
strategyName: scope.scope.strategyName,
id: scope.scope.id
}
const queryStr = encodeURIComponent(JSON.stringify(params))
// 为了避免特殊符号encodeURIComponent多一次
const queryStr = encodeURIComponent(encodeURIComponent(JSON.stringify(params)))
this.$router.push({
path: `/strategy/burialPointList/`+queryStr,
query: { $title: recordType.name }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!