|
|
|
@ -1,14 +1,5 @@ |
|
|
|
|
<template> |
|
|
|
|
<a-modal |
|
|
|
|
:title="title" |
|
|
|
|
:width="780" |
|
|
|
|
:visible="visible" |
|
|
|
|
:confirmLoading="confirmLoading" |
|
|
|
|
:maskClosable="false" |
|
|
|
|
:destroyOnClose="true" |
|
|
|
|
@ok="handleSubmit" |
|
|
|
|
@cancel="handleCancel" |
|
|
|
|
> |
|
|
|
|
<a-modal :title="title" :width="780" :visible="visible" :confirmLoading="confirmLoading" :maskClosable="false" :destroyOnClose="true" @ok="handleSubmit" @cancel="handleCancel"> |
|
|
|
|
<a-spin :spinning="confirmLoading"> |
|
|
|
|
<a-form :form="form"> |
|
|
|
|
<a-form-item label="预售名称" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
@ -16,19 +7,11 @@ |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="预售商品" :labelCol="labelCol" :wrapperCol="wrapperCol" required> |
|
|
|
|
<div style="width: 100%; overflow-x: auto;"> |
|
|
|
|
<SelectGoods |
|
|
|
|
:defaultList="selectGoodsList" |
|
|
|
|
:multiple="true" |
|
|
|
|
v-decorator="['goods_list', { rules: [{ required: true, message: '请选择预售商品' }] }]" |
|
|
|
|
/> |
|
|
|
|
<SelectGoods :defaultList="selectGoodsList" :multiple="true" v-decorator="['goods_list', { rules: [{ required: true, message: '请选择预售商品' }] }]" /> |
|
|
|
|
</div> |
|
|
|
|
</a-form-item> |
|
|
|
|
<a-form-item label="预售时间" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
|
<a-date-picker |
|
|
|
|
show-time |
|
|
|
|
format="YYYY-MM-DD HH:mm:ss" |
|
|
|
|
v-decorator="['p_time', { rules: [{ required: true, message: '请输入预售时间' }] }]" |
|
|
|
|
/> |
|
|
|
|
<a-date-picker show-time format="YYYY-MM-DD HH:mm:ss" v-decorator="['p_time', { rules: [{ required: true, message: '请输入预售时间' }] }]" /> |
|
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
@ -52,7 +35,7 @@ export default { |
|
|
|
|
SelectImage, |
|
|
|
|
SelectGoods |
|
|
|
|
}, |
|
|
|
|
data () { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
// 对话框标题 |
|
|
|
|
title: '编辑预售', |
|
|
|
@ -75,7 +58,7 @@ export default { |
|
|
|
|
methods: { |
|
|
|
|
|
|
|
|
|
// 显示对话框 |
|
|
|
|
edit (record) { |
|
|
|
|
edit(record) { |
|
|
|
|
// 显示窗口 |
|
|
|
|
this.visible = true |
|
|
|
|
// 当前记录 |
|
|
|
@ -88,7 +71,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 设置默认值 |
|
|
|
|
setFieldsValue () { |
|
|
|
|
setFieldsValue() { |
|
|
|
|
const { record, form: { setFieldsValue } } = this |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
setFieldsValue(pick(record, ['name', 'goods_list', 'p_time', 'status'])) |
|
|
|
@ -96,7 +79,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 确认按钮 |
|
|
|
|
handleSubmit (e) { |
|
|
|
|
handleSubmit(e) { |
|
|
|
|
e.preventDefault() |
|
|
|
|
// 表单验证 |
|
|
|
|
const { form: { validateFields } } = this |
|
|
|
@ -107,15 +90,18 @@ export default { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 关闭对话框事件 |
|
|
|
|
handleCancel () { |
|
|
|
|
handleCancel() { |
|
|
|
|
this.visible = false |
|
|
|
|
this.form.resetFields() |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
hasObject(arr) { |
|
|
|
|
return arr.some(item => typeof item === 'object' && item !== null); |
|
|
|
|
}, |
|
|
|
|
// 提交到后端api |
|
|
|
|
onFormSubmit (values) { |
|
|
|
|
onFormSubmit(values) { |
|
|
|
|
this.confirmLoading = true |
|
|
|
|
Api.edit({ id: this.record.id, form: { ...values, goods_list: values.goods_list.join(',') } }) |
|
|
|
|
let arrType=this.hasObject(values.goods_list) |
|
|
|
|
Api.edit({ id: this.record.id, form: { ...values, goods_list: arrType?values.goods_list.map(item => item.goods_id).join(","):values.goods_list.join(',') } }) |
|
|
|
|
.then(result => { |
|
|
|
|
// 显示成功 |
|
|
|
|
this.$message.success(result.message, 1.5) |
|
|
|
|