From d1f8366b677a898baa965d6bd4d047789f96576e Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Wed, 15 Jun 2022 16:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=8B=E5=87=8F=E9=87=91=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=20=E6=9C=89=E6=95=88=E6=97=B6=E9=97=B4=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/knockGold/index.jsx | 44 ++++++++++--------- src/components/knockGold/index.less | 14 ++++-- .../adddistributorinfo.less | 31 +++++++------ .../order/orderaddform/orderaddform.less | 17 ++++--- src/utils.js | 27 ++++++++++++ 5 files changed, 88 insertions(+), 45 deletions(-) diff --git a/src/components/knockGold/index.jsx b/src/components/knockGold/index.jsx index 20d2a381..50e35fcc 100644 --- a/src/components/knockGold/index.jsx +++ b/src/components/knockGold/index.jsx @@ -6,7 +6,7 @@ import Form from '@/components/form/main' import FormItem from '@/components/form-item/main' import rules from './rules' import moment from 'moment' -import { deWeightThree } from '@/utils' +import { deWeightThree, timeDiff } from '@/utils' import { isSameDay } from 'date-fns' import Bus from '@/assets/eventBus.js' import { @@ -31,8 +31,7 @@ import AddNewDialog from './Dialog' import MobileComponent from './mobileCmponent' const getTimeList = [ { key: '0', text: '立即生效' }, - { key: '1', text: '次日生效' }, - { key: '2', text: '自定义时间' } + { key: '1', text: '次日生效' } ] const cardTypeList = [ { key: '1', text: '借记卡' }, @@ -149,11 +148,9 @@ export default class addKnockGold extends Component { if (this.props.data.time_limit.use_time.effect_day) { model.effect_date_type = - Number(this.props.data.time_limit.use_time.effect_day) < 2 - ? getTimeList[ - Number(this.props.data.time_limit.use_time.effect_day) - ] - : getTimeList[2] + getTimeList[ + Number(this.props.data.time_limit.use_time.effect_date_type) + ] } else { model.effect_date_type = '' } @@ -420,7 +417,8 @@ export default class addKnockGold extends Component { start_time: this.state.model.fixed_time[0], end_time: this.state.model.fixed_time[1] }, - effect_day: this.state.model.effect_date + effect_day: this.state.model.effect_date, + effect_date_type: this.state.model.effect_date_type.key } } } @@ -454,6 +452,18 @@ export default class addKnockGold extends Component { } } + const TimeDiffer = timeDiff( + this.state.model.entry_time[0], + this.state.model.entry_time[1] + ) + if (TimeDiffer < Number(this.state.model.effect_date)) { + Notify.error( + `有限期不允许大于生效时间段 + 注:当前有效期最大时间为 ${TimeDiffer} 天` + ) + return false + } + if ( this.state.model.usable_time === 'fiexd' && this.setTime(this.state.model.fixed_time) @@ -941,18 +951,15 @@ export default class addKnockGold extends Component { placeholder='选择一项' onChange={(value) => { this.onHandleChange(value, 'effect_date_type') - this.onHandleChange(value?.key, 'effect_date') - if (value?.key !== '2') { - this.onHandleChange(value?.key, 'effect_date') - } else { - this.onHandleChange('', 'effect_date') - } }} value={this.state.model.effect_date_type} className='select-basic' disabled={this.props?.data?.id ? true : false} + width='195px' + popupWidth='195px' /> + 有效期 { this.onHandleChange(value, 'effect_date') @@ -960,12 +967,7 @@ export default class addKnockGold extends Component { onClearItem={() => { this.onHandleChange('', 'effect_date') }} - disabled={ - this.props?.data?.id || - this.state.model?.effect_date_type?.key !== '2' - ? true - : false - } + disabled={this.props?.data?.id ? true : false} value={this.state.model.effect_date} placeholder={'请输入'} labelWidth={'0px'} diff --git a/src/components/knockGold/index.less b/src/components/knockGold/index.less index 33d030ef..934c56f5 100644 --- a/src/components/knockGold/index.less +++ b/src/components/knockGold/index.less @@ -189,11 +189,15 @@ margin-top: 20px; } - .boxTime:first-child { - .iptfillself { - margin-left: 20px; + .effect_dates { + margin: 0 10px 0 15px; + display: inline-block; + } + } - } + .zent-select-v2-visible { + .zent-select-v2-popup { + width: 195px !important; } } } @@ -291,6 +295,8 @@ padding: 0; } } + + } .dialog_p { diff --git a/src/pages/distributor/adddistributorinfo/adddistributorinfo.less b/src/pages/distributor/adddistributorinfo/adddistributorinfo.less index 6e35fe09..4c168dcb 100644 --- a/src/pages/distributor/adddistributorinfo/adddistributorinfo.less +++ b/src/pages/distributor/adddistributorinfo/adddistributorinfo.less @@ -1,25 +1,30 @@ .zent-form-horizontal[data-zv="9.11.0"] .zent-form-label { - flex-basis: 118px!important; - justify-content: flex-start!important; + flex-basis: 118px !important; + justify-content: flex-start !important; } -.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content{ + +.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content { margin-left: 0; } + .adddistributor .iptfillself .label { - margin-right:66px; + margin-right: 66px; } - .zent-select-v2-popup{ - width: 250px !important; -} -.zent-btn-info[data-zv="9.11.0"]{ + +// .zent-select-v2-popup{ +// width: 250px !important; +// } +.zent-btn-info[data-zv="9.11.0"] { width: 120px; - color: #296bef!important; - border: none!important; + color: #296bef !important; + border: none !important; } -.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"]{ - margin-top: -180px; + +.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"] { + margin-top: -180px; } -.tip-reseller{ + +.tip-reseller { color: red; font-size: 12px; } \ No newline at end of file diff --git a/src/pages/order/orderaddform/orderaddform.less b/src/pages/order/orderaddform/orderaddform.less index 1c75c7cc..af84f798 100644 --- a/src/pages/order/orderaddform/orderaddform.less +++ b/src/pages/order/orderaddform/orderaddform.less @@ -1,13 +1,16 @@ .zent-form-horizontal[data-zv="9.11.0"] .zent-form-label { - flex-basis: 118px!important; - justify-content: flex-start!important; + flex-basis: 118px !important; + justify-content: flex-start !important; } -.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content{ + +.zent-form-horizontal[data-zv="9.11.0"] .zent-form-control-content { margin-left: 0; } + .adddistributor .iptfillself .label { - margin-right:66px; + margin-right: 66px; } - .zent-select-v2-popup{ - width: 250px !important; -} \ No newline at end of file + +// .zent-select-v2-popup{ +// width: 250px !important; +// } \ No newline at end of file diff --git a/src/utils.js b/src/utils.js index e3b846b5..1dca58bb 100644 --- a/src/utils.js +++ b/src/utils.js @@ -40,3 +40,30 @@ export function uuid(len, radix) { return uuid.join('') } + +//计算两个时间差 返回天 +export function timeDiff(begin_time, end_time) { + //年月日时分秒转换为时间戳 + let beginTime = new Date(begin_time).getTime() / 1000 + let endTime = new Date(end_time).getTime() / 1000 + var starttime = '' + var endtime = '' + if (beginTime < endTime) { + starttime = beginTime + endtime = endTime + } else { + starttime = endTime + endtime = beginTime + } + //计算天数 + var timediff = endtime - starttime + var days = parseInt(timediff / 86400) + //计算小时数 + var remain = timediff % 86400 + var hours = parseInt(remain / 3600) + //计算分钟数 + var remain = remain % 3600 + var mins = parseInt(remain / 60) + var res = Number((days + hours / 24).toFixed(1)) + return res +}