shot.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451
  1. <template>
  2. <headerBar
  3. :title="configInfoStore.appModel === 1 ? '拍摄商品' : '处理图像'"
  4. showUser
  5. :menu="menu"
  6. />
  7. <hardware-check/>
  8. <div class="photography-page flex-col">
  9. <div class="main-container">
  10. <template v-if="configInfoStore.appModel === 1 ">
  11. <div class="content-wrapper flex-row">
  12. <!-- <img class="camera-image" referrerpolicy="no-referrer" src="@/assets/images/Photography/camera-icon.png" />-->
  13. <div class="step-number flex-col"><span class="text_22">1</span></div>
  14. <div class="step-one flex-col justify-between">
  15. <div class="step-header flex-row">
  16. <span class="step-title">第一步:获取商品货号</span>
  17. <img class="step-icon" referrerpolicy="no-referrer" src="@/assets/images/Photography/step1-icon.png" />
  18. <img class="step-divider" referrerpolicy="no-referrer"
  19. src="@/assets/images/Photography/step-divider-line.png" />
  20. </div>
  21. <div class="step-content flex-row justify-between">
  22. <div class="method-container flex-col">
  23. <div class="input-container flex-row">
  24. <el-input class="input-item" v-model="goods_art_no" placeholder="请输入货号"> </el-input>
  25. </div>
  26. <div class="auto-method flex-row justify-between">
  27. <div class="text-method-tag flex-col"><span class="text_4">自动获取</span></div>
  28. <span class="method-description">用遥控器扫描商品资料二维码</span>
  29. </div>
  30. <div class="scan-method flex-row justify-between">
  31. <div class="remote-control flex-col">
  32. </div>
  33. <!-- <span class="scan-label">遥控器扫描键</span>-->
  34. </div>
  35. </div>
  36. <img class="remote-image" referrerpolicy="no-referrer"
  37. src="@/assets/images/Photography/remote-control.png" />
  38. </div>
  39. </div>
  40. <div class="step-number flex-col"><span class="text_22">2</span></div>
  41. <div class="step-two flex-col justify-between">
  42. <span class="step-title">第二步:启动拍摄(根据按遥控器左右键启动)</span>
  43. <div class="shooting-container flex-col">
  44. <div class="shooting-tips flex-row justify-between">
  45. <img class="info-icon" referrerpolicy="no-referrer" src="@/assets/images/Photography/info-icon.png" />
  46. <span class="tips-text">遥控左右按键可启动拍摄,中间按钮可在拍摄5张主图后解锁,用于拍摄自定义图</span>
  47. </div>
  48. <div class="wifi mar-top-20">
  49. <img referrerpolicy="no-referrer"
  50. src="@/assets/images/Photography/wifi.png" style="width: 60px" />
  51. </div>
  52. <div class="remote-control-wrap">
  53. <RemoteControl
  54. @onRemoteControl="onRemoteControl"
  55. />
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="last-photo" v-show="showlastPhoto" v-key="lastPhoto.file_path">
  61. <div>{{lastPhoto.action_name || ''}}</div>
  62. <el-image :src="getFilePath(lastPhoto.file_path)" fit="contain" ></el-image>
  63. </div>
  64. </template>
  65. <div class="history-section flex-col"
  66. :class="configInfoStore.appModel === 2 ? 'koutu-section' : ''"
  67. >
  68. <span class="history-title flex between">
  69. <div>拍摄记录</div>
  70. <div class="c-666 fs-12" v-if="goodsList.length" >
  71. <el-button :disabled="!(runLoading || takePictureLoading)" @click="oneClickStop" v-if="configInfoStore.appModel === 1" class="input-button" type="primary" size="mini">一键停止</el-button>
  72. <el-button :disabled="runLoading || takePictureLoading" @click="delAll" class="input-button" type="primary" size="mini">一键删除</el-button>
  73. </div>
  74. </span>
  75. <img class="divider-line" referrerpolicy="no-referrer" src="@/assets/images/Photography/divider-line.png" />
  76. <div class="history-warp">
  77. <div v-if="!goodsList.length" class="fs-14 c-666 mar-top-50">
  78. {{ loading ? '数据正在加载中,请稍候...' : '暂无数据,请先进行拍摄'}}
  79. </div>
  80. <div v-else class="history-item clearfix" v-for="item,index in goodsList" style="padding:10px;">
  81. <div class="flex between flex-item c-333">
  82. <div class="chaochu flex-item flex left">货号:{{ item.goods_art_no }}</div>
  83. <div >
  84. <!--
  85. <el-button :disabled="runLoading || takePictureLoading" size="small" plain >高级生成</el-button>
  86. -->
  87. <el-dropdown @command="handleGenerateCommand" :disabled="runLoading || takePictureLoading" >
  88. <el-button :disabled="runLoading || takePictureLoading" size="small" plain style="margin-right: 5px" >高级生成</el-button>
  89. <template #dropdown>
  90. <el-dropdown-menu>
  91. <el-dropdown-item
  92. v-for="menu in generate.children"
  93. @click.native="onGenerateCLick(menu,item)">{{ menu.name }}</el-dropdown-item>
  94. </el-dropdown-menu>
  95. </template>
  96. </el-dropdown>
  97. <el-button size="small" :disabled="runLoading || takePictureLoading" type="primary" @click="reTakePictureNos(item.goods_art_no,item)" plain v-if="configInfoStore.appModel === 1">重拍</el-button>
  98. <el-button size="small" :disabled="runLoading || takePictureLoading" @click="delGoods({goods_art_nos:[item.goods_art_no]})">删除</el-button>
  99. </div>
  100. </div>
  101. <div class="flex between flex-item c-333">
  102. <div class="c-999 fs-12">{{ getTime(item.action_time) }}</div>
  103. </div>
  104. <div class="mar-top-10 clearfix history-item_image_wrap" style="width: 100%" >
  105. <component class="history-item_image"
  106. v-for="image,index in item.items"
  107. v-loading="!image.PhotoRecord.image_path && runAction.goods_art_no == item.goods_art_no"
  108. :is="image.PhotoRecord.image_path ? 'div' : 'p'"
  109. >
  110. <span class="tag">{{ image.action_name }}</span>
  111. <el-popover
  112. :popper-class="configInfoStore.appModel === 1 ? 'shot-image-popper' : 'koutu-image-popper'"
  113. :placement=" configInfoStore.appModel === 1 ? 'left' : 'right'"
  114. :hide-after="0"
  115. width="50%"
  116. offset="20"
  117. v-if="image.PhotoRecord.image_path"
  118. >
  119. <template #reference>
  120. <div class="flex el-image_view">
  121. <el-image :src="getFilePath(image.PhotoRecord.image_path)" fit="contain" >
  122. <template #error>
  123. <div class="image-slot"></div>
  124. </template>
  125. </el-image>
  126. <el-button :disabled="runLoading || takePictureLoading" class="reset-button" @click="reTakePicture(image.PhotoRecord)">重拍</el-button>
  127. </div>
  128. </template>
  129. <el-image :src="getFilePath(image.PhotoRecord.image_path)" fit="contain" >
  130. <template #error>
  131. <div class="image-slot"></div>
  132. </template>
  133. </el-image>
  134. </el-popover>
  135. <div class="flex el-image_view" v-else>
  136. <el-image :src="getFilePath(image.PhotoRecord.image_path)" fit="contain">
  137. <template #error>
  138. <div class="image-slot"></div>
  139. <el-button :disabled="runLoading || takePictureLoading" class="reset-button" @click="reTakePicture(image.PhotoRecord)">重拍</el-button>
  140. </template>
  141. </el-image>
  142. </div>
  143. </component>
  144. <div v-if="item.items.length < 5"
  145. v-for="item in (5 - item.items.length)"
  146. class="history-item_image"
  147. >
  148. <span class="tag" style="font-size: 12px;">暂未配置</span>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. <!-- 无数据 -->
  154. <!-- <div class="empty-state flex-col justify-between">
  155. <img
  156. class="empty-icon"
  157. referrerpolicy="no-referrer"
  158. src="@/assets/images/Photography/empty-state-icon.png"
  159. />
  160. <span class="empty-text">暂无数据</span>
  161. </div>-->
  162. <div v-if="goodsList.length" class="next-step button--primary1 flex-col" @click="openPhotographyDetail"><span
  163. class="next-step-text">{{ configInfoStore.appModel === 1 ? '开始生成' : '开始生成'}}</span></div>
  164. </div>
  165. </div>
  166. </div>
  167. </template>
  168. <script setup lang="ts">
  169. import headerBar from '@/components/header-bar/index.vue'
  170. import { ref, reactive, onMounted, onBeforeUnmount,watchEffect, computed} from 'vue'
  171. import icpList from '@/utils/ipc'
  172. import client from "@/stores/modules/client";
  173. import socket from "@/stores/modules/socket";
  174. import { ElMessage ,ElMessageBox } from 'element-plus'
  175. import { getFilePath,getRouterUrl } from '@/utils/appfun'
  176. import {useRouter} from "vue-router";
  177. import HardwareCheck from '@/components/check/index.vue'
  178. import checkInfo from "@/stores/modules/check";
  179. import RemoteControl from '@/views/RemoteControl/index'
  180. import generate from '@/utils/menus/generate'
  181. const loading = ref(false)
  182. const runLoading = ref(false)
  183. const takePictureLoading = ref(false)
  184. import useUserInfo from "@/stores/modules/user";
  185. const useUserInfoStore = useUserInfo();
  186. import configInfo from '@/stores/modules/config';
  187. const configInfoStore = configInfo();
  188. import qiehuan from '@/components/header-bar/assets/qiehuan.svg'
  189. const menu = computed(()=>{
  190. if(configInfoStore.appModel === 2){
  191. return [
  192. {
  193. type:'setting'
  194. },
  195. {
  196. name:'切换模式',
  197. click(){
  198. configInfoStore.updateAppModel(1)
  199. Router.push({
  200. name:'PhotographyCheck'
  201. })
  202. }
  203. },
  204. {
  205. ...generate
  206. },
  207. {
  208. type:'ota'
  209. }
  210. ]
  211. }
  212. if(useUserInfoStore.userInfo.brand_company_code === '1300'){
  213. return [
  214. {
  215. type:'setting'
  216. },
  217. {
  218. type:'developer'
  219. },
  220. {
  221. ...generate,
  222. },
  223. {
  224. type:'ota'
  225. }
  226. ]
  227. }
  228. return [
  229. {
  230. type:'setting'
  231. },
  232. {
  233. ...generate
  234. },
  235. {
  236. type:'ota'
  237. }
  238. ]
  239. })
  240. const clientStore = client();
  241. const Router = useRouter()
  242. /*const goodsList = ref([
  243. {
  244. "goods_art_no": "123456789",
  245. "items": [
  246. {
  247. "record_id":1,
  248. "image_deal_mode":0,
  249. "image_path": "C:\\Users\\Administrator\\Pictures\\digiCamControl\\Session1\\DSC_0001.jpg",
  250. },
  251. {
  252. "record_id":2,
  253. "image_deal_mode":0,
  254. "image_path": "C:\\Users\\Administrator\\Pictures\\digiCamControl\\Session1\\DSC_0002.jpg",
  255. },
  256. {
  257. "record_id":3,
  258. "image_deal_mode":0,
  259. "image_path": "C:\\Users\\Administrator\\Pictures\\digiCamControl\\Session1\\DSC_0003.jpg",
  260. },
  261. {
  262. "record_id":4,
  263. "image_deal_mode":0,
  264. "image_path": "C:\\Users\\Administrator\\Pictures\\digiCamControl\\Session1\\DSC_0004.jpg",
  265. },
  266. {
  267. "record_id":5,
  268. "image_deal_mode":0,
  269. "image_path": "C:\\Users\\Administrator\\Pictures\\digiCamControl\\Session1\\DSC_0005.jpg",
  270. }
  271. ]
  272. }
  273. ])*/
  274. const goodsList = ref([])
  275. const goods_art_no_tpl = ref('')
  276. const goods_art_no = ref('')
  277. const runAction = ref({
  278. "action": "",
  279. "goods_art_no": ""
  280. })
  281. // 初始化 WebSocket 状态管理
  282. const socketStore = socket()
  283. /**
  284. * 保存货号模板到货号变量中。
  285. */
  286. function saveGoodsArtNo(){
  287. if(goods_art_no_tpl.value){
  288. goods_art_no.value = goods_art_no_tpl.value
  289. ElMessage.success('商品货号'+goods_art_no.value+'获取成功,请在遥控器上按下左或右脚按键,启动拍摄')
  290. }
  291. }
  292. /**
  293. * 获取拍照记录。
  294. * @param params - 可选参数,用于分页或其他筛选条件。
  295. */
  296. async function getPhotoRecords(params?:{}) {
  297. if(loading.value) return;
  298. loading.value = true;
  299. clientStore.ipc.send(icpList.takePhoto.getPhotoRecords,{
  300. ...params,
  301. page:1,
  302. size:100,
  303. });
  304. clientStore.ipc.on(icpList.takePhoto.getPhotoRecords, (event, result) => {
  305. loading.value = false;
  306. if(result.code === 0){
  307. clientStore.ipc.removeAllListeners(icpList.takePhoto.getPhotoRecords);
  308. console.log('getPhotoRecords print_time:'+new Date().toLocaleString()) // 打印当前时间
  309. console.log('getPhotoRecords print_time:'+JSON.stringify(result.data.list)) // 打印当前时间
  310. goodsList.value = result.data.list
  311. if(isDelGoodsGetList.value){
  312. isDelGoodsGetList.value = false;
  313. return;
  314. }
  315. getLastPhotoRecord()
  316. }else if(result.msg) {
  317. ElMessage.error(result.msg)
  318. }
  319. });
  320. }
  321. /**
  322. * 执行拍照操作。
  323. * @param data - 包含拍摄所需的数据对象。
  324. */
  325. async function runGoods(data) {
  326. if(runLoading.value || takePictureLoading.value){
  327. ElMessage.error('拍摄程序正在运行,请稍候')
  328. return
  329. }
  330. await socketStore.connectSocket();
  331. socketStore.sendMessage({
  332. type: 'run_mcu',
  333. data,
  334. })
  335. ElMessage.success('开始拍摄,请稍后')
  336. runLoading.value = true;
  337. runAction.value.action = data.action
  338. runAction.value.goods_art_no = data.goods_art_no
  339. goods_art_no.value = ''
  340. goods_art_no_tpl.value = ''
  341. reNosObj.value.goods_art_no = null;
  342. reNosObj.value.action = null;
  343. clientStore.ipc.on(icpList.socket.message + '_run_mcu', (event, result) => {
  344. clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu');
  345. console.log('_run_mcu');
  346. console.log(result);
  347. if(result.code !== 0 && result.msg){
  348. ElMessage.error(result.msg)
  349. runLoading.value = false
  350. return;
  351. }
  352. })
  353. }
  354. /**
  355. * 格式化时间字符串。
  356. * @param time - 原始时间字符串。
  357. * @returns 格式化后的时间字符串,若输入为空则返回 null。
  358. */
  359. const getTime = function(time){
  360. if(!time) return null
  361. return time.replace('T',' ').substr(5,11)
  362. }
  363. /**
  364. * 删除所有商品货号的历史记录。
  365. */
  366. async function delAll(){
  367. let params = goodsList.value.map(item=>item.goods_art_no)
  368. await ElMessageBox.confirm('确定要删除当下的历史记录吗?', '提示', {
  369. confirmButtonText: '确定',
  370. cancelButtonText: '取消',
  371. })
  372. del({goods_art_nos:params})
  373. }
  374. /**
  375. * 删除指定的商品货号。
  376. * @param params - 包含需要删除的货号列表的对象。
  377. */
  378. const delGoods = async function(params){
  379. await ElMessageBox.confirm('确定要删除货号:'+params.goods_art_nos[0]+'的拍摄数据吗?', '提示', {
  380. confirmButtonText: '确定',
  381. cancelButtonText: '取消',
  382. })
  383. del(params)
  384. }
  385. /**
  386. * 删除指定的商品货号。
  387. * @param params - 包含需要删除的货号列表的对象。
  388. */
  389. const isDelGoodsGetList = ref(false)
  390. const del = async function(params){
  391. clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
  392. clientStore.ipc.send(icpList.takePhoto.delectGoodsArts,params);
  393. clientStore.ipc.on(icpList.takePhoto.delectGoodsArts, (event, result) => {
  394. clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
  395. if(result.code === 0){
  396. isDelGoodsGetList.value =true
  397. ElMessage.info('货号删除成功')
  398. getPhotoRecords()
  399. if(reNosObj.value.goods_art_no){
  400. runGoods(reNosObj.value)
  401. }
  402. }else if(result.msg) {
  403. ElMessage.error(result.msg)
  404. }
  405. });
  406. }
  407. //单个重拍
  408. const reTakePicture = async (img)=>{
  409. if(!img.id) return;
  410. await ElMessageBox.confirm('此操作会先删除此数据,需要继续吗?', '提示', {
  411. confirmButtonText: '确定',
  412. cancelButtonText: '取消',
  413. })
  414. socketStore.sendMessage({
  415. type: 're_take_picture',
  416. "data":{"record_id":img.id},
  417. })
  418. clientStore.ipc.removeAllListeners(icpList.socket.message + '_re_take_picture');
  419. clientStore.ipc.on(icpList.socket.message + '_re_take_picture', (event, result) => {
  420. console.log('_re_take_picture')
  421. console.log(result)
  422. if(result.code === 0){
  423. getPhotoRecords()
  424. setTimeout(()=>{
  425. showlastPhoto.value = false
  426. },6000)
  427. }else if(result.msg) {
  428. ElMessage.error(result.msg)
  429. }
  430. clientStore.ipc.removeAllListeners(icpList.socket.message + '_re_take_picture');
  431. })
  432. }
  433. const reNosObj = ref({
  434. goods_art_no:null,
  435. action:null,
  436. })
  437. //货号重拍
  438. const reTakePictureNos = async (goods_art_no,item)=>{
  439. await ElMessageBox.confirm('此操作会先删除删除货号:'+goods_art_no+'的拍摄数据吗,需要继续吗?', '提示', {
  440. confirmButtonText: '确定',
  441. cancelButtonText: '取消',
  442. })
  443. reNosObj.value.goods_art_no = goods_art_no
  444. reNosObj.value.action = '执行左脚程序'
  445. if(item.items && typeof item.items === 'object' && item.items[0].image_deal_mode){
  446. reNosObj.value.action = '执行右脚程序'
  447. }
  448. del({goods_art_nos:[goods_art_no]})
  449. }
  450. /**
  451. * 检查是否可以进入下一步操作。
  452. */
  453. const next = async function(){
  454. if(runLoading.value){
  455. ElMessage.error('正在拍摄中,请稍候')
  456. return;
  457. }
  458. if(goodsList.length){
  459. ElMessage.error('请先拍摄商品。')
  460. return;
  461. }
  462. }
  463. const oneClickStop = ()=>{
  464. if(!(runLoading.value || takePictureLoading.value)){
  465. ElMessage.error('拍摄程序已结束,不需要单独停止!')
  466. return
  467. }else{
  468. socketStore.sendMessage({
  469. type: 'stop_action',
  470. })
  471. }
  472. }
  473. /**
  474. * 页面挂载时初始化事件监听器并获取初始数据。
  475. */
  476. onMounted(async () => {
  477. // 监听蓝牙扫描事件
  478. clientStore.ipc.on(icpList.socket.message + '_blue_tooth_scan', (event, result) => {
  479. console.log('_blue_tooth_scan')
  480. if (result.code === 0 && result.data?.data) {
  481. console.log(goods_art_no.value);
  482. if(!goods_art_no.value){
  483. ElMessage.error('请先扫描货号或者手动输入货号!')
  484. return;
  485. }
  486. runGoods({
  487. ...result.data?.data,
  488. goods_art_no: goods_art_no.value
  489. })
  490. }
  491. });
  492. /* window.addEventListener('storage', handleStorageEvent);*/
  493. await getPhotoRecords();
  494. // 监听图片处理完成事件
  495. clientStore.ipc.on(icpList.socket.message + '_image_process', (event, result) => {
  496. console.log('_image_process')
  497. console.log(result)
  498. getPhotoRecords()
  499. // 延迟两秒再获取一遍数据
  500. setTimeout(()=>{
  501. getPhotoRecords()
  502. },3000)
  503. })
  504. // 监听拍照完成事件
  505. clientStore.ipc.on(icpList.socket.message + '_photo_take', (event, result) => {
  506. console.log('_photo_take')
  507. console.log(result)
  508. if(result.status === 2 && result.msg.includes('执行完成')){
  509. getPhotoRecords()
  510. // 延迟两秒再获取一遍数据
  511. setTimeout(()=>{
  512. getPhotoRecords()
  513. },3000)
  514. takePictureLoading.value = false;
  515. return;
  516. }
  517. if(result.code !== 0 && result.msg){
  518. ElMessage.error(result.msg)
  519. takePictureLoading.value = false;
  520. }
  521. })
  522. // 监听一键停止
  523. clientStore.ipc.on(icpList.socket.message + '_stop_action', (event, result) => {
  524. console.log('_stop_action')
  525. console.log(result)
  526. oneClickStop()
  527. })
  528. // 监听拍照完成后的最终状态事件
  529. clientStore.ipc.on(icpList.socket.message + '_photo_take_finish', (event, result) => {
  530. console.log('_photo_take_finish')
  531. console.log(result)
  532. if(result.code === 0) {
  533. runLoading.value = false;
  534. runAction.value.goods_art_no = '';
  535. runAction.value.action = '';
  536. setTimeout(()=>{
  537. showlastPhoto.value = false
  538. },5000)
  539. }
  540. })
  541. // 监听手动触发拍照事件
  542. clientStore.ipc.on(icpList.socket.message + '_handler_take_picture', async (event, result) => {
  543. console.log('_handler_take_picture')
  544. console.log(result)
  545. if(result.code === 0){
  546. if(runLoading.value || takePictureLoading.value){
  547. ElMessage.error('拍摄程序正在运行,请稍候')
  548. return
  549. }
  550. ElMessage.success('正在拍摄中,请稍候')
  551. takePictureLoading.value = true;
  552. /* setTimeout(()=>{
  553. takePictureLoading.value = false;
  554. },3000)*/
  555. await socketStore.connectSocket();
  556. socketStore.sendMessage(result.data)
  557. getPhotoRecords()
  558. // 延迟两秒再获取一遍数据
  559. setTimeout(()=>{
  560. getPhotoRecords()
  561. },3000)
  562. }
  563. })
  564. })
  565. const onRemoteControl = (type)=>{
  566. if(type == 'take_picture'){
  567. if(runLoading.value || takePictureLoading.value){
  568. ElMessage.error('拍摄程序正在运行,请稍候')
  569. return
  570. }
  571. ElMessage.success('正在拍摄中,请稍候')
  572. socketStore.sendMessage({
  573. type: 'handler_take_picture',
  574. })
  575. return;
  576. }
  577. if(!goods_art_no.value){
  578. ElMessage.error('请先扫描货号或者手动输入货号!')
  579. return;
  580. }
  581. let action = '执行左脚程序'
  582. if(type === 'right') action = '执行右脚程序'
  583. runGoods({
  584. "action": action,
  585. "goods_art_no": goods_art_no.value,
  586. })
  587. }
  588. /*const handleStorageEvent = (e) => {
  589. if(e.key === 'run_mcu' && e.newValue){
  590. if(!goods_art_no.value){
  591. ElMessage.error('请先扫描货号或者手动输入货号!')
  592. localStorage.setItem('run_mcu','')
  593. return;
  594. }
  595. let action = '执行左脚程序'
  596. if(e.newValue === 'right') action = '执行右脚程序'
  597. runGoods({
  598. "action": action,
  599. "goods_art_no": goods_art_no.value,
  600. })
  601. localStorage.setItem('run_mcu','')
  602. }
  603. };*/
  604. const checkInfoStore = checkInfo()
  605. checkInfoStore.set_blue_tooth_scan_NO('')
  606. watchEffect(async ()=>{
  607. if(checkInfoStore.blue_tooth_scan_NO){
  608. ElMessage.success('商品货号'+checkInfoStore.blue_tooth_scan_NO+'获取成功,请在遥控器上按下左或右脚按键,启动拍摄')
  609. goods_art_no.value = checkInfoStore.blue_tooth_scan_NO
  610. checkInfoStore.set_blue_tooth_scan_NO('')
  611. }
  612. })
  613. /**
  614. * 页面卸载时移除所有事件监听器。
  615. */
  616. onBeforeUnmount(() => {
  617. clientStore.ipc.removeAllListeners(icpList.socket.message + '_blue_tooth_scan');
  618. clientStore.ipc.removeAllListeners(icpList.socket.message + '_image_process');
  619. clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu');
  620. clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take');
  621. clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take_finish');
  622. clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu_update');
  623. clientStore.ipc.removeAllListeners(icpList.socket.message + '_stop_action');
  624. /* window.removeEventListener('storage', handleStorageEvent);*/
  625. })
  626. /*
  627. * 打开最近一张拍摄图
  628. * */
  629. const lastPhoto = ref({})
  630. const showlastPhoto = ref(false)
  631. const getLastPhotoRecord = async ()=>{
  632. return;
  633. if(goodsList.value && goodsList.value.length === 0) return;
  634. clientStore.ipc.removeAllListeners(icpList.takePhoto.getLastPhotoRecord);
  635. clientStore.ipc.send(icpList.takePhoto.getLastPhotoRecord,);
  636. clientStore.ipc.on(icpList.takePhoto.getLastPhotoRecord, (event, result) => {
  637. console.log('getLastPhotoRecord')
  638. console.log(result)
  639. console.log(runAction.value)
  640. clientStore.ipc.removeAllListeners(icpList.takePhoto.getLastPhotoRecord);
  641. if(result.code === 0){
  642. if(lastPhoto.value?.image_path){
  643. if( lastPhoto.value?.image_path == result.data?.image_path) return;
  644. if(runAction.value.goods_art_no === result.data?.goods_art_no){
  645. showlastPhoto.value = true
  646. }
  647. }
  648. lastPhoto.value = result.data
  649. }else if(result.msg) {
  650. ElMessage.error(result.msg)
  651. }
  652. });
  653. }
  654. // 监听拍照完成后的最终状态事件
  655. clientStore.ipc.on(icpList.socket.message + '_run_mcu_update', (event, result) => {
  656. console.log('run_mcu_updat print_time:'+new Date().toLocaleString()) // 打印当前时间
  657. console.log('run_mcu_update print_time:'+JSON.stringify(result))
  658. if(result.code === 0){
  659. if(result.data?.file_path){
  660. if( lastPhoto.value?.file_path == result.data?.file_path) return;
  661. if(runAction.value.goods_art_no === result.data?.goods_art_no){
  662. showlastPhoto.value = true
  663. goodsList.value.map(item=>{
  664. if(item.goods_art_no === result.data?.goods_art_no){
  665. console.log('========item');
  666. console.log(item);
  667. item.items[result.data.image_index].PhotoRecord.image_path = result.data?.file_path
  668. result.data.action_name = item.items[result.data.image_index].action_name
  669. setTimeout(()=>{
  670. item.items[result.data.image_index].PhotoRecord.image_path = result.data?.file_path
  671. },1000)
  672. console.log(item);
  673. console.log( goodsList.value);
  674. }
  675. })
  676. // getPhotoRecords()
  677. setTimeout(()=>{
  678. getPhotoRecords()
  679. },2000)
  680. }
  681. lastPhoto.value = result.data
  682. }
  683. }else if(result.msg) {
  684. ElMessage.error(result.msg)
  685. }
  686. })
  687. /**
  688. * 打开主图详情页面。
  689. */
  690. function openPhotographyDetail() {
  691. if(runLoading.value || takePictureLoading.value){
  692. ElMessage.error('正在拍摄中,请稍候')
  693. return;
  694. }
  695. const { href } = Router.resolve({
  696. name: 'PhotographyDetail',
  697. query:{
  698. goods_art_nos:goodsList.value.map(item=>item.goods_art_no),
  699. }
  700. })
  701. clientStore.ipc.removeAllListeners(icpList.utils.openMain);
  702. let params = {
  703. title: '主图与详情生成',
  704. width: 1000,
  705. height: 630,
  706. frame: true,
  707. id: "PhotographyDetail",
  708. url: getRouterUrl(href)
  709. }
  710. clientStore.ipc.send(icpList.utils.openMain, params);
  711. }
  712. /*高级生成*/
  713. const onGenerateCLick = (menu,item)=>{
  714. if(menu.name === '历史记录'){
  715. menu.click()
  716. return
  717. }
  718. const firstWithImagePath = item.items.find(
  719. (image) => image.PhotoRecord.image_path
  720. );
  721. if (firstWithImagePath) {
  722. menu.click({
  723. query:{
  724. image_path:firstWithImagePath.PhotoRecord.image_path
  725. }
  726. })
  727. } else {
  728. menu.click()
  729. }
  730. }
  731. </script>
  732. <style lang="scss">
  733. .shot-image-popper {
  734. width: calc(100vw - 370px) !important;
  735. left: 20px !important;
  736. top: 50px !important;
  737. height: calc(100vh - 70px) !important;
  738. transform: translate(0px, 0px) !important;
  739. .el-image {
  740. width: 100%;
  741. height:100%;
  742. display: block;
  743. .el-image__inner {
  744. width: 100%;
  745. height:100%;
  746. display: block;
  747. }
  748. }
  749. }
  750. </style>
  751. <style scoped lang="scss">
  752. .photography-page {
  753. background-color: rgba(255, 255, 255, 1);
  754. position: relative;
  755. .main-container {
  756. position: relative;
  757. display: flex;
  758. .content-wrapper {
  759. flex-grow: 1 ;
  760. position: relative;
  761. top: 0;
  762. left: 0;
  763. right: 0;
  764. bottom: 0;
  765. margin: auto;
  766. justify-content: center;
  767. .step-number {
  768. background-color: rgba(22, 119, 255, 1);
  769. border-radius: 50%;
  770. height: 32px;
  771. margin-top: 51px;
  772. width: 32px;
  773. .text_22 {
  774. width: 6px;
  775. height: 22px;
  776. overflow-wrap: break-word;
  777. color: rgba(255, 255, 255, 1);
  778. font-size: 14px;
  779. font-weight: NaN;
  780. text-align: right;
  781. white-space: nowrap;
  782. line-height: 22px;
  783. margin: 5px 0 0 13px;
  784. }
  785. }
  786. .step-one {
  787. width: 426px;
  788. height: 521px;
  789. margin: 55px 0 0 5px;
  790. .step-header {
  791. width: 391px;
  792. height: 24px;
  793. margin-left: 3px;
  794. .step-title {
  795. width: 160px;
  796. height: 24px;
  797. overflow-wrap: break-word;
  798. color: rgba(0, 0, 0, 0.85);
  799. font-size: 16px;
  800. font-family: PingFangSC-Medium;
  801. font-weight: 500;
  802. text-align: left;
  803. white-space: nowrap;
  804. line-height: 24px;
  805. }
  806. .step-icon {
  807. width: 32px;
  808. height: 20px;
  809. margin-top: 4px;
  810. }
  811. .step-divider {
  812. width: 191px;
  813. height: 1px;
  814. margin: 13px 0 0 8px;
  815. }
  816. }
  817. .step-content {
  818. width: 426px;
  819. height: 469px;
  820. margin-top: 28px;
  821. .method-container {
  822. background-color: rgba(247, 247, 247, 1);
  823. height: 484px;
  824. width: 353px;
  825. .auto-method {
  826. width: 253px;
  827. height: 24px;
  828. margin: 28px 0 0 14px;
  829. .text-method-tag {
  830. background-color: rgba(0, 174, 30, 1);
  831. height: 24px;
  832. width: 65px;
  833. .text_4 {
  834. width: 56px;
  835. height: 20px;
  836. overflow-wrap: break-word;
  837. color: rgba(255, 255, 255, 1);
  838. font-size: 14px;
  839. font-family: PingFangSC-Semibold;
  840. font-weight: 600;
  841. text-align: left;
  842. white-space: nowrap;
  843. line-height: 20px;
  844. margin: 2px 0 0 4px;
  845. }
  846. }
  847. .method-description {
  848. width: 182px;
  849. height: 20px;
  850. overflow-wrap: break-word;
  851. color: rgba(71, 71, 71, 1);
  852. font-size: 14px;
  853. font-family: PingFangSC-Semibold;
  854. font-weight: 600;
  855. text-align: left;
  856. white-space: nowrap;
  857. line-height: 20px;
  858. margin-top: 2px;
  859. }
  860. }
  861. .scan-method {
  862. width: 350px;
  863. height: 350px;
  864. margin: 10px;
  865. .remote-control {
  866. width: 350px;
  867. height: 350px;
  868. background: url(@/assets/images/Photography/left.png) 0px 0px no-repeat;
  869. background-size: 300px 300px;
  870. position: relative;
  871. .scan-button {
  872. background-color: rgba(0, 174, 30, 1);
  873. border-radius: 50%;
  874. width: 27px;
  875. height: 27px;
  876. margin: 27px 0 0 34px;
  877. }
  878. .scan-line {
  879. position: absolute;
  880. left: 52px;
  881. top: 40px;
  882. width: 112px;
  883. height: 1px;
  884. }
  885. }
  886. .scan-label {
  887. width: 96px;
  888. height: 22px;
  889. overflow-wrap: break-word;
  890. color: rgba(0, 174, 30, 1);
  891. font-size: 16px;
  892. font-family: PingFangSC-Semibold;
  893. font-weight: 600;
  894. text-align: left;
  895. white-space: nowrap;
  896. line-height: 22px;
  897. margin-top: 30px;
  898. }
  899. }
  900. .manual-method {
  901. width: 155px;
  902. height: 24px;
  903. margin: 53px 0 0 14px;
  904. .method-tag {
  905. background-color: rgba(0, 148, 174, 1);
  906. height: 24px;
  907. width: 65px;
  908. .text_7 {
  909. width: 56px;
  910. height: 20px;
  911. overflow-wrap: break-word;
  912. color: rgba(255, 255, 255, 1);
  913. font-size: 14px;
  914. font-family: PingFangSC-Semibold;
  915. font-weight: 600;
  916. text-align: left;
  917. white-space: nowrap;
  918. line-height: 20px;
  919. margin: 2px 0 0 4px;
  920. }
  921. }
  922. .method-description {
  923. width: 84px;
  924. height: 20px;
  925. overflow-wrap: break-word;
  926. color: rgba(71, 71, 71, 1);
  927. font-size: 14px;
  928. font-family: PingFangSC-Semibold;
  929. font-weight: 600;
  930. text-align: left;
  931. white-space: nowrap;
  932. line-height: 20px;
  933. margin-top: 2px;
  934. }
  935. }
  936. .input-container {
  937. width: calc(100% - 20px );
  938. height: 36px;
  939. margin: 20px 10px 0;
  940. .input-item {
  941. :deep(.el-input__inner){
  942. height: 36px;
  943. line-height: 36px;
  944. }
  945. }
  946. }
  947. }
  948. .remote-image {
  949. width: 61px;
  950. height: 38px;
  951. margin-top: 216px;
  952. }
  953. }
  954. }
  955. .step-two {
  956. width: 384px;
  957. height: 521px;
  958. margin: 55px 0 0 7px;
  959. .step-title {
  960. width: 384px;
  961. height: 24px;
  962. overflow-wrap: break-word;
  963. color: rgba(0, 0, 0, 0.85);
  964. font-size: 16px;
  965. font-family: PingFangSC-Medium;
  966. font-weight: 500;
  967. text-align: left;
  968. white-space: nowrap;
  969. line-height: 24px;
  970. }
  971. .shooting-container {
  972. background-color: rgba(247, 247, 247, 1);
  973. width: 353px;
  974. height: 484px;
  975. margin: 28px 0 0 2px;
  976. .remote-control-wrap {
  977. width: 353px;
  978. height: 300px;
  979. }
  980. .shooting-tips {
  981. width: 325px;
  982. height: 40px;
  983. margin: 12px 0 0 15px;
  984. .info-icon {
  985. width: 16px;
  986. height: 16px;
  987. margin-top: 2px;
  988. }
  989. .tips-text {
  990. width: 302px;
  991. height: 40px;
  992. overflow-wrap: break-word;
  993. color: rgba(255, 76, 0, 1);
  994. font-size: 14px;
  995. font-weight: NaN;
  996. text-align: left;
  997. line-height: 20px;
  998. }
  999. }
  1000. .left-foot-text {
  1001. width: 240px;
  1002. height: 22px;
  1003. overflow-wrap: break-word;
  1004. color: rgba(0, 174, 30, 1);
  1005. font-size: 16px;
  1006. font-family: PingFangSC-Semibold;
  1007. font-weight: 600;
  1008. text-align: left;
  1009. white-space: nowrap;
  1010. line-height: 22px;
  1011. margin: 36px 0 0 9px;
  1012. }
  1013. .remote-control-container {
  1014. position: relative;
  1015. width: 280px;
  1016. height: 298px;
  1017. margin: 9px 0 0 35px;
  1018. .remote-buttons {
  1019. width: 206px;
  1020. height: 233px;
  1021. background: url(@/assets/images/Photography/right-button.png) 100% no-repeat;
  1022. background-size: 100% 100%;
  1023. margin: 30px 0 0 37px;
  1024. .left-button {
  1025. background-color: rgba(0, 174, 30, 1);
  1026. border-radius: 50%;
  1027. width: 55px;
  1028. height: 55px;
  1029. margin: 91px 0 0 1px;
  1030. }
  1031. .right-button {
  1032. background-color: rgba(0, 148, 174, 1);
  1033. border-radius: 50%;
  1034. width: 55px;
  1035. height: 55px;
  1036. margin: 91px 2px 0 93px;
  1037. }
  1038. }
  1039. .left-button-image {
  1040. width: 40px;
  1041. height: 148px;
  1042. margin: 150px 0 0 -3px;
  1043. }
  1044. .right-button-image {
  1045. position: absolute;
  1046. left: 0;
  1047. top: 0;
  1048. width: 40px;
  1049. height: 148px;
  1050. }
  1051. }
  1052. .right-foot-text {
  1053. width: 240px;
  1054. height: 22px;
  1055. overflow-wrap: break-word;
  1056. color: rgba(0, 148, 174, 1);
  1057. font-size: 16px;
  1058. font-family: PingFangSC-Semibold;
  1059. font-weight: 600;
  1060. text-align: left;
  1061. white-space: nowrap;
  1062. line-height: 22px;
  1063. margin: 12px 0 18px 98px;
  1064. }
  1065. }
  1066. }
  1067. }
  1068. .camera-image {
  1069. position: absolute;
  1070. left: 620px;
  1071. top: 220px;
  1072. width: 111px;
  1073. height: 111px;
  1074. }
  1075. .step-number-two {
  1076. background-color: rgba(22, 119, 255, 1);
  1077. border-radius: 50%;
  1078. height: 32px;
  1079. width: 32px;
  1080. position: absolute;
  1081. left: 450px;
  1082. top: 51px;
  1083. .step-text {
  1084. width: 9px;
  1085. height: 22px;
  1086. overflow-wrap: break-word;
  1087. color: rgba(255, 255, 255, 1);
  1088. font-size: 14px;
  1089. font-weight: NaN;
  1090. text-align: right;
  1091. white-space: nowrap;
  1092. line-height: 22px;
  1093. margin: 5px 0 0 12px;
  1094. }
  1095. }
  1096. }
  1097. }
  1098. .history-section {
  1099. background-color: rgba(234, 236, 237, 1);
  1100. width: 332px;
  1101. height: calc(100vh - 30px);
  1102. &.koutu-section {
  1103. width: 100%;
  1104. .reset-button {
  1105. display: none !important;
  1106. }
  1107. }
  1108. .history-title {
  1109. width: calc(100% - 20px);
  1110. height: 22px;
  1111. overflow-wrap: break-word;
  1112. color: rgba(51, 51, 51, 1);
  1113. font-size: 16px;
  1114. font-family: PingFangSC-Semibold;
  1115. font-weight: 600;
  1116. text-align: center;
  1117. white-space: nowrap;
  1118. line-height: 22px;
  1119. margin: 9px 0 0 10px;
  1120. }
  1121. .divider-line {
  1122. width: 100%;
  1123. height: 1px;
  1124. margin-top: 9px;
  1125. }
  1126. .history-warp {
  1127. flex-grow: 1;
  1128. overflow: auto;
  1129. height: calc(100% - 125px);
  1130. .history-item {
  1131. .history-item_image_wrap {
  1132. padding-bottom: 20px;
  1133. border-bottom: 1px solid #CCCCCC;
  1134. }
  1135. .history-item_image {
  1136. .tag {
  1137. color: #bbb;
  1138. position: absolute;
  1139. left: 0;
  1140. right: 0;
  1141. top:50%;
  1142. margin-top: -15px;
  1143. line-height: 20px;
  1144. }
  1145. /* &:nth-child(1)::before{
  1146. content:"俯视图";
  1147. }
  1148. &:nth-child(2)::before{
  1149. content:"侧视图";
  1150. }
  1151. &:nth-child(3)::before{
  1152. content:"后视图";
  1153. }
  1154. &:nth-child(4)::before{
  1155. content:"鞋底";
  1156. }
  1157. &:nth-child(5)::before{
  1158. content:"内里";
  1159. }*/
  1160. position: relative;
  1161. width: 70px;
  1162. height: 70px;
  1163. float: left;
  1164. margin: 6px 0 0 6px;
  1165. background: #F7F7F7;
  1166. .el-image {
  1167. display: block;
  1168. width:100%;
  1169. height: 100%;
  1170. }
  1171. &:first-child {
  1172. width: 146px;
  1173. height: 146px;
  1174. }
  1175. &.el-loading-parent--relative{
  1176. ::v-deep {
  1177. .el-loading-mask { display: none}
  1178. }
  1179. }
  1180. }
  1181. .el-image_view {
  1182. display: flex;
  1183. width: 100%;
  1184. height: 100%;
  1185. .reset-button {
  1186. width: 40px;
  1187. text-align: center;
  1188. height: 20px;
  1189. position: absolute;
  1190. left:50%;
  1191. top:50%;
  1192. padding: 0px;
  1193. margin-left:-20px;
  1194. margin-top:-10px;
  1195. color: #ffffff;
  1196. font-size: 14px;
  1197. background: rgba(0,0,0,0.6);
  1198. border-radius: 12px;
  1199. display: none;
  1200. cursor: pointer;
  1201. }
  1202. &:hover {
  1203. .reset-button {
  1204. display: block;
  1205. }
  1206. }
  1207. }
  1208. p:first-of-type {
  1209. ::v-deep {
  1210. .el-loading-mask { display: block !important;}
  1211. }
  1212. }
  1213. }
  1214. }
  1215. .empty-state {
  1216. width: 56px;
  1217. height: 48px;
  1218. .empty-icon {
  1219. width: 32px;
  1220. height: 18px;
  1221. margin-left: 12px;
  1222. }
  1223. .empty-text {
  1224. width: 56px;
  1225. height: 20px;
  1226. overflow-wrap: break-word;
  1227. color: rgba(153, 153, 153, 1);
  1228. font-size: 14px;
  1229. font-weight: NaN;
  1230. text-align: left;
  1231. white-space: nowrap;
  1232. line-height: 20px;
  1233. margin-top: 10px;
  1234. }
  1235. }
  1236. .next-step {
  1237. height: 50px;
  1238. background-size: 100% 100%;
  1239. width: 100%;
  1240. line-height: 50px;
  1241. .next-step-text {
  1242. width: 100%;
  1243. overflow-wrap: break-word;
  1244. color: rgba(255, 255, 255, 1);
  1245. font-weight: NaN;
  1246. text-align: center;
  1247. white-space: nowrap;
  1248. }
  1249. }
  1250. }
  1251. .last-photo{
  1252. position: fixed;
  1253. left: 20px;
  1254. top: 50px;
  1255. bottom: 20px;
  1256. right: 350px;
  1257. z-index: 10;
  1258. }
  1259. </style>