预售列表

master
fanfan 5 months ago
parent af186fb16e
commit bdd295f3d4
  1. 210
      src/views/market/presale/modules/EditForm.vue
  2. 2
      src/views/user/order/Index.vue

@ -1,45 +1,28 @@
<template>
<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">
<a-input v-decorator="['name', { rules: [{ required: true, message: '请输入预售名称' }] }]" placeholder="请输入预售名称" />
</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-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">
<a-input v-decorator="['name', { rules: [{ required: true, message: '请输入预售名称' }] }]" placeholder="请输入预售名称" />
</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-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]">
<a-radio :value="1">开启</a-radio>
<a-radio :value="0">关闭</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
<a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-radio-group v-decorator="['status', { initialValue: 1, rules: [{ required: true }] }]">
<a-radio :value="1">开启</a-radio>
<a-radio :value="0">关闭</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
@ -48,85 +31,88 @@ import * as Api from '@/api/market/presale'
import { SelectImage, SelectGoods } from '@/components'
export default {
components: {
SelectImage,
SelectGoods
},
data () {
return {
//
title: '编辑预售',
//
labelCol: { span: 3 },
//
wrapperCol: { span: 19 },
// modal()
visible: false,
// modal() loading
confirmLoading: false,
//
form: this.$form.createForm(this),
//
record: {},
//
selectGoodsList: []
}
},
methods: {
components: {
SelectImage,
SelectGoods
},
data() {
return {
//
title: '编辑预售',
//
labelCol: { span: 3 },
//
wrapperCol: { span: 19 },
// modal()
visible: false,
// modal() loading
confirmLoading: false,
//
form: this.$form.createForm(this),
//
record: {},
//
selectGoodsList: []
}
},
methods: {
//
edit (record) {
//
this.visible = true
//
this.record = record
//
edit(record) {
//
this.visible = true
//
this.record = record
this.selectGoodsList = record.goods_list || []
this.selectGoodsList = record.goods_list || []
//
this.setFieldsValue()
},
//
this.setFieldsValue()
},
//
setFieldsValue () {
const { record, form: { setFieldsValue } } = this
this.$nextTick(() => {
setFieldsValue(pick(record, ['name', 'goods_list', 'p_time', 'status']))
})
},
//
setFieldsValue() {
const { record, form: { setFieldsValue } } = this
this.$nextTick(() => {
setFieldsValue(pick(record, ['name', 'goods_list', 'p_time', 'status']))
})
},
//
handleSubmit (e) {
e.preventDefault()
//
const { form: { validateFields } } = this
validateFields((errors, values) => {
// api
!errors && this.onFormSubmit(values)
})
},
//
handleSubmit(e) {
e.preventDefault()
//
const { form: { validateFields } } = this
validateFields((errors, values) => {
// api
!errors && this.onFormSubmit(values)
})
},
//
handleCancel () {
this.visible = false
this.form.resetFields()
},
// api
onFormSubmit (values) {
//
handleCancel() {
this.visible = false
this.form.resetFields()
},
hasObject(arr) {
return arr.some(item => typeof item === 'object' && item !== null);
},
// api
onFormSubmit(values) {
this.confirmLoading = true
Api.edit({ id: this.record.id, form: { ...values, goods_list: values.goods_list.join(',') } })
.then(result => {
//
this.$message.success(result.message, 1.5)
//
this.handleCancel()
//
this.$emit('handleSubmit', values)
})
.finally(() => this.confirmLoading = false)
}
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)
//
this.handleCancel()
//
this.$emit('handleSubmit', values)
})
.finally(() => this.confirmLoading = false)
}
}
}
}
</script>

@ -24,7 +24,7 @@
</a-form-item>
<a-form-item label="支付方式">
<a-select v-decorator="['pay_method', { initialValue: 0 }]">
<a-select-option :value="''">全部</a-select-option>
<a-select-option :value="0">全部</a-select-option>
<a-select-option :value="'wechat'">会员</a-select-option>
<a-select-option :value="'balance'">分销商 </a-select-option>
</a-select>

Loading…
Cancel
Save