-- 打印模板表（Hiprint JSON）
CREATE TABLE IF NOT EXISTS `print_template` (
  `id` varchar(36) NOT NULL COMMENT '主键',
  `template_code` varchar(64) NOT NULL COMMENT '模板编码',
  `template_name` varchar(200) NOT NULL COMMENT '模板名称',
  `category` varchar(32) DEFAULT 'form' COMMENT 'barcode/form/report',
  `paper_width_mm` decimal(10,2) DEFAULT 210.00 COMMENT '纸宽mm',
  `paper_height_mm` decimal(10,2) DEFAULT 297.00 COMMENT '纸高mm',
  `paper_orientation` varchar(16) DEFAULT 'portrait' COMMENT 'portrait/landscape',
  `template_json` longtext COMMENT 'Hiprint模板JSON',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  `create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_print_template_code` (`template_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='打印模板';

-- 菜单：打印管理
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000100', '', '打印管理', '/print', 'layouts/default/index', 1, NULL, '/print/template', 0, NULL, '0', 50.00, 0, 'ant-design:printer-outlined', 0, 0, 0, 0, 'Hiprint 可视化打印模板', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000101', '1900000000000000100', '打印模板', '/print/template', 'print/template/index', 1, 'PrintTemplateList', NULL, 1, NULL, '0', 1.00, 0, 'ant-design:file-text-outlined', 1, 1, 0, 0, '模板列表与设计入口', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000102', '1900000000000000100', '打印设计器', '/print/designer', 'print/template/PrintDesigner', 1, 'PrintDesigner', NULL, 1, NULL, '0', 2.00, 0, '', 1, 0, 1, 0, 'Hiprint 设计器（隐藏菜单）', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

-- 按钮权限
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000111', '1900000000000000101', '打印模板-查询', NULL, NULL, 0, NULL, NULL, 2, 'print:template:list', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000112', '1900000000000000101', '打印模板-添加', NULL, NULL, 0, NULL, NULL, 2, 'print:template:add', '1', 2.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000113', '1900000000000000101', '打印模板-编辑', NULL, NULL, 0, NULL, NULL, 2, 'print:template:edit', '1', 3.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000114', '1900000000000000101', '打印模板-删除', NULL, NULL, 0, NULL, NULL, 2, 'print:template:delete', '1', 4.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
