331 lines
26 KiB
SQL
331 lines
26 KiB
SQL
-- ============================================================================
|
||
-- 合同管理 — 权限库菜单/字段/按钮/授权 SQL(只产出脚本,需人工在对应环境执行)
|
||
-- 设计文档:doc/contract-management-design.md(v0.6)/ 接口契约:doc/contract-management-api.md
|
||
--
|
||
-- 权限库三环境 schema(切环境只需改第一行 USE,其余语句通用):
|
||
-- dev → xiaoqu_comples_d
|
||
-- test → test
|
||
-- prd → xiaoqu_comples_p
|
||
--
|
||
-- 菜单结构决策(2026-08-25 查 dev 库后确定):
|
||
-- 现有一级菜单无「合同管理」的明显归属(客户管理 id=60 下均为物业/站点类页面,
|
||
-- 合同管理是与开票管理/营销管理同级的独立业务域),故新建一级目录菜单「合同管理」:
|
||
-- 合同管理(type=2 目录,path='',参照 开票管理 id=133 的取值)
|
||
-- ├─ 合同列表 path=contractList (列表页 type=0,按钮:新增/查看/审核/驳回修改/终止/删除/导出)
|
||
-- └─ 工作流设置 path=contractFlowSet (列表页 type=0,按钮:添加设置/编辑)
|
||
--
|
||
-- 授权规则(不硬编码 authority_id、不硬编码自增主键):
|
||
-- ① 目录菜单「合同管理」:动态复用全部一级菜单(parent_id=0)的授权并集;
|
||
-- ② 子页面/字段/按钮:复用「合同管理」目录自身授权(新建目录下无兄弟菜单可复用,
|
||
-- 等价于"与同分类兄弟菜单可见性一致")。
|
||
--
|
||
-- page_field.class_name 铁律(反射加载,必须严格一致):
|
||
-- 合同列表 → me.iiv.iivframework.controller.contract.output.ContractListOutput
|
||
-- 工作流设置 → me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput
|
||
-- 说明:合同列表接口 listByPage 用 getFieldList(is_select=1) → entityToColumns → wrapper.select,
|
||
-- 故 is_select=1 的 en_name 必须是 contract_new 真实列(驼峰);
|
||
-- 计算列(contractStatusStr/createName/*AgentName/todoFlag)用 is_select=0 只作展示元数据。
|
||
-- 搜索区中 日期类型/起止日期/金额区间/公司(companyAgentId) 等参数为 ContractPageInput 专有、
|
||
-- 不在 Output 类中,不写 page_field,由前端页面自带搜索控件。
|
||
-- ============================================================================
|
||
USE xiaoqu_complex; -- dev;test 改 USE test; prd 改 USE xiaoqu_comples_p;
|
||
|
||
START TRANSACTION;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ① webpage:一级目录菜单「合同管理」
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO webpage
|
||
(title, param, icon, description, order_by, parent_id, `type`, `status`, `path`, is_table_show)
|
||
VALUES
|
||
('合同管理', '', '', '', 3, 0, 2, 1, '', 1);
|
||
|
||
SET @contract_parent_id := LAST_INSERT_ID();
|
||
SELECT @contract_parent_id AS contract_parent_webpage_id;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ② webpage_authority:目录菜单授权(动态复用一级菜单授权并集)
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO webpage_authority
|
||
(web_id, authority_id, title, `path`, parent_id, check_status, `type`, is_table_show, order_by)
|
||
SELECT
|
||
@contract_parent_id, sa.authority_id, '合同管理', '', 0, 1, 2, 1, 3
|
||
FROM (
|
||
SELECT DISTINCT authority_id
|
||
FROM webpage_authority
|
||
WHERE web_id IN (SELECT id FROM webpage WHERE parent_id = 0 AND id <> @contract_parent_id)
|
||
AND soft_delete = 0
|
||
) sa;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ③ webpage:子菜单「合同列表」
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO webpage
|
||
(title, param, icon, description, order_by, parent_id, `type`, `status`, `path`, is_table_show)
|
||
VALUES
|
||
('合同列表', '', '', '', 0, @contract_parent_id, 0, 1, 'contractList', 1);
|
||
|
||
SET @contract_list_web_id := LAST_INSERT_ID();
|
||
|
||
INSERT INTO webpage_authority
|
||
(web_id, authority_id, title, `path`, parent_id, check_status, `type`, is_table_show, order_by)
|
||
SELECT
|
||
@contract_list_web_id, wa.authority_id, '合同列表', 'contractList', @contract_parent_id, 1, 0, 1, 0
|
||
FROM (
|
||
SELECT DISTINCT authority_id FROM webpage_authority
|
||
WHERE web_id = @contract_parent_id AND soft_delete = 0
|
||
) wa;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ④ webpage:子菜单「工作流设置」
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO webpage
|
||
(title, param, icon, description, order_by, parent_id, `type`, `status`, `path`, is_table_show)
|
||
VALUES
|
||
('工作流设置', '', '', '', 1, @contract_parent_id, 0, 1, 'contractFlowSet', 1);
|
||
|
||
SET @contract_flow_web_id := LAST_INSERT_ID();
|
||
|
||
INSERT INTO webpage_authority
|
||
(web_id, authority_id, title, `path`, parent_id, check_status, `type`, is_table_show, order_by)
|
||
SELECT
|
||
@contract_flow_web_id, wa.authority_id, '工作流设置', 'contractFlowSet', @contract_parent_id, 1, 0, 1, 1
|
||
FROM (
|
||
SELECT DISTINCT authority_id FROM webpage_authority
|
||
WHERE web_id = @contract_parent_id AND soft_delete = 0
|
||
) wa;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ⑤ page_field:合同列表字段(class_name = ContractListOutput 全限定名)
|
||
-- is_select=1 → contract_new 真实列(进 select);is_select=0 → 计算列/元数据
|
||
-- nav_select=1 → 搜索区;is_table_show=1 → 列表列
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO page_field
|
||
(web_id, cn_name, en_name, class_name, field_type, order_by,
|
||
is_select, nav_select, is_table_show, param)
|
||
VALUES
|
||
-- 列表显示字段
|
||
(@contract_list_web_id, '合同编号', 'contractNo', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 2, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '合同名称', 'contractName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 3, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '物业名称', 'propertyName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 4, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '客户名称', 'customerName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 5, 1, 1, 1, ''),
|
||
(@contract_list_web_id, '客户所属公司', 'customerAgentName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 6, 0, 0, 1, ''),
|
||
(@contract_list_web_id, '合同所属公司', 'contractAgentName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 7, 0, 0, 1, ''),
|
||
(@contract_list_web_id, '合同金额', 'amount', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 8, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '合同开始日期', 'startDate', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 9, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '合同结束日期', 'endDate', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 10, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '联系人', 'contact', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 11, 1, 1, 1, ''),
|
||
(@contract_list_web_id, '到期提醒', 'expireRemind', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'select', 12, 1, 1, 1, '0:不提醒;1:提醒'),
|
||
(@contract_list_web_id, '所属销售', 'saleName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 13, 1, 1, 1, ''),
|
||
(@contract_list_web_id, '创建人员', 'createName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 14, 0, 0, 1, ''),
|
||
(@contract_list_web_id, '创建时间', 'createTime', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 15, 1, 0, 1, ''),
|
||
(@contract_list_web_id, '合同状态', 'contractStatusStr', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 16, 0, 0, 1, ''),
|
||
(@contract_list_web_id, '待办人', 'todoUserNames', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 17, 0, 0, 1, ''),
|
||
-- 搜索区专用(真实列,不在列表显示)
|
||
(@contract_list_web_id, '公司名称', 'customerAgentId', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'inputSelect',20, 1, 1, 0, ''),
|
||
(@contract_list_web_id, '物业名称', 'propertyId', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'inputSelect',21, 1, 1, 0, ''),
|
||
(@contract_list_web_id, '合同状态', 'contractStatus', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'inputSelect',22, 1, 1, 0, ''),
|
||
-- 隐藏/公共字段(元数据完整性与 select 需要)
|
||
(@contract_list_web_id, '提醒天数', 'remindDays', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 30, 1, 0, 0, ''),
|
||
(@contract_list_web_id, '提醒时间', 'remindTime', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 31, 1, 0, 0, ''),
|
||
(@contract_list_web_id, 'id', 'id', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 32, 1, 0, 0, ''),
|
||
(@contract_list_web_id, '创建id', 'createId', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'inputSelect',33, 1, 0, 0, ''),
|
||
(@contract_list_web_id, '合同所属公司ID','contractAgentId', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'inputSelect',34, 1, 0, 0, ''),
|
||
(@contract_list_web_id, '数据状态', 'softDelete', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 35, 1, 0, 0, ''),
|
||
(@contract_list_web_id, '待办标记', 'todoFlag', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 36, 0, 0, 0, '');
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ⑥ page_field:工作流设置字段(class_name = ContractFlowListOutput 全限定名)
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO page_field
|
||
(web_id, cn_name, en_name, class_name, field_type, order_by,
|
||
is_select, nav_select, is_table_show, param)
|
||
VALUES
|
||
(@contract_flow_web_id, '所属公司', 'agentName', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 2, 1, 0, 1, ''),
|
||
(@contract_flow_web_id, '部门内审批开关', 'departAuditSwitch', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'select', 3, 1, 0, 1, '0:关;1:开'),
|
||
(@contract_flow_web_id, '审核人员', 'auditUserNames', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 4, 1, 0, 1, ''),
|
||
(@contract_flow_web_id, '抄送人员', 'ccUserNames', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 5, 1, 0, 1, ''),
|
||
(@contract_flow_web_id, '创建人', 'createName', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 6, 1, 0, 1, ''),
|
||
(@contract_flow_web_id, '创建时间', 'createTime', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 7, 1, 0, 1, ''),
|
||
(@contract_flow_web_id, '修改人', 'modifyName', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 8, 1, 0, 1, ''),
|
||
(@contract_flow_web_id, '修改时间', 'modifyTime', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 9, 1, 0, 1, ''),
|
||
-- 搜索区(所属公司下拉、审核人姓名模糊对应 ContractFlowPageInput.agentId/userName)
|
||
(@contract_flow_web_id, '所属公司', 'agentId', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'inputSelect',20, 1, 1, 0, ''),
|
||
(@contract_flow_web_id, 'id', 'id', 'me.iiv.iivframework.controller.contractFlow.output.ContractFlowListOutput', 'string', 32, 1, 0, 0, '');
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ⑦ field_webpage_authority:字段级权限(跟随页面授权 CROSS JOIN page_field)
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO field_webpage_authority
|
||
(web_id, authority_id, cn_name, en_name, is_select, nav_select,
|
||
field_type, field_id, order_by, check_status, param, is_table_show)
|
||
SELECT
|
||
pf.web_id, wa.authority_id, pf.cn_name, pf.en_name, pf.is_select, pf.nav_select,
|
||
pf.field_type, pf.id, pf.order_by, 1, pf.param, pf.is_table_show
|
||
FROM page_field pf
|
||
CROSS JOIN (
|
||
SELECT DISTINCT authority_id FROM webpage_authority
|
||
WHERE web_id = @contract_list_web_id AND soft_delete = 0
|
||
) wa
|
||
WHERE pf.web_id = @contract_list_web_id;
|
||
|
||
INSERT INTO field_webpage_authority
|
||
(web_id, authority_id, cn_name, en_name, is_select, nav_select,
|
||
field_type, field_id, order_by, check_status, param, is_table_show)
|
||
SELECT
|
||
pf.web_id, wa.authority_id, pf.cn_name, pf.en_name, pf.is_select, pf.nav_select,
|
||
pf.field_type, pf.id, pf.order_by, 1, pf.param, pf.is_table_show
|
||
FROM page_field pf
|
||
CROSS JOIN (
|
||
SELECT DISTINCT authority_id FROM webpage_authority
|
||
WHERE web_id = @contract_flow_web_id AND soft_delete = 0
|
||
) wa
|
||
WHERE pf.web_id = @contract_flow_web_id;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ⑧ button:合同列表(新增/查看/审核/驳回修改/终止/删除/导出)
|
||
-- type=1 页头按钮;type=0 行内按钮(参照 开票记录 web 现有按钮取值)
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO button
|
||
(web_id, cn_name, en_name, icon, class_name, function_path, `type`, `status`, order_by, theme, memo)
|
||
VALUES
|
||
(@contract_list_web_id, '新增', 'add', '', '', '', 1, 0, 0, 'primary', ''),
|
||
(@contract_list_web_id, '导出', 'export', '', '', '', 1, 0, 1, 'success', ''),
|
||
(@contract_list_web_id, '查看', 'lookDetail', '', '', '', 0, 0, 2, 'primary', ''),
|
||
(@contract_list_web_id, '审核', 'audit', '', '', '', 0, 0, 3, 'primary', ''),
|
||
(@contract_list_web_id, '驳回修改', 'updateResubmit', '', '', '', 0, 0, 4, 'primary', ''),
|
||
(@contract_list_web_id, '终止', 'stop', '', '', '', 0, 0, 5, 'primary', ''),
|
||
(@contract_list_web_id, '删除', 'delete', '', '', '', 0, 0, 6, '', '');
|
||
|
||
-- 工作流设置(添加设置/编辑)
|
||
INSERT INTO button
|
||
(web_id, cn_name, en_name, icon, class_name, function_path, `type`, `status`, order_by, theme, memo)
|
||
VALUES
|
||
(@contract_flow_web_id, '添加设置', 'add', '', '', '', 1, 0, 0, 'primary', ''),
|
||
(@contract_flow_web_id, '编辑', 'edit', '', '', '', 0, 0, 1, 'primary', '');
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ⑨ button_webpage_authority:按钮授权(按钮 × 页面授权 CROSS JOIN)
|
||
-- ─────────────────────────────────────────────────────────────
|
||
INSERT INTO button_webpage_authority
|
||
(web_id, authority_id, cn_name, en_name, button_id, order_by, check_status, param, icon, `type`, class_name, theme, memo)
|
||
SELECT
|
||
b.web_id, wa.authority_id, b.cn_name, b.en_name, b.id, b.order_by, 1, '', b.icon, b.`type`, b.class_name, b.theme, b.memo
|
||
FROM button b
|
||
CROSS JOIN (
|
||
SELECT DISTINCT authority_id FROM webpage_authority
|
||
WHERE web_id = @contract_list_web_id AND soft_delete = 0
|
||
) wa
|
||
WHERE b.web_id = @contract_list_web_id AND b.soft_delete = 0;
|
||
|
||
INSERT INTO button_webpage_authority
|
||
(web_id, authority_id, cn_name, en_name, button_id, order_by, check_status, param, icon, `type`, class_name, theme, memo)
|
||
SELECT
|
||
b.web_id, wa.authority_id, b.cn_name, b.en_name, b.id, b.order_by, 1, '', b.icon, b.`type`, b.class_name, b.theme, b.memo
|
||
FROM button b
|
||
CROSS JOIN (
|
||
SELECT DISTINCT authority_id FROM webpage_authority
|
||
WHERE web_id = @contract_flow_web_id AND soft_delete = 0
|
||
) wa
|
||
WHERE b.web_id = @contract_flow_web_id AND b.soft_delete = 0;
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- ⑩ 校验段
|
||
-- ─────────────────────────────────────────────────────────────
|
||
SELECT id, parent_id, title, `path`, order_by, `type`, `status`
|
||
FROM webpage WHERE id IN (@contract_parent_id, @contract_list_web_id, @contract_flow_web_id);
|
||
SELECT web_id, COUNT(DISTINCT authority_id) AS authority_grants
|
||
FROM webpage_authority WHERE web_id IN (@contract_parent_id, @contract_list_web_id, @contract_flow_web_id) GROUP BY web_id;
|
||
SELECT web_id, COUNT(*) AS field_count
|
||
FROM page_field WHERE web_id IN (@contract_list_web_id, @contract_flow_web_id) GROUP BY web_id;
|
||
SELECT web_id, COUNT(*) AS field_grants_total
|
||
FROM field_webpage_authority WHERE web_id IN (@contract_list_web_id, @contract_flow_web_id) GROUP BY web_id;
|
||
SELECT web_id, COUNT(*) AS button_count
|
||
FROM button WHERE web_id IN (@contract_list_web_id, @contract_flow_web_id) GROUP BY web_id;
|
||
SELECT web_id, COUNT(*) AS button_grants_total
|
||
FROM button_webpage_authority WHERE web_id IN (@contract_list_web_id, @contract_flow_web_id) GROUP BY web_id;
|
||
-- 期待:三个 web_id 的 authority_grants 相等;
|
||
-- field_grants_total = field_count × authority_grants;
|
||
-- button_grants_total = button_count × authority_grants;
|
||
-- 合同列表 field_count=26 / button_count=7;工作流设置 field_count=10 / button_count=2。
|
||
|
||
COMMIT;
|
||
-- 失败请改 ROLLBACK
|
||
|
||
-- ─────────────────────────────────────────────────────────────
|
||
-- PRD 上线前 sanity check(在 xiaoqu_comples_p 执行,只查不改):
|
||
-- -- ① 防重复执行:确认菜单尚未存在
|
||
-- SELECT id, parent_id, title, path FROM webpage WHERE path IN ('contractList','contractFlowSet') OR title='合同管理';
|
||
-- -- ② 一级菜单授权集合规模(② 步动态复用的并集)
|
||
-- SELECT DISTINCT authority_id FROM webpage_authority
|
||
-- WHERE web_id IN (SELECT id FROM webpage WHERE parent_id=0) AND soft_delete=0;
|
||
-- 说明:本脚本菜单为新建一级目录,无 parent_id 硬编码替换问题;授权全部动态,三环境可原样执行。
|
||
-- ─────────────────────────────────────────────────────────────
|
||
|
||
-- ============================================================================
|
||
-- 二期(V2.11.31)增量:合同类型字段/合同名称搜索/续签按钮(2026-09-16 已在 dev 执行)
|
||
-- test → USE test; prd → USE xiaoqu_comples_p; 同样幂等(NOT EXISTS 守卫)
|
||
-- ============================================================================
|
||
USE xiaoqu_comples_d;
|
||
|
||
START TRANSACTION;
|
||
|
||
-- 目标页面 web_id 按 path 动态取(各环境自增 id 不同,禁止写死 dev 的 394!)
|
||
SET @contract_list_web_id := (SELECT id FROM webpage WHERE `path` = 'contractList' AND soft_delete = 0 LIMIT 1);
|
||
SELECT @contract_list_web_id AS contract_list_web_id; -- 校验:必须非空,且 title='合同列表'
|
||
|
||
-- ① 列表列:合同类型(计算列展示)
|
||
INSERT INTO page_field (web_id, cn_name, en_name, class_name, field_type, order_by, is_select, nav_select, is_table_show, param)
|
||
SELECT @contract_list_web_id, '合同类型', 'contractTypeStr', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'select', 16.5, 0, 0, 1, '0:租赁;1:售卖;2:其他'
|
||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM page_field WHERE web_id=@contract_list_web_id AND en_name='contractTypeStr' AND soft_delete=0);
|
||
SET @f1 := LAST_INSERT_ID();
|
||
INSERT INTO field_webpage_authority (web_id, authority_id, cn_name, en_name, is_select, nav_select, field_type, field_id, order_by, check_status, param, is_table_show)
|
||
SELECT @contract_list_web_id, wa.authority_id, '合同类型', 'contractTypeStr', 0, 0, 'select', @f1, 16.5, 1, '0:租赁;1:售卖;2:其他', 1
|
||
FROM (SELECT DISTINCT authority_id FROM webpage_authority WHERE web_id=@contract_list_web_id AND soft_delete=0) wa
|
||
WHERE @f1 > 0;
|
||
|
||
-- ② 搜索区:合同类型(真实列,select 选项)
|
||
INSERT INTO page_field (web_id, cn_name, en_name, class_name, field_type, order_by, is_select, nav_select, is_table_show, param)
|
||
SELECT @contract_list_web_id, '合同类型', 'contractType', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'select', 23, 1, 1, 0, '0:租赁;1:售卖;2:其他'
|
||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM page_field WHERE web_id=@contract_list_web_id AND en_name='contractType' AND soft_delete=0);
|
||
SET @f2 := LAST_INSERT_ID();
|
||
INSERT INTO field_webpage_authority (web_id, authority_id, cn_name, en_name, is_select, nav_select, field_type, field_id, order_by, check_status, param, is_table_show)
|
||
SELECT @contract_list_web_id, wa.authority_id, '合同类型', 'contractType', 1, 1, 'select', @f2, 23, 1, '0:租赁;1:售卖;2:其他', 0
|
||
FROM (SELECT DISTINCT authority_id FROM webpage_authority WHERE web_id=@contract_list_web_id AND soft_delete=0) wa
|
||
WHERE @f2 > 0;
|
||
|
||
-- ③ 搜索区:合同名称(真实列,文本框)
|
||
INSERT INTO page_field (web_id, cn_name, en_name, class_name, field_type, order_by, is_select, nav_select, is_table_show, param)
|
||
SELECT @contract_list_web_id, '合同名称', 'contractName', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 24, 1, 1, 0, ''
|
||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM page_field WHERE web_id=@contract_list_web_id AND en_name='contractName' AND nav_select=1 AND soft_delete=0);
|
||
SET @f3 := LAST_INSERT_ID();
|
||
INSERT INTO field_webpage_authority (web_id, authority_id, cn_name, en_name, is_select, nav_select, field_type, field_id, order_by, check_status, param, is_table_show)
|
||
SELECT @contract_list_web_id, wa.authority_id, '合同名称', 'contractName', 1, 1, 'string', @f3, 24, 1, '', 0
|
||
FROM (SELECT DISTINCT authority_id FROM webpage_authority WHERE web_id=@contract_list_web_id AND soft_delete=0) wa
|
||
WHERE @f3 > 0;
|
||
|
||
-- ④ 隐藏列:已被续签标记 renewed(is_select=1 进 wrapper.select,不展示,供续签按钮控制)
|
||
INSERT INTO page_field (web_id, cn_name, en_name, class_name, field_type, order_by, is_select, nav_select, is_table_show, param)
|
||
SELECT @contract_list_web_id, '已被续签标记', 'renewed', 'me.iiv.iivframework.controller.contract.output.ContractListOutput', 'string', 37, 1, 0, 0, ''
|
||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM page_field WHERE web_id=@contract_list_web_id AND en_name='renewed' AND soft_delete=0);
|
||
SET @f4 := LAST_INSERT_ID();
|
||
INSERT INTO field_webpage_authority (web_id, authority_id, cn_name, en_name, is_select, nav_select, field_type, field_id, order_by, check_status, param, is_table_show)
|
||
SELECT @contract_list_web_id, wa.authority_id, '已被续签标记', 'renewed', 1, 0, 'string', @f4, 37, 1, '', 0
|
||
FROM (SELECT DISTINCT authority_id FROM webpage_authority WHERE web_id=@contract_list_web_id AND soft_delete=0) wa
|
||
WHERE @f4 > 0;
|
||
|
||
-- ⑤ 行按钮:续签
|
||
INSERT INTO button (web_id, cn_name, en_name, icon, class_name, function_path, `type`, `status`, order_by, theme, memo)
|
||
SELECT @contract_list_web_id, '续签', 'renew', '', '', '', 0, 0, 7, 'primary', ''
|
||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM button WHERE web_id=@contract_list_web_id AND en_name='renew' AND soft_delete=0);
|
||
SET @b1 := LAST_INSERT_ID();
|
||
INSERT INTO button_webpage_authority (web_id, authority_id, cn_name, en_name, button_id, order_by, check_status, param, icon, `type`, class_name, theme, memo)
|
||
SELECT @contract_list_web_id, wa.authority_id, '续签', 'renew', @b1, 7, 1, '', '', 0, '', 'primary', ''
|
||
FROM (SELECT DISTINCT authority_id FROM webpage_authority WHERE web_id=@contract_list_web_id AND soft_delete=0) wa
|
||
WHERE @b1 > 0;
|
||
|
||
-- 校验:field_webpage_authority 4字段×授权数,button_webpage_authority 续签=授权数
|
||
SELECT (SELECT COUNT(*) FROM field_webpage_authority WHERE web_id=@contract_list_web_id AND en_name IN ('contractTypeStr','contractType','renewed') ) AS new_field_auth,
|
||
(SELECT COUNT(*) FROM button_webpage_authority WHERE web_id=@contract_list_web_id AND en_name='renew') AS renew_btn_auth;
|
||
COMMIT;
|