n20-common-lib 1.3.32 → 1.3.35

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.32",
3
+ "version": "1.3.35",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <div>
3
+ <div ref="ad">
4
+ <el-card class="box-card" :header="header">
5
+ <cB />
6
+ <p>这里的传值,是只依赖DOM结构,利用自定义事件/事件冒泡实现值得传递</p>
7
+ </el-card>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ import cB from './b.vue'
14
+ export default {
15
+ components: { cB },
16
+ data() {
17
+ return {
18
+ header: ''
19
+ }
20
+ },
21
+ mounted() {
22
+ this.$refs['ad'].addEventListener('demoEv', (event) => {
23
+ event.stopPropagation()
24
+ const cD = event.target.customData
25
+ this.header = cD.title
26
+ })
27
+ }
28
+ }
29
+ </script>
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <div>
3
+ <cC />
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import cC from './c.vue'
9
+ export default {
10
+ components: { cC }
11
+ }
12
+ </script>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <div class="flex-box flex-v">
3
+ <label>标题</label><el-input class="flex-item m-l" v-model="title" />
4
+ <EventBubble :data-custom="{ title: title }" data-event="demoEv" />
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+ import EventBubble from '../index.vue'
10
+ export default {
11
+ components: { EventBubble },
12
+ data() {
13
+ return {
14
+ title: '默认标题'
15
+ }
16
+ }
17
+ }
18
+ </script>
@@ -4,8 +4,8 @@
4
4
 
5
5
  <script>
6
6
  // 触发自定义冒泡事假
7
- // XXX:还差iframe的处理
8
7
  export default {
8
+ name: 'EventBubble',
9
9
  props: {
10
10
  dataCustom: {
11
11
  type: Object,
@@ -25,7 +25,9 @@ export default {
25
25
  }
26
26
  },
27
27
  mounted() {
28
- this.setData(this.dataCustom)
28
+ this.$nextTick(() => {
29
+ this.setData(this.dataCustom)
30
+ })
29
31
  },
30
32
  methods: {
31
33
  setData(obj) {
@@ -42,11 +44,14 @@ function dispatchEvent(el, type) {
42
44
  var evEvent = undefined
43
45
 
44
46
  if (!window[evName]) {
45
- evEvent = document.createEvent('Event')
46
- evEvent.initEvent(type, true, false)
47
+ evEvent = new CustomEvent(type, { bubbles: true, cancelable: false })
47
48
  window[evName] = evEvent
48
49
  }
49
50
 
50
51
  el.dispatchEvent(window[evName])
52
+ // iframe is not target
53
+ // if (el.nodeName !== 'IFRAME' && window.frameElement) {
54
+ // dispatchEvent(window.frameElement, type)
55
+ // }
51
56
  }
52
57
  </script>
@@ -168,7 +168,7 @@ export default {
168
168
  }
169
169
  },
170
170
  inputFn({ target }) {
171
- if (isNaN(target.value)) {
171
+ if (target.value !== '-' && isNaN(target.value)) {
172
172
  target.value = this.preValue
173
173
  } else {
174
174
  this.preValue = target.value
@@ -179,6 +179,7 @@
179
179
  </template>
180
180
 
181
181
  <script>
182
+ import Cookies from 'js-cookie'
182
183
  import { themeList } from '../../../utils/theme.config.js'
183
184
 
184
185
  import dialogWrap from '../../Dialog/index.vue'
@@ -229,7 +230,7 @@ const i18n = {
229
230
  en: ':'
230
231
  },
231
232
  秒: {
232
- en: ':'
233
+ en: ''
233
234
  },
234
235
  '确定退出,将清除未提交的临时操作,是否继续?': {
235
236
  en: 'Are you sure to exit? Uncommitted temporary operations will be cleared. Do you want to continue?'
@@ -299,23 +300,35 @@ export default {
299
300
  },
300
301
  setUserVisible(v) {
301
302
  if (v) {
302
- let loginTime = sessionStorage.getItem('loginTime')
303
- if (loginTime) {
304
- this.durationTime = dayjs.duration(Date.now() - loginTime).format(
305
- `HH${this.$l('小时', this.i18n)}
306
- mm${this.$l('分', this.i18n)}
307
- ss${this.$l('秒', this.i18n)}`
308
- )
309
- }
310
-
311
303
  let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
312
304
  this.userInfo = {
313
305
  userName: userInfo.uname,
314
306
  companyName: userInfo.cltName
315
307
  }
316
308
  this.rolesList = userInfo.roles || []
309
+
310
+ let loginTime = sessionStorage.getItem('loginTime')
311
+ if (loginTime) {
312
+ this.setDurationTime(loginTime)
313
+ this.durationTime_timeout = setInterval(
314
+ () => this.setDurationTime(loginTime),
315
+ 500
316
+ )
317
+ }
318
+ } else {
319
+ clearInterval(this.durationTime_timeout)
317
320
  }
318
321
  },
322
+ setDurationTime(loginTime) {
323
+ this.durationTime = dayjs
324
+ .duration(Date.now() - loginTime)
325
+ .format(
326
+ `HH${this.$l('小时', this.i18n)}mm${this.$l(
327
+ '分',
328
+ this.i18n
329
+ )}ss${this.$l('秒', this.i18n)}`
330
+ )
331
+ },
319
332
  // 打开帮助文档
320
333
  openHelp() {
321
334
  axios
@@ -357,6 +370,10 @@ export default {
357
370
  setLang() {
358
371
  this.langV = false
359
372
  window.localStorage.setItem('pageLang', this.langVal)
373
+ Cookies.set(
374
+ 'language',
375
+ ['zh-cn', 'zh-hk'].includes(this.langVal) ? 'zh' : this.langVal
376
+ )
360
377
  window.location.reload()
361
378
  },
362
379
  setTheme({ value }) {
@@ -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)
@@ -1,8 +1,9 @@
1
- .page-header {
1
+ .n20-page-header {
2
2
  display: flex;
3
3
  line-height: 20px;
4
4
  padding-bottom: 2px;
5
5
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
6
+
6
7
  .page-header__left {
7
8
  display: flex;
8
9
  align-items: center;
@@ -10,12 +11,15 @@
10
11
  margin-right: 16px;
11
12
  position: relative;
12
13
  }
14
+
13
15
  .page-header__left:hover {
14
16
  color: var(--color-primary);
17
+
15
18
  .page-header__title {
16
19
  color: var(--color-primary);
17
20
  }
18
21
  }
22
+
19
23
  .page-header__left:after {
20
24
  content: '';
21
25
  position: absolute;
@@ -26,14 +30,16 @@
26
30
  transform: translateY(-50%);
27
31
  background-color: #dcdfe6;
28
32
  }
33
+
29
34
  .page-header__title {
30
35
  font-size: 14px;
31
36
  line-height: 20px;
32
37
  color: #3d4a57;
33
38
  }
39
+
34
40
  .page-header__content {
35
41
  font-size: 14px;
36
42
  line-height: 20px;
37
43
  color: #3d4a57;
38
44
  }
39
- }
45
+ }
package/src/index.js CHANGED
@@ -48,10 +48,11 @@ import FlowStep from './components/FlowStep/index.vue'
48
48
  import CascaderArea from './components/CascaderArea/index.vue'
49
49
  import FileExportAsync from './components/FileExportAsync/index.vue'
50
50
  import FlowDialog from './components/ApprovalRecord/flowDialog.vue'
51
- import ChildRange from './components/ChildRange/index'
52
- import FileImport from './components/FileImport/index'
53
- import PageHeader from './components/PageHeader/index'
54
- import Descriptions from './components/Descriptions'
51
+ import ChildRange from './components/ChildRange/index.vue'
52
+ import FileImport from './components/FileImport/index.vue'
53
+ import PageHeader from './components/PageHeader/index.vue'
54
+ import Descriptions from './components/Descriptions/index.vue'
55
+ import EventBubble from './components/EventBubble/index.vue'
55
56
  // ECharts 不要打包进来
56
57
  // import Search from './components/Search/index.vue'
57
58
  import Stamp from './components/Stamp/index.vue'
@@ -142,6 +143,7 @@ const components = [
142
143
  FileImport,
143
144
  PageHeader,
144
145
  Descriptions,
146
+ EventBubble,
145
147
  // Search,
146
148
  approvalImg,
147
149
  Stamp,
@@ -154,6 +156,8 @@ const components = [
154
156
  const install = function (Vue, opts = { prefix: 'Cl', i18nConfig: {} }) {
155
157
  components.forEach((component) => {
156
158
  let name = component.name
159
+ if (!name) return console.error('Component name is required:', component)
160
+
157
161
  name = opts.prefix + name.replace(name[0], name[0].toUpperCase())
158
162
  Vue.component(name, component)
159
163
  })
@@ -251,6 +255,7 @@ export {
251
255
  FileImport,
252
256
  PageHeader,
253
257
  Descriptions,
258
+ EventBubble,
254
259
  // Search,
255
260
  approvalImg,
256
261
  Stamp
@@ -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
  }
package/src/utils/auth.js CHANGED
@@ -29,6 +29,7 @@ const auth = {
29
29
  },
30
30
  setLoginPath(router) {
31
31
  let { base = '/', mode = 'history' } = router.options
32
+ ;/\/$/.test(base) || (base += '/')
32
33
  if (mode === 'hash') {
33
34
  ownLoginPath = window.location.origin + base + '#/login'
34
35
  } else {
@@ -17,7 +17,7 @@ export function $l(zh, map = {}) {
17
17
  } else {
18
18
  let key = pageLang
19
19
  let valMap = map[zh] || $i18n_map_root[zh] || {}
20
- let val = valMap[key] || zh
20
+ let val = valMap[key] !== undefined ? valMap[key] : zh
21
21
 
22
22
  return val
23
23
  }
@@ -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,4 +90,6 @@ function toExcel({ columns = [], rows = [], name = 'sheet01' }) {
89
90
  })
90
91
  })
91
92
  }
92
- export default toExcel
93
+
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
+ }