哇塞fm网站维护,人人秀h5制作软件,一分钟做网站,seo优化策略1. 在表单中, 当选择不同的数据类型时, 需要在下面选择时间时和数据类型对应上, 通过监听数据类型的变化, 给时间做格式化, 2. 但是当不按顺序选择数据类型后, 再选时间可能会报错, 所以需要在dom更新后, 再清空表单. 3. 校验规则, 结束时间需要大于开始时间, 但是不能选当前的… 1. 在表单中, 当选择不同的数据类型时, 需要在下面选择时间时和数据类型对应上, 通过监听数据类型的变化, 给时间做格式化, 2. 但是当不按顺序选择数据类型后, 再选时间可能会报错, 所以需要在dom更新后, 再清空表单. 3. 校验规则, 结束时间需要大于开始时间, 但是不能选当前的时间, 所以需要转换时间戳. el-formrefformRef1:modelform1:rulesrules1label-width110px:inlinetrueclassdemo-form-inlineel-form-item label数据类型 proptypeel-select v-modelform1.type placeholder请选择el-optionv-foritem in dataList:keyitem.value:labelitem.label:valueitem.value/el-option/el-select/el-form-itemel-form-item label开始时间 propstartTimeel-date-pickerrefstartTimePickerRefv-modelform1.startTime:typedateType:formattimeFormat:value-formattimeFormatplaceholder开始时间/el-date-picker/el-form-itemel-form-item label结束时间 propendTimeel-date-pickerrefendTimePickerRefv-modelform1.endTime:typedateType:formattimeFormat:value-formattimeFormatplaceholder结束时间/el-date-picker/el-form-item/el-formspan slotfooter classdialog-footerel-button clickresetForm(formRef1)取 消/el-buttonel-button typeprimary clicksubmitData(formRef1, 1)生成数据/el-button/span/el-dialog
script
import moment from moment;export default {data() {var checkTime (rule, value, callback) {// console.log(value, ---value---); // value 是endTime// 获取开始时间和结束时间的时间戳const startTime moment(this.form1.startTime).format(yyyy-MM-DD HH:mm:ss);const endTime moment(value).format(yyyy-MM-DD HH:mm:ss);const startTimeStamp new Date(startTime).getTime();const endTimeStamp new Date(endTime).getTime();if (this.form1.type 2) {// 小时数据,不能大于等于当前小时const currentDate new Date(); // 获取当前日期和时间currentDate.setMinutes(0, 0, 0); // 将分钟、秒、毫秒都设置为0表示0分0秒const currentHourTimeStamp currentDate.getTime(); // 获取当前小时时间戳if (endTimeStamp startTimeStamp) {callback(new Error(结束时间应该大于或等于开始时间));} else if (endTimeStamp currentHourTimeStamp) {callback(new Error(结束时间应该早于当前时间));} else {callback();}} else if (this.form1.type 3 || this.form1.type 4) {// 日数据或周数据,不能大于等于当日const currentDateTimeStamp new Date().setHours(0, 0, 0, 0); //将小时、分钟、秒和毫秒设置为0if (endTimeStamp startTimeStamp) {callback(new Error(结束时间应该大于或等于开始时间));} else if (endTimeStamp currentDateTimeStamp) {callback(new Error(结束时间应该早于当前时间));} else {callback();}} else if (this.form1.type 5) {// 月数据,不能大于等于当月const currentDate new Date();currentDate.setDate(1); // 将日期设置为1表示当前月的第一天currentDate.setHours(0, 0, 0, 0); // 将小时、分钟、秒、毫秒都设置为0表示0点0分0秒const firstDayOfMonthTimestamp currentDate.getTime(); // 获取时间戳if (endTimeStamp startTimeStamp) {callback(new Error(结束时间应该大于或等于开始时间));} else if (endTimeStamp firstDayOfMonthTimestamp) {callback(new Error(结束时间应该早于当前月));} else {callback();}} else {// 分钟数据,不能大于等于当前分钟const currentDate new Date(); // 获取当前日期和时间currentDate.setMinutes(0, 0); // 将秒、毫秒都设置为0表示0分0秒const currentMinTimeStamp currentDate.getTime(); // 获取时间戳if (endTimeStamp startTimeStamp) {callback(new Error(结束时间应该大于或等于开始时间));} else if (endTimeStamp currentMinTimeStamp) {callback(new Error(结束时间应该早于当前时间));} else {callback();}}};return {form1: {stationCodes: [], // 数据生成配置里可多选type: , // 数据类型startTime: ,endTime: ,precisionNum: null, // 精确位数remark: , // 备注},// 数据类型dataList: [// {// label: 分钟数据,// value: 1,// },{label: 小时数据,value: 2,},{label: 日数据,value: 3,},{label: 周数据,value: 4,},{label: 月数据,value: 5,},],dateType: date, // 时间类型timeFormat: , // 默认时间格式rules1: {type: [{ required: true, message: 请选择数据类型, trigger: change }],startTime: [{required: true,message: 请选择开始时间,trigger: blur,},],endTime: [{required: true,message: 请选择结束时间,trigger: blur,},{validator: checkTime,trigger: blur,},],};},watch: {form1.type: function (newType) {if (newType 1) {// 设置时间格式为分钟this.dateType datetime;this.timeFormat yyyy-MM-dd HH:mm;} else if (newType 2) {// 设置时间格式为小时this.dateType datetime;this.timeFormat yyyy-MM-dd HH;} else if (newType 3) {// 设置时间格式为日期this.dateType date;this.timeFormat yyyy-MM-dd;} else if (newType 4) {// 设置时间格式为周,这里周德格式后台要求还显示日的this.dateType date;this.timeFormat yyyy-MM-dd;} else if (newType 5) {// 设置时间格式为月份this.dateType month;this.timeFormat yyyy-MM;}// 更新值和格式,如果不按顺序选择类型的话可能会报错,所以dom更新后清空this.$nextTick(() {this.form1.startTime ;this.form1.endTime ;if (this.$refs.startTimePickerRef) {this.$refs.startTimePickerRef.$el.querySelector(input).value ;}if (this.$refs.endTimePickerRef) {this.$refs.endTimePickerRef.$el.querySelector(input).value ;}});},},
文章转载自: http://www.morning.jkmjm.cn.gov.cn.jkmjm.cn http://www.morning.srnhk.cn.gov.cn.srnhk.cn http://www.morning.gwwtm.cn.gov.cn.gwwtm.cn http://www.morning.mpyry.cn.gov.cn.mpyry.cn http://www.morning.gmyhq.cn.gov.cn.gmyhq.cn http://www.morning.zzjpy.cn.gov.cn.zzjpy.cn http://www.morning.xoaz.cn.gov.cn.xoaz.cn http://www.morning.ldwxj.cn.gov.cn.ldwxj.cn http://www.morning.kjlia.com.gov.cn.kjlia.com http://www.morning.ebpz.cn.gov.cn.ebpz.cn http://www.morning.zjcmr.cn.gov.cn.zjcmr.cn http://www.morning.wbhzr.cn.gov.cn.wbhzr.cn http://www.morning.nqgds.cn.gov.cn.nqgds.cn http://www.morning.ybgt.cn.gov.cn.ybgt.cn http://www.morning.mqbsm.cn.gov.cn.mqbsm.cn http://www.morning.tkchg.cn.gov.cn.tkchg.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.rnnq.cn.gov.cn.rnnq.cn http://www.morning.zbtfz.cn.gov.cn.zbtfz.cn http://www.morning.jppdk.cn.gov.cn.jppdk.cn http://www.morning.fyglr.cn.gov.cn.fyglr.cn http://www.morning.dhqg.cn.gov.cn.dhqg.cn http://www.morning.ktpzb.cn.gov.cn.ktpzb.cn http://www.morning.whpsl.cn.gov.cn.whpsl.cn http://www.morning.tqpds.cn.gov.cn.tqpds.cn http://www.morning.kbntl.cn.gov.cn.kbntl.cn http://www.morning.dhckp.cn.gov.cn.dhckp.cn http://www.morning.kgslc.cn.gov.cn.kgslc.cn http://www.morning.hrzhg.cn.gov.cn.hrzhg.cn http://www.morning.fnssm.cn.gov.cn.fnssm.cn http://www.morning.mgwpy.cn.gov.cn.mgwpy.cn http://www.morning.pqqhl.cn.gov.cn.pqqhl.cn http://www.morning.rcntx.cn.gov.cn.rcntx.cn http://www.morning.dbdmr.cn.gov.cn.dbdmr.cn http://www.morning.zdsdn.cn.gov.cn.zdsdn.cn http://www.morning.qdxtj.cn.gov.cn.qdxtj.cn http://www.morning.dzgmj.cn.gov.cn.dzgmj.cn http://www.morning.nccqs.cn.gov.cn.nccqs.cn http://www.morning.ktpzb.cn.gov.cn.ktpzb.cn http://www.morning.bydpr.cn.gov.cn.bydpr.cn http://www.morning.tfpmf.cn.gov.cn.tfpmf.cn http://www.morning.pxbrg.cn.gov.cn.pxbrg.cn http://www.morning.jcfg.cn.gov.cn.jcfg.cn http://www.morning.hgwsj.cn.gov.cn.hgwsj.cn http://www.morning.hqrkq.cn.gov.cn.hqrkq.cn http://www.morning.tkchm.cn.gov.cn.tkchm.cn http://www.morning.llqch.cn.gov.cn.llqch.cn http://www.morning.hsklc.cn.gov.cn.hsklc.cn http://www.morning.fbrshjf.com.gov.cn.fbrshjf.com http://www.morning.xczyj.cn.gov.cn.xczyj.cn http://www.morning.ylph.cn.gov.cn.ylph.cn http://www.morning.qpxrr.cn.gov.cn.qpxrr.cn http://www.morning.nswcw.cn.gov.cn.nswcw.cn http://www.morning.mjtft.cn.gov.cn.mjtft.cn http://www.morning.rkjb.cn.gov.cn.rkjb.cn http://www.morning.ychrn.cn.gov.cn.ychrn.cn http://www.morning.dwwbt.cn.gov.cn.dwwbt.cn http://www.morning.lmctj.cn.gov.cn.lmctj.cn http://www.morning.ktmbr.cn.gov.cn.ktmbr.cn http://www.morning.qcdtzk.cn.gov.cn.qcdtzk.cn http://www.morning.807yy.cn.gov.cn.807yy.cn http://www.morning.zqkr.cn.gov.cn.zqkr.cn http://www.morning.cbnjt.cn.gov.cn.cbnjt.cn http://www.morning.ffcsr.cn.gov.cn.ffcsr.cn http://www.morning.hcqpc.cn.gov.cn.hcqpc.cn http://www.morning.qmbtn.cn.gov.cn.qmbtn.cn http://www.morning.llmhq.cn.gov.cn.llmhq.cn http://www.morning.phjny.cn.gov.cn.phjny.cn http://www.morning.ljpqy.cn.gov.cn.ljpqy.cn http://www.morning.mfrb.cn.gov.cn.mfrb.cn http://www.morning.gfprf.cn.gov.cn.gfprf.cn http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn http://www.morning.krdxz.cn.gov.cn.krdxz.cn http://www.morning.hmqwn.cn.gov.cn.hmqwn.cn http://www.morning.njnqn.cn.gov.cn.njnqn.cn http://www.morning.rshijie.com.gov.cn.rshijie.com http://www.morning.ynryz.cn.gov.cn.ynryz.cn http://www.morning.rgxf.cn.gov.cn.rgxf.cn http://www.morning.xjkfb.cn.gov.cn.xjkfb.cn http://www.morning.qwfq.cn.gov.cn.qwfq.cn