Files
jjx-web/pages/user/components/notice.vue
T
2023-12-06 16:48:56 +08:00

264 lines
6.5 KiB
Vue

<template>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>您有<em style="color: #bf2b28;padding: 0 3px;font-weight: 500">{{ num }}</em>条未读消息</span>
<el-button style="float: right; padding: 3px 0; color: #666" type="text" @click="onSetting"><i class="el-icon-setting"></i> 消息推送设置</el-button>
</div>
<!-- 消息列表 -->
<div class="notice-list">
<div class="item" v-for="(item,index) in noticeList" :key="index">
<div class="title-box">
<div class="title-box">
<el-badge is-dot class="badge" v-if="item.status === 0"></el-badge>
<div class="title">{{ item.title }}</div>
<div class="time">{{ item.time }}</div>
</div>
<div class="right">
<div class="btn" @click="onStatus(index)">
<i class="el-icon-sunset"></i>标记为已读
</div>
<div class="btn" @click="onDelete(index)">
<i class="el-icon-delete"></i>删除
</div>
</div>
</div>
<div class="desc">
{{ item.comments }}
</div>
</div>
</div>
<!-- 添加或编辑的弹窗结束 -->
</el-card>
</template>
<script>
let that;
const originalForms = {sort: 0, enable: true}
// import { VueCropper } from 'vue-cropper'
export default {
components: {
// VueCropper
},
data() {
return {
num: 1,
noticeList: [
{
id: 1,
title: '恭喜!您已注册成功!',
comments: '尊敬的用户,恭喜您已成功注册金久信钢铁交易平台,感谢您的支持!',
time: '2023-05-18 10:15:00',
status: 0
}
],
// 表格相关开始 -----------------------------------------------------------
table1: {
// 表格数据请求地址
action: "client/seal/kh/getList",
// 表格字段显示规则
columns: [
{
key: "imageUrl",
title: "印章",
type: "image",
width: 280,
},
{
key: "remark",
title: "备注",
type: "text",
},
{
key: "_add_time",
title: "添加时间",
type: "time",
width: 160
},
],
// 多选框选中的值
multipleSelection: [],
// 当前高亮的记录
selectItem: ""
},
// 表格相关结束 -----------------------------------------------------------
// 表单相关开始 -----------------------------------------------------------
form1: {
// 表单请求数据,此处可以设置默认值
data: {
enable: true
},
// 表单属性
props: {
// 表单请求地址
action: "",
// 表单字段显示规则
columns: [
{
key:"imageUrl", title:"印章图片", type:"image",
limit: 1,
tips: '图片格式:PNG,需设置为透明底;图片尺寸:企业章 166x166 像素,个人章 134x60 像素,印章紧密贴紧四周,尽量避免留白;',
watch: (data) => {
const { value, formData, column, index, option, $set } = data
if(!value) {
this.form1.data.imageBase64 = ""
}else {
vk.showLoading('正在上传')
vk.myfn.urlTobase64(value).then(res => {
this.form1.data.imageBase64 = res
vk.hideLoading();
})
}
}
},
{
key:"remark", title:"备注", type:"text"
},
{ key: "enable", title: "启用", type: "switch", activeValue: true, inactiveValue: false, width: 100 },
],
// 表单验证规则
rules: {
imageUrl: [
{ required:true, message:'印章不能为空', trigger:'blur' },
{ required:true, message:'印章不能为空', trigger:'blur' },
],
label:[
{ required:true, message:'属性名称不能为空', trigger:'blur' },
],
values:[
{ required:true, message:'可选值不能为空', trigger:'blur' },
],
},
// add 代表添加 update 代表修改
formType: "",
// 是否显示表单的弹窗
show: false,
beforeAction:(formData)=>{
// 可在此处修改 formData 后返回 formData,若在此处return false,则表单不触发提交请求。
return formData;
},
}
},
// 其他弹窗表单
// 表单相关结束 -----------------------------------------------------------
}
},
created() {
that = this
},
methods: {
addBtn() {
that.resetForm();
that.form1.props.action = 'client/seal/kh/add';
that.form1.props.formType = 'add';
that.form1.props.title = '添加';
that.form1.props.show = true;
},
// 显示修改页面
updateBtn({
item
}) {
that.form1.props.action = 'client/seal/kh/update';
that.form1.props.formType = 'update';
that.form1.props.title = '编辑';
that.form1.props.show = true;
that.form1.data = item;
},
closeForm() {
this.form1.props.show = false
this.form1.data = {
sort: 0,
enable: true
}
},
// 删除按钮
deleteBtn({
item,
deleteFn
}) {
deleteFn({
action: "client/seal/kh/delete",
data: {
_id: item._id
},
});
},
// 表单重置
resetForm() {
vk.pubfn.resetForm(originalForms, that);
},
// 搜索
search() {
that.$refs.table1.search();
},
// 刷新
refresh() {
that.$refs.table1.refresh();
},
onStatus(index){
this.noticeList[index].status = 1;
},
onDelete(index){
this.noticeList.splice(index,1)
},
onSetting(){
this.$emit('done','setting')
}
}
}
</script>
<style lang="less">
.el-icon-setting{
padding: 0 5px;
}
.notice-list{
.item{
display: flex;
flex-direction: column;
.title-box{
display: flex;
align-items: center;
justify-content: space-between;
.title{
font-size: 14px;
}
.time{
margin-left: 10px;
color: #999999;
}
.badge{
display: flex;
flex-direction: column;
margin-right: 10px;
}
}
.desc{
color: #999999;
line-height: 2em;
}
.right{
display: flex;
.btn{
color: #bf2b28;
cursor: pointer;
i{
padding: 0 5px;
margin-left: 10px;
}
}
.active{
}
}
}
}
</style>