vue2-client 1.8.0-7 → 1.8.0-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": "vue2-client",
3
- "version": "1.8.0-7",
3
+ "version": "1.8.0-9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
@@ -82,6 +82,7 @@
82
82
  "browserslist": [
83
83
  "> 1%",
84
84
  "last 2 versions",
85
- "not ie <= 10"
85
+ "not dead",
86
+ "not ie 11"
86
87
  ]
87
88
  }
@@ -680,7 +680,7 @@ export default {
680
680
  // 编辑数据字段前准备数据
681
681
  editColumnItemExecute (_item) {
682
682
  this.type = '修改'
683
- const defaultValue = { formType: 'input', type: 'string', addOrEdit: 'all', slot: { type: 'default' }, rule: {}, selectKey: {} }
683
+ const defaultValue = { formType: 'input', type: 'string', addOrEdit: 'all', slot: { type: 'default' }, rule: {}, selectKey: {}, column: [] }
684
684
  if (!_item.queryType) {
685
685
  defaultValue.queryType = '='
686
686
  }
@@ -9,7 +9,11 @@
9
9
  okText="提交"
10
10
  @cancel="close"
11
11
  @ok="$refs.nativeForm.onSubmit()">
12
- <x-add-native-form ref="nativeForm" @onSubmit="onSubmit" @tempTableModify="tempTableModify"/>
12
+ <x-add-native-form
13
+ ref="nativeForm"
14
+ @afterSubmit="afterSubmit"
15
+ @onSubmit="onSubmit"
16
+ @tempTableModify="tempTableModify"/>
13
17
  </a-modal>
14
18
  </template>
15
19
  <script>
@@ -43,6 +47,7 @@ export default {
43
47
  },
44
48
  methods: {
45
49
  init (params) {
50
+ params.showSubmitBtn = false
46
51
  const {
47
52
  businessType, title
48
53
  } = params
@@ -50,7 +55,7 @@ export default {
50
55
  this.title = title
51
56
  this.visible = true
52
57
  const that = this
53
- that.$nextTick(function () {
58
+ that.$nextTick(() => {
54
59
  that.$refs.nativeForm.init(params)
55
60
  })
56
61
  },
@@ -60,9 +65,20 @@ export default {
60
65
  },
61
66
  onSubmit (params) {
62
67
  this.loading = true
63
- this.$emit('onSubmit', params, () => {
64
- this.close()
65
- })
68
+ if (this.$listeners.onSubmit) {
69
+ // 交由父级处理
70
+ this.$emit('onSubmit', params, () => {
71
+ this.close()
72
+ })
73
+ } else {
74
+ // 触发默认提交事件
75
+ this.$refs.nativeForm.defaultSubmit(params.realForm, () => {
76
+ this.close()
77
+ })
78
+ }
79
+ },
80
+ afterSubmit (params) {
81
+ this.$emit('afterSubmit', params)
66
82
  },
67
83
  tempTableModify (params) {
68
84
  this.$emit('tempTableModify', params)
@@ -1,63 +1,66 @@
1
1
  <template>
2
- <a-form-model
3
- v-if="loaded"
4
- ref="selectForm"
5
- :zIndex="1001"
6
- :model="form"
7
- :rules="rules">
8
- <a-row :gutter="16">
9
- <x-form-item
10
- v-for="(item, index) in realJsonData"
11
- :key="index"
12
- :attr="item"
13
- :disabled="itemDisabled(item)"
14
- :files="files"
15
- :form="form"
16
- :images="images"
17
- :service-name="serviceName"
18
- mode="新增/修改"
19
- :get-data-params="getDataParams"
20
- />
21
- </a-row>
22
- <a-row :gutter="16" v-for="(groupItem, groupIndex) in groupJsonData" :key="groupIndex">
23
- <a-card :title="groupItem.name" :bordered="false" size="small">
2
+ <div>
3
+ <a-form-model
4
+ v-if="loaded"
5
+ ref="selectForm"
6
+ :zIndex="1001"
7
+ :model="form"
8
+ :rules="rules">
9
+ <a-row :gutter="16">
24
10
  <x-form-item
25
- v-for="(item, index) in groupItem.groupItems"
11
+ v-for="(item, index) in realJsonData"
26
12
  :key="index"
27
13
  :attr="item"
28
14
  :disabled="itemDisabled(item)"
29
15
  :files="files"
30
- :form="form[groupItem.model]"
31
- :images="images"
32
- :service-name="serviceName"
33
- mode="新增/修改"
34
- :get-data-params="getDataParams"
35
- />
36
- </a-card>
37
- </a-row>
38
- <a-row :gutter="16" v-for="(item, key) in simpleFormJsonData" :key="'row' + key">
39
- <a-card :title="item.name" :bordered="false" size="small">
40
- <x-form-item
41
- v-for="(formItem, formItemIndex) in item.value"
42
- :key="key + formItemIndex"
43
- :attr="formItem"
44
- :disabled="itemDisabled(formItem)"
45
- :files="files"
46
16
  :form="form"
47
17
  :images="images"
48
18
  :service-name="serviceName"
49
19
  mode="新增/修改"
50
20
  :get-data-params="getDataParams"
51
21
  />
52
- </a-card>
53
- </a-row>
54
- </a-form-model>
22
+ </a-row>
23
+ <a-row :gutter="16" v-for="(groupItem, groupIndex) in groupJsonData" :key="groupIndex">
24
+ <a-card :title="groupItem.name" :bordered="false" size="small">
25
+ <x-form-item
26
+ v-for="(item, index) in groupItem.groupItems"
27
+ :key="index"
28
+ :attr="item"
29
+ :disabled="itemDisabled(item)"
30
+ :files="files"
31
+ :form="form[groupItem.model]"
32
+ :images="images"
33
+ :service-name="serviceName"
34
+ mode="新增/修改"
35
+ :get-data-params="getDataParams"
36
+ />
37
+ </a-card>
38
+ </a-row>
39
+ <a-row :gutter="16" v-for="(item, key) in simpleFormJsonData" :key="'row' + key">
40
+ <a-card :title="item.name" :bordered="false" size="small">
41
+ <x-form-item
42
+ v-for="(formItem, formItemIndex) in item.value"
43
+ :key="key + formItemIndex"
44
+ :attr="formItem"
45
+ :disabled="itemDisabled(formItem)"
46
+ :files="files"
47
+ :form="form"
48
+ :images="images"
49
+ :service-name="serviceName"
50
+ mode="新增/修改"
51
+ :get-data-params="getDataParams"
52
+ />
53
+ </a-card>
54
+ </a-row>
55
+ </a-form-model>
56
+ <a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">提交</a-button>
57
+ </div>
55
58
  </template>
56
59
  <script>
57
60
  import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
58
61
  import { formatDate } from '@vue2-client/utils/util'
59
62
  import { mapState } from 'vuex'
60
- import { runLogic } from '@vue2-client/services/api/common'
63
+ import { addOrModify, runLogic } from '@vue2-client/services/api/common'
61
64
 
62
65
  export default {
63
66
  name: 'XAddNativeForm',
@@ -82,10 +85,16 @@ export default {
82
85
  loading: false,
83
86
  // 表单Model
84
87
  form: {},
88
+ // 配置名称
89
+ configName: undefined,
90
+ // 配置内容,用于查询配置生成器的预览
91
+ configContent: undefined,
85
92
  // 表单项集合
86
93
  formItems: [],
87
94
  // 服务名称
88
95
  serviceName: undefined,
96
+ // 是否显示提交按钮
97
+ showSubmitBtn: true,
89
98
  // 修改有文件的表单时使用
90
99
  files: [],
91
100
  images: [],
@@ -142,9 +151,11 @@ export default {
142
151
  methods: {
143
152
  init (params) {
144
153
  const {
145
- formItems, viewMode, isHandleFormKey = true, serviceName, isTableTemp = false, modifyModelData = {}, businessType, title, fixedAddForm = {}, getDataParams = {}, simpleFormJsonData = {}
154
+ configName, configContent, formItems, viewMode, isHandleFormKey = true, showSubmitBtn = true, serviceName, isTableTemp = false, modifyModelData = {}, businessType, title, fixedAddForm = {}, getDataParams = {}, simpleFormJsonData = {}
146
155
  } = params
147
156
  this.loaded = false
157
+ this.configName = configName
158
+ this.configContent = configContent
148
159
  if (typeof formItems === 'string') {
149
160
  this.formItems = JSON.parse(formItems)
150
161
  } else {
@@ -152,6 +163,7 @@ export default {
152
163
  }
153
164
  this.viewMode = viewMode
154
165
  this.isHandleFormKey = isHandleFormKey
166
+ this.showSubmitBtn = showSubmitBtn
155
167
  this.serviceName = serviceName
156
168
  this.businessType = businessType
157
169
  this.title = title
@@ -334,21 +346,42 @@ export default {
334
346
  }
335
347
  if (this.viewMode) {
336
348
  this.$message.info('预览模式禁止新增和修改')
337
- console.log({
349
+ return false
350
+ }
351
+ if (this.$listeners.onSubmit) {
352
+ // 交由父级处理
353
+ this.$emit('onSubmit', {
338
354
  businessType: this.businessType,
339
355
  serviceName: this.serviceName,
340
356
  realForm: realForm,
341
357
  currUserName: this.currUser.name
342
358
  })
343
- return false
359
+ } else {
360
+ this.defaultSubmit(realForm)
361
+ }
362
+ })
363
+ },
364
+ // 默认提交事件
365
+ defaultSubmit (realForm, callback) {
366
+ // 组织请求
367
+ const requestParameters = {
368
+ queryParamsName: this.configName,
369
+ queryParams: this.configContent,
370
+ form: realForm,
371
+ businessType: this.businessType,
372
+ operator: this.currUser.name
373
+ }
374
+ addOrModify(requestParameters, this.serviceName).then(data => {
375
+ this.$message.success(this.businessType + '成功!')
376
+ // commit
377
+ this.$emit('afterSubmit', { type: this.businessType, id: data.id, form: requestParameters.form })
378
+ }).catch(e => {
379
+ this.$message.error(this.businessType + '失败:' + e)
380
+ }).finally(() => {
381
+ this.loading = false
382
+ if (callback) {
383
+ callback()
344
384
  }
345
- // 交由父级处理
346
- this.$emit('onSubmit', {
347
- businessType: this.businessType,
348
- serviceName: this.serviceName,
349
- realForm: realForm,
350
- currUserName: this.currUser.name
351
- })
352
385
  })
353
386
  },
354
387
  // 获取表单字段实际值
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <div>
3
+ <a-skeleton :loading="loading" :paragraph="{ rows: 4 }" />
4
+ <div v-show="!loading">
5
+ <template v-if="!loadError">
6
+ <a-descriptions v-if="realData" :column="isMobile ? 1 : column" size="small" :title="title">
7
+ <a-descriptions-item
8
+ v-for="(value, key) in realData"
9
+ :key="key"
10
+ :label="key">
11
+ {{ formatText(value) }}
12
+ </a-descriptions-item>
13
+ </a-descriptions>
14
+ </template>
15
+ <template v-else>
16
+ <a-empty>
17
+ <span slot="description"> 页面配置不存在,请联系系统管理员 </span>
18
+ </a-empty>
19
+ </template>
20
+ </div>
21
+ </div>
22
+ </template>
23
+ <script>
24
+
25
+ import { mapState } from 'vuex'
26
+ import { getConfig } from '@vue2-client/services/api'
27
+
28
+ export default {
29
+ name: 'XDescriptions',
30
+ components: {
31
+ },
32
+ props: {
33
+ // 标题
34
+ title: {
35
+ type: String,
36
+ required: true
37
+ },
38
+ // 内容
39
+ content: {
40
+ type: Object,
41
+ required: true
42
+ },
43
+ // 模型名
44
+ model: {
45
+ type: String,
46
+ required: true
47
+ },
48
+ // 配置名称
49
+ configName: {
50
+ type: String,
51
+ required: true
52
+ },
53
+ // 配置所属命名空间
54
+ serviceName: {
55
+ type: String,
56
+ default: undefined
57
+ },
58
+ // 每列显示数量
59
+ column: {
60
+ type: Number,
61
+ default: 2
62
+ }
63
+ },
64
+ created () {
65
+ this.initConfig()
66
+ },
67
+ data () {
68
+ return {
69
+ // 加载状态
70
+ loading: false,
71
+ loadError: false,
72
+ realData: undefined
73
+ }
74
+ },
75
+ computed: {
76
+ ...mapState('setting', ['isMobile'])
77
+ },
78
+ methods: {
79
+ initConfig () {
80
+ this.loading = true
81
+ this.loadError = false
82
+ if (this.configName) {
83
+ this.getConfig()
84
+ } else {
85
+ this.loading = false
86
+ this.loadError = true
87
+ }
88
+ },
89
+ getConfig () {
90
+ getConfig(this.configName, this.serviceName, (res) => {
91
+ const mapIndex = {}
92
+ res.formJson.filter(item => {
93
+ const model = item.model
94
+ return model.indexOf(this.model) > 0
95
+ })[0].groupItems.forEach(item => {
96
+ mapIndex[item.model.substring(item.model.indexOf('_') + 1)] = item.name
97
+ })
98
+ const result = {}
99
+ for (const key of Object.keys(this.content)) {
100
+ const name = mapIndex[key]
101
+ if (name) {
102
+ result[name] = this.content[key]
103
+ } else {
104
+ result[key] = this.content[key]
105
+ }
106
+ }
107
+ this.realData = result
108
+ this.loading = false
109
+ })
110
+ },
111
+ // 文字格式化
112
+ formatText (value) {
113
+ return value || '--'
114
+ }
115
+ }
116
+ }
117
+ </script>
@@ -0,0 +1,3 @@
1
+ import XDescriptions from './XDescriptions.vue'
2
+
3
+ export default XDescriptions
@@ -0,0 +1,83 @@
1
+ # XDescriptions
2
+
3
+ 动态Descriptions控件,根据JSON配置动态生成Descriptions
4
+
5
+
6
+ ## 何时使用
7
+
8
+ 当需要一个动态生成的Descriptions时
9
+
10
+
11
+ 引用方式:
12
+
13
+ ```javascript
14
+ import XDescriptions from '@vue2-client/base-client/components/XDescriptions/XDescriptions'
15
+
16
+ export default {
17
+ components: {
18
+ XDescriptions
19
+ }
20
+ }
21
+ ```
22
+
23
+
24
+
25
+ ## 代码演示
26
+
27
+ ```html
28
+ <x-descriptions
29
+ title="设备属性"
30
+ :content="details.prop_json"
31
+ :queryParamsName="queryParamsName">
32
+ </x-descriptions>
33
+ ```
34
+
35
+ ## API
36
+
37
+ | 参数 | 说明 | 类型 | 默认值 |
38
+ |-----------------|-------------|--------|------|
39
+ | title | 业务名称 | String | '' |
40
+ | content | 业务内容 | String | '' |
41
+ | queryParamsName | 查询配置JSON文件名 | String | null |
42
+ | serviceName | 配置所属命名空间 | String | null |
43
+
44
+ ## 例子1
45
+ ----
46
+ (基础使用)
47
+
48
+ ```vue
49
+ <template>
50
+ <x-descriptions
51
+ title="设备属性"
52
+ :content="details.prop_json"
53
+ :configName="configName">
54
+ </x-descriptions>
55
+ </template>
56
+
57
+ <script>
58
+ import XDescriptions from '@vue2-client/base-client/components/XDescriptions/XDescriptions'
59
+
60
+ export default {
61
+ components: {
62
+ XDescriptions
63
+ },
64
+ data () {
65
+ return {
66
+ // 查询配置文件名
67
+ configName: 'logQueryParams',
68
+ details: {
69
+ prop_json: {
70
+ 规格: 'G2.5'
71
+ }
72
+ }
73
+ }
74
+ },
75
+ created () {
76
+
77
+ },
78
+ methods: {
79
+
80
+ }
81
+ }
82
+ </script>
83
+ ```
@@ -5,7 +5,7 @@
5
5
  <template v-if="!loadError">
6
6
  <x-add-form
7
7
  ref="xAddForm"
8
- @onSubmit="onAddOrEditSubmit"
8
+ @afterSubmit="onAddOrEditSubmitAfterSubmit"
9
9
  />
10
10
  <x-form
11
11
  ref="xForm"
@@ -57,7 +57,7 @@ import XForm from '@vue2-client/base-client/components/common/XForm'
57
57
  import XAddForm from '@vue2-client/base-client/components/common/XAddForm'
58
58
  import XTable from '@vue2-client/base-client/components/common/XTable'
59
59
  import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
60
- import { addOrModify, getConfig, getConfigByLogic, parseConfig } from '@vue2-client/services/api/common'
60
+ import { getConfig, getConfigByLogic, parseConfig } from '@vue2-client/services/api/common'
61
61
  import { mapState } from 'vuex'
62
62
 
63
63
  export default {
@@ -240,27 +240,12 @@ export default {
240
240
  }
241
241
  },
242
242
  /**
243
- * 提交新增表单事件
243
+ * 提交新增/修改表单后事件
244
244
  */
245
- onAddOrEditSubmit (res, callback) {
246
- // 组织请求
247
- const requestParameters = {
248
- queryParamsName: this.queryParamsName,
249
- queryParams: this.queryParamsJson,
250
- form: res.realForm,
251
- businessType: res.businessType,
252
- operator: res.currUserName
253
- }
254
- addOrModify(requestParameters, this.serviceName).then(data => {
255
- this.$message.success(res.businessType + '成功!')
256
- this.refreshTable(res.businessType === '新增')
257
- // commit
258
- this.$emit('afterSubmit', { type: res.businessType, id: data.id, form: requestParameters.form })
259
- }).catch(e => {
260
- this.$message.error(res.businessType + '失败:' + e)
261
- }).finally(() => {
262
- callback()
263
- })
245
+ onAddOrEditSubmitAfterSubmit (res) {
246
+ this.refreshTable(res.businessType === '新增')
247
+ // commit
248
+ this.$emit('afterSubmit', res)
264
249
  },
265
250
  /**
266
251
  * 表格查询后事件
@@ -288,6 +273,8 @@ export default {
288
273
  businessType: '新增',
289
274
  title: this.title,
290
275
  isShow: !res.buttonState || res.buttonState.add || res.buttonState.edit,
276
+ configName: this.queryParamsName,
277
+ configContent: this.queryParamsJson,
291
278
  formItems: res.formJson,
292
279
  viewMode: this.viewMode,
293
280
  isTableTemp: this.isTableTemp,
@@ -306,6 +293,8 @@ export default {
306
293
  businessType: '修改',
307
294
  title: this.title,
308
295
  isShow: !res.buttonState || res.buttonState.add || res.buttonState.edit,
296
+ configName: this.queryParamsName,
297
+ configContent: this.queryParamsJson,
309
298
  formItems: res.formJson,
310
299
  viewMode: this.viewMode,
311
300
  isTableTemp: this.isTableTemp,
@@ -38,6 +38,7 @@ export default {
38
38
  | title | 业务名称 | String | '' |
39
39
  | queryParamsName | 查询配置JSON文件名 | String | null |
40
40
  | queryParamsJson | 查询配置文件Json,用于查询配置生成器的预览 | Object | null |
41
+ | serviceName | 配置所属命名空间 | String | null |
41
42
  | logicName | 通过logic获取表单表格配置 | String | null |
42
43
  | logicParam | 执行logic传递的参数 | Object | null |
43
44
  | fixedQueryForm | 固定查询表单,会和查询表单合并查询 | Object | {} |
package/vue.config.js CHANGED
@@ -35,6 +35,9 @@ module.exports = {
35
35
  target: 'http://127.0.0.1:4789',
36
36
  changeOrigin: true
37
37
  }
38
+ },
39
+ client: {
40
+ overlay: false
38
41
  }
39
42
  },
40
43
  pluginOptions: {
@@ -73,7 +76,7 @@ module.exports = {
73
76
  if (isProd) {
74
77
  // add `CompressionWebpack` plugin to webpack plugins
75
78
  config.plugins.push(new CompressionWebpackPlugin({
76
- algorithm: require('zlib').createGzip,
79
+ algorithm: 'gzip',
77
80
  test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
78
81
  threshold: 10240,
79
82
  minRatio: 0.8
@@ -1,15 +1,15 @@
1
- # vue2迁移vue3
2
-
3
- 1. 完成vue-cli,webpack,babel,eslint的升级
4
- - core-js 3.30.1 -> 3.33.0
5
- - add regenerator-runtime
6
- - @babel/core 7.21.4 -> 7.22.20
7
- - babel-eslint 10.1.0 -> @babel/eslint-parser 7.22.15
8
- - @vue/cli 4.5.19 -> 5.0.8
9
- - babel-jest 25.5.1 -> 26.6.3
10
- - eslint 6.8.0 -> 7.32.0
11
- - jest 24.0.0 -> 26.6.3
12
- - webpack 4.46.0 -> 5.88.2
13
- 2. 完成vue2的2.7升级
14
- - vue 2.6.14 -> 2.7.14
15
- - eslint 7.32.0 -> 8.51.0
1
+ # vue2迁移vue3
2
+
3
+ 1. 完成vue-cli,webpack,babel,eslint的升级
4
+ - core-js 3.30.1 -> 3.33.0
5
+ - add regenerator-runtime
6
+ - @babel/core 7.21.4 -> 7.22.20
7
+ - babel-eslint 10.1.0 -> @babel/eslint-parser 7.22.15
8
+ - @vue/cli 4.5.19 -> 5.0.8
9
+ - babel-jest 25.5.1 -> 26.6.3
10
+ - eslint 6.8.0 -> 7.32.0
11
+ - jest 24.0.0 -> 26.6.3
12
+ - webpack 4.46.0 -> 5.88.2
13
+ 2. 完成vue2的2.7升级
14
+ - vue 2.6.14 -> 2.7.14
15
+ - eslint 7.32.0 -> 8.51.0