fix:项目初始化

This commit is contained in:
ouyangxiu
2025-06-10 17:11:41 +07:00
commit db9bffd2c5
713 changed files with 159746 additions and 0 deletions
@@ -0,0 +1,116 @@
<template>
<el-dialog :title="title" :visible.sync="Visible" width="780px" center class="ac-dialog" :close-on-click-modal="false" @close="close">
<el-form :inline="true" :model="form" :rules="rules" ref="form" class="demo-form-inline" label-width="120px" label-position="right">
<el-row :gutter="24">
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="标题" prop="name">
<el-input v-model="form.title" placeholder="请输入标题" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="答案" prop="answer">
<el-input v-model="form.answer" placeholder="请输入答案" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="排序" prop="rank">
<el-input v-model.number="form.rank" placeholder="请输入排序" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="是否开启" prop="enable">
<el-switch v-model="form.enable" active-color="#13ce66" :active-value="true" :inactive-value="false"></el-switch>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="Visible = false"> </el-button>
<el-button type="primary" @click="submit('form')"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { aicustomerserviceAdd, aicustomerserviceUpdate } from '@/api/otherConfig/aicustomerservice'
export default {
name: 'AddOrEdit',
props: ['data'],
components: {
},
data() {
return {
Visible: true,
title: '',
// 表单数据
form: {
title:undefined,
answer:undefined,
rank: undefined, // 0,排序
enable: undefined, // true,是否开启
},
rules: {}
}
},
mounted() {
this.title = this.data.title
if (this.title === '编辑') {
this.form = JSON.parse(JSON.stringify(this.data.data))
}
},
methods: {
// TODO:新增首页跳转按钮
add(data) {
aicustomerserviceAdd(data).then(res => {
if (res.code === 200) {
this.$message.success('新增成功')
this.Visible = false
} else {
this.$message.error('新增失败')
}
})
},
// TODO:编辑首页跳转按钮
update(data) {
const param = {
id: data.id,
param: data
}
aicustomerserviceUpdate(param).then(res => {
if (res.code === 200) {
this.$message.success('更新成功')
this.Visible = false
} else {
this.$message.error('更新失败')
}
})
},
// 提交按钮
submit(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
if (this.title === '新增') {
this.add(this.form)
} else if (this.title === '编辑') {
this.update(this.form)
}
}
})
},
// 关闭编辑
close() {
this.$emit('close')
},
// 切换图片
changeimgUrl(data) {
this.form.avatar = data
},
changePicture(data) {
this.form.picture = data
}
}
}
</script>
@@ -0,0 +1,192 @@
<template>
<div class="pf-warpper avlist">
<el-row class="table-form">
<el-form :inline="true" :model="searchData.param" class="form-inline" size="mini">
<el-form-item>
<el-input clearable placeholder="名称" v-model="searchData.name" @clear="onClear('name')" />
</el-form-item>
<el-form-item>
<el-button @click="onSearch" icon="el-icon-search" plain type="primary">搜索</el-button>
<el-button @click="add" icon="el-icon-circle-plus-outline" plain type="success">新增</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col>
<el-table :data="resData" element-loading-text="拼命加载中" border height="750" highlight-current-row style="width: 100%" v-loading="loading" :row-style="{ height: '70px' }">
<el-table-column align="center" label="ID" width="210">
<template slot-scope="scope">{{ scope.row.id }}</template>
</el-table-column>
<el-table-column align="center" label="标题" width="80">
<template slot-scope="scope">{{ scope.row.title }}</template>
</el-table-column>
<el-table-column align="center" label="答案" width="80">
<template slot-scope="scope">{{ scope.row.answer }}</template>
</el-table-column>
<el-table-column align="center" label="排序" width="80">
<template slot-scope="scope">{{ scope.row.rank }}</template>
</el-table-column>
<el-table-column align="center" label="展示的id" width="80">
<template slot-scope="scope">{{ scope.row.exhibitId }}</template>
</el-table-column>
<el-table-column align="center" label="状态" width="100">
<template slot-scope="scope">
<el-button :type="scope.row.enable ? 'success' : 'danger'" plain size="mini">{{ scope.row.enable ? '开启' : '关闭' }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="180">
<template slot-scope="scope">{{ scope.row.createdAt | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" label="更新时间" width="180">
<template slot-scope="scope">{{ scope.row.updatedAt | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="200">
<template slot-scope="scope">
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">编辑</el-button>
<el-button @click="handleDelete(scope.$index, scope.row)" size="mini" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<div class="table-pagination">
<el-pagination
:current-page="searchData.pageNum"
:page-size="searchData.pageSize"
:page-sizes="[10, 20, 30, 50, 100]"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
layout="total, sizes, prev, pager, next, jumper"/>
</div>
<!-- 新增及编辑 -->
<Edit :data="editData" v-if="editVisible" @close="closeEdit" :cardList="cardList" />
</div>
</template>
<script>
// 引入模块
import Edit from './components/AddOrEdit'
import { aicustomerserviceList, aicustomerserviceDel } from '@/api/otherConfig/aicustomerservice.js'
export default {
name: 'Aicustomerservice',
components: {
Edit
},
data() {
return {
// 请求列表参数
searchData: {
pageNum: 1,
pageSize: 10,
name: undefined // 名称
},
resData: [], // el-table表格数据
editVisible: false, // 新增或编辑弹出框
total: 0, // 数据总条数
loading: true, // 列表加载状态
cardList: [],
// 编辑数据
editData: {
title: '新增',
data: {}
}
}
},
filters: {
changeCard(cardID, list) {
const arr = list.filter(item => {
return item.id === cardID
})
if (arr.length) {
return arr[0].title
} else {
return ''
}
}
},
async mounted() {
await this.getActivity()
},
methods: {
// TODO:请求约会抽奖活动列表数据
async getActivity() {
await aicustomerserviceList(this.searchData).then(res => {
if (res.code === 200) {
this.resData = res.data.list
this.total = res.data.totalCount
} else {
this.$message.error('请求列表失败!')
this.resData = []
this.total = 0
}
this.loading = false
})
},
// TODO:删除约会抽奖活动列表数据
handleDelete(index, row) {
this.$confirm('确定删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
aicustomerserviceDel({ id: row.id }).then(res => {
if (res.code === 200) {
this.getActivity()
this.$message.success('成功删除!')
} else {
this.$message.error('删除失败')
}
})
})
},
onSearch() {
this.searchData.pageNum = 1
this.searchData.pageSize = 10
this.getActivity()
},
// 切换每页数据量
handleSizeChange(val) {
this.searchData.pageSize = val
this.getActivity()
},
// 切换页数
handleCurrentChange(val) {
this.searchData.pageNum = val
this.getActivity()
},
// 新增按钮
add() {
this.editVisible = true
},
// 编辑按钮
handleEdit(index, row) {
this.editVisible = true
this.editData = {
title: '编辑',
data: row
}
},
// 关闭编辑弹窗
closeEdit() {
this.editData = {
title: '新增',
data: {}
}
this.editVisible = false
this.getActivity()
},
// 清空某一项筛选列表
onClear(key) {
this.searchData[key] = undefined
this.getActivity()
}
}
}
</script>
@@ -0,0 +1,160 @@
<template>
<div class="center">
<el-row>
<el-col>
<el-form ref="form" :model="form" label-width="180px" style="width: 800px; margin: 0 auto">
<el-form-item label="卷图片">
<UploadImg
@changeImgUrl="changeJuanImageUrl"
@onRemove="onRemoveImage('juanImage', $event)"
:img="form.juanImage"></UploadImg>
</el-form-item>
<el-form-item label="扣图片">
<UploadImg
@changeImgUrl="changeKouImageUrl"
@onRemove="onRemoveImage('kouImage', $event)"
:img="form.kouImage"></UploadImg>
</el-form-item>
<el-form-item label="折图片">
<UploadImg
@changeImgUrl="changeZheImageUrl"
@onRemove="onRemoveImage('zheImage', $event)"
:img="form.zheImage"></UploadImg>
</el-form-item>
<el-form-item label="我的奖">
<UploadImg
@changeImgUrl="changeMyPrizeImageUrl"
@onRemove="onRemoveImage('myPrizeImage', $event)"
:img="form.myPrizeImage"></UploadImg>
</el-form-item>
<el-form-item label="标题图">
<UploadImg
@changeImgUrl="changeTitleImageUrl"
@onRemove="onRemoveImage('titleImage', $event)"
:img="form.titleImage"></UploadImg>
</el-form-item>
<el-form-item label="背景图">
<UploadImg
@changeImgUrl="changeBackgroundImageUrl"
@onRemove="onRemoveImage('backgroundImage', $event)"
:img="form.backgroundImage"></UploadImg>
</el-form-item>
<el-form-item label="可翻牌卡片" prop="discountCardId">
<el-select multiple placeholder="请选择可翻牌卡片" v-model="form.drawCardIds" style="width:160px">
<el-option v-for="item in discountcardList" :label="item.name" :value="item.id" :key='item.id' />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">提交</el-button>
<el-button>取消</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
</template>
<script>
import { discountcardcfgGet, discountcardcfgUpdate } from '@/api/otherConfig/discountcard'
import UploadImg from '@/components/UploadImg/index'
import { getDiscountcard } from '@/api/commodity/discountcard'
export default {
name: 'SystemConfig',
components: {
UploadImg
},
data() {
return {
discountcardList: [],
form: {
juanImage: undefined, // 卷图片
kouImage: undefined, // 扣图片
zheImage: undefined, // 折图片
myPrizeImage: undefined, // 我的奖
titleImage: undefined, // 标题图
drawCardIds: [],
backgroundImage: undefined // 背景图
}
}
},
mounted() {
this.getData()
this.getDiscountcardList()
},
methods: {
// TODO:请求卡片管理数据
getDiscountcardList() {
getDiscountcard({ pageNum: 1, pageSize: 1000 }).then(res => {
if (res.code === 200) {
this.discountcardList = res.data.list
} else {
this.discountcardList = []
}
})
},
// TODO:请求系统配置列表数据
getData() {
discountcardcfgGet({}).then(res => {
if (res.code === 200) {
this.form = res.data
} else {
this.$message.error('请求系统配置失败')
}
})
},
// TODO:提交系统配置列表数据
onSubmit() {
const data = { ...this.form }
discountcardcfgUpdate(data).then(res => {
if (res.code === 200) {
this.$message.success('配置成功')
} else {
this.$message.error('配置失败')
}
})
},
// 移除图片地址到form表单
onRemoveImage(key) {
this.form[key] = ''
},
// 上传图片返回地址
changeJuanImageUrl(data) {
this.form.juanImage = data
},
changeKouImageUrl(data) {
this.form.kouImage = data
},
changeZheImageUrl(data) {
this.form.zheImage = data
},
changeMyPrizeImageUrl(data) {
this.form.myPrizeImage = data
},
changeTitleImageUrl(data) {
this.form.titleImage = data
},
changeBackgroundImageUrl(data) {
this.form.backgroundImage = data
}
}
}
</script>
<style lang="scss" scoped>
@import '@/styles/variables.scss';
.center {
width: 100%;
height: calc(100vh - 140px);
padding: 45px 0;
margin: 0 auto;
overflow: auto;
border-radius: 6px;
background-color: $themeBg;
}
</style>
@@ -0,0 +1,142 @@
<template>
<el-dialog :title="title" :visible.sync="Visible" width="780px" center class="ac-dialog" :close-on-click-modal="false" @close="close">
<el-form :inline="true" :model="form" :rules="rules" ref="form" class="demo-form-inline" label-width="120px" label-position="right">
<el-row :gutter="24">
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="图片">
<UploadImg @changeImgUrl="changeimgUrl" :img="form.avatar"></UploadImg>
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="中文名称" prop="name">
<el-input v-model="form.cnName" placeholder="请输入中文名称" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="英文名称" prop="name">
<el-input v-model="form.enName" placeholder="请输入英文名称" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="排序" prop="rank">
<el-input v-model.number="form.rank" placeholder="请输入排序" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="是否开启" prop="status">
<el-switch v-model="form.status" active-color="#13ce66" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
<el-form-item label="跳转地址" prop="link">
<el-input v-model="form.link" placeholder="请输入跳转地址" style="width: 400px" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="显示位置" prop="advertisingId">
<el-select placeholder="请选择显示位置" clearable v-model="form.location" filterable>
<el-option :key="item.value" :label="item.label" :value="item.value" v-for="item in locationList" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="Visible = false"> </el-button>
<el-button type="primary" @click="submit('form')"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { jumptabAdd, jumptabUpdate } from '@/api/otherConfig/jumptab'
import UploadImg from '@/components/UploadImg/index'
import { locationList } from '@/filters/mediaLibrary/videoList'
export default {
name: 'AddOrEdit',
props: ['data', 'cardList'],
components: {
UploadImg
},
data() {
return {
Visible: true,
title: '',
locationList: locationList(),
// 表单数据
form: {
enName:undefined,
cnName:undefined,
rank: undefined, // 0,排序
status: undefined, // true,是否开启
link: undefined, // "string",跳转地址
avatar: undefined, // 头像
name: undefined // "string",名称
},
rules: {}
}
},
mounted() {
this.title = this.data.title
if (this.title === '编辑') {
this.form = JSON.parse(JSON.stringify(this.data.data))
}
},
methods: {
// TODO:新增首页跳转按钮
add(data) {
jumptabAdd(data).then(res => {
if (res.code === 200) {
this.$message.success('新增成功')
this.Visible = false
} else {
this.$message.error('新增失败')
}
})
},
// TODO:编辑首页跳转按钮
update(data) {
const param = {
id: data.id,
param: data
}
jumptabUpdate(param).then(res => {
if (res.code === 200) {
this.$message.success('更新成功')
this.Visible = false
} else {
this.$message.error('更新失败')
}
})
},
// 提交按钮
submit(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
if (this.title === '新增') {
this.add(this.form)
} else if (this.title === '编辑') {
this.update(this.form)
}
}
})
},
// 关闭编辑
close() {
this.$emit('close')
},
// 切换图片
changeimgUrl(data) {
this.form.avatar = data
},
changePicture(data) {
this.form.picture = data
}
}
}
</script>
+215
View File
@@ -0,0 +1,215 @@
<template>
<div class="pf-warpper avlist">
<el-row class="table-form">
<el-form :inline="true" :model="searchData.param" class="form-inline" size="mini">
<el-form-item>
<el-input clearable placeholder="名称" v-model="searchData.name" @clear="onClear('name')" />
</el-form-item>
<el-form-item>
<el-button @click="onSearch" icon="el-icon-search" plain type="primary">搜索</el-button>
<el-button @click="add" icon="el-icon-circle-plus-outline" plain type="success">新增</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col>
<el-table :data="resData" element-loading-text="拼命加载中" border height="750" highlight-current-row style="width: 100%" v-loading="loading" :row-style="{ height: '70px' }">
<el-table-column align="center" label="ID" width="210">
<template slot-scope="scope">{{ scope.row.id }}</template>
</el-table-column>
<el-table-column align="center" label="中文名称" width="80">
<template slot-scope="scope">{{ scope.row.cnName }}</template>
</el-table-column>
<el-table-column align="center" label="英文名称" width="80">
<template slot-scope="scope">{{ scope.row.enName }}</template>
</el-table-column>
<el-table-column align="center" label="排序" width="80">
<template slot-scope="scope">{{ scope.row.rank }}</template>
</el-table-column>
<el-table-column align="center" label="显示位置" width="80">
<template slot-scope="scope">{{ scope.row.location | changeLocation }}</template>
</el-table-column>
<el-table-column align="center" label="图片" width="120">
<template slot-scope="scope">
<ShowImg style="width: 104px; height: 70px; margin: 0 auto" :urls="scope.row.avatar"></ShowImg>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="100">
<template slot-scope="scope">
<el-button :type="scope.row.status ? 'success' : 'danger'" plain size="mini">{{ scope.row.status ? '开启' : '关闭' }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" label="跳转链接">
<template slot-scope="scope">{{ scope.row.link }}</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="180">
<template slot-scope="scope">{{ scope.row.createdAt | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" label="更新时间" width="180">
<template slot-scope="scope">{{ scope.row.updatedAt | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="200">
<template slot-scope="scope">
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">编辑</el-button>
<el-button @click="handleDelete(scope.$index, scope.row)" size="mini" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<div class="table-pagination">
<el-pagination
:current-page="searchData.pageNum"
:page-size="searchData.pageSize"
:page-sizes="[10, 20, 30, 50, 100]"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
layout="total, sizes, prev, pager, next, jumper"/>
</div>
<!-- 新增及编辑 -->
<Edit :data="editData" v-if="editVisible" @close="closeEdit" :cardList="cardList" />
</div>
</template>
<script>
// 引入模块
import Edit from './components/AddOrEdit'
import ShowImg from '@/components/ShowImg/index.vue'
import { jumptabList, jumptabDel } from '@/api/otherConfig/jumptab'
import { getVipCardList } from '@/api/commodity/vipcard'
export default {
name: 'Jumptab',
components: {
Edit,
ShowImg
},
data() {
return {
// 请求列表参数
searchData: {
pageNum: 1,
pageSize: 10,
name: undefined // 名称
},
resData: [], // el-table表格数据
editVisible: false, // 新增或编辑弹出框
total: 0, // 数据总条数
loading: true, // 列表加载状态
cardList: [],
// 编辑数据
editData: {
title: '新增',
data: {}
}
}
},
filters: {
changeCard(cardID, list) {
const arr = list.filter(item => {
return item.id === cardID
})
if (arr.length) {
return arr[0].title
} else {
return ''
}
}
},
async mounted() {
await this.getData()
await this.getActivity()
},
methods: {
// TODO:请求卡片管理数据
async getData() {
await getVipCardList({ pageNum: 1, pageSize: 100, cardTypeNum: 2 }).then(res => {
if (res.code === 200) {
this.cardList = res.data.list
} else {
this.cardList = []
this.$message.error('请求卡片管理列表数据失败')
}
})
},
// TODO:请求约会抽奖活动列表数据
async getActivity() {
await jumptabList(this.searchData).then(res => {
if (res.code === 200) {
this.resData = res.data.list
this.total = res.data.total
} else {
this.$message.error('请求列表失败!')
this.resData = []
this.total = 0
}
this.loading = false
})
},
// TODO:删除约会抽奖活动列表数据
handleDelete(index, row) {
this.$confirm('确定删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
jumptabDel({ id: row.id }).then(res => {
if (res.code === 200) {
this.getActivity()
this.$message.success('成功删除!')
} else {
this.$message.error('删除失败')
}
})
})
},
onSearch() {
this.searchData.pageNum = 1
this.searchData.pageSize = 10
this.getActivity()
},
// 切换每页数据量
handleSizeChange(val) {
this.searchData.pageSize = val
this.getActivity()
},
// 切换页数
handleCurrentChange(val) {
this.searchData.pageNum = val
this.getActivity()
},
// 新增按钮
add() {
this.editVisible = true
},
// 编辑按钮
handleEdit(index, row) {
this.editVisible = true
this.editData = {
title: '编辑',
data: row
}
},
// 关闭编辑弹窗
closeEdit() {
this.editData = {
title: '新增',
data: {}
}
this.editVisible = false
this.getActivity()
},
// 清空某一项筛选列表
onClear(key) {
this.searchData[key] = undefined
this.getActivity()
}
}
}
</script>
@@ -0,0 +1,136 @@
<!--
* @Author:
* @Mail:
* @Date: 2022-03-14 15:22:03
* @LastEditTime: 2022-06-06 20:06:20
* @LastEditors:
* @FilePath: /comics-admin/src/views/searchManagement/hotsearch/components/AddOrEdit.vue
-->
<template>
<el-dialog :title="`${title}群组`" :visible.sync="Visible" width="700px" center class="ac-dialog" :close-on-click-modal="false" @close="close">
<el-form :inline="true" :model="form" :rules="rules" ref="form" class="demo-form-inline" label-width="120px" label-ition="right">
<el-row :gutter="24">
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="排名">
<el-input v-model.number="form.rank" placeholder="请输入排名" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="标题">
<el-input v-model.number="form.title" placeholder="请输入标题" />
</el-form-item>
</el-col>
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="是否开启">
<el-switch v-model="form.status" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xs="24">
<el-form-item label="活动跳转地址">
<el-input v-model="form.jumpUrl" placeholder="请输入内容" type="text" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :xs="24">
<el-form-item label="首页活动图片">
<UploadImg @changeImgUrl="changeCoverImgUrl" @onRemove="onRemoveImage('cover', $event)" :img="form.cover"></UploadImg>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="Visible = false"> </el-button>
<el-button type="primary" @click="submit('form')"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { contactAdd, contactUpdate } from '@/api/otherConfig/officialgroup.js'
import UploadImg from '@/components/UploadImg/index'
export default {
name: 'AddOrEdit',
props: ['data'],
components: {
UploadImg
},
data() {
return {
Visible: true,
title: '',
// 表单数据
form: {
cover: undefined,
createdAt: undefined,
id: undefined,
jumpUrl: undefined,
rank: undefined,
status: undefined,
title: undefined,
updatedAt: undefined
},
rules: {}
}
},
mounted() {
this.title = this.data.title
if (this.title === '编辑') {
this.form = { ...this.data.data }
}
},
methods: {
// 移除图片地址到form表单
onRemoveImage(key) {
this.form[key] = ''
},
changeFloatImgUrl(data) {
this.form.cover = data
},
// TODO:新增热搜列表数据
add(data) {
contactAdd(data).then(res => {
if (res.code === 200) {
this.$message.success('新增成功')
} else {
this.$message.error('新增失败')
}
this.Visible = false
})
},
// TODO:编辑热搜列表数据
update(data) {
contactUpdate(data).then(res => {
if (res.code === 200) {
this.$message.success('更新成功')
this.Visible = false
} else {
this.$message.error('更新失败')
}
})
},
// 提交按钮
submit(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
if (this.title === '新增') {
this.add(this.form)
} else if (this.title === '编辑') {
this.update(this.form)
}
}
})
},
// 关闭编辑
close() {
this.$emit('close')
}
}
}
</script>
@@ -0,0 +1,174 @@
<template>
<div class="pf-warpper avlist">
<el-row class="table-form">
<el-form :inline="true" :model="searchData.param" class="form-inline" size="mini">
<el-form-item>
<el-button @click="add" icon="el-icon-circle-plus-outline" plain type="success">新增</el-button>
<el-button @click="onSearch" icon="el-icon-refresh" plain type="info">刷新</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col>
<el-table :data="resData" element-loading-text="拼命加载中" border height="750" highlight-current-row style="width: 100%" v-loading="loading" :row-style="{ height: '70px' }">
<el-table-column align="center" label="排名" width="80">
<template slot-scope="scope">{{ scope.row.rank }}</template>
</el-table-column>
<el-table-column align="center" label="ID" width="200">
<template slot-scope="scope">{{ scope.row.id }}</template>
</el-table-column>
<el-table-column align="center" label="封面" width="100">
<template slot-scope="scope">{{ scope.row.cover }}</template>
</el-table-column>
<el-table-column align="center" label="活动跳转地址" width="350">
<template slot-scope="scope">{{ scope.row.jumpUrl }}</template>
</el-table-column>
<el-table-column align="center" label="是否官方" width="80">
<template slot-scope="scope"> {{ scope.row.isOfficial ? '是' : '否' }} </template>
</el-table-column>
<el-table-column align="center" label="是否开启" width="100">
<template slot-scope="scope">
<el-button :type="scope.row.status ? 'success' : 'danger'" plain size="mini">{{ scope.row.status ? '开启' : '关闭' }}</el-button>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="200">
<template slot-scope="scope">{{ scope.row.createdAt | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" label="更新时间" width="200">
<template slot-scope="scope">{{ scope.row.updatedAt | BeiJingTime }}</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="200">
<template slot-scope="scope">
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">编辑</el-button>
<el-button @click="contactDelFn(scope.$index, scope.row)" size="mini" type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<div class="table-pagination">
<el-pagination
:current-page="searchData.pageNum"
:page-size="searchData.pageSize"
:page-sizes="[10, 20, 30, 50, 100]"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
layout="total, sizes, prev, pager, next, jumper"/>
</div>
<!-- 新增及编辑 -->
<Edit :data="editData" v-if="editVisible" @close="closeEdit" />
</div>
</template>
<script>
// 引入模块
import Edit from './components/AddOrEdit'
import { contactList, contactDel } from '@/api/otherConfig/officialgroup.js'
export default {
name: 'Hotsearch',
components: {
Edit
},
data() {
return {
// 请求列表参数
searchData: {
pageNum: 1,
pageSize: 10
},
resData: [], // el-table表格数据
total: 0, // 数据总条数
loading: true, // 列表加载状态
editVisible: false, // 新增或编辑弹出框
// 编辑数据
editData: {
title: '新增',
data: {}
}
}
},
mounted() {
this.getContactList()
},
methods: {
// TODO:请求热搜列表数据
getContactList() {
contactList(this.searchData).then(res => {
if (res.code === 200) {
this.resData = res.data.list
this.total = res.data.total
} else {
this.resData = []
this.total = 0
this.$message.error('请求列表失败!')
}
this.loading = false
})
},
// TODO:删除热搜列表数据
contactDelFn(index, row) {
this.$confirm('确定删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
contactDel({ id: row.id }).then(res => {
if (res.code === 200) {
this.getContactList()
this.$message.success('成功删除!')
} else {
this.$message.error('操作失败')
}
})
})
},
onSearch() {
this.searchData.pageNum = 1
this.searchData.pageSize = 10
this.getContactList()
},
// 切换每页数据量
handleSizeChange(val) {
this.searchData.pageSize = val
this.getContactList()
},
// 切换页数
handleCurrentChange(val) {
this.searchData.pageNum = val
this.getContactList()
},
// 新增按钮
add() {
this.editVisible = true
},
// 编辑按钮
handleEdit(index, row) {
this.editData = {
title: '编辑',
data: row
}
this.editVisible = true
},
// 关闭编辑弹窗
closeEdit() {
this.editData = {
title: '新增',
data: {}
}
this.editVisible = false
this.getContactList()
},
// 清空某一项筛选列表
onClear(key) {
this.searchData[key] = undefined
this.getContactList()
}
}
}
</script>