瀏覽代碼

fix: 流程样式优化

liuc 3 月之前
父節點
當前提交
fdd9fad6fd

+ 1 - 1
src/views/flow/stFormDesign/packages/StFormDesign/MobileIndex.vue

@@ -190,7 +190,7 @@ export default defineComponent({
     },
     showHead: {
       type: Boolean,
-      default: true,
+      default: false,
     },
     hideResetHint: {
       type: Boolean,

+ 1 - 1
src/views/flow/stFormDesign/packages/StFormDesign/index.vue

@@ -184,7 +184,7 @@
       },
       showHead: {
         type: Boolean,
-        default: true,
+        default: false,
       },
       hideResetHint: {
         type: Boolean,

+ 22 - 17
src/views/flow/stFormDesign/packages/StFormDesign/module/formProperties.vue

@@ -103,16 +103,14 @@
               <a-button style="width: 100%" type="primary" @click="preViewCodeHandler">设置代码块</a-button>
             </a-col>
           </a-row>
-          <a-row :gutter="20">
-            <a-col :span="24">
-              <template v-for="(n,i) in customEvents">
-                <a-tag
-                    v-show="n.color&&scriptKeys.includes(n.key)"
-                    :color="n.color">{{ n.name }}
-                </a-tag>
-              </template>
-            </a-col>
-          </a-row>
+          <div class="event-tag">
+            <template v-for="(n,i) in customEvents">
+              <a-tag
+                  v-show="n.color&&scriptKeys.includes(n.key)"
+                  :color="n.color">{{ n.name }}
+              </a-tag>
+            </template>
+          </div>
 
         </a-form-item>
       </a-form>
@@ -159,33 +157,33 @@ export default {
         key: "loadBefore",
         name: "表单加载前",
         isShow: true,
-        color: 'success'
+        color: 'blue'
 
       }, {
         key: "loadAfter",
         name: "表单加载后",
         isShow: true,
-        color: 'pink'
+        color: 'processing'
       }, {
         key: "submitBefore",
         name: "表单提交前",
         isShow: true,
-        color: 'red'
+        color: 'blue'
       }, {
         key: "submitAfter",
         name: "表单提交后",
         isShow: true,
-        color: 'orange'
+        color: 'processing'
       }, {
         key: "rejectBefore",
         name: "表单驳回前",
         isShow: true,
-        color: 'green'
+        color: 'blue'
       }, {
         key: "rejectAfter",
         name: "表单驳回后",
         isShow: true,
-        color: 'cyan'
+        color: 'processing'
       }, {
         key: "saveBefore",
         name: "表单保存前",
@@ -195,7 +193,7 @@ export default {
         key: "saveAfter",
         name: "表单保存后",
         isShow: true,
-        color: 'purple'
+        color: 'processing'
       }],
       objectId: undefined,
       scriptKeys: [],
@@ -248,4 +246,11 @@ export default {
     }
   }
 }
+.event-tag{
+  display: flex;
+  flex-wrap: wrap; /* 允许子元素换行 */
+  gap: 10px; /* 子元素之间的间距 */
+  justify-content: center; /* 水平居中对齐 */
+  padding-top: 6px;
+}
 </style>

+ 26 - 14
src/views/flow/stFormDesign/packages/StFormDesign/module/jsModal.vue

@@ -102,7 +102,7 @@
                   class="copy-btn">
           复制代码
         </a-button>
-        <a-button @click="saveCode" @keydown="keyDownHandleSaveCode" type="primary" :loading="submitLoading"> 保存(Ctrl
+        <a-button @click="saveCode" type="primary" :loading="submitLoading"> 保存(Ctrl
           + S)
         </a-button>
         <a-button @click="viewCode" type="dashed" class="copy-btn"> 查看历史</a-button>
@@ -143,7 +143,7 @@ export default {
       title: '代码',
       objectId: undefined,
       submitLoading: false,
-      activeKey: 'initVar',
+      activeKey: 'loadAfter',
       size: 'small',
       customEvents: [
         {
@@ -290,7 +290,7 @@ export default {
       this.editorJsCode = '';
 
       if (type == '0') {
-        this.activeKey = 'initVar';
+        this.activeKey = 'loadAfter';
         this.objectId = this.config.event[this.activeKey];
         this.eventObj = this.customEvents.find((v) => v.key == this.activeKey);
       } else if (type == '1') {
@@ -310,6 +310,7 @@ export default {
     },
 
     async getCode(objectId, type) {
+
       this.loading = true;
       const {success, data} = await getJsStr({objectid: objectId});
       this.loading = false;
@@ -317,10 +318,12 @@ export default {
         this.$nextTick(() => {
           if (!isString(data)) {
             if (type == '0') {
-              this.editorJsCode = `
-//固定写法
+              const selectedItem = this.customEvents.find(item => item.key == this.activeKey)
+              this.editorJsCode = `/**
+ * ${selectedItem.name}
+ */
 (() => {
-  console.log("this", this)
+    console.log("this", this)
 
 
 
@@ -328,20 +331,30 @@ export default {
 })()
 `;
             } else if (type == '1') {
-              this.editorJsCode = `
-//固定写法
+              this.editorJsCode = `/**
+ * 值改变事件
+ */
 ((bizObj) => {
-  const { value, key, record, tableInfo } = bizObj;
+    // value                        修改后的值
+    // key                          字段的编码
+    // record                       字段的属性
+    // tableInfo                    仅在子表的值改变事件中有效
+    // tableInfo.rowIndex           修改的行的索引
+    // tableInfo.column.dataIndex   修改的列的编码
+    const { value, key, record, tableInfo } = bizObj;
 
 
 
 
 
-})(bizObj)
-`;
+
+
+})(bizObj)`;
             } else if (type == '2') {
-              this.editorJsCode = `
-//固定写法
+              this.editorJsCode = `// 自定义校验
+// rule.message 设置校验提示信息
+// return true  校验通过
+// return false 校验不通过
 const { rule, value } = bizObj;
 rule.message = '错误信息'
 if (value == '1') {
@@ -349,7 +362,6 @@ if (value == '1') {
 } else {
     return false//没有通过校验
 }
-
 `
             }
           } else {

+ 10 - 9
src/views/flow/stFormDesign/packages/StFormItem/index.vue

@@ -293,7 +293,6 @@ export default {
     handlerRules() {
       this.$nextTick(() => {
         const {stScriptCodeList} = useFlowStore()
-
         if (this.record.rules && this.record.rules.length > 0) {
           this.record.rules.forEach((rule) => {
             if (rule.keyCode) {
@@ -301,14 +300,16 @@ export default {
               if (rule.keyCode == 'custom') {
                 if (stScriptCodeList != null) {
                   const ruleCode = stScriptCodeList.find(v => v.objectid == rule.eventKey);
-                  const fn = new Function('bizObj', ruleCode.scriptValue);
-                  rule.validator = async (rule, value, callback) => {
-                    const result = fn({rule, value});
-                    if (!result) {
-                      return Promise.reject(callback(new Error('')));
-                    }
-                    return Promise.resolve(callback());
-                  };
+                  if (ruleCode){
+                    const fn = new Function('bizObj', ruleCode.scriptValue);
+                    rule.validator = async (rule, value, callback) => {
+                      const result = fn({rule, value});
+                      if (!result) {
+                        return Promise.reject(callback(new Error('')));
+                      }
+                      return Promise.resolve(callback());
+                    };
+                  }
                 }
               } else {
                 const {validator} = getRulesFunc(rule.keyCode);

+ 0 - 1
src/views/flow/stFormWork/formWork.vue

@@ -570,7 +570,6 @@ const initPageData = async () => {
     taskObj.value.tag = 'START'
   }
   operatePower.value = resFormLoadTemplateData.value.data.operatePower;
-
   fieldMap.value = resFormLoadTemplateData.value.data.fieldMap;
 
   if (resFormLoadTemplateData.value.data.taskItem) {