|
@@ -1,9 +1,9 @@
|
|
|
<template>
|
|
|
- <m-dialog title="名片解析" :visible.sync="show" showDrawer :footer="false">
|
|
|
- <div class="fullBox box-2">
|
|
|
+ <m-dialog title="名片解析" :visible.sync="show" :showDrawer="id !== null" :footer="false" @close="handleClose">
|
|
|
+ <div class="fullBox box-1" :class="{ 'box-2': id }">
|
|
|
<v-card class="upload-card d-flex flex-column align-center justify-center overflow-hidden" elevation="5">
|
|
|
<template v-if="file">
|
|
|
- <div class="fullBox overflow-auto">
|
|
|
+ <div class="fullBox overflow-auto text-center">
|
|
|
<div class="change d-flex align-center justify-end pr-3 pt-3">
|
|
|
<UploadBtn
|
|
|
:loading="loading"
|
|
@@ -12,25 +12,15 @@
|
|
|
class="white--text"
|
|
|
@change="handleImport"
|
|
|
>
|
|
|
- <v-icon
|
|
|
- left
|
|
|
- dark
|
|
|
- >
|
|
|
- mdi-cloud-upload
|
|
|
- </v-icon>
|
|
|
+ <v-icon left dark>mdi-cloud-upload</v-icon>
|
|
|
更换名片
|
|
|
</UploadBtn>
|
|
|
<v-btn color="primary" rounded class="buttons white--text ml-2" @click="handleAnalysis">
|
|
|
- <v-icon
|
|
|
- left
|
|
|
- dark
|
|
|
- >
|
|
|
- mdi-file-arrow-left-right
|
|
|
- </v-icon>
|
|
|
+ <v-icon left dark>mdi-file-arrow-left-right</v-icon>
|
|
|
解析
|
|
|
</v-btn>
|
|
|
</div>
|
|
|
- <img width="100%" :src="previewUrl" />
|
|
|
+ <img width="100%" :src="previewUrl" style="max-width: 700px;" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<template v-else>
|
|
@@ -42,10 +32,7 @@
|
|
|
class="ma-2 white--text"
|
|
|
@change="handleImport"
|
|
|
>
|
|
|
- <v-icon
|
|
|
- left
|
|
|
- dark
|
|
|
- >
|
|
|
+ <v-icon left dark>
|
|
|
mdi-cloud-upload
|
|
|
</v-icon>
|
|
|
点击上传
|
|
@@ -56,11 +43,11 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</v-card>
|
|
|
- <MCard class="show-card d-flex flex-column" title="名片解析" v-loading="loading">
|
|
|
+ <MCard v-if="id" class="show-card d-flex flex-column" title="名片解析" v-loading="loading">
|
|
|
<template #title>
|
|
|
- <v-btn color="primary" class="buttons" rounded>
|
|
|
- <v-icon left>mdi-send</v-icon>
|
|
|
- 提交
|
|
|
+ <v-btn color="primary" class="buttons" rounded @click="handleUpdate">
|
|
|
+ <v-icon left>mdi-update</v-icon>
|
|
|
+ 更新
|
|
|
</v-btn>
|
|
|
</template>
|
|
|
<div class="fullBox overflow-auto">
|
|
@@ -138,6 +125,11 @@ import UploadBtn from '@/components/UploadBtn'
|
|
|
import MDialog from '@/components/Dialog'
|
|
|
import MCard from '@/components/MCard'
|
|
|
import MForm from '@/components/MForm'
|
|
|
+import {
|
|
|
+ businessCardParse,
|
|
|
+ getBusinessCardImage,
|
|
|
+ updateBusinessCardStatus
|
|
|
+} from '@/api/dataOrigin'
|
|
|
export default {
|
|
|
name: 'imageImportEdit',
|
|
|
components: {
|
|
@@ -156,39 +148,68 @@ export default {
|
|
|
previewUrl: null,
|
|
|
formItems: [
|
|
|
{ slotName: 'baseInfo' },
|
|
|
- { label: '姓名(中)', key: 'name', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '姓名(英)', key: 'name', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '职位(中)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '职位(英)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文姓名', key: 'name_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文姓名', key: 'name_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文职位/头衔', key: 'title_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文职位/头衔', key: 'title_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
{ slotName: 'relationship' },
|
|
|
- { label: '手机', key: 'post', type: 'text', outlined: true, dense: true, col: 4 },
|
|
|
- { label: '电话', key: 'post', type: 'text', outlined: true, dense: true, col: 4 },
|
|
|
- { label: '邮箱', key: 'post', type: 'text', outlined: true, dense: true, col: 4 },
|
|
|
+ { label: '手机号码', key: 'mobile', type: 'text', outlined: true, dense: true, col: 4 },
|
|
|
+ { label: '固定电话', key: 'phone', type: 'text', outlined: true, dense: true, col: 4 },
|
|
|
+ { label: '电子邮箱', key: 'email', type: 'text', outlined: true, dense: true, col: 4 },
|
|
|
{ slotName: 'companyInfo' },
|
|
|
- { label: '酒店名称(中)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '酒店名称(英)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '品牌名称(中)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '品牌名称(英)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文酒店/公司名称', key: 'hotel_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文酒店/公司名称', key: 'hotel_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文品牌名称', key: 'brand_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文品牌名称', key: 'brand_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文隶属关系', key: 'affiliation_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文隶属关系', key: 'affiliation_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '品牌组合', key: 'brand_group', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '职业轨迹', key: 'career_path', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
{ slotName: 'addressInfo' },
|
|
|
- { label: '详细地址(中)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
- { label: '详细地址(英)', key: 'post', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文地址', key: 'address_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文地址', key: 'address_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '中文邮政编码', key: 'postal_code_zh', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
+ { label: '英文邮政编码', key: 'postal_code_en', type: 'text', outlined: true, dense: true, col: 6 },
|
|
|
{ slotName: 'systemInfo' }
|
|
|
],
|
|
|
- formQuery: {}
|
|
|
+ formQuery: {},
|
|
|
+ id: null
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- open (item) {
|
|
|
+ async open (item) {
|
|
|
this.show = true
|
|
|
this.loading = false
|
|
|
+ this.formQuery = this.formItems.reduce((res, val) => {
|
|
|
+ if (val.key) {
|
|
|
+ res[val.key] = null
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ }, {})
|
|
|
if (!item) {
|
|
|
this.file = null
|
|
|
this.previewUrl = null
|
|
|
+ this.id = null
|
|
|
return
|
|
|
}
|
|
|
+ this.id = item.id
|
|
|
+ Object.keys(this.formQuery).forEach(key => {
|
|
|
+ this.formQuery[key] = item[key] || null
|
|
|
+ })
|
|
|
// 获取文件内容
|
|
|
- this.file = null
|
|
|
- this.handlePreview(this.file)
|
|
|
+ if (!item.image_path) {
|
|
|
+ this.file = null
|
|
|
+ this.previewUrl = null
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.file = item.image_path
|
|
|
+ try {
|
|
|
+ const { data } = await getBusinessCardImage(item.image_path)
|
|
|
+ console.log(data)
|
|
|
+ this.handlePreview(this.file)
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
},
|
|
|
async handleImport (file) {
|
|
|
this.loading = true
|
|
@@ -206,11 +227,40 @@ export default {
|
|
|
}
|
|
|
reader.readAsDataURL(file)
|
|
|
},
|
|
|
- handleAnalysis () {
|
|
|
+ async handleAnalysis () {
|
|
|
this.linearLoading = true
|
|
|
- setTimeout(() => {
|
|
|
+ const query = new FormData()
|
|
|
+ query.append('image', this.file)
|
|
|
+ try {
|
|
|
+ const { data } = await businessCardParse(query)
|
|
|
+ this.id = data.id
|
|
|
+ Object.keys(this.formQuery).forEach(key => {
|
|
|
+ this.formQuery[key] = data[key] || null
|
|
|
+ })
|
|
|
+ this.$snackbar.success('名片解析成功')
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ } finally {
|
|
|
this.linearLoading = false
|
|
|
- }, 2000)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async handleUpdate () {
|
|
|
+ if (!this.id) {
|
|
|
+ this.$snackbar.error('ID获取异常')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await updateBusinessCardStatus(this.formQuery, this.id)
|
|
|
+ this.$snackbar.success('更新成功')
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleClose () {
|
|
|
+ if (!this.id) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$emit('refresh')
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -220,6 +270,7 @@ export default {
|
|
|
.fullBox {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
+ min-height: 400px;
|
|
|
}
|
|
|
.upload-card {
|
|
|
// position: relative;
|
|
@@ -229,11 +280,15 @@ export default {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-.box-2 {
|
|
|
+.box-1 {
|
|
|
display: grid;
|
|
|
- grid-template-columns: 1fr 1fr;
|
|
|
- grid-gap: 15px;
|
|
|
+ grid-template-columns: 1fr;
|
|
|
+ &.box-2 {
|
|
|
+ grid-template-columns: 1fr 1fr;
|
|
|
+ grid-gap: 15px;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
.infoBox {
|
|
|
.label {
|
|
|
width: 100px;
|