deviceOper.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. <template>
  2. <!-- 操作弹窗 -->
  3. <van-dialog
  4. class="operation-dialog"
  5. :width="isMobile ? '90%' : '560px'"
  6. v-model:show="show"
  7. :show-confirm-button="false"
  8. :show-cancel-button="false"
  9. :close-on-click-overlay="true"
  10. >
  11. <!-- 头部 -->
  12. <div class="dialog-header">
  13. <h3 class="dialog-title">{{ $t("device.commonOperations") }}</h3>
  14. <van-icon name="cross" class="close-icon" @click="show = false" />
  15. </div>
  16. <!-- 设备信息 -->
  17. <div class="device-info">
  18. <div class="info-item">
  19. <span class="info-label">{{ $t("device.equipmentName") }}:</span>
  20. <span class="info-value">{{
  21. device.name || $t("device.equipmentNameTips")
  22. }}</span>
  23. </div>
  24. <div class="info-item">
  25. <span class="info-label">{{ $t("device.equipmentNo") }}:</span>
  26. <span class="info-value">{{ device.clientId.slice(-6) }}</span>
  27. </div>
  28. </div>
  29. <!-- 操作列表 -->
  30. <div class="operation-grid">
  31. <!-- 重启炉头 -->
  32. <div
  33. v-if="controlList.includes('C1')"
  34. class="operation-item"
  35. @click="restartFurnace()"
  36. >
  37. <div class="icon-wrapper">
  38. <img
  39. class="operation-icon"
  40. src="../../assets/device/operIcon/restart.png"
  41. alt="restart"
  42. />
  43. </div>
  44. <div class="text-wrapper">
  45. <span class="operation-text">
  46. {{
  47. device.machineType === "0" || !device.machineType
  48. ? $t("device.restartFurnaceHead")
  49. : $t("device.restart")
  50. }}
  51. </span>
  52. </div>
  53. </div>
  54. <!-- 睡眠控制 -->
  55. <div
  56. v-if="controlList.includes('C2')"
  57. class="operation-item"
  58. @click="sleepEquipmentFun()"
  59. >
  60. <div class="icon-wrapper">
  61. <img
  62. class="operation-icon"
  63. v-if="sleepIcon === '0'"
  64. src="../../assets/device/operIcon/awake.png"
  65. alt="sleep"
  66. />
  67. <img
  68. class="operation-icon"
  69. v-else
  70. src="../../assets/device/operIcon/offSleep.png"
  71. alt="sleep"
  72. />
  73. </div>
  74. <div class="text-wrapper">
  75. <span class="operation-text">{{ sleepTitle }}</span>
  76. </div>
  77. </div>
  78. <!-- 开启炉头/设备 -->
  79. <div
  80. v-if="controlList.includes('C3') && device.machineType != '2'"
  81. class="operation-item"
  82. @click="openOffFurnace(1)"
  83. >
  84. <div class="icon-wrapper">
  85. <img
  86. class="operation-icon"
  87. src="../../assets/device/operIcon/onOff.png"
  88. alt="onOff"
  89. />
  90. </div>
  91. <div class="text-wrapper">
  92. <span class="operation-text">
  93. {{
  94. device.machineType === "0" || !device.machineType
  95. ? $t("device.openFurnHead")
  96. : $t("device.openDevice")
  97. }}
  98. </span>
  99. </div>
  100. </div>
  101. <!-- 关闭炉头/设备 -->
  102. <div
  103. v-if="controlList.includes('C4')"
  104. class="operation-item"
  105. @click="openOffFurnace(0)"
  106. >
  107. <div class="icon-wrapper">
  108. <img
  109. class="operation-icon"
  110. src="../../assets/device/operIcon/onOff.png"
  111. alt="onOff"
  112. />
  113. </div>
  114. <div class="text-wrapper">
  115. <span class="operation-text">
  116. {{
  117. device.machineType === "0" || !device.machineType
  118. ? $t("device.closeFurnHead")
  119. : $t("device.closeDevice")
  120. }}
  121. </span>
  122. </div>
  123. </div>
  124. <!-- 雪糕机制冷模式 -->
  125. <div
  126. v-if="device.machineType == '2' && controlList.includes('C24')"
  127. class="operation-item"
  128. @click="updateWorkingMode(0)"
  129. >
  130. <div class="icon-wrapper">
  131. <img
  132. class="operation-icon"
  133. src="../../assets/device/operIcon/refrigeration.png"
  134. alt="refrigeration"
  135. />
  136. </div>
  137. <div class="text-wrapper">
  138. <span class="operation-text">{{ $t("device.refrigeration") }}</span>
  139. </div>
  140. </div>
  141. <!-- 雪糕机搅拌模式 -->
  142. <div
  143. v-if="device.machineType == '2' && controlList.includes('C25')"
  144. class="operation-item"
  145. @click="updateWorkingMode(1)"
  146. >
  147. <div class="icon-wrapper">
  148. <img
  149. class="operation-icon"
  150. src="../../assets/device/operIcon/stir.png"
  151. alt="stir"
  152. />
  153. </div>
  154. <div class="text-wrapper">
  155. <div class="operation-text">{{ $t("device.stir") }}</div>
  156. </div>
  157. </div>
  158. <!-- 雪糕机保鲜模式 -->
  159. <div
  160. v-if="device.machineType == '2' && controlList.includes('C26')"
  161. class="operation-item"
  162. @click="updateWorkingMode(2)"
  163. >
  164. <div class="icon-wrapper">
  165. <img
  166. class="operation-icon"
  167. src="../../assets/device/operIcon/keepFresh.png"
  168. alt="keepFresh"
  169. />
  170. </div>
  171. <div class="text-wrapper">
  172. <span class="operation-text">{{ $t("device.keepFresh") }}</span>
  173. </div>
  174. </div>
  175. <!-- 雪糕机解冻模式 -->
  176. <div
  177. v-if="device.machineType == '2' && controlList.includes('C27')"
  178. class="operation-item"
  179. @click="updateWorkingMode(3)"
  180. >
  181. <div class="icon-wrapper">
  182. <img
  183. class="operation-icon"
  184. src="../../assets/device/operIcon/thaw.png"
  185. alt="thaw"
  186. />
  187. </div>
  188. <div class="text-wrapper">
  189. <span class="operation-text">{{ $t("device.thaw") }}</span>
  190. </div>
  191. </div>
  192. <!-- 远程开门 -->
  193. <div
  194. v-if="controlList.includes('C5')"
  195. class="operation-item"
  196. @click="openDoorFun()"
  197. >
  198. <div class="icon-wrapper">
  199. <img
  200. class="operation-icon"
  201. src="../../assets/device/operIcon/openControl.png"
  202. alt="openControl"
  203. />
  204. </div>
  205. <div class="text-wrapper">
  206. <span class="operation-text">{{
  207. $t("device.remoteDoorOpening")
  208. }}</span>
  209. </div>
  210. </div>
  211. <!-- 远程做糖 -->
  212. <div
  213. v-if="controlList.includes('C6')"
  214. class="operation-item"
  215. @click="doSugar()"
  216. >
  217. <div class="icon-wrapper">
  218. <img
  219. class="operation-icon"
  220. src="../../assets/device/operIcon/doSugar.png"
  221. alt="doSugar"
  222. />
  223. </div>
  224. <div class="text-wrapper">
  225. <span class="operation-text">{{
  226. $t("device.remoteProduction")
  227. }}</span>
  228. </div>
  229. </div>
  230. <!-- 定时开关 -->
  231. <div
  232. v-if="controlList.includes('C7') && device.equimentType != 'SI320'"
  233. class="operation-item"
  234. @click="alarmClock()"
  235. >
  236. <div class="icon-wrapper">
  237. <img
  238. class="operation-icon"
  239. src="../../assets/device/operIcon/alarmClock.png"
  240. alt="alarmClock"
  241. />
  242. </div>
  243. <div class="text-wrapper">
  244. <span class="operation-text">{{ $t("device.timeSwitch") }}</span>
  245. </div>
  246. </div>
  247. <!-- 音量调节 -->
  248. <div
  249. v-if="controlList.includes('C8')"
  250. class="operation-item"
  251. @click="modulation()"
  252. >
  253. <div class="icon-wrapper">
  254. <img
  255. class="operation-icon"
  256. src="../../assets/device/operIcon/modulation.png"
  257. alt="modulation"
  258. />
  259. </div>
  260. <div class="text-wrapper">
  261. <span class="operation-text">{{ $t("device.modulation") }}</span>
  262. </div>
  263. </div>
  264. <!-- 参数调整 -->
  265. <div
  266. v-if="
  267. device.equimentType != 'SI320' &&
  268. device.machineType != '2' &&
  269. controlList.includes('C9')
  270. "
  271. class="operation-item"
  272. @click="paramSetPush()"
  273. >
  274. <div class="icon-wrapper">
  275. <img
  276. class="operation-icon"
  277. src="../../assets/device/operIcon/paramsSet.png"
  278. alt="paramsSet"
  279. />
  280. </div>
  281. <div class="text-wrapper">
  282. <span class="operation-text">{{
  283. $t("device.parameterSetting")
  284. }}</span>
  285. </div>
  286. </div>
  287. <!-- 设置分销 -->
  288. <div
  289. v-if="user.ifForeign == '0' && controlList.includes('C10')"
  290. class="operation-item"
  291. @click="saveProportionPush()"
  292. >
  293. <div class="icon-wrapper">
  294. <img
  295. class="operation-icon"
  296. src="../../assets/device/operIcon/saveProportion.png"
  297. alt="saveProportion"
  298. />
  299. </div>
  300. <div class="text-wrapper">
  301. <span class="operation-text">{{ $t("device.addDistributor") }}</span>
  302. </div>
  303. </div>
  304. <!-- 系统脱机 -->
  305. <div
  306. v-if="controlList.includes('C19')"
  307. class="operation-item"
  308. @click="tuojiEquipmentFun()"
  309. >
  310. <div class="icon-wrapper">
  311. <img
  312. class="operation-icon"
  313. src="../../assets/device/operIcon/tuoji.png"
  314. alt="tuoji"
  315. />
  316. </div>
  317. <div class="text-wrapper">
  318. <span class="operation-text">{{ $t("device.sysOffline") }}</span>
  319. </div>
  320. </div>
  321. <!-- 修改价格 -->
  322. <div
  323. v-if="controlList.includes('C11')"
  324. class="operation-item"
  325. @click="modifyPriceClk()"
  326. >
  327. <div class="icon-wrapper">
  328. <img
  329. class="operation-icon"
  330. src="../../assets/device/operIcon/editPrice.png"
  331. alt="editPrice"
  332. />
  333. </div>
  334. <div class="text-wrapper">
  335. <span class="operation-text">{{ $t("device.modifyPrice") }}</span>
  336. </div>
  337. </div>
  338. <!-- 支付方式 -->
  339. <div
  340. v-if="
  341. controlList.includes('C28') &&
  342. device.machineType == '0' &&
  343. (user.ifForeign == '1' || user.type == 0)
  344. "
  345. class="operation-item"
  346. @click="paymentClk()"
  347. >
  348. <div class="icon-wrapper">
  349. <img
  350. class="operation-icon"
  351. src="../../assets/device/operIcon/payment.png"
  352. alt="payment"
  353. />
  354. </div>
  355. <div class="text-wrapper">
  356. <span class="operation-text">{{ $t("remote.C28") }}</span>
  357. </div>
  358. </div>
  359. <!-- 物料监控 -->
  360. <div
  361. v-if="device.equimentType != 'SI320' && controlList.includes('C12')"
  362. class="operation-item"
  363. @click="materialMonitorClk()"
  364. >
  365. <div class="icon-wrapper">
  366. <img
  367. class="operation-icon"
  368. v-if="materialIcon === '0'"
  369. src="../../assets/device/operIcon/materialMonitor.png"
  370. alt="materialMonitor"
  371. />
  372. <img
  373. class="operation-icon"
  374. v-else
  375. src="../../assets/device/operIcon/materialMonitorOff.png"
  376. alt="materialMonitorOff"
  377. />
  378. </div>
  379. <div class="text-wrapper">
  380. <span class="operation-text">{{ materialTitle }}</span>
  381. </div>
  382. </div>
  383. <!-- 屏蔽/展示商品 -->
  384. <div
  385. v-if="controlList.includes('C13')"
  386. class="operation-item"
  387. @click="showGoodsClk()"
  388. >
  389. <div class="icon-wrapper">
  390. <img
  391. class="operation-icon"
  392. src="../../assets/device/operIcon/showGoods.png"
  393. alt="showGoods"
  394. />
  395. </div>
  396. <div class="text-wrapper">
  397. <span class="operation-text">{{ $t("device.showGoods") }}</span>
  398. </div>
  399. </div>
  400. <!-- DIY花型 -->
  401. <div
  402. v-if="
  403. (device.equimentType == 'MG320' || device.equimentType == 'MG330') &&
  404. controlList.includes('C15')
  405. "
  406. class="operation-item"
  407. @click="diyFlowerClk()"
  408. >
  409. <div class="icon-wrapper">
  410. <img
  411. class="operation-icon"
  412. src="../../assets/device/operIcon/diyFlower.png"
  413. alt="diyFlower"
  414. />
  415. </div>
  416. <div class="text-wrapper">
  417. <span class="operation-text">{{ $t("device.diyFlower") }}</span>
  418. </div>
  419. </div>
  420. <!-- 修改机器密码 -->
  421. <div
  422. v-if="controlList.includes('C14')"
  423. class="operation-item"
  424. @click="changePasswordClk()"
  425. >
  426. <div class="icon-wrapper">
  427. <img
  428. class="operation-icon"
  429. src="../../assets/device/operIcon/password.png"
  430. alt="password"
  431. />
  432. </div>
  433. <div class="text-wrapper">
  434. <span class="operation-text">{{ $t("device.changePassword") }}</span>
  435. </div>
  436. </div>
  437. <!-- 删除设备 -->
  438. <div
  439. v-if="controlList.includes('C21')"
  440. class="operation-item"
  441. @click="deleteDevice()"
  442. >
  443. <div class="icon-wrapper">
  444. <img
  445. class="operation-icon"
  446. src="../../assets/device/operIcon/deletedevice.png"
  447. alt="deletedevice"
  448. />
  449. </div>
  450. <div class="text-wrapper">
  451. <span class="operation-text">{{ $t("device.deleteDevice") }}</span>
  452. </div>
  453. </div>
  454. <!-- 日志功能 -->
  455. <div
  456. v-if="controlList.includes('C20')"
  457. class="operation-item"
  458. @click="viewLogs()"
  459. >
  460. <div class="icon-wrapper">
  461. <img
  462. class="operation-icon"
  463. src="../../assets/device/operIcon/viewLogs.png"
  464. alt="viewLogs"
  465. />
  466. </div>
  467. <div class="text-wrapper">
  468. <span class="operation-text">{{ $t("device.viewLogs") }}</span>
  469. </div>
  470. </div>
  471. <!-- 定制logo -->
  472. <div
  473. v-if="controlList.includes('C22')"
  474. class="operation-item"
  475. @click="customLogo()"
  476. >
  477. <div class="icon-wrapper">
  478. <img
  479. class="operation-icon"
  480. src="../../assets/device/operIcon/customLogo.png"
  481. alt="customLogo"
  482. />
  483. </div>
  484. <div class="text-wrapper">
  485. <span class="operation-text">{{
  486. $t("device.customLogo.customLogo")
  487. }}</span>
  488. </div>
  489. </div>
  490. <!-- 远程锁机 -->
  491. <div
  492. v-if="controlList.includes('C23')"
  493. class="operation-item"
  494. @click="lockDevice()"
  495. >
  496. <div class="icon-wrapper">
  497. <img
  498. class="operation-icon"
  499. src="../../assets/device/operIcon/lock.png"
  500. alt="lock"
  501. />
  502. </div>
  503. <div class="text-wrapper">
  504. <span class="operation-text">{{ $t("device.lockDevice") }}</span>
  505. </div>
  506. </div>
  507. <!-- 远程重启触摸屏 -->
  508. <div
  509. v-if="controlList.includes('C16')"
  510. class="operation-item"
  511. @click="restartAndroid()"
  512. >
  513. <div class="icon-wrapper">
  514. <img
  515. class="operation-icon"
  516. src="../../assets/device/operIcon/restartAndroid.png"
  517. alt="restartAndroid"
  518. />
  519. </div>
  520. <div class="text-wrapper">
  521. <span class="operation-text">{{ $t("device.restartAndroid") }}</span>
  522. </div>
  523. </div>
  524. <!-- 设备清洗提醒 -->
  525. <div
  526. class="operation-item"
  527. v-if="
  528. (device.machineType === '0' || device.machineType === null) &&
  529. controlList.includes('C17')
  530. "
  531. @click="alramCleanClk()"
  532. >
  533. <div class="icon-wrapper">
  534. <img
  535. class="operation-icon"
  536. src="../../assets/device/operIcon/alramClean.png"
  537. alt="alramClean"
  538. />
  539. </div>
  540. <div class="text-wrapper">
  541. <span class="operation-text">{{ $t("device.alramClean") }}</span>
  542. </div>
  543. </div>
  544. <!-- 远程退币 -->
  545. <div
  546. class="operation-item"
  547. v-if="
  548. (device.machineType === '0' ||
  549. device.machineType === null ||
  550. device.equimentType === 'P30') &&
  551. (user.type < 2 || user.ifForeign === '1') &&
  552. controlList.includes('C18')
  553. "
  554. @click="returnCoinClk()"
  555. >
  556. <div class="icon-wrapper">
  557. <img
  558. class="operation-icon"
  559. src="../../assets/device/operIcon/coin.png"
  560. alt="coin"
  561. />
  562. </div>
  563. <div class="text-wrapper">
  564. <span class="operation-text">{{ $t("device.returnCoin") }}</span>
  565. </div>
  566. </div>
  567. <!-- 税费管理 -->
  568. <div
  569. v-if="
  570. (device.machineType === '0' || device.machineType === null) &&
  571. (user.type == 0 || user.ifForeign === '1') &&
  572. controlList.includes('C29')
  573. "
  574. class="operation-item"
  575. @click="taxClk()"
  576. >
  577. <div class="icon-wrapper">
  578. <img
  579. class="operation-icon"
  580. src="../../assets/device/operIcon/tax.png"
  581. alt="tax"
  582. />
  583. </div>
  584. <div class="text-wrapper">
  585. <span class="operation-text">{{ $t("remote.C29") }}</span>
  586. </div>
  587. </div>
  588. <!-- 果酱抽取 -->
  589. <div
  590. v-if="device.machineType === '2' && controlList.includes('C30')"
  591. class="operation-item"
  592. @click="jamClk()"
  593. >
  594. <div class="icon-wrapper">
  595. <img
  596. class="operation-icon"
  597. src="../../assets/device/operIcon/jam.png"
  598. alt="jam"
  599. />
  600. </div>
  601. <div class="text-wrapper">
  602. <span class="operation-text">{{ $t("remote.C30") }}</span>
  603. </div>
  604. </div>
  605. <!-- 维护记录 -->
  606. <div
  607. v-if="
  608. (device.machineType === '0' || device.machineType === '1') &&
  609. controlList.includes('C31')
  610. "
  611. class="operation-item"
  612. @click="maintenanceClk()"
  613. >
  614. <div class="icon-wrapper">
  615. <img
  616. class="operation-icon"
  617. src="../../assets/device/operIcon/maintenance.png"
  618. alt="maintenance"
  619. />
  620. </div>
  621. <div class="text-wrapper">
  622. <span class="operation-text">{{ $t("remote.C31") }}</span>
  623. </div>
  624. </div>
  625. <!-- 支付配置 -->
  626. <div
  627. v-if="
  628. device.machineType === '0' &&
  629. (user.type == 0 || user.ifForeign === '1') &&
  630. controlList.includes('C32')
  631. "
  632. class="operation-item"
  633. @click="payInfoClk()"
  634. >
  635. <div class="icon-wrapper">
  636. <img
  637. class="operation-icon"
  638. src="../../assets/device/operIcon/payInfo.png"
  639. alt="payInfo"
  640. />
  641. </div>
  642. <div class="text-wrapper">
  643. <span class="operation-text">{{ $t("remote.C32") }}</span>
  644. </div>
  645. </div>
  646. </div>
  647. </van-dialog>
  648. <van-dialog
  649. close-on-click-overlay
  650. v-model:show="operCheckShow"
  651. :title="$t('device.operationConfirmation')"
  652. :message="$t('device.pleaseConfirmAgainWhetherToOperate')"
  653. show-cancel-button
  654. @confirm="operCheck()"
  655. >
  656. </van-dialog>
  657. </template>
  658. <script>
  659. import { onMounted, ref, onBeforeUnmount } from "vue";
  660. import {
  661. setFurnace,
  662. sleepEquipment,
  663. // openDoor,
  664. Api_openDoor,
  665. deviceTuoji,
  666. delOneDevice,
  667. enableMaterial,
  668. updateLockStatus,
  669. restartScreen,
  670. machineReset,
  671. changeWorkingMode,
  672. } from "../../service/device";
  673. import { showFailToast, showSuccessToast } from "vant";
  674. import { useRouter } from "vue-router";
  675. import { useI18n } from "vue-i18n";
  676. import { getLoginUser } from "@/common/js/utils";
  677. export default {
  678. emits: ["operfinish"],
  679. components: {},
  680. setup(props, { emit }) {
  681. const isMobile = ref(false);
  682. // 检测屏幕尺寸
  683. const checkMobile = () => {
  684. isMobile.value = window.innerWidth < 768;
  685. };
  686. // 点击修改价格
  687. const modifyPriceClk = () => {
  688. router.push({
  689. path: "modifyPrice",
  690. query: { deviceId: device.value.id, name: device.value.name },
  691. });
  692. };
  693. // 点击支付方式
  694. const paymentClk = () => {
  695. router.push({
  696. path: "payment",
  697. query: {
  698. deviceId: device.value.id,
  699. name: device.value.name,
  700. payment: device.value.paymentType,
  701. },
  702. });
  703. };
  704. // 点击屏蔽/展示商品
  705. const showGoodsClk = () => {
  706. router.push({
  707. path: "showGoods",
  708. query: {
  709. deviceId: device.value.id,
  710. name: device.value.name,
  711. machineType: device.value.machineType,
  712. },
  713. });
  714. };
  715. // 点击DIY花型
  716. const diyFlowerClk = () => {
  717. router.push({
  718. path: "diyFlower",
  719. query: {
  720. deviceId: device.value.id,
  721. name: device.value.name,
  722. diyFlowerStatus: device.value.diyFlowerStatus,
  723. flower: device.value.flowers,
  724. clientId: device.value.clientId,
  725. },
  726. });
  727. };
  728. // 点击设备清洗提醒
  729. const alramCleanClk = () => {
  730. router.push({
  731. path: "alramClean",
  732. query: {
  733. deviceId: device.value.id,
  734. name: device.value.name,
  735. clientId: device.value.clientId,
  736. cleanFunction: device.value.cleanFunction,
  737. },
  738. });
  739. };
  740. // 点击远程退币
  741. const returnCoinClk = () => {
  742. router.push({
  743. path: "returnCoin",
  744. query: {
  745. deviceId: device.value.id,
  746. name: device.value.name,
  747. clientId: device.value.clientId,
  748. },
  749. });
  750. };
  751. // 点击税收管理
  752. const taxClk = () => {
  753. router.push({
  754. path: "tax",
  755. query: {
  756. deviceId: device.value.id,
  757. name: device.value.name,
  758. clientId: device.value.clientId,
  759. },
  760. });
  761. };
  762. // 果酱抽取
  763. const jamClk = () => {
  764. router.push({
  765. path: "jam",
  766. query: {
  767. deviceId: device.value.id,
  768. name: device.value.name,
  769. clientId: device.value.clientId,
  770. },
  771. });
  772. };
  773. // 维护记录
  774. const maintenanceClk = () => {
  775. router.push({
  776. path: "maintenance",
  777. query: {
  778. deviceId: device.value.id,
  779. name: device.value.name,
  780. clientId: device.value.clientId,
  781. },
  782. });
  783. };
  784. // 点击支付配置
  785. const payInfoClk = () => {
  786. router.push({
  787. path: "payInfo",
  788. query: {
  789. deviceId: device.value.id,
  790. name: device.value.name,
  791. clientId: device.value.clientId,
  792. },
  793. });
  794. };
  795. const { t } = useI18n();
  796. const user = getLoginUser();
  797. const router = useRouter();
  798. const show = ref(false);
  799. const operCheckShow = ref(false);
  800. const device = ref({});
  801. const operType = ref("");
  802. // 睡眠按钮文字
  803. const sleepTitle = ref(t("device.turnOnSleep"));
  804. // 物料监控按钮文字
  805. const materialTitle = ref(t("device.materialMonitorOn"));
  806. // 睡眠图标
  807. const sleepIcon = ref("0");
  808. // 物料监控图标
  809. const materialIcon = ref("0");
  810. // 工作模式
  811. const workMode = ref(null);
  812. // 操作权限
  813. const controlList = ref([]);
  814. // 初始化页面获取列表
  815. onMounted(async () => {
  816. // 加载样式
  817. // styleUrl('deviceOper');
  818. checkMobile();
  819. window.addEventListener("resize", checkMobile);
  820. });
  821. onBeforeUnmount(() => {
  822. window.removeEventListener("resize", checkMobile);
  823. });
  824. // 当前弹窗父组件触发
  825. const showOper = (e, value) => {
  826. controlList.value = value;
  827. device.value = e;
  828. show.value = true;
  829. // isSleep=true,机器处于睡眠状态,按钮是关闭睡眠
  830. if (device.value.isSleep) {
  831. sleepTitle.value = t("device.turnOffSleep");
  832. sleepIcon.value = "1";
  833. } else {
  834. sleepTitle.value = t("device.turnOnSleep");
  835. sleepIcon.value = "0";
  836. }
  837. // 物料监控
  838. // isMaterialUse = "1"时,物料监控已开启
  839. if (device.value.isMaterialUse === "1") {
  840. materialTitle.value = t("device.materialMonitorOn");
  841. materialIcon.value = "0";
  842. } else {
  843. materialTitle.value = t("device.materialMonitorOff");
  844. materialIcon.value = "1";
  845. }
  846. };
  847. const closeOper = () => {
  848. show.value = false;
  849. };
  850. // 重启炉头
  851. const restartFurnace = () => {
  852. operType.value = 1;
  853. operCheckShow.value = true;
  854. };
  855. // 睡眠
  856. const sleepEquipmentFun = () => {
  857. operType.value = 2;
  858. operCheckShow.value = true;
  859. };
  860. // 点击的是开启炉头还是关闭 1开启 0关闭
  861. const clkOpenOrClose = ref(1);
  862. // 开启关闭炉头
  863. const openOffFurnace = (idx) => {
  864. clkOpenOrClose.value = idx;
  865. operType.value = 3;
  866. operCheckShow.value = true;
  867. };
  868. // 远程开门
  869. /* const openDoorFun = () => {
  870. operType.value = 4;
  871. operCheckShow.value = true;
  872. }; */
  873. const openDoorFun = () => {
  874. if (device.value.machineType === "2") {
  875. operType.value = 4;
  876. operCheckShow.value = true;
  877. } else {
  878. // router.push({ path: "openDoor", query: { deviceId: device.value.id } });
  879. router.push({
  880. path: "openDoor",
  881. query: {
  882. deviceId: device.value.id,
  883. machineType: device.value.machineType,
  884. },
  885. });
  886. }
  887. };
  888. // 日志功能
  889. const viewLogs = () => {
  890. router.push({
  891. path: "viewLogs",
  892. query: { deviceId: device.value.id, name: device.value.name },
  893. });
  894. };
  895. // 定制logo
  896. const customLogo = () => {
  897. router.push({ path: "customLogo", query: { deviceId: device.value.id } });
  898. };
  899. // 音量调节
  900. const modulation = () => {
  901. router.push({
  902. path: "modulation",
  903. query: { deviceId: device.value.id, name: device.value.name },
  904. });
  905. };
  906. // 远程做糖
  907. const doSugar = () => {
  908. router.push({
  909. path: "doSugar",
  910. query: {
  911. deviceId: device.value.id,
  912. machineType: device.value.machineType,
  913. },
  914. });
  915. };
  916. // 定时开关
  917. const alarmClock = () => {
  918. router.push({ path: "alarmClock", query: { deviceId: device.value.id } });
  919. };
  920. // 跳转 - 设备充值
  921. const recharge = () => {
  922. router.push({ path: "recharge", query: { deviceId: device.value.id } });
  923. };
  924. // 跳转 - 参数设置
  925. const paramSetPush = () => {
  926. router.push({
  927. path: "paramsSet",
  928. query: {
  929. deviceId: device.value.id,
  930. machineType: device.value.machineType,
  931. name: device.value.name,
  932. },
  933. });
  934. };
  935. // 跳转 - 添加分销人
  936. const saveProportionPush = () => {
  937. router.push({
  938. path: "distributionDetail",
  939. query: { deviceId: device.value.id, clientId: device.value.clientId },
  940. });
  941. };
  942. // 系统脱机
  943. const tuojiEquipmentFun = () => {
  944. operType.value = 5;
  945. operCheckShow.value = true;
  946. };
  947. // 修改机器密码
  948. const changePasswordClk = () => {
  949. router.push({
  950. path: "devicePassword",
  951. query: { deviceId: device.value.id, name: device.value.name },
  952. });
  953. };
  954. // 删除设备
  955. const deleteDevice = () => {
  956. operType.value = 6;
  957. operCheckShow.value = true;
  958. };
  959. // 物料监控
  960. const materialMonitorClk = () => {
  961. operType.value = 7;
  962. operCheckShow.value = true;
  963. };
  964. // 远程锁机
  965. const lockDevice = () => {
  966. operType.value = 8;
  967. operCheckShow.value = true;
  968. };
  969. // 重启触摸屏
  970. const restartAndroid = () => {
  971. operType.value = 9;
  972. operCheckShow.value = true;
  973. };
  974. // 切换工作模式
  975. const updateWorkingMode = (value) => {
  976. workMode.value = value;
  977. operType.value = 10;
  978. operCheckShow.value = true;
  979. };
  980. // 取消操作
  981. const operCheckClear = () => {
  982. operCheckShow.value = false;
  983. };
  984. // 功能操作 - 确认操作
  985. const operCheck = async () => {
  986. // 重启
  987. if (operType.value === 1) {
  988. if (device.value.machineType === "2") {
  989. const { data } = await machineReset({
  990. equipmentId: device.value.id,
  991. });
  992. if (data.code) {
  993. showSuccessToast(t("device.enableMaterialSucceed"));
  994. operCheckShow.value = false;
  995. } else {
  996. showFailToast(data.message);
  997. }
  998. } else {
  999. const { data } = await setFurnace({
  1000. equipmentId: device.value.id,
  1001. eqeStatus: 1,
  1002. });
  1003. if (data.code) {
  1004. showSuccessToast(t("device.restartSucceeded"));
  1005. operCheckShow.value = false;
  1006. } else {
  1007. showFailToast(data.message);
  1008. }
  1009. }
  1010. }
  1011. // 睡眠
  1012. if (operType.value === 2) {
  1013. const { data } = await sleepEquipment({
  1014. equipmentId: device.value.id,
  1015. eqeStatus: device.value.isSleep ? "0" : "1",
  1016. });
  1017. if (data.code) {
  1018. showSuccessToast(t("device.sleepSuccessfully"));
  1019. operCheckShow.value = false;
  1020. } else {
  1021. showFailToast(data.message);
  1022. }
  1023. }
  1024. // 开机|关机
  1025. if (operType.value === 3) {
  1026. device.value.eqeStatus = clkOpenOrClose.value;
  1027. const { data } = await setFurnace({
  1028. equipmentId: device.value.id,
  1029. eqeStatus: device.value.eqeStatus,
  1030. });
  1031. if (data.code) {
  1032. showSuccessToast(
  1033. `${
  1034. device.value.eqeStatus === 0
  1035. ? t("device.close")
  1036. : t("device.open")
  1037. }${t("device.success")}`
  1038. );
  1039. device.value.eqeStatus = device.value.eqeStatus === 0 ? 1 : 0;
  1040. operCheckShow.value = false;
  1041. } else {
  1042. showFailToast(data.message);
  1043. }
  1044. }
  1045. // 远程开门
  1046. if (operType.value === 4) {
  1047. const { data } = await Api_openDoor({
  1048. equipmentId: device.value.id,
  1049. type: 0,
  1050. status: 1,
  1051. });
  1052. if (data.code) {
  1053. showSuccessToast(t("device.remoteDoorOpeningSucceeded"));
  1054. operCheckShow.value = false;
  1055. } else {
  1056. showFailToast(data.message);
  1057. }
  1058. }
  1059. // 系统脱机
  1060. if (operType.value === 5) {
  1061. const { data } = await deviceTuoji({
  1062. id: device.value.id,
  1063. clientId: device.value.clientId,
  1064. adminUserName: user.username,
  1065. });
  1066. if (data.code) {
  1067. showSuccessToast(t("device.sysOffSuccess"));
  1068. operCheckShow.value = false;
  1069. } else {
  1070. showFailToast(data.message);
  1071. }
  1072. }
  1073. // 删除设备
  1074. if (operType.value === 6) {
  1075. const { data } = await delOneDevice({
  1076. equipmentId: device.value.id,
  1077. adminId: user.id,
  1078. });
  1079. if (data.code) {
  1080. showSuccessToast(t("device.deleteDeviceSucceed"));
  1081. operCheckShow.value = false;
  1082. } else {
  1083. showFailToast(t("device.deleteDeviceFailed"));
  1084. }
  1085. }
  1086. // 启用物料监控
  1087. if (operType.value === 7) {
  1088. let materialMonitorStatus = 0; // 0默认是未开启
  1089. // isMaterialUse是1时,物料监控已启用,按钮是关闭功能
  1090. if (device.value.isMaterialUse === "1") {
  1091. materialMonitorStatus = 1; // 1代表已开启
  1092. }
  1093. const { data } = await enableMaterial({
  1094. equipmentId: device.value.id,
  1095. materialMonitorStatus,
  1096. });
  1097. if (data.code === "00000") {
  1098. showSuccessToast(t("device.enableMaterialSucceed"));
  1099. operCheckShow.value = false;
  1100. } else {
  1101. showFailToast(t("device.enableMaterialFailed"));
  1102. }
  1103. }
  1104. // 远程锁机
  1105. if (operType.value === 8) {
  1106. const { data } = await updateLockStatus({
  1107. equipmentId: device.value.id,
  1108. status: device.value.isBlocked ? "0" : "1",
  1109. });
  1110. if (data.code === "00000") {
  1111. showSuccessToast(t("device.Succeed"));
  1112. operCheckShow.value = false;
  1113. } else {
  1114. showFailToast(t("device.Failed"));
  1115. }
  1116. }
  1117. // 重启触摸屏
  1118. if (operType.value === 9) {
  1119. const { data } = await restartScreen({
  1120. equipmentId: device.value.id,
  1121. });
  1122. if (data.code === "00000") {
  1123. showSuccessToast(t("device.Succeed"));
  1124. operCheckShow.value = false;
  1125. } else {
  1126. showFailToast(t("device.Failed"));
  1127. }
  1128. }
  1129. // 切换工作模式
  1130. if (operType.value === 10) {
  1131. const { data } = await changeWorkingMode({
  1132. equipmentId: device.value.id,
  1133. workingMode: workMode.value,
  1134. });
  1135. if (data.code === "00000") {
  1136. showSuccessToast(t("device.Succeed"));
  1137. operCheckShow.value = false;
  1138. } else {
  1139. showFailToast(t("device.Failed"));
  1140. }
  1141. }
  1142. setTimeout(() => {
  1143. // 关闭弹窗
  1144. show.value = false;
  1145. // 触发操作完成回调
  1146. emit("operfinish", true);
  1147. }, 2000);
  1148. };
  1149. const isRole = (key) => {
  1150. return user.menuCodeList.filter((type) => key === type).length > 0;
  1151. };
  1152. return {
  1153. user,
  1154. device,
  1155. show,
  1156. operCheckShow,
  1157. showOper,
  1158. closeOper,
  1159. restartFurnace,
  1160. operCheckClear,
  1161. operCheck,
  1162. sleepEquipmentFun,
  1163. openOffFurnace,
  1164. openDoorFun,
  1165. modulation,
  1166. customLogo,
  1167. doSugar,
  1168. alarmClock,
  1169. recharge,
  1170. paramSetPush,
  1171. saveProportionPush,
  1172. tuojiEquipmentFun,
  1173. isRole,
  1174. modifyPriceClk,
  1175. showGoodsClk,
  1176. diyFlowerClk,
  1177. sleepTitle,
  1178. materialTitle,
  1179. viewLogs,
  1180. deleteDevice,
  1181. lockDevice,
  1182. restartAndroid,
  1183. alramCleanClk,
  1184. returnCoinClk,
  1185. taxClk,
  1186. jamClk,
  1187. maintenanceClk,
  1188. payInfoClk,
  1189. changePasswordClk,
  1190. sleepIcon,
  1191. materialIcon,
  1192. materialMonitorClk,
  1193. updateWorkingMode,
  1194. controlList,
  1195. isMobile,
  1196. paymentClk,
  1197. };
  1198. },
  1199. };
  1200. </script>
  1201. <style lang="less" scoped>
  1202. @import "../../common/style/common";
  1203. .operation-dialog {
  1204. border-radius: 12px;
  1205. overflow: hidden;
  1206. .dialog-header {
  1207. padding: 16px 24px;
  1208. background: #f8f9fa;
  1209. position: relative;
  1210. .dialog-title {
  1211. margin: 0;
  1212. font-size: 18px;
  1213. color: #1a1a1a;
  1214. font-weight: 500;
  1215. }
  1216. .close-icon {
  1217. position: absolute;
  1218. right: 16px;
  1219. top: 50%;
  1220. transform: translateY(-50%);
  1221. font-size: 20px;
  1222. color: #666;
  1223. padding: 8px;
  1224. border-radius: 50%;
  1225. transition: background 0.2s;
  1226. &:active {
  1227. background: #e8e8e8;
  1228. }
  1229. }
  1230. }
  1231. .device-info {
  1232. padding: 12px 24px;
  1233. border-bottom: 1px solid #eee;
  1234. .info-item {
  1235. display: flex;
  1236. align-items: center;
  1237. margin: 8px 0;
  1238. font-size: 14px;
  1239. .info-label {
  1240. color: #666;
  1241. margin-right: 8px;
  1242. flex-shrink: 0;
  1243. }
  1244. .info-value {
  1245. color: #333;
  1246. font-weight: 500;
  1247. .text-ellipsis();
  1248. }
  1249. }
  1250. }
  1251. .operation-grid {
  1252. display: grid;
  1253. grid-template-columns: repeat(4, 1fr);
  1254. gap: 12px;
  1255. padding: 10px;
  1256. max-height: 60vh;
  1257. overflow-y: auto;
  1258. overflow-x: hidden;
  1259. @media (max-width: 480px) {
  1260. grid-template-columns: repeat(3, 1fr);
  1261. /* 移动端2列 */
  1262. }
  1263. .operation-item {
  1264. display: flex;
  1265. flex-direction: column;
  1266. align-items: center;
  1267. padding: 8px;
  1268. position: relative;
  1269. .icon-wrapper {
  1270. width: 35px;
  1271. height: 35px;
  1272. margin-bottom: 6px;
  1273. display: flex;
  1274. align-items: center;
  1275. justify-content: center;
  1276. }
  1277. .operation-icon {
  1278. max-width: 100%;
  1279. max-height: 100%;
  1280. object-fit: contain;
  1281. }
  1282. .text-wrapper {
  1283. width: 100%;
  1284. min-height: 36px;
  1285. /* 固定文字容器高度 */
  1286. display: flex;
  1287. align-items: center;
  1288. justify-content: center;
  1289. text-align: center;
  1290. position: relative;
  1291. }
  1292. .operation-text {
  1293. font-size: 10px;
  1294. line-height: 1.4;
  1295. color: #333;
  1296. display: -webkit-box;
  1297. -webkit-line-clamp: 2;
  1298. /* 最多显示两行 */
  1299. -webkit-box-orient: vertical;
  1300. overflow: hidden;
  1301. text-overflow: ellipsis;
  1302. padding: 0 4px;
  1303. max-width: 100%;
  1304. /* 备用方案 */
  1305. @supports not (-webkit-line-clamp: 2) {
  1306. white-space: nowrap;
  1307. overflow: hidden;
  1308. text-overflow: ellipsis;
  1309. }
  1310. }
  1311. /* 悬浮提示 */
  1312. &:hover .text-tooltip {
  1313. visibility: visible;
  1314. opacity: 1;
  1315. }
  1316. .text-tooltip {
  1317. position: absolute;
  1318. bottom: 100%;
  1319. left: 50%;
  1320. transform: translateX(-50%);
  1321. background: rgba(0, 0, 0, 0.8);
  1322. color: white;
  1323. padding: 6px 12px;
  1324. border-radius: 4px;
  1325. font-size: 12px;
  1326. white-space: nowrap;
  1327. visibility: hidden;
  1328. opacity: 0;
  1329. transition: opacity 0.2s;
  1330. z-index: 100;
  1331. &::after {
  1332. content: "";
  1333. position: absolute;
  1334. top: 100%;
  1335. left: 50%;
  1336. margin-left: -4px;
  1337. border-width: 4px;
  1338. border-style: solid;
  1339. border-color: rgba(0, 0, 0, 0.8) transparent transparent;
  1340. }
  1341. }
  1342. }
  1343. }
  1344. }
  1345. // 文字截断混入
  1346. .text-ellipsis() {
  1347. overflow: hidden;
  1348. text-overflow: ellipsis;
  1349. white-space: nowrap;
  1350. }
  1351. /* 移动端适配 */
  1352. @media (max-width: 480px) {
  1353. .operation-item {
  1354. .text-wrapper {
  1355. min-height: 32px;
  1356. }
  1357. .operation-text {
  1358. font-size: 10px;
  1359. }
  1360. }
  1361. }
  1362. </style>