cloud-web-corejs 1.0.54-dev.695 → 1.0.54-dev.696

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.695",
4
+ "version": "1.0.54-dev.696",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -0,0 +1,102 @@
1
+ function isNull(val) {
2
+ return val == null || val === "" || val === undefined;
3
+ }
4
+
5
+ export function formatJsonContent(content) {
6
+ if (isNull(content)) return "";
7
+ if (typeof content === "object") {
8
+ try {
9
+ return JSON.stringify(content, null, 2);
10
+ } catch (e) {
11
+ return String(content);
12
+ }
13
+ }
14
+ const text = String(content).trim();
15
+ if (!text) return "";
16
+ try {
17
+ return JSON.stringify(JSON.parse(text), null, 2);
18
+ } catch (e) {
19
+ return text;
20
+ }
21
+ }
22
+
23
+ function parseExportContent(content) {
24
+ if (!content) {
25
+ return { list: [], isArray: true };
26
+ }
27
+ try {
28
+ const parsed = JSON.parse(content);
29
+ if (Array.isArray(parsed)) {
30
+ return { list: parsed, isArray: true };
31
+ }
32
+ return { list: [parsed], isArray: false };
33
+ } catch (e) {
34
+ return { list: [], isArray: true, invalid: true };
35
+ }
36
+ }
37
+
38
+ export function getExportExtraConfig(url, options = {}) {
39
+ if (options.extraExport) {
40
+ return options.extraExport;
41
+ }
42
+ if (!url) return null;
43
+ if (url.includes("/form_develop/exportFormScript")) {
44
+ return {
45
+ field: "script",
46
+ getExtraFileName(item) {
47
+ const scriptCode = item.scriptCode || "script";
48
+ const formCode = item.formCode;
49
+ return formCode
50
+ ? `${scriptCode} - ${formCode} - item(script)`
51
+ : `${scriptCode} - item(script)`;
52
+ },
53
+ };
54
+ }
55
+ if (url.includes("/form_develop/exportFormTemplate")) {
56
+ return {
57
+ field: "formViewContent",
58
+ getExtraFileName(item) {
59
+ return `${item.formCode || "form"} - item(form)`;
60
+ },
61
+ };
62
+ }
63
+ return null;
64
+ }
65
+
66
+ export function processExportContent(content, extraConfig) {
67
+ if (!extraConfig) {
68
+ return { mainContent: content, extraFiles: [] };
69
+ }
70
+
71
+ const { field, getExtraFileName } = extraConfig;
72
+ const { list, isArray, invalid } = parseExportContent(content);
73
+
74
+ if (invalid || !list.length) {
75
+ return { mainContent: content, extraFiles: [] };
76
+ }
77
+
78
+ const extraFiles = [];
79
+ const usedNames = {};
80
+
81
+ list.forEach((item, index) => {
82
+ if (!item || isNull(item[field])) return;
83
+
84
+ const formatted = formatJsonContent(item[field]);
85
+ item[field] = formatted;
86
+
87
+ let fileName = getExtraFileName(item, index);
88
+ if (!fileName) return;
89
+
90
+ if (usedNames[fileName]) {
91
+ usedNames[fileName] += 1;
92
+ fileName = `${fileName}_${usedNames[fileName]}`;
93
+ } else {
94
+ usedNames[fileName] = 1;
95
+ }
96
+
97
+ extraFiles.push({ fileName, content: formatted });
98
+ });
99
+
100
+ const mainContent = JSON.stringify(isArray ? list : list[0], null, 2);
101
+ return { mainContent, extraFiles };
102
+ }
@@ -4,6 +4,10 @@ import excelImport from "./index.vue";
4
4
  import exportDialog from "./exportDialog.vue";
5
5
  import { getBdEnv } from "@base/api/user";
6
6
  import { encrypt, decrypt } from "@base/utils/aes";
7
+ import {
8
+ getExportExtraConfig,
9
+ processExportContent,
10
+ } from "./exportUtil";
7
11
 
8
12
  import { getToken } from "../../utils/auth";
9
13
 
@@ -107,14 +111,19 @@ moudule.install = function (Vue) {
107
111
  .replaceAll(" ", "");
108
112
  fileName = options.title + "(" + timeStr + ")";
109
113
  }
110
- /* if (options.plaintext) {
111
- try {
112
- content = JSON.stringify(JSON.parse(content), null, 2);
113
- } catch (e) {
114
- // content is not valid JSON, keep original
115
- }
116
- } */
117
- downloadTxt(fileName, content);
114
+ const extraConfig = getExportExtraConfig(options.url, options);
115
+ if (extraConfig) {
116
+ const processed = processExportContent(content, extraConfig);
117
+ content = processed.mainContent;
118
+ const extraFiles = resolveExtraFileNames(
119
+ processed.extraFiles,
120
+ options.fileName
121
+ );
122
+ downloadTxt(fileName, content);
123
+ downloadExtraFiles(extraFiles);
124
+ } else {
125
+ downloadTxt(fileName, content);
126
+ }
118
127
  } else {
119
128
  this.$baseAlert(this.$t1("不存在需要导出的数据"));
120
129
  }
@@ -152,6 +161,28 @@ moudule.install = function (Vue) {
152
161
  };
153
162
  };
154
163
 
164
+ function resolveExtraFileNames(extraFiles, mainFileName) {
165
+ if (!extraFiles || !extraFiles.length) return [];
166
+ return extraFiles.map((file) => {
167
+ if (mainFileName && file.fileName === mainFileName) {
168
+ return {
169
+ ...file,
170
+ fileName: `${file.fileName}-content`,
171
+ };
172
+ }
173
+ return file;
174
+ });
175
+ }
176
+
177
+ function downloadExtraFiles(extraFiles) {
178
+ if (!extraFiles || !extraFiles.length) return;
179
+ extraFiles.forEach((file, index) => {
180
+ setTimeout(() => {
181
+ downloadTxt(file.fileName, file.content);
182
+ }, (index + 1) * 300);
183
+ });
184
+ }
185
+
155
186
  function downloadTxt(fileName, content) {
156
187
  // 创建Blob对象
157
188
  const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
@@ -1743,7 +1743,10 @@ wfStartMixin = {
1743
1743
  (this.wfDefItems = wfDefItems);
1744
1744
  this.$set(this.wfStartForm, "modelId", wfDefItems[0].modelId);
1745
1745
  if (wfDefItems.length == 1) {
1746
- if (settingConfig.withoutConfrimByOneWf === true) {
1746
+ if (
1747
+ settingConfig.withoutConfrimByOneWf === true ||
1748
+ (this.option && this.option.skipStartConfirm)
1749
+ ) {
1747
1750
  this.startSubmit();
1748
1751
  } else {
1749
1752
  let wfStartOperateName =
@@ -289,3 +289,4 @@ function appendPrevChildDom(parentDom, newDom) {
289
289
  }
290
290
 
291
291
  export const initWf = f;
292
+ export { openStartWfDialog };
@@ -0,0 +1,112 @@
1
+ <template>
2
+ <static-content-wrapper
3
+ :designer="designer"
4
+ :field="field"
5
+ :design-state="designState"
6
+ :display-style="field.options.displayStyle"
7
+ :parent-widget="parentWidget"
8
+ :parent-list="parentList"
9
+ :index-of-parent-list="indexOfParentList"
10
+ :sub-form-row-index="subFormRowIndex"
11
+ :sub-form-col-index="subFormColIndex"
12
+ :sub-form-row-id="subFormRowId"
13
+ >
14
+ <el-button
15
+ v-show="isShow"
16
+ class="button-sty"
17
+ :type="field.options.type"
18
+ :size="field.options.size"
19
+ :plain="field.options.plain"
20
+ :round="field.options.round"
21
+ :circle="field.options.circle"
22
+ :icon="field.options.icon"
23
+ :disabled="!designState && field.options.disabled"
24
+ @click="clickHandle"
25
+ >
26
+ {{ getI18nLabel(field.options.label) }}
27
+ </el-button>
28
+ </static-content-wrapper>
29
+ </template>
30
+
31
+ <script>
32
+ import StaticContentWrapper from "./static-content-wrapper";
33
+ import emitter from "../../../../../components/xform/utils/emitter";
34
+ import i18n from "../../../../../components/xform/utils/i18n";
35
+ import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
36
+
37
+ export default {
38
+ name: "save_submit_wf_button-widget",
39
+ componentName: "FieldWidget",
40
+ mixins: [emitter, fieldMixin, i18n],
41
+ props: {
42
+ field: Object,
43
+ parentWidget: Object,
44
+ parentList: Array,
45
+ indexOfParentList: Number,
46
+ designer: Object,
47
+ designState: {
48
+ type: Boolean,
49
+ default: false,
50
+ },
51
+ subFormRowIndex: {
52
+ type: Number,
53
+ default: -1,
54
+ },
55
+ subFormColIndex: {
56
+ type: Number,
57
+ default: -1,
58
+ },
59
+ subFormRowId: {
60
+ type: String,
61
+ default: "",
62
+ },
63
+ },
64
+ components: {
65
+ StaticContentWrapper,
66
+ },
67
+ inject: {
68
+ getHasWf: {
69
+ default: () => () => false,
70
+ },
71
+ },
72
+ computed: {
73
+ isShow() {
74
+ if (this.designState) return true;
75
+ const formRef = this.getFormRef();
76
+ if (!formRef?.formConfig?.wfEnabled) return false;
77
+ if (this.isWfStarted(formRef)) return false;
78
+ return !this.field.options.hidden;
79
+ },
80
+ },
81
+ created() {
82
+ this.registerToRefList();
83
+ this.initEventHandler();
84
+ this.handleOnCreated();
85
+ },
86
+ mounted() {
87
+ this.handleOnMounted();
88
+ },
89
+ beforeDestroy() {
90
+ this.unregisterFromRefList();
91
+ },
92
+ methods: {
93
+ isWfStarted(formRef) {
94
+ const wfParam = formRef?.wfParam || {};
95
+ return !!(
96
+ wfParam.hasWf ||
97
+ formRef.hasWf ||
98
+ this.getHasWf() ||
99
+ wfParam.wfInfo?.procInstId
100
+ );
101
+ },
102
+ clickHandle() {
103
+ if (this.designState || this.field.options.disabled || !this.isShow) return;
104
+ this.saveAndSubmitWfHandle();
105
+ },
106
+ },
107
+ };
108
+ </script>
109
+
110
+ <style lang="scss" scoped>
111
+ @import "~@/styles/global.scss";
112
+ </style>
@@ -94,6 +94,7 @@ export default {
94
94
  "print-detail-button",
95
95
  "download-button",
96
96
  "copy_button",
97
+ "save_submit_wf_button",
97
98
  "tempStorage",
98
99
  "dropdown",
99
100
  "dropdown-item",
@@ -3976,6 +3976,45 @@ export const businessFields = [
3976
3976
  tabDeleteEnabled: true,
3977
3977
  },
3978
3978
  },
3979
+ {
3980
+ type: "save_submit_wf_button",
3981
+ targetType: "button",
3982
+ icon: "button",
3983
+ commonFlag: !0,
3984
+ columnFlag: true,
3985
+ formItemFlag: !1,
3986
+ options: {
3987
+ name: "",
3988
+ label: "保存并提交流程",
3989
+ columnWidth: "200px",
3990
+ size: "",
3991
+ displayStyle: "block",
3992
+ disabled: !1,
3993
+ hidden: !1,
3994
+ type: "success",
3995
+ plain: !1,
3996
+ round: !1,
3997
+ circle: !1,
3998
+ icon: "el-icon-video-play",
3999
+ customClass: "",
4000
+ onCreated: "",
4001
+ onMounted: "",
4002
+ onClick: "this.saveAndSubmitWfHandle();",
4003
+ accessType: "1",
4004
+ saveSubmitWfButton: true,
4005
+ clickBindEvent: null,
4006
+ onBeforeClickButton: null,
4007
+ searchDialogConfig: {
4008
+ ...defaultSearchDialogConfig,
4009
+ },
4010
+ ...defaultWfConfig,
4011
+ ...defaultWidgetShowRuleConfig,
4012
+ hiddenByWf: true,
4013
+ showRuleFlag: 1,
4014
+ showRuleEnabled: 1,
4015
+ showRules: [],
4016
+ },
4017
+ },
3979
4018
  {
3980
4019
  type: "copy_button",
3981
4020
  icon: "button",
@@ -653,6 +653,10 @@ modules = {
653
653
 
654
654
  //处理组件显隐规则
655
655
  this.handleWidgetShowRule(widget);
656
+ if (wfParam.hasWf && widget?.options?.saveSubmitWfButton) {
657
+ widget.options.hidden = true;
658
+ return;
659
+ }
656
660
  if (wfParam.hasWf) {
657
661
  if (!widgetEditOnWf) {
658
662
  //有流程,且不匹配流程节点可编辑表单设置信息
@@ -697,6 +701,10 @@ modules = {
697
701
  const processWidget = (widget) => {
698
702
  if (!widget) return;
699
703
  this.handleWidgetShowRule(widget);
704
+ if (wfParam.hasWf && widget?.options?.saveSubmitWfButton) {
705
+ widget.options.hidden = true;
706
+ return;
707
+ }
700
708
  if (!wfParam.hasWf || widgetEditOnWf) return;
701
709
  this.hanldeWfWidgetNew1(widget);
702
710
  if (wfInfo.taskStep === "9999") {
@@ -828,6 +836,13 @@ modules = {
828
836
  },
829
837
  hanldeWfWidgetNew1(widget) {
830
838
  if (!widget) return;
839
+ if (widget?.options?.saveSubmitWfButton) {
840
+ let wfParam = this.wfParam || {};
841
+ if (wfParam.hasWf) {
842
+ widget.options.hidden = true;
843
+ }
844
+ return;
845
+ }
831
846
  let flag =
832
847
  widget.columnType &&
833
848
  ["editDelete", "removeTreeRow"].includes(widget.columnType);
@@ -877,7 +892,7 @@ modules = {
877
892
 
878
893
  let handleWfConfigData = (widget, columnOptions) => {
879
894
  let options = widget?.options || columnOptions;
880
- if (!options || !options.wfEdit) return;
895
+ if (!options || !options.wfEdit || options.saveSubmitWfButton) return;
881
896
  let wfConfigData = options.wfConfigData || [];
882
897
  let flag = false;
883
898
  wfConfigData.forEach((item) => {
@@ -1154,7 +1169,7 @@ modules = {
1154
1169
 
1155
1170
  let handleWfConfigData = (widget, columnOptions) => {
1156
1171
  let options = widget?.options || columnOptions;
1157
- if (!options || !options.wfEdit) return;
1172
+ if (!options || !options.wfEdit || options.saveSubmitWfButton) return;
1158
1173
  let wfConfigData = options.wfConfigData || [];
1159
1174
  let flag = false;
1160
1175
  wfConfigData.forEach((item) => {
@@ -76,6 +76,7 @@ export default {
76
76
  "print-button": "导出/打印(列表)",
77
77
  "print-detail-button": "导出/打印(详情)",
78
78
  copy_button: "复制按钮",
79
+ save_submit_wf_button: "保存并提交流程",
79
80
  "rich-editor": "富文本",
80
81
  cascader: "级联选择",
81
82
  "area-select": "地区选择",
@@ -1,6 +1,7 @@
1
1
  import moment from "moment";
2
2
  import { saveUserLog } from "@base/api/user";
3
3
  import settingConfig from "@/settings";
4
+ import { openStartWfDialog } from "../../../components/wf/wfUtil";
4
5
 
5
6
  let modules = {};
6
7
  modules = {
@@ -109,6 +110,46 @@ modules = {
109
110
  });
110
111
  }
111
112
  },
113
+ saveAndSubmitWfHandle(option) {
114
+ let formRef = this.getFormRef ? this.getFormRef() : this;
115
+ let formConfig = formRef.formConfig;
116
+ let reportTemplate = formRef.reportTemplate;
117
+ let wfParam = formRef.wfParam || {};
118
+
119
+ if (!formConfig?.wfEnabled) return;
120
+ if (
121
+ formRef.hasWf ||
122
+ wfParam.hasWf ||
123
+ wfParam.wfInfo?.procInstId
124
+ ) {
125
+ return;
126
+ }
127
+
128
+ let confirmText =
129
+ option?.confirmText ||
130
+ option?.config?.confirmText ||
131
+ this.$t1("您确定要保存并提交流程吗?");
132
+
133
+ this.saveDefaultHandle({
134
+ ...option,
135
+ config: {
136
+ ...option?.config,
137
+ successMsg: option?.config?.successMsg ?? true,
138
+ isConfirm: option?.config?.isConfirm ?? true,
139
+ confirmText: option?.config?.confirmText || confirmText,
140
+ success: (res) => {
141
+ openStartWfDialog(formRef, {
142
+ objId: res.objx,
143
+ wfCode: reportTemplate.objTypeCode,
144
+ formCode: reportTemplate.formCode,
145
+ serviceId: reportTemplate.serviceName,
146
+ skipStartConfirm: true,
147
+ });
148
+ option?.config?.success && option.config.success(res);
149
+ },
150
+ },
151
+ });
152
+ },
112
153
  saveDefaultHandle(option) {
113
154
  let formRef = this.getFormRef ? this.getFormRef() : this;
114
155
  let formConfig = formRef.formConfig;
@@ -286,7 +286,9 @@ modules = {
286
286
  data: [row.id],
287
287
  url: USER_PREFIX + "/form_develop/exportFormScript",
288
288
  plaintext: 1,
289
- fileName: row.scriptCode + "(script)",
289
+ fileName: row.formCode
290
+ ? `${row.scriptCode} - ${row.formCode}(script)`
291
+ : `${row.scriptCode}(script)`,
290
292
  abcEnabled: true,
291
293
  });
292
294
  },