cloud-web-corejs 1.0.253 → 1.0.255

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.253",
4
+ "version": "1.0.255",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -42,7 +42,7 @@ moudule = {
42
42
  confirmWfTaskUserRangeDialog(rows){
43
43
  let $grid = this.$refs["table-m1"];
44
44
  let item = $grid.getTableData().fullData[this.operateIndex];
45
- let wfTaskCandidateDTOs = item.wfTaskCandidateDTOs;
45
+ let wfTaskCandidateDTOs = item.wfTaskCandidateDTOs || [];
46
46
  let item1s = [];
47
47
  let item2s = []
48
48
  rows.forEach(row => {
@@ -169,7 +169,7 @@ moudule = {
169
169
  userConfirm(rows) {
170
170
  let $grid = this.$refs["table-m1"];
171
171
  let item = $grid.getTableData().fullData[this.operateIndex];
172
- let wfTaskCandidateDTOs = item.wfTaskCandidateDTOs;
172
+ let wfTaskCandidateDTOs = item.wfTaskCandidateDTOs || [];
173
173
  let item1s = [];
174
174
  let item2s = []
175
175
  rows.forEach(row => {
@@ -135,6 +135,7 @@ export default {
135
135
  this.option = {
136
136
  title: '附件',
137
137
  edit: !this.field.options.disabled,
138
+ showViewButton: this.field.options.showViewButton !== false,
138
139
  uploadConfig: {
139
140
  limit: this.field.options.limit,
140
141
  resultType: "Array"
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <el-form-item :label="i18nt('隐藏查看附件按钮')">
3
+ <el-switch :value="hideViewButton" @change="handleChange"></el-switch>
4
+ </el-form-item>
5
+ </template>
6
+
7
+ <script>
8
+ import i18n from "../../../../../components/xform/utils/i18n";
9
+
10
+ export default {
11
+ name: "showViewButton-editor",
12
+ mixins: [i18n],
13
+ props: {
14
+ designer: Object,
15
+ selectedWidget: Object,
16
+ optionModel: Object,
17
+ },
18
+ computed: {
19
+ hideViewButton() {
20
+ return this.optionModel.showViewButton === false;
21
+ },
22
+ },
23
+ methods: {
24
+ handleChange(hidden) {
25
+ this.$set(this.optionModel, "showViewButton", !hidden);
26
+ },
27
+ },
28
+ };
29
+ </script>
@@ -170,7 +170,8 @@ const COMMON_PROPERTIES = {
170
170
  "autoValueEnabled": "autoValueEnabled-editor",
171
171
  // "commonAttributeEnabled": "commonAttributeEnabled-editor"
172
172
  "colorClass": "colorClass-editor",
173
- "downloadButtonFlag": "downloadButtonFlag-editor"
173
+ "downloadButtonFlag": "downloadButtonFlag-editor",
174
+ "showViewButton": "showViewButton-editor"
174
175
  }
175
176
 
176
177
  const ADVANCED_PROPERTIES = {
@@ -3261,6 +3261,7 @@ export const advancedFields = [
3261
3261
  labelWidth: null,
3262
3262
  labelHidden: !0,
3263
3263
  limit: null,
3264
+ showViewButton: true,
3264
3265
  accessType: "1",
3265
3266
  entityTableCode: null,
3266
3267
  entityTableDesc: null,
@@ -43,6 +43,9 @@ import formulaDialog from "@base/components/xform/form-designer/form-widget/dial
43
43
  import baseFormulaDialog from "@base/components/xform/form-designer/form-widget/dialog/baseFormulaDialog.vue";
44
44
  import QRCode from "qrcode";
45
45
  import { openLuckysheetDialog } from "@base/components/luckysheet";
46
+ import {
47
+ openComponentDialog as mountComponentDialog,
48
+ } from "@base/utils/componentDialog";
46
49
 
47
50
  let modules = {};
48
51
  const baseRefUtil = {
@@ -3737,7 +3740,13 @@ modules = {
3737
3740
  },
3738
3741
  openLuckysheetDialog(option) {
3739
3742
  openLuckysheetDialog(option);
3740
- }
3743
+ },
3744
+ openComponentDialog(option = {}) {
3745
+ return mountComponentDialog(option, this).catch((error) => {
3746
+ this.$message.error(error.message || "组件弹框打开失败");
3747
+ return null;
3748
+ });
3749
+ },
3741
3750
  },
3742
3751
  };
3743
3752
 
@@ -0,0 +1,217 @@
1
+ import Vue from "vue";
2
+
3
+ const componentContext = require.context("../components", true, /\.vue$/, "lazy");
4
+ const viewContext = require.context("../views", true, /\.vue$/, "lazy");
5
+ const componentKeys = new Set(componentContext.keys());
6
+ const viewKeys = new Set(viewContext.keys());
7
+
8
+ function normalizePath(path) {
9
+ return String(path || "")
10
+ .trim()
11
+ .replace(/\\\\/g, "/")
12
+ .replace(/[?#].*$/, "")
13
+ .replace(/^\.\//, "")
14
+ .replace(/^src\//, "")
15
+ .replace(/^@base\//, "")
16
+ .replace(/^@\//, "")
17
+ .replace(/^\/+/, "")
18
+ .replace(/\/+$/, "");
19
+ }
20
+
21
+ function getComponentLoader(path) {
22
+ const normalizedPath = normalizePath(path);
23
+ if (!normalizedPath) {
24
+ throw new Error("[componentDialog] componentPath 不能为空");
25
+ }
26
+ if (normalizedPath.split("/").includes("..")) {
27
+ throw new Error("[componentDialog] componentPath 不允许包含 ..");
28
+ }
29
+
30
+ let context;
31
+ let contextKeys;
32
+ let relativePath;
33
+ if (normalizedPath.startsWith("components/")) {
34
+ context = componentContext;
35
+ contextKeys = componentKeys;
36
+ relativePath = normalizedPath.slice("components/".length);
37
+ } else if (normalizedPath.startsWith("views/")) {
38
+ context = viewContext;
39
+ contextKeys = viewKeys;
40
+ relativePath = normalizedPath.slice("views/".length);
41
+ } else {
42
+ throw new Error("[componentDialog] 只允许加载 src/components 或 src/views 下的组件");
43
+ }
44
+
45
+ const candidates = /\.vue$/i.test(relativePath)
46
+ ? [`./${relativePath}`]
47
+ : [`./${relativePath}.vue`, `./${relativePath}/index.vue`];
48
+ const componentKey = candidates.find((key) => contextKeys.has(key));
49
+ if (!componentKey) {
50
+ throw new Error(`[componentDialog] 找不到组件:${normalizedPath}`);
51
+ }
52
+ return () => Promise.resolve(context(componentKey));
53
+ }
54
+
55
+ async function loadComponent(path) {
56
+ const componentModule = await getComponentLoader(path)();
57
+ return componentModule.default || componentModule;
58
+ }
59
+
60
+ function callEvent(events, eventName, args) {
61
+ const handler = events[eventName];
62
+ if (typeof handler === "function") handler(...args);
63
+ }
64
+
65
+ function mountComponentDialog(component, options, parentVm) {
66
+ const {
67
+ wrapper = true,
68
+ dialog = {},
69
+ props = {},
70
+ attrs = {},
71
+ provide: provideValues = {},
72
+ events = {},
73
+ onClose,
74
+ } = options;
75
+ let hostInstance = null;
76
+ let destroyTimer = null;
77
+ let closeStarted = false;
78
+ let closeNotified = false;
79
+ let resizeHandler = null;
80
+ const centerTimers = [];
81
+
82
+ const centerDialog = () => {
83
+ if (!hostInstance || options.verticalCenter === false) return;
84
+ hostInstance.$nextTick(() => {
85
+ if (!hostInstance || !hostInstance.$el) return;
86
+ const hostElement = hostInstance.$el;
87
+ const dialogElement = hostElement.matches(".el-dialog")
88
+ ? hostElement
89
+ : hostElement.querySelector(".el-dialog");
90
+ if (!dialogElement || !dialogElement.offsetHeight) return;
91
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
92
+ dialogElement.style.marginTop = `${Math.max((viewportHeight - dialogElement.offsetHeight) / 2, 0)}px`;
93
+ });
94
+ };
95
+
96
+ const notifyClose = () => {
97
+ if (closeNotified) return;
98
+ closeNotified = true;
99
+ if (typeof onClose === "function") onClose();
100
+ };
101
+ const removeHost = () => {
102
+ if (!hostInstance) return;
103
+ centerTimers.forEach((timer) => clearTimeout(timer));
104
+ if (resizeHandler) window.removeEventListener("resize", resizeHandler);
105
+ resizeHandler = null;
106
+ const element = hostInstance.$el;
107
+ hostInstance.$destroy();
108
+ if (element && element.parentNode) element.parentNode.removeChild(element);
109
+ hostInstance = null;
110
+ };
111
+ const destroy = () => {
112
+ if (closeStarted) return;
113
+ closeStarted = true;
114
+ notifyClose();
115
+ destroyTimer = setTimeout(removeHost, 300);
116
+ };
117
+ const forceDestroy = () => {
118
+ if (destroyTimer) clearTimeout(destroyTimer);
119
+ destroyTimer = null;
120
+ closeStarted = true;
121
+ notifyClose();
122
+ removeHost();
123
+ };
124
+
125
+ const DialogHost = Vue.extend({
126
+ name: "DynamicComponentDialogHost",
127
+ provide() {
128
+ return provideValues;
129
+ },
130
+ data() {
131
+ return { visible: true };
132
+ },
133
+ methods: {
134
+ closeDialog() {
135
+ this.visible = false;
136
+ const componentInstance = this.$refs.contentComponent;
137
+ if (componentInstance && Object.prototype.hasOwnProperty.call(componentInstance, "showDialog")) {
138
+ componentInstance.showDialog = false;
139
+ }
140
+ destroy();
141
+ },
142
+ },
143
+ render(h) {
144
+ const childEvents = {};
145
+ Object.keys(events).forEach((eventName) => {
146
+ childEvents[eventName] = (...args) => callEvent(events, eventName, args);
147
+ });
148
+ childEvents["update:visible"] = (visible) => {
149
+ callEvent(events, "update:visible", [visible]);
150
+ this.visible = visible;
151
+ if (visible === false) this.closeDialog();
152
+ };
153
+ childEvents["update:visiable"] = (visible) => {
154
+ callEvent(events, "update:visiable", [visible]);
155
+ this.visible = visible;
156
+ if (visible === false) this.closeDialog();
157
+ };
158
+ childEvents.close = (...args) => {
159
+ callEvent(events, "close", args);
160
+ if (!wrapper) this.closeDialog();
161
+ };
162
+ const componentNode = h(component, {
163
+ ref: "contentComponent",
164
+ props: { ...props, visible: this.visible, visiable: this.visible },
165
+ attrs,
166
+ on: childEvents,
167
+ });
168
+ if (!wrapper) return componentNode;
169
+ return h("el-dialog", {
170
+ props: {
171
+ title: "",
172
+ width: "700px",
173
+ appendToBody: true,
174
+ closeOnClickModal: false,
175
+ ...dialog,
176
+ visible: this.visible,
177
+ },
178
+ on: {
179
+ "update:visible": (visible) => {
180
+ this.visible = visible;
181
+ },
182
+ close: destroy,
183
+ },
184
+ }, [componentNode]);
185
+ },
186
+ });
187
+
188
+ const parent = parentVm || (typeof window !== "undefined" && window.$vueRoot ? window.$vueRoot : null);
189
+ const instanceOptions = {};
190
+ if (parent) {
191
+ instanceOptions.parent = parent;
192
+ if (parent._i18n) instanceOptions.i18n = parent._i18n;
193
+ }
194
+ hostInstance = new DialogHost(instanceOptions);
195
+ hostInstance.$mount();
196
+ document.body.appendChild(hostInstance.$el);
197
+ if (options.verticalCenter !== false) {
198
+ resizeHandler = centerDialog;
199
+ window.addEventListener("resize", resizeHandler);
200
+ centerTimers.push(setTimeout(centerDialog, 0));
201
+ centerTimers.push(setTimeout(centerDialog, 300));
202
+ }
203
+ return {
204
+ host: hostInstance,
205
+ instance: hostInstance.$refs.contentComponent,
206
+ close() {
207
+ if (hostInstance) hostInstance.closeDialog();
208
+ },
209
+ destroy: forceDestroy,
210
+ recenter: centerDialog,
211
+ };
212
+ }
213
+
214
+ export async function openComponentDialog(options = {}, parentVm) {
215
+ const component = await loadComponent(options.componentPath);
216
+ return mountComponentDialog(component, options, parentVm);
217
+ }