From 5244fdb5f7932f2cbce43f4bfaa9dc06c9dd4c95 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期五, 01 十二月 2023 14:04:16 +0800 Subject: [PATCH] 修改FYLineChart.vue引用 --- src/sfc/TimeSelectWithShortCuts.vue | 161 +++++++++++++++++++++++++++++++---------------------- 1 files changed, 94 insertions(+), 67 deletions(-) diff --git a/src/sfc/TimeSelectWithShortCuts.vue b/src/sfc/TimeSelectWithShortCuts.vue index 4f08f84..11cacd5 100644 --- a/src/sfc/TimeSelectWithShortCuts.vue +++ b/src/sfc/TimeSelectWithShortCuts.vue @@ -13,68 +13,94 @@ *** --> <script> -import dayjs from 'dayjs' - export default { - emits: ['submitTime'], - data() { - return{ - //淇濆瓨寮�濮嬪拰缁撴潫鏃堕棿 - // 闅忎究璁剧疆鍒濆鍊� 锛宮ounted鏃跺啀璁炬纭殑锛岀洰鐨勬槸鏀瑰彉鏃堕棿浜嗚Е鍙慶hange - time: ['2023-06-01 12:00:00', '2023-06-20 16:00:00'], - shortcuts:[], - } - }, - mounted() { - this.initShortCuts() - this.initOneWeekAgoTime() - this.$emit('submitTime', this.time); - }, - methods: { - initShortCuts(){ - this.shortcuts = [ - { - text: '鍓嶄竴鏃�', - value: () => { - const end = new Date() - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24) - return [start, end] - }, - }, - - { - text: '鍓�7澶�', - value: () => { - const end = new Date() - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) - return [start, end] - }, - }, - { - text: '鍓嶄竴鏈�', - value: () => { - const end = new Date() - const start = new Date() - start.setTime(start.getTime() - 3600 * 1000 * 24 * 30) - return [start, end] - }, - }, - -] - }, - initOneWeekAgoTime(){ - // 缁欐椂闂撮�夋嫨鍣ㄨ缃粯璁ゆ椂闂翠负涓�鍛ㄥ墠 - this.time[0] = dayjs().subtract(6, 'week').format('YYYY-MM-DD HH:mm:ss'); - this.time[1] = dayjs().format('YYYY-MM-DD HH:mm:ss'); +import dayjs from 'dayjs'; +export default { + props: { + timeType: { + type: String, + default: 'month' } - } -} + }, + emits: ['submitTime'], + data() { + return { + //淇濆瓨寮�濮嬪拰缁撴潫鏃堕棿 + // 闅忎究璁剧疆鍒濆鍊� 锛宮ounted鏃跺啀璁炬纭殑锛岀洰鐨勬槸鏀瑰彉鏃堕棿浜嗚Е鍙慶hange + time: ['2023-06-01 12:00:00', '2023-06-20 16:00:00'], + shortcuts: [] + }; + }, + mounted() { + this.initShortCuts(); + this.initOneWeekAgoTime(); + this.$emit('submitTime', this.time); + }, + methods: { + initShortCuts() { + this.shortcuts = [ + { + text: '鍓嶄竴鏃�', + value: () => { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24); + return [start, end]; + } + }, + + { + text: '鍓�7澶�', + value: () => { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); + return [start, end]; + } + }, + { + text: '鍓嶄竴鏈�', + value: () => { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); + return [start, end]; + } + } + ]; + }, + initOneWeekAgoTime() { + switch (this.timeType) { + case 'day': + this.time[0] = dayjs() + .subtract(1, 'day') + .format('YYYY-MM-DD HH:mm:ss'); + this.time[1] = dayjs().format('YYYY-MM-DD HH:mm:ss'); + break; + case 'week': + this.time[0] = dayjs() + .subtract(1, 'week') + .format('YYYY-MM-DD HH:mm:ss'); + this.time[1] = dayjs().format('YYYY-MM-DD HH:mm:ss'); + break; + case 'month': + this.time[0] = dayjs() + .subtract(1, 'month') + .format('YYYY-MM-DD HH:mm:ss'); + this.time[1] = dayjs().format('YYYY-MM-DD HH:mm:ss'); + break; + default: + this.time[0] = dayjs().subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss'); + this.time[1] = dayjs().format('YYYY-MM-DD HH:mm:ss'); + } + } + } +}; </script> <template> - <div class="block"> - <div class="demonstration">璧锋鏃堕棿锛�</div> + <div class="block"> + <span class="demonstration">璧锋鏃堕棿锛�</span> + <div class="pick-date"> <el-date-picker v-model="time" type="datetimerange" @@ -84,23 +110,24 @@ end-placeholder="缁撴潫鏃堕棿" value-format="YYYY-MM-DD HH:mm:ss" @change="$emit('submitTime', time)" - class="pick-date" + /> + </div> </div> </template> -<style scoped> +<style scoped> .block { display: flex; - width: 570px; + width: 500px; } .demonstration { - margin-left: 15px; - margin-top: 5px; + color: #333333; font-weight: bold; + font-size: 14px; } -.pick-date { - margin-top: 5px; -} -</style> \ No newline at end of file +/* .pick-date { + width: 200px; +} */ +</style> -- Gitblit v1.9.3