lshcom 1.0.7 → 1.0.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lshcom",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "files": [
5
5
  "src/assets/*",
6
6
  "src/common/common.js",
@@ -530,6 +530,7 @@ Date.prototype.Format = function (fmt = 'yyyy-MM-dd hh:mm:ss') {
530
530
  var o = {
531
531
  "M+": this.getMonth() + 1,
532
532
  "d+": this.getDate(),
533
+ "H+": this.getHours(),
533
534
  "h+": this.getHours(),
534
535
  "m+": this.getMinutes(),
535
536
  "s+": this.getSeconds(),
@@ -41,9 +41,28 @@ const global = {
41
41
  number(val = '') {return val.replace(/[^\d]/g,'')}, // 只保留数字
42
42
  decimals2(val = '') {return val.replace(/[^\d.]/g,'').replace(/\.{2,}/g,'.').replace(/^\./g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')}, // 保留两位小数
43
43
  },
44
- format(date, fmt = 'yyyy-MM-dd hh:mm:ss') {
44
+ format(date, fmt = 'yyyy-MM-dd HH:mm:ss') {
45
45
  if(!date) return ''
46
- return new Date(date).Format(fmt)
46
+ const newDate = new Date(date)
47
+ var o = {
48
+ "M+": newDate.getMonth() + 1,
49
+ "d+": newDate.getDate(),
50
+ "H+": newDate.getHours(),
51
+ "h+": newDate.getHours(),
52
+ "m+": newDate.getMinutes(),
53
+ "s+": newDate.getSeconds(),
54
+ "q+": Math.floor((newDate.getMonth() + 3) / 3),
55
+ "S": newDate.getMilliseconds()
56
+ };
57
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (newDate.getFullYear() + "").substr(4 - RegExp.$1.length))
58
+ for (var k in o) {
59
+ if (new RegExp("(" + k + ")").test(fmt)) {
60
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1)
61
+ ? (o[ k ])
62
+ : (("00" + o[ k ]).substr(("" + o[ k ]).length)))
63
+ }
64
+ }
65
+ return fmt
47
66
  },
48
67
  open(url){window.open(origin + url, "_blank")},
49
68
  uploadUrl: cxb + '/v1/fileSys/file/upload',
@@ -14,6 +14,7 @@
14
14
  :picker-options="pickerOptions"
15
15
  :range-separator="rangeSeparator"
16
16
  :default-value="defaultValue"
17
+ :default-time="defaultTime"
17
18
  @change="change">
18
19
  </el-date-picker>
19
20
  </template>
@@ -33,6 +34,7 @@
33
34
  align: {type: String, default: 'left'}, // 对齐方式 left/center/right
34
35
  rangeSeparator: {type: String, default: ' - '}, // 选择范围时的分隔符
35
36
  defaultValue: [String, Number, Array, Date], // 可选,DatePicker打开时默认显示的时间,可被new Date()解析
37
+ defaultTime: {type: Array, default: () => (['00:00:00', '23:59:59'])}, // 选中日期后的默认具体时刻,非范围选择时:形如12:00:00的字符串;范围选择时:数组,长度为 2,每项值为字符串,形如12:00:00,第一项指定开始日期的时刻,第二项指定结束日期的时刻。不指定会使用时刻 00:00:00
36
38
  maxDate: {type: Number, default: 0}, // 可选,设置最大可选时间(天数)
37
39
  valueFormat: {type: String, default: ''}, // 可选,绑定值的格式。不指定则绑定值为 Date 对象
38
40
  },
@@ -65,43 +67,47 @@
65
67
  };
66
68
  },
67
69
  watch: {
68
- value: function (val, oldVal) {
69
- if(['daterange'].includes(this.type)){
70
- if (!val || !val.length) {
71
- this.change()
72
- } else if(val[0] !== this.date[0] || val[1] !== this.date[1]){
73
- this.change(val[0] + this.rangeSeparator + val[1])
70
+ value: {
71
+ handler (val, oldVal) {
72
+ if(['daterange','datetimerange'].includes(this.type)){
73
+ if (!val || !val.length) {
74
+ this.change()
75
+ } else if(val[0] !== this.date[0] || val[1] !== this.date[1]){
76
+ this.change(val[0] + this.rangeSeparator + val[1])
77
+ }
78
+ } else {
79
+ this.date = val
74
80
  }
75
- } else {
76
- this.date = val
77
- }
81
+ },
82
+ immediate: true,
83
+ deep: true,
78
84
  },
79
85
  },
80
86
  mounted() {
81
- this.date = this.value
87
+
82
88
  },
83
89
  methods: {
84
90
  change(value){
85
- if(['daterange'].includes(this.type)){
91
+ if(['daterange','datetimerange'].includes(this.type)){
86
92
  if (!value) {
87
93
  value = [undefined, undefined]
88
94
  } else {
89
- let valueArr = value.split(this.rangeSeparator)
95
+ let valueArr = this.global.getType(value) == 'string' ? value.split(this.rangeSeparator) : value
90
96
  if(this.valueFormat){
91
97
  value = [
92
- valueArr[0] ? new Date(valueArr[0]).Format(this.valueFormat) : undefined,
93
- valueArr[1] ? new Date(valueArr[1]).Format(this.valueFormat) : undefined,
98
+ valueArr[0] ? this.global.format(valueArr[0],this.valueFormat) : undefined,
99
+ valueArr[1] ? this.global.format(valueArr[1],this.valueFormat) : undefined,
94
100
  ]
95
101
  }else{
96
102
  value = [
97
- valueArr[0] ? new Date(valueArr[0]).Format('yyyy-MM-dd') + ' 00:00:00' : undefined,
98
- valueArr[1] ? new Date(valueArr[1]).Format('yyyy-MM-dd') + ' 23:59:59' : undefined,
103
+ valueArr[0] ? this.global.format(valueArr[0],'yyyy-MM-dd') + ' 00:00:00' : undefined,
104
+ valueArr[1] ? this.global.format(valueArr[1],'yyyy-MM-dd') + ' 23:59:59' : undefined,
99
105
  ]
100
106
  }
101
107
  }
102
108
  } else if(['date'].includes(this.type)){
103
109
  if(this.valueFormat && value){
104
- value = new Date(value).Format(this.valueFormat)
110
+ value = this.global.format(value,this.valueFormat)
105
111
  }
106
112
  }
107
113
  this.date = value
@@ -110,4 +116,8 @@
110
116
  },
111
117
  }
112
118
  };
113
- </script>
119
+ </script>
120
+
121
+ <style lang="scss" scoped>
122
+ .el-range-editor.el-input__inner{max-width: 100%;}
123
+ </style>
@@ -43,22 +43,19 @@
43
43
  this.currentPage = val
44
44
  this.change()
45
45
  },
46
- change(){
46
+ change(pageStart, pageNums){
47
+ if(pageStart || pageNums){
48
+ this.reset(pageStart, pageNums)
49
+ }
47
50
  this.$emit('change', {
48
51
  pageStart: this.currentPage,
49
52
  pageNums: this.pageSize
50
53
  })
51
54
  },
52
- reset(){
53
- this.currentPage = this.pageStart
54
- this.pageSize = this.pageNums
55
- },
56
- resetCurrent(currentPage){
57
- if (this.currentPage != currentPage) {
58
- this.currentPage = currentPage
59
- } else {
60
- this.change()
61
- }
55
+ // 重置页数和个数,但不触发change
56
+ reset(pageStart, pageNums){
57
+ this.currentPage = pageStart ? pageStart : this.pageStart
58
+ this.pageSize = pageNums ? pageNums : this.pageNums
62
59
  },
63
60
  }
64
61
  };
@@ -67,9 +67,9 @@
67
67
  });
68
68
  },
69
69
  // 从默认第一页开始获取数据
70
- resetData(currentPage = 1){
70
+ resetData(pageStart = 1, pageNums){
71
71
  if(this.ifPage) {
72
- this.$refs.ElePage.resetCurrent(currentPage)
72
+ this.$refs.ElePage.change(pageStart, pageNums)
73
73
  } else {
74
74
  this.getData({})
75
75
  }