| | |
| | | } |
| | | }, |
| | | delemembers() { |
| | | if (!this.bingshiall || this.bingshiall.length === 0) { |
| | | this.$message.warning("请先选择要删除的项"); |
| | | return; |
| | | } |
| | | |
| | | // 区分新增项和数据库项 |
| | | const localItems = this.bingshiall.filter((item) => !item.diseaseId); // 新增的 |
| | | const dbItems = this.bingshiall.filter((item) => item.diseaseId); // 数据库已有的 |
| | | |
| | | // 先删除新增的(本地直接删) |
| | | if (localItems.length > 0) { |
| | | this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter( |
| | | (item) => !localItems.includes(item) |
| | | ); |
| | | } |
| | | |
| | | if (dbItems.length === 0) { |
| | | // 只有新增项,无需调用接口,直接清空选中,退出 |
| | | this.bingshiall = []; |
| | | this.$forceUpdate(); |
| | | return; |
| | | } |
| | | |
| | | // 调接口删除数据库项 |
| | | const historyId = dbItems.map((item) => item.diseaseId); |
| | | removeAskHistorys(historyId) |
| | | .then((res) => { |
| | | this.$message.success("删除成功"); |
| | | // 接口成功后删除数据库项 |
| | | this.form.tjAskHistorysList = this.form.tjAskHistorysList.filter( |
| | | (item) => |
| | | !dbItems.some((selected) => selected.diseaseId === item.diseaseId) |
| | | ); |
| | | this.bingshiall = []; |
| | | this.$forceUpdate(); |
| | | }) |
| | | .catch(() => { |
| | | this.$message.warning("删除失败"); |
| | | }); |
| | | }, |
| | | |
| | | /* delemembers() { |
| | | if (this.bingshiall && this.bingshiall.length > 0) { |
| | | const historyId = this.bingshiall.map((item) => item.diseaseId); |
| | | |
| | |
| | | } else { |
| | | this.$message.warning("请先选择要删除的项"); |
| | | } |
| | | }, |
| | | }, */ |
| | | handlebingChange(selection) { |
| | | this.bingshiall = []; |
| | | this.bingshiall = selection; |