<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
			label-width="68px">
			<el-form-item label="上架日期" prop="beginTime">
				<div class="block">
					<el-date-picker v-model="queryParams.beginTime" value-format="yyyy-MM-dd" type="date"
						placeholder="选择日期" style="width: 200px;">
					</el-date-picker>
				</div>
			</el-form-item>
			<el-form-item label="" prop="endTime">
				<div class="block">
					<el-date-picker v-model="queryParams.endTime" type="date" value-format="yyyy-MM-dd"
						placeholder="选择日期" style="width: 200px;">
					</el-date-picker>
				</div>
			</el-form-item>
			<el-form-item label="店铺名称" prop="shopId">
				<el-select filterable clearable v-model="queryParams.shopId">
					<el-option v-for="(item,index) in shopList" :key="item.value" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="商品编号" prop="goodsId">
				<el-input v-model="queryParams.goodsId" placeholder="请输入商品编号" clearable
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="失败类型" prop="type">
				<el-select v-model="queryParams.type" placeholder="请选择失败类型"
					style="width: 100%">
					<el-option v-for="dict in dict.type.type_fail" :key="dict.value" :label="dict.label"
						:value="dict.value"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="备注" prop="remark">
				<el-input v-model="queryParams.remark" placeholder="请输入备注" clearable
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="所属游戏" prop="gameId">
				<el-select filterable clearable v-model="queryParams.gameId">
					<el-option v-for="(item,index) in gameList" :key="item.id" :label="item.gameName" :value="item.id">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
				<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>

		<el-row :gutter="10" class="mb8">
			<el-col :span="1.5">
				<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
					v-hasPermi="['system:tBusGoodsRegister:add']">新增
				</el-button>
			</el-col>
			<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
		</el-row>

		<el-table stripe="true" v-loading="loading" :data="goodsList">
			<el-table-column prop="createTime" show-overflow-tooltip align="center" width="110px" height="20px"
				label="创建时间">
			</el-table-column>
			<el-table-column label="店铺名称" height="20px" prop="shopName" />
			<el-table-column label="商品名称" show-overflow-tooltip align="center" height="20px" prop="goodsName" />
			<el-table-column label="商品编号" height="20px" prop="goodsId" />
			<el-table-column label="游戏账号" height="20px" prop="gameAccount" />
			<el-table-column label="游戏名称" align="center" prop="gameId">
				<template slot-scope="scope">
					<div v-for="(item,index) in gameList" :key="item.id" :label="item.gameName" :value="item.id">
						<span v-if="item.id==scope.row.gameId">{{item.gameName}}</span>
					</div>
				</template>
			</el-table-column>
			<el-table-column label="游戏账号售价" align="center" prop="price" />
			<el-table-column label="失败类型" align="center" prop="type">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.type_fail" :value="scope.row.type" />
				</template>
			</el-table-column>
			<el-table-column label="备注" align="center" prop="remark" />

			<el-table-column label="操作" width="200px" align="center" class-name="small-padding fixed-width">
				<template slot-scope="scope">
					<el-button size="small" type="success" v-hasPermi="['system:tBusGoodsRegister:edit']"
						@click="handleUpdate(scope.row)">修改
					</el-button>
					<el-button size="small" type="danger" v-hasPermi="['system:tBusGoodsRegister:remove']"
						@click="handleDelete(scope.row)">删除
					</el-button>
					<el-button size="small" type="primary" v-hasPermi="['system:tBusGoodsRegister:query']"
						@click="handleXq(scope.row)">详情
					</el-button>
				</template>
			</el-table-column>
		</el-table>

		<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
			@pagination="getList" />

		<!-- 添加或修改商品信息对话框 -->
		<el-dialog :title="title" :before-close="handleClose1" :visible.sync="open" high="1500px" width="100%"
			append-to-body>
			<el-form ref="form" :model="form" :rules="rules" label-width="80px">
				<el-row>
					<el-col :span="24">
						<el-form-item label="商品名称" prop="goodsName">
							<el-input type="textarea" :disabled='disabled' v-model="form.goodsName" placeholder="请输入商品名称" />
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="店铺名称" prop="shopId">
							<el-select v-model="form.shopId" style="width: 100%" filterable placeholder="请选择店铺"
								:disabled='disabled'>
								<el-option v-for="(item,index) in shopList" :key="item.id" :label="item.label"
									:value="item.value"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="商品编号" prop="goodsId">
							<el-input @blur="findGoods(form.goodsId)" :disabled='disabled' v-model="form.goodsId"
								placeholder="请输入商品编号" />
						</el-form-item>
					</el-col>

				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="所属游戏" prop="gameId">
							<el-select :disabled='disabled' v-model="form.gameId" @change="changeGameArea" style="width: 100%"
								filterable placeholder="请选择所属游戏">
								<el-option v-for="(item,index) in gameList" :key="item.id" :label="item.gameName"
									:value="item.id"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="游戏大区" prop="gameareaId">
							<el-cascader :disabled='disabled' style="width: 100%" placeholder="请选择游戏大区" v-model="form.gameareaId"
								:options="options" :props="{ expandTrigger: 'hover' }"></el-cascader>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="游戏账号" prop="gameAccount">
							<el-input :disabled='disabled' v-model="form.gameAccount" placeholder="请输入游戏账号" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="账号售价" prop="price">
							<el-input :disabled='disabled' v-model="form.price" placeholder="请输入游戏账号售价" />
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="失败类型" prop="type">
							<el-select v-model="form.type" :disabled='disabled' placeholder="请选择失败类型"
								style="width: 100%">
								<el-option v-for="dict in dict.type.type_fail" :key="dict.value" :label="dict.label"
									:value="dict.value"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="备注" prop="remark">
							<el-input :disabled='disabled' type="textarea" v-model="form.remark" placeholder="请输入备注" />
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>

					<el-col :span="12">
						<el-form-item label="附录" prop="credentials">
							<div class="img_list" v-if="title=='修改失败信息'||title=='查看详情'">
								<div style="position: relative;width: 100px;height: 100px;">
									<span style="color: red;" v-if="form.pic==null">无凭证</span>
									<image-preview v-else :src="'https://static.taohaowan.com/'+form.pic" :width="100"
										:height="100" />
								</div>
							</div>
							<el-upload ref="upload" v-if="title!='查看详情'" :action="uploadImgUrl" list-type="picture-card"
								:before-upload="beforeAvatarUpload" :on-success="handleAvatarSuccess"
								:on-remove="handleRemove" :on-change="changeUpload" :show-file-list="true"
								accept="image/png, image/jpeg, application/pdf" :multiple="true" :headers="headers">
							</el-upload>
						</el-form-item>
					</el-col>

				</el-row>
			</el-form>

			<div slot="footer" class="dialog-footer" v-if="title!='查看详情'">
				<el-button type="primary" @click="submitForm">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>


	</div>
</template>
<style lang="scss" scoped>
	.fxk {
		width: 140px;
		margin: 0 10px;
		overflow-x: hidden;
		// font-weight: 600;
	}

	.post-information-title {
		font-size: 15px;
		margin: -35px 10px 10px 10px;
		color: dodgerblue;

		span {
			display: inline-block;
			width: 11px;
			height: 100%;

			img {
				width: 100%;
			}
		}
	}

	.staffUpData .el-upload-list--picture-card .el-upload-list__item {
		overflow: inherit;
		float: left;
		background: rgba(255, 94, 94, 1);
		margin-top: 20px;

		img {
			display: block;
		}
	}

	.staffUpData .el-upload-list--picture-card .el-upload-list__item-name {
		display: block;
		width: 100%;
	}

	.staffUpData .el-upload--picture-card {
		margin-top: 20px;
	}

	.el-upload-list__item.is-success .el-upload-list__item-status-label {
		display: none !important;
	}

	.img_list {}

	.img_list div {
		margin: 10px;
		float: left;
	}
</style>

<script>
	import {
		listGoods,
		getGoods,
		delGoods,
		refGoods,
		addGoods,
		updateGoods,
		sell,
		getInitGoodsManager,
		getGameArea,
		getGoodsPictures,
		addGoodsPictures,
		getGoodsByShopId,
		getGameAttrib,
		goodsNoticeList,
		goodsPayment,
		goodsPaymentadd,
		getTBusShopInfo,
		getGameAttr,
		getGameAttr1,
		addAttr,
		getQueryById
	} from "@/api/data/numberIncreaseFailed";
	import {
		noticedown,
		noticeupload,
		noticeupdate
	} from "@/api/data/partnerlist";
	import {
		accountMonitoring,
	} from "@/api/data/numberLibrary";
	import {
		getToken
	} from "@/utils/auth";
	import {
		getInfo,
		getSysDeptInfo,
		queryTBusShop
	} from "@/api/data/goodsPayment";
	import {
		delAttach
	} from '@/api/data/attach'
	import Treeselect from "@riophae/vue-treeselect";
	import "@riophae/vue-treeselect/dist/vue-treeselect.css";
	import {
		deptTreeSelect
	} from '@/api/system/user';
	import Cookies from 'js-cookie';
	import axios from 'axios'
	import FileSaver from 'file-saver'
	import JSZip from 'jszip'

	export default {
		name: "Goods",
		dicts: ['account_source', 'is_multiple', 'by_stages', 'ranking', 'game_platform_mapping', 'identified_name',
			'account_type', 'binding_tap',
			'binding_psn',
			'account_type_wg', 'healthy_status', 'main_industry', 'rebates_type', 'type_fail'
		],
		components: {
			Treeselect
		},
		data() {
			return {
				imgType: 'ZC',
				value1: [],
				timer: null,
				checkList: ['7cf7907cc1e74d259bc3e538239c0132', '5ed2e37abe2249f5a5d6f9d7e0d13dfb'],
				attributeInvert: '',
				warehouse: '',
				userphone: false,
				ordercode: '',
				bdAccount: false,
				gameAttrs: [],
				gameAttrs2: [],
				gameAttrs3: [],
				gameAttrs4: [],
				input: [],
				selectvalue: [],
				resion1: [],
				checkarr: [],
				xinzeng: false,
				xiugai: false,
				xiugai1: false,
				xiugai2: false,
				values: [],
				labels: [],
				labels1: [],
				yxzhOptions: [],
				gameAttrs1: false,
				openGame: [],
				radio: '',
				props: {
					multiple: true
				},
				uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/uploadPlus", // 上传的图片服务器地址
				headers: {
					Authorization: "Bearer " + getToken(),
				},
				options: [],
				nginx_pictures_path: null,
				attach_list: [],
				pictureServerPath: null,
				// 遮罩层
				loading: true,
				sxz: false,
				lb: true,
				// 选中数组
				ids: [],
				ids1: [],
				type: [],
				block: true,
				channelid: false,
				bp1: false,
				bp2: false,
				deptName: '',
				deptName1: '',
				// 部门树选项
				deptOptions: undefined,
				// 非单个禁用
				single: true,
				// 非多个禁用
				multiple: true,
				multiple1: true,
				// 显示搜索条件
				showSearch: true,
				// 总条数
				total: 0,
				total1: 13,
				// 商品信息表格数据
				goodsList: [],
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				send: false,
				ck: false,
				xg: false,
				openPicture: false,
				openRefreshRecord: false,
				openRefreshRecord1: false,
				Channel: false,
				Channel1: false,
				bp: false,
				dbbp: false,
				bp1: false,
				form1: {
					userName: '',
				},

				// 查看表格
				tableData: [],
				tableData1: [],
				tableData2: [], //下拉框
				tableData3: [], //输入框
				tableData4: [], //补全新的下拉框
				// 修改参数
				form: {
					name: '',
					region: '',
					date1: '',
					date2: '',
					delivery: false,
					type: [],
					resource: '',
					desc: '',
					selectvalue: [],
					rebates: 'rebates_type_0'
				},
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					goodsName: null,
					gameId: null,
					gameName: null,
					gameareaId: null,
					gameareaName: null,
					price: null,
					healthyStatus: null,
					accountSource: null,
					gamePicture: null,
					shopId: null,
					sort: null,
					id: null
				},
				disabled: false,
				gameList: [],
				shopList: [],
				electronicDataList1: [],
				electronicDataList2: [],
				// 表单参数
				form: {
					electronicDataList: [],
					gamePicture: [],
					//创建一个游戏属性数值
					arrayLIst: [],
					sort: null,
				},
				form1: {
					identifiedNames: '',
				},
				// 表单校验
				rules: {

					sellChannels: [{
						required: true,
						message: "销售渠道不能为空",
						trigger: "blur"
					}],
					goodsName: [{
						required: true,
						message: "商品名称不能为空",
						trigger: "blur"
					}],
					goodsId: [{
						required: true,
						message: "商品编号不能为空",
						trigger: "blur"
					}],
					shopId: [{
						required: true,
						message: "店铺不能为空",
						trigger: "blur"
					}],
					type: [{
						required: true,
						message: "失败类型不能为空",
						trigger: "blur"
					}],
					gameId: [{
						required: true,
						message: "游戏不能为空",
						trigger: "blur"
					}],
					gameareaId: [{
						required: true,
						message: "大区不能为空",
						trigger: "blur"
					}],

					gameAccount: [{
						required: true,
						message: "游戏账号不能为空",
						trigger: "blur"
					}, ],
					selectvalue: [{
						required: true,
						message: "属性不能为空",
						trigger: "blur"
					}],
					ranking: [{
						required: true,
						message: "排位不能为空",
						trigger: "blur"
					}],
					accountType: [{
						required: true,
						message: "账户类型不能为空",
						trigger: "blur"
					}],
					accountTypeWg: [{
						required: true,
						message: "账号类型不能为空",
						trigger: "blur"
					}],
					bindingTap: [{
						required: true,
						message: "绑定tap不能为空",
						trigger: "blur"
					}],
					bindingPsn: [{
						required: true,
						message: "绑定psn不能为空",
						trigger: "blur"
					}],
					originalPrice: [{
						required: true,
						message: "商品原价不能为空",
						trigger: "blur"
					}],
					price: [{
						required: true,
						message: "账号售价不能为空",
						trigger: "blur",
					}, ],
					distributionChannel: [{
						required: true,
						message: "销售渠道不能为空",
						trigger: "blur"
					}],
					securityPrice: [{
						required: true,
						message: "包赔费用不能为空",
						trigger: "blur"
					}],
					securityRate: [{
						required: true,
						message: "包赔费率不能为空",
						trigger: "blur"
					}],
					isMultiple: [{
						required: true,
						message: "多倍包赔不能为空",
						trigger: "blur"
					}],
					byStages: [{
						required: true,
						message: "分期购买不能为空",
						trigger: "blur"
					}],

					paymentChannels: [{
						required: true,
						message: "付款渠道不能为空",
						trigger: "blur"
					}],
					paymentNumber: [{
						required: true,
						message: "付款流水号不能为空",
						trigger: "blur"
					}],
					isSecurity: [{
						required: true,
						message: "是否包赔不能为空",
						trigger: "blur"
					}],
					channelId: [{
							required: true,
							message: "分销编号不能为空",
							trigger: "blur"
						},
						{
							validator(rule, value, callback) {
								if (/(^[1-9]\d*$)/.test(value)) {
									callback()
								} else {
									callback(new Error('请输入正整数'))
								}
							},
							trigger: 'blur'
						}
					]
				},
				imageLinks: [],
				currentChooseImgList: [],
			};
		},
		watch: {
			'$route.query.shopId': {
				handler: function(newValue, oldValue) {
					if (newValue != undefined) {
						this.queryParams.shopId = newValue
					}
					if (oldValue != undefined) {
						this.queryParams.shopId = oldValue
					}
					this.getList();
				}
			}
		},
		created() {
			this.attributeInvert = this.$route.query.attributeInvert;
			this.warehouse = this.$route.query.warehouse;
			if (this.warehouse == 'Y') {
				this.bdAccount = true;
			}
			if (this.$route.query.openGame) {
				this.openGame = this.$route.query.openGame.split(',');
			} else {
				this.openGame = null
			}
			this.queryParams.sort = this.$route.query.sort;
			this.initGoodsManager();
			this.getList();
		},
		methods: {
			findGoods(id) {
				if(this.form.goodsName==null){
					getGoods(id).then(item => {
						this.form.goodsId = item.data.id;
						this.form.gameId = item.data.gameId;
						this.form.gameareaId = item.data.gameareaId;
						this.form.shopId = item.data.shopId;
						this.form.price = item.data.price;
						this.form.gameAccount = item.data.gameAccount;
						this.form.goodsName = item.data.goodsName;
						this.changeGameArea(this.form.gameId);
					})
				}
			},


			getBase64(img) {
				// width、height调用时传入具体像素值，控制大小 ,不传则默认图像大小
				function getBase64Image(img, width, height) {
					var canvas = document.createElement('canvas')
					canvas.width = width || img.width
					canvas.height = height || img.height

					var ctx = canvas.getContext('2d')
					ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
					var dataURL = canvas.toDataURL()
					return dataURL
				}
				return new Promise((resolve) => {
					var image = new Image()
					image.crossOrigin = 'Anonymous'
					image.src = img
					if (img) {
						image.onload = function() {
							// 读取图片之后的操作
							resolve(getBase64Image(image))
						}
					}
				})
			},
			handleClose1() {
				this.open = false;
				this.reset();
			},
			deletePicture(id) {
				let that = this
				this.$modal.confirm("确定删除此图片吗？").then(function() {
					delAttach(id).then(r => {
						getGoodsPictures({
							goodsId: that.form.id
						}).then(resp => {
							that.nginx_pictures_path = resp.nginx_pictures_path
							if (resp.attachlist.length != 0) {
								that.attach_list = resp.attachlist
							} else {
								that.attach_list = resp.gamePicturelist
							}

						})
					})
				})
			},

			rowClass() {
				return "text-align: rigth;";
			},

			addPictures() {
				let that = this
				this.form.gamePicture = null
				addGoodsPictures(this.form).then(resp => {
					if (resp.code == 200) {
						setTimeout(this.test, 3000); //3000毫秒后执行test()函数，只执行一次。
					}
				})

			},
			test() {
				this.openPicture = false
				let query = {
					id: this.form.id
				}
				noticeupload(query).then(res => {
					console.log(res)
				})
				location.reload();
			},

			uploadSumit() { // 上传文件
				this.isloading = true
				uploadElectronicData(this.form).then((res) => {
					this.$emit('getUploadSuccess')
					this.$message({
						message: '上传成功',
						type: 'success'
					})
					this.isshow = false
					this.isloading = false
				}).catch((e) => {
					this.$message({
						message: '上传失败',
						type: 'error'
					})
					this.form.electronicDataList = []
					this.isshow = false
					this.isloading = false
				})
			},
			openDialog(employeeId) {
				this.isshow = true
				this.form.employeeId = employeeId
				// employeeId && this.editEmployeeStatusDetail()
			},
			handlePictureCardPreview(file) {
				this.dialogImageUrl = file.url
				this.dialogVisible = true
			},
			handleDownload(file) {},
			// 删除
			handleRemove(file, fileList) {},
			// 上传之前
			beforeAvatarUpload(file) {
				const isJPG = file.type === 'image/jpeg'
				const isPng = file.type === 'image/png'
				const isPdf = file.type === 'application/pdf'
				const isLt50M = file.size / 1024 / 1024 < 50
				if (!isLt50M) {
					this.$message.warning('上传文件大小不能超过 50MB!')
					return false
				}
				if (!isJPG && !isPng && !isPdf) {
					this.$message.warning('只能上传 JPG/PNG/PDF/JPEG 格式!')
					return false
				}
			},
			// 上传成功
			handleAvatarSuccess(res) {
				this.form.pic = res.data.url
			},
			// 文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用
			changeUpload(file, fileList) {

				if (file.status === 'success') {
					this.$refs.upload.uploadFiles = this.$refs.upload.uploadFiles.filter((item) => {
						return item.raw.size / 1024 / 1024 < 50
					})
					this.tobase64(file)
				}
			},
			tobase64(file) {
				let that = this
				var reader = new FileReader()
				reader.readAsDataURL(file.raw)
				reader.onload = (e) => {
					const tempobj = {
						data: file.response.data.webUrl,
						suffix: '.' + file.raw.type.split('/')[1],
						fileName: file.name,
						uid: file.uid,
					}
					if (tempobj.uid == null) {
						this.$message.error('图片uid为空,请稍后重新上传图片!');
					} else if (tempobj.data == null) {
						this.$message.error('图片data为空,请稍后重新上传图片!');
					} else if (tempobj.suffix == null) {
						this.$message.error('图片suffix为空,请稍后重新上传图片!');
					} else if (tempobj.fileName == null) {
						this.$message.error('图片fileName为空,请稍后重新上传图片!');
					} else {
						this.form.electronicDataList.push(tempobj)
					}
				}
			},

			// 强制重新渲染
			forceUpdate() {
				this.$forceUpdate()
			},

			changeGameArea() {
				this.form.arrayList = []
				this.gameAttrs = []
				this.selectvalue = []
				this.tableData2 = []
				this.tableData3 = []
				this.tableData4 = []
				let that = this
				let gm = {
					gameId: this.form.gameId
				}
				getGameArea(gm).then(res => {
					that.options = res.gameArea
				})
			},
			/**
			 * 过滤数组 将树状结构转换为平铺数组
			 * @param data 树形结构的数据
			 */
			//将树形结构数据转换为平铺数据
			treeToArr(arr) {},

			find(arr) {
				this.labels = [];
				arr.forEach(arr => {
					let reasult = this.tableData1.find(item => {
						return item.id == arr
					})
					this.labels.push(reasult.label);
				});
			},
			initGoodsManager() {
				getInitGoodsManager().then(res => {
					this.pictureServerPath = res.pictureServerPath
					this.gameList = res.gameList
				});
				queryTBusShop().then(response => {
					response.data.forEach((item) => {
						this.shopList.push({
							label: item.name,
							value: item.id,
						});
					});
				});
			},

			/** 查询商品信息列表 */
			getList() {
				this.loading = true;
				listGoods(this.queryParams).then(response => {
					this.goodsList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			// 取消按钮
			cancelPic() {
				this.$refs.upload.clearFiles()
				this.openPicture = false;
				this.reset();
				location.href = location.href + "#reloaded";
			},


			cancel() {
				this.open = false;
				this.send = false;
				this.bp = false;
				this.dbbp = false;
				this.bp1 = false;
				this.bp2 = false;
				this.gameAttrs = [];
				this.selectvalue = [];
				this.tableData2 = [];
				this.tableData3 = [];
				this.tableData4 = [];
				this.xiugai = false;
				this.xiugai1 = false;
				this.xiugai2 = false;
				this.gameAttrs1 = false;
				this.channelid = false;
				this.reset();
			},
			// 表单重置
			reset() {
				this.form = {
					id: null,
					goodsName: null,
					gameId: null,
					gameName: null,
					gameareaId: null,
					gameareaName: null,
					createTime: null,
					price: null,
					healthyStatus: null,
					accountSource: null,
					gamePicture: null,
					goodsStatus: null,
					shopId: null,
					electronicDataList: [],
					arrayList: [],
				};
				this.resetForm("form");
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				this.getList();
			},
			/** 重置按钮操作 */
			resetQuery() {
				this.resetForm("queryForm");
				this.handleQuery();
			},
			// 多选框选中数据
			handleSelectionChange(selection) {
				this.ids = selection.map(item => item.id)
				this.single = selection.length !== 1
				this.multiple = !selection.length
				this.multiple1 = !selection.length
			},
			/** 新增按钮操作 */
			handleAdd() {
				this.disabled = false
				this.open = true;
				this.title = '新增失败信息'
			},
			handleUpdate(row) {
				this.form = [];
				this.disabled = false
				getQueryById(row.id).then(res => {
					this.form = res.data;
					this.open = true;
					this.title = '修改失败信息';
					this.changeGameArea(this.form.gameId);
				})
			},
			handleXq(row) {
				this.form = [];
				getQueryById(row.id).then(res => {
					this.form = res.data;
					this.open = true;
					this.title = '查看详情';
					this.disabled = true;
					this.changeGameArea(this.form.gameId);
				})
			},
			/** 删除按钮操作 */
			handleDelete(row) {
				let that = this
				const ids = row.id || this.ids;
				this.$modal.confirm('是否删除商品信息编号为"' + row.goodsId + '"的数据项？').then(function() {
					return delGoods(ids);
				}).then(() => {
					this.getList();
					this.$modal.msgSuccess("已删除");
				}).catch(() => {});

			},
			/** 提交按钮 */
			submitForm() {
				let _this = this;
				this.$refs["form"].validate(valid => {
					if (valid) {
						if (Array.isArray(this.form.gameareaId) != true) {
							_this.form.gameareaId = this.form.gameareaId
						} else {
							_this.form.gameareaId = _this.form.gameareaId[this.form.gameareaId.length - 1]
						}
						if (_this.form.id != null) {
							_this.form.verticalProperties = JSON.stringify(this.form.arrayList);
							updateGoods(_this.form).then(response => {
								this.$modal.msgSuccess("修改成功");
								_this.form = [];
								this.open = false;
								this.getList();
							});
						} else {
							_this.form.verticalProperties = JSON.stringify(this.form.arrayList);
							addGoods(_this.form).then(response => {
								_this.form = [];
								this.$modal.msgSuccess("新增成功");
								this.open = false;
								this.getList();
								window.location.reload();
							})
						}
					}
				});
			},
			test1() {
				let id = Cookies.get('DeleteId')
				let query = {
					id: id
				}
				let that = this
				noticedown(query).then(res => {
					clearInterval(that.timer)
				})
			},
			/** 导出按钮操作 */
			handleExport() {
				this.download('system/goods/export', {
					...this.queryParams
				}, `goods_${new Date().getTime()}.xlsx`)
			}
		}
	};
</script>