干燥机配套车间生产管理系统/云平台服务端
bsw215583320
2023-12-21 fa8fd40541df166a539bf3426ca67329930704e0
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
  <div>
    <div class="app">
      <div class="dragger">
        <a-upload-dragger
    v-model:fileList="fileList"
    name="file"
    accept="image/png, image/jpeg"
    :multiple="false"
    action="/herb/dry/real/identify"
    :beforeUpload="beforeUpload"
    @change="handleChange"
    @drop="handleDrop"
  >
    <p class="ant-upload-drag-icon">
      <inbox-outlined></inbox-outlined>
    </p>
    <p class="ant-upload-text">点击选择图片,或将图片拖到此区域内上传</p>
    <p class="ant-upload-hint">
      仅支持单个图片
    </p>
  </a-upload-dragger>
 
      </div>
 
      <div class="card">
 
 
        <a-row :gutter="10" style="width: 100%;">
          <a-col :span="12">
        <div >
          <a-card title="识别图像" >
            <div class="img">
              <div v-if="previewUrl" style="display: flex; justify-content: center;">
              <!-- <a-image
                :width="200"
                :src="previewUrl"
              /> -->
              <img :src="previewUrl" alt="预览图片" style="max-height: 500px; max-width: 100%;" />
            </div>
            </div>
 
 
          </a-card>
        </div>
      </a-col>
      <a-col :span="12">
        <div >
          <a-card title="识别结果">
            <div class="res">
              <a-table :columns="columns" :data-source="results" :pagination="false">
                </a-table>
            </div>
            </a-card>
          </div>
        </a-col>
        </a-row>
      </div>
     
    </div>
  </div>
 
 
</template>
 
<script setup lang="ts">
import { onMounted, ref, onUnmounted } from "vue";
import { InboxOutlined } from '@ant-design/icons-vue';
import { message } from 'ant-design-vue';
import type { UploadChangeParam } from 'ant-design-vue';
const fileList = ref([]);
const previewUrl = ref()
const results = ref([])
const columns = [
  {
    title: '药材',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '英文名',
    dataIndex: 'english',
    key: 'english',
  },
  {
    title: '可信度',
    dataIndex: 'probabily',
    key: 'probabily',
  },
]
const handleChange = (info: UploadChangeParam) => {
 // console.log("图片",info.file);
  // let reader = new FileReader()
  //       reader.readAsDataURL(info.file.originFileObj) // 文件转换
  //       reader.onloadend = function () {
  //         let src = this.result
 
  //         console.log("src::", src)
 
  //       }
 
  const status = info.file.status;
  if (status !== 'uploading') {
    console.log(info.file, info.fileList);
  }
  if (status === 'done') {
    message.success(`${info.file.name} file uploaded successfully.`);
    console.log("done",info.file.response.result)
    results.value = info.file.response.result
  } else if (status === 'error') {
    message.error(`${info.file.name} file upload failed.`);
  }
};
function handleDrop(e: DragEvent) {
  console.log(e);
}
 
function beforeUpload(file) {
  console.log("before",file)
  previewUrl.value =  URL.createObjectURL(file)
 
  console.log("pre",previewUrl.value)
}
 
 
 
 
 
// DOM挂载完成后渲染图表
onMounted(() => {
  
 
});
 
onUnmounted(() => {
 
});
</script>
 
<style lang="less" scoped>
.app {
  width: 100%;
 
 
  .dragger {
    margin:10px;
    height: 200px;
    background-color: white; 
  }
 
  .card {
    margin-left: 10px;
    display: flex;
    .img {
      height: 500px;
    }
    .res {
      height: 500px;
    }
  }
}
 
 
 
 
</style>