shot.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  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" @click="delGoods({goods_art_nos:[item.goods_art_no]})">删除</el-button>
  98. </div>
  99. </div>
  100. <div class="flex between flex-item c-333" style="margin-top: 5px">
  101. <div class="c-999 fs-12">{{ getTime(item.action_time) }}</div>
  102. <el-button size="small" :disabled="runLoading || takePictureLoading" type="primary" @click="reTakePictureNos(item.goods_art_no,item)" plain v-if="configInfoStore.appModel === 1">重拍</el-button>
  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. clientStore.ipc.removeAllListeners(icpList.socket.message + '_smart_shooter_photo_take');
  625. /* window.removeEventListener('storage', handleStorageEvent);*/
  626. })
  627. /*
  628. * 打开最近一张拍摄图
  629. * */
  630. const lastPhoto = ref({})
  631. const showlastPhoto = ref(false)
  632. const getLastPhotoRecord = async ()=>{
  633. return;
  634. if(goodsList.value && goodsList.value.length === 0) return;
  635. clientStore.ipc.removeAllListeners(icpList.takePhoto.getLastPhotoRecord);
  636. clientStore.ipc.send(icpList.takePhoto.getLastPhotoRecord,);
  637. clientStore.ipc.on(icpList.takePhoto.getLastPhotoRecord, (event, result) => {
  638. console.log('getLastPhotoRecord')
  639. console.log(result)
  640. console.log(runAction.value)
  641. clientStore.ipc.removeAllListeners(icpList.takePhoto.getLastPhotoRecord);
  642. if(result.code === 0){
  643. if(lastPhoto.value?.image_path){
  644. if( lastPhoto.value?.image_path == result.data?.image_path) return;
  645. if(runAction.value.goods_art_no === result.data?.goods_art_no){
  646. showlastPhoto.value = true
  647. }
  648. }
  649. lastPhoto.value = result.data
  650. }else if(result.msg) {
  651. ElMessage.error(result.msg)
  652. }
  653. });
  654. }
  655. let smartShooterTimeout = null; // 在合适的位置定义一个全局变量用于保存定时器
  656. //拍照成功 SmartShooter
  657. clientStore.ipc.on(icpList.socket.message+'_smart_shooter_photo_take', async (event, result) => {
  658. console.log('_smart_shooter_photo_take');
  659. console.log(result);
  660. if(result.code === 0 && result.data?.photo_file_name){
  661. if (smartShooterTimeout) {
  662. clearTimeout(smartShooterTimeout);
  663. }
  664. smartShooterTimeout = setTimeout(() => {
  665. getPhotoRecords();
  666. }, 2000);
  667. }
  668. })
  669. // 监听拍照完成后的最终状态事件
  670. clientStore.ipc.on(icpList.socket.message + '_run_mcu_update', (event, result) => {
  671. console.log('run_mcu_updat print_time:'+new Date().toLocaleString()) // 打印当前时间
  672. console.log('run_mcu_update print_time:'+JSON.stringify(result))
  673. if(result.code === 0){
  674. if(result.data?.file_path){
  675. if( lastPhoto.value?.file_path == result.data?.file_path) return;
  676. if(runAction.value.goods_art_no === result.data?.goods_art_no){
  677. showlastPhoto.value = true
  678. goodsList.value.map(item=>{
  679. if(item.goods_art_no === result.data?.goods_art_no){
  680. console.log('========item');
  681. console.log(item);
  682. item.items[result.data.image_index].PhotoRecord.image_path = result.data?.file_path
  683. result.data.action_name = item.items[result.data.image_index].action_name
  684. setTimeout(()=>{
  685. item.items[result.data.image_index].PhotoRecord.image_path = result.data?.file_path
  686. },1000)
  687. console.log(item);
  688. console.log( goodsList.value);
  689. }
  690. })
  691. // getPhotoRecords()
  692. setTimeout(()=>{
  693. getPhotoRecords()
  694. },2000)
  695. }
  696. lastPhoto.value = result.data
  697. }
  698. }else if(result.msg) {
  699. ElMessage.error(result.msg)
  700. }
  701. })
  702. /**
  703. * 打开主图详情页面。
  704. */
  705. function openPhotographyDetail() {
  706. if(runLoading.value || takePictureLoading.value){
  707. ElMessage.error('正在拍摄中,请稍候')
  708. return;
  709. }
  710. const { href } = Router.resolve({
  711. name: 'PhotographyDetail',
  712. query:{
  713. goods_art_nos:goodsList.value.map(item=>item.goods_art_no),
  714. }
  715. })
  716. clientStore.ipc.removeAllListeners(icpList.utils.openMain);
  717. let params = {
  718. title: '主图与详情生成',
  719. width: 1000,
  720. height: 630,
  721. frame: true,
  722. id: "PhotographyDetail",
  723. url: getRouterUrl(href)
  724. }
  725. clientStore.ipc.send(icpList.utils.openMain, params);
  726. }
  727. /*高级生成*/
  728. const onGenerateCLick = (menu,item)=>{
  729. if(menu.name === '历史记录'){
  730. menu.click()
  731. return
  732. }
  733. const firstWithImagePath = item.items.find(
  734. (image) => image.PhotoRecord.image_path
  735. );
  736. if (firstWithImagePath) {
  737. menu.click({
  738. query:{
  739. image_path:firstWithImagePath.PhotoRecord.image_path
  740. }
  741. })
  742. } else {
  743. menu.click()
  744. }
  745. }
  746. </script>
  747. <style lang="scss">
  748. .shot-image-popper {
  749. width: calc(100vw - 370px) !important;
  750. left: 20px !important;
  751. top: 50px !important;
  752. height: calc(100vh - 70px) !important;
  753. transform: translate(0px, 0px) !important;
  754. .el-image {
  755. width: 100%;
  756. height:100%;
  757. display: block;
  758. .el-image__inner {
  759. width: 100%;
  760. height:100%;
  761. display: block;
  762. }
  763. }
  764. }
  765. </style>
  766. <style scoped lang="scss">
  767. .photography-page {
  768. background-color: rgba(255, 255, 255, 1);
  769. position: relative;
  770. .main-container {
  771. position: relative;
  772. display: flex;
  773. .content-wrapper {
  774. flex-grow: 1 ;
  775. position: relative;
  776. top: 0;
  777. left: 0;
  778. right: 0;
  779. bottom: 0;
  780. margin: auto;
  781. justify-content: center;
  782. .step-number {
  783. background-color: rgba(22, 119, 255, 1);
  784. border-radius: 50%;
  785. height: 32px;
  786. margin-top: 51px;
  787. width: 32px;
  788. .text_22 {
  789. width: 6px;
  790. height: 22px;
  791. overflow-wrap: break-word;
  792. color: rgba(255, 255, 255, 1);
  793. font-size: 14px;
  794. font-weight: NaN;
  795. text-align: right;
  796. white-space: nowrap;
  797. line-height: 22px;
  798. margin: 5px 0 0 13px;
  799. }
  800. }
  801. .step-one {
  802. width: 426px;
  803. height: 521px;
  804. margin: 55px 0 0 5px;
  805. .step-header {
  806. width: 391px;
  807. height: 24px;
  808. margin-left: 3px;
  809. .step-title {
  810. width: 160px;
  811. height: 24px;
  812. overflow-wrap: break-word;
  813. color: rgba(0, 0, 0, 0.85);
  814. font-size: 16px;
  815. font-family: PingFangSC-Medium;
  816. font-weight: 500;
  817. text-align: left;
  818. white-space: nowrap;
  819. line-height: 24px;
  820. }
  821. .step-icon {
  822. width: 32px;
  823. height: 20px;
  824. margin-top: 4px;
  825. }
  826. .step-divider {
  827. width: 191px;
  828. height: 1px;
  829. margin: 13px 0 0 8px;
  830. }
  831. }
  832. .step-content {
  833. width: 426px;
  834. height: 469px;
  835. margin-top: 28px;
  836. .method-container {
  837. background-color: rgba(247, 247, 247, 1);
  838. height: 484px;
  839. width: 353px;
  840. .auto-method {
  841. width: 253px;
  842. height: 24px;
  843. margin: 28px 0 0 14px;
  844. .text-method-tag {
  845. background-color: rgba(0, 174, 30, 1);
  846. height: 24px;
  847. width: 65px;
  848. .text_4 {
  849. width: 56px;
  850. height: 20px;
  851. overflow-wrap: break-word;
  852. color: rgba(255, 255, 255, 1);
  853. font-size: 14px;
  854. font-family: PingFangSC-Semibold;
  855. font-weight: 600;
  856. text-align: left;
  857. white-space: nowrap;
  858. line-height: 20px;
  859. margin: 2px 0 0 4px;
  860. }
  861. }
  862. .method-description {
  863. width: 182px;
  864. height: 20px;
  865. overflow-wrap: break-word;
  866. color: rgba(71, 71, 71, 1);
  867. font-size: 14px;
  868. font-family: PingFangSC-Semibold;
  869. font-weight: 600;
  870. text-align: left;
  871. white-space: nowrap;
  872. line-height: 20px;
  873. margin-top: 2px;
  874. }
  875. }
  876. .scan-method {
  877. width: 350px;
  878. height: 350px;
  879. margin: 10px;
  880. .remote-control {
  881. width: 350px;
  882. height: 350px;
  883. background: url(@/assets/images/Photography/left.png) 0px 0px no-repeat;
  884. background-size: 300px 300px;
  885. position: relative;
  886. .scan-button {
  887. background-color: rgba(0, 174, 30, 1);
  888. border-radius: 50%;
  889. width: 27px;
  890. height: 27px;
  891. margin: 27px 0 0 34px;
  892. }
  893. .scan-line {
  894. position: absolute;
  895. left: 52px;
  896. top: 40px;
  897. width: 112px;
  898. height: 1px;
  899. }
  900. }
  901. .scan-label {
  902. width: 96px;
  903. height: 22px;
  904. overflow-wrap: break-word;
  905. color: rgba(0, 174, 30, 1);
  906. font-size: 16px;
  907. font-family: PingFangSC-Semibold;
  908. font-weight: 600;
  909. text-align: left;
  910. white-space: nowrap;
  911. line-height: 22px;
  912. margin-top: 30px;
  913. }
  914. }
  915. .manual-method {
  916. width: 155px;
  917. height: 24px;
  918. margin: 53px 0 0 14px;
  919. .method-tag {
  920. background-color: rgba(0, 148, 174, 1);
  921. height: 24px;
  922. width: 65px;
  923. .text_7 {
  924. width: 56px;
  925. height: 20px;
  926. overflow-wrap: break-word;
  927. color: rgba(255, 255, 255, 1);
  928. font-size: 14px;
  929. font-family: PingFangSC-Semibold;
  930. font-weight: 600;
  931. text-align: left;
  932. white-space: nowrap;
  933. line-height: 20px;
  934. margin: 2px 0 0 4px;
  935. }
  936. }
  937. .method-description {
  938. width: 84px;
  939. height: 20px;
  940. overflow-wrap: break-word;
  941. color: rgba(71, 71, 71, 1);
  942. font-size: 14px;
  943. font-family: PingFangSC-Semibold;
  944. font-weight: 600;
  945. text-align: left;
  946. white-space: nowrap;
  947. line-height: 20px;
  948. margin-top: 2px;
  949. }
  950. }
  951. .input-container {
  952. width: calc(100% - 20px );
  953. height: 36px;
  954. margin: 20px 10px 0;
  955. .input-item {
  956. :deep(.el-input__inner){
  957. height: 36px;
  958. line-height: 36px;
  959. }
  960. }
  961. }
  962. }
  963. .remote-image {
  964. width: 61px;
  965. height: 38px;
  966. margin-top: 216px;
  967. }
  968. }
  969. }
  970. .step-two {
  971. width: 384px;
  972. height: 521px;
  973. margin: 55px 0 0 7px;
  974. .step-title {
  975. width: 384px;
  976. height: 24px;
  977. overflow-wrap: break-word;
  978. color: rgba(0, 0, 0, 0.85);
  979. font-size: 16px;
  980. font-family: PingFangSC-Medium;
  981. font-weight: 500;
  982. text-align: left;
  983. white-space: nowrap;
  984. line-height: 24px;
  985. }
  986. .shooting-container {
  987. background-color: rgba(247, 247, 247, 1);
  988. width: 353px;
  989. height: 484px;
  990. margin: 28px 0 0 2px;
  991. .remote-control-wrap {
  992. width: 353px;
  993. height: 300px;
  994. }
  995. .shooting-tips {
  996. width: 325px;
  997. height: 40px;
  998. margin: 12px 0 0 15px;
  999. .info-icon {
  1000. width: 16px;
  1001. height: 16px;
  1002. margin-top: 2px;
  1003. }
  1004. .tips-text {
  1005. width: 302px;
  1006. height: 40px;
  1007. overflow-wrap: break-word;
  1008. color: rgba(255, 76, 0, 1);
  1009. font-size: 14px;
  1010. font-weight: NaN;
  1011. text-align: left;
  1012. line-height: 20px;
  1013. }
  1014. }
  1015. .left-foot-text {
  1016. width: 240px;
  1017. height: 22px;
  1018. overflow-wrap: break-word;
  1019. color: rgba(0, 174, 30, 1);
  1020. font-size: 16px;
  1021. font-family: PingFangSC-Semibold;
  1022. font-weight: 600;
  1023. text-align: left;
  1024. white-space: nowrap;
  1025. line-height: 22px;
  1026. margin: 36px 0 0 9px;
  1027. }
  1028. .remote-control-container {
  1029. position: relative;
  1030. width: 280px;
  1031. height: 298px;
  1032. margin: 9px 0 0 35px;
  1033. .remote-buttons {
  1034. width: 206px;
  1035. height: 233px;
  1036. background: url(@/assets/images/Photography/right-button.png) 100% no-repeat;
  1037. background-size: 100% 100%;
  1038. margin: 30px 0 0 37px;
  1039. .left-button {
  1040. background-color: rgba(0, 174, 30, 1);
  1041. border-radius: 50%;
  1042. width: 55px;
  1043. height: 55px;
  1044. margin: 91px 0 0 1px;
  1045. }
  1046. .right-button {
  1047. background-color: rgba(0, 148, 174, 1);
  1048. border-radius: 50%;
  1049. width: 55px;
  1050. height: 55px;
  1051. margin: 91px 2px 0 93px;
  1052. }
  1053. }
  1054. .left-button-image {
  1055. width: 40px;
  1056. height: 148px;
  1057. margin: 150px 0 0 -3px;
  1058. }
  1059. .right-button-image {
  1060. position: absolute;
  1061. left: 0;
  1062. top: 0;
  1063. width: 40px;
  1064. height: 148px;
  1065. }
  1066. }
  1067. .right-foot-text {
  1068. width: 240px;
  1069. height: 22px;
  1070. overflow-wrap: break-word;
  1071. color: rgba(0, 148, 174, 1);
  1072. font-size: 16px;
  1073. font-family: PingFangSC-Semibold;
  1074. font-weight: 600;
  1075. text-align: left;
  1076. white-space: nowrap;
  1077. line-height: 22px;
  1078. margin: 12px 0 18px 98px;
  1079. }
  1080. }
  1081. }
  1082. }
  1083. .camera-image {
  1084. position: absolute;
  1085. left: 620px;
  1086. top: 220px;
  1087. width: 111px;
  1088. height: 111px;
  1089. }
  1090. .step-number-two {
  1091. background-color: rgba(22, 119, 255, 1);
  1092. border-radius: 50%;
  1093. height: 32px;
  1094. width: 32px;
  1095. position: absolute;
  1096. left: 450px;
  1097. top: 51px;
  1098. .step-text {
  1099. width: 9px;
  1100. height: 22px;
  1101. overflow-wrap: break-word;
  1102. color: rgba(255, 255, 255, 1);
  1103. font-size: 14px;
  1104. font-weight: NaN;
  1105. text-align: right;
  1106. white-space: nowrap;
  1107. line-height: 22px;
  1108. margin: 5px 0 0 12px;
  1109. }
  1110. }
  1111. }
  1112. }
  1113. .history-section {
  1114. background-color: rgba(234, 236, 237, 1);
  1115. width: 332px;
  1116. height: calc(100vh - 30px);
  1117. &.koutu-section {
  1118. width: 100%;
  1119. .reset-button {
  1120. display: none !important;
  1121. }
  1122. }
  1123. .history-title {
  1124. width: calc(100% - 20px);
  1125. height: 22px;
  1126. overflow-wrap: break-word;
  1127. color: rgba(51, 51, 51, 1);
  1128. font-size: 16px;
  1129. font-family: PingFangSC-Semibold;
  1130. font-weight: 600;
  1131. text-align: center;
  1132. white-space: nowrap;
  1133. line-height: 22px;
  1134. margin: 9px 0 0 10px;
  1135. }
  1136. .divider-line {
  1137. width: 100%;
  1138. height: 1px;
  1139. margin-top: 9px;
  1140. }
  1141. .history-warp {
  1142. flex-grow: 1;
  1143. overflow: auto;
  1144. height: calc(100% - 125px);
  1145. .history-item {
  1146. .history-item_image_wrap {
  1147. padding-bottom: 20px;
  1148. border-bottom: 1px solid #CCCCCC;
  1149. }
  1150. .history-item_image {
  1151. .tag {
  1152. color: #bbb;
  1153. position: absolute;
  1154. left: 0;
  1155. right: 0;
  1156. top:50%;
  1157. margin-top: -15px;
  1158. line-height: 20px;
  1159. }
  1160. /* &:nth-child(1)::before{
  1161. content:"俯视图";
  1162. }
  1163. &:nth-child(2)::before{
  1164. content:"侧视图";
  1165. }
  1166. &:nth-child(3)::before{
  1167. content:"后视图";
  1168. }
  1169. &:nth-child(4)::before{
  1170. content:"鞋底";
  1171. }
  1172. &:nth-child(5)::before{
  1173. content:"内里";
  1174. }*/
  1175. position: relative;
  1176. width: 70px;
  1177. height: 70px;
  1178. float: left;
  1179. margin: 6px 0 0 6px;
  1180. background: #F7F7F7;
  1181. .el-image {
  1182. display: block;
  1183. width:100%;
  1184. height: 100%;
  1185. }
  1186. &:first-child {
  1187. width: 146px;
  1188. height: 146px;
  1189. }
  1190. &.el-loading-parent--relative{
  1191. ::v-deep {
  1192. .el-loading-mask { display: none}
  1193. }
  1194. }
  1195. }
  1196. .el-image_view {
  1197. display: flex;
  1198. width: 100%;
  1199. height: 100%;
  1200. .reset-button {
  1201. width: 40px;
  1202. text-align: center;
  1203. height: 20px;
  1204. position: absolute;
  1205. left:50%;
  1206. top:50%;
  1207. padding: 0px;
  1208. margin-left:-20px;
  1209. margin-top:-10px;
  1210. color: #ffffff;
  1211. font-size: 14px;
  1212. background: rgba(0,0,0,0.6);
  1213. border-radius: 12px;
  1214. display: none;
  1215. cursor: pointer;
  1216. }
  1217. &:hover {
  1218. .reset-button {
  1219. display: block;
  1220. }
  1221. }
  1222. }
  1223. p:first-of-type {
  1224. ::v-deep {
  1225. .el-loading-mask { display: block !important;}
  1226. }
  1227. }
  1228. }
  1229. }
  1230. .empty-state {
  1231. width: 56px;
  1232. height: 48px;
  1233. .empty-icon {
  1234. width: 32px;
  1235. height: 18px;
  1236. margin-left: 12px;
  1237. }
  1238. .empty-text {
  1239. width: 56px;
  1240. height: 20px;
  1241. overflow-wrap: break-word;
  1242. color: rgba(153, 153, 153, 1);
  1243. font-size: 14px;
  1244. font-weight: NaN;
  1245. text-align: left;
  1246. white-space: nowrap;
  1247. line-height: 20px;
  1248. margin-top: 10px;
  1249. }
  1250. }
  1251. .next-step {
  1252. height: 50px;
  1253. background-size: 100% 100%;
  1254. width: 100%;
  1255. line-height: 50px;
  1256. .next-step-text {
  1257. width: 100%;
  1258. overflow-wrap: break-word;
  1259. color: rgba(255, 255, 255, 1);
  1260. font-weight: NaN;
  1261. text-align: center;
  1262. white-space: nowrap;
  1263. }
  1264. }
  1265. }
  1266. .last-photo{
  1267. position: fixed;
  1268. left: 20px;
  1269. top: 50px;
  1270. bottom: 20px;
  1271. right: 350px;
  1272. z-index: 10;
  1273. }
  1274. </style>