<template>
	<div class="app-container">
		<el-row>
			<el-col :span="24">
				<div class="cell">
					<div class="cell-title">
						<div class="title-left">
							<div class="title">周边管理</div>
						</div>
					</div>
					<div class="cell-body">
						<div class="controls">
							<el-form :inline="true" :model="formInline" class="demo-form-inline">
								<el-form-item label="">
									<el-input v-model="formInline.key" style="width: 200px;" prefix-icon="el-icon-search" clearable
										placeholder="请输入关键字"></el-input>
								</el-form-item>
								<el-form-item>
									<el-button type="primary" class="btn-search" @click="btn_search">查询</el-button>
								</el-form-item>
								<el-form-item label="周边类型">
									<el-select v-model="formInline.rtype" clearable placeholder="全部" @change="handleTypeChange">
										<el-option v-for="item in formInline.rtypeOptions" :key="item.rtypeId" :label="item.rtype" :value="item.rtype">
										</el-option>
									</el-select>
								</el-form-item>
								<el-form-item label="所属乡镇">
									<el-select v-model="formInline.rtown" clearable placeholder="请选择所属乡镇" @change="handleTownChange">
										<el-option v-for="item in formInline.rtownOptions" :key="item.rtownId" :label="item.rtown" :value="item.rtown">
										</el-option>
									</el-select>
								</el-form-item>
							</el-form>
							<div>
								<el-button class="export" size="small" @click="add_perimeter">
									<i class="el-icon el-icon-circle-plus-outline" style="font-size: 20px;"></i>
									<span style="font-size: 16px;">新增周边</span>
								</el-button>
							</div>
						</div>
						<el-table ref="multipleTable" :data="tableData" height="558" style="width: 100%" :cell-style="cell_style" v-loading="loading"
							:header-cell-style="header_cell_style">
							<el-table-column label="序号" align="center" width="100">
								<template slot-scope="scope">
									<span>{{ scope.row.xuhao }}</span>
								</template>
							</el-table-column>
							<el-table-column label="类型" align="center" width="88">
								<template slot-scope="scope">
									<span>{{ scope.row.rtype }}</span>
								</template>
							</el-table-column>
							<el-table-column label="所在乡镇" align="center">
								<template slot-scope="scope">
									<span>{{ scope.row.rtown }}</span>
								</template>
							</el-table-column>
							<el-table-column label="名称" align="center">
								<template slot-scope="scope">
									<span>{{ scope.row.rname }}</span>
								</template>
							</el-table-column>
							<el-table-column label="联系电话" align="center">
								<template slot-scope="scope">
									<span>{{ scope.row.rphone }}</span>
								</template>
							</el-table-column>
							<el-table-column label="地址" align="center" width="320">
								<template slot-scope="scope">
									<span>{{ scope.row.radress }}</span>
								</template>
							</el-table-column>
							<el-table-column label="产品数量" align="center">
								<template slot-scope="scope">
									<span>{{ scope.row.cnum }}</span>
								</template>
							</el-table-column>
							<el-table-column label="操作" align="center" width="180">
								<template slot-scope="scope">
									<el-button @click="handleModifyClick(scope.row)" type="text" style="color: rgba(9, 101, 98, 1);" size="small">编辑</el-button>
									<el-button @click="handleDelClick(scope.row)" type="text" style="color: rgba(212, 48, 48, 1);" size="small">删除</el-button>
									<el-button @click="handleDetailClick(scope.row)" type="text" style="color: rgba(9, 101, 98, 1);"
										size="small">查看详情</el-button>
								</template>
							</el-table-column>
						</el-table>
						<div class="pagination-table">
							<el-pagination @current-change="currentPageChange" :current-page.sync="pagination.currentPage" :page-size="pagination.pageSize"
								layout="prev, pager, next, jumper" :total="pagination.total">
							</el-pagination>
						</div>
					</div>
				</div>
			</el-col>
		</el-row>
		<!-- 新增周边 -->
		<el-dialog title="新增周边" custom-class="add-dlg-class" :visible.sync="dialogAddVisible" :close-on-click-modal="false" :close-on-press-escape="false"
			@close="dialogAddVisible = false">
			<el-form :model="formAddDialog" ref="addDialogForm" :rules="addDialogFormRules">
				<el-row>
					<el-col :span="12">
						<el-form-item label="周边类型" :label-width="formLabelWidth" :required="true" prop="rtype">
							<el-select v-model="formAddDialog.rtype" clearable placeholder="请选择类型" style="width: 100%;">
								<el-option v-for="item in formAddDialog.rtypeOptions" :key="item.rtypeId" :label="item.rtype" :value="item.rtype">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="名称" :label-width="formLabelWidth" :required="true" prop="rname">
							<el-input v-model="formAddDialog.rname" autocomplete="off" placeholder="请输入名称" maxlength="50">
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="所在乡镇" :label-width="formLabelWidth" :required="true" prop="rtown">
							<el-select v-model="formAddDialog.rtown" clearable placeholder="请选择乡镇" style="width: 100%;">
								<el-option v-for="item in formAddDialog.rtownOptions" :key="item.rtownId" :label="item.rtown" :value="item.rtown">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="联系电话" :label-width="formLabelWidth" :required="true" prop="rphone">
							<el-input v-model="formAddDialog.rphone" autocomplete="off" placeholder="请输入联系电话" maxlength="25"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24" style="margin-top: -20px;">
						<el-form-item label="详细地址" :required="true" :label-width="formLabelWidth" prop="radress">
							<div style="display: flex;">
								<el-button icon="el-icon-map-location" @click="showMapDialog" ref="mapButton"
									style="width: 40px; height: 40px; margin-right: 5px; font-size: 22px; color: rgba(9, 101, 98, 1); padding: 0;"></el-button>
								<el-input v-model="formAddDialog.radress" placeholder="请输入地址"></el-input>
							</div>
						</el-form-item>
						<el-form-item label="简介" :required="true" :label-width="formLabelWidth" prop="detail">
							<quill-editor v-model="formAddDialog.detail" :options="editorOption"></quill-editor>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="6" style="display: flex; justify-content: center;">
						<div style="display: flex; flex-direction: column; align-items: center;">
							<div style="font-size: 18px; margin-bottom: 10px;">封面图：</div>
							<div
								style="display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; border-radius: 5px;">
								<div @click="del_local_display_img('formAddDialog.first_img')"
									style="position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; background: rgba(131, 131, 131, 1.0); border-radius: 50%; font-size: 22px; color: #e3e3e3; cursor: pointer; display: flex; justify-content: center; align-items: center;">
									&times;</div>
								<viewer>
									<img v-if="formAddDialog.first_img == ''" src="@/icons/images/initImg/150x180.png" height="180px" width="150px"
										style="border-radius: 5px;">
									<img v-else :src="formAddDialog.first_img" height="180px" width="150px" style="border-radius: 5px;">
								</viewer>
								<el-button @click="openImageUploadDialog"
									style="margin-top: 8px; width: 150px; border: none; background: rgba(9, 101, 98, 1); color: #fff; border-radius: 5px;"
									size="small">上传封面图片</el-button>
								<input type="file" ref="addImageUploadInput" style="display:none" accept=".jpg,.png"
									@change="uploadImageVideo($event, 'img')" />
							</div>
						</div>
					</el-col>
					<el-col :span="6" style="display: flex; justify-content: center;">
						<div style="display: flex; flex-direction: column; align-items: center;">
							<div style="font-size: 18px; margin-bottom: 10px;">介绍视频：</div>
							<div style="position: relative; border-radius: 5px; margin: 0 auto;">
								<div @click="del_local_display_img('formAddDialog.show_video')"
									style="position: absolute; top: 10px; right: 35px; width: 22px; height: 22px; background: rgba(131, 131, 131, 1.0); border-radius: 50%; font-size: 22px; color: #e3e3e3; cursor: pointer; display: flex; justify-content: center; align-items: center; z-index: 9999;">
									&times;</div>
								<img v-if="formAddDialog.show_video == ''" src="@/icons/images/initImg/150x180.png" height="180px" style="border-radius: 5px;">
								<video-player v-else class="video-player vjs-custom-skin" @play="onPlayerPlay($event)" :playsinline="true"
									:options="formAddDialog.show_video" style="height: 180px;"></video-player>
								<el-button @click="openVideoUploadDialog"
									style="margin-top: 8px; width: 150px; border: none; background: rgba(9, 101, 98, 1); color: #fff; border-radius: 5px;"
									size="small">上传视频</el-button>
								<input type="file" ref="addVideoUploadInput" style="display:none" accept=".mp4" @change="uploadImageVideo($event, 'video')" />
							</div>
						</div>
					</el-col>
					<el-col :span="12" style="display: flex; justify-content: center;">
						<div style="display: flex; flex-direction: column; align-items: center;">
							<div style="font-size: 18px; margin-bottom: 10px;">详情图：</div>
							<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 5px;">
								<viewer :images="formAddDialog.detail_img" style="width: 390px;">
									<el-carousel height="178px" width="100%" style="border-radius: 5px;">
										<el-carousel-item v-for="item in formAddDialog.detail_img" :key="item.id">
											<img v-if="item == 1 || item == 2" src="@/icons/images/initImg/390x180.png"
												style="border-radius: 5px; cursor: pointer; width: 100%; height: 178px;" />
											<img v-else :src="item" style="border-radius: 5px; cursor: pointer; width: 100%; height: 178px;" />
										</el-carousel-item>
									</el-carousel>
								</viewer>
								<el-button @click="openImageDetailUploadDialog"
									style="margin-top: 8px; width: 150px; border: none; background: rgba(9, 101, 98, 1); color: #fff; border-radius: 5px;"
									size="small">上传详情图片</el-button>
								<input type="file" ref="addImageDetailUploadInput" style="display:none" accept=".jpg,.png"
									@change="uploadImageVideo($event, 'imgDetail')" />
							</div>
						</div>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-info-cancel-btn" @click="dialogAddVisible = false">取 消</el-button>
				<el-button class="add-info-confirm-btn" @click="handleAddPerlmeter">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 添加产品 -->
		<el-dialog title="添加产品" custom-class="add-product-class" :visible.sync="dialogAddProductVisible" :close-on-click-modal="false"
			:close-on-press-escape="false" @close="dialogAddProductVisible = false">
			<el-form :model="formAddProduct" ref="addProductForm" :rules="addProductFormRules">
				<el-row>
					<el-col :span="24">
						<el-form-item label="产品名称" :label-width="formLabelWidth" :required="true" prop="product_name">
							<el-input v-model="formAddProduct.product_name" autocomplete="off" placeholder="请输入产品名称" maxlength="16">
							</el-input>
						</el-form-item>
						<el-form-item label="产品介绍" :label-width="formLabelWidth" :required="true" prop="product_desc">
							<el-input type="textarea" v-model="formAddProduct.product_desc" rows="5" placeholder="请输入产品介绍" maxlength="300"
								show-word-limit></el-input>
						</el-form-item>
						<el-form-item label="产品价格" :label-width="formLabelWidth" :required="true" prop="price">
							<div style="display: flex; align-items: center;">
								<el-input v-model="formAddProduct.price" style="width: 180px; margin-right: 8px;" autocomplete="off" placeholder="请输入产品价格"
									maxlength="11">
								</el-input>
								<div>元</div>
							</div>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-info-cancel-btn" @click="dialogAddProductVisible = false">取 消</el-button>
				<el-button class="add-info-confirm-btn" @click="handleAddProduct">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 编辑周边 -->
		<el-dialog title="编辑周边" custom-class="add-dlg-class" :visible.sync="dialogModifyVisible" :close-on-click-modal="false" :close-on-press-escape="false"
			@close="dialogModifyVisible = false">
			<el-form :model="formModifyDialog" ref="modifyDialogForm" :rules="modifyDialogFormRules">
				<el-row>
					<el-col :span="12">
						<el-form-item label="周边类型" :label-width="formLabelWidth" :required="true" prop="rtype">
							<el-select v-model="formModifyDialog.rtype" clearable placeholder="请选择类型" style="width: 100%;">
								<el-option v-for="item in formModifyDialog.rtypeOptions" :key="item.rtypeId" :label="item.rtype" :value="item.rtype">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="名称" :label-width="formLabelWidth" :required="true" prop="rname">
							<el-input v-model="formModifyDialog.rname" autocomplete="off" placeholder="请输入名称" maxlength="16">
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="所在乡镇" :label-width="formLabelWidth" :required="true" prop="rtown">
							<el-select v-model="formModifyDialog.rtown" clearable placeholder="请选择乡镇" style="width: 100%;">
								<el-option v-for="item in formModifyDialog.rtownOptions" :key="item.rtownId" :label="item.rtown" :value="item.rtown">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="联系电话" :label-width="formLabelWidth" :required="true" prop="rphone">
							<el-input v-model="formModifyDialog.rphone" autocomplete="off" placeholder="请输入联系电话"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24" style="margin-top: -20px;">
						<el-form-item label="详细地址" :required="true" :label-width="formLabelWidth" prop="radress">
							<div style="display: flex;">
								<el-button icon="el-icon-map-location" @click="showMapDialog" ref="mapButton"
									style="width: 40px; height: 40px; margin-right: 5px; font-size: 22px; color: rgba(9, 101, 98, 1); padding: 0;"></el-button>
								<el-input v-model="formModifyDialog.radress" placeholder="请输入地址"></el-input>
							</div>
						</el-form-item>
						<el-form-item label="简介" :required="true" :label-width="formLabelWidth" prop="detail">
							<quill-editor v-model="formModifyDialog.detail" :options="editorOption"></quill-editor>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="6" style="display: flex; justify-content: center;">
						<div style="display: flex; flex-direction: column; align-items: center;">
							<div style="font-size: 18px; margin-bottom: 10px;">封面图：</div>
							<div
								style="display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; border-radius: 5px;">
								<div @click="del_local_display_img('formModifyDialog.first_img')"
									style="position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; background: rgba(131, 131, 131, 1.0); border-radius: 50%; font-size: 22px; color: #e3e3e3; cursor: pointer; display: flex; justify-content: center; align-items: center;">
									&times;</div>
								<viewer>
									<img v-if="formModifyDialog.first_img == ''" src="@/icons/images/initImg/150x180.png" height="180px" width="150px"
										style="border-radius: 5px;">
									<img v-else :src="formModifyDialog.first_img" height="180px" width="150px" style="border-radius: 5px;">
								</viewer>
								<el-button @click="openImageUploadDialog_modify"
									style="margin-top: 8px; width: 150px; border: none; background: rgba(9, 101, 98, 1); color: #fff; border-radius: 5px;"
									size="small">上传封面图片</el-button>
								<input type="file" ref="modifyImageUploadInput" style="display:none" accept=".jpg,.png"
									@change="uploadModifyImageVideo($event, 'img')" />
							</div>
						</div>
					</el-col>
					<el-col :span="6" style="display: flex; justify-content: center;">
						<div style="display: flex; flex-direction: column; align-items: center;">
							<div style="font-size: 18px; margin-bottom: 10px;">介绍视频：</div>
							<div style="position: relative; border-radius: 5px;">
								<div @click="del_local_display_img('formModifyDialog.show_video')"
									style="position: absolute; top: 10px; right: 35px; width: 22px; height: 22px; background: rgba(131, 131, 131, 1.0); border-radius: 50%; font-size: 22px; color: #e3e3e3; cursor: pointer; display: flex; justify-content: center; align-items: center; z-index: 9999;">
									&times;</div>
								<img v-if="formModifyDialog.show_video == ''" src="@/icons/images/initImg/150x180.png" height="180px"
									style="border-radius: 5px;">
								<video-player v-else class="video-player vjs-custom-skin" @play="onPlayerPlay($event)" :playsinline="true"
									:options="formModifyDialog.show_video" style="height: 180px;"></video-player>
								<el-button @click="openVideoUploadDialog_modify"
									style="margin-top: 8px; width: 150px; border: none; background: rgba(9, 101, 98, 1); color: #fff; border-radius: 5px;"
									size="small">上传视频</el-button>
								<input type="file" ref="modifyVideoUploadInput" style="display:none" accept=".mp4"
									@change="uploadModifyImageVideo($event, 'video')" />
							</div>
						</div>
					</el-col>
					<el-col :span="12" style="display: flex; justify-content: center;">
						<div style="display: flex; flex-direction: column; align-items: center;">
							<div style="font-size: 18px; margin-bottom: 10px;">详情图：</div>
							<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 5px;">
								<viewer :images="formModifyDialog.detail_img" style="width: 390px;">
									<el-carousel height="178px" width="100%" style="border-radius: 5px;">
										<el-carousel-item v-for="item in formModifyDialog.detail_img" :key="item.id">
											<img :src="item" style="border-radius: 5px; cursor: pointer; width: 100%; height: 178px;">
										</el-carousel-item>
									</el-carousel>
								</viewer>
								<el-button @click="openImageDetailUploadDialog_modify"
									style="margin-top: 8px; width: 150px; border: none; background: rgba(9, 101, 98, 1); color: #fff; border-radius: 5px;"
									size="small">上传详情图片</el-button>
								<input type="file" ref="modifyImageDetailUploadInput" style="display:none" accept=".jpg,.png"
									@change="uploadModifyImageVideo($event, 'imgDetail')" />
							</div>
						</div>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-info-cancel-btn" @click="dialogModifyVisible = false">取 消</el-button>
				<el-button class="add-info-confirm-btn" @click="handleModifyPerlmeter">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 编辑产品 -->
		<el-dialog title="编辑产品" custom-class="add-product-class" :visible.sync="dialogModifyProductVisible" :close-on-click-modal="false"
			:close-on-press-escape="false" @close="dialogModifyProductVisible = false">
			<el-form :model="formModifyProduct" ref="modifyProductForm" :rules="modifyProductFormRules">
				<el-row>
					<el-col :span="24">
						<el-form-item label="产品名称" :label-width="formLabelWidth" :required="true" prop="product_name">
							<el-input v-model="formModifyProduct.product_name" autocomplete="off" placeholder="请输入产品名称" maxlength="16">
							</el-input>
						</el-form-item>
						<el-form-item label="产品介绍" :label-width="formLabelWidth" :required="true" prop="product_desc">
							<el-input type="textarea" v-model="formModifyProduct.product_desc" rows="5" placeholder="请输入产品介绍" maxlength="300"
								show-word-limit></el-input>
						</el-form-item>
						<el-form-item label="产品价格" :label-width="formLabelWidth" :required="true" prop="price">
							<div style="display: flex; align-items: center;">
								<el-input v-model="formModifyProduct.price" style="width: 180px; margin-right: 8px;" autocomplete="off" placeholder="请输入产品价格"
									maxlength="11">
								</el-input>
								<div>元</div>
							</div>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-info-cancel-btn" @click="dialogModifyProductVisible = false">取 消</el-button>
				<el-button class="add-info-confirm-btn" @click="handleModifyProduct">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 删除周边确认对话框 -->
		<el-dialog custom-class="el-dialog-delete-account" :visible.sync="dialogDeleteVisible" :close-on-click-modal="false" :close-on-press-escape="false"
			:show-close="false">
			<div slot="" class="del-account-body">
				<img src="../../icons/serveAC/del_warning.png" alt="">
				<div class="del-account-body-txt">是否确定从列表中删除？</div>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button class="add-user-cancel-btn" @click="dialogDeleteVisible = false"> 否 </el-button>
				<el-button class="add-user-confirm-btn" @click="dialogDeletePerimeter"> 是 </el-button>
			</div>
		</el-dialog>
		<!-- 周边详情 -->
		<el-dialog title="周边详情" custom-class="perimeter-class" :visible.sync="dialogInfoVisible" @close="dialogInfoVisible = false">
			<div style="padding: 0; margin: 0; overflow:auto;">
				<el-row>
					<el-col :span="14">
						<div style="display: flex; align-items: center; margin-bottom: 20px; ">
							<div
								style="font-size: 16px; font-weight: 700; min-width: 100px; width: 100px; text-align: right; margin-right: 18px; color: rgba(128, 128, 128, 1);">
								周边类型</div>
							<div style="font-size: 16px; font-weight: 700; color: #333;">{{ formDetailDialog.rtype }}</div>
						</div>
						<div style="display: flex; align-items: center; margin-bottom: 20px; ">
							<div
								style="font-size: 16px; font-weight: 700; min-width: 100px; width: 100px; text-align: right; margin-right: 18px; color: rgba(128, 128, 128, 1);">
								名称</div>
							<div style="font-size: 16px; font-weight: 700; color: #333;">{{ formDetailDialog.rname }}</div>
						</div>
						<div style="display: flex; align-items: center; margin-bottom: 20px; ">
							<div
								style="font-size: 16px; font-weight: 700; min-width: 100px; width: 100px; text-align: right; margin-right: 18px; color: rgba(128, 128, 128, 1);">
								所属乡镇</div>
							<div style="font-size: 16px; font-weight: 700; color: #333;">{{ formDetailDialog.rtown }}</div>
						</div>
						<div style="display: flex; align-items: center; margin-bottom: 20px; ">
							<div
								style="font-size: 16px; font-weight: 700; min-width: 100px; width: 100px; text-align: right; margin-right: 18px; color: rgba(128, 128, 128, 1);">
								详细地址</div>
							<div style="font-size: 16px; font-weight: 700; color: #333;">{{ formDetailDialog.radress }}</div>
						</div>
						<div style="display: flex; align-items: center; ">
							<div
								style="font-size: 16px; font-weight: 700; min-width: 100px; width: 100px; text-align: right; margin-right: 18px; color: rgba(128, 128, 128, 1);">
								联系电话</div>
							<div style="font-size: 16px; font-weight: 700; color: #333;">{{ formDetailDialog.rphone }}</div>
						</div>
					</el-col>
					<el-col :span="10">
						<div style="display: flex;">
							<div
								style="font-size: 16px; font-weight: 700; min-width: 100px; text-align: right; margin-right: 18px; color: rgba(128, 128, 128, 1);">
								封面图</div>
							<viewer :images="formDetailDialog.show_img">
								<img :src="formDetailDialog.first_img" width="160px" height="200px" style="border-radius: 5px;" />
							</viewer>
						</div>
					</el-col>
				</el-row>
				<el-divider></el-divider>
				<el-row>
					<el-col :span="24">
						<el-tabs v-model="activeName">
							<el-tab-pane label="产品" name="first">
								<el-button class="export" style="margin-bottom: 10px !important;" size="small" @click="showAddProductDialog">
									<i class="el-icon el-icon-circle-plus-outline" style="font-size: 16px;"></i>
									<span style="font-size: 14px;">添加产品</span>
								</el-button>
								<el-table ref="multipleTable" :data="productTableData" height="280" style="width: 100%" :cell-style="cell_style"
									v-loading="loading" :header-cell-style="header_cell_style">
									<el-table-column label="序号" align="center" width="100">
										<template slot-scope="scope">
											<span>{{ scope.row.xuhao }}</span>
										</template>
									</el-table-column>
									<el-table-column label="产品名称" align="center">
										<template slot-scope="scope">
											<span>{{ scope.row.product_name }}</span>
										</template>
									</el-table-column>
									<el-table-column label="产品介绍" align="center">
										<template slot-scope="scope">
											<span>{{ scope.row.product_desc }}</span>
										</template>
									</el-table-column>
									<el-table-column label="售价（元）" align="center">
										<template slot-scope="scope">
											<span>{{ scope.row.price }}</span>
										</template>
									</el-table-column>
									<el-table-column label="操作" align="center" width="180">
										<template slot-scope="scope">
											<el-button @click="showDelProduct(scope.row)" type="text" style="color: rgba(212, 48, 48, 1);"
												size="small">删除</el-button>
											<el-button @click="showModifyProduct(scope.row)" type="text" style="color: rgba(9, 101, 98, 1);"
												size="small">编辑</el-button>
										</template>
									</el-table-column>
								</el-table>
							</el-tab-pane>
							<el-tab-pane label="简介" name="second">
								<div style="height: 264px; overflow-y: auto;" v-html="formDetailDialog.detail"></div>
							</el-tab-pane>
							<el-tab-pane label="介绍视频" name="third">
								<div style="height: 300px; width: 530px; margin: 0 auto;">
									<video-player class="video-player vjs-custom-skin" @play="onPlayerPlay($event)" :playsinline="true"
										:options="formDetailDialog.show_video"></video-player>
								</div>
							</el-tab-pane>
							<el-tab-pane label="详情图" name="fourth">
								<div style="height: 300px;">
									<div style="display: flex; justify-content: center; align-items: center; border-radius: 5px;">
										<viewer :images="formDetailDialog.detail_img" style="width: 600px;">
											<el-carousel height="300px" width="100%" style="border-radius: 5px;">
												<el-carousel-item v-for="item in formDetailDialog.detail_img" :key="item.id">
													<img :src="item" style="border-radius: 5px; cursor: pointer; width: 100%; height: 300px;">
												</el-carousel-item>
											</el-carousel>
										</viewer>
									</div>
								</div>
							</el-tab-pane>
						</el-tabs>
					</el-col>
				</el-row>
			</div>
		</el-dialog>
		<el-dialog title="地图" v-if="dialogMapVisible" :visible.sync="dialogMapVisible" width="60%">
			<baidu-map style="width: 100%; height: 450px;" :center="center" :zoom="zoom" @click="handleMapClick">
				<bm-marker :position="markerPosition"></bm-marker>
			</baidu-map>
		</el-dialog>
	</div>
</template>

<script>
	import {
		getTableData,
		getTowns,
		appinsertArounds,
		appupdateArounds,
		appdelAround,
		uploadFiles,
		getProductTableData,
		appinsertAroundPd,
		appupdateAround_pd,
		appdelAround_pd
	} from '@/api/perimeterMgr'

	import {
		isEmpty,
		cos
	} from '@/js/common'

	import {
		valid
	} from 'mockjs'

	import COS from 'cos-js-sdk-v5'

	var townOptions = [] // 民宿列表
	var townOptions_obj = [] // 民宿列表
	export default {
		data() {
			return {
				zoom: 13, // 地图缩放级别
				center: {
					lng: 115.36400612205159,
					lat: 28.850799952953487
				}, // 地图中心点坐标
				markerPosition: {
					lng: 115.36400612205159,
					lat: 28.850799952953487
				}, // 标记点位置坐标
				dialogMapVisible: false,
				videoList: [],
				activeName: 'first',
				currentUserLevel: this.$store.state.user.level, // 当前用户的权限
				formLabelWidth: '100px',
				// 表格单元格样式
				cell_style: {
					color: '#1A202B',
					'font-size': '14px',
					'font-family': 'Microsoft YaHei-3970(82674968)'
				},
				// 表格头部样式
				header_cell_style: {
					background: '#E6ECFE',
					color: '#1A202B',
					'font-size': '16px',
					'font-family': 'Microsoft YaHei-3970(82674968)'
				},
				addDialogFormRules: { // 新增周边验证规则
					rtype: [{
						required: true,
						message: '请选择周边类型',
						trigger: 'change'
					}],
					rtown: [{
						required: true,
						message: '请选择所在乡镇',
						trigger: 'change'
					}],
					rname: [{
						required: true,
						message: '请输入名称',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					rphone: [{
						required: true,
						message: '请输入联系电话',
						trigger: 'blur'
					}, {
						pattern: /^(1[3-9]\d{9}|0\d{2,3}-\d{7,8}|\d{3}\-\d{8,9}|1[3-9]\d{9}\/0\d{2,3}-\d{7,8}|1[3-9]\d{9}\/\d{3}\-\d{8,9})$/,
						message: '请输入【手机号、手机/座机、座机】3种之一',
						trigger: 'blur'
					}],
					radress: [{
						required: true,
						message: '请输入详细地址',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					detail: [{
						required: true,
						message: '请输入简介',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{3,}.*$/,
						message: '至少3个汉字，其它字符不限',
						trigger: 'blur'
					}]
				},
				// 富文本编辑器配置
				editorOption: {
					modules: {
						toolbar: [
							['bold', 'italic', 'underline', 'strike'], // 加粗、斜体、下划线、删除线按钮

							[{
								'list': 'ordered'
							}, {
								'list': 'bullet'
							}], // 有序列表和无序列表按钮
							[{
								'indent': '-1'
							}, {
								'indent': '+1'
							}], // 减少缩进和增加缩进按钮

							[{
								'size': ['small', false, 'large', 'huge']
							}], // 自定义下拉菜单，表示字体大小

							[{
								'color': []
							}, {
								'background': []
							}], // 下拉菜单，使用主题中的默认颜色和背景色
							[{
								'align': []
							}], // 下拉菜单，选择对齐方式

							['clean'] // 清除格式按钮，移除所有格式
						]
					},
					placeholder: '请输入简介'
				},
				modifyDialogFormRules: { // 编辑周边验证规则
					rtype: [{
						required: true,
						message: '请选择周边类型',
						trigger: 'change'
					}],
					rtown: [{
						required: true,
						message: '请选择所在乡镇',
						trigger: 'change'
					}],
					rname: [{
						required: true,
						message: '请输入名称',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					rphone: [{
						required: true,
						message: '请输入联系电话',
						trigger: 'blur'
					}, {
						pattern: /^(1[3-9]\d{9}|0\d{2,3}-\d{7,8}|\d{3}\-\d{8,9}|1[3-9]\d{9}\/0\d{2,3}-\d{7,8}|1[3-9]\d{9}\/\d{3}\-\d{8,9})$/,
						message: '请输入【手机号、手机/座机、座机】3种之一',
						trigger: 'blur'
					}],
					radress: [{
						required: true,
						message: '请输入详细地址',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					detail: [{
						required: true,
						message: '请输入简介',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{3,}.*$/,
						message: '至少3个汉字，其它字符不限',
						trigger: 'blur'
					}]
				},
				rtownOptions: [],
				rtypeOptions: [{
					// 	rtypeId: 0,
					// 	rtype: '民宿'
					// }, {
					rtypeId: 1,
					rtype: '美食'
				}, {
					rtypeId: 2,
					rtype: '景点'
					// }, {
					// 	rtypeId: 3,
					// 	rtype: '停车场'
					// }, {
					// 	rtypeId: 4,
					// 	rtype: '洗浴'
					// }, {
					// 	rtypeId: 5,
					// 	rtype: '健身'
					// }, {
					// 	rtypeId: 6,
					// 	rtype: 'KTV'
					// }, {
					// 	rtypeId: 7,
					// 	rtype: '电影院'
					// }, {
					// 	rtypeId: 8,
					// 	rtype: '酒吧'
				}, {
					rtypeId: 9,
					rtype: '加油站'
					// }, {
					// 	rtypeId: 10,
					// 	rtype: '其它'
				}],
				// 查询数据
				formInline: {
					rtownId: '',
					rtownOptions: [],
					rtypeId: '',
					rtypeOptions: '',
					key: '',
					rtype: '',
					rtown: ''
				},
				videoOptions: {
					playbackRates: [0.5, 0.8, 1.0, 1.25, 1.5, 1.75, 2.0], //播放速度
					autoplay: false, // 如果true,浏览器准备好时开始回放。
					muted: false, // 默认情况下将会消除任何音频。
					loop: false, // 导致视频一结束就重新开始。
					preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
					language: "zh-CN",
					aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
					fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
					sources: [{
						withCredentials: false,
						type: "video/mp4", // 这里的种类支持很多种：基本视频格式、直播、流媒体等，具体可以参看git网址项目
						src: '', // https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4
					}],
					controls: true,
					hls: true,
					poster: "", // 你的封面地址
					notSupportedMessage: "此视频暂无法播放，请稍后再试", // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
					controlBar: {
						progressControl: true,
						currentTimeDisplay: true,
						timeDivider: true,
						durationDisplay: true,
						remainingTimeDisplay: false,
						fullscreenToggle: true, // 全屏按钮
					},
					flash: {
						hls: {
							withCredentials: false
						}
					},
					html5: {
						hls: {
							withCredentials: false
						}
					}
				},
				detail_img_array: [],
				formAddDialog: {
					rtownId: '',
					rtownOptions: [],
					rtypeId: '',
					rtypeOptions: '',
					rtype: '',
					rtown: '',
					rname: '',
					rphone: '',
					radress: '',
					detail: '',
					first_img: '',
					show_video: '',
					post_video: '',
					detail_img: [1, 2],
					jingwei: ''
				},
				formModifyDialog: {
					id: '',
					rtownId: '',
					rtownOptions: [],
					rtypeId: '',
					rtypeOptions: '',
					rtype: '',
					rtown: '',
					rname: '',
					rphone: '',
					radress: '',
					detail: '',
					first_img: '',
					show_video: '',
					detail_img: [1, 2],
					jingwei: ''
				},
				formDetailDialog: {
					id: '',
					rtype: '',
					rtown: '',
					rname: '',
					rphone: '',
					radress: '',
					detail: '',
					show_img: '', // 用于放大显示
					first_img: '',
					show_video: '',
					detail_img: [1, 2],
					jingwei: ''
				},
				formAddProduct: {
					aid: '',
					product_name: '',
					product_desc: '',
					price: ''
				},
				formModifyProduct: {
					aid: '',
					id: '',
					product_name: '',
					product_desc: '',
					price: ''
				},
				formDelProduct: {
					aid: ''
				},
				addProductFormRules: { // 添加产品验证规则
					product_name: [{
						required: true,
						message: '请输入产品名称',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					product_desc: [{
						required: true,
						message: '请输入产品介绍',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					price: [{
						required: true,
						message: '请输入产品价格',
						trigger: 'blur'
					}, {
						pattern: /^\d+(\.\d{1,2})?$/,
						message: '请输入产品价格，最多保留2位小数',
						trigger: 'blur'
					}]
				},
				modifyProductFormRules: { // 编辑产品验证规则
					product_name: [{
						required: true,
						message: '请输入产品名称',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					product_desc: [{
						required: true,
						message: '请输入产品介绍',
						trigger: 'blur'
					}, {
						pattern: /^.*[\u4e00-\u9fa5]{2,}.*$/,
						message: '至少2个汉字，其它字符不限',
						trigger: 'blur'
					}],
					price: [{
						required: true,
						message: '请输入产品价格',
						trigger: 'blur'
					}, {
						pattern: /^\d+(\.\d{1,2})?$/,
						message: '请输入产品价格，最多保留2位小数',
						trigger: 'blur'
					}]
				},
				productTableData: [],
				tableData: [],
				cond_data: {},
				// 分页参数
				pagination: {
					currentPage: 1,
					pageSize: 9,
					total: 0
				},
				loading: true,
				dialogAddVisible: false, // 新增周边
				dialogInfoVisible: false, // 周边详情
				dialogModifyVisible: false, // 修改周边
				dialogDeleteVisible: false, // 删除确认对话框
				dialogAddProductVisible: false, // 添加产品对话框
				dialogModifyProductVisible: false, // 编辑产品对话框
				delPerimeterId: '',
				cosVal: {
					SecretId: "AKIDJSP9gz469yZv77tQjotsgHguvjIgtvkL",
					SecretKey: "b3MVRD1g8RYS9g195oMkvukQvDKZfbOz",
					SecurityToken: "1320402385",
					Bucket: "jinganminsu-1320402385",
					Region: "ap-nanjing",
				}
			}
		},
		created() {
			// 检测权限
			if (this.currentUserLevel !== 2) {
				this.$router.replace({
					path: '/data'
				})
				return
			}
			// 获取周边记录,表格数据
			this.get_table_data('list')

			this.get_towns()

			this.formInline.rtypeOptions = this.rtypeOptions
			this.formAddDialog.rtypeOptions = this.rtypeOptions
			this.formModifyDialog.rtypeOptions = this.rtypeOptions

			this.videoList.push({
				playerOptions: {
					playbackRates: [0.5, 0.8, 1.0, 1.25, 1.5, 1.75, 2.0], //播放速度
					autoplay: false, // 如果true,浏览器准备好时开始回放。
					muted: false, // 默认情况下将会消除任何音频。
					loop: false, // 导致视频一结束就重新开始。
					preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
					language: "zh-CN",
					aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
					fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
					sources: [{
						withCredentials: false,
						type: "video/mp4", // 这里的种类支持很多种：基本视频格式、直播、流媒体等，具体可以参看git网址项目
						src: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4',
					}],
					controls: true,
					hls: true,
					poster: "", // 你的封面地址
					notSupportedMessage: "此视频暂无法播放，请稍后再试", // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
					controlBar: {
						progressControl: true,
						currentTimeDisplay: true,
						timeDivider: true,
						durationDisplay: true,
						remainingTimeDisplay: false,
						fullscreenToggle: true, // 全屏按钮
					},
					flash: {
						hls: {
							withCredentials: false
						}
					},
					html5: {
						hls: {
							withCredentials: false
						}
					}
				}
			})
		},
		mounted() {
			document.getElementsByClassName("el-pagination__jump")[0].childNodes[0].nodeValue = "跳至";

			document.addEventListener('fullscreenchange', this.handleFullScreenChange);
		},
		watch: {
			dialogAddVisible(newVal, oldVal) {
				if (newVal == true) {
					this.$nextTick(() => {
						this.$refs.addDialogForm.resetFields(); // 重置表单
					});
				}
			},
			dialogAddProductVisible(newVal, oldVal) {
				if (newVal == true) {
					this.$nextTick(() => {
						this.$refs.addProductForm.resetFields();
					});
				}
			}
		},
		beforeDestroy() {
			document.removeEventListener('fullscreenchange', this.handleFullScreenChange);
		},
		methods: {
			// 显示地图界面
			showMapDialog() {
				this.zoom = 13

				if (this.dialogAddVisible && !isEmpty(this.formAddDialog.jingwei)) {
					var t = this.formAddDialog.jingwei.split(',')
					this.$set(this.center, 'lng', t[0])
					this.$set(this.center, 'lat', t[1])

					this.$set(this.markerPosition, 'lng', t[0])
					this.$set(this.markerPosition, 'lat', t[1])

				} else if (this.dialogModifyVisible && !isEmpty(this.formModifyDialog.jingwei)) {
					var t = this.formModifyDialog.jingwei.split(',')
					this.$set(this.center, 'lng', t[0])
					this.$set(this.center, 'lat', t[1])

					this.$set(this.markerPosition, 'lng', t[0])
					this.$set(this.markerPosition, 'lat', t[1])
				}

				this.dialogMapVisible = true;
			},
			// 地图的单击，获取坐标、地址
			handleMapClick(e) {
				const {
					lng,
					lat
				} = e.point

				if (this.dialogAddVisible) {
					this.formAddDialog.jingwei = lng + ',' + lat
				} else if (this.dialogModifyVisible) {
					this.formModifyDialog.jingwei = lng + ',' + lat
				}
				this.markerPosition = {
					lng,
					lat
				}

				const geoc = new BMap.Geocoder()
				const point = new BMap.Point(lng, lat)

				geoc.getLocation(point, (result) => {
					if (result) {
						// console.log('Location:', result.address)
						if (this.dialogAddVisible) {
							this.formAddDialog.radress = result.address
						} else if (this.dialogModifyVisible) {
							this.formModifyDialog.radress = result.address
						}
					}
				})
				// console.log(this.formAddDialog.jingwei);
			},
			// 周边类型下拉列表发生改变
			handleTypeChange() {
				this.get_table_data('search')
			},
			// 乡镇下拉列表发生改变
			handleTownChange() {
				this.get_table_data('search')
			},
			// 获取乡镇列表
			get_towns() {
				getTowns().then((res) => {
					if (res.code === 200) {
						this.formInline.rtownOptions = []
						this.formAddDialog.rtownOptions = []
						this.formModifyDialog.rtownOptions = []
						this.rtownOptions = []
						for (var i = 0; i < res.data.length; i++) {
							let town = {
								rtownId: res.data[i].id,
								rtown: res.data[i].name
							}
							this.formInline.rtownOptions.push(town)
							this.formAddDialog.rtownOptions.push(town)
							this.formModifyDialog.rtownOptions.push(town)
							this.rtownOptions.push(town)
						}
					} else {
						if (res.data.length === 0) {
							this.formInline.rtownOptions = []
							this.$message.warning('没有符合条件的数据！')
						} else {
							this.$message.warning(res.message)
						}
					}
				}).catch((err) => {
					// console.log(err);
					this.$message.error(err.message)
				});
			},
			handleFullScreenChange() {
				if (!document.fullscreenElement) {
					// 退出全屏逻辑
					this.playering.pause()
				}
			},
			// 定义点击播放按钮，自动全屏化的方法
			full(e) {
				// 做兼容处理
				if (e.requestFullscreen) {
					e.requestFullscreen()
				} else if (e.mozRequestFullScreen) {
					e.mozRequestFullScreen()
				} else if (e.msRequestFullscreen) {
					e.msRequestFullscreen()
				} else if (e.oRequestFullscreen) {
					e.oRequestFullscreen()
				} else if (e.webkitRequestFullscreen) {
					e.webkitRequestFullScreen()
				} else {
					// var docHtml = document.documentElement;
					// var docBody = document.body;
					var videobox = document.getElementsByClassName('video-player')
					var cssText = 'width:100%;height:100%;overflow:hidden;'
					// docHtml.style.cssText = cssText;
					// docBody.style.cssText = cssText;
					videobox.style.cssText = cssText + ';' + 'margin:0px;padding:0px;'
					document.IsFullScreen = true
				}
			},
			// 定义点击播放按钮，调用全屏化的方法
			onPlayerPlay(player) {
				// console.log('player play===>>>', player)
				this.playering = player
				this.full(player)
			},
			// 添加对话框单击上传封面图片
			openImageUploadDialog() {
				this.$refs.addImageUploadInput.click();
			},
			// 添加对话框单击上传视频
			openVideoUploadDialog() {
				this.$refs.addVideoUploadInput.click();
			},
			// 添加对话框单击上传详情图
			openImageDetailUploadDialog() {
				this.$refs.addImageDetailUploadInput.click();
			},
			// 修改对话框单击上传封面图片
			openImageUploadDialog_modify() {
				this.$refs.modifyImageUploadInput.click();
			},
			// 修改对话框单击上传视频
			openVideoUploadDialog_modify() {
				this.$refs.modifyVideoUploadInput.click();
			},
			// 修改对话框单击上传详情图
			openImageDetailUploadDialog_modify() {
				this.$refs.modifyImageDetailUploadInput.click();
			},
			// 周边新增上传文件
			uploadImageVideo(event, imgOrVideo) {
				console.log(event.target.files);
				// 点击取消,长度为0
				if (event.target.files.length == 0)
					return;
				const file = event.target.files[0];

				const key = `/uploads/zhoubian/${new Date().getTime()}`; // 设置上传到 COS 后的文件名
				var that = this
				const cos = new COS(this.cosVal);
				cos.putObject({
						Bucket: "jinganminsu-1320402385",
						Region: "ap-nanjing",
						Key: key,
						Body: file,
					},
					function(err, data) {
						if (err) {
							// console.error(err);
							that.$message.error(err);
							if (imgOrVideo == 'img') {
								that.$set(that.formAddDialog, 'first_img', '')
							} else if (imgOrVideo == 'imgDetail') {
								that.$set(that.formAddDialog, 'detail_img', '')
							} else {
								that.$set(that.formAddDialog, 'show_video', '')
							}
							return;
						} else {
							// console.log(data);
							if (!isEmpty(`${data.Location}`)) {
								if (imgOrVideo == 'img') {
									that.$set(that.formAddDialog, 'first_img', `https://${data.Location}`)
								} else if (imgOrVideo == 'imgDetail') {
									that.detail_img_array.push(`https://${data.Location}`)
									that.$set(that.formAddDialog, 'detail_img', that.detail_img_array)
								} else {
									that.videoOptions.sources[0].src = `https://${data.Location}`
									that.$set(that.formAddDialog, 'show_video', that.videoOptions)
									that.$set(that.formAddDialog, 'post_video', `https://${data.Location}`)
								}
							} else {
								if (imgOrVideo == 'img') {
									that.$set(that.formAddDialog, 'first_img', '')
								} else if (imgOrVideo == 'imgDetail') {
									that.$set(that.formAddDialog, 'detail_img', '')
								} else {
									that.$set(that.formAddDialog, 'show_video', '')
								}
							}
						}
						event.target.value = null;
					}
				);
			},
			// 周边修改上传文件
			uploadModifyImageVideo(event, imgOrVideo) {
				// 点击取消,长度为0
				if (event.target.files.length == 0)
					return;
					
				const file = event.target.files[0];

				const key = `/uploads/zhoubian/${new Date().getTime()}`; // 设置上传到 COS 后的文件名
				var that = this
				const cos = new COS(this.cosVal);
				cos.putObject({
						Bucket: "jinganminsu-1320402385",
						Region: "ap-nanjing",
						Key: key,
						Body: file,
					},
					function(err, data) {
						if (err) {
							// console.error(err);
							that.$message.error(err);
							if (imgOrVideo == 'img') {
								that.$set(that.formModifyDialog, 'first_img', '')
							} else if (imgOrVideo == 'imgDetail') {
								that.$set(that.formModifyDialog, 'detail_img', '')
							} else {
								that.$set(that.formModifyDialog, 'show_video', '')
							}
							return;
						} else {
							// console.log(data);
							if (!isEmpty(`${data.Location}`)) {
								if (imgOrVideo == 'img') {
									that.$set(that.formModifyDialog, 'first_img', `https://${data.Location}`)
								} else if (imgOrVideo == 'imgDetail') {
									that.detail_img_array.push(`https://${data.Location}`)
									that.$set(that.formModifyDialog, 'detail_img', that.detail_img_array)
								} else {
									that.videoOptions.sources[0].src = `https://${data.Location}`
									that.$set(that.formModifyDialog, 'show_video', that.videoOptions)
									that.$set(that.formModifyDialog, 'post_video', `https://${data.Location}`)
								}
							} else {
								if (imgOrVideo == 'img') {
									that.$set(that.formModifyDialog, 'first_img', '')
								} else if (imgOrVideo == 'imgDetail') {
									that.$set(that.formModifyDialog, 'detail_img', '')
								} else {
									that.$set(that.formModifyDialog, 'show_video', '')
								}
							}
						}
						event.target.value = null;
					}
				);
			},
			// 删除本地显示的图片或视频
			del_local_display_img(param) {
				if (param === 'formAddDialog.first_img') {
					this.$set(this.formAddDialog, 'first_img', '')
				} else if (param === 'formAddDialog.show_video') {
					this.$set(this.formAddDialog, 'show_video', '')
				} else if (param === 'formModifyDialog.first_img') {
					this.$set(this.formModifyDialog, 'first_img', '')
				} else if (param === 'formModifyDialog.show_video') {
					this.$set(this.formModifyDialog, 'show_video', '')
					this.$set(this.formModifyDialog, 'post_video', '')
				}
			},
			// 添加周边
			handleAddPerlmeter() {
				var that = this;
				this.$refs.addDialogForm.validate(valid => {
					if (valid) {
						if (that.formAddDialog.jingwei == '') {
							that.$message.error('请选择地址在地图中对应的位置')
							that.$refs.mapButton.$el.click()
							return
						}
						var data = that.formAddDialog
						appinsertArounds(data).then((res) => {
							// console.log(res);
							if (res.code == 200) {
								that.get_table_data('list')
								that.dialogAddVisible = false
								that.$message.success('周边添加成功！')
								that.formAddDialog = {
									rtownId: '',
									rtownOptions: that.rtownOptions,
									rtypeId: '',
									rtypeOptions: that.rtypeOptions,
									rtype: '',
									rtown: '',
									rname: '',
									rphone: '',
									radress: '',
									detail: '',
									first_img: '',
									show_video: '',
									post_video: '',
									detail_img: [1, 2],
									jingwei: ''
								}
							} else {
								that.$message.error(res.message)
							}
						})
					}
				})
			},
			// 编辑周边
			handleModifyPerlmeter() {
				var that = this;
				this.$refs.modifyDialogForm.validate(valid => {
					if (valid) {
						if (that.formModifyDialog.jingwei == '') {
							that.$message.error('请选择地址在地图中对应的位置')
							that.$refs.mapButton.$el.click()
							return
						}
						var data = that.formModifyDialog
						appupdateArounds(data).then((res) => {
							// console.log(res);
							if (res.code == 200) {
								that.get_table_data('list')
								that.dialogModifyVisible = false
								that.$message.success('周边修改成功！')
								that.formModifyDialog = {
									id: '',
									rtownId: '',
									rtownOptions: that.rtownOptions,
									rtypeId: '',
									rtypeOptions: that.rtypeOptions,
									rtype: '',
									rtown: '',
									rname: '',
									rphone: '',
									radress: '',
									detail: '',
									first_img: '',
									show_video: '',
									detail_img: [1, 2],
									jingwei: ''
								}
							} else {
								that.$message.err(res.message)
							}
						})
					}
				})
			},
			/**
			 * 显示添加产品对话框
			 */
			showAddProductDialog() {
				// this.$set(this.formAddProduct, 'product_name', '')
				// this.$set(this.formAddProduct, 'product_desc', '')
				// this.$set(this.formAddProduct, 'price', '')

				this.dialogAddProductVisible = true
			},
			// 添加产品
			handleAddProduct() {
				var that = this
				appinsertAroundPd(that.formAddProduct).then((res) => {
					// console.log(res);
					if (res.code === 200) {
						that.getProductTableData(that.formAddProduct.aid)
						that.dialogAddProductVisible = false
						that.$message.success('产品添加成功！')
						that.get_table_data('list')
					} else {
						that.$message.warning('产品添加失败！')
					}
				}).catch((err) => {
					that.$message.error(err.message)
				});
			},
			// 编辑产品
			handleModifyProduct() {
				var that = this
				appupdateAround_pd(that.formModifyProduct).then((res) => {
					// console.log(res);
					if (res.code === 200) {
						that.getProductTableData(that.formModifyProduct.aid)
						that.dialogModifyProductVisible = false
						that.$message.success('产品编辑成功！')
					} else {
						that.$message.warning('产品编辑失败！')
					}
				}).catch((err) => {
					that.$message.error(err.message)
				});
			},
			// 显示修改产品对话框
			showModifyProduct(row) {
				this.$set(this.formModifyProduct, 'id', row.id)
				this.$set(this.formModifyProduct, 'product_name', row.product_name)
				this.$set(this.formModifyProduct, 'product_desc', row.product_desc)
				this.$set(this.formModifyProduct, 'price', row.price)

				this.dialogModifyProductVisible = true
			},
			// 显示删除产品对话框
			showDelProduct(row) {
				var that = this
				this.$confirm('此操作将永久删除该产品, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					appdelAround_pd(row.id).then((res) => {
						// console.log(res);
						if (res.code === 200) {
							that.getProductTableData(that.formDelProduct.aid)
							that.dialogAddProductVisible = false
							that.$message.success('产品删除成功！')
							this.get_table_data('list')
						} else {
							that.$message.warning('产品删除失败！')
						}
					}).catch((err) => {
						that.$message.error(err.message)
					});
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			/**
			 * 新增周边
			 */
			add_perimeter() {
				// this.$set(this.formAddDialog, 'rtownId', '')
				// this.$set(this.formAddDialog, 'rtypeId', '')
				// this.$set(this.formAddDialog, 'rtype', '')
				// this.$set(this.formAddDialog, 'rtown', '')
				// this.$set(this.formAddDialog, 'rname', '')
				// this.$set(this.formAddDialog, 'rphone', '')
				// this.$set(this.formAddDialog, 'radress', '')
				// this.$set(this.formAddDialog, 'detail', '')
				// this.$set(this.formAddDialog, 'first_img', '')
				// this.$set(this.formAddDialog, 'show_video', '')
				// this.$set(this.formAddDialog, 'detail_img', [1, 2])
				this.detail_img_array = []

				this.dialogAddVisible = true
			},
			/**
			 * 打开编辑周边
			 * @param {Object} row
			 */
			handleModifyClick(row) {
				// console.log(row);
				this.$set(this.formModifyDialog, 'id', row.id)
				this.$set(this.formModifyDialog, 'rtype', row.rtype)
				this.$set(this.formModifyDialog, 'rtown', row.rtown)
				this.$set(this.formModifyDialog, 'rname', row.rname)
				this.$set(this.formModifyDialog, 'rphone', row.rphone)
				this.$set(this.formModifyDialog, 'radress', row.radress)
				this.$set(this.formModifyDialog, 'detail', row.detail)
				this.$set(this.formModifyDialog, 'first_img', row.first_img)
				this.$set(this.formModifyDialog, 'jingwei', row.jingwei)
				if (typeof row.show_video !== 'undefined') {
					var tmpOption = this.videoOptions
					tmpOption.sources[0].src = row.show_video
					this.$set(this.formModifyDialog, 'show_video', tmpOption)
					this.$set(this.formModifyDialog, 'post_video', row.show_video)
				} else {
					this.$set(this.formModifyDialog, 'show_video', '')
					this.$set(this.formModifyDialog, 'post_video', '')
				}
				this.$set(this.formModifyDialog, 'detail_img', row.detail_img.split(','))

				this.dialogModifyVisible = true
			},
			/**
			 * 显示删除周边
			 */
			handleDelClick(row) {
				this.delPerimeterId = row.id
				this.dialogDeleteVisible = true
			},
			/**
			 * 删除周边记录
			 */
			dialogDeletePerimeter() {
				var that = this
				appdelAround(this.delPerimeterId).then((res) => {
					// console.log(res);
					if (res.code == 200) {
						that.get_table_data('list')
						that.dialogDeleteVisible = false
						that.$message.success('周边删除成功！')
					} else {
						that.$message.error(res.message)
					}
				})
			},
			/**
			 * 周边详情对话框
			 * @param {Object} row
			 */
			handleDetailClick(row) {
				// console.log(row);
				this.productTableData = []
				this.getProductTableData(row.id)

				this.$set(this.formDetailDialog, 'id', row.id)
				this.$set(this.formDetailDialog, 'rtype', row.rtype)
				this.$set(this.formDetailDialog, 'rname', row.rname)
				this.$set(this.formDetailDialog, 'rtown', row.rtown)
				this.$set(this.formDetailDialog, 'radress', row.radress)
				this.$set(this.formDetailDialog, 'rphone', row.rphone)
				var tmp_show_img = []
				tmp_show_img.push(row.first_img)
				this.$set(this.formDetailDialog, 'show_img', tmp_show_img)
				this.$set(this.formDetailDialog, 'first_img', row.first_img)
				this.$set(this.formDetailDialog, 'detail_img', row.detail_img.split(','))
				this.$set(this.formDetailDialog, 'detail', row.detail)
				this.$set(this.formDetailDialog, 'jingwei', row.jingwei)

				this.videoOptions.sources[0].src = row.show_video
				this.$set(this.formDetailDialog, 'show_video', this.videoOptions)

				this.$set(this.formAddProduct, 'aid', this.formDetailDialog.id)
				this.$set(this.formModifyProduct, 'aid', this.formDetailDialog.id)
				this.$set(this.formDelProduct, 'aid', this.formDetailDialog.id)

				this.dialogInfoVisible = true
			},
			// 获取产品表格数据
			getProductTableData(id) {
				var data = {
					aid: id,
					page: 1,
					rows: 500
				}
				getProductTableData(data).then((res) => {
					// console.log(res);
					if (res.code === 200) {
						if (res.rows != '') {
							for (var i = 0; i < res.rows.length; i++) {
								res.rows[i].xuhao = i + 1
							}
							this.productTableData = res.rows
						}
					} else {
						this.$message.error(err.message)
					}
				}).catch((err) => {
					this.$message.error(err.message)
				});
			},
			/**
			 * 获取周边记录,表格数据
			 */
			get_table_data(param) {
				this.loading = true
				this.get_condtion();

				let data = this.cond_data;
				if (param == 'search') {
					data.page = 1
					this.pagination.currentPage = 1
				}

				var that = this
				// console.log(data);
				getTableData(data).then((res) => {
					// console.log(res.rows);
					if (res.code === 200) {
						let tempData = res.rows;
						if (typeof tempData !== 'undefined' && tempData !== '') {
							this.pagination.total = res.total
							this.tableData = []
							for (var i = 0; i < tempData.length; i++) {
								tempData[i].xuhao = (this.pagination.currentPage - 1) * this.pagination.pageSize + i + 1
								this.tableData.push(tempData[i])
							}
						} else {
							this.tableData = []
							this.$message.warning('没有符合条件的数据！')
						}
						// that.tableData.sort((a,b) => b.createDate.localeCompare(a.createDate))
					} else {
						that.tableData = []
						that.$message.warning('没有符合条件的数据！')
					}
				}).catch((err) => {
					// console.log(err);
					that.$message.error(err.message)
				});
				that.loading = false;
			},
			/**
			 * 查询条件
			 */
			get_condtion() {
				let data = {
					page: this.pagination.currentPage,
					rows: this.pagination.pageSize
				}

				if (this.formInline.key !== '') {
					data.key = this.formInline.key
				}

				if (this.formInline.rtown !== '') {
					data.rtown = this.formInline.rtown
				}

				if (this.formInline.rtype !== '') {
					data.rtype = this.formInline.rtype
				}

				this.cond_data = data;
			},
			/**
			 * 搜索
			 */
			btn_search() {
				this.get_table_data('search')
			},
			/**
			 * currentPage 改变时会触发
			 * @param {Object} val
			 */
			currentPageChange(val) {
				this.pagination.currentPage = val
				this.get_table_data('pages')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.app-container {
		background-color: #EFF2F7;
		padding: 10px;

		.el-row {

			.el-col {
				padding: 10px;

				.cell {
					padding: 30px;
					border-radius: 10px;
					background-color: #FFFFFF;
					box-shadow: 0px 3px 21px 0px rgba(60, 108, 254, 0.16);

					.cell-title {
						display: flex;
						justify-content: space-between;
						align-items: center;
						margin-bottom: 30px;
						padding-bottom: 30px;
						border-bottom: 1px solid #CCCCCC;

						.title-left {
							display: flex;
							align-items: center;

							.title {
								font-size: 22px;
								font-family: Microsoft YaHei-3970(82674968);
								font-weight: bold;
								color: #1A202B;
							}

							.title-detail {
								margin-left: 50px;
								font-size: 18px;
								font-family: Microsoft YaHei-3970(82674968);
								color: #1A202B;
							}
						}

						.title-right {
							display: flex;
							justify-content: space-between;
							align-items: center;

							.el-button {
								width: 110px;
								height: 46px;
								background: #2B4CFE;
								font-size: 18px;
								color: #FFFFFF;
								font-family: Microsoft YaHei-3970(82674968);
								border-radius: 5px;
							}

							.el-button--warning {
								background: #F88A64;
							}
						}
					}

					.cell-body {

						.controls {
							display: flex;
							justify-content: space-between;
							align-items: center;

							.demo-form-inline {
								display: inline-flex;
								flex-wrap: wrap;
								align-items: center;
								justify-content: flex-start;

								.btn-search {
									background: rgba(9, 101, 98, 1);
									font-size: 14px;
									color: #FFFFFF;
									font-family: Microsoft YaHei-3970(82674968);
									border-radius: 5px;
									border: none;
								}
							}

							.export {
								background: rgba(9, 101, 98, 1);
								font-size: 14px;
								color: #FFFFFF;
								font-family: Microsoft YaHei-3970(82674968);
								border-radius: 5px;
								margin-bottom: 22px;
								border: none;
							}
						}

						.pagination-table {
							display: flex;
							justify-content: flex-end;
							align-items: center;
							height: 30px;
							margin-top: 20px;

							.txt-notice {

								span {
									font-size: 28px;
									font-weight: 500;
									font-family: '微软雅黑';
								}
							}

							::v-deep .el-pagination {
								display: flex;
								justify-content: flex-end;
								align-items: center;
							}

							::v-deep .el-pagination ul {
								display: flex;

							}

							::v-deep .el-pagination button,
							::v-deep .el-pagination li {
								display: flex;
								justify-content: center;
								align-items: center;
								width: 50px;
								height: 36px;
								border: 1px solid #626262;
								border-radius: 3px;
								font-size: 14px;
								margin: 0 5px;
							}

							::v-deep .el-pagination span {
								margin-left: 10px;
							}

							::v-deep .el-pagination .el-pagination__jump {
								font-size: 16px;
							}

							::v-deep .el-pagination .el-pagination__editor {
								width: 50px;
								height: 36px;
								margin: 0 5px;
							}

							::v-deep .el-pagination .el-input__inner {
								width: 50px;
								height: 36px;
								border: 1px solid #626262;
								margin: -4px 0 0 0;
							}
						}
					}
				}
			}
		}

		::v-deep .el-dialog {
			margin: 0 !important;
			width: 600px;
			height: 560px;
			background: #FFFFFF;
			box-shadow: 0px 0px 13px 0px rgba(0, 0, 0, 0.29);
			border-radius: 6px;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);

			.el-dialog__header {
				display: flex;
				align-items: center;
				width: 100%;
				height: 58px;
				padding: 30px;
				border-radius: 6px 6px 0px 0px;
				font-weight: bold;
				border-bottom: 1px solid rgba(230, 230, 230, 1);
			}

			.el-dialog__body {
				padding-bottom: 0;

				.el-form-item__label,
				.el-form-item__content {
					font-size: 16px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #53575A;
				}
			}

			// 删除对话框的样式
			.del-account-body {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				height: 180px;

				img {
					width: 72px;
				}

				.del-account-body-txt {
					height: 58px;
					line-height: 58px;
					font-size: 18px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #333333;
				}
			}

			.el-dialog__footer {
				padding-bottom: 0 !important;
				text-align: center;

				.el-button.el-button--default {
					width: 75px;
					height: 40px;
					border: 1px solid #2B4CFE;
					border-radius: 6px;
					font-size: 16px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #2B4CFE;
				}

				.el-button.el-button--primary {
					width: 75px;
					height: 40px;
					background: #2B4CFE;
					border-radius: 6px;
					font-size: 16px;
					font-family: Microsoft YaHei-3970(82674968);
					color: #FFFFFF;
					margin-left: 60px;
				}
			}
		}
	}
</style>

<style>
	.perimeter-class {
		width: 900px !important;
		height: 760px !important;
	}

	.el-date-editor--daterange.el-input__inner {
		width: 280px !important;
	}

	.demo-table-expand {
		font-size: 0;
	}

	.demo-table-expand label {
		width: 180px;
		color: #99a9bf;
	}

	.demo-table-expand .el-form-item {
		margin-right: 0;
		margin-bottom: 0;
		width: 33%;
	}

	.show-imgs {
		display: flex;
	}

	.imgs {
		display: flex;
		flex-direction: row;
		margin-left: 20px;
	}

	.lbl-cls {
		display: inline-block;
		width: 100px;
		text-align: right;
		padding-right: 10px;
		color: #bbb;
	}

	.export {
		background: rgba(9, 101, 98, 1) !important;
		font-size: 14px !important;
		color: #FFFFFF !important;
		font-family: Microsoft YaHei-3970(82674968);
		border-radius: 5px !important;
		margin-bottom: 22px !important;
		border: none !important;
	}

	.add-class {
		height: 450px !important;
		width: 800px !important;
	}

	.dialog-footer {
		display: flex;
		justify-content: flex-end;
	}

	.add-info-cancel-btn {
		color: rgba(9, 101, 98, 1) !important;
		border: 1px solid rgba(9, 101, 98, 1) !important;
	}

	.add-info-confirm-btn {
		border: none !important;
		background: rgba(9, 101, 98, 1) !important;
		color: #fff !important;
		border-radius: 5px !important;
		margin-left: 28px !important;
	}

	.el-form-item>label {
		color: rgba(128, 128, 128, 1) !important;
	}

	.custom-input {
		width: 7rem !important;
	}

	.custom-input input {
		width: 7rem !important;
	}

	.el-radio {
		margin-right: 10px;
	}

	.el-form-item {
		margin-bottom: 16px !important;
	}

	.add-dlg-class {
		width: 830px !important;
		height: 850px !important;
	}

	.add-product-class {
		width: 680px !important;
		height: 440px !important;
	}

	.el-carousel__indicators {
		display: none !important;
	}

	.el-tabs__item {
		width: 100px !important;
		text-align: center !important;
		font-size: 20px !important;
	}


	.el-tabs__item.is-active,
	.el-tabs__item:hover {
		color: rgba(9, 101, 98, 1) !important;
	}

	.el-tabs__active-bar {
		color: rgba(9, 101, 98, 1) !important;
		background-color: rgba(9, 101, 98, 1) !important;
	}

	.el-dialog-delete-account {
		height: 300px !important;
		width: 500px !important;
	}

	.el-dialog-delete-account .el-dialog__header {
		display: none !important;
	}

	.add-user-cancel-btn {
		color: rgba(9, 101, 98, 1) !important;
		border: 1px solid rgba(9, 101, 98, 1) !important;
	}

	.add-user-confirm-btn {
		border: none !important;
		background: rgba(9, 101, 98, 1) !important;
		color: #fff !important;
		border-radius: 5px !important;
		margin-left: 28px !important;
	}

	.ql-container {
		height: 150px;
	}
</style>