n20-common-lib 1.3.7 → 1.3.10

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": "1.3.7",
3
+ "version": "1.3.10",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -4,30 +4,30 @@
4
4
  <div class="flex">
5
5
  <div class="from">
6
6
  <el-input
7
- ref="input_left"
8
- v-model="value1"
9
- :disabled="disabled"
10
- placeholder="子票区间起"
11
- @blur="handleBlurleft"
12
- @focus="handleFocusLeft"
13
- @input="handleInputleft"
14
- @change="handleInputChangeLeft"
15
- ></el-input>
7
+ ref="input_left"
8
+ v-model="value1"
9
+ :disabled="disabled"
10
+ placeholder="子票区间起"
11
+ @blur="handleBlurleft"
12
+ @focus="handleFocusLeft"
13
+ @input="handleInputleft"
14
+ @change="handleInputChangeLeft"
15
+ />
16
16
  </div>
17
17
  <div class="center">
18
18
  <span> - </span>
19
19
  </div>
20
20
  <div class="to">
21
21
  <el-input
22
- ref="input_right"
23
- v-model="value2"
24
- :disabled="disabled"
25
- placeholder="子票区间止"
26
- @blur="handleBlurRight"
27
- @focus="handleFocusRight"
28
- @input="handleInputRight"
29
- @change="handleInputChangeRight"
30
- ></el-input>
22
+ ref="input_right"
23
+ v-model="value2"
24
+ :disabled="disabled"
25
+ placeholder="子票区间止"
26
+ @blur="handleBlurRight"
27
+ @focus="handleFocusRight"
28
+ @input="handleInputRight"
29
+ @change="handleInputChangeRight"
30
+ />
31
31
  </div>
32
32
  </div>
33
33
  </div>
@@ -36,7 +36,7 @@
36
36
 
37
37
  <script>
38
38
  export default {
39
- name: "ChildRange",
39
+ name: 'ChildRange',
40
40
  props: {
41
41
  // 初始化范围
42
42
  value: { required: true },
@@ -79,7 +79,7 @@ export default {
79
79
  toPrecision(num, precision) {
80
80
  if (precision === undefined) precision = 0
81
81
  return parseFloat(
82
- Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision)
82
+ Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision)
83
83
  )
84
84
  },
85
85
 
@@ -122,9 +122,9 @@ export default {
122
122
  // 如果from > to 将from值替换成to
123
123
  if (typeof this.value2 === 'number') {
124
124
  this.value1 =
125
- parseFloat(this.value1) <= parseFloat(this.value2)
126
- ? this.value1
127
- : this.value2
125
+ parseFloat(this.value1) <= parseFloat(this.value2)
126
+ ? this.value1
127
+ : this.value2
128
128
  }
129
129
  this.$emit('input', [this.value1, this.value2])
130
130
  this.$emit('changefrom', this.value1)
@@ -145,9 +145,9 @@ export default {
145
145
  // 如果to < tfrom 将to值替换成from
146
146
  if (typeof this.value1 === 'number') {
147
147
  this.value2 =
148
- parseFloat(this.value2) >= parseFloat(this.value1)
149
- ? this.value2
150
- : this.value1
148
+ parseFloat(this.value2) >= parseFloat(this.value1)
149
+ ? this.value2
150
+ : this.value1
151
151
  }
152
152
  this.$emit('input', [this.value1, this.value2])
153
153
  this.$emit('changeright', this.value2)
@@ -165,8 +165,7 @@ export default {
165
165
  }
166
166
  </script>
167
167
 
168
- <style lang="scss" scoped>
169
-
168
+ <style lang="less" scoped>
170
169
  .input-child-range {
171
170
  background-color: #fff;
172
171
  border: 1px solid #dcdfe6;
@@ -199,4 +198,4 @@ export default {
199
198
  color: #c0c4cc;
200
199
  cursor: not-allowed;
201
200
  }
202
- </style>
201
+ </style>
@@ -0,0 +1,201 @@
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>
13
+ </template>
14
+
15
+ <script>
16
+ import XLSX from 'xlsx'
17
+ import axios from '../../utils/axios'
18
+ 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
+ }
200
+ }
201
+ </script>
@@ -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>
@@ -24,7 +24,7 @@ export default {
24
24
  },
25
25
  content: String,
26
26
  disable: {
27
- type:Boolean,
27
+ type: Boolean,
28
28
  default: false
29
29
  },
30
30
  icon: {
@@ -32,23 +32,21 @@ export default {
32
32
  default: 'n20-icon-yuefenqiehuan-zuoce'
33
33
  }
34
34
  }
35
- };
35
+ }
36
36
  </script>
37
37
 
38
-
39
- <style lang="scss" scoped>
38
+ <style lang="less" scoped>
40
39
  .page-header {
41
40
  display: flex;
42
41
  line-height: 20px;
43
42
  padding-bottom: 2px;
44
- border-bottom: 1px solid rgba(0,0,0,0.10);
43
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
45
44
  .page-header__left {
46
45
  display: flex;
47
46
  align-items: center;
48
47
  cursor: pointer;
49
48
  margin-right: 16px;
50
49
  position: relative;
51
-
52
50
  }
53
51
  .page-header__left:hover {
54
52
  color: var(--color-primary);
@@ -57,7 +55,7 @@ export default {
57
55
  }
58
56
  }
59
57
  .page-header__left:after {
60
- content: "";
58
+ content: '';
61
59
  position: absolute;
62
60
  width: 1px;
63
61
  height: 16px;
@@ -69,12 +67,12 @@ export default {
69
67
  .page-header__title {
70
68
  font-size: 14px;
71
69
  line-height: 20px;
72
- color: #3D4A57;
70
+ color: #3d4a57;
73
71
  }
74
72
  .page-header__content {
75
73
  font-size: 14px;
76
74
  line-height: 20px;
77
- color: #3D4A57;
75
+ color: #3d4a57;
78
76
  }
79
77
  }
80
- </style>
78
+ </style>
@@ -496,7 +496,7 @@ export default {
496
496
  }
497
497
  </script>
498
498
 
499
- <style lang="scss">
499
+ <style lang="less">
500
500
  .n20-search__popper.el-popper[x-placement^='bottom'] {
501
501
  padding: 16px;
502
502
  }
@@ -11,33 +11,38 @@
11
11
  class="input-w"
12
12
  @keyup.enter.native="handleSearch"
13
13
  >
14
- <i slot="suffix" class="el-input__icon el-icon-search" @click="handleSearch"></i>
14
+ <i
15
+ slot="suffix"
16
+ class="el-input__icon el-icon-search"
17
+ @click="handleSearch"
18
+ ></i>
15
19
  </el-input>
16
20
 
17
- <div class="flex-column m-t-14">
18
- <el-checkbox
21
+ <div class="flex-column m-t-14">
22
+ <el-checkbox
19
23
  v-model="checkbox"
20
24
  :indeterminate="isIndeterminate"
21
25
  @change="checkboxChange"
22
26
  >{{ '全部' + '(' + this.thIndex.length + ')' }}</el-checkbox
23
27
  >
24
- <el-checkbox-group
25
- v-model="checkLists"
26
- class="flex-column"
27
- @change="handleCheckedCitiesChange"
28
- >
29
- <el-checkbox
30
- v-for="item in checkList[property]"
31
- :key="item"
32
- class="m-t-s"
33
- :label="item"
34
- >{{ item + '(' + countNum(item) + ')' }}</el-checkbox>
35
- </el-checkbox-group>
36
- </div>
37
- <div class="flex-box flex-c m-t-m">
38
- <el-button type="primary" @click="confirm">确认</el-button>
39
- <el-button plain @click="reset">清空</el-button>
40
- </div>
28
+ <el-checkbox-group
29
+ v-model="checkLists"
30
+ class="flex-column"
31
+ @change="handleCheckedCitiesChange"
32
+ >
33
+ <el-checkbox
34
+ v-for="item in checkList[property]"
35
+ :key="item"
36
+ class="m-t-s"
37
+ :label="item"
38
+ >{{ item + '(' + countNum(item) + ')' }}</el-checkbox
39
+ >
40
+ </el-checkbox-group>
41
+ </div>
42
+ <div class="flex-box flex-c m-t-m">
43
+ <el-button type="primary" @click="confirm">确认</el-button>
44
+ <el-button plain @click="reset">清空</el-button>
45
+ </div>
41
46
  <i slot="reference" class="el-icon-arrow-down"></i>
42
47
  </el-popover>
43
48
  </template>
@@ -69,7 +74,7 @@ export default {
69
74
  return {
70
75
  value: '',
71
76
  checkLists: [],
72
- list:[],
77
+ list: [],
73
78
  checkbox: false,
74
79
  isIndeterminate: true
75
80
  }
@@ -88,12 +93,11 @@ export default {
88
93
  if (!this.value) {
89
94
  this.checkList[this.property] = this.list
90
95
  } else {
91
- this.checkList[this.property] = this.list.filter(v => {
96
+ this.checkList[this.property] = this.list.filter((v) => {
92
97
  return v.indexOf(this.value) !== -1
93
98
  })
94
99
  }
95
100
  this.$forceUpdate()
96
-
97
101
  },
98
102
  reset() {
99
103
  this.value = ''
@@ -123,7 +127,7 @@ export default {
123
127
  }
124
128
  </script>
125
129
 
126
- <style lang="scss">
130
+ <style lang="less">
127
131
  .table-header-popover.el-popover {
128
132
  padding: 16px;
129
133
  }