<el-form
v-if="form"
ref="form"
:model="form"
:rules="alterType === 'read' ? {} : formRules"
label-width="150px"></el-form>
computed: {
formRules() {
if (this.$terminal(['institution'])) {
return this.formRules2
} else if (this.$terminal(['company'])) {
return this.alterType == 'add' ? this.addFormRules1 : this.formRules1
} else {
console.warn('terminal错误')
return {}
}
},
//未来月份禁用
<el-form-item label="所属月份">
<el-date-picker
v-model="searchForm.comment_month"
:picker-options="pickerOptions"
type="month"
format="yyyy-MM "
value-format="yyyy-MM"
placeholder="选择月份">
</el-date-picker>
</el-form-item>
data() {
return {
pickerOptions: {
disabledDate(time) {
// 获取时间选择器的月份信息
const timeyear = time.getFullYear(); // 获取时间选择器的年份
let timemonth = time.getMonth() + 1; // 获取时间选择器的月份
if (timemonth >= 1 && timemonth <= 9) {
timemonth = "0" + timemonth;
}
const elTimeData = timeyear.toString() + timemonth.toString();
var date = new Date()
var month = parseInt(date.getMonth() + 1)
if (month >= 1 && month <= 9) {
month = '0' + month
}
//大于指定时间都不可选
return elTimeData * 1 > parseInt(date.getFullYear().toString() + month);
},
},
}
}
mounted() {
var date = new Date()
var month = parseInt(date.getMonth() + 1)
if (month >= 1 && month <= 9) {
month = '0' + month
}
this.formInline.comment_month=date.getFullYear() + "-" +month
this.getList()
},