check.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <headerBar
  3. v-if="!isSetting"
  4. title="拍摄物体镜头矫正"
  5. :menu="menu"
  6. showUser
  7. />
  8. <div class="check-wrap">
  9. <div class="check-page flex-col" :class="isSetting ? 'check-page_seeting' : '' ">
  10. <div class="main-container flex-col">
  11. <div class="content-wrapper flex-row justify-between">
  12. <div class="left-panel flex-col justify-between">
  13. <div class="tips-container flex-row" v-if="show">
  14. <spanc v-if="isSetting" class="tips-tex">
  15. 请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,如果光亮不够,可以打开光源。
  16. </spanc>
  17. <span v-else class="tips-tex">
  18. 请在圆盘上摆上鞋子(注意左右脚),要求鞋外侧朝向拍照机,鞋子中轴线和红外线对齐,可以打开光源。
  19. </span>
  20. </div>
  21. <div class="camera-preview flex col center ">
  22. <div class="camera-preview-img" v-if="step === 1">
  23. <img v-if="previewKey" class="camera-img" :src="preview+'?key='+previewKey" />
  24. <div class="example-image flex-col" v-if="!isSetting && previewKey > 1"><img src="https://huilimaimg.cnhqt.com/frontend/zhihuiyin/demo.jpg?x-oss-process=image/resize,w_400"></div>
  25. </div>
  26. <template v-if="step === 2" >
  27. <img class="camera-img" :src="getFilePath(imageTplPath)" />
  28. <span class="camera-description">这是一张用于检查镜头是否合适的测试图</span>
  29. </template>
  30. </div>
  31. </div>
  32. </div>
  33. <template v-if="!isSetting">
  34. <div v-if="step === 1" class="action-button flex cente">
  35. <div @click="takePictures" class="check-button button--primary1 flex-col"><span class="button-text" v-loading="loading">拍照检查</span>
  36. </div>
  37. </div>
  38. <div v-else class="action-button flex center">
  39. <div @click="checkConfirm(false)" class="check-button button--white flex-col">
  40. <span class="button-text cu-p">重新拍照检查</span>
  41. </div>
  42. <router-link class="mar-left-20 " :to="{
  43. name: 'PhotographyShot'
  44. }">
  45. <div class="check-button button--primary1 flex-col">
  46. <span class="button-text cu-p">确认无误,下一步</span>
  47. </div>
  48. </router-link>
  49. </div>
  50. </template>
  51. </div>
  52. </div>
  53. <editRow
  54. v-if="showrEditRow || isSetting"
  55. :id="id"
  56. @confirm="confirm"
  57. ref="editData"
  58. @onClose="onClose"
  59. :addRowData="addRowData"
  60. />
  61. </div>
  62. <hardware-check v-if="!isSetting"
  63. isInitCheck
  64. @confirm="checkConfirm(true)"
  65. />
  66. </template>
  67. <script setup lang="ts">
  68. import {watchEffect, ref, reactive, defineEmits, defineProps, computed, onBeforeUnmount, onMounted} from 'vue'
  69. import client from "@/stores/modules/client";
  70. import socket from "@/stores/modules/socket";
  71. import icpList from '@/utils/ipc'
  72. import useUserInfo from "@/stores/modules/user";
  73. import headerBar from '@/components/header-bar/index.vue'
  74. import editRow from './components/editRow'
  75. const clientStore = client();
  76. const socketStore = socket(); // WebSocket状态管理实例
  77. const emit = defineEmits([ 'confirm','onClose']);
  78. const confirm = ()=>{
  79. hideVideo()
  80. emit('confirm')
  81. }
  82. const onClose = ()=>{
  83. hideVideo()
  84. emit('onClose')
  85. }
  86. // 定义 props
  87. const props = defineProps({
  88. id:{
  89. type: Number||String,
  90. default: 0
  91. },
  92. addRowData:{
  93. type: Object,
  94. default: () => {
  95. return { }
  96. }
  97. }
  98. })
  99. const menu = reactive([])
  100. const show = ref(true)
  101. const isSetting = computed(()=>{
  102. return props.id || props.addRowData.mode_type
  103. })
  104. const useUserInfoStore = useUserInfo()
  105. import HardwareCheck from '@/components/check/index.vue'
  106. import { digiCamControlWEB } from '@/utils/appconfig'
  107. import { getFilePath } from '@/utils/appfun'
  108. import {ElMessage} from "element-plus";
  109. const previewKey = ref(0)
  110. const preview = ref(digiCamControlWEB+'liveview.jpg')
  111. const step = ref(1)
  112. function checkConfirm(init){
  113. step.value =1
  114. if(menu.length === 0){
  115. if(useUserInfoStore.userInfo.brand_company_code === '1300'){
  116. menu.push({
  117. type:'developer'
  118. })
  119. }
  120. }
  121. if(!init) previewKey.value++;
  122. showVideo()
  123. showrEditRow.value = true
  124. }
  125. const showrEditRow = ref(false)
  126. let interval:any = null
  127. function showVideo(){
  128. clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
  129. clientStore.ipc.send(icpList.camera.PreviewShow);
  130. clientStore.ipc.on(icpList.camera.PreviewShow, async (event, result) => {
  131. setTimeout(()=>{
  132. interval = setInterval(()=>{
  133. previewKey.value++;
  134. },200)
  135. },2000)
  136. })
  137. }
  138. function hideVideo(){
  139. clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
  140. clientStore.ipc.send(icpList.camera.PreviewHide);
  141. clientStore.ipc.on(icpList.camera.PreviewHide, async (event, result) => {
  142. if(interval) clearInterval(interval)
  143. })
  144. }
  145. const loading = ref(false)
  146. const editData = ref(null);
  147. const imageTplPath = ref(null)
  148. function takePictures() {
  149. console.log(editData);
  150. console.log(editData.value.editRowData);
  151. if (clientStore.isClient) {
  152. loading.value = true;
  153. socketStore.sendMessage({
  154. type: 'run_mcu_single',
  155. data: {
  156. camera_height: Number(editData.value.editRowData.camera_height),
  157. camera_angle: Number(editData.value.editRowData.camera_angle),
  158. led_switch:editData.value.editRowData.led_switch,
  159. id:0,
  160. mode_type:editData.value.editRowData.mode_type,
  161. turntable_position:Number(editData.value.editRowData.turntable_position),
  162. action_name:editData.value.editRowData.action_name || '测试',
  163. turntable_angle: Number(editData.value.editRowData.turntable_angle),
  164. shoe_upturn: Number(editData.value.editRowData.shoe_upturn),
  165. action_index:1,
  166. number_focus:0,
  167. take_picture:true,
  168. pre_delay:0,
  169. after_delay:0,
  170. }
  171. });
  172. clientStore.ipc.on(icpList.socket.message+'_run_mcu_single', async (event, result) => {
  173. console.log('_run_mcu_single_check')
  174. console.log(result)
  175. if(result.code === 0 && result.data?.file_path){
  176. clientStore.ipc.removeAllListeners(icpList.takePhoto.createMainImage);
  177. clientStore.ipc.send(icpList.takePhoto.createMainImage,{
  178. file_path:result.data.file_path
  179. });
  180. clientStore.ipc.on(icpList.takePhoto.createMainImage, async (event, result) => {
  181. console.log('icpList.utils.createMainImage');
  182. if(result.code === 0 && result.data?.main_out_path){
  183. imageTplPath.value = result.data?.main_out_path
  184. hideVideo()
  185. step.value = 2
  186. loading.value = false;
  187. }else if(result.msg){
  188. if(result.code !== 0) ElMessage.error(result.msg)
  189. }
  190. });
  191. }else if(result.msg){
  192. if(result.code !== 0) ElMessage.error(result.msg)
  193. }
  194. })
  195. }
  196. }
  197. onMounted(()=>{
  198. showVideo()
  199. })
  200. /**
  201. * 页面卸载时移除所有事件监听器。
  202. */
  203. onBeforeUnmount(() => {
  204. hideVideo()
  205. clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
  206. clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
  207. clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
  208. })
  209. </script>
  210. <style scoped lang="scss">
  211. .check-wrap {
  212. background-color: rgba(234, 236, 237, 1);
  213. display: flex;
  214. justify-content: left;
  215. }
  216. .check-page {
  217. width: calc(100% - 330px) ;
  218. position: relative;
  219. min-height: calc(100vh - 35px);
  220. overflow: hidden;
  221. background: #fff;
  222. .main-container {
  223. width: 100%;
  224. min-height: calc(100vh - 35px);
  225. margin-bottom: 1px;
  226. .content-wrapper {
  227. width:100%;
  228. padding: 10px;
  229. .left-panel {
  230. width: 100%;
  231. height: calc(100% - 80px);
  232. .tips-container {
  233. background-color: rgba(255, 241, 222, 0.8);
  234. border-radius: 4px;
  235. width: 100%;
  236. height: 40px;
  237. border: 1px solid rgba(255, 228, 190, 1);
  238. justify-content: flex-center;
  239. .tips-icon {
  240. width: 16px;
  241. height: 16px;
  242. margin: 12px 0 0 16px;
  243. }
  244. .tips-tex {
  245. width: 549px;
  246. height: 22px;
  247. overflow-wrap: break-word;
  248. color: rgba(0, 0, 0, 0.85);
  249. font-size: 14px;
  250. font-weight: NaN;
  251. text-align: left;
  252. white-space: nowrap;
  253. line-height: 22px;
  254. margin: 9px 0 0 7px;
  255. }
  256. .close-icon {
  257. width: 12px;
  258. height: 12px;
  259. margin: 14px 16px 0 17px;
  260. }
  261. }
  262. .camera-preview {
  263. background-color: rgba(255, 255, 255, 1);
  264. height: calc(100vh - 200px);
  265. position: relative;
  266. margin-top: 20px;
  267. position: relative;
  268. .camera-description {
  269. position: absolute;
  270. bottom: 20px;
  271. width: 60%;
  272. padding: 8px 20px;
  273. background: rgba($color: #ffffff, $alpha: .2);
  274. border-radius: 20px;
  275. font-size: 14px;
  276. }
  277. .camera-preview-img {
  278. display: inline-block;
  279. height: 100%;
  280. min-width: 300px;
  281. position: relative;
  282. }
  283. .camera-img {
  284. // width: 100%;
  285. display: block;
  286. position: relative;
  287. box-shadow: 0px 2px 10px 0px rgba(0, 32, 78, 0.1);
  288. height: 100%;
  289. object-fit:contain;
  290. }
  291. .example-image {
  292. position: absolute;
  293. right: 10px;
  294. bottom: 10px;
  295. background-color: rgba(216, 216, 216, 1);
  296. height: 200px;
  297. margin-top: 10px;
  298. width: 200px;
  299. img {
  300. width: 200px;
  301. height: 200px;
  302. display: block;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. .action-button {
  309. width: 100%;
  310. text-align: center;
  311. margin-top: 28px;
  312. .check-button {
  313. .button-text {
  314. width: 180px;
  315. overflow-wrap: break-word;
  316. font-size: 16px;
  317. text-align: center;
  318. white-space: nowrap;
  319. height: 40px;
  320. line-height: 40px;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. .check-page_seeting {
  327. min-height: calc(100vh - 92px);
  328. .main-container {
  329. min-height: calc(100vh - 92px);
  330. }
  331. }
  332. </style>