Browse Source

限制今天日期之前的日期不可选

zhangdan 4 years ago
parent
commit
5691812684
1 changed files with 31 additions and 2 deletions
  1. 31 2
      src/views/appSetting/addEditionSetting.vue

+ 31 - 2
src/views/appSetting/addEditionSetting.vue

@@ -29,15 +29,23 @@
               :wrapper-col="formItemLayout.wrapperCol"
               :wrapper-col="formItemLayout.wrapperCol"
               label="请选择更新时间"
               label="请选择更新时间"
             >
             >
-              <a-date-picker
+			<a-date-picker
+			  show-time
+			  id="addEditionSetting-publicDate"
+			  placeholder="年/月/日 时/分/秒"
+			  :disabled-date="disabledDate"
+			  v-decorator="['formData.publicDate', { initialValue: formData.publicDate, rules: [{ required: true, message: '请选择更新时间!' }] }]"
+			   />
+             <!-- <a-date-picker
                 show-time
                 show-time
 				id="addEditionSetting-publicDate"
 				id="addEditionSetting-publicDate"
                 placeholder="年/月/日 时/分/秒"
                 placeholder="年/月/日 时/分/秒"
+				:disabled-date="disabledDate"
                 v-decorator="[
                 v-decorator="[
                   'formData.publicDate',
                   'formData.publicDate',
                   { initialValue: formData.publicDate,
                   { initialValue: formData.publicDate,
                     rules: [{required: true, message: '请选择更新时间!' }] },
                     rules: [{required: true, message: '请选择更新时间!' }] },
-                ]" />
+                ]" /> -->
             </a-form-item>
             </a-form-item>
           </a-col>
           </a-col>
           <a-col :span="24">
           <a-col :span="24">
@@ -180,6 +188,27 @@ export default {
     }
     }
   },
   },
   methods: {
   methods: {
+		moment,
+		// 禁止当前之前的日期选择
+		range(start, end) {
+		      const result = [];
+		      for (let i = start; i < end; i++) {
+		        result.push(i);
+		      }
+		      return result;
+		    },
+
+		    disabledDate(current) {
+		      // Can not select days before today and today
+		      return current && current <moment().subtract(1, "days");
+		    },
+		    // disabledDateTime () {
+		    //   return {
+		    //     disabledHours: () => this.range(0, moment().hour()),
+		    //     disabledMinutes: () => this.range(0, moment().minute()),
+		    //     disabledSeconds: () => this.range(0, moment().second())
+		    //   }
+		    // },
     // 保存
     // 保存
     handleSubmit (e) {
     handleSubmit (e) {
       e.preventDefault()
       e.preventDefault()