|
|
@ -1,45 +1,28 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<a-modal |
|
|
|
<a-modal :title="title" :width="780" :visible="visible" :confirmLoading="confirmLoading" :maskClosable="false" :destroyOnClose="true" @ok="handleSubmit" @cancel="handleCancel"> |
|
|
|
:title="title" |
|
|
|
<a-spin :spinning="confirmLoading"> |
|
|
|
:width="780" |
|
|
|
<a-form :form="form"> |
|
|
|
:visible="visible" |
|
|
|
<a-form-item label="预售名称" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
:confirmLoading="confirmLoading" |
|
|
|
<a-input v-decorator="['name', { rules: [{ required: true, message: '请输入预售名称' }] }]" placeholder="请输入预售名称" /> |
|
|
|
:maskClosable="false" |
|
|
|
</a-form-item> |
|
|
|
:destroyOnClose="true" |
|
|
|
<a-form-item label="预售商品" :labelCol="labelCol" :wrapperCol="wrapperCol" required> |
|
|
|
@ok="handleSubmit" |
|
|
|
<div style="width: 100%; overflow-x: auto;"> |
|
|
|
@cancel="handleCancel" |
|
|
|
<SelectGoods :defaultList="selectGoodsList" :multiple="true" v-decorator="['goods_list', { rules: [{ required: true, message: '请选择预售商品' }] }]" /> |
|
|
|
> |
|
|
|
</div> |
|
|
|
<a-spin :spinning="confirmLoading"> |
|
|
|
</a-form-item> |
|
|
|
<a-form :form="form"> |
|
|
|
<a-form-item label="预售时间" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
<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-input v-decorator="['name', { rules: [{ required: true, message: '请输入预售名称' }] }]" placeholder="请输入预售名称" /> |
|
|
|
</a-form-item> |
|
|
|
</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: '请选择预售商品' }] }]" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</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-form-item> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
<a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]"> |
|
|
|
<a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]"> |
|
|
|
<a-radio :value="1">开启</a-radio> |
|
|
|
<a-radio :value="1">开启</a-radio> |
|
|
|
<a-radio :value="0">关闭</a-radio> |
|
|
|
<a-radio :value="0">关闭</a-radio> |
|
|
|
</a-radio-group> |
|
|
|
</a-radio-group> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
</a-form> |
|
|
|
</a-form> |
|
|
|
</a-spin> |
|
|
|
</a-spin> |
|
|
|
</a-modal> |
|
|
|
</a-modal> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
@ -48,85 +31,88 @@ import * as Api from '@/api/market/presale' |
|
|
|
import { SelectImage, SelectGoods } from '@/components' |
|
|
|
import { SelectImage, SelectGoods } from '@/components' |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
components: { |
|
|
|
components: { |
|
|
|
SelectImage, |
|
|
|
SelectImage, |
|
|
|
SelectGoods |
|
|
|
SelectGoods |
|
|
|
}, |
|
|
|
}, |
|
|
|
data () { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
// 对话框标题 |
|
|
|
// 对话框标题 |
|
|
|
title: '编辑预售', |
|
|
|
title: '编辑预售', |
|
|
|
// 标签布局属性 |
|
|
|
// 标签布局属性 |
|
|
|
labelCol: { span: 3 }, |
|
|
|
labelCol: { span: 3 }, |
|
|
|
// 输入框布局属性 |
|
|
|
// 输入框布局属性 |
|
|
|
wrapperCol: { span: 19 }, |
|
|
|
wrapperCol: { span: 19 }, |
|
|
|
// modal(对话框)是否可见 |
|
|
|
// modal(对话框)是否可见 |
|
|
|
visible: false, |
|
|
|
visible: false, |
|
|
|
// modal(对话框)确定按钮 loading |
|
|
|
// modal(对话框)确定按钮 loading |
|
|
|
confirmLoading: false, |
|
|
|
confirmLoading: false, |
|
|
|
// 当前表单元素 |
|
|
|
// 当前表单元素 |
|
|
|
form: this.$form.createForm(this), |
|
|
|
form: this.$form.createForm(this), |
|
|
|
// 当前记录 |
|
|
|
// 当前记录 |
|
|
|
record: {}, |
|
|
|
record: {}, |
|
|
|
// 关联商品列表 |
|
|
|
// 关联商品列表 |
|
|
|
selectGoodsList: [] |
|
|
|
selectGoodsList: [] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
|
|
|
|
|
|
|
|
// 显示对话框 |
|
|
|
// 显示对话框 |
|
|
|
edit (record) { |
|
|
|
edit(record) { |
|
|
|
// 显示窗口 |
|
|
|
// 显示窗口 |
|
|
|
this.visible = true |
|
|
|
this.visible = true |
|
|
|
// 当前记录 |
|
|
|
// 当前记录 |
|
|
|
this.record = record |
|
|
|
this.record = record |
|
|
|
|
|
|
|
|
|
|
|
this.selectGoodsList = record.goods_list || [] |
|
|
|
this.selectGoodsList = record.goods_list || [] |
|
|
|
|
|
|
|
|
|
|
|
// 设置默认值 |
|
|
|
// 设置默认值 |
|
|
|
this.setFieldsValue() |
|
|
|
this.setFieldsValue() |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 设置默认值 |
|
|
|
// 设置默认值 |
|
|
|
setFieldsValue () { |
|
|
|
setFieldsValue() { |
|
|
|
const { record, form: { setFieldsValue } } = this |
|
|
|
const { record, form: { setFieldsValue } } = this |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
setFieldsValue(pick(record, ['name', 'goods_list', 'p_time', 'status'])) |
|
|
|
setFieldsValue(pick(record, ['name', 'goods_list', 'p_time', 'status'])) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 确认按钮 |
|
|
|
// 确认按钮 |
|
|
|
handleSubmit (e) { |
|
|
|
handleSubmit(e) { |
|
|
|
e.preventDefault() |
|
|
|
e.preventDefault() |
|
|
|
// 表单验证 |
|
|
|
// 表单验证 |
|
|
|
const { form: { validateFields } } = this |
|
|
|
const { form: { validateFields } } = this |
|
|
|
validateFields((errors, values) => { |
|
|
|
validateFields((errors, values) => { |
|
|
|
// 提交到后端api |
|
|
|
// 提交到后端api |
|
|
|
!errors && this.onFormSubmit(values) |
|
|
|
!errors && this.onFormSubmit(values) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 关闭对话框事件 |
|
|
|
// 关闭对话框事件 |
|
|
|
handleCancel () { |
|
|
|
handleCancel() { |
|
|
|
this.visible = false |
|
|
|
this.visible = false |
|
|
|
this.form.resetFields() |
|
|
|
this.form.resetFields() |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
hasObject(arr) { |
|
|
|
// 提交到后端api |
|
|
|
return arr.some(item => typeof item === 'object' && item !== null); |
|
|
|
onFormSubmit (values) { |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交到后端api |
|
|
|
|
|
|
|
onFormSubmit(values) { |
|
|
|
this.confirmLoading = true |
|
|
|
this.confirmLoading = true |
|
|
|
Api.edit({ id: this.record.id, form: { ...values, goods_list: values.goods_list.join(',') } }) |
|
|
|
let arrType=this.hasObject(values.goods_list) |
|
|
|
.then(result => { |
|
|
|
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) |
|
|
|
// 显示成功 |
|
|
|
// 关闭对话框事件 |
|
|
|
this.$message.success(result.message, 1.5) |
|
|
|
this.handleCancel() |
|
|
|
// 关闭对话框事件 |
|
|
|
// 通知父端组件提交完成了 |
|
|
|
this.handleCancel() |
|
|
|
this.$emit('handleSubmit', values) |
|
|
|
// 通知父端组件提交完成了 |
|
|
|
}) |
|
|
|
this.$emit('handleSubmit', values) |
|
|
|
.finally(() => this.confirmLoading = false) |
|
|
|
}) |
|
|
|
} |
|
|
|
.finally(() => this.confirmLoading = false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|