| | |
| | | this.$bus.$off('getCurrSelected', this.handleGetCurrSelected); |
| | | }, |
| | | methods: { |
| | | handleAdd: function () { |
| | | let nextSeq = 0; |
| | | // 安全的写法 |
| | | if (this.dataSource && this.dataSource.length > 0) { |
| | | const lastItem = this.dataSource[this.dataSource.length - 1]; |
| | | if (lastItem && lastItem.seq !== undefined) { |
| | | nextSeq = Number(lastItem.seq) + 1; |
| | | } else { |
| | | // 处理最后一个元素不存在seq的情况 |
| | | nextSeq = 0; // 或其他默认值 |
| | | } |
| | | } else { |
| | | // 处理数组为空的情况 |
| | | nextSeq = 0; // 或其他默认值 |
| | | } |
| | | this.$refs.modalForm.add(nextSeq); |
| | | this.$refs.modalForm.title = "新增"; |
| | | this.$refs.modalForm.disableSubmit = false; |
| | | }, |
| | | handleStatus(record) { |
| | | getAction(this.url.list, { parentId: record.id }).then((res) => { |
| | | if (res.success) { |