类型:datetimerange ,返回结果是一个数组。
查询前可以在前端,也可以在后端处理下数据。
我这里选择前端处理数据。
if (this.crud.query.controlStartTimeStr) {
this.crud.query.controlStartTime1 = new Date(this.crud.query.controlStartTimeStr[0])
this.crud.query.controlStartTime2 = new Date(this.crud.query.controlStartTimeStr[1])
} else {
this.crud.query.controlStartTime1 = ''
this.crud.query.controlStartTime2 = ''
}
注意:一定要置空!
2、typpe:datetime这种类型情况下,如果后台java是通过timeStamp对象来接受参数的,就不用改。
什时候java后端需要修改呢?
@JsonFormat(pattern=”yyyy-MM-dd HH:mm:ss”)
使用情况:结果数据从后台传到前台,前台没办法解析(多半是展示时不友好)需要做下操作。
2.0 、@DateTimeFormat@DateTimeFormat(pattern=”yyyy-MM-dd HH:mm:ss”)
可将前台的字符串日期转为java中的Date对象。注意字符串的格式要和pattern中的格式匹配上!
另外:js和java中都可以将 【中国标准时间】 转为时间戳,如下:
new Date(【中国标准时间】) ----》 时间戳
通过handleSelectionChange 可以获得选择的list。
handleSelectionChange(selection) {
this.controlList = selection
},
三、表单
1、校验
手动提交表单校验,不知道为什么我直接写 this.$refs[‘controlForm’] 会提示undefined, 所以这里的from 一定要当做参数传进来。
this.loading = true,是为了防止多次点击按钮提交的。
submit(form) {
this.loading = true
this.$refs[form].validate((valid) => {
if (valid) {
crudSqControlInfo.add(this.controlForm).then(res => {
this.$notify({
title: '提交成功',
type: 'success',
duration: 2500
})
this.loading = false
}).catch(e => {
this.$notify({
title: '操作失败',
type: 'error',
duration: 2500
})
this.loading = false
})
} else {
this.loading = false
}
return false
})
}



