<template>
<el-dialog title="发货" v-model="visible" :width="600" destroy-on-close :close-on-click-modal="false" @closed="$emit('closed')">
	<el-main>
		<el-form ref="dialogForm" :model="form" :rules="rules" label-width="160px">
			<el-form-item label="发货单号" prop="delivery_no">
				<el-input v-model="form.delivery_no" placeholder="请输入发货单号" clearable />
			</el-form-item>
		</el-form>
	</el-main>
	<template #footer>
		<el-button type="primary" @click="onSubmit">确认提交</el-button>
	</template>
</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "add",
			form: {delivery_no: ''},
			rules: {
				delivery_no: [{required: true, message: '请输入发货单号'}]
			},
			visible: false,
			isSaveing: false,
			cache: {}
		}
	},
	watch: {
		"form.operate"(value){
			this.priceTab = value[0]
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(mode='add'){
			this.mode = mode;
			this.visible = true;
			return this;
		},
		//表单提交方法
		onSubmit(){
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					let res = await this.$API.order.lists.send.post(this.form);

					this.isSaveing = false;
					if(res.code == 1){
						this.$emit('success', res.data)
						this.visible = false;
						this.$message.success("操作成功")
					}else{
						this.$message.error(res.message)
					}
				}
			})
		},
		//表单注入数据
		setData(data){
			this.loading = true
			this.form.order_id = data.order_id
			this.form.id = data.id
			this.form.delivery_no = data.delivery_no
		}
	}
}
</script>
