Browse Source

阶段性提交

soft5566 2 years ago
parent
commit
cd617060b3

+ 1 - 1
.env.production

@@ -2,5 +2,5 @@
 ENV = 'production'
 
 # base api
-VUE_APP_BASE_API = 'https://chtech.ncjti.edu.cn/hotelReservation/zhotel'
+VUE_APP_BASE_API = 'https://chtech.ncjti.edu.cn/hotelReservation/mhotel'
 

+ 3 - 0
src/api/residentialhostelMgr.js

@@ -163,6 +163,9 @@ export function modifyHomestayDictionary(param) {
 	data.append('id', param.id);
 	data.append('name', param.name);
 	data.append('code', param.code);
+	if (typeof param.fileUrl !== 'undefined') {
+		data.append('fileUrl', param.fileUrl);
+	}
 
 	return request({
 		url: '/hotelupdateHotelDict.action',

+ 11 - 0
src/api/stdbookMgr.js

@@ -30,6 +30,17 @@ export function getTableData(forData) {
 	})
 }
 
+
+// 获取乡镇配置列表
+export function getTowns() {
+	let query = '?code=10'
+
+	return request({
+		url: '/hotelqueryList.action' + query,
+		method: 'get'
+	});
+};
+
 // 下载
 export function downloadExcel(forData) {
 	let data = new FormData()

+ 44 - 20
src/components/pl-upload/index.vue

@@ -1,9 +1,9 @@
 <template>
 	<div>
 		<el-upload action :accept="defFilterTypes" list-type="picture-card" :on-change="handleChange" :file-list="fileList" :http-request="uploadFile"
-			:limit="limitCount" :class="{hide:hideUpload}">
+			:on-success="uploadSuccess" :on-error="uploadError" :limit="limitCount" :class="{hide:hideUpload}">
 			<i slot="default" class="el-icon-plus" />
-			<div v-for="file in uploadFileList" slot="file">
+			<div slot="file" slot-scope="{file}">
 				<img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
 				<span class="el-upload-list__item-actions">
 					<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
@@ -59,33 +59,31 @@
 		},
 		methods: {
 			init() {
-				console.log('====initupload====')
+				this.uploadFileList = []
+				this.fileList = []
 				if (this.linkId || this.linkUrl) { // 编辑进来
 					if (this.type === 2 && this.limitCount === 1) {
 						this.fileList.push({
 							url: this.linkUrl
 						})
-						this.uploadFileList.push({
-							url: this.linkUrl
-						})
 						this.hideUpload = this.fileList.length >= this.limitCount
 					} else {
 						getFileList(this.linkId).then((res) => {
 							const tempData = res.data
 							if (typeof tempData !== 'undefined' && tempData !== '') {
-								this.fileList = []
 								for (var i = 0; i < tempData.length; i++) {
 									this.fileList.push(tempData[i])
 								}
-								this.hideUpload = this.fileList.length >= this.limitCount
 							} else {
 								this.fileList = []
 							}
+							this.hideUpload = this.fileList.length >= this.limitCount
 						}).catch((err) => {
 							this.$message.error(err.message)
 						})
 					}
 				}
+				this.refreshUploadFile()
 			},
 			handleClick(tab, event) {
 				// console.log(tab, event)
@@ -94,39 +92,65 @@
 			handleChange(file, fileList) {
 				this.fileList = fileList
 				this.hideUpload = this.fileList.length >= this.limitCount
-				console.log(this.hideUpload)
 				this.refreshUploadFile()
 			},
+			// 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传
+			beforeUploadFile(file) {
+				let isSubmit = true
+
+				const size = file.size / 1024 / 1024
+				if (size > 10) {
+					this.$message.warning('文件大小不得超过10M')
+					isSubmit = false
+				}
+				return isSubmit
+			},
 			// 移除
 			handleRemove(file) {
 				// 使用filter()方法从数组中删除元素
-				if (this.type === 1) {
-					const index = this.uploadFileList.findIndex(item => item.id === file.id)
-					this.uploadFileList.splice(index, 1)
-				} else {
-					this.uploadFileList.splice(0, 1)
-				}
+				const index = this.fileList.findIndex(item => item.url === file.url)
+				this.fileList.splice(index, 1)
 				this.refreshUploadFile()
 				setTimeout(() => {
-					this.hideUpload = this.uploadFileList.length >= this.limitCount
+					this.hideUpload = this.fileList.length >= this.limitCount
 				}, 1000)
 			},
 			uploadFile(file) {
+				const self = this
+				const loading = this.$loading({
+					lock: true,
+					text: '附件上传中',
+					spinner: 'el-icon-loading',
+					background: 'rgba(0, 0, 0, 0.7)'
+				})
 				// 发起上传
 				uploadhimage(file).then((res) => {
 					const tempData = res.data
-					this.uploadFileList.push(tempData)
-					this.refreshUploadFile()
+					self.fileList[self.fileList.length - 1] = tempData
+					self.refreshUploadFile()
+					loading.close()
+				}).catch((err) => {
+					self.fileList.splice(self.fileList.length - 1, 1)
+					console.log(err)
+					loading.close()
+					this.$message.error('上传失败')
 				})
 			},
+			uploadSuccess(file) {
+				this.$message.success('上传成功')
+			},
+			uploadError(err, file, fileList) {
+				this.$message.error('上传失败' + err)
+			},
 			refreshUploadFile() {
 				if (this.type === 2 && this.limitCount === 1) {
-					if (this.uploadFileList.length > 0) {
-						this.$emit('refreshModel', this.uploadFileList[0].url)
+					if (this.fileList.length > 0) {
+						this.$emit('refreshModel', this.fileList[0].url)
 					} else {
 						this.$emit('refreshModel', undefined)
 					}
 				} else {
+					this.uploadFileList = this.fileList
 					this.$emit('refreshModel', JSON.stringify(this.uploadFileList))
 				}
 			}

+ 12 - 7
src/views/residentialhostelMgr/index.vue

@@ -491,8 +491,8 @@
 			</el-row>
 			<el-row>
 				<el-col :span="24">
-					<div style="font-size: 16px;font-weight: 700; color: rgba(0, 0, 0, 1); margin: 0px 0 20px 20px;">图标</div>{{modify_dictionary_data.fileUrl}}
-					<pl-upload v-model="modify_dictionary_data.fileUrl" :linkUrl="modify_dictionary_data.fileUrl" :limitCount="1" :type="2"></pl-upload>
+					<div style="font-size: 16px;font-weight: 700; color: rgba(0, 0, 0, 1); margin: 0px 0 20px 20px;">图标</div>
+					<pl-upload v-model="modify_dictionary_data.fileUrl" :linkUrl="modify_dictionary_data.url" :limitCount="1" :type="2"></pl-upload>
 				</el-col>
 			</el-row>
 			<div slot="footer" class="dialog-footer">
@@ -555,7 +555,7 @@
 			<el-row>
 				<el-col :span="24">
 					<div style="font-size: 16px;font-weight: 700; color: rgba(0, 0, 0, 1); margin: 0px 0 20px 20px;">图标</div>
-					<pl-upload v-model="add_dictionary_data.fileUrl" :linkUrl="add_dictionary_data.url" :limitCount="1" :type="2"></pl-upload>
+					<pl-upload v-model="add_dictionary_data.fileUrl" :linkUrl="add_dictionary_data.fileUrl" :limitCount="1" :type="2"></pl-upload>
 				</el-col>
 			</el-row>
 			<div slot="footer" class="dialog-footer">
@@ -579,7 +579,7 @@
 			</el-row>
 			<el-row>
 				<el-col :span="24">
-					<div style="font-size: 16px;font-weight: 700; color: rgba(0, 0, 0, 1); margin: 0px 0 20px 20px;">图标</div>{{modify_dictionary_data.fileUrl}}
+					<div style="font-size: 16px;font-weight: 700; color: rgba(0, 0, 0, 1); margin: 0px 0 20px 20px;">图标</div>
 					<pl-upload v-model="modify_dictionary_data.fileUrl" :linkUrl="modify_dictionary_data.fileUrl" :limitCount="1" :type="2"></pl-upload>
 				</el-col>
 			</el-row>
@@ -812,13 +812,15 @@
 					id: 0,
 					code: 0,
 					name: '',
-					fileUrl: '' // 图片上传列表
+					fileUrl: '', // 图片上传列表
+					url: ''
 				},
 				// 增加字典数据
 				add_dictionary_data: {
 					code: 0,
 					name: '',
-					fileUrl: '' // 图片上传列表
+					fileUrl: '', // 图片上传列表
+					url: ''
 				},
 				// 删除字典数据
 				del_dictionary_data: {
@@ -1016,6 +1018,7 @@
 			 * @param {Object} row
 			 */
 			modify_house_class_dialog_handler(i) {
+				console.log(this.modify_dictionary_data);
 				modifyHomestayDictionary(this.modify_dictionary_data).then((res) => {
 					// console.log(res);
 					if (typeof res.code == 'undefined' || res.code == '') {
@@ -1092,6 +1095,7 @@
 			 * 添加民宿类型
 			 */
 			add_house_class_dialog_handler(i) {
+				console.log(this.add_dictionary_data);
 				addHomestayDictionary(this.add_dictionary_data).then((res) => {
 					// console.log(res);
 					if (typeof res.code == 'undefined' || res.code == '') {
@@ -1126,7 +1130,8 @@
 				this.add_dictionary_data = {
 					code: 0,
 					name: '',
-					fileUrl: '' // 图片上传列表
+					fileUrl: '', // 图片上传列表
+					url: ''
 				}
 			},
 			/**

+ 59 - 27
src/views/stdbookMgr/index.vue

@@ -12,8 +12,8 @@
 						<div class="controls">
 							<el-form :inline="true" :model="formInline" class="demo-form-inline">
 								<el-form-item label="所属乡镇">
-									<el-select v-model="formInline.value" clearable placeholder="请选择">
-										<el-option v-for="item in formInline.options" :key="item.value" :label="item.label" :value="item.value">
+									<el-select v-model="formInline.id" clearable placeholder="请选择">
+										<el-option v-for="item in formInline.options" :key="item.id" :label="item.hotelTownship" :value="item.id">
 										</el-option>
 									</el-select>
 								</el-form-item>
@@ -60,19 +60,19 @@
 											<span>{{ props.row.checkOutTime }}</span>
 										</el-form-item>
 										<el-form-item label="酒店类型">
-											<span>{{ props.row.htype }}</span>
+											<span>{{ props.row.hotelType }}</span>
 										</el-form-item>
 										<el-form-item label="酒店位置">
-											<span>{{ props.row.hposition }}</span>
+											<span>{{ props.row.hotelPosition }}</span>
 										</el-form-item>
 										<el-form-item label="酒店名称">
-											<span>{{ props.row.hname }}</span>
+											<span>{{ props.row.hotelName }}</span>
 										</el-form-item>
 										<el-form-item label="酒店位置经纬度">
-											<span>{{ props.row.hpositionWens }}</span>
+											<span>{{ props.row.hotelHpositionWens }}</span>
 										</el-form-item>
 										<el-form-item label="酒店状态(1 营业 2.休息)">
-											<span>{{ props.row.hstatus }}</span>
+											<span>{{ props.row.hotelStatus }}</span>
 										</el-form-item>
 										<el-form-item label="开业时间">
 											<span>{{ props.row.openTime }}</span>
@@ -148,6 +148,7 @@
 <script>
 	import {
 		getTableData,
+		getTowns,
 		downloadExcel
 	} from '@/api/stdbookMgr'
 
@@ -172,23 +173,8 @@
 				},
 				// 查询数据
 				formInline: {
-					options: [{
-						value: '选项1',
-						label: '乡镇A'
-					}, {
-						value: '选项2',
-						label: '乡镇B'
-					}, {
-						value: '选项3',
-						label: '乡镇C'
-					}, {
-						value: '选项4',
-						label: '乡镇D'
-					}, {
-						value: '选项5',
-						label: '乡镇E'
-					}],
-					value: '',
+					options: [],
+					id: '',
 					amount1: '',
 					amount2: '',
 					search_datatime: '',
@@ -205,12 +191,41 @@
 				loading: true
 			}
 		},
-		mounted() {
+		created() {
 			// 获取消费记录,表格数据
 			this.get_table_data('list')
+			// 获取乡镇
+			this.get_towns()
+		},
+		mounted() {
 			document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";
 		},
 		methods: {
+			// 获取乡镇列表
+			get_towns() {
+				getTowns().then((res) => {
+					if (res.code === 200) {
+						this.formInline.options = []
+						for (var i = 0; i < res.data.length; i++) {
+							let town = {
+								id: res.data[i].id,
+								hotelTownship: res.data[i].name
+							}
+							this.formInline.options.push(town)
+						}
+					} else {
+						if (res.data.length === 0) {
+							this.formInline.options = []
+							this.$message.warning('没有符合条件的数据!')
+						} else {
+							this.$message.warning(res.message)
+						}
+					}
+				}).catch((err) => {
+					// console.log(err);
+					this.$message.error(err.message)
+				});
+			},
 			/**
 			 * 获取消费记录,表格数据
 			 */
@@ -248,7 +263,7 @@
 				that.loading = false;
 			},
 			/**
-			 * 条件
+			 * 查询条件
 			 */
 			get_condtion() {
 				let data = {
@@ -279,6 +294,23 @@
 				this.cond_data = data;
 			},
 			/**
+			 * 导出为Excel
+			 */
+			exportExcel() {
+				downloadExcel(this.cond_data).then((res) => {
+					console.log(res);
+					if (res.code === 200) {
+						that.$message.success(res.message)
+					} else {
+						that.tableData = []
+						that.$message.warning(res.message)
+					}
+				}).catch((err) => {
+					// console.log(err);
+					that.$message.error(err.message)
+				});
+			},
+			/**
 			 * 搜索
 			 */
 			btn_search() {
@@ -473,7 +505,7 @@
 	}
 
 	.demo-table-expand label {
-		width: 90px;
+		width: 180px;
 		color: #99a9bf;
 	}