deviceOper.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <!-- 设备常见操作弹窗 -->
  3. <van-dialog class-name="operDialog" width="auto" v-model:show="show" :showConfirmButton="false"
  4. :showCancelButton="false">
  5. <slot name="title">
  6. <div class="van-dialog__header">{{ $t("device.commonOperations") }}</div>
  7. <div class="txt1" style="padding: 0.2em 1em">
  8. {{ $t("device.equipmentName") }}: {{ device.name != null ? device.name : $t("device.equipmentNameTips") }}
  9. </div>
  10. <div class="txt1" style="padding: 0.2em 1em">
  11. {{ $t("device.equipmentNo") }}: {{ device.clientId }}
  12. </div>
  13. </slot>
  14. <van-icon name="cross" class="close" @click="show = false" />
  15. <div class="group4 flex-col"></div>
  16. <div class="operBox">
  17. <!-- 重启炉头 -->
  18. <div class="operItem" @click="restartFurnace()">
  19. <div class="operIcon">
  20. <img class="operImg" src="../../assets/device/operIcon/restart.png" />
  21. </div>
  22. <div v-if="device.machineType === '1'" class="operText">{{ $t("device.restart") }}</div>
  23. <div v-else class="operText">{{ $t("device.restartFurnaceHead") }}</div>
  24. </div>
  25. <!-- 睡眠 -->
  26. <div class="operItem" @click="sleepEquipmentFun()">
  27. <div class="operIcon">
  28. <img class="operImg" src="../../assets/device/operIcon/sleep.png" />
  29. </div>
  30. <div class="operText">{{ sleepTitle }}</div>
  31. </div>
  32. <div class="operItem" @click="openOffFurnace(1)">
  33. <div class="operIcon">
  34. <img class="operImg" src="../../assets/device/operIcon/onOff.png" />
  35. </div>
  36. <div v-if="device.machineType === '1'" class="operText">{{ $t("device.openDevice") }}</div>
  37. <div v-else class="operText">{{ $t("device.openFurnHead") }}</div>
  38. </div>
  39. <div class="operItem" @click="openOffFurnace(0)">
  40. <div class="operIcon">
  41. <img class="operImg" src="../../assets/device/operIcon/onOff.png" />
  42. </div>
  43. <div v-if="device.machineType === '1'" class="operText">{{ $t("device.closeDevice") }}</div>
  44. <div v-else class="operText">{{ $t("device.closeFurnHead") }}</div>
  45. </div>
  46. <!-- <div class="operItem" @click="openDoorFun()">
  47. <div class="operIcon">
  48. <img
  49. class="operImg"
  50. src="../../assets/device/operIcon/openDoor.png"
  51. />
  52. </div>
  53. <div class="operText">{{ $t("device.remoteDoorOpening") }}</div>
  54. </div> -->
  55. <div class="operItem" @click="openDoorFun()">
  56. <div class="operIcon">
  57. <img class="operImg" src="../../assets/device/operIcon/openDoor.png" />
  58. </div>
  59. <div class="operText">{{ $t("device.remoteDoorOpening") }}</div>
  60. </div>
  61. <div class="operItem" @click="doSugar()">
  62. <div class="operIcon">
  63. <img class="operImg" src="../../assets/device/operIcon/doSugar.png" />
  64. </div>
  65. <div v-if="device.machineType === '1'" class="operText">{{ $t("device.remoteProduction") }}</div>
  66. <div v-else class="operText">{{ $t("device.remoteSugarMaking") }}</div>
  67. </div>
  68. <div class="operItem" @click="alarmClock()">
  69. <div class="operIcon">
  70. <img class="operImg" src="../../assets/device/operIcon/alarmClock.png" />
  71. </div>
  72. <div class="operText">{{ $t("device.timeSwitch") }}</div>
  73. </div>
  74. <div class="operItem" @click="modulation()">
  75. <div class="operIcon">
  76. <img class="operImg" src="../../assets/device/operIcon/modulation.png" />
  77. </div>
  78. <div class="operText">{{ $t("device.modulation") }}</div>
  79. </div>
  80. <!-- <div v-if="user.ifForeign == '0'" class="operItem" @click="recharge()">
  81. <div class="operIcon">
  82. <img class="operImg" src="../../assets/device/operIcon/recharge.png" />
  83. </div>
  84. <div class="operText">{{ $t("device.equipmentRecharge") }}</div>
  85. </div> -->
  86. <div class="operItem" @click="paramSetPush()">
  87. <div class="operIcon">
  88. <img class="operImg" src="../../assets/device/operIcon/paramsSet.png" />
  89. </div>
  90. <div class="operText">{{ $t("device.parameterSetting") }}</div>
  91. </div>
  92. <div v-if="user.ifForeign == '0'" class="operItem" @click="saveProportionPush()">
  93. <div class="operIcon">
  94. <img class="operImg" src="../../assets/device/operIcon/saveProportion.png" />
  95. </div>
  96. <div class="operText">{{ $t("device.addDistributor") }}</div>
  97. </div>
  98. <div v-if="isRole('M17')" class="operItem" @click="tuojiEquipmentFun()">
  99. <div class="operIcon">
  100. <img class="operImg" src="../../assets/device/operIcon/tuoji.png" />
  101. </div>
  102. <div class="operText">{{ $t("device.sysOffline") }}</div>
  103. </div>
  104. <div class="operItem" @click="modifyPriceClk()">
  105. <div class="operIcon">
  106. <img class="operImg" src="../../assets/device/operIcon/editPrice.png" />
  107. </div>
  108. <div class="operText">{{ $t("device.modifyPrice") }}</div>
  109. </div>
  110. <!-- 物料监控 -->
  111. <div class="operItem" @click="materialMonitorClk()">
  112. <div class="operIcon">
  113. <img class="operImg" src="../../assets/device/operIcon/materialMonitor.png" />
  114. </div>
  115. <div class="operText">{{ $t("device.materialMonitor") }}</div>
  116. </div>
  117. <!-- 屏蔽/展示商品 -->
  118. <div class="operItem" @click="showGoodsClk()">
  119. <div class="operIcon">
  120. <img class="operImg" src="../../assets/device/operIcon/showGoods.png" />
  121. </div>
  122. <div class="operText">{{ $t("device.showGoods") }}</div>
  123. </div>
  124. <!-- DIY花型 -->
  125. <!-- v-if="device.equimentType == 'MG320' || device.equimentType == 'MG330'" -->
  126. <div class="operItem" v-if="user.type < 1" @click="diyFlowerClk()">
  127. <div class="operIcon">
  128. <img class="operImg" src="../../assets/device/operIcon/diyFlower.png" />
  129. </div>
  130. <div class="operText">{{ $t("device.diyFlower") }}</div>
  131. </div>
  132. <!-- 修改机器密码 -->
  133. <div v-if="user.type < 3" class="operItem" @click="changePasswordClk()">
  134. <div class="operIcon">
  135. <img class="operImg" src="../../assets/device/operIcon/password.png" />
  136. </div>
  137. <div class="operText">{{ $t("device.changePassword") }}</div>
  138. </div>
  139. <!-- 删除设备 -->
  140. <div v-if="user.type < 2" class="operItem" @click="deleteDevice()">
  141. <div class="operIcon">
  142. <img class="operImg" src="../../assets/device/operIcon/deletedevice.png" />
  143. </div>
  144. <div class="operText">{{ $t("device.deleteDevice") }}</div>
  145. </div>
  146. <!-- 日志功能 -->
  147. <div v-if="user.type < 2" class="operItem" @click="viewLogs()">
  148. <div class="operIcon">
  149. <img class="operImg" src="../../assets/device/operIcon/viewLogs.png" />
  150. </div>
  151. <div class="operText">{{ $t("device.viewLogs") }}</div>
  152. </div>
  153. <!-- 定制logo -->
  154. <div v-if="user.type < 2" class="operItem" @click="customLogo()">
  155. <div class="operIcon">
  156. <img class="operImg" src="../../assets/device/operIcon/customLogo.png" />
  157. </div>
  158. <div class="operText">{{ $t("device.customLogo.customLogo") }}</div>
  159. </div>
  160. <!-- 查看定位 -->
  161. <!-- <div class="operItem" @click="viewPosiClk()">
  162. <div class="operIcon">
  163. <img class="operImg" src="../../assets/device/operIcon/location.png" />
  164. </div>
  165. <div class="operText">{{ $t("device.viewPositioning") }}</div>
  166. </div> -->
  167. </div>
  168. </van-dialog>
  169. <van-dialog v-model:show="operCheckShow" :title="$t('device.operationConfirmation')" :showConfirmButton="false"
  170. :showCancelButton="false">
  171. <div class="operCheckBox">
  172. <div class="block5 flex-col"></div>
  173. <span class="word10">{{
  174. $t("device.pleaseConfirmAgainWhetherToOperate")
  175. }}</span>
  176. <div class="block6 flex-row justify-between">
  177. <div class="mod7 flex-col" @click="operCheckClear()">
  178. <span class="info5">{{ $t("device.IllThinkAboutItAgain") }}</span>
  179. </div>
  180. <div class="mod8 flex-col" @click="operCheck()">
  181. <span class="info6">{{ $t("device.confirm") }}</span>
  182. </div>
  183. </div>
  184. </div>
  185. </van-dialog>
  186. </template>
  187. <script>
  188. import { onMounted, ref } from "vue";
  189. import {
  190. setFurnace,
  191. sleepEquipment,
  192. openDoor,
  193. deviceTuoji,
  194. delOneDevice,
  195. enableMaterial
  196. } from "../../service/device";
  197. import { showFailToast, showSuccessToast } from "vant";
  198. import { useRouter } from "vue-router";
  199. import { useI18n } from "vue-i18n";
  200. import { getLoginUser, styleUrl } from "@/common/js/utils";
  201. export default {
  202. emits: ['operfinish'],
  203. setup(props, { emit }) {
  204. // 点击修改价格
  205. const modifyPriceClk = () => {
  206. router.push({
  207. path: "modifyPrice",
  208. query: { deviceId: device.value.id, name: device.value.name },
  209. });
  210. };
  211. // 点击屏蔽/展示商品
  212. const showGoodsClk = () => {
  213. router.push({
  214. path: "showGoods",
  215. query: { deviceId: device.value.id, name: device.value.name },
  216. });
  217. };
  218. // 点击DIY花型
  219. const diyFlowerClk = () => {
  220. router.push({
  221. path: "diyFlower",
  222. query: { deviceId: device.value.id, name: device.value.name, diyFlowerStatus: device.value.diyFlowerStatus, flower: device.value.flowers },
  223. });
  224. };
  225. const { t } = useI18n();
  226. const user = getLoginUser();
  227. const router = useRouter();
  228. const show = ref(false);
  229. const operCheckShow = ref(false);
  230. const device = ref({});
  231. const operType = ref("");
  232. // 休眠按钮
  233. const sleepTitle = ref(t("device.turnOnSleep"));
  234. // 初始化页面获取列表
  235. onMounted(async () => {
  236. // 加载样式
  237. styleUrl('deviceOper');
  238. });
  239. // 当前弹窗父组件触发
  240. const showOper = (e) => {
  241. device.value = e;
  242. show.value = true;
  243. // isSleep=true,机器属于休眠状态,按钮是关闭休眠
  244. if (device.value.isSleep) {
  245. sleepTitle.value = t("device.turnOffSleep");
  246. } else {
  247. sleepTitle.value = t("device.turnOnSleep");
  248. }
  249. };
  250. const closeOper = () => {
  251. show.value = false;
  252. }
  253. // 重启炉头
  254. const restartFurnace = () => {
  255. operType.value = 1;
  256. operCheckShow.value = true;
  257. };
  258. // 睡眠
  259. const sleepEquipmentFun = () => {
  260. operType.value = 2;
  261. operCheckShow.value = true;
  262. };
  263. // 点击的是开启炉头还是关闭 1开启 0关闭
  264. const clkOpenOrClose = ref(1);
  265. // 开启关闭炉头
  266. const openOffFurnace = (idx) => {
  267. clkOpenOrClose.value = idx;
  268. operType.value = 3;
  269. operCheckShow.value = true;
  270. };
  271. // 远程开门
  272. /* const openDoorFun = () => {
  273. operType.value = 4;
  274. operCheckShow.value = true;
  275. }; */
  276. const openDoorFun = () => {
  277. if (device.value.machineType === '1' || device.value.equimentType === 'MG280') {
  278. operType.value = 4;
  279. operCheckShow.value = true;
  280. } else {
  281. router.push({ path: "openDoor", query: { deviceId: device.value.id } });
  282. }
  283. };
  284. // 日志功能
  285. const viewLogs = () => {
  286. router.push({ path: "viewLogs", query: { deviceId: device.value.id } });
  287. };
  288. // 定制logo
  289. const customLogo = () => {
  290. router.push({ path: "customLogo", query: { deviceId: device.value.id } });
  291. }
  292. // 音量调节
  293. const modulation = () => {
  294. router.push({ path: "modulation", query: { deviceId: device.value.id } });
  295. };
  296. // 远程做糖
  297. const doSugar = () => {
  298. router.push({ path: "doSugar", query: { deviceId: device.value.id, machineType: device.value.machineType } });
  299. };
  300. // 定时开关
  301. const alarmClock = () => {
  302. router.push({ path: "alarmClock", query: { deviceId: device.value.id } });
  303. };
  304. // 跳转 - 设备充值
  305. const recharge = () => {
  306. router.push({ path: "recharge", query: { deviceId: device.value.id } });
  307. };
  308. // 跳转 - 参数设置
  309. const paramSetPush = () => {
  310. router.push({ path: "paramsSet", query: { deviceId: device.value.id } });
  311. };
  312. // 物料监控
  313. const materialMonitorClk = () => {
  314. operType.value = 7;
  315. operCheckShow.value = true;
  316. };
  317. // 跳转 - 添加分销人
  318. const saveProportionPush = () => {
  319. router.push({
  320. path: "distributionDetail",
  321. query: { deviceId: device.value.id, clientId: device.value.clientId },
  322. });
  323. };
  324. // 系统脱机✓
  325. const tuojiEquipmentFun = () => {
  326. operType.value = 5;
  327. operCheckShow.value = true;
  328. };
  329. // 修改机器密码
  330. const changePasswordClk = () => {
  331. router.push({
  332. path: "devicePassword",
  333. query: { deviceId: device.value.id, name: device.value.name },
  334. });
  335. };
  336. const deleteDevice = () => {
  337. operType.value = 6;
  338. operCheckShow.value = true;
  339. };
  340. // 取消操作
  341. const operCheckClear = () => {
  342. operCheckShow.value = false;
  343. };
  344. // 功能操作 - 确认操作
  345. const operCheck = async () => {
  346. // 重启
  347. if (operType.value === 1) {
  348. const { data } = await setFurnace({
  349. equipmentId: device.value.id,
  350. eqeStatus: 1,
  351. });
  352. if (data.code) {
  353. showSuccessToast(t("device.restartSucceeded"));
  354. operCheckShow.value = false;
  355. } else {
  356. showFailToast(data.message);
  357. }
  358. }
  359. // 睡眠
  360. if (operType.value === 2) {
  361. let eqeStatus = 1;
  362. // isSleep=true,机器属于休眠状态,按钮是关闭休眠
  363. if (device.value.isSleep) {
  364. eqeStatus = 0;
  365. }
  366. const { data } = await sleepEquipment({
  367. equipmentId: device.value.id,
  368. eqeStatus,
  369. });
  370. if (data.code) {
  371. showSuccessToast(t("device.sleepSuccessfully"));
  372. operCheckShow.value = false;
  373. } else {
  374. showFailToast(data.message);
  375. }
  376. }
  377. // 开机|关机
  378. if (operType.value === 3) {
  379. device.value.eqeStatus = clkOpenOrClose.value;
  380. const { data } = await setFurnace({
  381. equipmentId: device.value.id,
  382. eqeStatus: device.value.eqeStatus,
  383. });
  384. if (data.code) {
  385. showSuccessToast(
  386. `${device.value.eqeStatus === 0
  387. ? t("device.close")
  388. : t("device.open")
  389. }${t("device.success")}`
  390. );
  391. device.value.eqeStatus = device.value.eqeStatus === 0 ? 1 : 0;
  392. operCheckShow.value = false;
  393. } else {
  394. showFailToast(data.message);
  395. }
  396. }
  397. // 远程开门
  398. if (operType.value === 4) {
  399. const { data } = await openDoor({ equipmentId: device.value.id });
  400. if (data.code) {
  401. showSuccessToast(t("device.remoteDoorOpeningSucceeded"));
  402. operCheckShow.value = false;
  403. } else {
  404. showFailToast(data.message);
  405. }
  406. }
  407. // 系统脱机
  408. if (operType.value === 5) {
  409. const { data } = await deviceTuoji({ id: device.value.id, clientId: device.value.clientId, adminUserName: user.username });
  410. if (data.code) {
  411. showSuccessToast(t("device.sysOffSuccess"));
  412. operCheckShow.value = false;
  413. } else {
  414. showFailToast(data.message);
  415. }
  416. }
  417. // 删除设备✓
  418. if (operType.value === 6) {
  419. const { data } = await delOneDevice({
  420. equipmentId: device.value.id,
  421. adminId: user.id,
  422. });
  423. if (data.code) {
  424. showSuccessToast(t("device.deleteDeviceSucceed"));
  425. operCheckShow.value = false;
  426. } else {
  427. showFailToast(t("device.deleteDeviceFailed"));
  428. }
  429. }
  430. // 启用物料监控
  431. if (operType.value === 7) {
  432. const { data } = await enableMaterial({
  433. equipmentId: device.value.id,
  434. });
  435. if (data.code === '00000') {
  436. showSuccessToast(t("device.enableMaterialSucceed"));
  437. operCheckShow.value = false;
  438. } else {
  439. showFailToast(t("device.enableMaterialFailed"));
  440. }
  441. }
  442. // 关闭弹窗
  443. show.value = false;
  444. // 触发操作完成回调
  445. emit("operfinish", true);
  446. };
  447. const isRole = (key) => {
  448. return user.menuCodeList.filter((type) => key === type).length > 0;
  449. };
  450. return {
  451. user,
  452. device,
  453. show,
  454. operCheckShow,
  455. showOper,
  456. closeOper,
  457. restartFurnace,
  458. operCheckClear,
  459. operCheck,
  460. sleepEquipmentFun,
  461. openOffFurnace,
  462. openDoorFun,
  463. modulation,
  464. customLogo,
  465. doSugar,
  466. alarmClock,
  467. recharge,
  468. paramSetPush,
  469. saveProportionPush,
  470. tuojiEquipmentFun,
  471. isRole,
  472. modifyPriceClk,
  473. showGoodsClk,
  474. diyFlowerClk,
  475. sleepTitle,
  476. viewLogs,
  477. deleteDevice,
  478. changePasswordClk,
  479. materialMonitorClk
  480. };
  481. },
  482. components: {},
  483. };
  484. </script>
  485. <style lang="less" scoped>
  486. @import "../../common/style/common";
  487. </style>