ProfitAnalysis.vue 2.66 KB
<template>
  <BasicModal
    v-bind="$attrs"
    destroyOnClose
    @register="register"
    title="利润分析表"
    :helpMessage="['提示1', '提示2']"
    @visible-change="handleShow"
    :footer="null"
  >
    <!-- <template #insertFooter>
      <a-button type="primary" danger @click="setLines" :disabled="loading">点我更新内容</a-button>
    </template> -->
    <!-- <template v-if="loading">
      <div class="empty-tips">加载中,稍等3秒……</div>
    </template> -->
    <Description
      class="mt-4"
      layout="vertical"
      :collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
      :column="2"
      :data="mockData"
      :schema="schema"
    />
  </BasicModal>
</template>
<script lang="ts">
  import { defineComponent, ref, toRaw, watch } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { Description, DescItem, useDescription } from '/@/components/Description/index';
  import { orderAnalysis } from '/@/api/project/order';

  export default defineComponent({
    components: { BasicModal, Description },
    setup() {
      const loading = ref(true);
      const lines = ref(10);
      const [register, { setModalProps, redoModalHeight }] = useModalInner(async (data) => {
        const orderIds = toRaw(data.data);
        const res = await orderAnalysis({ orderIds });
      });
      const mockData = {
        username: '100',
        nickName: '100',
        age: '123',
        phone: '1222',
        addr: '2332',
      };

      const schema: DescItem[] = [
        {
          field: 'username',
          label: '客户总金额',
        },
        {
          field: 'nickName',
          label: '供应商总价',
        },
        {
          field: 'phone',
          label: '包装费用',
        },
        {
          field: 'addr',
          label: '总利润率',
        },
      ];

      watch(
        () => lines.value,
        () => {
          redoModalHeight();
        },
      );

      function handleShow(visible: boolean) {
        if (visible) {
          loading.value = true;
          // setModalProps({ loading: true, confirmLoading: true });
          setTimeout(() => {
            lines.value = Math.round(Math.random() * 30 + 5);
            loading.value = false;
            setModalProps({ loading: false, confirmLoading: false });
          }, 3000);
        }
      }

      function setLines() {
        lines.value = Math.round(Math.random() * 20 + 10);
      }
      return { register, loading, handleShow, lines, setLines, mockData, schema };
    },
  });
</script>
<style scoped>
  .empty-tips {
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
</style>