采集地址:穿梭框显示全部同品牌机床、删除按钮禁用、后端Delete抛异常、数据库允许NULL

main
haoliang 1 week ago
parent f015afe301
commit 6c3ca47fb7

@ -17,7 +17,7 @@
<el-table-column label="操作" width="120" align="center"><template #default="{row}"> <el-table-column label="操作" width="120" align="center"><template #default="{row}">
<div style="white-space:nowrap"> <div style="white-space:nowrap">
<el-button link type="primary" @click="handleEdit(row)"></el-button> <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> </div>
</template></el-table-column> </template></el-table-column>
</el-table> </el-table>

@ -120,7 +120,8 @@ namespace CncService.Impl
public bool Delete(int id) 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); return _collectAddressRepository.Delete(id);
} }

Loading…
Cancel
Save