<template>
	<div>
		<el-dialog title="上架" :visible.sync="dialogVisible" width="30%">
			<el-checkbox v-model="allPut">同时上架到所有店铺，所有机器中</el-checkbox>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="putShop">确 定</el-button>
			</span>
		</el-dialog>
		<el-dialog title="上架" :visible.sync="dialogVisible2" width="30%">
			本商品已在店铺中上架，下架商品会在店铺中同时下架，是否确认下架？
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible2 = false">取 消</el-button>
				<el-button type="primary" @click="offShop">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
import { putShop, offShop } from "@/api/system/goods";

export default {
	data() {
		return {
			id: '',
			dialogVisible: false,
			dialogVisible2: false,
			allPut: false
		}
	},
	methods: {
		putShopModal(id) {
			this.id = id
			this.dialogVisible = true
		},
		offShopModal(id) {
			this.id = id
			this.dialogVisible2 = true
		},
		putShop() {
			putShop({ goodsId: this.id, boo: this.allPut }).then(res => {
				this.$modal.msgSuccess("上架成功");
				this.dialogVisible = false;
				this.$emit('callback')
			})
		},
		offShop() {
			offShop({ goodsId: this.id, boo: true }).then(res => {
				this.$modal.msgSuccess("下架成功");
				this.dialogVisible2 = false
				this.$emit('callback')
			})
		}
	}
}
</script>

<style>
</style>