Commit ff436a7a by 杨北旺

分类联调

1 parent b66f21d0
...@@ -83,7 +83,42 @@ const getStrategyDetailApi = params => { ...@@ -83,7 +83,42 @@ const getStrategyDetailApi = params => {
sign: true 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 { export default {
getListApi, getListApi,
updateMainFlagApi, updateMainFlagApi,
...@@ -92,5 +127,9 @@ export default { ...@@ -92,5 +127,9 @@ export default {
topStrategyApi, topStrategyApi,
exportListApi, exportListApi,
addStrategyApi, addStrategyApi,
getStrategyDetailApi getStrategyDetailApi,
addOrEditClass,
classSetToTop,
classList,
deleteclass
} }
\ No newline at end of file \ No newline at end of file
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<el-button size="small" type="primary" @click="addClass(1)">新增</el-button> <el-button size="small" type="primary" @click="addClass(1)">新增</el-button>
</div> </div>
</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"> <div 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>
<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="wrap">
<div class="labelName"> <div class="labelName">
<span class="require">*</span> <span class="require">*</span>
...@@ -23,20 +23,21 @@ ...@@ -23,20 +23,21 @@
<el-dialog title="提示" width="576px" @close="cancelTop" :visible.sync="dialogVisible"> <el-dialog title="提示" width="576px" @close="cancelTop" :visible.sync="dialogVisible">
<div class="warning_body"> <div class="warning_body">
<div class="header"> <div class="header">
<i class="el-icon-warning"></i> <i style="color:#5850FF" class="el-icon-warning"></i>
<span class="title">确定置顶此分类?</span> <span class="title">确定置顶此分类?</span>
<span class="cont">置顶后,分类数据在列表栏和小程序攻略专区里均优先展示</span> <span class="cont">置顶后,分类数据在列表栏和小程序攻略专区里均优先展示</span>
</div> </div>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button :size="size" @click="cancelTop">取 消</el-button> <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> </span>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import util from '@/util/util'
export default { export default {
name: 'classManagerIndex', name: 'classManagerIndex',
data() { data() {
...@@ -49,11 +50,14 @@ export default { ...@@ -49,11 +50,14 @@ export default {
tableColumns: [ tableColumns: [
{ {
label: '分类名称', label: '分类名称',
prop: 'strategyName' prop: 'categoryName'
}, },
{ {
label: '创建时间', 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 { ...@@ -77,7 +81,7 @@ export default {
fn: '删除' fn: '删除'
}, },
listeners: { listeners: {
click: row => this.delClass(row.scope) click: row => this.toDeleteCategory(row.scope.id)
} }
}, },
{ {
...@@ -88,42 +92,95 @@ export default { ...@@ -88,42 +92,95 @@ export default {
fn: '置顶' fn: '置顶'
}, },
listeners: { listeners: {
click: row => this.topClass(row.scope) click: row => this.topClass(row.scope.id)
} }
} }
], ],
isVisible: false, isVisible: false,
modalTitle: '新增', modalTitle: '新增',
categoryName: '', categoryName: '',
dialogVisible: false dialogVisible: false,
getListApi: this.$apis.strategy.classList
} }
}, },
components: {}, components: {},
mounted() {}, mounted() {
console.log(util.dateFormat(1702518870000))
},
methods: { methods: {
topClass() {}, topClass(id) {
delClass() {}, this.topId = id
addClass(type) { this.dialogVisible = true
},
addClass(type, row) {
this.isVisible = true this.isVisible = true
this.modalTitle = type == 2 ? '编辑' : '新增' this.modalTitle = type == 2 ? '编辑' : '新增'
if (type == 2) {
this.categoryName = row.categoryName
this.editId = row.id
}
}, },
handleClose() { handleClose() {
this.isVisible = false this.isVisible = false
}, },
onOk() {
this.handleClose()
},
intClassName(e) { intClassName(e) {
this.categoryName = e this.categoryName = e
}, },
cancelTop() { cancelTop() {
this.dialogVisible = false 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> <template>
<div class="ctnr"> <div class="ctnr">
<div class="global-title">基础信息</div> <div class="global-title">基础信息</div>
<div class="main"> <div class="main">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" <glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule"> <div slot="coverSlot">
<div slot="coverSlot"> <glsx-preview :picOptions="posterOptions" :imageUrlArr="formObj.coverArr" @change="changeChannelImg"></glsx-preview>
<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> </div>
<GLFooter> <div slot="richTextSlot">
<el-button @click="handleCancel">取消</el-button> <textBox @change="writeChange" ref="textBox" @forbid="forbidEdit"></textBox>
<el-button type="primary" @click="handleSave">确定</el-button> </div>
</GLFooter> </glsx-combi-form>
</div> </div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
</div>
</template> </template>
<script> <script>
...@@ -28,127 +26,146 @@ import textBox from '@/components/text-box' ...@@ -28,127 +26,146 @@ import textBox from '@/components/text-box'
import preview from '@/components/preview' import preview from '@/components/preview'
export default { export default {
name: 'add', name: 'add',
data() { data() {
return { return {
myRule: { myRule: {
strategyName: [{required: true, message: '请输入攻略名称', trigger: 'change'}], strategyName: [{ required: true, message: '请输入攻略名称', trigger: 'change' }],
categoryName: [{required: true, message: '请选择分类名称', trigger: 'change'}], categoryName: [{ required: true, message: '请选择分类名称', trigger: 'change' }],
strategyImg: [{ strategyImg: [
required: true, validator: (rule, value, callback) => { {
if (this.formObj.coverArr?.length != 1) { required: true,
callback(new Error(`请上传分类图标`)) validator: (rule, value, callback) => {
} else { if (this.formObj.coverArr?.length != 1) {
callback() callback(new Error(`请上传分类图标`))
} } else {
}, trigger: 'change' callback()
}], }
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
}, },
{ trigger: 'change'
label: '攻略宣传图', }
name: 'strategyImg',
addHtml: 'coverSlot'
},
{
label: '攻略内容',
addHtml: 'richTextSlot'
}
], ],
} 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
}, },
getDetail() {
components: { this.$apis.strategy.getStrategyDetailApi({ id: this.routeInfo.id }).then(res => {
glsxCombiForm, if (res) {
glsxPreview: preview, console.log(res)
textBox 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() {
created() { this.$refs.baseInfoRef.$refs.formRef.validate(valid => {
const urlParam = this.$route.params if (valid) {
this.routeInfo = JSON.parse(decodeURIComponent(urlParam.id)) let params = utils.deepClone(this.formObj)
console.log(this.routeInfo) params.strategyImg = params.coverArr[0]
if(this.routeInfo.id) { params.mainFlag = 1
this.getDetail() 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()
}
})
} }
})
}, },
handleCancel() {
mounted() { this.$router.back()
}, },
//获取分类列表
methods: { getCategoryList() {
writeChange(val) { this.$apis.strategy.classList({ pageNum: 1, pageSize: 99999 }).then(res => {
this.formObj.content = val if (res) {
}, const Index = this.formData.findIndex(item => item.name === 'categoryId')
getDetail(){ this.formData[Index].optionList = res.list
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()
} }
})
} }
} }
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.ctnr{ .ctnr {
.main{ .main {
background-color: #fff; background-color: #fff;
padding: 32px 20px; padding: 32px 20px;
margin-bottom: 16px; margin-bottom: 16px;
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -51,6 +51,10 @@ export default { ...@@ -51,6 +51,10 @@ export default {
addHtml: 'imgSlot', addHtml: 'imgSlot',
}, },
{ {
label: '分类名称',
prop: 'categoryName'
},
{
label: '浏览量/次', label: '浏览量/次',
prop: 'viewAmount', prop: 'viewAmount',
addHtml: 'linkText' addHtml: 'linkText'
...@@ -194,7 +198,8 @@ export default { ...@@ -194,7 +198,8 @@ export default {
strategyName: scope.scope.strategyName, strategyName: scope.scope.strategyName,
id: scope.scope.id id: scope.scope.id
} }
const queryStr = encodeURIComponent(JSON.stringify(params)) // 为了避免特殊符号encodeURIComponent多一次
const queryStr = encodeURIComponent(encodeURIComponent(JSON.stringify(params)))
this.$router.push({ this.$router.push({
path: `/strategy/burialPointList/`+queryStr, path: `/strategy/burialPointList/`+queryStr,
query: { $title: recordType.name } 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!