st-comp 0.0.216 → 0.0.217

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": "st-comp",
3
3
  "public": true,
4
- "version": "0.0.216",
4
+ "version": "0.0.217",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -38,6 +38,8 @@ const visibleDescriptions = ref(false);
38
38
  const factorType = ref("脚本");
39
39
  const scriptTestLoading = ref(false);
40
40
  const scriptCopyLoading = ref(false);
41
+ const testVariety = ref("");
42
+ const testVarietyVisible = ref(false);
41
43
  const scriptTestLogVisible = ref(false);
42
44
  const scriptTestResult = reactive({
43
45
  result: null,
@@ -320,33 +322,55 @@ const handleScriptCopy = async () => {
320
322
  scriptCopyLoading.value = false;
321
323
  }
322
324
  };
323
- // 脚本: 测试
324
- const handleScriptTest = async () => {
325
- try {
326
- scriptTestLoading.value = true;
327
- const script = monacoEditorRef.value.getValue();
328
- if (!script) return ElMessage.error("请输入脚本语句");
329
- const { body } = await request.post("/common/qt/getFuncExpr", { factorSelectExpr: script });
330
- if (!body) return ElMessage.error("脚本解析失败, 请检查脚本内容是否填写完整或者联系管理员");
331
- const testRes = await request.post("/common/qt/testFactorSelect", { factorSelectExpr: body });
332
- const { result, detail } = testRes.body;
333
- Object.assign(scriptTestResult, { result, detail, code: body });
334
- if (result === 1) {
335
- ElMessage.success("测试通过");
336
- } else {
337
- ElMessage.error("测试未能通过");
325
+ // 测试: 打开/确认/日志
326
+ const extractCodesFromString = (str) => {
327
+ if (!str) return [];
328
+ return str.split("\n").reduce((result, next) => {
329
+ const code = next.trim().replace(/\s+/gi, " ").split(" ")[0];
330
+ code && result.push(code);
331
+ return result;
332
+ }, []);
333
+ };
334
+ const handleScriptTest = async (action) => {
335
+ switch (action) {
336
+ case "open": {
337
+ // 基础校验
338
+ if (!monacoEditorRef.value.getValue()) return ElMessage.error("脚本语句不可为空");
339
+ testVarietyVisible.value = true;
340
+ break;
341
+ }
342
+ case "submit": {
343
+ testVarietyVisible.value = false;
344
+ try {
345
+ scriptTestLoading.value = true;
346
+ const { body } = await request.post("/common/qt/getFuncExpr", { factorSelectExpr: monacoEditorRef.value.getValue() });
347
+ if (!body) return ElMessage.error("脚本解析失败, 请检查脚本内容是否填写完整或者联系管理员");
348
+ const params = {
349
+ codes: extractCodesFromString(testVariety.value),
350
+ factorSelectExpr: body,
351
+ };
352
+ const testRes = await request.post("/common/qt/testFactorSelect", params);
353
+ const { result, detail } = testRes.body;
354
+ Object.assign(scriptTestResult, { result, detail, code: body });
355
+ if (result === 1) {
356
+ ElMessage.success("测试通过");
357
+ } else {
358
+ ElMessage.error("测试未能通过");
359
+ scriptTestLogVisible.value = true;
360
+ }
361
+ } finally {
362
+ scriptTestLoading.value = false;
363
+ }
364
+ break;
365
+ }
366
+ case "log": {
367
+ if (scriptTestResult.result === null) {
368
+ return ElMessage.warning("请先进行测试, 等待测试完成后可查看日志");
369
+ }
338
370
  scriptTestLogVisible.value = true;
371
+ break;
339
372
  }
340
- } finally {
341
- scriptTestLoading.value = false;
342
- }
343
- };
344
- // 脚本: 日志明细
345
- const handleScriptLog = () => {
346
- if (scriptTestResult.result === null) {
347
- return ElMessage.warning("请先进行测试, 等待测试完成后可查看日志");
348
373
  }
349
- scriptTestLogVisible.value = true;
350
374
  };
351
375
 
352
376
  // 监控: 窗口开关
@@ -378,6 +402,7 @@ watch(
378
402
  case false: {
379
403
  stVarSelectDialogRef.value.close();
380
404
  scriptTestLogVisible.value = false;
405
+ testVariety.value = "";
381
406
  break;
382
407
  }
383
408
  }
@@ -526,13 +551,13 @@ watch(
526
551
  type="primary"
527
552
  size="small"
528
553
  :loading="scriptTestLoading"
529
- @click="handleScriptTest"
554
+ @click="handleScriptTest('open')"
530
555
  >测试</el-button
531
556
  >
532
557
  <el-button
533
558
  size="small"
534
559
  :icon="Document"
535
- @click="handleScriptLog"
560
+ @click="handleScriptTest('log')"
536
561
  >日志明细</el-button
537
562
  >
538
563
  </div>
@@ -812,6 +837,55 @@ watch(
812
837
  :factorType="factorType"
813
838
  :data="config.factorDescriptions?.filter((item) => [1, 3].includes(item.type))"
814
839
  />
840
+ <!-- 窗口: 选择测试所用的品种 -->
841
+ <el-dialog
842
+ modal-class="test-variety-dialog"
843
+ v-model="testVarietyVisible"
844
+ width="500"
845
+ align-center
846
+ append-to-body
847
+ overflow
848
+ :modal="false"
849
+ :modal-penetrable="true"
850
+ :show-close="false"
851
+ >
852
+ <template #header="{ titleId, titleClass }">
853
+ <div class="custom-header">
854
+ <div class="left">
855
+ <span
856
+ :id="titleId"
857
+ :class="titleClass"
858
+ >
859
+ 测试品种
860
+ </span>
861
+ </div>
862
+ <div class="right">
863
+ <st-varietyAutoComplete
864
+ label=""
865
+ @select="({ name, code }) => (testVariety += `${code} ${name} \n`)"
866
+ />
867
+ <el-icon @click="testVarietyVisible = false"><Close /></el-icon>
868
+ </div>
869
+ </div>
870
+ </template>
871
+ <el-input
872
+ class="full-height-textarea"
873
+ v-model="testVariety"
874
+ resize="none"
875
+ type="textarea"
876
+ :placeholder="`不填写时, 默认为000001 平安银行\n格式示例:\nhc8888\xa0\xa0\xa0\xa0热轧卷板期货指数\nsp8888\xa0\xa0\xa0\xa0纸浆期货指数\nbu8888\xa0\xa0\xa0\xa0石油沥青期货指数`"
877
+ />
878
+ <template #footer>
879
+ <div class="dialog-footer">
880
+ <el-button
881
+ type="primary"
882
+ @click="handleScriptTest('submit')"
883
+ >
884
+ 确认
885
+ </el-button>
886
+ </div>
887
+ </template>
888
+ </el-dialog>
815
889
  <!-- 窗口: 日志明细 -->
816
890
  <el-dialog
817
891
  modal-class="log-dialog"
@@ -853,7 +927,7 @@ watch(
853
927
  <el-divider direction="vertical" />
854
928
  <!-- 日志 -->
855
929
  <el-scrollbar height="600px">
856
- <pre :class="scriptTestResult.result === 1 ? 'success-log' : 'error-log'">{{ scriptTestResult.result === 1 ? "测试通过 √" : scriptTestResult.detail }}</pre>
930
+ <pre :class="scriptTestResult.result === 1 ? 'success-log' : 'error-log'">{{ scriptTestResult.result === 1 ? `✅️ 测试通过\n${scriptTestResult.detail}` : scriptTestResult.detail }}</pre>
857
931
  </el-scrollbar>
858
932
  </div>
859
933
  <!-- 底部 -->
@@ -912,6 +986,31 @@ watch(
912
986
  }
913
987
  }
914
988
  }
989
+ .test-variety-dialog {
990
+ .custom-header {
991
+ display: flex;
992
+ align-items: center;
993
+ justify-content: space-between;
994
+ .left,
995
+ .right {
996
+ display: flex;
997
+ align-items: center;
998
+ gap: 10px;
999
+ }
1000
+ .el-icon {
1001
+ cursor: pointer;
1002
+ }
1003
+ }
1004
+ .full-height-textarea {
1005
+ width: 100%;
1006
+ height: 200px;
1007
+ margin-top: 10px;
1008
+ :deep(.el-textarea__inner) {
1009
+ box-sizing: border-box;
1010
+ height: 100%;
1011
+ }
1012
+ }
1013
+ }
915
1014
  .log-dialog {
916
1015
  .custom-header {
917
1016
  display: flex;