CRM_26-08-05#story#9126,车辆管理、服务商管理系统需求
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// 拍摄页与表单页之间的内存中转:blob 无法走路由 query,返回时由表单页取出并清空
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
result: null, // 拍照确认结果 { type, blob, dataURL }
|
||||
fallback: null // 相机不可用降级信息 { type, error }
|
||||
},
|
||||
mutations: {
|
||||
setResult(state, payload) {
|
||||
state.result = payload
|
||||
state.fallback = null
|
||||
},
|
||||
setFallback(state, payload) {
|
||||
state.fallback = payload
|
||||
state.result = null
|
||||
},
|
||||
clear(state) {
|
||||
state.result = null
|
||||
state.fallback = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<!-- 独立拍摄页:由 vehicleAdd 跳转进入(query.type = front/back/car),
|
||||
确认/取消/降级后 $router.back() 返回 vehicleAdd -->
|
||||
<camera-guide
|
||||
:visible="show"
|
||||
:type="type"
|
||||
@confirm="onConfirm"
|
||||
@cancel="goBack"
|
||||
@fallback="onFallback"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CameraGuide from "@/components/CameraGuide.vue";
|
||||
|
||||
export default {
|
||||
name: 'cameraGuidePage',
|
||||
components: { CameraGuide },
|
||||
data() {
|
||||
return {
|
||||
show: false // 挂载后置 true,触发组件 visible 侦听器启动相机
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
type() {
|
||||
const t = this.$route.query.type
|
||||
return ['front', 'back', 'car'].includes(t) ? t : 'front'
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.show = true
|
||||
},
|
||||
methods: {
|
||||
onConfirm({ blob, dataURL }) { // 拍照确认:结果存入 store,返回 vehicleAdd 消费
|
||||
this.$store.commit('camera/setResult', { type: this.type, blob, dataURL })
|
||||
this.$router.back()
|
||||
},
|
||||
onFallback(e) { // 相机不可用:降级信息存入 store,返回 vehicleAdd 走系统选择器
|
||||
this.$store.commit('camera/setFallback', { type: this.type, error: e })
|
||||
this.$router.back()
|
||||
},
|
||||
goBack() {
|
||||
this.$router.back()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user