vue2-client 1.9.85 → 1.9.87

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.9.85",
3
+ "version": "1.9.87",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -92,8 +92,10 @@
92
92
  </x-form-table>
93
93
  </a-card>
94
94
  </a-row>
95
- <a-row type="flex" justify="center">
96
- <a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">提交</a-button>
95
+ <a-row type="flex" :justify="btnPlace" :style="{paddingLeft: '16px',paddingRight: '16px'}">
96
+ <slot name="footer" :loading="loading">
97
+ <a-button v-if="showSubmitBtn" :loading="loading" type="primary" @click="onSubmit()">{{ btnName }}</a-button>
98
+ </slot>
97
99
  </a-row>
98
100
  </a-form-model>
99
101
  </div>
@@ -153,8 +155,14 @@ export default {
153
155
  modifyModelData: {},
154
156
  // 当前环境
155
157
  env: 'prod',
158
+ // 表单主键
159
+ primaryKey: null,
156
160
  // 表单模式 horizontal | vertical | inline
157
- layout: 'horizontal'
161
+ layout: 'horizontal',
162
+ // 提交按钮名称
163
+ btnName: '提交',
164
+ // 提交按钮位置 start / center / end
165
+ btnPlace: 'center'
158
166
  }
159
167
  },
160
168
  computed: {
@@ -188,6 +196,12 @@ export default {
188
196
  return item.type === 'childTable'
189
197
  })
190
198
  },
199
+ // 过滤出用于form子表数据新增/修改场景的表单项
200
+ childFormData: function () {
201
+ return this.formItems.filter((item) => {
202
+ return item.type === 'rowEdit'
203
+ })
204
+ },
191
205
  // 过滤出用于静默新增场景的表单项
192
206
  silenceAddJsonData: function () {
193
207
  return this.formItems.filter(function (item) {
@@ -230,9 +244,9 @@ export default {
230
244
  init (params) {
231
245
  const {
232
246
  configName, configContent, formItems, formJson, viewMode, isHandleFormKey, isKeyHandle = true,
233
- showSubmitBtn = true, serviceName,
247
+ showSubmitBtn = true, serviceName, primaryKey,
234
248
  modifyModelData = {}, businessType, title, fixedAddForm = {}, getDataParams = {},
235
- simpleFormJsonData = {}, env = 'prod', layout, xAddFormLayout = 'horizontal'
249
+ simpleFormJsonData = {}, env = 'prod', layout, xAddFormLayout = 'horizontal', btnName = '提交', btnPlace = 'center'
236
250
  } = params
237
251
  this.loaded = false
238
252
  // 兼容需要省略 传递 layout: res.xAddFormLayout 可以使用 ...res 展开运算符 直接转递
@@ -253,12 +267,15 @@ export default {
253
267
  this.formItems = this.getFromItem(formItems, formJson)
254
268
  this.viewMode = viewMode
255
269
  this.showSubmitBtn = showSubmitBtn
270
+ this.primaryKey = primaryKey
256
271
  this.serviceName = serviceName
257
272
  this.businessType = businessType
258
273
  this.title = title
259
274
  this.getDataParams = getDataParams
260
275
  this.simpleFormJsonData = simpleFormJsonData
261
276
  this.env = env
277
+ this.btnName = btnName
278
+ this.btnPlace = btnPlace
262
279
  // 如果 fixedAddForm 有 selected_id 值,并且设置了处理表单key值,则多给 selected_id 加前缀 避免处理错误
263
280
  if (fixedAddForm.selected_id && this.isHandleFormKey) {
264
281
  fixedAddForm._selected_id = fixedAddForm.selected_id
@@ -619,6 +636,21 @@ export default {
619
636
  realForm[childModel] = childData
620
637
  }
621
638
  }
639
+ // 增加form子表数据
640
+ if (this.childFormData.length > 0) {
641
+ for (const item of this.childFormData) {
642
+ const childModel = item.model
643
+ const childData = this.$refs[item.model].getTableData()
644
+ for (let i = 0; i < childData.length; i++) {
645
+ childData[i] = this.handleFormKeys(childData[i])
646
+ // 外键不需要带表别名,所以此处放到表单处理后赋值
647
+ if (realForm.id) {
648
+ childData[i][item.childTableForeignKeyName] = realForm.id
649
+ }
650
+ }
651
+ realForm[childModel] = childData
652
+ }
653
+ }
622
654
  if (this.$listeners.onSubmit) {
623
655
  // 交由父级处理
624
656
  this.$emit('onSubmit', {
@@ -834,6 +866,22 @@ export default {
834
866
  },
835
867
  setForm (obj) {
836
868
  this.form = Object.assign(this.form, obj)
869
+ // 给子表赋外键条件
870
+ if (this.childFormData.length > 0) {
871
+ for (const item of this.childFormData) {
872
+ const child = this.$refs[item.model]
873
+ // 有主键,且主键有值,添加主键条件
874
+ if (this.primaryKey && this.form[this.primaryKey]) {
875
+ const foreignKey = item.foreignKey
876
+ if (!child.fixedQueryForm) {
877
+ child.fixedQueryForm = { [foreignKey]: this.form[this.primaryKey] }
878
+ } else {
879
+ Object.assign(child.fixedQueryForm, { [foreignKey]: this.form[this.primaryKey] })
880
+ }
881
+ child.refreshTable()
882
+ }
883
+ }
884
+ }
837
885
  },
838
886
  setFormWithKey (obj) {
839
887
  setDataByRealKey(this.form, obj)
@@ -883,8 +883,8 @@ export default {
883
883
  // 把内部的crud表单录入放到表单中,以便外部可以调用
884
884
  onComponentMounted (h, attr) {
885
885
  console.log('crud表单', h)
886
- if (cell.slotRef) {
887
- this.registerComponent(attr.key, this.$refs["'childXFormTable_' + attr.model"])
886
+ if (attr.crud) {
887
+ this.registerComponent(attr.model, this.$refs['childXFormTable_' + attr.model])
888
888
  }
889
889
  },
890
890
  childTableFixedQueryForm (item) {
@@ -181,8 +181,8 @@ export default {
181
181
  const values = []
182
182
  if (extra.allCheckedNodes) {
183
183
  for (const item of extra.allCheckedNodes) {
184
- if (item.node.key) {
185
- values.push(item.node.key)
184
+ if (item.node.key && item.node?.data?.props?.label !== item.node?.data?.props?.value) {
185
+ values.push(`${item.node.key}`)
186
186
  }
187
187
  if (item.children && item.children.length) {
188
188
  this.getNodeValues(item.children, value, values)
@@ -198,7 +198,7 @@ export default {
198
198
  },
199
199
  getNodeValues (data, value, values) {
200
200
  for (const item of data) {
201
- values.push(item.node.key)
201
+ values.push(`${item.node.key}`)
202
202
  if (item.children && item.children.length) {
203
203
  this.getNodeValues(item.children, value, values)
204
204
  }
@@ -40,7 +40,7 @@ export default {
40
40
  data () {
41
41
  return {
42
42
  // 查询配置文件名
43
- queryParamsName: 'ceshiCRUD',
43
+ queryParamsName: 'ChargeQueryCRUD',
44
44
  // 查询配置左侧tree
45
45
  // xTreeConfigName: 'addressType',
46
46
  // 新增表单固定值
@@ -558,12 +558,14 @@ export default {
558
558
  }
559
559
  param = Object.assign(param, await runLogic(res.paramLogicName, selectedId, cell.serviceName))
560
560
  }
561
+ console.info('给表单赋值', res)
561
562
  this.$refs[`dynamicComponent_${cell.slotRef || cellIndex}`][0].init({
562
563
  serviceName: cell.serviceName,
563
564
  formItems: res.formJson,
564
565
  showSubmitBtn: !this.isInAModal,
565
566
  businessType: param.businessType || '新增',
566
567
  layout: res.xAddFormLayout,
568
+ primaryKey: res.primaryKey,
567
569
  ...res,
568
570
  fixedAddForm: param,
569
571
  modifyModelData: {
@@ -15,7 +15,7 @@ export default {
15
15
  this.inputData = ''
16
16
  this.audioChunks = []
17
17
 
18
- const url = 'ws://192.168.50.67:31090/websocket/bash' // WebSocket地址
18
+ const url = 'ws://192.168.50.67:30288/websocket/bash' // WebSocket地址
19
19
  this.setupWebSocket(url)
20
20
 
21
21
  // 等待 WebSocket 连接成功
@@ -199,7 +199,27 @@ export default {
199
199
  },
200
200
 
201
201
  getRecordingData () {
202
- return this.inputData
202
+ return new Promise((resolve, reject) => {
203
+ if (!this.ws) {
204
+ // 如果 WebSocket 未初始化,直接拒绝
205
+ reject(this.inputData)
206
+ return
207
+ }
208
+
209
+ // 保存原有的 onclose 处理逻辑
210
+ const originalOnClose = this.ws.onclose
211
+
212
+ // 新增的 onclose 逻辑
213
+ this.ws.onclose = (event) => {
214
+ // 触发原有的 onclose 回调
215
+ if (typeof originalOnClose === 'function') {
216
+ originalOnClose(event)
217
+ }
218
+
219
+ // 返回数据
220
+ resolve(this.inputData)
221
+ }
222
+ })
203
223
  },
204
224
 
205
225
  resRecordingData () {