n20-common-lib 2.5.0-beta.7 → 2.5.0-beta.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": "n20-common-lib",
3
- "version": "2.5.0-beta.7",
3
+ "version": "2.5.0-beta.9",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -18,27 +18,27 @@
18
18
 
19
19
  <script>
20
20
  import { $lc } from '../../utils/i18n/index'
21
- // import dayjs from 'dayjs'
22
- // let startDate = ''
21
+ import dayjs from 'dayjs'
22
+ let startDate = ''
23
23
 
24
- // const onPick = ({ maxDate, minDate }) => {
25
- // startDate = minDate.getMonth() + 1 + '-' + minDate.getDate()
26
- // let startSh = shortcuts_2.find((s) => s.text.includes($lc('开始')))
27
- // startSh.text = startDate + $lc('开始')
28
- // startSh.onClick = (picker) => {
29
- // const start = dayjs(minDate).format('YYYY-MM-DD HH:mm:ss')
30
- // const end = dayjs(minDate).add(100, 'year').format('YYYY-MM-DD HH:mm:ss')
31
- // picker.$emit('pick', [start, end])
32
- // }
24
+ const onPick = ({ maxDate, minDate }) => {
25
+ startDate = minDate.getMonth() + 1 + '-' + minDate.getDate()
26
+ let startSh = shortcuts_2.find((s) => s.text.includes($lc('开始')))
27
+ startSh.text = startDate + $lc('开始')
28
+ startSh.onClick = (picker) => {
29
+ const start = dayjs(minDate).format('YYYY-MM-DD HH:mm:ss')
30
+ const end = dayjs(minDate).add(100, 'year').format('YYYY-MM-DD HH:mm:ss')
31
+ picker.$emit('pick', [start, end])
32
+ }
33
33
 
34
- // let endSh = shortcuts_2.find((s) => s.text.includes($lc('截止')))
35
- // endSh.text = startDate + $lc('截止')
36
- // endSh.onClick = (picker) => {
37
- // const end = dayjs(minDate).format('YYYY-MM-DD HH:mm:ss')
38
- // const start = dayjs(minDate).subtract(100, 'year').format('YYYY-MM-DD HH:mm:ss')
39
- // picker.$emit('pick', [start, end])
40
- // }
41
- // }
34
+ let endSh = shortcuts_2.find((s) => s.text.includes($lc('截止')))
35
+ endSh.text = startDate + $lc('截止')
36
+ endSh.onClick = (picker) => {
37
+ const end = dayjs(minDate).format('YYYY-MM-DD HH:mm:ss')
38
+ const start = dayjs(minDate).subtract(100, 'year').format('YYYY-MM-DD HH:mm:ss')
39
+ picker.$emit('pick', [start, end])
40
+ }
41
+ }
42
42
 
43
43
  let disabledDate_1 = (t) => {
44
44
  let now = new Date()
@@ -95,23 +95,23 @@ let shortcuts_2 = [
95
95
  end.setHours(23, 59, 59)
96
96
  picker.$emit('pick', [start, end])
97
97
  }
98
+ },
99
+ {
100
+ text: $lc('今天开始'),
101
+ onClick(picker) {
102
+ const start = dayjs().format('YYYY-MM-DD HH:mm:ss')
103
+ const end = dayjs().add(99, 'year').format('YYYY-MM-DD HH:mm:ss')
104
+ picker.$emit('pick', [start, end])
105
+ }
106
+ },
107
+ {
108
+ text: $lc('今天截止'),
109
+ onClick(picker) {
110
+ const end = dayjs().format('YYYY-MM-DD HH:mm:ss')
111
+ const start = dayjs().subtract(100, 'year').format('YYYY-MM-DD HH:mm:ss')
112
+ picker.$emit('pick', [start, end])
113
+ }
98
114
  }
99
- // {
100
- // text: $lc('今天开始'),
101
- // onClick(picker) {
102
- // const start = dayjs().format('YYYY-MM-DD HH:mm:ss')
103
- // const end = dayjs().add(99, 'year').format('YYYY-MM-DD HH:mm:ss')
104
- // picker.$emit('pick', [start, end])
105
- // }
106
- // },
107
- // {
108
- // text: $lc('今天截止'),
109
- // onClick(picker) {
110
- // const end = dayjs().format('YYYY-MM-DD HH:mm:ss')
111
- // const start = dayjs().subtract(100, 'year').format('YYYY-MM-DD HH:mm:ss')
112
- // picker.$emit('pick', [start, end])
113
- // }
114
- // }
115
115
  ]
116
116
 
117
117
  export default {
@@ -165,13 +165,13 @@ export default {
165
165
  this.pickerOptionsAs = Object.assign(
166
166
  {
167
167
  disabledDate: this.minNow ? disabledDate_1 : this.maxNow ? disabledDate_2 : undefined,
168
- shortcuts
169
- // onPick
168
+ shortcuts,
169
+ onPick
170
170
  },
171
171
  this.pickerOptions
172
172
  )
173
173
 
174
- this.listeners = Object.assign({}, this.$listeners, { input: () => {}, change: () => {} })
174
+ this.listeners = Object.assign({}, this.$listeners, { input: () => {}, change: () => {}, blur: this.HandleBlur })
175
175
  return {}
176
176
  },
177
177
  computed: {
@@ -226,22 +226,22 @@ export default {
226
226
  }
227
227
  },
228
228
  methods: {
229
- // HandleBlur() {
230
- // let startSh = shortcuts_2.find((s) => s.text.includes($lc('开始')))
231
- // let endSh = shortcuts_2.find((s) => s.text.includes($lc('截止')))
232
- // startSh.text = $lc('今天开始')
233
- // startSh.onClick = (picker) => {
234
- // const start = dayjs().format('YYYY-MM-DD HH:mm:ss')
235
- // const end = dayjs().add(100, 'year').format('YYYY-MM-DD HH:mm:ss')
236
- // picker.$emit('pick', [start, end])
237
- // }
238
- // endSh.text = $lc('今天截止')
239
- // endSh.onClick = (picker) => {
240
- // const end = dayjs().format('YYYY-MM-DD HH:mm:ss')
241
- // const start = dayjs().subtract(100, 'year').format('YYYY-MM-DD HH:mm:ss')
242
- // picker.$emit('pick', [start, end])
243
- // }
244
- // }
229
+ HandleBlur() {
230
+ let startSh = shortcuts_2.find((s) => s.text.includes($lc('开始')))
231
+ let endSh = shortcuts_2.find((s) => s.text.includes($lc('截止')))
232
+ startSh.text = $lc('今天开始')
233
+ startSh.onClick = (picker) => {
234
+ const start = dayjs().format('YYYY-MM-DD HH:mm:ss')
235
+ const end = dayjs().add(100, 'year').format('YYYY-MM-DD HH:mm:ss')
236
+ picker.$emit('pick', [start, end])
237
+ }
238
+ endSh.text = $lc('今天截止')
239
+ endSh.onClick = (picker) => {
240
+ const end = dayjs().format('YYYY-MM-DD HH:mm:ss')
241
+ const start = dayjs().subtract(100, 'year').format('YYYY-MM-DD HH:mm:ss')
242
+ picker.$emit('pick', [start, end])
243
+ }
244
+ }
245
245
  }
246
246
  }
247
247
  </script>
@@ -554,9 +554,12 @@ export default {
554
554
  MultipleSUccessFn(response, file, fileList, row) {
555
555
  if (fileList.length > 1) {
556
556
  let deepRow = cloneDeep(row)
557
- if (!this.tableData[0][this.keys.url]) {
558
- this.tableData.shift()
559
- }
557
+ this.$nextTick(() => {
558
+ if (this.tableData.length && !this.tableData[0][this.keys.url]) {
559
+ this.tableData.shift()
560
+ }
561
+ })
562
+
560
563
  setTimeout(() => {
561
564
  this.tableData.splice(0, 0, {
562
565
  _name: file.name,
@@ -0,0 +1,22 @@
1
+ const directive = {}
2
+
3
+ directive.install = (Vue) => {
4
+ Vue.directive('toErrorMessage', {
5
+ bind: () => {
6
+ document.body.addEventListener('click', () => {
7
+ // 获取el-form元素
8
+ var form = document.querySelector('.el-form')
9
+ // 检查是否有必填项校验错误
10
+ var errorElement = form.querySelector('.is-error')
11
+ if (errorElement) {
12
+ // 获取第一个必填项所在的位置
13
+ var errorOffset = errorElement.offsetTop
14
+ // 滚动到必填项位置
15
+ window.scrollTo(0, errorOffset)
16
+ }
17
+ })
18
+ }
19
+ })
20
+ }
21
+
22
+ export default directive
package/src/index.js CHANGED
@@ -97,6 +97,7 @@ import VMove from './directives/VMove/index.js'
97
97
  import VRuleKey from './directives/VRuleKey/index.js'
98
98
  import { HoverTooltip, TitleDirective } from './directives/VTitle/index.js'
99
99
  import VTableLoading from './directives/loading/index.js'
100
+ import VErrorMessage from './directives/VErrorMessage/index.js'
100
101
 
101
102
  /** 注入方法 */
102
103
  import dayjs from 'dayjs'
@@ -227,6 +228,7 @@ const install = function (Vue, opts = { prefix: 'Cl', i18nConfig: {} }) {
227
228
  Vue.use(VClickOutside)
228
229
  Vue.use(VHas)
229
230
  Vue.use(VTableLoading)
231
+ Vue.use(VErrorMessage)
230
232
 
231
233
  Vue.use(i18n, opts.i18nConfig)
232
234
  Vue.prototype.$axios = axios