diff --git a/src/components/Template/BaseInfoFormPcakge.vue b/src/components/Template/BaseInfoFormPcakge.vue
index d140ebc..6010ad1 100644
--- a/src/components/Template/BaseInfoFormPcakge.vue
+++ b/src/components/Template/BaseInfoFormPcakge.vue
@@ -94,7 +94,10 @@
-
+
-
-
+
{{ row[col.prop] }}
-
+
-
-
-
-
{{ row[col.bodySubKey] }}
@@ -98,10 +93,15 @@ export default {
// { label: '状态', prop: 'status', type: 'select', options: [{value:1,label:'启用'},...], selected: null }
// ]
},
- dataSource: {
- type: Array,
- required: true
- }
+ formData: {
+ type: Object,
+ default:()=>{
+ return {
+ stepTableFormData: [],
+ headerSelectFields: {}
+ }
+ }
+ },
},
data() {
return {
@@ -110,19 +110,18 @@ export default {
}
},
watch: {
- dataSource: {
+ formData:{
immediate: true,
handler(newData) {
- this.localDataSource = JSON.parse(JSON.stringify(newData));
- // 初始化表头选择器值
+ console.log(newData,"newData")
+ const {stepTableFormData = [], headerSelectFields = {}} = newData;
+ this.updateDataSource(stepTableFormData);
+ this.headerSelectFields = JSON.parse(JSON.stringify(headerSelectFields))
}
},
- columns: {
- immediate: true,
- handler(newColumns) {
- this.initHeaderSelectValues();
- }
- }
+ },
+ mounted() {
+ this.initHeaderSelectValues();
},
methods: {
// 初始化表头选择器值
@@ -133,7 +132,6 @@ export default {
headerSelectObj[col.headerSelectKey] = col.defaultValue || col.headerOptions[0].value || ""
}
});
- console.log(headerSelectObj,"headerSelectObj")
this.headerSelectFields = headerSelectObj;
},
// 获取最新数据
@@ -146,7 +144,7 @@ export default {
return new Promise((resolve,reject)=>{
if(validateResult.valid){
resolve({
- dataSource: [...this.localDataSource],
+ stepTableFormData: [...this.localDataSource],
headerSelectFields: this.headerSelectFields,
})
}else{
@@ -238,33 +236,41 @@ export default {
label: ""
}
},
- getBodyItem(col) {
- return {
+ getBodyItem(col,rowIndex) {
+ const currentItem = this.localDataSource[rowIndex];
+ const item = {
fillType: col.bodyFillType,
options: col.bodyOptions,
- maxLength: col.bodyMaxLength,
- label: ""
+ maxlength: col.bodyMaxlength,
+ label: col.label,
+ precision: currentItem[col.bodyPrecisionKey] || col.precision || 0,
+ };
+ if(col.bodyDisabled){
+ item.disabled = col.bodyDisabled;
}
+ return item
},
getBodySubItem(col) {
- return {
+ const item = {
fillType: col.bodySubFillType,
options: col.bodySubOptions,
+ maxlength: col.bodySubMaxlength,
label: "",
+ placeholder:col.bodySubPlaceholder||"请输入"
}
- },
- getPrecisionNumberItem(col) {
- return {
- fillType: col.bodySubFillType,
- options: col.bodySubOptions,
- label: "",
- placeholder:"请输入保留小数位数"
+ if(col.bodySubDisabled){
+ item.disabled = col.bodySubDisabled;
}
},
// 删除行
deleteRow(rowIndex) {
this.localDataSource.splice(rowIndex, 1);
this.$emit('row-delete', rowIndex);
+ },
+ // 更新数据方法,可在formData变更时调用,也可由父组件调用
+ updateDataSource(dataSource = []) {
+ // 深拷贝数据以避免直接修改原始数据
+ this.localDataSource = JSON.parse(JSON.stringify(dataSource || []));
}
}
};
diff --git a/src/components/Template/DecimalInput.vue b/src/components/Template/DecimalInput.vue
index 0fe677c..27dd81e 100644
--- a/src/components/Template/DecimalInput.vue
+++ b/src/components/Template/DecimalInput.vue
@@ -1,5 +1,5 @@
-
+