n20-common-lib 1.3.36 → 1.3.37

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.
@@ -1,201 +1,9 @@
1
1
  <template>
2
- <el-dropdown
3
- trigger="click"
4
- placement="bottom-start"
5
- @command="handleCommand"
6
- >
7
- <el-button size="mini" type="primary"> 导入 </el-button>
8
- <el-dropdown-menu slot="dropdown">
9
- <el-dropdown-item command="a">导入数据</el-dropdown-item>
10
- <el-dropdown-item command="b">模板下载</el-dropdown-item>
11
- </el-dropdown-menu>
12
- </el-dropdown>
2
+ <div>待完善</div>
13
3
  </template>
14
4
 
15
5
  <script>
16
- import XLSX from 'xlsx'
17
- import axios from '../../utils/axios'
18
6
  export default {
19
- name: 'FileImport',
20
- props: {
21
- title: {
22
- type: String,
23
- default: function () {
24
- return '文件导入'
25
- }
26
- },
27
- tips: {
28
- type: Array,
29
- default: () => {
30
- return []
31
- }
32
- },
33
- templateUrl: {
34
- type: String,
35
- default: ''
36
- },
37
- downConfig: {
38
- type: Object,
39
- default() {
40
- return {
41
- isFrontDown: true,
42
- fileName: '下载.xlsx'
43
- }
44
- }
45
- },
46
- footerHandlers: {
47
- type: Object,
48
- default: function () {
49
- return {
50
- // cancel: {
51
- // text: '取消'
52
- // },
53
- // confirm: {
54
- // text: '导入'
55
- // }
56
- }
57
- }
58
- },
59
- beforeUpload: Function, // eslint-disable-line
60
- callback: {
61
- type: Function,
62
- default: () => {}
63
- },
64
- handleConfirm: {
65
- type: Function,
66
- default: () => {}
67
- },
68
- reset: {
69
- type: Boolean,
70
- default: false
71
- }
72
- },
73
- data() {
74
- return {
75
- excelData: {
76
- tableHeader: [],
77
- tableData: []
78
- },
79
-
80
- analysisText: 'analysis',
81
- fileName: '',
82
- statisticsFlag: false,
83
- columnsListTemp: [],
84
- errorListTemp: [],
85
- successFlag: false,
86
- confirmDisabledFlag: true
87
- }
88
- },
89
- methods: {
90
- handleCommand(val) {
91
- if (val == 'a') {
92
- this.seletFile()
93
- } else if (val == 'b') {
94
- this.downloadTemplate()
95
- }
96
- },
97
- seletFile() {
98
- let input = document.createElement('input')
99
- let self = this
100
- input.type = 'file'
101
- input.accept = '.xlsx, .xls, .csv'
102
- input.addEventListener('change', function (event) {
103
- const files = event.target.files
104
- const rawFile = files[0] // only use files[0]
105
- console.log('导入的文件:', rawFile)
106
- self.fileName = rawFile.name
107
- if (!rawFile) return
108
- self.upload(rawFile)
109
- this.value = null // fix can't select the same excel
110
- })
111
- input.click()
112
- },
113
- /* 上传文件 */
114
- upload(rawFile) {
115
- if (!this.beforeUpload) {
116
- this.readerData(rawFile)
117
- return
118
- }
119
- const before = this.beforeUpload(rawFile)
120
- if (before) {
121
- this.readerData(rawFile)
122
- }
123
- },
124
- /*解析传入的表格 */
125
- readerData(rawFile) {
126
- return new Promise((resolve) => {
127
- const reader = new FileReader()
128
- reader.onload = (e) => {
129
- const data = e.target.result
130
- const workbook = XLSX.read(data, {
131
- type: 'array',
132
- cellDates: true
133
- })
134
- const firstSheetName = workbook.SheetNames[0]
135
- const worksheet = workbook.Sheets[firstSheetName]
136
- const header = this.getHeaderRow(worksheet)
137
- const results = XLSX.utils.sheet_to_json(worksheet)
138
-
139
- this.generateData({ header, results })
140
- resolve()
141
- }
142
- reader.readAsArrayBuffer(rawFile)
143
- })
144
- },
145
- generateData({ header, results }) {
146
- this.excelData.tableHeader = header
147
- this.excelData.tableData = results
148
- this.callback && this.callback(this.excelData)
149
- },
150
- getHeaderRow(sheet) {
151
- console.log(sheet)
152
- const headers = []
153
- const range = XLSX.utils.decode_range(sheet['!ref'])
154
- let C
155
- const R = range.s.r
156
- /* start in the first row */
157
- for (C = range.s.c; C <= range.e.c; ++C) {
158
- /* walk every column in the range */
159
- const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]
160
- /* find the cell in the first row */
161
- let hdr = 'UNKNOWN ' + C // <-- replace with your desired default
162
- if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
163
- headers.push(hdr)
164
- }
165
- return headers
166
- },
167
- // 下载文件
168
- downloadTemplate() {
169
- // 前端下载
170
- if (this.downConfig.isFrontDown) {
171
- const aEl = document.createElement('a')
172
- aEl.setAttribute('href', this.templateUrl)
173
- aEl.target = '_blank'
174
- // aEl.download = this.templateUrl
175
- aEl.click()
176
- } else {
177
- axios({
178
- url: this.templateUrl,
179
- method: 'get',
180
- responseType: 'blob'
181
- }).then((res) => {
182
- const content = res
183
- const blob = new Blob([content])
184
- if ('download' in document.createElement('a')) {
185
- const link = document.createElement('a')
186
- link.download = this.downConfig.fileName
187
- link.style.display = 'none'
188
- link.href = URL.createObjectURL(blob)
189
- document.body.appendChild(link)
190
- link.click()
191
- URL.revokeObjectURL(link.href)
192
- document.body.removeChild(link)
193
- } else {
194
- navigator.msSaveBlob(blob, this.downConfig.fileName)
195
- }
196
- })
197
- }
198
- }
199
- }
7
+ name: 'FileImport'
200
8
  }
201
9
  </script>
@@ -1,9 +1,181 @@
1
1
  <template>
2
- <div>待完善</div>
2
+ <el-dropdown
3
+ trigger="click"
4
+ placement="bottom-start"
5
+ @command="handleCommand"
6
+ >
7
+ <el-button size="mini" type="primary"> 导入 </el-button>
8
+ <el-dropdown-menu slot="dropdown">
9
+ <el-dropdown-item command="a">导入数据</el-dropdown-item>
10
+ <el-dropdown-item command="b">模板下载</el-dropdown-item>
11
+ </el-dropdown-menu>
12
+ </el-dropdown>
3
13
  </template>
4
14
 
5
15
  <script>
16
+ import XLSX from 'xlsx'
17
+ import axios from '../../utils/axios'
6
18
  export default {
7
- name: 'FileImport'
19
+ name: 'FileImport',
20
+ props: {
21
+ templateUrl: {
22
+ type: String,
23
+ default: ''
24
+ },
25
+ downConfig: {
26
+ type: Object,
27
+ default() {
28
+ return {
29
+ isFrontDown: true,
30
+ fileName: '下载.xlsx'
31
+ }
32
+ }
33
+ },
34
+ footerHandlers: {
35
+ type: Object,
36
+ default: function () {
37
+ return {
38
+ // cancel: {
39
+ // text: '取消'
40
+ // },
41
+ // confirm: {
42
+ // text: '导入'
43
+ // }
44
+ }
45
+ }
46
+ },
47
+ beforeUpload: Function, // eslint-disable-line
48
+ callback: {
49
+ type: Function,
50
+ default: () => {}
51
+ }
52
+ },
53
+ data() {
54
+ return {
55
+ excelData: {
56
+ tableHeader: [],
57
+ tableData: []
58
+ },
59
+
60
+ analysisText: 'analysis',
61
+ fileName: '',
62
+ statisticsFlag: false,
63
+ columnsListTemp: [],
64
+ errorListTemp: [],
65
+ successFlag: false,
66
+ confirmDisabledFlag: true
67
+ }
68
+ },
69
+ methods: {
70
+ handleCommand(val) {
71
+ if (val === 'a') {
72
+ this.seletFile()
73
+ } else if (val === 'b') {
74
+ this.downloadTemplate()
75
+ }
76
+ },
77
+ seletFile() {
78
+ let input = document.createElement('input')
79
+ let self = this
80
+ input.type = 'file'
81
+ input.accept = '.xlsx, .xls, .csv'
82
+ input.addEventListener('change', function (event) {
83
+ const files = event.target.files
84
+ const rawFile = files[0] // only use files[0]
85
+ console.log('导入的文件:', rawFile)
86
+ self.fileName = rawFile.name
87
+ if (!rawFile) return
88
+ self.upload(rawFile)
89
+ this.value = null // fix can't select the same excel
90
+ })
91
+ input.click()
92
+ },
93
+ /* 上传文件 */
94
+ upload(rawFile) {
95
+ if (!this.beforeUpload) {
96
+ this.readerData(rawFile)
97
+ return
98
+ }
99
+ const before = this.beforeUpload(rawFile)
100
+ if (before) {
101
+ this.readerData(rawFile)
102
+ }
103
+ },
104
+ /*解析传入的表格 */
105
+ readerData(rawFile) {
106
+ return new Promise((resolve) => {
107
+ const reader = new FileReader()
108
+ reader.onload = (e) => {
109
+ const data = e.target.result
110
+ const workbook = XLSX.read(data, {
111
+ type: 'array',
112
+ cellDates: true
113
+ })
114
+ const firstSheetName = workbook.SheetNames[0]
115
+ const worksheet = workbook.Sheets[firstSheetName]
116
+ const header = this.getHeaderRow(worksheet)
117
+ const results = XLSX.utils.sheet_to_json(worksheet)
118
+
119
+ this.generateData({ header, results })
120
+ resolve()
121
+ }
122
+ reader.readAsArrayBuffer(rawFile)
123
+ })
124
+ },
125
+ generateData({ header, results }) {
126
+ this.excelData.tableHeader = header
127
+ this.excelData.tableData = results
128
+ this.callback && this.callback(this.excelData)
129
+ },
130
+ getHeaderRow(sheet) {
131
+ console.log(sheet)
132
+ const headers = []
133
+ const range = XLSX.utils.decode_range(sheet['!ref'])
134
+ let C
135
+ const R = range.s.r
136
+ /* start in the first row */
137
+ for (C = range.s.c; C <= range.e.c; ++C) {
138
+ /* walk every column in the range */
139
+ const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]
140
+ /* find the cell in the first row */
141
+ let hdr = 'UNKNOWN ' + C // <-- replace with your desired default
142
+ if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
143
+ headers.push(hdr)
144
+ }
145
+ return headers
146
+ },
147
+ // 下载文件
148
+ downloadTemplate() {
149
+ // 前端下载
150
+ if (this.downConfig.isFrontDown) {
151
+ const aEl = document.createElement('a')
152
+ aEl.setAttribute('href', this.templateUrl)
153
+ aEl.target = '_blank'
154
+ // aEl.download = this.templateUrl
155
+ aEl.click()
156
+ } else {
157
+ axios({
158
+ url: this.templateUrl,
159
+ method: 'get',
160
+ responseType: 'blob'
161
+ }).then((res) => {
162
+ const content = res
163
+ const blob = new Blob([content])
164
+ if ('download' in document.createElement('a')) {
165
+ const link = document.createElement('a')
166
+ link.download = this.downConfig.fileName
167
+ link.style.display = 'none'
168
+ link.href = URL.createObjectURL(blob)
169
+ document.body.appendChild(link)
170
+ link.click()
171
+ URL.revokeObjectURL(link.href)
172
+ document.body.removeChild(link)
173
+ } else {
174
+ navigator.msSaveBlob(blob, this.downConfig.fileName)
175
+ }
176
+ })
177
+ }
178
+ }
179
+ }
8
180
  }
9
181
  </script>
@@ -129,10 +129,13 @@ export default {
129
129
  },
130
130
  blurFn() {
131
131
  this.showStr = true
132
+ this.$emit('blur', this.value)
132
133
  },
133
134
  changeFn(val) {
134
135
  if (!val && val !== 0) {
135
- return this.$emit('input', val)
136
+ this.$emit('input', val)
137
+ this.$emit('change', val)
138
+ return
136
139
  }
137
140
 
138
141
  switch (this.type) {
@@ -148,6 +151,7 @@ export default {
148
151
  this.$nextTick(() => {
149
152
  this.valueNum = nVar
150
153
  this.$emit('input', nVar)
154
+ this.$emit('change', nVar)
151
155
  })
152
156
  }
153
157
  break
@@ -162,6 +166,7 @@ export default {
162
166
  this.$nextTick(() => {
163
167
  this.valueNum = nVar
164
168
  this.$emit('input', nVar)
169
+ this.$emit('change', nVar)
165
170
  })
166
171
  }
167
172
  break
@@ -6,7 +6,8 @@
6
6
  :max="endValue || endValue === 0 ? endValue : $attrs.max"
7
7
  :type="type"
8
8
  style="width: calc(50% - 8px)"
9
- @input="(val) => $emit('update:start-value', val)"
9
+ @input="startChange"
10
+ @blur="blurFn"
10
11
  />
11
12
  <span class="numbre-range text-c" style="display: inline-block; width: 16px"
12
13
  >-</span
@@ -17,7 +18,8 @@
17
18
  :min="startValue || startValue === 0 ? startValue : $attrs.min"
18
19
  :type="type"
19
20
  style="width: calc(50% - 8px)"
20
- @input="(val) => $emit('update:end-value', val)"
21
+ @input="endChange"
22
+ @blur="blurFn"
21
23
  />
22
24
  </div>
23
25
  </template>
@@ -42,6 +44,19 @@ export default {
42
44
  type: String,
43
45
  default: 'money'
44
46
  }
47
+ },
48
+ methods: {
49
+ startChange(val) {
50
+ this.$emit('update:start-value', val)
51
+ this.$emit('change', [this.startValue, this.endValue])
52
+ },
53
+ endChange(val) {
54
+ this.$emit('update:end-value', val)
55
+ this.$emit('change', [this.startValue, this.endValue])
56
+ },
57
+ blurFn() {
58
+ this.$emit('blur', [this.startValue, this.endValue])
59
+ }
45
60
  }
46
61
  }
47
62
  </script>
@@ -52,6 +52,7 @@
52
52
  <script>
53
53
  import getJsonc from '../../assets/getJsonc'
54
54
  import realUrl from '../../assets/realUrl'
55
+ import axios from '../../utils/axios'
55
56
 
56
57
  import loginForm from './form.vue'
57
58
  import retrievePw from './retrievePw.vue'
@@ -84,46 +85,56 @@ export default {
84
85
  operateType: 'login'
85
86
  }
86
87
  },
87
- async created() {
88
+ created() {
88
89
  this.removeStorage()
89
- await this.init()
90
- this.setConfig()
90
+ this.init()
91
91
  },
92
92
  methods: {
93
- async init() {
94
- const { data } = await this.$axios.get(`/bems/1.0/sysSetting/list`)
95
- if (data) {
96
- this.getdata(data)
97
- this.getLogoImag()
98
- }
93
+ init() {
94
+ axios
95
+ .get(`/bems/1.0/sysSetting/list`, null, {
96
+ loading: false,
97
+ noMsg: true
98
+ })
99
+ .then(({ data }) => {
100
+ this.getdata(data)
101
+ })
102
+ .finally(() => {
103
+ this.setConfig()
104
+ })
105
+
106
+ this.getLogoImag()
99
107
  },
100
108
  async getLogoImag() {
101
- const login = await this.$axios.get(
102
- `/bems/1.0/attach/LOGIN_BACKGROUND_IMAGE`,
103
- {},
104
- { config: { responseType: 'arraybuffer' } }
105
- )
106
- this.BgImage = window.URL.createObjectURL(new Blob([login]))
107
- const company = await this.$axios.get(
108
- `/bems/1.0/attach/COMPANY_LOGOE`,
109
- {},
110
- {
111
- config: { responseType: 'arraybuffer' }
112
- }
113
- )
114
- this.LogoImage = window.URL.createObjectURL(new Blob([company]))
109
+ axios
110
+ .get(`/bems/1.0/attach/LOGIN_BACKGROUND_IMAGE`, null, {
111
+ responseType: 'blob',
112
+ loading: false,
113
+ noMsg: true
114
+ })
115
+ .then((blob) => {
116
+ this.BgImage = window.URL.createObjectURL(blob)
117
+ })
118
+ axios
119
+ .get(`/bems/1.0/attach/COMPANY_LOGOE`, null, {
120
+ responseType: 'blob',
121
+ loading: false,
122
+ noMsg: true
123
+ })
124
+ .then((blob) => {
125
+ this.LogoImage = window.URL.createObjectURL(blob)
126
+ })
115
127
  },
116
128
  getdata(list) {
117
- for (const i of list) {
118
- if (i.pmName == 'LOGIN_MODE') {
119
- this.LOGIN_MODE = i.pmValue.split(',')
120
- console.log(this.LOGIN_MODE)
121
- } else if (i.pmName == 'MAIN_PAGE_TEXT') {
122
- this.MAIN_PAGE_TEXT = i.pmValue
123
- } else if (i.pmName == 'SYSTEM_NAME') {
124
- this.SYSTEM_NAME = i.pmValue
129
+ list.forEach((item) => {
130
+ if (item.pmName === 'LOGIN_MODE') {
131
+ this.LOGIN_MODE = item.pmValue.split(',')
132
+ } else if (item.pmName === 'MAIN_PAGE_TEXT') {
133
+ this.MAIN_PAGE_TEXT = item.pmValue
134
+ } else if (item.pmName === 'SYSTEM_NAME') {
135
+ this.SYSTEM_NAME = item.pmValue
125
136
  }
126
- }
137
+ })
127
138
  },
128
139
  setConfig() {
129
140
  getJsonc('/server-config.jsonc').then(({ _layoutData = {} }) => {
@@ -63,6 +63,7 @@ export default {
63
63
  methods: {
64
64
  change(val) {
65
65
  this.$emit('input', val)
66
+ this.$emit('change', val)
66
67
  },
67
68
  lazyGet() {
68
69
  this.$emit('scroll-bottom')
@@ -5,7 +5,7 @@ directive.install = (Vue) => {
5
5
  bind: function (el, binding, node) {
6
6
  el.clickOutsideEvent = function (event) {
7
7
  if (!(el === event.target || el.contains(event.target))) {
8
- node.context[binding.expression](event)
8
+ binding.value(event)
9
9
  }
10
10
  }
11
11
  document.body.addEventListener('click', el.clickOutsideEvent, binding.arg === 'capture')