add() {
this.tittle = '添加';
// 遍历headers每个值
this.headers.map( v => {
v['val'] = '';
});
this.show_form = true;
this.show_table = false;
}
edit(index) {
// 将数据表的数据赋值给headers对应的值
// index是个对象 如:index={i;2}
this.tittle = '编辑';
const i = index['i'];
console.log('edit', this.data);
this.headers.map(d => {
console.log('-----------',d)
switch (d.type) {
case 'input':
d.val = this.data[i][d.key];
break;
case 'select':
d.val = this.data[i][d.key];
break;
case 'select-line':
d.val = '';
break;
case 'fuzzy_select':
d.val = this.data[i]['role'];
console.log('========', d.val);
break;
default:
d.val = this.data[i][d.key];
}
this.show_form = true;
this.show_table = false;
});
}