OnlineHandleDrawer.vue
1.82 KB
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
<template>
  <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="处理上下线记录" width="30%">
    <Description :column="3" size="middle" @register="registeDesc" />
    <div style="height: 30px"></div>
    <BasicForm @register="registerForm" />
    <div class="flex flex-end" style="float: right">
      <a-button type="primary" @click="handleDeviceState">处理</a-button>
    </div>
  </BasicDrawer>
</template>
<script lang="ts" setup>
  import { reactive } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form';
  import { formHandleSchema, formDetailSchema } from './config.data';
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { deviceStateLogPost } from '/@/api/device/deviceManager';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { useDescription } from '/@/components/Description';
  import { Description } from '/@/components/Description/index';
  const emits = defineEmits(['success', 'register']);
  const { createMessage } = useMessage();
  const record = reactive({
    obj: {},
  });
  const [registerForm, { resetFields, getFieldsValue }] = useForm({
    schemas: formHandleSchema,
    showActionButtonGroup: false,
  });
  const [registeDesc, { setDescProps }] = useDescription({
    schema: formDetailSchema,
    column: 2,
    layout: 'vertical',
  });
  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
    await resetFields();
    setDrawerProps({ confirmLoading: false });
    record.obj = data.record;
    setDescProps({ data: data.record });
  });
  const handleDeviceState = async () => {
    const values = getFieldsValue();
    await deviceStateLogPost({
      ...record.obj,
      ...values,
    });
    emits('success');
    closeDrawer();
    createMessage.success('处理成功');
  };
</script>