diff --git a/hw-ui/src/views/board/demo/index.vue b/hw-ui/src/views/board/demo/index.vue index e105dfe..be3d164 100644 --- a/hw-ui/src/views/board/demo/index.vue +++ b/hw-ui/src/views/board/demo/index.vue @@ -21,22 +21,34 @@ label="工序" width="180" > + + + + @@ -48,35 +60,42 @@ let id = 0 let deepSearch = (arr, target) => { let results = [] arr.forEach(element => { - id = Math.max(id,element.id) - if (Array.isArray(element.children)) { - results = results.concat(deepSearch(element.children, target)) - } else if (element.id === target) { + console.log(element) + id = Math.max(id, element.id) + if (element.id === target) { results.push(element) + } else if (Array.isArray(element.children)) { + results = results.concat(deepSearch(element.children, target)) } + // if (Array.isArray(element.children)) { + // results = results.concat(deepSearch(element.children, target)) + // } else if (element.id === target) { + // results.push(element) + // } }) - return results + return results } export default { name: 'Demo', data() { return { show: true, + id:0, tableData: [ - { - id: 1, - process: 1, - procedure: '2016-05-02', - staff: '王小虎', - time: '上海市普陀区金沙江路 1518 弄' - }, - { - id: 2, - process: 1, - procedure: '2016-05-02', - staff: '王小虎', - time: '上海市普陀区金沙江路 1518 弄' - }, + // { + // id: 1, + // process: 1, + // procedure: '2016-05-02', + // staff: '王小虎', + // time: '上海市普陀区金沙江路 1518 弄' + // }, + // { + // id: 2, + // process: 1, + // procedure: '2016-05-02', + // staff: '王小虎', + // time: '上海市普陀区金沙江路 1518 弄' + // }, { id: 3, process: 1, @@ -92,56 +111,53 @@ export default { time: '上海市普陀区金沙江路 1518 弄' } ] - }, - { - id: 5, - process: 1, - procedure: '2016-05-02', - staff: '王小虎', - time: '上海市普陀区金沙江路 1518 弄' } + // { + // id: 5, + // process: 1, + // procedure: '2016-05-02', + // staff: '王小虎', + // time: '上海市普陀区金沙江路 1518 弄' + // } ] } }, + mounted() { + this.getId(this.tableData) + }, methods: { + getId(arr) { + arr.forEach(element => { + this.id = Math.max(this.id, element.id) + if (Array.isArray(element.children)) { + this.getId(element.children) + } + }) + }, add(e) { let data = deepSearch(this.tableData, e.row.id)?.[0] if (Array.isArray(data.children)) { this.$set(data.children, data.children.length, { - id: id+1, - process: 1, - procedure: '2016-05-02', - staff: '王小虎', - time: '上海市普陀区金沙江路 1518 弄' + id: this.id + 1, + process: null, + procedure: null, + staff: null, + time: null }) - // data.children.push( - // ) } else { this.$set(data, 'children', [ { - id: id+1, - process: 1, - procedure: '2016-05-02', - staff: '王小虎', - time: '上海市普陀区金沙江路 1518 弄' + id: this.id + 1, + process: null, + procedure: null, + staff: null, + time: null } ]) } - // console.log(e) - // e.row = {} - // this.$set(e,'row',[ - // { - // id: 6, - // process: 1, - // procedure: '2016-05-02', - // staff: '王小虎', - // time: '上海市普陀区金沙江路 1512138 弄' - // }, - // ]) - console.log(data) - console.log(this.tableData) - this.show = false - this.show = true + this.id += 1 + // this.show = false + // this.show = true } }, metaInfo() {