Browse Source

攻略基本完成

soft5566 2 years ago
parent
commit
888d82116d
2 changed files with 144 additions and 164 deletions
  1. 26 36
      src/api/strategyMgr.js
  2. 118 128
      src/views/strategyMgr/index.vue

+ 26 - 36
src/api/strategyMgr.js

@@ -21,10 +21,11 @@ export function getTableData(forData) {
 }
 
 // 获取发布人
-export function getPublisher() {
+export function getPublisher(adminId) {
 	let data = new FormData()
 	data.append('page', 1)
-	data.append('rows', 10000)
+	data.append('rows', 9999)
+	data.append('adminId', adminId)
 
 	return request({
 		url: '/mhotel/articlegetUserContactList.action',
@@ -126,40 +127,6 @@ export function uploadFiles(file) {
 	})
 }
 
-// 修改攻略-增加附件
-export function addImgOrVideo(formData) {
-	let data = {}
-	if (typeof forData.id !== 'undefined' && forData.id !== '') {
-		data.id = forData.id
-	}
-	if (typeof forData.img !== 'undefined' && forData.img !== '') {
-		data.images = forData.img
-	}
-	if (typeof forData.video !== 'undefined' && forData.video !== '') {
-		data.video = forData.video
-	}
-
-	return request({
-		url: '/mhotel/articleaddFile.action',
-		method: 'post',
-		data
-	})
-}
-
-// 修改攻略-删除附件
-export function delImgOrVideo(formData) {
-	let data = {}
-	if (typeof forData.id !== 'undefined' && forData.id !== '') {
-		data.id = forData.id
-	}
-
-	return request({
-		url: '/mhotel/articledelFile.action',
-		method: 'post',
-		data
-	})
-}
-
 // 修改攻略
 export function updateStrategy(forData) {
 	let data = {}
@@ -220,4 +187,27 @@ export function delStrategy(id) {
 		method: 'post',
 		data
 	})
+}
+
+// 设置发布人
+export function bindingPublisher(data) {
+	return request({
+		url: '/mhotel/articlebindUser.action',
+		method: 'post',
+		data
+	})
+}
+
+// 发布人用户列表
+export function publisherList(adminId) {
+	let data = new FormData()
+	data.append('page', 1)
+	data.append('rows', 9999)
+	data.append('adminId', adminId)
+
+	return request({
+		url: '/mhotel/articlegetAllUserList.action',
+		method: 'post',
+		data
+	})
 }

+ 118 - 128
src/views/strategyMgr/index.vue

@@ -24,7 +24,7 @@
 									<i class="el-icon el-icon-circle-plus-outline" style="font-size: 20px;"></i>
 									<span style="font-size: 16px;">新增攻略</span>
 								</el-button>
-								<el-button class="export" style="display: none;" size="small" @click="setPublisherVisible = true">
+								<el-button class="export" size="small" @click="showSetPublisher">
 									<i class="el-icon el-icon-setting" style="font-size: 20px;"></i>
 									<span style="font-size: 16px;">发布人设置</span>
 								</el-button>
@@ -115,13 +115,17 @@
 		<!-- 发布人设置 -->
 		<el-dialog title="发布人设置" custom-class="configuration-window" :visible.sync="setPublisherVisible" :close-on-click-modal="false"
 			:close-on-press-escape="false" @close="setPublisherVisible = false">
-			<el-row>
-				<el-col :span="24" class="configure-btn-position">
-					<el-button class="configure-btn" @click="show_add_publisher_dialog = true">添加</el-button>
+			<el-row style="display: none;">
+				<el-col :span="24" style="display: flex; justify-content: space-between; padding: 0;">
+					<div>
+						<el-input v-model="publisherSearch.key" style="width: 180px; margin-right: 10px;" clearable placeholder="请输入用户名"></el-input>
+						<el-button type="primary" class="configure-btn" @click="btn_search">查询</el-button>
+					</div>
+					<el-button class="configure-btn" @click="show_add_publisher_dialog = true">确定设置</el-button>
 				</el-col>
 			</el-row>
 			<el-row>
-				<el-col :span="24">
+				<el-col :span="24" style="padding: 0;margin: 10px 0;">
 					<el-table :data="tableData_publisher" height="380" style="width: 100%" :cell-style="cell_style" v-loading="loading"
 						:header-cell-style="header_cell_style">
 						<el-table-column label="序号" align="center" width="55">
@@ -139,54 +143,18 @@
 								<span>{{ scope.row.name }}</span>
 							</template>
 						</el-table-column>
-						<el-table-column label="操作" align="center" width="110">
+						<el-table-column label="操作" align="center">
 							<template slot-scope="scope">
-								<div class="action-btns">
-									<el-link class="bg-btn" @click="show_modify_publisher_dialog(scope.$index, scope.row)">编辑</el-link>
-									<el-link type="danger" @click="delete_publisher_dialog(scope.$index, scope.row)">删除</el-link>
-								</div>
+								<el-button v-if="scope.row.mark == 0" @click="bindingPuhlisherIds(scope.row.id, 'add')" type="text"
+									style="color: rgba(9, 101, 98, 1);" size="small">绑定</el-button>
+								<el-button v-else @click="bindingPuhlisherIds(scope.row.id, 'del')" type="text" style="color: rgba(212, 48, 48, 1);"
+									size="small">取消绑定</el-button>
 							</template>
 						</el-table-column>
 					</el-table>
 				</el-col>
 			</el-row>
 		</el-dialog>
-		<!-- 添加发布人-->
-		<el-dialog title="添加发布人" custom-class="add-ms-class" :visible.sync="show_add_publisher_dialog" :close-on-click-modal="false"
-			:close-on-press-escape="false" @close="show_add_publisher_dialog = false">
-			<el-row>
-				<el-col :span="24">
-					<el-form :model="add_publisher_data" ref="addHostelClassForm" :rules="addPublisherFormRules">
-						<el-form-item label="ID:" :label-width="formLabelWidth" :required="true" prop="id">
-							<el-input v-model="add_publisher_data.id" autocomplete="off" maxlength="20" placeholder="请输入用户ID">
-							</el-input>
-						</el-form-item>
-					</el-form>
-				</el-col>
-			</el-row>
-			<div slot="footer" class="dialog-footer">
-				<el-button class="add-info-cancel-btn" @click="show_add_publisher_dialog = false">取 消</el-button>
-				<el-button class="add-info-confirm-btn" @click="add_publisher_handler">确 认</el-button>
-			</div>
-		</el-dialog>
-		<!-- 修改发布人-->
-		<el-dialog title="修改发布人" custom-class="add-ms-class" :visible.sync="show_modify_publisher_dialog_visible" :close-on-click-modal="false"
-			:close-on-press-escape="false" @close="show_modify_publisher_dialog_visible = false">
-			<el-row>
-				<el-col :span="24">
-					<el-form :model="modify_publisher_data" ref="addHostelClassForm" :rules="modifyPublisherFormRules">
-						<el-form-item label="ID:" :label-width="formLabelWidth" :required="true" prop="id">
-							<el-input v-model="modify_publisher_data.id" autocomplete="off" maxlength="20" placeholder="请输入用户ID">
-							</el-input>
-						</el-form-item>
-					</el-form>
-				</el-col>
-			</el-row>
-			<div slot="footer" class="dialog-footer">
-				<el-button class="add-info-cancel-btn" @click="show_modify_publisher_dialog_visible = false">取 消</el-button>
-				<el-button class="add-info-confirm-btn" @click="modify_publisher_handler">确 认</el-button>
-			</div>
-		</el-dialog>
 		<!-- 新增攻略 -->
 		<el-dialog title="新增攻略" custom-class="add-dlg-class" :visible.sync="dialogAddStrategyVisible" :close-on-click-modal="false"
 			:close-on-press-escape="false" @close="dialogAddStrategyVisible = false">
@@ -228,7 +196,7 @@
 							<div v-else class="add-strategy-img-box-video">
 								<video-player class="video-player vjs-custom-skin" style="margin-top: 25px; overflow: hidden;" @play="onPlayerPlay($event)"
 									:playsinline="true" :options="formAddDialog.show_video"></video-player>
-								<div @click="del_local_display_img('formAddDialog.show_video')" class="add-strategy-img-clear"
+								<div @click="del_local_display_img('formAddDialog.show_video', -1)" class="add-strategy-img-clear"
 									style="color: #fff; background-color: #ff4949;">&times;</div>
 							</div>
 							<input type="file" ref="addVideoUploadInput" style="display:none" accept=".mp4" @change="uploadImageVideo($event, 'video', -1)" />
@@ -309,7 +277,7 @@
 							<div v-else class="add-strategy-img-box-video">
 								<video-player class="video-player vjs-custom-skin" style="margin-top: 25px; overflow: hidden;" @play="onPlayerPlay($event)"
 									:playsinline="true" :options="formModifyDialog.show_video"></video-player>
-								<div @click="del_local_display_img('formModifyDialog.show_video')" class="add-strategy-img-clear"
+								<div @click="del_local_display_img('formModifyDialog.show_video', -1)" class="add-strategy-img-clear"
 									style="color: #fff; background-color: #ff4949;">&times;</div>
 							</div>
 							<input type="file" ref="modifyVideoUploadInput" style="display:none" accept=".mp4"
@@ -375,9 +343,9 @@
 		uploadFiles,
 		insertStrategy,
 		updateStrategy,
-		addImgOrVideo,
-		delImgOrVideo,
-		delStrategy
+		delStrategy,
+		bindingPublisher,
+		publisherList
 	} from '@/api/strategyMgr'
 
 	import {
@@ -400,7 +368,7 @@
 				videoList: [],
 				currentUserLevel: this.$store.state.user.level, // 当前用户的权限
 				//currentUserCreateId: this.$store.state.user.create_id, // 当前用户的createId
-				//currentUserId: this.$store.state.user.user_id, // 当前用户的createId
+				currentUserId: this.$store.state.user.user_id, // 当前用户的userId
 				formLabelWidth: '100px',
 				// 表格单元格样式
 				cell_style: {
@@ -548,6 +516,10 @@
 				formInline: {
 					key: ''
 				},
+				publisherSearch: {
+					key: ''
+				}, // 搜索用户名
+				bindedPublisherIds: '', // 绑定的用户ids
 				videoOptions: {
 					playbackRates: [0.5, 0.8, 1.0, 1.25, 1.5, 1.75, 2.0], //播放速度
 					autoplay: false, // 如果true,浏览器准备好时开始回放。
@@ -586,9 +558,9 @@
 					}
 				},
 				addVideoUploadFileDisable: false, // 添加视频无效
-				addImgsUploadFileDisable: false,  // 添加图片无效
-				modifyVideoUploadFileDisable: false,  // 修改添加视频无效
-				modifyImgsUploadFileDisable: false,  // 修改添加图片无效
+				addImgsUploadFileDisable: false, // 添加图片无效
+				modifyVideoUploadFileDisable: false, // 修改添加视频无效
+				modifyImgsUploadFileDisable: false, // 修改添加图片无效
 				options: [],
 				formAddDialog: {
 					title: '',
@@ -676,43 +648,7 @@
 					istop: false
 				},
 				tableData: [], // 攻略分页列表
-				tableData_publisher: [{
-					xuhao: 1,
-					id: 1231242,
-					name: 'askldfj'
-				}], // 发布人列表
-				add_publisher_data: {
-					id: '',
-					name: ''
-				}, // 添加发布人
-				modify_publisher_data: {
-					id: '',
-					name: ''
-				}, // 添加发布人
-				addPublisherFormRules: [{
-					id: [{
-						required: true,
-						message: '请输入发布人ID',
-						trigger: 'blur'
-					}],
-					name: [{
-						required: true,
-						message: '请输入账号名',
-						trigger: 'blur'
-					}]
-				}], // 添加发布人规则
-				modifyPublisherFormRules: [{
-					id: [{
-						required: true,
-						message: '请输入发布人ID',
-						trigger: 'blur'
-					}],
-					name: [{
-						required: true,
-						message: '请输入账号名',
-						trigger: 'blur'
-					}]
-				}], // 添加发布人规则
+				tableData_publisher: [], // 发布人列表
 				cond_data: {},
 				// 分页参数
 				pagination: {
@@ -722,8 +658,6 @@
 				},
 				loading: true,
 				setPublisherVisible: false, // 发布人设置
-				show_add_publisher_dialog: false, // 添加发布人对话框
-				show_modify_publisher_dialog_visible: false, // 修改发布人对话框
 				dialogAddStrategyVisible: false, // 新增攻略
 				dialogModifyVisible: false, // 修改攻略
 				dialogDeleteVisible: false, // 删除确认对话框
@@ -747,7 +681,7 @@
 			}
 			// 获取消费记录,表格数据
 			this.get_table_data('list');
-			// 发布人列表
+			// 绑定的发布人列表
 			this.getPublisherOptions();
 
 			this.getTown();
@@ -797,6 +731,10 @@
 				if (newVal == true) {
 					this.$nextTick(() => {
 						this.$refs.addDialogForm.resetFields(); // 重置表单
+						for (let i = 0; i < 9; i++) {
+							this.del_local_display_img('formAddDialog.img', i);
+						}
+						this.del_local_display_img('formAddDialog.show_video', -1);
 					});
 				}
 			}
@@ -810,40 +748,92 @@
 			document.removeEventListener('fullscreenchange', this.handleFullScreenChange);
 		},
 		methods: {
-			// 添加发布人
-			add_publisher_handler() {
-
-			},
-			modify_publisher_handler() {
+			// 绑定 或 解绑发布人
+			bindingPuhlisherIds(id, param) {
+				if (param == 'add') {
+					if (this.bindedPublisherIds == '') {
+						this.bindedPublisherIds = id;
+					} else {
+						this.bindedPublisherIds = this.bindedPublisherIds + ',' + id;
+					}
+				} else if (param == 'del') {
+					if (this.bindedPublisherIds.includes(id + ',')) {
+						this.bindedPublisherIds = this.bindedPublisherIds.replace(id + ',', '');
+					} else if (this.bindedPublisherIds.includes(',' + id)) {
+						this.bindedPublisherIds = this.bindedPublisherIds.replace(',' + id, '');
+					} else {
+						//this.bindedPublisherIds = this.bindedPublisherIds.replace(id, '');
+						this.$message.warning('至少保留一个发布人');
+						return
+					}
+				}
+				let data = {
+					id: this.currentUserId,
+					userId: this.bindedPublisherIds
+				}
 
+				let that = this;
+				bindingPublisher(data).then((res) => {
+					if (res.code === 200) {
+						if (param == 'add') {
+							that.$message.success('绑定成功')
+						} else if (param == 'del') {
+							that.$message.success('解绑成功')
+						}
+						// 发布人列表
+						that.showSetPublisher()
+						// 绑定的发布人列表
+						this.getPublisherOptions();
+					} else {
+						that.$message.warning(res.message)
+					}
+				}).catch((err) => {
+					// console.log(err);
+					that.$message.error(err.message)
+				});
 			},
-			// 显示修改发布人
-			show_modify_publisher_dialog(index, row) {
-				this.modify_publisher_data.id = row.id;
-				this.modify_publisher_data.name = row.name;
-				this.show_modify_publisher_dialog_visible = true;
-			},
-			// 删除发布人
-			delete_publisher_dialog() {
-				this.$confirm('此操作将永久删除该发布人, 是否继续?', '提示', {
-					confirmButtonText: '确定',
-					cancelButtonText: '取消',
-					type: 'warning'
-				}).then(() => {
-					this.$message({
-						type: 'success',
-						message: '删除成功!'
-					});
-				}).catch(() => {
-					this.$message({
-						type: 'info',
-						message: '已取消删除'
-					});
+			// 发布人列表
+			showSetPublisher() {
+				let that = this;
+				publisherList(that.currentUserId).then((res) => {
+					// console.log(res.data.pageList);
+					if (res.code === 200) {
+						let tempData = res.data.pageList;
+						that.tableData_publisher = [];
+						if (typeof tempData !== 'undefined' && tempData !== '') {
+							let ids = '';
+							for (let i = 0; i < tempData.length; i++) {
+								let tdata = {
+									xuhao: i + 1,
+									id: tempData[i].id,
+									name: tempData[i].user_name,
+									mark: tempData[i].mark
+								};
+								that.tableData_publisher.push(tdata);
+								if (tempData[i].mark == 1) {
+									ids = ids + tempData[i].id + ',';
+								}
+							}
+							that.bindedPublisherIds = ids.substring(0, ids.length - 1);
+						} else {
+							that.tableData_publisher = [];
+							that.$message.warning('没有符合条件的数据!')
+						}
+					} else {
+						that.tableData_publisher = [];
+						that.$message.warning('没有符合条件的数据!')
+					}
+				}).catch((err) => {
+					// console.log(err);
+					that.$message.error(err.message)
 				});
+				// 显示对话框窗口
+				that.setPublisherVisible = true;
 			},
+			// 获取发布人
 			getPublisherOptions() {
 				var that = this;
-				getPublisher().then((res) => {
+				getPublisher(this.currentUserId).then((res) => {
 					// console.log(res.data.pageList);
 					if (res.code === 200) {
 						let tempData = res.data.pageList;
@@ -1427,9 +1417,9 @@
 			 * 新增攻略
 			 */
 			add_strategy() {
-				this.resetFormAddDialog();
-
 				this.dialogAddStrategyVisible = true;
+
+				this.resetFormAddDialog();
 			},
 			/**
 			 * 打开编辑攻略
@@ -1451,7 +1441,7 @@
 
 				this.$set(this.formModifyDialog, 'content', row.content)
 				if (typeof row.image !== 'undefined') {
-					let imgs = row.image.split(',');
+					let imgs = row.image;
 					for (let i = 0; i < imgs.length; i++) {
 						if (imgs[i] !== '') {
 							this.$set(this.formModifyDialog.imgs[i], 'img', imgs[i])
@@ -1469,9 +1459,9 @@
 					this.$set(this.formModifyDialog, 'show_video', tmpOption)
 					this.$set(this.formModifyDialog, 'post_video', row.video.sources[0].src)
 				}
-				
+
 				this.onlyOneFileClass('modify');
-				
+
 				this.dialogModifyVisible = true
 			},
 			/**