- 常见问题
+ {{ title }}
-
-
+
+
+
-
-
+
+
删除
@@ -26,6 +29,25 @@ export default {
dataForm: {
type: Object,
default: () => { }
+ },
+ title: {
+ type: String,
+ default: '常见问题'
+ },
+ keyTextObj: {
+ type: Object,
+ default: () => {
+ return {
+ nameObj: {
+ text: '问题名称',
+ key: 'question'
+ },
+ descObj: {
+ text: '问题描述',
+ key: 'answer'
+ },
+ }
+ }
}
},
data() {
@@ -38,7 +60,7 @@ export default {
handler(newVal) {
this.dataInfo = newVal;
this.$emit('update', {
- title: '常见问题',
+ title: this.title,
list: newVal
})
},
@@ -51,21 +73,29 @@ export default {
let arr = []
if (dataForm && (dataForm.id || dataForm.id === 0)) {
let fuseAttrList = dataForm.fuseAttrList || [];
- let obj = fuseAttrList.find(v => v.attrType === '常见问题') || {}
+ let obj = fuseAttrList.find(v => v.attrType === this.title) || {}
let attrValue = JSON.parse(obj.attrValue || "[]")
if (attrValue.length > 0) {
attrValue.map(v => {
arr.push({
- question: v.question,
- answer: v.answer,
+ [this.keyTextObj.nameObj.key]: v[this.keyTextObj.nameObj.key],
+ [this.keyTextObj.descObj.key]: v[this.keyTextObj.descObj.key],
})
})
+ } else {
+ arr = []
+ console.log('this.keyTextObj.nameObj.key------------>', this.keyTextObj.nameObj.key);
+ arr.push({
+ [this.keyTextObj.nameObj.key]: '',
+ [this.keyTextObj.descObj.key]: '',
+ })
}
} else {
arr = []
+ console.log('this.keyTextObj.nameObj.key------------>', this.keyTextObj.nameObj.key);
arr.push({
- question: "",
- answer: "",
+ [this.keyTextObj.nameObj.key]: '',
+ [this.keyTextObj.descObj.key]: '',
})
}
this.dataInfo = arr;
@@ -73,8 +103,8 @@ export default {
// 新增
addItem() {
this.dataInfo.push({
- question: "",
- answer: "",
+ [this.keyTextObj.nameObj.key]: '',
+ [this.keyTextObj.descObj.key]: '',
})
},
// 删除