*查询当天时间的数据,注意⚠️时间2023-04-28 00:00:00-2023-04-28 23:59:59
**api :日期格式
使用format指定输入框的格式;使用value-format指定绑定值的格式。
**
<el-date-picker
v-model="valueTime"
type="daterange"
range-separator="-"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
start-placeholder="开始时间"
end-placeholder="结束时间"
>
</el-date-picker>
getData() {
let sqlDict = `select * from dict where 1=1`;
let sqlModel1;
if (this.valueTime.length > 0 && !this.unicode_name) {
this.starTime = this.valueTime[0] + ' 00:00:00';
this.endTime = this.valueTime[1] + ' 23:59:59';
sqlModel1 = `select * from cacu_center_record where 1=1 and create_time >= '${this.starTime}' and create_time <= '${this.endTime}' and model_id='${this.logId}'`;
} else if (this.unicode_name && this.valueTime.length == 0) {
sqlModel1 = `select * from cacu_center_record where 1=1 and crew_name='${this.unicode_name}' and model_id='${this.logId}'`;
} else if (this.unicode_name && this.valueTime.length > 0) {
this.starTime = this.valueTime[0] + ' 00:00:00';
this.endTime = this.valueTime[1] + ' 23:59:59';
sqlModel1 = `select * from cacu_center_record where 1=1 and create_time >= '${this.starTime}' and create_time <= '${this.endTime}' and crew_name='${this.unicode_name}' and model_id='${this.logId}'`;
} else {
sqlModel1 = `select * from cacu_center_record where 1=1 and model_id='${this.logId}'`;
}
req(sqlModel1).then(res => {
this.tableData = res.rows; //表格数据
this.tableData.sort(function(a, b) {
return Date.parse(b.period_time) - Date.parse(a.period_time); // 时间倒序
});
this.total = res.rowCount;
this.tableData = this.tableData;
});
},