ruhuxu 12 часов назад
Родитель
Сommit
182aeaa97e
2 измененных файлов с 41 добавлено и 12 удалено
  1. 4 11
      js/vue/ss-components.js
  2. 37 1
      page/ws_inp.jsp

+ 4 - 11
js/vue/ss-components.js

@@ -3477,13 +3477,9 @@ import { EVEN_VAR } from "./EventBus.js";
         type: String,
         default: "请输入内容",
       },
-      readonly: {
-        type: Boolean,
-        default: false,
-      },
       mode: {
         type: String,
-        default: "edit", // 'edit' | 'view'
+        default: "edit", // 'edit' | 'play'
       },
       uploadUrl: {
         type: String,
@@ -3508,9 +3504,6 @@ import { EVEN_VAR } from "./EventBus.js";
       const uniqueId = "editor-" + Date.now();
       const errMsg = Vue.ref("");
 
-      // 计算是否只读:mode='play' 表示只读 by xu 20250402
-      const isReadonly = computed(() => props.mode === "play");
-
       // button 支持对象(旧格式,单个附件按钮)或数组(新格式,多个按钮)by xu 20250331
       const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
       const buttonArray = Array.isArray(buttonConfigRaw)
@@ -3695,7 +3688,7 @@ import { EVEN_VAR } from "./EventBus.js";
         validate();
 
         // 只读模式下不初始化 Jodit,直接设置内容 by xu 20250402
-        if (isReadonly) {
+        if (props.mode === "play") {
           if (props.html) {
             setEditorHtml(props.html);
           } else if (props.url) {
@@ -3794,7 +3787,7 @@ import { EVEN_VAR } from "./EventBus.js";
         const editor = Jodit.make(`#${uniqueId}`, {
           height: props.height,
           placeholder: props.placeholder,
-          readonly: isReadonly,
+          readonly: props.mode === "play",
           language: "zh_cn",
           i18n: {
             zh_cn: {
@@ -4205,7 +4198,7 @@ import { EVEN_VAR } from "./EventBus.js";
 
       return () => {
         // 只读模式:不初始化 Jodit,直接渲染 HTML + 附件按钮 by xu 20250402
-        if (isReadonly) {
+        if (props.mode === "play") {
           return h("div", { class: "ss-editor-container ss-editor-readonly" }, [
             fjid.value &&
               h("input", {

+ 37 - 1
page/ws_inp.jsp

@@ -259,12 +259,48 @@ url="<ss:serv name='loadEditorBody' />"
 v-model="zwwj"
 :html="zwwjHtml"
 name="zwwj"
-:readonly="false"
+mode="edit"
 width="700px"
 >
 
 </ss-editor>
 
+<!-- 【TEST】mode="play" 只读模式测试 by xu 20250402 -->
+<tr>
+    <th>正文(只读模式测试)</th>
+    <td colspan="3">
+        <script>
+        // 只读模式测试:带默认 HTML 内容 by xu 20250402
+        ss.dom.formElemConfig.zwwjTest = {val: '${ws.zwwj}', type: window.ss.dom.TYPE.HTML};
+        ss.dom.formElemConfig.zwwjTestHtml = {
+            val: '<h2 style="color: #333; border-bottom: 2px solid #1890ff; padding-bottom: 10px;">测试文书标题</h2>' +
+                 '<p style="line-height: 1.8; color: #666;">这是一段测试内容,用于展示 <strong>mode="play"</strong> 只读模式的效果。</p>' +
+                 '<p style="line-height: 1.8; color: #666;">在只读模式下:</p>' +
+                 '<ul style="color: #666;">' +
+                 '<li>不加载 Jodit 编辑器</li>' +
+                 '<li>直接渲染 HTML 内容</li>' +
+                 '<li>保留附件按钮功能</li>' +
+                 '</ul>' +
+                 '<p style="margin-top: 20px; padding: 10px; background: #f5f5f5; border-left: 3px solid #1890ff;">' +
+                 '<strong>备注:</strong>此区域为只读展示,如需编辑请使用上方的编辑器。' +
+                 '</p>',
+            type: window.ss.dom.TYPE.INPUT
+        };
+        </script>
+        <ss-editor
+            mode="play"
+            :height="300"
+            url="<ss:serv name='loadEditorBody' />"
+            :param="{'mode':'view','obj':'ws','jlztm':'${ws.jlztm}','button':[{'desc':'附件','name':'fjid','val':'${ws.fjid}','cmsUpdUrl':'<ss:serv name='regCms' dest='cmsHome' />','cmsAddUrl':'<ss:serv name='makeAttCms' />'}]}"
+            v-model="zwwjTest"
+            :html="zwwjTestHtml"
+            name="zwwjTest"
+            width="700px"
+        >
+        </ss-editor>
+    </td>
+</tr>
+
             </td>
         </tr>
         <tr>