<template>
<el-dialog title="复制店铺" v-model="visible" :with="800" destroy-on-close :close-on-click-modal="false" @closed="$emit('closed')">
	<el-form :model="form" label-width="100px" :rules="rules" ref="dialogForm">
		<el-form-item label="店铺名称" prop="title">
			<el-input v-model="form.title" placeholder="请输入店铺名称" />
		</el-form-item>
		<el-form-item label="店主" prop="member_id">
			<el-input v-model="form.member_id" placeholder="请输入店主UID" />
		</el-form-item>
	</el-form>
	<template #footer>
		<el-button type="primary" @click="onSubmit" :disable="isSaveing">确认提交</el-button>
	</template>
</el-dialog>
</template>

<script>
export default {
	data(){
		return {
			visible: false,
			isSaveing: false,
			form: {},
			rules: {
				title: [
					{ required: true, message: '请输入店铺名称', trigger: 'blur' }
				],
				member_id: [
					{ required: true, message: '请输入店主UID', trigger: 'blur' }
				]
			}
		}
	},
	mounted(){
	},
	methods:{
		//显示
		open(){
			this.visible = true;
			return this;
		},
		async onSubmit(){
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					let res = await this.$API.store.lists.copy.post(this.form);
					if(res.code == 1){
						this.$message.success("复制成功");
						this.visible = false;
						this.$emit('success', res.data);
					}else{
						this.$message.error(res.message)
					}
				}
			})
		},
		//表单注入数据
		setData(data){
			this.form.copy_id = data.id
		}
	}
}
</script>

<style scoped>
</style>
