n20-common-lib 1.3.33 → 1.3.36

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.
@@ -169,8 +169,12 @@ export default {
169
169
  }
170
170
  }
171
171
  }
172
- /deep/.el-table td,
173
- .el-table th {
174
- padding: 2px;
172
+ .el-table {
173
+ ::v-deep {
174
+ td,
175
+ th {
176
+ padding: 2px;
177
+ }
178
+ }
175
179
  }
176
180
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "1.3.33",
3
+ "version": "1.3.36",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
1
  .el-button--primary,
2
2
  .el-button--default,
3
3
  .el-button--default.is-plain,
4
- .el-button--warning.is-plain {
4
+ .el-button--warning.is-plain,
5
+ .el-button--danger.is-plain {
5
6
  min-width: 72px;
6
7
  }
7
8
 
@@ -402,7 +402,7 @@ export default {
402
402
  }
403
403
 
404
404
  let { getSign } = await import('../../plugins/Sign')
405
- sign = await getSign(username, userDn)
405
+ sign = await getSign(username + userDn, userDn)
406
406
  certDn = userDn
407
407
  }
408
408
  await this.authorizationCode(username, password, code) // authorizationValue 使用一次后就失效了
@@ -1,12 +1,14 @@
1
1
  <template>
2
2
  <div
3
3
  class="login-wrap"
4
- :style="{ backgroundImage: loginBg && `url(${loginBg})` }"
4
+ :style="{
5
+ backgroundImage: BgImage ? `url(${BgImage})` : `url(${loginBg})`
6
+ }"
5
7
  >
6
8
  <div class="login-logo-box flex-box flex-v">
7
9
  <img
8
10
  v-if="loginLogo"
9
- :src="loginLogo"
11
+ :src="LogoImage || loginLogo"
10
12
  :style="{ width: loginLogoWidth, height: loginLogoHeight }"
11
13
  />
12
14
  <span
@@ -14,14 +16,14 @@
14
16
  class="login-logo-hr m-l-s m-r-s"
15
17
  ></span>
16
18
  <h3 class="login-logo-text">
17
- {{ loginLogoText }}
19
+ {{ SYSTEM_NAME || loginLogoText }}
18
20
  </h3>
19
21
  </div>
20
22
  <!-- eslint-disable-next-line vue/no-v-html -->
21
23
  <div doc="登录页标语" v-html="sloganHtml"></div>
22
24
  <loginForm
23
25
  v-if="operateType === 'login'"
24
- :login-types="loginTypes"
26
+ :login-types="LOGIN_MODE || loginTypes"
25
27
  :login-then="loginThen"
26
28
  class="login-form"
27
29
  @changType="getChangetype"
@@ -68,6 +70,11 @@ export default {
68
70
  data() {
69
71
  return {
70
72
  loginTypes: ['account'],
73
+ LOGIN_MODE: ['account'],
74
+ MAIN_PAGE_TEXT: '',
75
+ SYSTEM_NAME: '',
76
+ BgImage: '',
77
+ LogoImage: '',
71
78
  loginBg: undefined,
72
79
  loginLogo: undefined,
73
80
  loginLogoWidth: '60px',
@@ -77,11 +84,47 @@ export default {
77
84
  operateType: 'login'
78
85
  }
79
86
  },
80
- created() {
87
+ async created() {
81
88
  this.removeStorage()
89
+ await this.init()
82
90
  this.setConfig()
83
91
  },
84
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
+ }
99
+ },
100
+ 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]))
115
+ },
116
+ 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
125
+ }
126
+ }
127
+ },
85
128
  setConfig() {
86
129
  getJsonc('/server-config.jsonc').then(({ _layoutData = {} }) => {
87
130
  _layoutData.loginTypes && (this.loginTypes = _layoutData.loginTypes)
@@ -8,10 +8,10 @@ directive.install = (Vue) => {
8
8
  node.context[binding.expression](event)
9
9
  }
10
10
  }
11
- document.body.addEventListener('click', el.clickOutsideEvent)
11
+ document.body.addEventListener('click', el.clickOutsideEvent, binding.arg === 'capture')
12
12
  },
13
- unbind: function (el) {
14
- document.body.removeEventListener('click', el.clickOutsideEvent)
13
+ unbind: function (el, binding) {
14
+ document.body.removeEventListener('click', el.clickOutsideEvent, binding.arg === 'capture')
15
15
  }
16
16
  })
17
17
  }
@@ -0,0 +1,10 @@
1
+ const directive = {}
2
+ directive.install = (Vue) => {
3
+ Vue.directive('rules', {
4
+ bind(el, binding, vnode) {},
5
+ update(el, binding) {},
6
+ unbind(el, binding) {}
7
+ })
8
+ }
9
+
10
+ export default directive
@@ -104,21 +104,26 @@ export async function getSign(plain, dn) {
104
104
  /**
105
105
  * 签名
106
106
  */
107
- let v_retVal
107
+ let v_retVal, cert
108
108
  let val = s_retVal.filter((v) => v.retVal === dn)
109
- let cert = r_retVal.filter((s) => s.certId === val[0].certId)
110
- await new Promise((resolve, reject) => {
111
- window.SOF_SignData(val[0].certId, plainText + '' + dn, (v) => {
112
- if (v.retVal) {
113
- v_retVal = v.retVal
114
- resolve()
115
- } else {
116
- errMsg = '签名失败!'
117
- Message.error(errMsg)
118
- reject(errMsg)
119
- }
109
+ if (val.length > 0) {
110
+ cert = r_retVal.filter((s) => s.certId === val[0].certId)
111
+ await new Promise((resolve, reject) => {
112
+ window.SOF_SignData(val[0].certId, plainText, (v) => {
113
+ if (v.retVal) {
114
+ v_retVal = v.retVal
115
+ resolve()
116
+ } else {
117
+ errMsg = '签名失败!'
118
+ Message.error(errMsg)
119
+ reject(errMsg)
120
+ }
121
+ })
120
122
  })
121
- })
122
-
123
- return Promise.resolve(v_retVal + '@@@' + cert[0].retVal)
123
+ return Promise.resolve(v_retVal + '@@@' + cert[0].retVal)
124
+ } else {
125
+ errMsg = '参数dn信息不批匹配!'
126
+ Message.error(errMsg)
127
+ return Promise.reject(errMsg)
128
+ }
124
129
  }
@@ -1,6 +1,19 @@
1
1
  /* 对ElementUI硬优化 */
2
2
  import Popper from 'element-ui/lib/utils/popper.js'
3
3
 
4
+ import Vue from 'vue'
5
+ import FilterPanel from './tableheaderFilterpanel.vue'
6
+
7
+ function hasClass(el, cls) {
8
+ if (!el || !cls) return false
9
+ if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.')
10
+ if (el.classList) {
11
+ return el.classList.contains(cls)
12
+ } else {
13
+ return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1
14
+ }
15
+ }
16
+
4
17
  function setPropsDefault(component, props) {
5
18
  let c_props = component.props
6
19
  Object.keys(props).forEach((key) => {
@@ -69,7 +82,7 @@ export default function (ElementUI) {
69
82
  default: true
70
83
  }
71
84
  })
72
-
85
+ // 设置表头最小宽度,保证表头不换行
73
86
  setMethodsDefault(ElementUI.TableColumn, {
74
87
  setColumnWidth(column) {
75
88
  if (this.realWidth) {
@@ -92,4 +105,41 @@ export default function (ElementUI) {
92
105
  return column
93
106
  }
94
107
  })
108
+
109
+ // 美化表头搜索
110
+ if (ElementUI.Table.components.TableHeader) {
111
+ setMethodsDefault(ElementUI.Table.components.TableHeader, {
112
+ handleFilterClick(event, column) {
113
+ event.stopPropagation()
114
+ const target = event.target
115
+ let cell = target.tagName === 'TH' ? target : target.parentNode
116
+ if (hasClass(cell, 'noclick')) return
117
+ cell = cell.querySelector('.el-table__column-filter-trigger') || cell
118
+ const table = this.$parent
119
+
120
+ let filterPanel = this.filterPanels[column.id]
121
+
122
+ if (filterPanel && column.filterOpened) {
123
+ filterPanel.showPopper = false
124
+ return
125
+ }
126
+
127
+ if (!filterPanel) {
128
+ filterPanel = new Vue(FilterPanel)
129
+ this.filterPanels[column.id] = filterPanel
130
+ if (column.filterPlacement) {
131
+ filterPanel.placement = column.filterPlacement
132
+ }
133
+ filterPanel.table = table
134
+ filterPanel.cell = cell
135
+ filterPanel.column = column
136
+ !this.$isServer && filterPanel.$mount(document.createElement('div'))
137
+ }
138
+
139
+ setTimeout(() => {
140
+ filterPanel.showPopper = true
141
+ }, 16)
142
+ }
143
+ })
144
+ }
95
145
  }
@@ -0,0 +1,249 @@
1
+ <template>
2
+ <transition name="el-zoom-in-top">
3
+ <div
4
+ v-if="multiple"
5
+ v-show="showPopper"
6
+ v-click-outside:capture="handleOutsideClick"
7
+ class="el-table-filter p-a m-t"
8
+ >
9
+ <el-input
10
+ v-model="searchVal"
11
+ class="input-w m-b"
12
+ placeholder="请输入"
13
+ clearable
14
+ suffix-icon="el-icon-search"
15
+ />
16
+ <div>
17
+ <el-scrollbar>
18
+ <el-checkbox
19
+ v-model="allCheck"
20
+ :label="true"
21
+ :indeterminate="filteredValue.length > 0"
22
+ @change="allChange"
23
+ >{{ filters | alltextF }}</el-checkbox
24
+ >
25
+ <el-checkbox-group v-model="filteredValue" class="flex-column">
26
+ <template v-for="filter in filters">
27
+ <el-checkbox
28
+ v-if="filter.text.includes(searchVal)"
29
+ :key="filter.value"
30
+ class="m-t-s"
31
+ :label="filter.value"
32
+ >{{ filter | textF }}</el-checkbox
33
+ >
34
+ </template>
35
+ </el-checkbox-group>
36
+ </el-scrollbar>
37
+ </div>
38
+ <div class="flex-box flex-c m-t-m">
39
+ <el-button
40
+ type="primary"
41
+ size="mini"
42
+ @click="
43
+ () => {
44
+ filteredValue.length ? handleConfirm() : handleReset()
45
+ }
46
+ "
47
+ >
48
+ 确认
49
+ </el-button>
50
+ <el-button plain size="mini" @click="handleReset">清空</el-button>
51
+ </div>
52
+ </div>
53
+ <div
54
+ v-else
55
+ v-show="showPopper"
56
+ v-click-outside:capture="handleOutsideClick"
57
+ class="el-table-filter p-a m-t"
58
+ >
59
+ <el-input
60
+ v-model="searchVal"
61
+ class="input-w m-b-ss"
62
+ placeholder="请输入"
63
+ clearable
64
+ suffix-icon="el-icon-search"
65
+ />
66
+ <ul class="el-table-filter__list">
67
+ <li
68
+ class="el-table-filter__list-item"
69
+ :class="{
70
+ 'is-active': filterValue === undefined || filterValue === null
71
+ }"
72
+ @click="handleSelect(null)"
73
+ >
74
+ {{ filters | alltextF }}
75
+ </li>
76
+ <template v-for="filter in filters">
77
+ <li
78
+ v-if="filter.text.includes(searchVal)"
79
+ :key="filter.value"
80
+ class="el-table-filter__list-item"
81
+ :label="filter.value"
82
+ :class="{ 'is-active': isActive(filter) }"
83
+ @click="handleSelect(filter.value)"
84
+ >
85
+ {{ filter | textF }}
86
+ </li>
87
+ </template>
88
+ </ul>
89
+ </div>
90
+ </transition>
91
+ </template>
92
+
93
+ <script>
94
+ import Popper from 'element-ui/lib/utils/vue-popper.js'
95
+ export default {
96
+ name: 'ElTableFilterPanelPor',
97
+ filters: {
98
+ textF(item) {
99
+ if (item.count === undefined) {
100
+ return item.text
101
+ } else {
102
+ return item.text + ' (' + item.count + ')'
103
+ }
104
+ },
105
+ alltextF(list = []) {
106
+ if (list.some((c) => c.count !== undefined)) {
107
+ let total = 0
108
+ list.forEach((c) => {
109
+ if (!isNaN(c.count)) {
110
+ total = total + Number(c.count)
111
+ }
112
+ })
113
+ return '全部 (' + total + ')'
114
+ } else {
115
+ return '全部'
116
+ }
117
+ }
118
+ },
119
+ mixins: [Popper],
120
+ props: {
121
+ placement: {
122
+ type: String,
123
+ default: 'bottom-end'
124
+ }
125
+ },
126
+
127
+ data() {
128
+ return {
129
+ table: null,
130
+ cell: null,
131
+ column: null,
132
+ searchVal: '',
133
+ allCheck: false
134
+ }
135
+ },
136
+
137
+ computed: {
138
+ filters() {
139
+ return this.column && this.column.filters
140
+ },
141
+
142
+ filterValue: {
143
+ get() {
144
+ return (this.column.filteredValue || [])[0]
145
+ },
146
+ set(value) {
147
+ if (this.filteredValue) {
148
+ console.log(this.filteredValue, 567)
149
+ if (typeof value !== 'undefined' && value !== null) {
150
+ this.filteredValue.splice(0, 1, value)
151
+ } else {
152
+ this.filteredValue.splice(0, 1)
153
+ }
154
+ }
155
+ }
156
+ },
157
+
158
+ filteredValue: {
159
+ get() {
160
+ if (this.column) {
161
+ return this.column.filteredValue || []
162
+ }
163
+ return []
164
+ },
165
+ set(value) {
166
+ if (this.column) {
167
+ this.column.filteredValue = value
168
+ }
169
+ }
170
+ },
171
+
172
+ multiple() {
173
+ if (this.column) {
174
+ return this.column.filterMultiple
175
+ }
176
+ return true
177
+ }
178
+ },
179
+
180
+ mounted() {
181
+ this.popperElm = this.$el
182
+ this.referenceElm = this.cell
183
+ this.table.bodyWrapper.addEventListener('scroll', () => {
184
+ this.updatePopper()
185
+ })
186
+
187
+ this.$watch('showPopper', (value) => {
188
+ if (this.column) this.column.filterOpened = value
189
+ if (value) this.searchVal = ''
190
+ // if (value) {
191
+ // Dropdown.open(this)
192
+ // } else {
193
+ // Dropdown.close(this)
194
+ // }
195
+ })
196
+ },
197
+
198
+ methods: {
199
+ isActive(filter) {
200
+ return filter.value === this.filterValue
201
+ },
202
+
203
+ handleOutsideClick() {
204
+ setTimeout(() => {
205
+ this.showPopper = false
206
+ }, 16)
207
+ },
208
+
209
+ handleConfirm() {
210
+ this.confirmFilter(this.filteredValue)
211
+ this.handleOutsideClick()
212
+ },
213
+
214
+ handleReset() {
215
+ this.filteredValue = []
216
+ this.confirmFilter(this.filteredValue)
217
+ this.handleOutsideClick()
218
+ },
219
+
220
+ handleSelect(filterValue) {
221
+ this.filterValue = filterValue
222
+
223
+ if (typeof filterValue !== 'undefined' && filterValue !== null) {
224
+ this.confirmFilter(this.filteredValue)
225
+ } else {
226
+ this.confirmFilter([])
227
+ }
228
+
229
+ this.handleOutsideClick()
230
+ },
231
+
232
+ confirmFilter(filteredValue) {
233
+ this.table.store.commit('filterChange', {
234
+ column: this.column,
235
+ values: filteredValue
236
+ })
237
+ this.table.store.updateAllSelected()
238
+ },
239
+
240
+ allChange(val) {
241
+ if (val) {
242
+ this.filteredValue = this.filters.map((f) => f.value)
243
+ } else {
244
+ this.filteredValue = []
245
+ }
246
+ }
247
+ }
248
+ }
249
+ </script>
@@ -1,6 +1,10 @@
1
1
  import ExcelJS from 'exceljs'
2
2
 
3
- function toExcel({ columns = [], rows = [], name = 'sheet01' }) {
3
+ export default function toExcel({ columns = [], rows = [], name = 'sheet01' }) {
4
+ // 创建工作簿
5
+ const workbook = new ExcelJS.Workbook()
6
+ // 创建工作表
7
+ const worksheet = workbook.addWorksheet(name)
4
8
  let cols = []
5
9
  columns.forEach((col) => {
6
10
  if (!col.static) {
@@ -32,9 +36,6 @@ function toExcel({ columns = [], rows = [], name = 'sheet01' }) {
32
36
  let cL = cols.length
33
37
  let rL = rows.length
34
38
 
35
- const workbook = new ExcelJS.Workbook()
36
- const worksheet = workbook.addWorksheet(name)
37
-
38
39
  worksheet.columns = cols
39
40
  worksheet.addRows(rows)
40
41
 
@@ -89,27 +90,6 @@ function toExcel({ columns = [], rows = [], name = 'sheet01' }) {
89
90
  })
90
91
  })
91
92
  }
92
- export default toExcel
93
93
 
94
- export function toJson(file, name) {
95
- const workbook = new ExcelJS.Workbook()
96
- return new Promise((resolve, reject) => {
97
- workbook.xlsx
98
- .load(file)
99
- .then(() => {
100
- const worksheet = workbook.getWorksheet(name || 1)
101
- let rows = []
102
- worksheet.eachRow((r) => {
103
- let row = []
104
- r.eachCell((c) => {
105
- row.push(c.value)
106
- })
107
- rows.push(row)
108
- })
109
- resolve(rows)
110
- })
111
- .catch((err) => {
112
- reject(err)
113
- })
114
- })
115
- }
94
+ import xlsx2json from './xlsx2json.js'
95
+ export const toJson = xlsx2json
@@ -0,0 +1,40 @@
1
+ import { read, utils } from 'xlsx'
2
+
3
+ export default function toJson(file, name) {
4
+ let pro = new Promise((resolve, reject) => {
5
+ if (file instanceof Blob) {
6
+ file.arrayBuffer().then((array) => {
7
+ try {
8
+ const workbook = read(array, { type: 'array', cellDates: true })
9
+ resolve(workbook)
10
+ } catch (err) {
11
+ reject(err)
12
+ }
13
+ })
14
+ } else if (file instanceof ArrayBuffer) {
15
+ try {
16
+ const workbook = read(array, { type: 'array', cellDates: true })
17
+ resolve(workbook)
18
+ } catch (err) {
19
+ reject(err)
20
+ }
21
+ }
22
+ })
23
+
24
+ return pro.then((workbook) => {
25
+ let sheetName = workbook.SheetNames[name || 0]
26
+ let workSheet = workbook.Sheets[sheetName]
27
+ let rows = []
28
+ let cols = utils.sheet_to_csv(workSheet).split('\n')[0].split(',')
29
+ rows.push(cols)
30
+ let rowsc = utils.sheet_to_json(workSheet)
31
+ rowsc.forEach((r) => {
32
+ let row = []
33
+ cols.forEach((c) => {
34
+ row.push(r[c])
35
+ })
36
+ rows.push(row)
37
+ })
38
+ return Promise.resolve(rows)
39
+ })
40
+ }
@@ -0,0 +1,24 @@
1
+ import ExcelJS from 'exceljs'
2
+
3
+ export default function toJson(file, name) {
4
+ const workbook = new ExcelJS.Workbook()
5
+ return new Promise((resolve, reject) => {
6
+ workbook.xlsx
7
+ .load(file)
8
+ .then(() => {
9
+ const worksheet = workbook.getWorksheet(name || 1)
10
+ let rows = []
11
+ worksheet.eachRow((r) => {
12
+ let row = []
13
+ r.eachCell((c) => {
14
+ row.push(c.value)
15
+ })
16
+ rows.push(row)
17
+ })
18
+ resolve(rows)
19
+ })
20
+ .catch((err) => {
21
+ reject(err)
22
+ })
23
+ })
24
+ }