Răsfoiți Sursa

添加公告

yuan 4 luni în urmă
părinte
comite
1a7dc78ef0
1 a modificat fișierele cu 62 adăugiri și 34 ștergeri
  1. 62 34
      src/views/message/message.vue

+ 62 - 34
src/views/message/message.vue

@@ -203,16 +203,15 @@
 			<el-table v-loading="tableDataLoading" :data="tableData.list">
 				<el-table-column prop="id" label="编号" width="80">
 				</el-table-column>
-				<el-table-column prop="type" label="类型">
+				<el-table-column prop="type" label="标题" width="150">
+				</el-table-column>
+				<el-table-column prop="url" label="图片" width="100">
 					<template slot-scope="scope">
-						<span v-if="scope.row.type==1">个人</span>
-						<span v-else-if="scope.row.type==2">企业</span>
+						<img :src="scope.row.url" width="60" height="60" />
 					</template>
 				</el-table-column>
-				<el-table-column prop="title" label="标题">
+				<el-table-column prop="content" label="公告内容" width="800">
 				</el-table-column>
-				<!-- <el-table-column prop="url" label="地址">
-				</el-table-column> -->
 				<el-table-column prop="createAt" label="创建时间" width="160">
 				</el-table-column>
 				<el-table-column fixed='right' label="操作" width="100">
@@ -521,17 +520,28 @@
 		<!-- 添加/修改公告 -->
 		<el-dialog :title="titles" :visible.sync="dialogFormVisible1" center>
 			<div style="margin-bottom: 10px;">
-				<span style="width: 200px;display: inline-block;text-align: right;">类型:</span>
-				<el-radio-group v-model="type">
-					<el-radio :label="1">个人</el-radio>
-					<el-radio :label="2">企业</el-radio>
-				</el-radio-group>
+				<span style="width: 200px;display: inline-block;text-align: right;">标题:</span>
+				<el-input style="width:50%;" v-model="type" placeholder="请输入标题">
+				</el-input>
 			</div>
 			<div style="margin-bottom: 10px;">
-				<span style="width: 200px;display: inline-block;text-align: right;">标题:</span>
-				<el-input style="width:50%;" v-model="titleMsg" placeholder="请输入标题">
+				<span style="width: 200px;display: inline-block;text-align: right;">内容:</span>
+				<el-input style="width:50%;" v-model="content" placeholder="请输入内容">
 				</el-input>
 			</div>
+			<div style="margin-bottom: 10px;display: flex;">
+				<span style="width: 200px;display: inline-block;text-align: right;">图片:</span>
+				<div
+					style=" width:148px;height:148px;border: 1px dashed #c0ccda;border-radius: 6px;text-align: center;line-height: 148px;">
+					<el-upload class="avatar-uploader" v-model="url"
+						:action="$http.adornUrl('alioss/upload')" :show-file-list="false"
+						:on-success="handleAvatarSuccess">
+						<img v-if="url" :src="url" class="avatar"
+							style="border-radius: 6px;width: 148px;height: 148px;" />
+						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
+					</el-upload>
+				</div>
+			</div>
 			<div slot="footer" class="dialog-footer">
 				<el-button @click="dialogFormVisible1 = false">取 消</el-button>
 				<el-button type="primary" @click="refusetoGg()">确 定</el-button>
@@ -658,6 +668,10 @@
 				this.page = val;
 				this.dataSelect1()
 			},
+			//上传成功
+			handleAvatarSuccess(file) {
+				this.url = file.data
+			},
 			handleClick(tab, event) {
 				if (tab._props.label == '意见反馈') {
 					this.page = 1
@@ -1480,24 +1494,27 @@
 			},
 			// 添加公告
 			addNotice(row) {
+				this.title = '公告中心'
 				if (row) {
 					this.titles = '修改',
-						this.titleMsg = row.title
-					this.urlMsg = row.url
-					this.idMsg = row.id
-					this.type = Number(row.type)
+					this.id = row.id
+					this.type = row.type
+					this.createAt = row.createAt
+					this.url = row.url
+					this.content = row.content
 				} else {
 					this.titles = '添加',
-						this.titleMsg = ''
-					this.urlMsg = ''
-					this.idMsg = ''
-					this.type = 1
+					this.id = ''
+					this.type = ''
+					this.createAt = ''
+					this.url = ''
+					this.content = ''
 				}
 				this.dialogFormVisible1 = true
 			},
 			refusetoGg() {
 
-				if (this.titleMsg == '') {
+				if (this.type == '') {
 					this.$notify({
 						title: '提示',
 						duration: 1800,
@@ -1506,15 +1523,24 @@
 					});
 					return
 				}
-				// if (this.urlMsg === '') {
-				// 	this.$notify({
-				// 		title: '提示',
-				// 		duration: 1800,
-				// 		message: '请输入地址',
-				// 		type: 'warning'
-				// 	});
-				// 	return
-				// }
+				if (this.content == '') {
+					this.$notify({
+						title: '提示',
+						duration: 1800,
+						message: '请输入公告内容',
+						type: 'warning'
+					});
+					return
+				}
+				if (this.url == '') {
+					this.$notify({
+						title: '提示',
+						duration: 1800,
+						message: '请输入公告图片',
+						type: 'warning'
+					});
+					return
+				}
 				var url = ''
 				if (this.titles == '添加') {
 					url = 'message/insertMessage'
@@ -1526,10 +1552,12 @@
 					url: this.$http.adornUrl(url),
 					method: 'post',
 					data: this.$http.adornData({
-						'title': this.titleMsg,
-						'url': this.urlMsg,
+						'title': this.title,
+						'url': this.url,
 						'type': this.type,
-						'id': this.idMsg,
+						'id': this.id,
+						'content': this.content,
+						'createAt': this.createAt,
 						'state': 1
 					})
 				}).then(({