@kezh/my-custom-js-converter 1.5.0 → 1.5.1
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/TASKS.md +398 -1
- package/core/util/ast.js +2 -1
- package/package.json +1 -1
package/TASKS.md
CHANGED
|
@@ -1,2 +1,399 @@
|
|
|
1
1
|
# 任务
|
|
2
|
-
|
|
2
|
+
在其他项目依赖该项目时执行`npx decode`结果和当前项目测试结果不一致:
|
|
3
|
+
+ decode后的依赖路径错误,@会紧贴util,导致依赖路径错误:
|
|
4
|
+
```js
|
|
5
|
+
const form = require("@util/@3.0.0/form");
|
|
6
|
+
const http = require("@util/@3.0.0/http");
|
|
7
|
+
const message = require("@util/@3.0.0/message");
|
|
8
|
+
const dom = require("@util/@3.0.0/dom");
|
|
9
|
+
const vue = require("@util/@3.0.0/vue");
|
|
10
|
+
const tch = require("@util/@3.0.0/tch");
|
|
11
|
+
const customEvent = {
|
|
12
|
+
onFormReady() {
|
|
13
|
+
this.initForm();
|
|
14
|
+
this.initHangupBtn();
|
|
15
|
+
},
|
|
16
|
+
onFormSubmit() {
|
|
17
|
+
if (form.getValue("REASON_TYPE_ORIGIN")) {
|
|
18
|
+
form.setValue(
|
|
19
|
+
"REASON_TYPE",
|
|
20
|
+
form.getSelectOptionLabel("REASON_TYPE_ORIGIN")
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if ("挂起" == form.getValue("SUSPENDED_STATE")) {
|
|
24
|
+
message.warning("该流程已挂起,请解挂后提交工单!");
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
initForm() {
|
|
30
|
+
form.hidden("hiddenInfo");
|
|
31
|
+
if (form.getValue("SUSPENDED_STATE")) {
|
|
32
|
+
form.show("hangupInfo");
|
|
33
|
+
} else {
|
|
34
|
+
form.hidden("hangupInfo");
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
initHangupBtn() {
|
|
38
|
+
if ("告警处理" !== tch.getCurTchName()) {
|
|
39
|
+
return;
|
|
40
|
+
} // 注入弹出框样式
|
|
41
|
+
dom.addCss(
|
|
42
|
+
`
|
|
43
|
+
.hangup-dialog-overlay {
|
|
44
|
+
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
|
|
45
|
+
background: rgba(0, 0, 0, 0.5); z-index: 2000;
|
|
46
|
+
display: flex; align-items: center; justify-content: center;
|
|
47
|
+
}
|
|
48
|
+
.hangup-dialog {
|
|
49
|
+
background: #fff; border-radius: 4px; width: 420px; padding: 20px;
|
|
50
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
|
|
51
|
+
}
|
|
52
|
+
.hangup-dialog__title {
|
|
53
|
+
font-size: 16px; font-weight: bold; margin-bottom: 16px; color: #303133;
|
|
54
|
+
}
|
|
55
|
+
.hangup-dialog__label {
|
|
56
|
+
display: block; font-size: 14px; color: #606266; margin-bottom: 6px;
|
|
57
|
+
}
|
|
58
|
+
.hangup-dialog__input {
|
|
59
|
+
width: 100%; box-sizing: border-box; padding: 8px 12px;
|
|
60
|
+
border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px;
|
|
61
|
+
margin-bottom: 16px; outline: none;
|
|
62
|
+
}
|
|
63
|
+
.hangup-dialog__input:focus {
|
|
64
|
+
border-color: #409eff;
|
|
65
|
+
}
|
|
66
|
+
.hangup-dialog__textarea {
|
|
67
|
+
width: 100%; box-sizing: border-box; padding: 8px 12px;
|
|
68
|
+
border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px;
|
|
69
|
+
margin-bottom: 16px; outline: none; resize: vertical; min-height: 80px;
|
|
70
|
+
}
|
|
71
|
+
.hangup-dialog__textarea:focus {
|
|
72
|
+
border-color: #409eff;
|
|
73
|
+
}
|
|
74
|
+
.hangup-dialog__footer {
|
|
75
|
+
text-align: right; margin-top: 8px;
|
|
76
|
+
}
|
|
77
|
+
.hangup-dialog__btn {
|
|
78
|
+
padding: 8px 20px; border-radius: 4px; font-size: 14px;
|
|
79
|
+
cursor: pointer; border: 1px solid #dcdfe6; margin-left: 10px;
|
|
80
|
+
}
|
|
81
|
+
.hangup-dialog__btn--primary {
|
|
82
|
+
background: #409eff; color: #fff; border-color: #409eff;
|
|
83
|
+
}
|
|
84
|
+
.hangup-dialog__btn--primary:hover {
|
|
85
|
+
background: #66b1ff; border-color: #66b1ff;
|
|
86
|
+
}
|
|
87
|
+
.hangup-dialog__btn--default {
|
|
88
|
+
background: #fff; color: #606266;
|
|
89
|
+
}
|
|
90
|
+
.hangup-dialog__btn--default:hover {
|
|
91
|
+
color: #409eff; border-color: #c6e2ff; background: #ecf5ff;
|
|
92
|
+
}
|
|
93
|
+
`,
|
|
94
|
+
"hangup-dialog-style"
|
|
95
|
+
); // 等待DOM渲染完成后注入按钮
|
|
96
|
+
vue.nextTick(() => {
|
|
97
|
+
this.renderHangupBtn();
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
renderHangupBtn() {
|
|
101
|
+
const suspendedState = form.getValue("SUSPENDED_STATE", ""); // 查找锚点元素:优先按ID查找提交按钮,兜底查找菜单栏最后一个按钮
|
|
102
|
+
const submitBtn =
|
|
103
|
+
document.getElementById("220001") ||
|
|
104
|
+
document.querySelector(".fi-workflow-menu-item.btn:last-child");
|
|
105
|
+
if (!submitBtn) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (suspendedState === "挂起") {
|
|
109
|
+
// 当前已挂起,显示解挂按钮
|
|
110
|
+
submitBtn.insertAdjacentHTML(
|
|
111
|
+
"afterend",
|
|
112
|
+
'<div class="fi-workflow-menu-item btn" id="hangupBtn"><div> <i class="fi el-icon-lock icon"></i>解挂</div></div>'
|
|
113
|
+
);
|
|
114
|
+
document.getElementById("hangupBtn").addEventListener("click", () => {
|
|
115
|
+
this.showResumeDialog();
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
// 当前未挂起,默认显示挂起按钮
|
|
119
|
+
submitBtn.insertAdjacentHTML(
|
|
120
|
+
"afterend",
|
|
121
|
+
'<div class="fi-workflow-menu-item btn" id="hangupBtn"><div> <i class="fi el-icon-unlock icon"></i>挂起</div></div>'
|
|
122
|
+
);
|
|
123
|
+
document.getElementById("hangupBtn").addEventListener("click", () => {
|
|
124
|
+
this.showHangupDialog();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
showHangupDialog() {
|
|
129
|
+
const overlay = document.createElement("div");
|
|
130
|
+
overlay.className = "hangup-dialog-overlay";
|
|
131
|
+
overlay.id = "hangupDialogOverlay";
|
|
132
|
+
overlay.innerHTML = `
|
|
133
|
+
<div class="hangup-dialog">
|
|
134
|
+
<div class="hangup-dialog__title">挂起工单</div>
|
|
135
|
+
<label class="hangup-dialog__label">挂起原因</label>
|
|
136
|
+
<textarea class="hangup-dialog__textarea" id="hangupReason" placeholder="请输入挂起原因"></textarea>
|
|
137
|
+
<label class="hangup-dialog__label"><span style="color:#f56c6c">*</span> 自动解挂时间</label>
|
|
138
|
+
<input class="hangup-dialog__input" type="datetime-local" id="hangupUnbanTime" />
|
|
139
|
+
<div class="hangup-dialog__footer">
|
|
140
|
+
<button class="hangup-dialog__btn hangup-dialog__btn--default" id="hangupCancelBtn">取 消</button>
|
|
141
|
+
<button class="hangup-dialog__btn hangup-dialog__btn--primary" id="hangupConfirmBtn">确 定</button>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
`;
|
|
145
|
+
document.body.appendChild(overlay); // 设置自动解挂时间默认值为当前时间+1天
|
|
146
|
+
var defaultTime = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
|
147
|
+
var pad = function (n) {
|
|
148
|
+
return n < 10 ? "0" + n : "" + n;
|
|
149
|
+
};
|
|
150
|
+
var defaultTimeStr =
|
|
151
|
+
defaultTime.getFullYear() +
|
|
152
|
+
"-" +
|
|
153
|
+
pad(defaultTime.getMonth() + 1) +
|
|
154
|
+
"-" +
|
|
155
|
+
pad(defaultTime.getDate()) +
|
|
156
|
+
"T" +
|
|
157
|
+
pad(defaultTime.getHours()) +
|
|
158
|
+
":" +
|
|
159
|
+
pad(defaultTime.getMinutes());
|
|
160
|
+
document.getElementById("hangupUnbanTime").value = defaultTimeStr; // 点击遮罩层关闭
|
|
161
|
+
overlay.addEventListener("click", (e) => {
|
|
162
|
+
if (e.target === overlay) {
|
|
163
|
+
this.closeDialog("hangupDialogOverlay");
|
|
164
|
+
}
|
|
165
|
+
}); // 取消按钮
|
|
166
|
+
document.getElementById("hangupCancelBtn").addEventListener("click", () => {
|
|
167
|
+
this.closeDialog("hangupDialogOverlay");
|
|
168
|
+
}); // 确定按钮
|
|
169
|
+
document
|
|
170
|
+
.getElementById("hangupConfirmBtn")
|
|
171
|
+
.addEventListener("click", () => {
|
|
172
|
+
this.confirmHangup();
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
async confirmHangup() {
|
|
176
|
+
const reason = document.getElementById("hangupReason").value;
|
|
177
|
+
const unbanTimeRaw = document.getElementById("hangupUnbanTime").value;
|
|
178
|
+
if (!unbanTimeRaw) {
|
|
179
|
+
message.warning("请填写自动解挂时间");
|
|
180
|
+
return;
|
|
181
|
+
} // datetime-local的值格式为 yyyy-MM-ddTHH:mm,转为 yyyy-MM-dd HH:mm:ss
|
|
182
|
+
const unbanTime = unbanTimeRaw.replace("T", " ") + ":00";
|
|
183
|
+
const orderCode = form.getValue("ORDER_CODE", "");
|
|
184
|
+
const flowId = form.getValue("FLOW_ID", "");
|
|
185
|
+
if (!orderCode) {
|
|
186
|
+
message.error("集团工单号为空,无法挂起");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!flowId) {
|
|
190
|
+
message.error("工单ID为空,无法挂起");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const result = await http.post(
|
|
195
|
+
"/aiops/api/v1/flow/group/province/alarm/dispatch/order/hangupOrder",
|
|
196
|
+
{
|
|
197
|
+
ORDER_CODE: orderCode,
|
|
198
|
+
FLOW_ID: flowId,
|
|
199
|
+
TYPE: "1",
|
|
200
|
+
REASON: reason,
|
|
201
|
+
UNBAN_TIME: unbanTime
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
if (result && result.resultCode === 0) {
|
|
205
|
+
message.success("挂起成功");
|
|
206
|
+
this.closeDialog("hangupDialogOverlay"); // 更新按钮状态为解挂
|
|
207
|
+
this.updateHangupBtnState("解挂");
|
|
208
|
+
} else {
|
|
209
|
+
message.error((result && result.resultMsg) || "挂起失败");
|
|
210
|
+
}
|
|
211
|
+
} catch (e) {
|
|
212
|
+
message.error("挂起请求异常");
|
|
213
|
+
console.error(e);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
showResumeDialog() {
|
|
217
|
+
const overlay = document.createElement("div");
|
|
218
|
+
overlay.className = "hangup-dialog-overlay";
|
|
219
|
+
overlay.id = "resumeDialogOverlay";
|
|
220
|
+
overlay.innerHTML = `
|
|
221
|
+
<div class="hangup-dialog">
|
|
222
|
+
<div class="hangup-dialog__title">解挂工单</div>
|
|
223
|
+
<label class="hangup-dialog__label">解挂原因</label>
|
|
224
|
+
<textarea class="hangup-dialog__textarea" id="resumeReason" placeholder="请输入解挂原因"></textarea>
|
|
225
|
+
<div class="hangup-dialog__footer">
|
|
226
|
+
<button class="hangup-dialog__btn hangup-dialog__btn--default" id="resumeCancelBtn">取 消</button>
|
|
227
|
+
<button class="hangup-dialog__btn hangup-dialog__btn--primary" id="resumeConfirmBtn">确 定</button>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
`;
|
|
231
|
+
document.body.appendChild(overlay); // 点击遮罩层关闭
|
|
232
|
+
overlay.addEventListener("click", (e) => {
|
|
233
|
+
if (e.target === overlay) {
|
|
234
|
+
this.closeDialog("resumeDialogOverlay");
|
|
235
|
+
}
|
|
236
|
+
}); // 取消按钮
|
|
237
|
+
document.getElementById("resumeCancelBtn").addEventListener("click", () => {
|
|
238
|
+
this.closeDialog("resumeDialogOverlay");
|
|
239
|
+
}); // 确定按钮
|
|
240
|
+
document
|
|
241
|
+
.getElementById("resumeConfirmBtn")
|
|
242
|
+
.addEventListener("click", () => {
|
|
243
|
+
this.confirmResume();
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
async confirmResume() {
|
|
247
|
+
const reason = document.getElementById("resumeReason").value;
|
|
248
|
+
const orderCode = form.getValue("ORDER_CODE", "");
|
|
249
|
+
const flowId = form.getValue("FLOW_ID", "");
|
|
250
|
+
if (!orderCode) {
|
|
251
|
+
message.error("集团工单号为空,无法解挂");
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (!flowId) {
|
|
255
|
+
message.error("工单ID为空,无法解挂");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
const result = await http.post(
|
|
260
|
+
"/aiops/api/v1/flow/group/province/alarm/dispatch/order/resumeOrder",
|
|
261
|
+
{ ORDER_CODE: orderCode, FLOW_ID: flowId, REASON: reason }
|
|
262
|
+
);
|
|
263
|
+
if (result && result.resultCode === 0) {
|
|
264
|
+
message.success("解挂成功");
|
|
265
|
+
this.closeDialog("resumeDialogOverlay"); // 更新按钮状态为挂起
|
|
266
|
+
this.updateHangupBtnState("挂起");
|
|
267
|
+
} else {
|
|
268
|
+
message.error((result && result.resultMsg) || "解挂失败");
|
|
269
|
+
}
|
|
270
|
+
} catch (e) {
|
|
271
|
+
message.error("解挂请求异常");
|
|
272
|
+
console.error(e);
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
updateHangupBtnState(prevState) {
|
|
276
|
+
const hangupBtn = document.getElementById("hangupBtn");
|
|
277
|
+
if (!hangupBtn) {
|
|
278
|
+
return;
|
|
279
|
+
} // 移除旧按钮的事件监听(通过替换节点实现)
|
|
280
|
+
const newBtn = hangupBtn.cloneNode(false);
|
|
281
|
+
if (prevState === "挂起") {
|
|
282
|
+
// 从挂起变为解挂 → 显示挂起按钮
|
|
283
|
+
newBtn.innerHTML =
|
|
284
|
+
'<div> <i class="fi el-icon-unlock icon"></i>挂起</div>';
|
|
285
|
+
newBtn.addEventListener("click", () => {
|
|
286
|
+
this.showHangupDialog();
|
|
287
|
+
}); // 同步更新表单字段
|
|
288
|
+
form.setValue("SUSPENDED_STATE", "解挂");
|
|
289
|
+
} else {
|
|
290
|
+
// 从解挂变为挂起 → 显示解挂按钮
|
|
291
|
+
newBtn.innerHTML = '<div> <i class="fi el-icon-lock icon"></i>解挂</div>';
|
|
292
|
+
newBtn.addEventListener("click", () => {
|
|
293
|
+
this.showResumeDialog();
|
|
294
|
+
}); // 同步更新表单字段
|
|
295
|
+
form.setValue("SUSPENDED_STATE", "挂起");
|
|
296
|
+
}
|
|
297
|
+
hangupBtn.parentNode.replaceChild(newBtn, hangupBtn);
|
|
298
|
+
},
|
|
299
|
+
closeDialog(overlayId) {
|
|
300
|
+
const overlay = document.getElementById(overlayId);
|
|
301
|
+
if (overlay) {
|
|
302
|
+
document.body.removeChild(overlay);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
async receiveOrder() {
|
|
306
|
+
const orderCode = form.getValue("ORDER_CODE", "");
|
|
307
|
+
const flowId = form.getValue("FLOW_ID", "");
|
|
308
|
+
if (!orderCode) {
|
|
309
|
+
message.error("集团工单号为空,无法接单");
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
if (!flowId) {
|
|
313
|
+
message.error("工单ID为空,无法接单");
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
const result = await http.post(
|
|
318
|
+
"/aiops/api/v1/flow/group/province/alarm/dispatch/order/receiveOrder",
|
|
319
|
+
this.form
|
|
320
|
+
);
|
|
321
|
+
if (result && result.resultCode === 0) {
|
|
322
|
+
message.success("接单成功");
|
|
323
|
+
return true;
|
|
324
|
+
} else {
|
|
325
|
+
message.error((result && result.resultMsg) || "接单失败");
|
|
326
|
+
}
|
|
327
|
+
} catch (e) {
|
|
328
|
+
message.error("接单请求异常");
|
|
329
|
+
console.error(e);
|
|
330
|
+
}
|
|
331
|
+
return false;
|
|
332
|
+
},
|
|
333
|
+
async handleAlarm() {
|
|
334
|
+
const orderCode = form.getValue("ORDER_CODE", "");
|
|
335
|
+
const flowId = form.getValue("FLOW_ID", "");
|
|
336
|
+
if (!orderCode) {
|
|
337
|
+
message.error("集团工单号为空,无法处理");
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
if (!flowId) {
|
|
341
|
+
message.error("工单ID为空,无法处理");
|
|
342
|
+
return false;
|
|
343
|
+
} // 1. 调用关联变更单接口(不判断结果)
|
|
344
|
+
try {
|
|
345
|
+
await http.post(
|
|
346
|
+
"/aiops/api/v1/flow/group/province/alarm/dispatch/order/relateChangeOrder",
|
|
347
|
+
this.form
|
|
348
|
+
);
|
|
349
|
+
} catch (e) {
|
|
350
|
+
console.error(e);
|
|
351
|
+
} // 2. 调用定位接口(不判断结果)
|
|
352
|
+
try {
|
|
353
|
+
await http.post(
|
|
354
|
+
"/aiops/api/v1/flow/group/province/alarm/dispatch/order/positioningOrder",
|
|
355
|
+
this.form
|
|
356
|
+
);
|
|
357
|
+
} catch (e) {
|
|
358
|
+
console.error(e);
|
|
359
|
+
} // 3. 调用回单接口
|
|
360
|
+
try {
|
|
361
|
+
const returnResult = await http.post(
|
|
362
|
+
"/aiops/api/v1/flow/group/province/alarm/dispatch/order/returnOrder",
|
|
363
|
+
this.form
|
|
364
|
+
);
|
|
365
|
+
if (returnResult && returnResult.resultCode === 0) {
|
|
366
|
+
message.success("告警处理成功");
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
message.error((returnResult && returnResult.resultMsg) || "回单失败");
|
|
370
|
+
return false;
|
|
371
|
+
} catch (e) {
|
|
372
|
+
message.error("回单请求异常");
|
|
373
|
+
console.error(e);
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
onChange_IF_RELATED_CHANGEORDER() {
|
|
378
|
+
form.removeRequired("CHANGE_ORDER");
|
|
379
|
+
if ("是" == form.getValue("IF_RELATED_CHANGEORDER")) {
|
|
380
|
+
const orderStr = form.getValue("CHANGE_ORDERS", "");
|
|
381
|
+
const orders = orderStr
|
|
382
|
+
.split(",")
|
|
383
|
+
.filter((order) => order.trim())
|
|
384
|
+
.map((order) => ({
|
|
385
|
+
label: order,
|
|
386
|
+
value: order,
|
|
387
|
+
children: null,
|
|
388
|
+
isShow: true,
|
|
389
|
+
pid: null,
|
|
390
|
+
state: null
|
|
391
|
+
}));
|
|
392
|
+
form.setSelectOptions("CHANGE_ORDER", orders);
|
|
393
|
+
form.setRequired("CHANGE_ORDER");
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
module.exports = customEvent;
|
|
398
|
+
|
|
399
|
+
```
|
package/core/util/ast.js
CHANGED
|
@@ -346,7 +346,8 @@ function importMods(outDir, srcAst, mapContext, useAlias = false) {
|
|
|
346
346
|
.replace(/\\/g, "/")
|
|
347
347
|
.replace(/\/index\.js$/, "")
|
|
348
348
|
.replace(/\.js$/, "");
|
|
349
|
-
|
|
349
|
+
// 确保 @ 别名路径格式为 @/xxx(@ 与路径之间必须有 /)
|
|
350
|
+
requireFrom = aliasPath.startsWith("/") ? "@" + aliasPath : "@/" + aliasPath;
|
|
350
351
|
}
|
|
351
352
|
else {
|
|
352
353
|
requireFrom = (0, path_1.relative)(outDir, srcPath.replace(/\/index\.js$/, "").replace(/\\index\.js$/, "").replace(/\.js$/, ""))
|