Commit 8db743381ba246480f413eea7afb5c2103169aeb

Authored by fengtao
1 parent f7c96e78

feat:转换脚本 新增启用后查看功能

... ... @@ -5,8 +5,8 @@
5 5 :title="getTitle"
6 6 @register="register"
7 7 width="500px"
8   - showFooter
9 8 @ok="handleSubmit"
  9 + showFooter
10 10 >
11 11 <BasicForm @register="registerForm">
12 12 <template #function>
... ... @@ -27,7 +27,7 @@
27 27 </template>
28 28
29 29 <script lang="ts" setup>
30   - import { ref, computed } from 'vue';
  30 + import { ref, computed, unref } from 'vue';
31 31 import { useDrawerInner, BasicDrawer } from '/@/components/Drawer/index';
32 32 import { useForm, BasicForm } from '/@/components/Form/index';
33 33 import { formSchema } from '../config/config.data';
... ... @@ -40,7 +40,8 @@
40 40 import { beautify } from 'ace-builds/src-noconflict/ext-beautify.js';
41 41
42 42 const emit = defineEmits(['register', 'isStatus', 'success']);
43   - const isUpdate = ref(false);
  43 + const isUpdate: any = ref(false);
  44 + const isView = ref(true);
44 45 const aceEditor = ref();
45 46 const aceRef = ref();
46 47 const getTitle = computed(() => (isUpdate.value ? '编辑转换脚本' : '新增转换脚本'));
... ... @@ -50,9 +51,33 @@
50 51 setDrawerProps({ confirmLoading: false });
51 52 isUpdate.value = data.isUpdate;
52 53 initEditor(data.record?.configuration.jsScript);
53   - if (isUpdate.value) {
54   - editId.value = data.record.id;
55   - setFieldsValue(data.record);
  54 + switch (isUpdate.value) {
  55 + case 'view':
  56 + isView.value = false;
  57 + setDrawerProps({
  58 + showFooter: unref(isView),
  59 + title: '查看转换脚本',
  60 + loading: false,
  61 + });
  62 + break;
  63 + case true:
  64 + isView.value = true;
  65 + setDrawerProps({
  66 + showFooter: unref(isView),
  67 + title: '编辑转换脚本',
  68 + loading: false,
  69 + });
  70 + editId.value = data.record.id;
  71 + setFieldsValue(data.record);
  72 + break;
  73 + case false:
  74 + isView.value = true;
  75 + setDrawerProps({
  76 + showFooter: unref(isView),
  77 + title: '新增转换脚本',
  78 + loading: false,
  79 + });
  80 + break;
56 81 }
57 82 });
58 83 const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({
... ...
... ... @@ -28,10 +28,18 @@
28 28 <TableAction
29 29 :actions="[
30 30 {
  31 + label: '查看',
  32 + // auth: 'api:yt:convert:js:get',
  33 + icon: 'ant-design:eye-outlined',
  34 + onClick: handleView.bind(null, record),
  35 + ifShow: record.status == 1,
  36 + },
  37 + {
31 38 label: '编辑',
32 39 auth: 'api:yt:convert:js:update',
33 40 icon: 'clarity:note-edit-line',
34 41 onClick: handleEdit.bind(null, record),
  42 + ifShow: record.status == 0,
35 43 },
36 44 {
37 45 label: '删除',
... ... @@ -59,7 +67,7 @@
59 67 </template>
60 68
61 69 <script lang="ts" setup>
62   - import { ref,nextTick } from 'vue';
  70 + import { ref, nextTick } from 'vue';
63 71 import { Switch } from 'ant-design-vue';
64 72 import { BasicTable, useTable, TableAction } from '/@/components/Table';
65 73 import { columns, searchFormSchema } from './config/config.data';
... ... @@ -130,12 +138,16 @@
130 138 }
131 139 };
132 140 const handleCreate = () => {
133   - openDrawer(true, {
134   - isUpdate: false,
  141 + nextTick(() => {
  142 + openDrawer(true, {
  143 + isUpdate: false,
  144 + });
135 145 });
136 146 };
137 147 const handleEdit = (record: Recordable) => {
138   - openDrawer(true, { isUpdate: true, record });
  148 + nextTick(() => {
  149 + openDrawer(true, { isUpdate: true, record });
  150 + });
139 151 };
140 152 const statusChange = async (checked, record) => {
141 153 setProps({
... ... @@ -159,4 +171,11 @@
159 171 reload();
160 172 }
161 173 };
  174 + function handleView() {
  175 + nextTick(() => {
  176 + openDrawer(true, {
  177 + isUpdate: 'view',
  178 + });
  179 + });
  180 + }
162 181 </script>
... ...