gunter-kgd 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@
9
9
  :style="{
10
10
  cursor: DragObject.mouseDown ? 'grabbing' : 'grab',
11
11
  width:current_data.width?current_data.width+'px':0,
12
- transform: `translate3d(${current_data.left?current_data.left+'px':0},10px,0)`,
12
+ transform: `translate3d(${current_data.left?current_data.left+'px':0},15px,0)`,
13
13
  transition: !DragObject.mouseDown ? 'width .5s linear, opacity .2s ease' : 'null',
14
14
  background:current_data.bg_color?current_data.bg_color:'#FD8A25',
15
15
  borderColor: current_data.bg_color ? `${current_data.bg_color} ${current_data.bg_color} transparent`: '#00b0ff #00b0ff transparent'}"
@@ -82,7 +82,7 @@
82
82
  buildToastContent() {
83
83
  if (!this.current_data || !this.current_data.params) {
84
84
  this.toastClassResolved = (this.toastClass || '').trim();
85
- return '';
85
+ return { content: '', canShow: false };
86
86
  }
87
87
  let list = '';
88
88
  for (let i in this.th_data) {
@@ -114,7 +114,8 @@
114
114
  }
115
115
 
116
116
  this.toastClassResolved = resolvedClass;
117
- return resolvedContent;
117
+ const canShow = resolvedContent !== '';
118
+ return { content: resolvedContent, canShow };
118
119
  },
119
120
  showToast(e) {
120
121
  this.canShow = true;
@@ -124,7 +125,14 @@
124
125
  if(this.current_data && this.canShow){
125
126
  if(this.current_data.params){
126
127
  let toast = document.createElement('div'), add_toast = true
127
- const content = this.buildToastContent();
128
+ const toastInfo = this.buildToastContent();
129
+ if(!toastInfo.canShow){
130
+ if (document.getElementsByClassName('gante-toast-liu')[0]) {
131
+ document.getElementsByClassName('gante-toast-liu')[0].style.display = 'none';
132
+ }
133
+ return;
134
+ }
135
+ const content = toastInfo.content;
128
136
  const toastClass = `gante-toast-liu${this.toastClassResolved ? ' ' + this.toastClassResolved : ''}`
129
137
  toast.setAttribute('class', toastClass)
130
138
  if (document.getElementsByClassName('gante-toast-liu')[0]) {
@@ -300,9 +308,14 @@
300
308
  if (document.getElementsByClassName('gante-toast-liu')[0]) {
301
309
  toast = document.getElementsByClassName('gante-toast-liu')[0]
302
310
  toast.style.display = 'block';
303
- const content = this.buildToastContent();
304
- if(toast.innerHTML != content || content == ''){
305
- toast.innerHTML = content
311
+ const toastInfo = this.buildToastContent();
312
+ if(!toastInfo.canShow){
313
+ toast.style.display = 'none';
314
+ return;
315
+ }
316
+ const content = toastInfo.content;
317
+ if(toast.innerHTML != content){
318
+ toast.innerHTML = content;
306
319
  }
307
320
  }
308
321
  }
@@ -247,7 +247,7 @@
247
247
  }
248
248
  .gc-locate-btn{
249
249
  position: absolute;
250
- top: 9px;
250
+ top: 13px;
251
251
  width: 18px;
252
252
  height: 22px;
253
253
  border-radius: 4px;
@@ -239,30 +239,109 @@
239
239
  this.todayInfo.left = (new Date(new Date().toLocaleDateString()).getTime() - first_time.getTime())/time;
240
240
 
241
241
  var list = [];
242
- for (let i = 0; i <= all_width;) {
243
- var old_time = first_time;
244
- var date = '';
242
+ if (time_mode == 1) {
243
+ const dayMs = 24 * 60 * 60 * 1000;
244
+ let cursor = new Date(first_time);
245
+ while (cursor.getTime() <= all_width) {
246
+ const monthEnd = new Date(cursor.getFullYear(), cursor.getMonth() + 1, 1);
247
+ const remainingDays = Math.ceil((monthEnd.getTime() - cursor.getTime()) / dayMs);
248
+ if (remainingDays < 7 && list.length) {
249
+ const prev = list[list.length - 1];
250
+ const extraWidth = (monthEnd.getTime() - cursor.getTime()) / time;
251
+ prev.width += extraWidth;
252
+ this.header_width += extraWidth;
253
+ cursor = monthEnd;
254
+ continue;
255
+ }
256
+ let next = new Date(cursor.getFullYear(), cursor.getMonth(), cursor.getDate() + 7);
257
+ if (next.getTime() > monthEnd.getTime()) {
258
+ next = monthEnd;
259
+ }
260
+ const width = (next.getTime() - cursor.getTime()) / time;
261
+ this.header_width += width;
262
+ list.push({
263
+ left: (cursor.getTime() - this.first_day.getTime()) / time,
264
+ width: width,
265
+ date: this.format(cursor, 2)
266
+ });
267
+ cursor = next;
268
+ this.future_time = cursor.getTime();
269
+ }
270
+ } else if (time_mode == 2) {
271
+ const weekMs = 7 * 24 * 60 * 60 * 1000;
272
+ let cursor = new Date(first_time);
273
+ while (cursor.getTime() <= all_width) {
274
+ const yearEnd = new Date(cursor.getFullYear() + 1, 0, 1);
275
+ const remainingWeeks = Math.ceil((yearEnd.getTime() - cursor.getTime()) / weekMs);
276
+ if (remainingWeeks < 4 && list.length) {
277
+ const prev = list[list.length - 1];
278
+ const extraWidth = (yearEnd.getTime() - cursor.getTime()) / time;
279
+ prev.width += extraWidth;
280
+ this.header_width += extraWidth;
281
+ cursor = yearEnd;
282
+ continue;
283
+ }
284
+ let next = new Date(cursor.getFullYear(), cursor.getMonth(), cursor.getDate() + 28);
285
+ if (next.getTime() > yearEnd.getTime()) {
286
+ next = yearEnd;
287
+ }
288
+ const width = (next.getTime() - cursor.getTime()) / time;
289
+ this.header_width += width;
290
+ list.push({
291
+ left: (cursor.getTime() - this.first_day.getTime()) / time,
292
+ width: width,
293
+ date: this.format(cursor, 5)
294
+ });
295
+ cursor = next;
296
+ this.future_time = cursor.getTime();
297
+ }
298
+ } else if (time_mode == 3) {
299
+ let cursor = new Date(first_time);
300
+ while (cursor.getTime() <= all_width) {
301
+ const yearEnd = new Date(cursor.getFullYear() + 1, 0, 1);
302
+ const remainingMonths = (yearEnd.getFullYear() - cursor.getFullYear()) * 12 + (yearEnd.getMonth() - cursor.getMonth());
303
+ if (remainingMonths < 3 && list.length) {
304
+ const prev = list[list.length - 1];
305
+ const extraWidth = (yearEnd.getTime() - cursor.getTime()) / time;
306
+ prev.width += extraWidth;
307
+ this.header_width += extraWidth;
308
+ cursor = yearEnd;
309
+ continue;
310
+ }
311
+ let next = new Date(cursor.getFullYear(), cursor.getMonth() + 3, 1);
312
+ if (next.getTime() > yearEnd.getTime()) {
313
+ next = yearEnd;
314
+ }
315
+ const width = (next.getTime() - cursor.getTime()) / time;
316
+ this.header_width += width;
317
+ list.push({
318
+ left: (cursor.getTime() - this.first_day.getTime()) / time,
319
+ width: width,
320
+ date: this.format(cursor, 5)
321
+ });
322
+ cursor = next;
323
+ this.future_time = cursor.getTime();
324
+ }
325
+ } else {
326
+ for (let i = 0; i <= all_width;) {
327
+ var old_time = first_time;
328
+ var date = '';
245
329
 
246
- if (time_mode == 1) {
247
- // 月的形式,保留月份显示
248
- date = this.format(old_time, 2); // 格式: YYYY-MM
249
- first_time = new Date(first_time.getFullYear(), first_time.getMonth() + 1, 1);
250
- } else {
251
330
  // 年的形式,只展示年份
252
331
  date = this.format(old_time, 5); // 格式: YYYY
253
332
  first_time = new Date(first_time.getFullYear() + 1, 0, 1);
254
- }
255
333
 
256
- var width = (first_time.getTime() - old_time.getTime()) / time;
257
- this.header_width += width;
258
- list.push({
259
- left: (old_time.getTime() - this.first_day.getTime()) / time,
260
- width: width,
261
- date: date
262
- });
334
+ var width = (first_time.getTime() - old_time.getTime()) / time;
335
+ this.header_width += width;
336
+ list.push({
337
+ left: (old_time.getTime() - this.first_day.getTime()) / time,
338
+ width: width,
339
+ date: date
340
+ });
263
341
 
264
- i = first_time.getTime();
265
- this.future_time = i;
342
+ i = first_time.getTime();
343
+ this.future_time = i;
344
+ }
266
345
  }
267
346
 
268
347
  this.top_time_data = list;
@@ -404,6 +483,9 @@
404
483
  line-height: 25px;
405
484
  position: relative;
406
485
  background: #fff;
486
+ font-size: 14px;
487
+ font-weight: 800;
488
+ color: #000000D9;
407
489
  /*display: flex;*/
408
490
  /*justify-content: flex-start;*/
409
491
  }
@@ -415,7 +497,7 @@
415
497
 
416
498
  .ganteview-toptime .ganteview-headercell {
417
499
  padding-left: 4px;
418
- text-align: left;
500
+ text-align: center;
419
501
  }
420
502
 
421
503
  .ganteview-bottomtime .ganteview-headercell {
@@ -437,12 +519,11 @@
437
519
  height: calc(100% - 54px);
438
520
  z-index: 0;
439
521
  box-sizing: border-box;
440
- background: #dcecfe;
522
+ background: #5396e2;
441
523
  }
442
524
 
443
525
  .ganteview-headercell {
444
526
  box-sizing: border-box;
445
- color: #666;
446
527
  border-right: 1px solid #ebeef5;
447
528
  border-bottom: 1px solid #ebeef5;
448
529
  overflow: hidden;
@@ -332,8 +332,11 @@
332
332
  -ms-user-select: none;
333
333
  user-select: none;
334
334
  text-align: left;
335
- background: #fff;
336
- box-sizing: border-box;
335
+ background: #fff;
336
+ box-sizing: border-box;
337
+ font-size: 14px;
338
+ font-weight: 800;
339
+ color: #000000D9;
337
340
  }
338
341
  /*.gante-tr{*/
339
342
  /*display: table-row;*/
package/gante.vue CHANGED
@@ -99,82 +99,86 @@
99
99
  }
100
100
  },
101
101
  created() {
102
+ this.initEmit()
103
+ },
104
+ mounted() {
105
+ this.init(this.getInitParams(), true)
106
+ this.$nextTick(function () {
107
+ setTimeout(() => {
108
+ // 获取到左边表格所有td加起来的宽度
109
+ this.find_attr(document.getElementsByClassName('gante-table-box')[0].clientWidth, this.th_data)
110
+ })
111
+ })
112
+
113
+ },
114
+ watch: {
115
+ $attrs: {
116
+ handler() {
117
+ this.init(this.getInitParams(), true)
118
+ },
119
+ deep: true
120
+ }
121
+ },
122
+ methods: {
123
+ //初始化emit
124
+ initEmit() {
102
125
  commitEmit.$off('change')
103
126
  commitEmit.$on('change', (data) => {
104
- this.change(data)
127
+ this.change(data)
105
128
  });
106
129
  commitEmit.$off('change-calendar')
107
130
  commitEmit.$on('change-calendar', (data) => {
108
- this.change_calendar(data)
131
+ this.change_calendar(data)
109
132
  });
110
133
  // 某个单元格的点击事件
111
134
  commitEmit.$off('on-click')
112
135
  commitEmit.$on('on-click', (data) => {
113
- this.onclick(data)
136
+ this.onclick(data)
114
137
  });
115
138
  // 拖动改变时间
116
139
  commitEmit.$off('onDragChangeTime')
117
140
  commitEmit.$on('onDragChangeTime', (oldData,data) => {
118
- const resolves = (bol)=>{
119
- if(!bol){
120
- this.resetTask(this.ganteData,oldData);
121
- }
141
+ const resolves = (bol)=>{
142
+ if(!bol){
143
+ this.resetTask(this.ganteData,oldData);
122
144
  }
123
- this.onDragChangeTime(data,resolves)
145
+ }
146
+ this.onDragChangeTime(data,resolves)
124
147
  });
125
148
 
126
149
 
127
150
  //懒加载
128
151
  commitEmit.$off('on-load')
129
152
  commitEmit.$on('on-load', () => {
130
- /**
131
- *
132
- * @type {Function}
133
- * requestBol: 是否显示加载图标
134
- * data: 加载的数据
135
- * start_time: 最小开始时间
136
- * end_time: 最大的结束时间
137
- */
138
- const resolve = ((requestBol, data, start_time, end_time) => {
139
- if (!requestBol) {
140
- this.showLoading = false
141
- }
142
- this.ganteData.push(...data)
143
- this.start_time = start_time
144
- this.end_time = end_time
145
- this.init({ganteData: this.ganteData, start_time: this.start_time, end_time: this.end_time},false)
146
- this.$nextTick(function () {
147
- this.$refs.gante_gc.requestBol = requestBol
148
- })
153
+ /**
154
+ *
155
+ * @type {Function}
156
+ * requestBol: 是否显示加载图标
157
+ * data: 加载的数据
158
+ * start_time: 最小开始时间
159
+ * end_time: 最大的结束时间
160
+ */
161
+ const resolve = ((requestBol, data, start_time, end_time) => {
162
+ if (!requestBol) {
163
+ this.showLoading = false
164
+ }
165
+ this.ganteData.push(...data)
166
+ this.start_time = start_time
167
+ this.end_time = end_time
168
+ this.init({ganteData: this.ganteData, start_time: this.start_time, end_time: this.end_time},false)
169
+ this.$nextTick(function () {
170
+ this.$refs.gante_gc.requestBol = requestBol
149
171
  })
150
- this.onLoad(resolve)
172
+ })
173
+ this.onLoad(resolve)
151
174
  });
152
175
 
153
176
 
154
177
  commitEmit.$off('triggerInit');
155
178
  commitEmit.$on('triggerInit', (start_time,end_time) =>{
156
- this.init({start_time: start_time, end_time: end_time},false)
157
- })
158
- },
159
- mounted() {
160
- this.init(this.getInitParams(), true)
161
- this.$nextTick(function () {
162
- setTimeout(() => {
163
- // 获取到左边表格所有td加起来的宽度
164
- this.find_attr(document.getElementsByClassName('gante-table-box')[0].clientWidth, this.th_data)
165
- })
179
+ this.init({start_time: start_time, end_time: end_time},false)
166
180
  })
167
-
168
- },
169
- watch: {
170
- $attrs: {
171
- handler() {
172
- this.init(this.getInitParams(), true)
173
- },
174
- deep: true
175
- }
176
- },
177
- methods: {
181
+ },
178
182
  getInitParams(){
179
183
  return Object.assign({}, this.$attrs)
180
184
  },
@@ -475,7 +479,7 @@
475
479
  display: flex;
476
480
  align-items: center;
477
481
  justify-content: space-between;
478
- z-index: 99999;
482
+ z-index: 999;
479
483
  gap: 10px;
480
484
  .today{
481
485
  padding: 6px 10px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gunter-kgd",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "main": "gante-vue.common.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"