干燥机配套车间生产管理系统/云平台服务端
baoshiwei
2023-03-10 1fb197352b6a263646e4ccd3ed1c7854ede031dd
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
73
74
75
76
<template>
  <div>
    <template v-if="hasFile" v-for="(file, fileKey) of [innerFile || {}]" :key="fileKey">
      <a-input :readOnly="true" :value="file.name">
        <template #addonBefore style="width: 30px">
          <a-tooltip v-if="file.status === 'uploading'" :title="`上传中(${Math.floor(file.percent)}%)`">
            <LoadingOutlined />
          </a-tooltip>
          <a-tooltip v-else-if="file.status === 'done'" title="上传完成">
            <Icon icon="ant-design:check-circle-outlined" style="color: #00db00" />
          </a-tooltip>
          <a-tooltip v-else :title="file.message || '上传失败'">
            <Icon icon="ant-design:exclamation-circle-outlined" style="color: red" />
          </a-tooltip>
        </template>
        <span v-if="file.status === 'uploading'" slot="addonAfter">{{ Math.floor(file.percent) }}%</span>
        <template v-if="originColumn.allowDownload !== false || originColumn.allowRemove !== false" #addonAfter>
          <Dropdown :trigger="['click']" placement="bottomRight">
            <a-tooltip title="操作">
              <Icon icon="ant-design:setting-outlined" style="cursor: pointer" />
            </a-tooltip>
            <template #overlay>
              <a-menu>
                <a-menu-item v-if="originColumn.allowDownload !== false" @click="handleClickDownloadFile">
                  <span><Icon icon="ant-design:download-outlined" />&nbsp;下载</span>
                </a-menu-item>
                <a-menu-item v-if="originColumn.allowRemove !== false" @click="handleClickDeleteFile">
                  <span><Icon icon="ant-design:delete-outlined" />&nbsp;删除</span>
                </a-menu-item>
              </a-menu>
            </template>
          </Dropdown>
        </template>
      </a-input>
    </template>
    <a-upload
      v-show="!hasFile"
      name="file"
      :data="{ isup: 1 }"
      :multiple="false"
      :action="originColumn.action"
      :headers="uploadHeaders"
      :showUploadList="false"
      v-bind="cellProps"
      @change="handleChangeUpload"
    >
      <a-button preIcon="ant-design:upload-outlined">{{ originColumn.btnText || '点击上传' }}</a-button>
    </a-upload>
  </div>
</template>
 
<script lang="ts">
  import { defineComponent } from 'vue';
  import { Icon } from '/@/components/Icon';
  import { Dropdown } from 'ant-design-vue';
  import { LoadingOutlined } from '@ant-design/icons-vue';
  import { JVxeComponent } from '/@/components/jeecg/JVxeTable/types';
  import { useJVxeCompProps } from '/@/components/jeecg/JVxeTable/hooks';
  import { useJVxeUploadCell, fileGetValue, fileSetValue } from '../../hooks/cells/useJVxeUploadCell';
 
  export default defineComponent({
    name: 'JVxeUploadCell',
    components: { Icon, Dropdown, LoadingOutlined },
    props: useJVxeCompProps(),
    setup(props: JVxeComponent.Props) {
      const setup = useJVxeUploadCell(props);
      return { ...setup };
    },
    // 【组件增强】注释详见::JVxeComponent.Enhanced
    enhanced: {
      switches: { visible: true },
      getValue: (value) => fileGetValue(value),
      setValue: (value) => fileSetValue(value),
    } as JVxeComponent.EnhancedPartial,
  });
</script>