# `Sp_checkismakerson_updatedel` (procedure)

> 根据模块sId删除模块（包含子模块）


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuids` | `varchar(255)` |
| 2 | IN | `sFormGuid` | `varchar(100)` |
| 3 | IN | `sTableName` | `varchar(255)` |
| 4 | IN | `sLoginId` | `varchar(255)` |
| 5 | IN | `sBrId` | `varchar(255)` |
| 6 | IN | `sSuId` | `varchar(255)` |
| 7 | IN | `sType` | `varchar(255)` |
| 8 | OUT | `sCode` | `int` |
| 9 | OUT | `sReturn` | `varchar(255)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_checkismakerson_updatedel`'`._

## Narrative

**Business context:** Cross-cutting permission guard, called from the generic save/update/delete dispatchers (`Sp_DelMasterSlave_Pro`, `Sp_UpdateAdd_Check`, `Sp_UpdateAdd_Check_NEW`). Enforces two policies on top of any bill operation: (1) once a master row has `bCheck=1` (审核 audited) it cannot be modified or deleted; (2) when `SysSystemSettings.CkxModifyBillNoMakePerson=1`, a row can only be modified/deleted by its original `sMakePerson` (制单人), unless the logged-in user is `sftlogininfo.sType='sysadmin'` or has `bChange=1` (override flag). 物流单 (logistics order) carries its own override paths (`bAheadComplete`/`bConfirmComplete`).

**What it does:** Sets defaults and rewrites slave table names back to their master counterpart via `REPLACE(LOWER(sTableName),'slave','master')`. Skips entirely if the table name contains `gds` (gds-prefixed metadata is unrestricted). Builds a dynamic `SELECT COUNT(1) ... WHERE sId=sGuids AND bCheck=1` against the master table; non-zero count returns `sReturn='单据已审核不能操作本单据'`, `sCode=-1`. For `logisticsordermaster` specifically: `bAheadComplete=1` blocks all edits; `bConfirmComplete=1` + `sType='check'` blocks edits with a "主管已确认" message; on delete (`sType='check'`), a non-制单人 attempting to delete a confirmed logistics bill is blocked with "非制单人不能删除物流单单据!". For a whitelisted set of `sFormGuid`s the proc short-circuits to `sCode=1`. Otherwise, when `CkxModifyBillNoMakePerson=1` and the table is one of a fixed master-table whitelist (`elecustomer`/`elesupply`/`elematerials`/`eleproduct`/`eleemployee`/`eleknifemould`/`elemachine`/`elesemigoods`/`eleteam`/`eleprocess`/`eleteststandard`/`sisformula`/`sleproductinformation`/`sisproductclassify`/`sisposition` or any `*master`), it runs a second dynamic `COUNT` filtered by `sMakePerson <> sLoginId` and returns `sCode=-8`, `sReturn='非制单人不能操作本单据!!!'` on a hit.

**Invocation:** Called by `Sp_DelMasterSlave_Pro`, `Sp_UpdateAdd_Check`, and `Sp_UpdateAdd_Check_NEW` — the three generic CRUD dispatchers — early in their flow before they touch the target row. No direct UI binding. xly-src ships `script/标版/30100101/Sp_checkismakerson_updatedel.sql` as the install body.
