| | |
| | | |
| | | pickerOptions: { |
| | | shortcuts: [{ |
| | | text: '近1天', |
| | | text: '今天', |
| | | onClick (picker) { |
| | | const end = dayjs().subtract(1, 'hour') |
| | | const start = new Date(dayjs().startOf('day')) |
| | | picker.$emit('pick', [new Date(start), new Date(end)]) |
| | | } |
| | | }, { |
| | | text: '近1天', |
| | | onClick (picker) { |
| | | const end = dayjs() |
| | | const start = dayjs().subtract(1, 'day') |
| | | picker.$emit('pick', [new Date(start), new Date(end)]) |
| | | } |
| | | }, { |
| | | text: '近3天', |
| | | onClick (picker) { |
| | | const end = dayjs().subtract(1, 'hour') |
| | | const end = dayjs() |
| | | const start = dayjs().subtract(3, 'day') |
| | | picker.$emit('pick', [new Date(start), new Date(end)]) |
| | | } |
| | | }, { |
| | | text: '近5天', |
| | | onClick (picker) { |
| | | const end = dayjs().subtract(1, 'hour') |
| | | const end = dayjs() |
| | | const start = dayjs().subtract(5, 'day') |
| | | picker.$emit('pick', [new Date(start), new Date(end)]) |
| | | } |
| | | }, { |
| | | text: '近7天', |
| | | onClick (picker) { |
| | | const end = dayjs().subtract(1, 'hour') |
| | | const end = dayjs() |
| | | const start = dayjs().subtract(7, 'day') |
| | | picker.$emit('pick', [new Date(start), new Date(end)]) |
| | | } |
| | |
| | | }, |
| | | mounted () { |
| | | this.title = `${this.macDate.name}详情` |
| | | this.startTime = this.macDate.startTime |
| | | this.endTime = this.macDate.endTime |
| | | this.startTime = dayjs(this.macDate.startTime).format('YYYY-MM-DD HH:mm') |
| | | this.endTime = dayjs(this.macDate.endTime).format('YYYY-MM-DD HH:mm') |
| | | this.$set(this.selectTime, 0, new Date(this.macDate.startTime)) |
| | | this.$set(this.selectTime, 1, new Date(this.macDate.endTime)) |
| | | this.getLineData() |
| | |
| | | this.startTime = !this.selectTime ? '' : dayjs(this.selectTime[0]).format('YYYY-MM-DD HH:mm') |
| | | this.endTime = !this.selectTime ? '' : dayjs(this.selectTime[1]).format('YYYY-MM-DD HH:mm') |
| | | this.getMacDetail() |
| | | if (this.type !== 'minute') { |
| | | this.getLineData() |
| | | if (this.type === 'minute') { |
| | | this.lineType = 'hour' |
| | | this.getLineData(this.startTime, this.endTime, 'hour') |
| | | } else { |
| | | this.lineType = this.type |
| | | this.getLineData(this.startTime, this.endTime, this.type) |
| | | } |
| | | }, |
| | | initPieChart (pieChartData) { |
| | |
| | | type="datetimerange" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | :clearable="false" |
| | | end-placeholder="结束日期" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | :default-date="[selectTime[0], selectTime[1]]" |
| | | :picker-options="pickerOptions" |
| | | @change="changeDay" |
| | | @change="changeDay()" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="小时状态:"> |
| | |
| | | organizationId: '', |
| | | hourState: '', |
| | | state: '', |
| | | startTime: dayjs().startOf('day').format('YYYY-MM-DD HH:mm'), |
| | | endTime: dayjs().subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | startTime: '', |
| | | endTime: '' |
| | | }, |
| | | time: '今天', |
| | | selectTime: '', |
| | | selectTime: [], |
| | | macDate: {}, |
| | | macOnlineData: {}, |
| | | orgData: [], |
| | |
| | | time (newValue, oldValue) { |
| | | let now = dayjs() // 获取当前时间 |
| | | if (newValue === '近1天') { |
| | | this.selectTime = [] |
| | | this.$set(this.selectTime, 0, new Date(now.subtract(1, 'day').format('YYYY-MM-DD HH:mm'))) |
| | | this.$set(this.selectTime, 1, new Date(now.format('YYYY-MM-DD HH:mm'))) |
| | | this.formInline.endTime = now.subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | this.formInline.startTime = now.subtract(1, 'day').format('YYYY-MM-DD HH:mm') // 获取昨天的零点 |
| | | } else if (newValue === '近3天') { |
| | | this.selectTime = [] |
| | | this.$set(this.selectTime, 0, new Date(now.subtract(3, 'day').format('YYYY-MM-DD HH:mm'))) |
| | | this.$set(this.selectTime, 1, new Date(now.format('YYYY-MM-DD HH:mm'))) |
| | | this.formInline.endTime = now.subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | this.formInline.startTime = now.subtract(3, 'day').format('YYYY-MM-DD HH:mm') // 获取前天的零点 |
| | | } else if (newValue === '近5天') { |
| | | this.selectTime = [] |
| | | this.$set(this.selectTime, 0, new Date(now.subtract(5, 'day').format('YYYY-MM-DD HH:mm'))) |
| | | this.$set(this.selectTime, 1, new Date(now.format('YYYY-MM-DD HH:mm'))) |
| | | this.formInline.endTime = now.subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | this.formInline.startTime = now.subtract(5, 'day').format('YYYY-MM-DD HH:mm') // 获取前天的零点 |
| | | } else if (newValue === '近7天') { |
| | | this.selectTime = [] |
| | | this.$set(this.selectTime, 0, new Date(now.subtract(7, 'day').format('YYYY-MM-DD HH:mm'))) |
| | | this.$set(this.selectTime, 1, new Date(now.format('YYYY-MM-DD HH:mm'))) |
| | | this.formInline.endTime = now.subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | this.formInline.startTime = now.subtract(7, 'day').format('YYYY-MM-DD HH:mm') // 获取前天的零点 |
| | | } else if (newValue === '今天') { |
| | | this.selectTime = [] |
| | | this.$set(this.selectTime, 0, new Date(dayjs().startOf('day').format('YYYY-MM-DD HH:mm'))) |
| | | this.$set(this.selectTime, 1, new Date(now.format('YYYY-MM-DD HH:mm'))) |
| | | this.formInline.endTime = now.subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | console.log('000', dayjs().startOf('day').format('YYYY-MM-DD HH:mm')) |
| | | this.formInline.startTime = dayjs().startOf('day').format('YYYY-MM-DD HH:mm') |
| | | } |
| | | } |
| | | }, |
| | | mounted () { |
| | | this.$set(this.selectTime, 0, new Date(dayjs().startOf('day').format('YYYY-MM-DD HH:mm'))) |
| | | this.$set(this.selectTime, 1, new Date(dayjs().format('YYYY-MM-DD HH:mm'))) |
| | | }, |
| | | created () { |
| | | this.getOrganizationId() |
| | | }, |
| | | methods: { |
| | | changeDay () { |
| | | console.log('this.selectTime', this.selectTime) |
| | | if (this.selectTime !== null) { |
| | | console.log(this.selectTime) |
| | | this.formInline.startTime = this.selectTime[0] |
| | | this.formInline.endTime = this.selectTime[1] |
| | | |
| | | if (dayjs(this.selectTime[1]).format('YYYY-MM-DD HH') === dayjs().format('YYYY-MM-DD HH')) { |
| | | this.formInline.endTime = dayjs(this.selectTime[1]).subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | } else { |
| | | this.formInline.endTime = dayjs(this.selectTime[1]).startOf('day').format('YYYY-MM-DD HH:mm') |
| | | } |
| | | } |
| | | console.log('this.formInline12', this.formInline) |
| | | this.time = '' |
| | | }, |
| | | handleDetail (row) { |
| | | console.log(row) |
| | | this.handleShow = true |
| | | this.macDate = _.cloneDeep(row) |
| | | this.macDate.startTime = this.formInline.startTime |
| | | this.macDate.endTime = this.formInline.endTime |
| | | this.macDate.startTime = this.selectTime[0] |
| | | this.macDate.endTime = this.selectTime[1] |
| | | console.log(this.macDate) |
| | | }, |
| | | handleSearch () { |
| | | this.getOnlineData() |
| | | console.log(' this.formInline', this.formInline) |
| | | if (this.formInline.organizationId !== '') { |
| | | if (this.time === '今天') { |
| | | console.log('今天今天') |
| | | this.formInline.startTime = dayjs().startOf('day').format('YYYY-MM-DD HH:mm') |
| | | this.formInline.endTime = dayjs().subtract(1, 'hour').format('YYYY-MM-DD HH:mm') |
| | | } |