Jelajahi Sumber

提交随访模版修改

wangshuangpan 3 hari lalu
induk
melakukan
f2a92c4d74

+ 35 - 17
health-admin/src/main/java/com/bzd/web/controller/gxhpz/FollowTemplateConfigController.java

@@ -9,6 +9,7 @@ import com.bzd.common.enums.BusinessType;
 import com.bzd.common.utils.DateUtils;
 import com.bzd.common.utils.StringUtils;
 import com.bzd.system.service.gxhpz.FollowTemplateConfigService;
+import com.github.pagehelper.PageHelper;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -161,9 +162,13 @@ public class FollowTemplateConfigController extends BaseController {
     @RequiresPermissions("gxhpz:followTemplate:field")
     @GetMapping("/addField/{templateId}")
     public String addField(@PathVariable("templateId") Long templateId, ModelMap mmap) throws Exception {
+        PageData pd = this.getPageData();
+        pd.put("isEnabled",1);
+        pd.put("storeId",getSysUser().getDeptId());
+        PageHelper.clearPage(); // 关键:清除分页上下文,避免自动分页
         // 获取所有可用字段
-        List<PageData> availableFields = followTemplateConfigService.getAvailableFields();
-        mmap.put("availableFields", availableFields);
+        List<PageData> availableFields = followTemplateConfigService.selectFieldList(pd);
+       // mmap.put("availableFields", availableFields);
         mmap.put("templateId", templateId);
         return prefix + "/addField";
     }
@@ -178,9 +183,17 @@ public class FollowTemplateConfigController extends BaseController {
     public AjaxResult saveField() throws Exception {
         PageData pd = this.getPageData();
         pd.put("createdTime", DateUtils.getTime());
-        
+        pd.put("storeId", getSysUser().getDeptId());
+        List<PageData> checkFields= (List<PageData>) followTemplateConfigService.checkFields(pd);
+        if(checkFields.size()>0){
+            return AjaxResult.error("添加失败:字段或编码已存在");
+        }
         Integer result = followTemplateConfigService.insertField(pd);
-        return toAjax(result);
+        if(result>0){
+            return AjaxResult.success();
+        }else {
+            return AjaxResult.error("失败");
+        }
     }
 
     /**
@@ -204,7 +217,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 字段规则配置页面
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+    //@RequiresPermissions("gxhpz:followTemplate:rule")
     @GetMapping("/rules/{templateId}")
     public String rules(@PathVariable("templateId") Long templateId, ModelMap mmap) throws Exception {
         PageData pd = new PageData();
@@ -218,7 +231,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 查询字段规则列表
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+    //@RequiresPermissions("gxhpz:followTemplate:rule")
     @PostMapping("/ruleList")
     @ResponseBody
     public TableDataInfo ruleList() throws Exception {
@@ -236,7 +249,12 @@ public class FollowTemplateConfigController extends BaseController {
     @ResponseBody
     public AjaxResult getAvailableFields() {
         try {
-            List<PageData> fields = followTemplateConfigService.getAvailableFields();
+            PageData pd = this.getPageData();
+            pd.put("isEnabled",1);
+            pd.put("storeId",getSysUser().getDeptId());
+            PageHelper.clearPage(); // 关键:清除分页上下文,避免自动分页
+           //List<PageData> fields = followTemplateConfigService.getAvailableFields();
+            List<PageData> fields = followTemplateConfigService.selectFieldList(pd);
             return AjaxResult.success(fields);
         } catch (Exception e) {
             return AjaxResult.error("获取可用字段失败");
@@ -256,7 +274,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 获取可用模版列表(用于任务创建时选择)
      */
-    @PostMapping("/getAvailableTemplates")
+    //@PostMapping("/getAvailableTemplates")
     @ResponseBody
     public AjaxResult getAvailableTemplates() throws Exception {
         PageData pd = this.getPageData();
@@ -269,7 +287,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 复制模版
      */
-    @RequiresPermissions("gxhpz:followTemplate:add")
+    //@RequiresPermissions("gxhpz:followTemplate:add")
     @Log(title = "复制模版", businessType = BusinessType.INSERT)
     @PostMapping("/copy")
     @ResponseBody
@@ -286,7 +304,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 启用/禁用模版
      */
-    @RequiresPermissions("gxhpz:followTemplate:edit")
+    //@RequiresPermissions("gxhpz:followTemplate:edit")
     @Log(title = "模版状态", businessType = BusinessType.UPDATE)
     @PostMapping("/changeStatus")
     @ResponseBody
@@ -344,7 +362,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 更新规则状态
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+   // @RequiresPermissions("gxhpz:followTemplate:rule")
     @Log(title = "规则状态", businessType = BusinessType.UPDATE)
     @PostMapping("/updateRuleStatus")
     @ResponseBody
@@ -360,7 +378,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 删除规则
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+    //@RequiresPermissions("gxhpz:followTemplate:rule")
     @Log(title = "删除规则", businessType = BusinessType.DELETE)
     @PostMapping("/deleteRule")
     @ResponseBody
@@ -377,7 +395,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 规则测试页面
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+    //@RequiresPermissions("gxhpz:followTemplate:rule")
     @GetMapping("/testRule/{ruleId}")
     public String testRule(@PathVariable("ruleId") Long ruleId, ModelMap mmap) throws Exception {
         PageData pd = new PageData();
@@ -390,7 +408,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 模版预览页面
      */
-    @RequiresPermissions("gxhpz:followTemplate:view")
+    //@RequiresPermissions("gxhpz:followTemplate:view")
     @GetMapping("/preview/{templateId}")
     public String preview(@PathVariable("templateId") Long templateId, ModelMap mmap) throws Exception {
         PageData pd = new PageData();
@@ -450,7 +468,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 批量更新字段配置
      */
-    @RequiresPermissions("gxhpz:followTemplate:field")
+    //@RequiresPermissions("gxhpz:followTemplate:field")
     @Log(title = "批量字段配置", businessType = BusinessType.UPDATE)
     @PostMapping("/batchUpdateFields")
     @ResponseBody
@@ -550,7 +568,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 保存字段规则
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+   // @RequiresPermissions("gxhpz:followTemplate:rule")
     @Log(title = "字段规则", businessType = BusinessType.INSERT)
     @PostMapping("/saveRule")
     @ResponseBody
@@ -565,7 +583,7 @@ public class FollowTemplateConfigController extends BaseController {
     /**
      * 更新字段规则
      */
-    @RequiresPermissions("gxhpz:followTemplate:rule")
+    //@RequiresPermissions("gxhpz:followTemplate:rule")
     @Log(title = "字段规则", businessType = BusinessType.UPDATE)
     @PostMapping("/updateRule")
     @ResponseBody

+ 1 - 1
health-admin/src/main/resources/application.yml

@@ -90,7 +90,7 @@ mybatis:
 # PageHelper分页插件
 pagehelper:
   helperDialect: mysql
-  supportMethodsArguments: true
+  supportMethodsArguments: false
   params: count=countSql
 
 # Shiro

+ 203 - 93
health-admin/src/main/resources/templates/gxhpz/followTemplateConfig/addField.html

@@ -7,77 +7,131 @@
 <body class="white-bg">
 <div class="wrapper wrapper-content animated fadeInRight ibox-content">
     <form class="form-horizontal m" id="form-field-add">
-        <input type="hidden" name="templateId" th:value="${templateId}">
+        <input type="hidden" name="templateId" th:value="${templateId}" />
 
+        <!-- 字段编码 -->
         <div class="form-group">
-            <label class="col-sm-3 control-label is-required">选择字段:</label>
+            <label class="col-sm-3 control-label is-required">字段编码:</label>
             <div class="col-sm-8">
-                <select name="fieldCode" class="form-control select2" required>
-                    <option value="">请选择字段</option>
-                    <optgroup th:each="entry : ${fieldsByTab}" th:label="${entry.key}">
-                        <option th:each="field : ${entry.value}"
-                                th:value="${field.fieldCode}"
-                                th:data-field-name="${field.fieldName}"
-                                th:data-field-type="${field.fieldType}"
-                                th:data-tab-code="${field.tabCode}"
-                                th:data-tab-name="${field.tabName}">
-                            [[${field.fieldName}]] ([[${field.fieldType}]])
-                        </option>
-                    </optgroup>
-                </select>
+                <input name="fieldCode" class="form-control" type="text" />
+
             </div>
         </div>
 
+        <!-- 字段名称 -->
         <div class="form-group">
             <label class="col-sm-3 control-label">字段名称:</label>
             <div class="col-sm-8">
-                <input name="fieldName" class="form-control" type="text" readonly>
+                <input name="fieldName" class="form-control" type="text" />
+            </div>
+        </div>
+
+        <!-- 字段类型 -->
+        <div class="form-group">
+            <label class="col-sm-3 control-label is-required">字段类型:</label>
+            <div class="col-sm-8">
+                <select name="fieldType" class="form-control" required>
+                    <option value="">请选择类型</option>
+                    <option value="input">输入框(input)</option>
+                    <option value="textarea">文本域(textarea)</option>
+                    <option value="radio">单选框(radio)</option>
+                    <option value="checkbox">复选框(checkbox)</option>
+                    <option value="select">下拉框(select)</option>
+                    <option value="file">文件上传(file)</option>
+                    <option value="datetime">日期时间(datetime)</option>
+                    <option value="table">表格(table)</option>
+                </select>
             </div>
         </div>
 
+        <!-- 所属Tab -->
         <div class="form-group">
-            <label class="col-sm-3 control-label">字段类型:</label>
+            <label class="col-sm-3 control-label is-required">所属Tab:</label>
             <div class="col-sm-8">
-                <input name="fieldType" class="form-control" type="text" readonly>
+                <select name="tabCode" class="form-control" required>
+                    <option value="">请选择Tab编码</option>
+                    <option value="tab-4">tab-4 - 本次任务</option>
+                    <option value="tab-6">tab-6 - 用药依从性</option>
+                    <option value="tab-7">tab-7 - 药物安全性</option>
+                    <option value="tab-8">tab-8 - 药物有效性</option>
+                    <option value="tab-9">tab-9 - 治疗方案</option>
+                    <option value="tab-10">tab-10 - 适宜性评估</option>
+                    <option value="tab-11">tab-11 - 用药记录</option>
+                    <option value="tab-12">tab-12 - 量表测评</option>
+                    <option value="tab-13">tab-13 - 患者咨询</option>
+                    <option value="tab-14">tab-14 - 其他</option>
+                </select>
+
             </div>
         </div>
 
+        <!-- Tab名称(用于显示) -->
         <div class="form-group">
-            <label class="col-sm-3 control-label">所属Tab:</label>
+            <label class="col-sm-3 control-label">Tab名称:</label>
             <div class="col-sm-8">
-                <input name="tabName" class="form-control" type="text" readonly>
-                <input name="tabCode" type="hidden">
+<!--                <input class="form-control" type="text" readonly placeholder="自动填充" />-->
+                <!-- 注意:这里你写的是 th:value="${{tabName}},双重大括号是转义输出,应该改为单层 -->
+                <!-- 推荐改为:th:value="${tabName}" -->
+                <input class="form-control" name="tabName" type="text" readonly placeholder="自动填充" th:value="${tabName}" />
             </div>
         </div>
 
+        <!-- 是否必填 -->
         <div class="form-group">
             <label class="col-sm-3 control-label">是否必填:</label>
             <div class="col-sm-8">
                 <div class="radio-box">
-                    <input type="radio" id="isRequired1" name="isRequired" value="1">
+                    <input type="radio" id="isRequired1" name="isRequired" value="1" />
                     <label for="isRequired1">是</label>
                 </div>
                 <div class="radio-box">
-                    <input type="radio" id="isRequired0" name="isRequired" value="0" checked>
+                    <input type="radio" id="isRequired0" name="isRequired" value="0" checked />
                     <label for="isRequired0">否</label>
                 </div>
             </div>
         </div>
 
+        <!-- 是否启用 -->
+        <div class="form-group">
+            <label class="col-sm-3 control-label">是否启用:</label>
+            <div class="col-sm-8">
+                <div class="radio-box">
+                    <input type="radio" id="isEnabled1" name="isEnabled" value="1" checked />
+                    <label for="isEnabled1">是</label>
+                </div>
+                <div class="radio-box">
+                    <input type="radio" id="isEnabled0" name="isEnabled" value="0" />
+                    <label for="isEnabled0">否</label>
+                </div>
+            </div>
+        </div>
+
+        <!-- 显示顺序 -->
         <div class="form-group">
             <label class="col-sm-3 control-label">显示顺序:</label>
             <div class="col-sm-8">
-                <input name="displayOrder" class="form-control" type="number" value="1" min="1" required>
+                <input name="displayOrder" class="form-control" type="number" value="1" min="0" required />
             </div>
         </div>
 
+        <!-- 占位符 -->
         <div class="form-group">
             <label class="col-sm-3 control-label">占位符:</label>
             <div class="col-sm-8">
-                <input name="placeholder" class="form-control" type="text" placeholder="请输入占位符文本">
+                <input name="placeholder" class="form-control" type="text" placeholder="请输入占位符文本" />
+            </div>
+        </div>
+
+        <!-- 验证规则(可选) -->
+        <div class="form-group">
+            <label class="col-sm-3 control-label">验证规则(JSON):</label>
+            <div class="col-sm-8">
+                <textarea name="validationRules" class="form-control" rows="2" placeholder='如:{"minLength": 5, "maxLength": 100}'></textarea>
+                <small class="text-muted">可选,输入 JSON 格式的验证规则</small>
             </div>
         </div>
 
+        <!-- 字段选项 -->
         <div class="form-group" id="fieldOptionsGroup" style="display: none;">
             <label class="col-sm-3 control-label">字段选项:</label>
             <div class="col-sm-8">
@@ -87,95 +141,132 @@
                 <button type="button" class="btn btn-sm btn-primary" onclick="addOption()">
                     <i class="fa fa-plus"></i> 添加选项
                 </button>
+                <small class="text-muted">例如:是,否 或 正常,异常</small>
             </div>
         </div>
     </form>
+    <div class="row">
+        <div class="col-sm-offset-5 col-sm-10">
+            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
+            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
+        </div>
+    </div>
 </div>
 
 <th:block th:include="include :: footer" />
 <th:block th:include="include :: select2-js" />
+
 <script th:inline="javascript">
-    var availableFields = [[${availableFields}]];
-    var fieldsByTab = {};
+    // var availableFields = [[${availableFields}]];
+    // 定义 Tab 映射关系:tabCode -> 中文名称
+    var tabMap = {
+        'tab-4':  '本次任务',
+        'tab-6':  '用药依从性',
+        'tab-7':  '药物安全性',
+        'tab-8':  '药物有效性',
+        'tab-9':  '治疗方案',
+        'tab-10': '适宜性评估',
+        'tab-11': '用药记录',
+        'tab-12': '量表测评',
+        'tab-13': '患者咨询',
+        'tab-14': '其他'
+    };
 
-    $(function() {
-        // 初始化select2
-        $('.select2').select2();
 
-        // 处理字段数据
-        availableFields.forEach(function(field) {
-            if (!fieldsByTab[field.tabName]) {
-                fieldsByTab[field.tabName] = [];
-            }
-            fieldsByTab[field.tabName].push(field);
+    // 更新 Tab 名称的函数
+    function updateTabName() {
+        var tabCode = $('select[name="tabCode"]').val();
+        var tabName = tabMap[tabCode] || ''; // 查找中文名,不存在则为空
+
+        // 更新隐藏域:用于表单提交
+        $('input[name="tabName"]').val(tabName);
+console.log("tabName="+tabName)
+        // 更新只读显示框(用于界面展示)
+        // 注意:Thymeleaf 的 th:value 不影响 JS 操作,直接用 val() 即可
+        $('input[readonly][name="tabName"]').val(tabName);
+    }
+
+    $(function () {
+        // 初始化 select2
+        //$('.select2').select2();
+
+
+        // 初始化:页面加载时尝试设置一次(比如编辑场景)
+        updateTabName();
+
+        // 监听 "所属Tab" 下拉框变化
+        $('select[name="tabCode"]').change(function () {
+            updateTabName();
         });
 
-        // 字段选择变化事件
-        $('select[name="fieldCode"]').change(function() {
-            var selectedOption = $(this).find('option:selected');
-            var fieldName = selectedOption.data('field-name');
-            var fieldType = selectedOption.data('field-type');
-            var tabCode = selectedOption.data('tab-code');
-            var tabName = selectedOption.data('tab-name');
-
-            $('input[name="fieldName"]').val(fieldName);
-            $('input[name="fieldType"]').val(fieldType);
-            $('input[name="tabCode"]').val(tabCode);
-            $('input[name="tabName"]').val(tabName);
-
-            // 根据字段类型显示/隐藏选项配置
-            if (fieldType === 'radio' || fieldType === 'checkbox' || fieldType === 'select') {
+        // 字段类型变化
+        $('select[name="fieldType"]').change(function () {
+            var type = $(this).val();
+            var fieldName = $('input[name="fieldName"]').val();
+
+            // 控制选项显示
+            if (['radio', 'checkbox', 'select'].includes(type)) {
                 $('#fieldOptionsGroup').show();
-                loadDefaultOptions(fieldType);
+                loadDefaultOptions(type);
             } else {
                 $('#fieldOptionsGroup').hide();
             }
 
-            // 设置默认占位符
-            var defaultPlaceholder = '';
-            if (fieldType === 'input' || fieldType === 'textarea') {
-                defaultPlaceholder = '请输入' + fieldName;
-            } else if (fieldType === 'select') {
-                defaultPlaceholder = '请选择' + fieldName;
-            } else if (fieldType === 'datetime') {
-                defaultPlaceholder = '请选择日期时间';
+            // 自动设置 placeholder
+            let placeholder = '';
+            if (type === 'input' || type === 'textarea') {
+                placeholder = '请输入' + (fieldName || '');
+            } else if (type === 'select') {
+                placeholder = '请选择' + (fieldName || '');
+            } else if (type === 'datetime') {
+                placeholder = '请选择日期时间';
             }
-            $('input[name="placeholder"]').val(defaultPlaceholder);
+            $('input[name="placeholder"]').val(placeholder);
         });
 
+        // 表单验证
         $("#form-field-add").validate({
+            rules: {
+                fieldCode: { required: true },
+                fieldType: { required: true },
+                tabCode: { required: true },
+                displayOrder: { required: true, digits: true }
+            },
             focusCleanup: true
         });
     });
 
     // 加载默认选项
-    function loadDefaultOptions(fieldType) {
-        var html = '';
-        var defaultOptions = ['选项1', '选项2', '选项3'];
+    function loadDefaultOptions(type) {
+        const defaults = {
+            'radio': ['是', '否'],
+            'checkbox': ['选项1', '选项2'],
+            'select': ['请选择', '选项1', '选项2']
+        };
+        const options = defaults[type] || ['选项1', '选项2'];
 
-        defaultOptions.forEach(function(option, index) {
+        let html = '';
+        options.forEach(opt => {
             html += '<div class="option-item" style="margin-bottom: 5px;">';
             html += '  <input type="text" class="form-control input-sm" style="width: 200px; display: inline-block;" ';
-            html += '         name="fieldOption" value="' + option + '" placeholder="选项文本">';
+            html += '         name="fieldOption" value="' + opt + '" placeholder="选项文本">';
             html += '  <button type="button" class="btn btn-sm btn-danger" onclick="removeOption(this)" style="margin-left: 5px;">';
             html += '    <i class="fa fa-minus"></i>';
             html += '  </button>';
             html += '</div>';
         });
-
         $('#fieldOptions').html(html);
     }
 
     // 添加选项
     function addOption() {
-        var html = '<div class="option-item" style="margin-bottom: 5px;">';
+        let html = '<div class="option-item" style="margin-bottom: 5px;">';
         html += '  <input type="text" class="form-control input-sm" style="width: 200px; display: inline-block;" ';
         html += '         name="fieldOption" placeholder="选项文本">';
         html += '  <button type="button" class="btn btn-sm btn-danger" onclick="removeOption(this)" style="margin-left: 5px;">';
         html += '    <i class="fa fa-minus"></i>';
         html += '  </button>';
         html += '</div>';
-
         $('#fieldOptions').append(html);
     }
 
@@ -184,35 +275,54 @@
         $(btn).closest('.option-item').remove();
     }
 
+    // 提交处理
     function submitHandler() {
-        if ($.validate.form()) {
-            var formData = $('#form-field-add').serializeArray();
-            var data = {};
-
-            // 处理表单数据
-            formData.forEach(function(item) {
-                if (item.name === 'fieldOption') {
-                    if (!data.fieldOptions) {
-                        data.fieldOptions = [];
-                    }
-                    if (item.value) {
-                        data.fieldOptions.push(item.value);
-                    }
-                } else {
-                    data[item.name] = item.value;
-                }
-            });
+        if (!$('#form-field-add').valid()) return false;
 
-            // 将选项数组转换为JSON字符串
-            if (data.fieldOptions && data.fieldOptions.length > 0) {
-                data.fieldOptions = JSON.stringify(data.fieldOptions);
-            }
+        var formData = $('#form-field-add').serializeArray();
+        var data = {};
 
-            // 设置默认值
-            data.isEnabled = 1;
+        formData.forEach(function (item) {
+            if (item.name === 'fieldOption') {
+                if (!data.fieldOptions) data.fieldOptions = [];
+                if (item.value) data.fieldOptions.push(item.value);
+            } else {
+                data[item.name] = item.value;
+            }
+        });
 
-            $.operate.save(ctx + "gxhpz/followTemplateConfig/saveField", data);
+        // 转换 fieldOptions 为 JSON 字符串
+        if (data.fieldOptions && data.fieldOptions.length > 0) {
+            data.fieldOptions = JSON.stringify(data.fieldOptions);
+        } else {
+            data.fieldOptions = null;
         }
+
+        // 设置默认值
+        data.isEnabled = data.isEnabled || 1;
+        data.isRequired = data.isRequired || 0;
+        $.ajax({
+            cache : true,
+            type : "POST",
+            url : ctx + "gxhpz/followTemplateConfig/saveField",
+            data : data,
+            async : false,
+            error : function(request) {
+                $.modal.alertError("失败");
+            },
+            success : function(data) {
+                if(data.code==500){
+                    $.modal.alertError(data.msg)
+                }else {
+                    $.modal.alertSuccess(data.msg)
+                    $.modal.closeTab();
+                }
+
+
+            }
+        });
+        // 发送请求(使用原接口)
+        //$.operate.save(ctx + "gxhpz/followTemplateConfig/saveField", data);
     }
 </script>
 </body>

+ 13 - 13
health-admin/src/main/resources/templates/gxhpz/followTemplateConfig/edit.html

@@ -10,13 +10,13 @@
         <div class="form-group">
             <label class="col-sm-3 control-label is-required">模版名称:</label>
             <div class="col-sm-8">
-                <input name="templateName" th:value="${templateName}" class="form-control" type="text" maxlength="100" required>
+                <input name="templateName" th:value="${template_name}" class="form-control" type="text" maxlength="100" required>
             </div>
         </div>
         <div class="form-group">
             <label class="col-sm-3 control-label">模版描述:</label>
             <div class="col-sm-8">
-                <textarea name="templateDesc" th:text="${templateDesc}" class="form-control" rows="3" maxlength="500"></textarea>
+                <textarea name="templateDesc" th:text="${template_desc}" class="form-control" rows="3" maxlength="500"></textarea>
             </div>
         </div>
         <div class="form-group">
@@ -24,8 +24,8 @@
             <div class="col-sm-8">
                 <select name="templateType" class="form-control" required>
                     <option value="">请选择模版类型</option>
-                    <option value="custom" th:selected="${templateType} == 'custom'">自定义</option>
-                    <option value="default" th:selected="${templateType} == 'default'">系统默认</option>
+                    <option value="custom" th:selected="${template_type} == 'custom'">自定义</option>
+                    <option value="default" th:selected="${template_type} == 'default'">系统默认</option>
                 </select>
             </div>
         </div>
@@ -47,10 +47,10 @@
             <div class="col-sm-8">
                 <select name="businessType" class="form-control">
                     <option value="">请选择适用业务</option>
-                    <option value="常规随访" th:selected="${businessType} eq '常规随访'">常规随访</option>
-                    <option value="脱落召回" th:selected="${businessType} eq '脱落召回'">脱落召回</option>
-                    <option value="不良反应" th:selected="${businessType} eq '不良反应'">不良反应</option>
-                    <option value="用药指导" th:selected="${businessType} eq '用药指导'">用药指导</option>
+                    <option value="常规随访" th:selected="${business_type} eq '常规随访'">常规随访</option>
+                    <option value="脱落召回" th:selected="${business_type} eq '脱落召回'">脱落召回</option>
+                    <option value="不良反应" th:selected="${business_type} eq '不良反应'">不良反应</option>
+                    <option value="用药指导" th:selected="${business_type} eq '用药指导'">用药指导</option>
                 </select>
             </div>
         </div>
@@ -64,17 +64,17 @@
             <label class="col-sm-3 control-label">创建信息:</label>
             <div class="col-sm-8">
                 <div class="form-control-static">
-                    创建人:<span th:text="${createdBy}"></span> |
-                    创建时间:<span th:text="${createdTime}"></span>
+                    创建人:<span th:text="${created_by}"></span> |
+                    创建时间:<span th:text="${created_time}"></span>
                 </div>
             </div>
         </div>
-        <div class="form-group" th:if="${updatedBy}">
+        <div class="form-group" th:if="${updated_by}">
             <label class="col-sm-3 control-label">更新信息:</label>
             <div class="col-sm-8">
                 <div class="form-control-static">
-                    更新人:<span th:text="${updatedBy}"></span> |
-                    更新时间:<span th:text="${updatedTime}"></span>
+                    更新人:<span th:text="${updated_by}"></span> |
+                    更新时间:<span th:text="${updated_time}"></span>
                 </div>
             </div>
         </div>

File diff ditekan karena terlalu besar
+ 1551 - 399
health-admin/src/main/resources/templates/gxhpz/followTemplateConfig/fields.html


+ 211 - 37
health-admin/src/main/resources/templates/gxhpz/followTemplateConfig/followTemplateConfig.html

@@ -2,12 +2,6 @@
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 <head>
     <th:block th:include="include :: header('随访模版配置')" />
-    <th:block th:include="include :: bootstrap-select-css" />
-    <th:block th:include="include :: bootstrap-select-js" />
-    <th:block th:include="include :: bootstrap-fileinput-css" />
-    <th:block th:include="include :: bootstrap-fileinput-js" />
-    <th:block th:include="include :: select2-css" />
-    <th:block th:include="include :: bootstrap-fileinput-css" />
 </head>
 <body class="gray-bg">
 <div class="container-fluid">
@@ -41,7 +35,7 @@
 
         <div class="btn-group-sm" id="toolbar" role="group">
             <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="gxhpz:followTemplate:add">
-                <i class="fa fa-plus"></i> 添加
+                <i class="fa fa-plus"></i> 新增模版
             </a>
             <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="gxhpz:followTemplate:edit">
                 <i class="fa fa-edit"></i> 修改
@@ -52,12 +46,15 @@
             <a class="btn btn-info single disabled" onclick="configFields()" shiro:hasPermission="gxhpz:followTemplate:field">
                 <i class="fa fa-cog"></i> 字段配置
             </a>
-            <a class="btn btn-warning single disabled" onclick="configRules()" shiro:hasPermission="gxhpz:followTemplate:rule">
-                <i class="fa fa-gear"></i> 规则配置
-            </a>
-            <a class="btn btn-success single disabled" onclick="copyTemplate()" shiro:hasPermission="gxhpz:followTemplate:add">
-                <i class="fa fa-copy"></i> 复制模版
+            <a class="btn btn-info single disabled" onclick="addFields()" shiro:hasPermission="gxhpz:followTemplate:field">
+                <i class="fa fa-cog"></i> 添加字段
             </a>
+<!--            <a class="btn btn-warning single disabled" onclick="configRules()" shiro:hasPermission="gxhpz:followTemplate:rule">-->
+<!--                <i class="fa fa-gear"></i> 规则配置-->
+<!--            </a>-->
+<!--            <a class="btn btn-success single disabled" onclick="copyTemplate()" shiro:hasPermission="gxhpz:followTemplate:add">-->
+<!--                <i class="fa fa-copy"></i> 复制模版-->
+<!--            </a>-->
         </div>
 
         <div class="col-sm-12 select-table table-striped">
@@ -82,6 +79,10 @@
                         <input type="hidden" name="sourceTemplateId">
                     </div>
                     <div class="form-group">
+                        <label>模版描述:</label>
+                        <textarea class="form-control" name="templateDesc" rows="3" placeholder="请输入模版描述"></textarea>
+                    </div>
+                    <div class="form-group">
                         <label>状态:</label>
                         <select class="form-control" name="status">
                             <option value="1">启用</option>
@@ -116,6 +117,13 @@
             removeUrl: prefix + "/remove",
             exportUrl: prefix + "/export",
             modalName: "随访模版配置",
+            search: false,
+            showSearch: false,
+            showRefresh: true,
+            showToggle: true,
+            showColumns: true,
+            sortName: "createdTime",
+            sortOrder: "desc",
             columns: [{
                 checkbox: true
             },
@@ -125,16 +133,26 @@
                     visible: false
                 },
                 {
-                    field: 'templateName',
-                    title: '模版名称'
+                    field: 'template_name',
+                    title: '模版名称',
+                    align: 'left'
                 },
                 {
-                    field: 'templateDesc',
-                    title: '模版描述'
+                    field: 'template_desc',
+                    title: '模版描述',
+                    align: 'left',
+                    formatter: function(value, row, index) {
+                        if (value && value.length > 50) {
+                            return '<span title="' + value + '">' + value.substring(0, 50) + '...</span>';
+                        }
+                        return value || '-';
+                    }
                 },
                 {
-                    field: 'templateType',
+                    field: 'template_type',
                     title: '模版类型',
+                    align: 'center',
+                    width: 100,
                     formatter: function(value, row, index) {
                         if (value == 'default') {
                             return '<span class="label label-primary">系统默认</span>';
@@ -144,49 +162,75 @@
                     }
                 },
                 {
+                    field: 'business_type',
+                    title: '适用业务',
+                    align: 'center',
+                    width: 100,
+                    formatter: function(value, row, index) {
+                        return value || '-';
+                    }
+                },
+                {
                     field: 'status',
                     title: '状态',
+                    align: 'center',
+                    width: 80,
                     formatter: function(value, row, index) {
-                        // 自定义字典转换函数
-                        const dictMap = {
-                            '0': '禁用',
-                            '1': '启用'
-                        };
-                        return dictMap[value] || value; // 匹配失败返回原值
+                        if (value == '1') {
+                            return '<span class="label label-success">启用</span>';
+                        } else {
+                            return '<span class="label label-danger">禁用</span>';
+                        }
                     }
                 },
                 {
-                    field: 'createdBy',
-                    title: '创建人'
+                    field: 'created_by',
+                    title: '创建人',
+                    align: 'center',
+                    width: 100
                 },
                 {
-                    field: 'createdTime',
-                    title: '创建时间'
+                    field: 'created_time',
+                    title: '创建时间',
+                    align: 'center',
+                    width: 160
                 },
                 {
                     title: '操作',
                     align: 'center',
+                    width: 300,
                     formatter: function(value, row, index) {
                         var actions = [];
 
-                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.view(' + row.id + ')"><i class="fa fa-eye"></i> 预览</a>');
+                        // 预览按钮
+                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="previewTemplate(' + row.id + ')" title="预览模版">' +
+                            '<i class="fa fa-eye"></i> 预览</a>');
 
+                        // 编辑按钮
                         if (editFlag) {
-                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a>');
+                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')" title="编辑模版">' +
+                                '<i class="fa fa-edit"></i> 编辑</a>');
                         }
 
+                        // 字段配置按钮
                         if (fieldFlag) {
-                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="configFields(' + row.id + ')"><i class="fa fa-cog"></i> 字段配置</a>');
+                            actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="configFields(' + row.id + ')" title="配置字段">' +
+                                '<i class="fa fa-cog"></i> 字段配置</a>');
                         }
 
+                        // 规则配置按钮
                         if (ruleFlag) {
-                            actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="configRules(' + row.id + ')"><i class="fa fa-gear"></i> 规则配置</a>');
+                            actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="configRules(' + row.id + ')" title="配置规则">' +
+                                '<i class="fa fa-gear"></i> 规则配置</a>');
                         }
 
+                        // 状态切换按钮
                         if (row.status == '1') {
-                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="changeStatus(' + row.id + ', 0)"><i class="fa fa-ban"></i> 禁用</a>');
+                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="changeStatus(' + row.id + ', 0)" title="禁用模版">' +
+                                '<i class="fa fa-ban"></i> 禁用</a>');
                         } else {
-                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="changeStatus(' + row.id + ', 1)"><i class="fa fa-check"></i> 启用</a>');
+                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="changeStatus(' + row.id + ', 1)" title="启用模版">' +
+                                '<i class="fa fa-check"></i> 启用</a>');
                         }
 
                         return actions.join(' ');
@@ -209,7 +253,18 @@
         var url = ctx + 'gxhpz/followTemplateConfig/fields/' + id;
         $.modal.openTab("字段配置", url);
     }
-
+    function addFields(id) {
+        if (typeof id === 'undefined') {
+            var rows = $.table.selectFirstColumns();
+            if (rows.length == 0) {
+                $.modal.alertWarning("请选择一条记录");
+                return;
+            }
+            id = rows[0];
+        }
+        var url = ctx + 'gxhpz/followTemplateConfig/addField/' + id;
+        $.modal.openTab("添加字段", url);
+    }
     // 规则配置
     function configRules(id) {
         if (typeof id === 'undefined') {
@@ -232,25 +287,47 @@
             return;
         }
 
+        // 获取选中行的数据
+        var selectedData = $("#bootstrap-table").bootstrapTable('getSelections')[0];
+
+        // 设置默认值
         $("input[name='sourceTemplateId']").val(rows[0]);
+        $("input[name='templateName']").val(selectedData.templateName + "_副本");
+        $("textarea[name='templateDesc']").val(selectedData.templateDesc ? selectedData.templateDesc + " (复制)" : "");
+
         $("#copyTemplateModal").modal('show');
     }
 
     // 提交复制模版
     function submitCopyTemplate() {
+        var templateName = $("input[name='templateName']").val();
+        if (!templateName || templateName.trim() === '') {
+            $.modal.alertWarning("请输入模版名称");
+            return;
+        }
+
         var data = $("#copyTemplateForm").serialize();
+        $.modal.loading("正在复制模版,请稍候...");
+
         $.ajax({
             url: prefix + "/copy",
             type: "post",
             data: data,
             success: function(result) {
+                $.modal.closeLoading();
                 if (result.code == 0) {
                     $.modal.alertSuccess("复制成功");
                     $("#copyTemplateModal").modal('hide');
                     $.table.refresh();
+                    // 清空表单
+                    $("#copyTemplateForm")[0].reset();
                 } else {
-                    $.modal.alertError(result.msg);
+                    $.modal.alertError(result.msg || "复制失败");
                 }
+            },
+            error: function() {
+                $.modal.closeLoading();
+                $.modal.alertError("复制失败,请重试");
             }
         });
     }
@@ -259,6 +336,7 @@
     function changeStatus(id, status) {
         var statusText = status == 1 ? "启用" : "禁用";
         $.modal.confirm("确认要" + statusText + "该模版吗?", function() {
+            $.modal.loading("正在" + statusText + ",请稍候...");
             $.ajax({
                 url: prefix + "/changeStatus",
                 type: "post",
@@ -267,22 +345,118 @@
                     status: status
                 },
                 success: function(result) {
+                    $.modal.closeLoading();
                     if (result.code == 0) {
                         $.modal.alertSuccess(statusText + "成功");
                         $.table.refresh();
                     } else {
-                        $.modal.alertError(result.msg);
+                        $.modal.alertError(result.msg || statusText + "失败");
                     }
+                },
+                error: function() {
+                    $.modal.closeLoading();
+                    $.modal.alertError(statusText + "失败,请重试");
                 }
             });
         });
     }
 
     // 预览模版
-    function preview(id) {
+    function previewTemplate(id) {
+        if (typeof id === 'undefined') {
+            var rows = $.table.selectFirstColumns();
+            if (rows.length == 0) {
+                $.modal.alertWarning("请选择一条记录");
+                return;
+            }
+            id = rows[0];
+        }
         var url = ctx + 'gxhpz/followTemplateConfig/preview/' + id;
         $.modal.openTab("模版预览", url);
     }
+
+    // 导出模版
+    function exportTemplate() {
+        var rows = $.table.selectColumns();
+        if (rows.length == 0) {
+            $.modal.alertWarning("请选择要导出的记录");
+            return;
+        }
+
+        $.modal.confirm("确认要导出选中的模版吗?", function() {
+            var ids = rows.join(",");
+            window.location.href = prefix + "/export?ids=" + ids;
+        });
+    }
+
+    // 批量删除确认
+    function batchDelete() {
+        var rows = $.table.selectColumns();
+        if (rows.length == 0) {
+            $.modal.alertWarning("请选择要删除的记录");
+            return;
+        }
+
+        $.modal.confirm("确认要删除选中的 " + rows.length + " 条记录吗?", function() {
+            $.operate.removeAll();
+        });
+    }
 </script>
+
+<style>
+    /* 自定义样式 */
+    .table th {
+        background-color: #f5f5f5;
+        font-weight: 600;
+    }
+
+    .btn-xs {
+        margin: 1px;
+    }
+
+    .label {
+        font-size: 11px;
+        padding: 3px 6px;
+    }
+
+    /* 响应式调整 */
+    @media (max-width: 768px) {
+        .btn-xs {
+            margin: 2px 1px;
+            padding: 2px 5px;
+            font-size: 10px;
+        }
+
+        .table-responsive {
+            font-size: 12px;
+        }
+    }
+
+    /* 模态框样式优化 */
+    .modal-header {
+        background-color: #f5f5f5;
+        border-bottom: 1px solid #ddd;
+    }
+
+    .modal-title {
+        font-weight: 600;
+        color: #333;
+    }
+
+    .form-group label {
+        font-weight: 600;
+        color: #555;
+    }
+
+    /* 工具栏样式 */
+    #toolbar {
+        margin-bottom: 15px;
+    }
+
+    #toolbar .btn {
+        margin-right: 5px;
+        margin-bottom: 5px;
+    }
+</style>
 </body>
 </html>

+ 36 - 42
health-admin/src/main/resources/templates/gxhpz/followTemplateConfig/preview.html

@@ -113,46 +113,29 @@
         <div class="col-sm-12">
             <div class="ibox">
                 <div class="ibox-title">
-                    <h5>模版预览 - <span th:text="${template.templateName}"></span></h5>
-                    <div class="ibox-tools">
-                        <button class="btn btn-default btn-sm" onclick="window.close()">
-                            <i class="fa fa-times"></i> 关闭
-                        </button>
-                    </div>
-                </div>
-
-                <div class="ibox-content">
-                    <div class="preview-note">
-                        <i class="fa fa-info-circle"></i>
-                        这是模版预览页面,所有表单元素均为演示效果,不能进行实际操作。
-                    </div>
-
-                    <!-- 模版基本信息 -->
-                    <div class="template-info">
-                        <h4><i class="fa fa-info-circle"></i> 模版信息</h4>
-                        <div class="row">
-                            <div class="col-sm-6">
-                                <p><strong>模版名称:</strong><span th:text="${template.templateName}"></span></p>
-                                <p><strong>模版类型:</strong>
-                                    <span th:if="${template.templateType} =='custom' ">自定义</span>
-                                    <span th:if="${template.templateType} =='default'">系统默认</span></p>
-                                <p><strong>适用业务:</strong><span th:text="${template.businessType}"></span></p>
-                            </div>
-                            <div class="col-sm-6">
-                                <p><strong>状态:</strong>
-                                    <span th:if="${template.status == 1}" class="label label-success">启用</span>
-                                    <span th:if="${template.status == 0}" class="label label-danger">禁用</span>
-                                </p>
-                                <p><strong>创建人:</strong><span th:text="${template.createdBy}"></span></p>
-                                <p><strong>创建时间:</strong><span th:text="${template.createdTime}"></span></p>
-                            </div>
-                        </div>
-                        <div class="row" th:if="${template.templateDesc}">
-                            <div class="col-sm-12">
-                                <p><strong>模版描述:</strong><span th:text="${template.templateDesc}"></span></p>
-                            </div>
+                    <h5>模版预览 - <span th:text="${template.get('templateName')}"></span></h5>
+
+                    <!-- 模版信息 -->
+                    <p><strong>模版名称:</strong><span th:text="${template.get('templateName')}"></span></p>
+                    <p><strong>模版类型:</strong>
+                        <span th:if="${template.get('templateType') == 'custom'}">自定义</span>
+                        <span th:if="${template.get('templateType') == 'default'}">系统默认</span>
+                    </p>
+                    <p><strong>适用业务:</strong><span th:text="${template.get('businessType')}"></span></p>
+
+                    <p><strong>状态:</strong>
+                        <span th:if="${template.get('status') == 1}" class="label label-success">启用</span>
+                        <span th:if="${template.get('status') == 0}" class="label label-danger">禁用</span>
+                    </p>
+                    <p><strong>创建人:</strong><span th:text="${template.get('createdBy')}"></span></p>
+                    <p><strong>创建时间:</strong><span th:text="${template.get('createdTime')}"></span></p>
+
+                    <div class="row" th:if="${template.get('templateDesc')}">
+                        <div class="col-sm-12">
+                            <p><strong>模版描述:</strong><span th:text="${template.get('templateDesc')}"></span></p>
                         </div>
                     </div>
+                    </div>
 
                     <!-- 预览内容容器 -->
                     <div class="preview-container">
@@ -231,7 +214,12 @@
 </div>
 
 <th:block th:include="include :: footer" />
-<th:block th:include="include :: bootstrap-table-js" />
+<th:block th:include="include :: bootstrap-select-css" />
+<th:block th:include="include :: bootstrap-select-js" />
+<th:block th:include="include :: bootstrap-fileinput-css" />
+<th:block th:include="include :: bootstrap-fileinput-js" />
+<th:block th:include="include :: datetimepicker-css" />
+<th:block th:include="include :: datetimepicker-js" />
 <script th:inline="javascript">
     var templateId = [[${templateId}]];
     var templateConfig = null;
@@ -278,9 +266,15 @@
 
         var tabHtml = '';
         tabs.forEach(function(tab) {
-            if (tab.tabCode !== 'tab-4') { // 本次任务Tab已经存在
-                tabHtml += '<li><a data-toggle="tab" href="#preview-' + tab.tabCode + '">' + tab.tabName + '</a></li>';
-                $('#preview-' + tab.tabCode).addClass('enabled');
+            if (tab.tab_code !== 'tab-4') {
+                console.log("tab_code="+tab.tab_code);
+                console.log("tab="+tab);
+
+                console.log("tabCode="+tab.tab_code);
+                console.log("tabName="+tab.tab_name);
+                // 本次任务Tab已经存在
+                tabHtml += '<li><a data-toggle="tab" href="#preview-' + tab.tab_code + '">' + tab.tab_name + '</a></li>';
+                $('#preview-' + tab.tab_code).addClass('enabled');
             }
         });
 

+ 1 - 1
health-admin/src/main/resources/templates/gxhpz/followTemplateConfig/rules.html

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
+<html lang="zh" xmlns:th="http://www.thymeleaf.org">
 <head>
     <th:block th:include="include :: header('规则配置')" />
     <style>

+ 59 - 11
health-system/src/main/java/com/bzd/system/service/gxhpz/FollowTemplateConfigService.java

@@ -5,12 +5,15 @@ import com.bzd.common.config.dao.PageData;
 import com.bzd.common.utils.StringUtils;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.pagehelper.PageHelper;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
 
+import static com.bzd.common.utils.ShiroUtils.getSysUser;
+
 /**
  * 随访模版配置服务
  * @author system
@@ -75,16 +78,58 @@ public class FollowTemplateConfigService {
     /**
      * 查询字段配置列表
      */
-    public List<PageData> selectFieldList(PageData pd) throws Exception {
-        return (List<PageData>) daoSupport.findForList("followTemplateConfigMapper.selectFieldList", pd);
+    public List<PageData> selectFieldList(final PageData pd) throws Exception {
+
+//        PageHelper.offsetPage(0, Integer.MAX_VALUE); // 从0开始,取最大数量
+        PageHelper.clearPage();
+        // 从数据库查询原始数据
+        List<PageData> dbFields = (List<PageData>) daoSupport.findForList("followTemplateConfigMapper.selectFieldList", pd);
+
+        List<PageData> result = new ArrayList<>();
+
+        for (PageData field : dbFields) {
+            // 从数据库字段中提取值,用 createField 重新构建,确保格式统一
+            String fieldCode = field.getString("field_code");         // 数据库字段名
+            String fieldName = field.getString("field_name");
+            String fieldType = field.getString("field_type");
+            String tabCode = field.getString("tab_code");
+            String tabName = field.getString("tab_name");
+            Integer displayOrder = field.getInteger("display_order");
+            Integer isRequired = field.getInteger("is_required");
+
+            // 使用 createField 统一构建(复用逻辑)
+            PageData standardizedField = createField(
+                    fieldCode,
+                    fieldName,
+                    fieldType != null ? fieldType : "input",  // 默认 input
+                    tabCode,
+                    tabName,
+                    displayOrder != null ? displayOrder : 99,
+                    isRequired != null && isRequired == 1      // 1 表示 true
+            );
+
+            // 如果数据库有额外字段(如 id、remark 等),可以再 put 回去
+             standardizedField.put("id", field.get("id"));
+
+            result.add(standardizedField);
+        }
+
+        return result;
+
+
     }
 
     /**
      * 新增字段配置
      */
     public Integer insertField(PageData pd) throws Exception {
+
         return daoSupport.save("followTemplateConfigMapper.insertField", pd);
     }
+    public List<PageData> checkFields(PageData pd) throws Exception {
+
+        return (List<PageData>) daoSupport.findForList("followTemplateConfigMapper.checkFields", pd);
+    }
 
     /**
      * 删除字段配置
@@ -108,7 +153,7 @@ public class FollowTemplateConfigService {
     public List<PageData> getAvailableFields() throws Exception {
         List<PageData> fields = new ArrayList<>();
         
-        // 本次任务 tab-4
+        // 本次任务 tab-4做到这里 模版配置 动态的
         fields.add(createField("returnMethod", "回访方式", "radio", "tab-4", "本次任务", 1, true));
         fields.add(createField("returnImgUrl", "回访图片", "file", "tab-4", "本次任务", 2, false));
         fields.add(createField("InterviewRecord", "面访记录", "input", "tab-4", "本次任务", 3, false));
@@ -165,7 +210,7 @@ public class FollowTemplateConfigService {
         // 其他 tab-14
         fields.add(createField("patientConditionAssessment", "患者病情评估", "select", "tab-14", "其他", 1, false));
         fields.add(createField("projectDescription", "共建项目描述", "textarea", "tab-14", "其他", 2, false));
-        
+
         return fields;
     }
 
@@ -196,7 +241,8 @@ public class FollowTemplateConfigService {
         PageData template = selectTemplateById(pd);
         result.put("template", template);
         
-        // 获取启用的Tab配置
+        // 获取启用的Tab配置 templateId
+        pd.put("templateId",pd.get("id"));
         List<PageData> tabs = (List<PageData>) daoSupport.findForList("followTemplateConfigMapper.selectTabList", pd);
         result.put("tabs", tabs);
         
@@ -337,7 +383,9 @@ public class FollowTemplateConfigService {
             // 先删除原有配置
             PageData deleteTabPd = new PageData();
             deleteTabPd.put("templateId", templateId);
-            daoSupport.delete("FollowTemplateConfigMapper.deleteTemplateTabsByTemplateId", deleteTabPd);
+            daoSupport.delete("followTemplateConfigMapper.deleteTabsByTemplateId", deleteTabPd);
+            daoSupport.delete("followTemplateConfigMapper.deleteFieldsByTemplateId", deleteTabPd);
+            daoSupport.delete("followTemplateConfigMapper.deleteRulesByTemplateId", deleteTabPd);
 
             // 解析并保存新配置
             List<Map<String, Object>> tabConfigs = objectMapper.readValue(tabConfigData,
@@ -351,7 +399,7 @@ public class FollowTemplateConfigService {
                 tabPd.put("displayOrder", tabConfig.get("displayOrder"));
                 tabPd.put("isEnabled", tabConfig.get("isEnabled"));
                 tabPd.put("createdTime", pd.get("updatedTime"));
-                daoSupport.save("FollowTemplateConfigMapper.insertTemplateTab", tabPd);
+                daoSupport.save("followTemplateConfigMapper.insertTab", tabPd);
             }
         }
 
@@ -360,7 +408,7 @@ public class FollowTemplateConfigService {
             // 先删除原有配置
             PageData deleteFieldPd = new PageData();
             deleteFieldPd.put("templateId", templateId);
-            daoSupport.delete("FollowTemplateConfigMapper.deleteTemplateFieldsByTemplateId", deleteFieldPd);
+            daoSupport.delete("followTemplateConfigMapper.deleteFieldsByTemplateId", deleteFieldPd);
 
             // 解析并保存新配置
             List<Map<String, Object>> fieldConfigs = objectMapper.readValue(fieldConfigData,
@@ -378,7 +426,7 @@ public class FollowTemplateConfigService {
                 fieldPd.put("placeholder", fieldConfig.get("placeholder"));
                 fieldPd.put("isEnabled", 1);
                 fieldPd.put("createdTime", pd.get("updatedTime"));
-                daoSupport.save("FollowTemplateConfigMapper.insertTemplateField", fieldPd);
+                daoSupport.save("followTemplateConfigMapper.insertField", fieldPd);
             }
         }
 
@@ -392,11 +440,11 @@ public class FollowTemplateConfigService {
 
 
     public List<PageData> getTemplateFields(PageData pd) throws Exception {
-        return (List<PageData>) daoSupport.findForList("FollowTemplateConfigMapper.selectTemplateFieldsByTemplateId", pd);
+        return (List<PageData>) daoSupport.findForList("followTemplateConfigMapper.selectTemplateFieldsByTemplateId", pd);
     }
 
     public Integer updateRuleStatus(PageData pd) throws Exception {
-        return (Integer) daoSupport.update("FollowTemplateConfigMapper.updateRuleStatus", pd);
+        return (Integer) daoSupport.update("followTemplateConfigMapper.updateRuleStatus", pd);
     }
 
     public Integer deleteRuleById(String id) throws Exception {

+ 82 - 64
health-system/src/main/resources/mapper/gxhpz/followTemplateConfigMapper.xml

@@ -3,70 +3,70 @@
 <mapper namespace="followTemplateConfigMapper">
 
     <!-- 模版配置结果映射 -->
-    <resultMap id="TemplateConfigResult" type="com.bzd.common.config.dao.PageData">
-        <result property="id" column="id"/>
-        <result property="templateName" column="template_name"/>
-        <result property="templateDesc" column="template_desc"/>
-        <result property="templateType" column="template_type"/>
-        <result property="businessType" column="business_type"/>
-        <result property="status" column="status"/>
-        <result property="storeId" column="store_id"/>
-        <result property="createdBy" column="created_by"/>
-        <result property="createdTime" column="created_time"/>
-        <result property="updatedBy" column="updated_by"/>
-        <result property="updatedTime" column="updated_time"/>
-        <result property="remark" column="remark"/>
-    </resultMap>
+<!--    <resultMap id="TemplateConfigResult" type="com.bzd.common.config.dao.PageData">-->
+<!--        <result property="id" column="id"/>-->
+<!--        <result property="templateName" column="template_name"/>-->
+<!--        <result property="templateDesc" column="template_desc"/>-->
+<!--        <result property="templateType" column="template_type"/>-->
+<!--        <result property="businessType" column="business_type"/>-->
+<!--        <result property="status" column="status"/>-->
+<!--        <result property="storeId" column="store_id"/>-->
+<!--        <result property="createdBy" column="created_by"/>-->
+<!--        <result property="createdTime" column="created_time"/>-->
+<!--        <result property="updatedBy" column="updated_by"/>-->
+<!--        <result property="updatedTime" column="updated_time"/>-->
+<!--        <result property="remark" column="remark"/>-->
+<!--    </resultMap>-->
 
     <!-- 字段配置结果映射 -->
-    <resultMap id="FieldConfigResult" type="com.bzd.common.config.dao.PageData">
-        <result property="id" column="id"/>
-        <result property="templateId" column="template_id"/>
-        <result property="fieldCode" column="field_code"/>
-        <result property="fieldName" column="field_name"/>
-        <result property="fieldType" column="field_type"/>
-        <result property="fieldOptions" column="field_options"/>
-        <result property="isRequired" column="is_required"/>
-        <result property="displayOrder" column="display_order"/>
-        <result property="tabCode" column="tab_code"/>
-        <result property="tabName" column="tab_name"/>
-        <result property="isEnabled" column="is_enabled"/>
-        <result property="placeholder" column="placeholder"/>
-        <result property="validationRules" column="validation_rules"/>
-        <result property="createdTime" column="created_time"/>
-    </resultMap>
+<!--    <resultMap id="FieldConfigResult" type="com.bzd.common.config.dao.PageData">-->
+<!--        <result property="id" column="id"/>-->
+<!--        <result property="templateId" column="template_id"/>-->
+<!--        <result property="fieldCode" column="field_code"/>-->
+<!--        <result property="fieldName" column="field_name"/>-->
+<!--        <result property="fieldType" column="field_type"/>-->
+<!--        <result property="fieldOptions" column="field_options"/>-->
+<!--        <result property="isRequired" column="is_required"/>-->
+<!--        <result property="displayOrder" column="display_order"/>-->
+<!--        <result property="tabCode" column="tab_code"/>-->
+<!--        <result property="tabName" column="tab_name"/>-->
+<!--        <result property="isEnabled" column="is_enabled"/>-->
+<!--        <result property="placeholder" column="placeholder"/>-->
+<!--        <result property="validationRules" column="validation_rules"/>-->
+<!--        <result property="createdTime" column="created_time"/>-->
+<!--    </resultMap>-->
 
     <!-- 规则配置结果映射 -->
-    <resultMap id="RuleConfigResult" type="com.bzd.common.config.dao.PageData">
-        <result property="id" column="id"/>
-        <result property="templateId" column="template_id"/>
-        <result property="ruleName" column="rule_name"/>
-        <result property="triggerFieldCode" column="trigger_field_code"/>
-        <result property="triggerFieldValue" column="trigger_field_value"/>
-        <result property="targetFieldCodes" column="target_field_codes"/>
-        <result property="actionType" column="action_type"/>
-        <result property="ruleLogic" column="rule_logic"/>
-        <result property="isEnabled" column="is_enabled"/>
-        <result property="createdTime" column="created_time"/>
-    </resultMap>
+<!--    <resultMap id="RuleConfigResult" type="com.bzd.common.config.dao.PageData">-->
+<!--        <result property="id" column="id"/>-->
+<!--        <result property="templateId" column="template_id"/>-->
+<!--        <result property="ruleName" column="rule_name"/>-->
+<!--        <result property="triggerFieldCode" column="trigger_field_code"/>-->
+<!--        <result property="triggerFieldValue" column="trigger_field_value"/>-->
+<!--        <result property="targetFieldCodes" column="target_field_codes"/>-->
+<!--        <result property="actionType" column="action_type"/>-->
+<!--        <result property="ruleLogic" column="rule_logic"/>-->
+<!--        <result property="isEnabled" column="is_enabled"/>-->
+<!--        <result property="createdTime" column="created_time"/>-->
+<!--    </resultMap>-->
 
     <!-- Tab配置结果映射 -->
-    <resultMap id="TabConfigResult" type="com.bzd.common.config.dao.PageData">
-        <result property="id" column="id"/>
-        <result property="templateId" column="template_id"/>
-        <result property="tabCode" column="tab_code"/>
-        <result property="tabName" column="tab_name"/>
-        <result property="displayOrder" column="display_order"/>
-        <result property="isEnabled" column="is_enabled"/>
-        <result property="iconClass" column="icon_class"/>
-        <result property="createdTime" column="created_time"/>
-    </resultMap>
+<!--    <resultMap id="TabConfigResult" type="com.bzd.common.config.dao.PageData">-->
+<!--        <result property="id" column="id"/>-->
+<!--        <result property="templateId" column="template_id"/>-->
+<!--        <result property="tabCode" column="tab_code"/>-->
+<!--        <result property="tabName" column="tab_name"/>-->
+<!--        <result property="displayOrder" column="display_order"/>-->
+<!--        <result property="isEnabled" column="is_enabled"/>-->
+<!--        <result property="iconClass" column="icon_class"/>-->
+<!--        <result property="createdTime" column="created_time"/>-->
+<!--    </resultMap>-->
 
     <!-- 查询模版配置列表 -->
-    <select id="selectTemplateList" parameterType="pd" resultMap="TemplateConfigResult">
+    <select id="selectTemplateList" parameterType="pd" resultType="pd">
         SELECT
         id, template_name, template_desc, template_type, status, store_id,
-        created_by, created_time, updated_by, updated_time, remark
+        created_by, created_time, updated_by, updated_time, remark,business_type
         FROM s_follow_template_config
         WHERE 1=1
         <if test="templateName != null and templateName != ''">
@@ -82,7 +82,7 @@
     </select>
 
     <!-- 根据ID查询模版配置 -->
-    <select id="selectTemplateById" parameterType="pd" resultMap="TemplateConfigResult">
+    <select id="selectTemplateById" parameterType="pd" resultType="pd">
         SELECT
             id, template_name, template_desc, template_type, status, store_id,
             created_by, created_time, updated_by, updated_time, remark,business_type
@@ -129,29 +129,47 @@
     </update>
 
     <!-- 查询字段配置列表 -->
-    <select id="selectFieldList" parameterType="pd" resultMap="FieldConfigResult">
+    <select id="selectFieldList" parameterType="pd" resultType="pd">
         SELECT
         id, template_id, field_code, field_name, field_type, field_options,
         is_required, display_order, tab_code, tab_name, is_enabled,
         placeholder, validation_rules, created_time
         FROM s_follow_template_fields
-        WHERE template_id = #{templateId}
-        <if test="isEnabled != null and isEnabled != ''">
+        WHERE 1=1
+        <if test="isEnabled != null">
             AND is_enabled = #{isEnabled}
         </if>
-        ORDER BY tab_code, display_order
+        <if test="storeId != null">
+            AND store_id = #{storeId}
+        </if>
+        ORDER BY tab_code
     </select>
 
+    <select id="checkFields" parameterType="pd" resultType="pd">
+        SELECT *
+        FROM s_follow_template_fields
+        <where>
+            <if test="fieldName != null and fieldName != ''">
+                field_name = #{fieldName}
+            </if>
+            <if test="fieldCode != null and fieldCode != ''">
+                OR field_code = #{fieldCode}
+            </if>
+        </where>
+    </select>
+
+
+
     <!-- 新增字段配置 -->
     <insert id="insertField" parameterType="pd">
         INSERT INTO s_follow_template_fields (
             template_id, field_code, field_name, field_type, field_options,
             is_required, display_order, tab_code, tab_name, is_enabled,
-            placeholder, validation_rules, created_time
+            placeholder, validation_rules, created_time,store_id
         ) VALUES (
                      #{templateId}, #{fieldCode}, #{fieldName}, #{fieldType}, #{fieldOptions},
                      #{isRequired}, #{displayOrder}, #{tabCode}, #{tabName}, #{isEnabled},
-                     #{placeholder}, #{validationRules}, #{createdTime}
+                     #{placeholder}, #{validationRules}, #{createdTime}, #{storeId}
                  )
     </insert>
 
@@ -169,7 +187,7 @@
     </delete>
 
     <!-- 查询规则配置列表 -->
-    <select id="selectRuleList" parameterType="pd" resultMap="RuleConfigResult">
+    <select id="selectRuleList" parameterType="pd" resultType="pd">
         SELECT
         id, template_id, rule_name, trigger_field_code, trigger_field_value,
         target_field_codes, action_type, rule_logic, is_enabled, created_time
@@ -195,7 +213,7 @@
 
 
     <!-- 查询Tab配置列表 -->
-    <select id="selectTabList" parameterType="pd" resultMap="TabConfigResult">
+    <select id="selectTabList" parameterType="pd" resultType="pd">
         SELECT
         id, template_id, tab_code, tab_name, display_order, is_enabled,
         icon_class, created_time
@@ -310,7 +328,7 @@
     </update>
 
     <!-- 根据ID查询规则 -->
-    <select id="selectRuleById" parameterType="pd" resultMap="RuleConfigResult">
+    <select id="selectRuleById" parameterType="pd" resultType="pd">
         SELECT
             id, template_id, rule_name, trigger_field_code, trigger_field_value,
             target_field_codes, action_type, rule_logic, is_enabled, created_time

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini