ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<script lang="ts" setup>
import { ref } from 'vue';
 
import { MonacoEditor } from '@jnpf/ui';
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
 
import ScriptDemo from '#/components/FormGenerator/src/components/ScriptDemo.vue';
 
const emit = defineEmits(['register', 'confirm']);
const [registerModal, { closeModal }] = useModalInner(init);
const editorRef = ref(null);
const text = ref('');
const funcName = ref('');
const title = ref('');
function init(data) {
  text.value = data.text;
  funcName.value = data.funcName;
  title.value = getFuncText(data.funcName);
}
function getFuncText(key) {
  let text = '';
  switch (key) {
    case 'afterOnload': {
      text = '表格事件';
      break;
    }
    case 'btnEnableRule': {
      text = '启用规则配置';
      break;
    }
    case 'cellStyle': {
      text = '单元格样式';
      break;
    }
    case 'rowStyle': {
      text = '表格行样式';
      break;
    }
    default: {
      text = '';
      break;
    }
  }
  return text;
}
function handleSubmit() {
  emit('confirm', text.value, funcName.value);
  closeModal();
}
</script>
<template>
  <BasicModal
    v-bind="$attrs"
    @register="registerModal"
    :title="title"
    help-message="小程序不支持在线JS脚本"
    :width="1000"
    @ok="handleSubmit"
    destroy-on-close
    class="form-script-modal">
    <div class="form-script-modal-body">
      <div class="main-board">
        <div class="main-board-editor">
          <MonacoEditor ref="editorRef" v-model="text" />
        </div>
        <div class="main-board-tips">
          <p>支持JavaScript的脚本,<ScriptDemo :type="funcName" /></p>
        </div>
      </div>
    </div>
  </BasicModal>
</template>