@leevan/jtui 2.0.54-beta.3 → 2.0.54-beta.5

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": "@leevan/jtui",
3
- "version": "2.0.54-beta.3",
3
+ "version": "2.0.54-beta.5",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -117,14 +117,6 @@ export default {
117
117
  type: {
118
118
  type: String,
119
119
  default: 'text'
120
- },
121
- row: {
122
- type: Object,
123
- default: null
124
- },
125
- prop: {
126
- type: String,
127
- default: ''
128
120
  }
129
121
  },
130
122
  data() {
@@ -140,12 +132,13 @@ export default {
140
132
  watch: {
141
133
  value(newVal) {
142
134
  this.currentValue = newVal;
135
+ },
136
+ // 监听 currentValue 变化,实时同步给父组件
137
+ currentValue(newVal) {
138
+ this.$emit('input', newVal);
143
139
  }
144
140
  },
145
141
  mounted() {
146
- if (this.row && this.prop && !(this.prop in this.row)) {
147
- this.$set(this.row, this.prop, this.value == null ? '' : this.value);
148
- }
149
142
  this.$nextTick(() => {
150
143
  if (this.$refs.inputRef) {
151
144
  const input = this.$refs.inputRef.$el ? this.$refs.inputRef.$el.querySelector('input') : this.$refs.inputRef;
@@ -163,14 +156,6 @@ export default {
163
156
  this.doComplete();
164
157
  },
165
158
  doComplete() {
166
- if (this.row && this.prop) {
167
- if (!(this.prop in this.row)) {
168
- this.$set(this.row, this.prop, this.currentValue);
169
- } else {
170
- this.row[this.prop] = this.currentValue;
171
- }
172
- }
173
- this.$emit('input', this.currentValue);
174
159
  this.closeEdit();
175
160
  },
176
161
  closeEdit() {
@@ -59,10 +59,9 @@
59
59
  </div>
60
60
  <EditInput
61
61
  v-else-if="item && item.edit && item.edit.name == '$input'"
62
- v-model="row[subSubItem.prop]"
62
+ :value="row[subSubItem.prop]"
63
63
  :type="(item.edit.props && item.edit.props.type) || 'text'"
64
- :row="row"
65
- :prop="subSubItem.prop"
64
+ @input="(val) => handleInputChange(val, row, subSubItem.prop)"
66
65
  />
67
66
  </template>
68
67
  </vxe-table-column>
@@ -112,10 +111,9 @@
112
111
  </div>
113
112
  <EditInput
114
113
  v-else-if="item && item.edit && item.edit.name == '$input'"
115
- v-model="row[subItem.prop]"
114
+ :value="row[subItem.prop]"
116
115
  :type="(item.edit.props && item.edit.props.type) || 'text'"
117
- :row="row"
118
- :prop="subItem.prop"
116
+ @input="(val) => handleInputChange(val, row, subItem.prop)"
119
117
  />
120
118
  </template>
121
119
  </vxe-table-column>
@@ -166,10 +164,9 @@
166
164
  </div>
167
165
  <EditInput
168
166
  v-else-if="item && item.edit && item.edit.name == '$input'"
169
- v-model="row[item.prop]"
167
+ :value="row[item.prop]"
170
168
  :type="(item.edit.props && item.edit.props.type) || 'text'"
171
- :row="row"
172
- :prop="item.prop"
169
+ @input="(val) => handleInputChange(val, row, item.prop)"
173
170
  />
174
171
  </template>
175
172
  </vxe-table-column>
@@ -264,6 +261,10 @@ export default {
264
261
  const findItem = this.item.edit.options.find(op => op.value === value);
265
262
  return findItem ? findItem.label : (value || '请选择');
266
263
  },
264
+ handleInputChange(val, row, prop) {
265
+ // 无论字段是否存在,都使用 $set 来确保响应式
266
+ this.$set(row, prop, val);
267
+ },
267
268
  toggleDropdown() {
268
269
  this.isOpen = !this.isOpen;
269
270
  },