活动页面完善
This commit is contained in:
199
src/views/modules/xieyi/add-update.vue
Normal file
199
src/views/modules/xieyi/add-update.vue
Normal file
@@ -0,0 +1,199 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<el-dialog
|
||||
title="编辑协议"
|
||||
:visible.sync="visible"
|
||||
width="50%" @close="handlereset"
|
||||
>
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
|
||||
label-width="100px">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="dataForm.title" placeholder="名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="dataForm.type" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="协议内容" prop="content">
|
||||
<quill-editor v-model="dataForm.content" ref="myQuillEditor" :options="editorOption"
|
||||
@blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
|
||||
@ready="onEditorReady($event)" class="shangpin_editor">
|
||||
</quill-editor>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="handlereset">取消</el-button>
|
||||
<el-button type="primary" @click="subMit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
quillEditor
|
||||
} from 'vue-quill-editor'
|
||||
|
||||
import 'quill/dist/quill.core.css'
|
||||
import 'quill/dist/quill.snow.css'
|
||||
import 'quill/dist/quill.bubble.css'
|
||||
export default {
|
||||
props: {
|
||||
// visible: {
|
||||
// type: Boolean,
|
||||
// value: false
|
||||
// },
|
||||
// details: {
|
||||
// type: Object,
|
||||
// value: {}
|
||||
// },
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
visible:false,
|
||||
dataForm:{
|
||||
content:'',
|
||||
title:'',
|
||||
id: 0,
|
||||
type:''
|
||||
},
|
||||
dataRule: {
|
||||
title: [{
|
||||
required: true,
|
||||
message: '请填写标题',
|
||||
trigger: 'blur'
|
||||
}],},
|
||||
options: [{
|
||||
value: 'member',
|
||||
label: '会员协议'
|
||||
}, {
|
||||
value: 'pay',
|
||||
label: '充值协议'
|
||||
}],
|
||||
editorOption: {
|
||||
modules: {
|
||||
toolbar: [
|
||||
['bold', 'italic', 'underline', 'strike'], // 加粗 斜体 下划线 删除线
|
||||
['blockquote', 'code-block'], // 引用 代码块
|
||||
[{
|
||||
header: 1
|
||||
}, {
|
||||
header: 2
|
||||
}], // 1、2 级标题
|
||||
[{
|
||||
list: 'ordered'
|
||||
}, {
|
||||
list: 'bullet'
|
||||
}], // 有序、无序列表
|
||||
[{
|
||||
script: 'sub'
|
||||
}, {
|
||||
script: 'super'
|
||||
}], // 上标/下标
|
||||
[{
|
||||
indent: '-1'
|
||||
}, {
|
||||
indent: '+1'
|
||||
}], // 缩进
|
||||
[{
|
||||
direction: 'rtl'
|
||||
}], // 文本方向
|
||||
[{
|
||||
size: ['12', '14', '16', '18', '20', '22', '24', '28', '32', '36']
|
||||
}], // 字体大小
|
||||
[{
|
||||
header: [1, 2, 3, 4, 5, 6]
|
||||
}], // 标题
|
||||
[{
|
||||
color: []
|
||||
}, {
|
||||
background: []
|
||||
}], // 字体颜色、字体背景颜色
|
||||
// [{ font: ['songti'] }], // 字体种类
|
||||
[{
|
||||
align: []
|
||||
}], // 对齐方式
|
||||
['clean'], // 清除文本格式
|
||||
['image', 'video'] // 链接、图片、视频
|
||||
]
|
||||
},
|
||||
placeholder: '请输入正文'
|
||||
},
|
||||
}
|
||||
},methods:{
|
||||
init(row){
|
||||
this.dataForm = row
|
||||
this.visible = true
|
||||
},
|
||||
handlereset() {
|
||||
this.visible = false
|
||||
this.$refs['dataForm'].resetFields()
|
||||
this.$emit('refreshDataList')
|
||||
// this.$refs['dataForm'].reset()
|
||||
},
|
||||
subMit(){
|
||||
// 表单提交
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/sys/agreement/${!this.dataForm.id ? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'id': this.dataForm.id || undefined,
|
||||
'title': this.dataForm.title,
|
||||
'content': this.dataForm.content,
|
||||
'type': this.dataForm.type
|
||||
})
|
||||
}).then(({ data }) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$refs['dataForm'].resetFields()
|
||||
// this.$refs['dataForm'].reset()
|
||||
this.$emit('refreshDataList')
|
||||
this.handleClose()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
handleClose(){
|
||||
this.$emit("Close", false)
|
||||
// this.details = { content:'', title:'', id: 0, type:''}
|
||||
// this.$refs['dataForm'].resetFields()
|
||||
},
|
||||
// 失去焦点事件
|
||||
onEditorBlur(quill) {
|
||||
console.log('editor blur!', quill)
|
||||
},
|
||||
// 获得焦点事件
|
||||
onEditorFocus(quill) {
|
||||
//console.log('editor focus!', quill)
|
||||
},
|
||||
// 准备富文本编辑器
|
||||
onEditorReady(quill) {
|
||||
// console.log('editor ready!', quill)
|
||||
},
|
||||
|
||||
},components:{
|
||||
quillEditor
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
120
src/views/modules/xieyi/xieyi.vue
Normal file
120
src/views/modules/xieyi/xieyi.vue
Normal file
@@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<!-- <el-button size="mini" v-if="isAuth('book:coupon:save')" type="primary" @click="addOrUpdateHandle">新增</el-button> -->
|
||||
<el-button style="margin-bottom: 10px" size="mini" v-if="isAuth('book:coupon:save')" type="primary" @click="addOrUpdateHandle(details)">新增</el-button>
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="id"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="序号" width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="title"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="名称" width="500">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row)">修改</el-button>
|
||||
<!-- <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" ></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './add-update'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
dataList: [],
|
||||
details:{ content:'',
|
||||
title:'',
|
||||
id: 0,
|
||||
type:''},
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated () {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList () {
|
||||
this.dataListLoading = true
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/sys/agreement/list'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({
|
||||
// 'page': this.pageIndex,
|
||||
// 'limit': this.pageSize,
|
||||
// 'key': this.dataForm.key,
|
||||
// 'currentState': this.couponActiveName
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list
|
||||
this.totalPage = data.page.totalCount
|
||||
} else {
|
||||
this.dataList = []
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle (val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle (val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
addOrUpdateHandle (row) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(row)
|
||||
})
|
||||
//this.addOrUpdateVisible = true
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user