|
|
|
@ -7,7 +7,7 @@ |
|
|
|
<div class="header-cell-content"> |
|
|
|
<div>{{ col.label }}</div> |
|
|
|
<template v-if="col.headerSelectKey && col.headerOptions"> |
|
|
|
<HandleFormItem type="select" class="header-select" :item="getHeaderItem(col)" |
|
|
|
<HandleFormItem type="select" class="header-select" :item="getHeaderItem(col)" |
|
|
|
v-model="headerSelectFields[col.headerSelectKey]" @change="onHeaderSelectChange(index, $event)" /> |
|
|
|
</template> |
|
|
|
</div> |
|
|
|
@ -29,29 +29,24 @@ |
|
|
|
<div class="inner-table-cell"> |
|
|
|
<div> |
|
|
|
<template v-if="col.bodyType === 'input'"> |
|
|
|
<HandleFormItem type="input" class="body-input" :item="getBodyItem(col)" v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
<HandleFormItem type="input" class="body-input" :item="getBodyItem(col,rowIndex)" v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
</template> |
|
|
|
<template v-else-if="col.bodyType === 'inputNumber'"> |
|
|
|
<HandleFormItem type="inputNumber" class="body-input-number" :item="getBodyItem(col)" |
|
|
|
<HandleFormItem type="inputNumber" class="body-input-number" :item="getBodyItem(col,rowIndex)" |
|
|
|
v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
</template> |
|
|
|
<template v-else-if="col.bodyType === 'select'"> |
|
|
|
<HandleFormItem type="select" class="body-select" :item="getBodyItem(col)" v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
<HandleFormItem type="select" class="body-select" :item="getBodyItem(col,rowIndex)" v-model="row[col.prop]" @change="onBodyValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
</template> |
|
|
|
<template v-else> |
|
|
|
{{ row[col.prop] }} |
|
|
|
</template> |
|
|
|
</div> |
|
|
|
<div class="m-l-5"> |
|
|
|
<template v-if="col.bodySubType === 'inputNumber'"> |
|
|
|
<template v-if="col.bodySubType === 'inputNumber' && col.showBodySub"> |
|
|
|
<HandleFormItem type="inputNumber" :item="getBodySubItem(col)" |
|
|
|
v-model="row[col.bodySubKey]" @change="onBodySubValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
</template> |
|
|
|
<!-- 预填才显示精度输入框 --> |
|
|
|
<template v-else-if="col.bodySubType === 'precisionNumber'&& $store.state.template.templateStatus === 'preFill'"> |
|
|
|
<HandleFormItem type="inputNumber" class="sub-input-number" :item="getPrecisionNumberItem(col)" |
|
|
|
v-model="row[col.bodySubKey]" @change="onBodySubValueChange(rowIndex, colIndex, $event)" /> |
|
|
|
</template> |
|
|
|
<template v-else> |
|
|
|
{{ row[col.bodySubKey] }} |
|
|
|
</template> |
|
|
|
@ -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 || [])); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|