123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <a-modal
- centered
- class="editActiveEndTime-basicInfo-modal"
- :footer="null"
- :maskClosable="false"
- title="时间变更"
- v-model="isShow"
- @cancel="isShow=false"
- :width="500">
- <a-spin :spinning="spinning" tip="Loading...">
- <div style="text-align: center;margin-bottom: 20px;font-weight: bold;">确定要变更{{ form.name }}的促销时间吗?</div>
- <a-form-model
- id="editActiveEndTime-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol" >
- <a-form-model-item label="原结束日期" prop="time">
- <span>{{ form.timeEnd }}</span>
- </a-form-model-item>
- <a-form-model-item label="变更后结束日期" prop="newTimeEnd">
- <a-date-picker style="width:90%" v-model="form.newTimeEnd" @change="onChange" :format="dateFormat" :disabled-date="disabledDate"/>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button id="editActiveEndTime-basicInfo-modal-back" @click="isShow = false">取消</a-button>
- <a-button style="margin-left: 15px;" type="primary" id="editActiveEndTime-modal-save" @click="handleSave">确定</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import moment from 'moment'
- import { promotionDateModify } from '@/api/promotion'
- export default {
- name: 'EditActiveEndTimeModal',
- mixins: [commonMixin],
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- } },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- spinning: false,
- formItemLayout: {
- labelCol: { span: 6 },
- wrapperCol: { span: 16 }
- },
- form: {
- name: '',
- timeStart: '',
- timeEnd: '',
- newTimeEnd: undefined
- },
- dateFormat: 'YYYY-MM-DD',
- rules: {
- newTimeEnd: [
- { required: true, message: '请选择变更的结束时间', trigger: 'change' }
- ]
- }
- }
- },
- methods: {
- onChange (date, dateString) {
- if (date) {
- this.form.newTimeEnd = dateString + ' 23:59:59'
- } else {
- this.form.newTimeEnd = undefined
- }
- },
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- promotionDateModify({ promotionSn: _this.form.sn, promotionDateStart: _this.form.timeStart, promotionDateEnd: _this.form.newTimeEnd }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- setTimeout(() => {
- _this.isShow = false
- _this.$emit('ok', res.data)
- _this.spinning = false
- }, 1000)
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- },
- // 获取显示内容
- setData (obj) {
- this.form = { ...this.form, ...obj }
- },
- // 不可选日期
- disabledDate (date, dateStrings) {
- return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.form = {
- name: '',
- timeStart: '',
- timeEnd: '',
- newTimeEnd: undefined
- }
- this.$refs.ruleForm.resetFields()
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .editActiveEndTime-basicInfo-modal{
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|