@ -17,7 +17,7 @@
<el-table-column label="操作" width="120" align="center"><template #default="{row}">
<div style="white-space:nowrap">
<el-button link type="primary" @click="handleEdit(row)">编辑</el-button>
<el-button link type="danger" @click="handleDelete(row)">删除</el-button>
<el-button link type="danger" :disabled="row.machineCount>0" @click="handleDelete(row)">删除</el-button>
</div>
</template></el-table-column>
</el-table>
@ -120,7 +120,8 @@ namespace CncService.Impl
public bool Delete(int id)
{
// 检查关联机床数量
if (_collectAddressRepository.GetMachineCount(id) > 0) return false;
var count = _collectAddressRepository.GetMachineCount(id);
if (count > 0) throw new BusinessException(CncModels.Constants.ErrorCode.DataReferenced, $"该地址下有 {count} 台机床,请先解除关联");
return _collectAddressRepository.Delete(id);
}