index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <!-- 设备列表 -->
  3. <div class="devicePage flex-col">
  4. <s-header :name="sys ? sys.title : $t('device.managementCenter')" :noback="true"></s-header>
  5. <div class="listBox">
  6. <van-list v-model:loading="loading" v-model:error="error" :error-text="$t('public.requestFailed')"
  7. :finished="finished" :finished-text="$t('public.noMore')" offset="300" :immediate-check="false" @load="onLoad">
  8. <div class="deviceBox1 flex-col">
  9. <div class="searchRow flex-row justify-between">
  10. <div class="flex-col">
  11. <div class="flex-row justify-between bd3">
  12. <div class="flex-col outer4"></div>
  13. <span class="flex-col txt2">{{
  14. $t("device.dataOverview")
  15. }}</span>
  16. </div>
  17. </div>
  18. <div class="flex-col">
  19. <div class="main5 flex-row justify-between" @click="searchClick">
  20. <img class="label2" src="../../assets/device/searchIcon.png" />
  21. <div class="TextGroup2 flex-col">
  22. <span class="txt3">{{ $t("device.search") }}</span>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <img class="pic1" src="../../assets/device/line.png" />
  28. <div class="o-plr-15 o-ptb-20">
  29. <div class="bd1 flex-col">
  30. <div class="box2 l-f l-flex-c l-flex-j-a">
  31. <div @click="eqeStatusClk(1)" class="TextGroup3 flex-col">
  32. <div class="group1 flex-col justify-between align-center">
  33. <span class="word4">{{ equipStatus.machineUseNum }}</span>
  34. <span class="info1">{{
  35. $t("device.totalNumberOfRuns")
  36. }}</span>
  37. </div>
  38. </div>
  39. <div @click="eqeStatusClk('')" class="TextGroup4 flex-col">
  40. <div class="main6 flex-col justify-between align-center">
  41. <span class="word5">{{ equipStatus.machineTotalNum }}</span>
  42. <span class="word6">{{
  43. $t("device.totalNumberOfEquipment")
  44. }}</span>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="deviceBox2 flex-col justify-between">
  52. <div class="section1 flex-col">
  53. <div class="outer1 flex-col o-plr-15">
  54. <div v-for="item in list" :key="item" class="o-pb-20">
  55. <div class="bd1 l-flex-between">
  56. <div class="l-flex-RC">
  57. <div class="layer1 flex-col"></div>
  58. <div class="txtBox">
  59. <span class="txt1">{{ item.name }}</span>
  60. </div>
  61. </div>
  62. <div class="l-flex-RC">
  63. <!-- 报警标志 -->
  64. <!-- <div v-if="item.hasTodayAlarm" class="box4 flex-col"> -->
  65. <!-- <img class="pic1" src="../../assets/device/alarm.png" /> -->
  66. <!-- <img class="pic1" src="../../assets/home/M15.png" /> -->
  67. <!-- </div> -->
  68. <div v-if="item.hasTodayAlarm" class="l-flex-between o-pl-5">
  69. <div class="box4 flex-col "></div>
  70. <span class="o-pl-2" style="color: #fe5d55">{{ $t("device.alarmClock") }}</span>
  71. </div>
  72. <div class="layer2 flex-col" :class="{
  73. deviceOn: item.eqeStatus === 1,
  74. layerLeft: item.hasTodayAlarm,
  75. }"></div>
  76. </div>
  77. </div>
  78. <span class="txt1 o-mt-10">{{ $t("device.affiliatedMerchants") }}:{{
  79. item.adminUserName
  80. }}</span>
  81. <span class="txt1 o-mt-10 kBordBott">{{ $t("device.machineUniqueCode") }}:{{
  82. item.clientId
  83. }}</span>
  84. <div class="contentBottomCon" v-if="item.checkType">
  85. <img class="pic1" referrerpolicy="no-referrer" src="../../assets/home/line.png" />
  86. <div class="layer2 flex-row justify-between o-ptb-8 kBordBott">
  87. <span class="info1 o-ptb-8 kBordBott">{{ $t("device.sleepState") }}:{{
  88. item.isSleep
  89. ? $t("device.sleeping")
  90. : $t("device.notSleeping")
  91. }}</span>
  92. </div>
  93. <div v-if="item.isSleep" class="layer3 o-ptb-8">
  94. <span class="word1">
  95. <div v-if="!sleepDescBoxShow">
  96. <van-field colon center class="word2" v-model="item.sleepDesc"
  97. :placeholder="$t('device.sleepDescPlace')" :label="$t('device.sleepDesc')" label-width="auto">
  98. <template #button class="button_1">
  99. <van-button size="small" type="primary" @click="sleepDescChg(item.sleepDesc, item.id)">{{
  100. $t("device.confirm") }}
  101. </van-button>
  102. <van-button size="small" type="primary" @click="editSleepDesc()">{{ $t("device.cancel")
  103. }}</van-button>
  104. </template>
  105. </van-field>
  106. <!-- </span> -->
  107. </div>
  108. <div v-else>
  109. <span class="word3 o-pr-10">{{ $t("device.sleepDesc") }}:</span>
  110. <span class="word3">{{ item.sleepDesc == null ? $t("device.SuspendBusiness") :
  111. item.sleepDesc }}</span>
  112. <van-icon name="edit" size="18" class="editIcon" @click="editSleepDesc()" />
  113. </div>
  114. </span>
  115. </div>
  116. <!-- <span class="txt5 o-ptb-10 kBordBott l-flex-RC"><span>一键重启炉头:</span>
  117. <van-button type="primary">重启</van-button>
  118. </span> -->
  119. <div class="word4 o-ptb-8">
  120. <span class="word3 o-pr-5" v-if="item.machineType == '0' || item.machineType == null">{{
  121. $t("device.furnHeadStatus") }}: </span>
  122. <span class="word3 o-pr-5" v-else>{{ $t("device.deviceStatus") }}: </span>
  123. <span>{{ item.eqeStatus === 1 ? $t("device.opened") : $t("device.closed") }}
  124. </span>
  125. <!-- <div class="l-flex-RC">
  126. <van-button type="primary">开启</van-button>
  127. <van-button type="primary">关闭</van-button>
  128. </div> -->
  129. </div>
  130. <!-- <span class="txt5 o-ptb-10 kBordBott l-flex-RC"><span>远程开门:</span>
  131. <van-button type="primary">开门</van-button>
  132. </span> -->
  133. <!-- 设备地址 -->
  134. <!-- <span class="txt1 o-ptb-8">{{ item.fullName }}</span> -->
  135. <!-- 定位: -->
  136. <!-- <div>
  137. <span v-if="item.latitude" class="txt5 o-ptb-8 kBordBott l-flex-RC">
  138. <span class="info1">{{
  139. $t("device.position") }}:</span>
  140. <van-button @click="viewPosiClk(item)" type="primary">{{
  141. $t("device.view")
  142. }}</van-button>
  143. </span>
  144. </div> -->
  145. <!-- 定位: -->
  146. <div>
  147. <span v-if="item.latitude" class="txt5 o-ptb-8 kBordBott l-flex-RC">
  148. <span class="info1">{{ $t("device.position") }}:</span>
  149. <a class="clickable-link o-ptb-8" @click="viewPosiClk(item)">{{ item.fullName }}</a>
  150. </span>
  151. </div>
  152. <van-row class="layer5 o-ptb-8 kBordBott" justify="space-between"
  153. v-if="(item.machineType == '0' || item.machineType == null) && item.equimentType != 'POP320'">
  154. <van-col class="word5">{{ $t("device.furnaceHeadTemperature") }}:{{
  155. item.furnaceTm
  156. }}{{ $t("device.degree") }}</van-col>
  157. <van-col class="word5">{{ $t("device.temperatureInCabinet") }}:{{
  158. item.cabinetTm
  159. }}{{ $t("device.degree") }}</van-col>
  160. <van-col class="word5">{{ $t("device.humidityInCabinet") }}:{{ item.cabinetHd
  161. }}{{ $t("device.humidity") }}</van-col>
  162. </van-row>
  163. <van-row class="layer5 o-ptb-8 kBordBott" justify="space-between" v-else>
  164. <van-col class="word5">{{ $t("device.stirringTemperature") }}:{{
  165. item.stirTm
  166. }}{{ $t("device.degree") }}</van-col>
  167. <van-col class="word5">{{ $t("device.cornGeneratorTemperature") }}:{{
  168. item.cornGeneratorTm
  169. }}{{ $t("device.degree") }}</van-col>
  170. <van-col class="word5">{{ $t("device.cupQuantity") }}:{{ item.cupQuantity
  171. }}</van-col>
  172. </van-row>
  173. <template v-if="item.isMaterialUse === '1' && (item.machineType == '0' || item.machineType == null)">
  174. <van-row justify="space-between" class="sugarTxt o-ptb-8 kBordBott">
  175. <van-col>
  176. {{ $t("device.whiteSugar") }}:{{ Format_calcuDecial(item.whiteSugar) }}%
  177. </van-col>
  178. <van-col>
  179. {{ $t("device.redSugar") }}:{{ Format_calcuDecial(item.redSugar) }}%
  180. </van-col>
  181. <van-col>
  182. {{ $t("device.yellowSugar") }}:{{ Format_calcuDecial(item.yellowSugar) }}%
  183. </van-col>
  184. <van-col>
  185. {{ $t("device.blueSugar") }}:{{ Format_calcuDecial(item.blueSugar) }}%
  186. </van-col>
  187. </van-row>
  188. <div class="sugarTxt o-ptb-8 kBordBott">
  189. <span>{{ $t("device.stick") }}:{{
  190. Format_calcuDecial(item.stick)
  191. }}%</span>
  192. </div>
  193. <van-row gutter="50" class="sugarTxt o-ptb-8 kBordBott">
  194. <van-col>
  195. {{ $t("device.water") }}:{{ Format_calcuDecial(item.water) }}%
  196. </van-col>
  197. <van-col>
  198. {{ $t("device.wasteWater") }}:{{ Format_calcuDecial(item.wasteWater) }}%
  199. </van-col>
  200. </van-row>
  201. <!-- 一键补料 -->
  202. <span class="txt5 o-ptb-8 kBordBott l-flex-RC"><span>{{ $t("device.oneKeyFeed") }}:</span>
  203. <!-- <van-button @click="replenishmentClk(item)" type="primary">{{ $t("device.replenishment") }}
  204. </van-button> -->
  205. <a class="replenishment o-ptb-8" @click="replenishmentClk(item)">{{ $t("device.replenishment") }}</a>
  206. </span>
  207. </template>
  208. <span class="info1 o-ptb-8 kBordBott">{{ $t("device.lastRefreshTime") }}:{{
  209. showDateTime(item.lastUpdateTime)
  210. }}</span>
  211. <span class="info2 o-ptb-8 kBordBott">{{ $t("device.volume") }}:{{ item.volume }}</span>
  212. <div class="l-flex-RC">
  213. <span class="info3 o-pr-10 kBordBott">{{ $t("device.alarmContent") }}:{{
  214. item.alarmList && item.alarmList[0]
  215. ? item.alarmList[0].alarmContent
  216. : item.alarmContent
  217. }}
  218. </span>
  219. <van-button v-if="item.alarmList && item.alarmList[0]" type="primary" size="small" color="#07c160"
  220. :text="$t('device.eliminateAlarm')" @click="clearAlarm(item.alarmList[0])"></van-button>
  221. </div>
  222. <div class="editDeviceBtnCon l-flex-center o-mt-10">
  223. <div class="l-flex-RC" @click="deviceSet(item)">
  224. <span class="c-text-14">{{
  225. $t("device.editDevice")
  226. }}</span>
  227. <div class="box2 flex-col"></div>
  228. </div>
  229. <div class="l-flex-RC o-ml-30" @click="deviceOprShow(item)">
  230. <span class="c-text-14">{{
  231. $t("device.commonOperations")
  232. }}</span>
  233. <div class="box2 flex-col"></div>
  234. </div>
  235. </div>
  236. </div>
  237. <div class="bd6 l-flex-center o-ptb-8" @click="item.checkType = !item.checkType">
  238. <div class="l-flex-RC">
  239. <span class="info2 o-mr-2">{{
  240. item.checkType ? $t("device.stow") : $t("device.seeMore")
  241. }}</span>
  242. <div class="group2 flex-col" :class="{ checkType: item.checkType }"></div>
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </van-list>
  250. </div>
  251. <deviceOper ref="oprRef" @operfinish="operFinish"></deviceOper>
  252. <!-- 搜索弹出框 -->
  253. <deviceSearch ref="searchRef" @search="search($event)"></deviceSearch>
  254. <nav-bar></nav-bar>
  255. </div>
  256. </template>
  257. <script>
  258. import {
  259. Api_postMachineNum,
  260. } from "../../service/home";
  261. import { onMounted, reactive, toRefs, ref } from "vue";
  262. import { Toast, Dialog } from "vant";
  263. import navBar from "../../components/NavBar";
  264. import sHeader from "../../components/SimpleHeader";
  265. import { getLoginUser, Format_calcuDecial } from "../../common/js/utils";
  266. import {
  267. getDeviceList,
  268. eliminate,
  269. Api_getReplenishment,
  270. changeSleepDesc,
  271. } from "../../service/device/index";
  272. import deviceSearch from "./deviceSearch";
  273. import deviceOper from "./deviceOper";
  274. import { useRouter } from "vue-router";
  275. import dateUtil from "../../utils/dateUtil";
  276. import { useI18n } from "vue-i18n";
  277. export default {
  278. name: "device",
  279. components: { sHeader, navBar, deviceSearch, deviceOper },
  280. setup() {
  281. const { t } = useI18n();
  282. const searchRef = ref(null);
  283. const oprRef = ref(null);
  284. const list = ref([]);
  285. const loading = ref(true);
  286. const error = ref(false);
  287. const finished = ref(false);
  288. const router = useRouter();
  289. const sys = ref(null);
  290. const user = getLoginUser();
  291. //控制睡眠描述的显示隐藏
  292. const sleepDescBoxShow = ref(true);
  293. // 页面列表查询参数
  294. let searchParams = reactive({
  295. id: "", // 用户账户id
  296. // adminName: '', // 用户登录名
  297. current: 1, // 页数
  298. size: 10, // 页大小
  299. todayDate: dateUtil.formateDate(new Date(), "yyyy-MM-dd"), // 当天时间
  300. });
  301. // 初始化页面获取列表
  302. onMounted(() => {
  303. init();
  304. //加载样式
  305. // styleUrl('device');
  306. });
  307. // 初始化
  308. const init = () => {
  309. // 获取设备情况
  310. getMachineNum();
  311. if (localStorage.getItem("loginSys")) {
  312. const loginSysString = localStorage.getItem("loginSys");
  313. sys.value = JSON.parse(loginSysString);
  314. }
  315. list.value = [];
  316. searchParams.current = 1;
  317. if (user) {
  318. searchParams.id = user.id;
  319. // if (user.isAdmined) {
  320. // searchParams.adminName = user.username;
  321. // }
  322. getList();
  323. }
  324. };
  325. // 获取设备列表数据
  326. const getList = async () => {
  327. finished.value = false;
  328. const { data } = await getDeviceList(Object.assign({}, searchParams));
  329. if (data.code === "00000") {
  330. if (searchParams.current === 0) {
  331. list.value = [];
  332. }
  333. // 列表值叠加
  334. list.value = list.value.concat(
  335. data.data.records.map((item) => {
  336. if (item.sleepDesc == null) {
  337. item.sleepDesc = t("device.SuspendBusiness");
  338. }
  339. return {
  340. ...item,
  341. checkType: false,
  342. };
  343. })
  344. );
  345. if (list.value.length === data.data.total) {
  346. finished.value = true;
  347. }
  348. loading.value = false;
  349. } else {
  350. Toast.fail(data.message);
  351. }
  352. };
  353. // 滚动加载
  354. const onLoad = () => {
  355. if (!finished.value) {
  356. searchParams.current = searchParams.current + 1;
  357. getList();
  358. }
  359. };
  360. // 搜索点击
  361. const searchClick = () => {
  362. searchRef.value.showSearch();
  363. };
  364. // 搜索条件触发查询
  365. const search = (e) => {
  366. list.value = [];
  367. loading.value = true;
  368. searchParams.current = 1;
  369. searchParams = Object.assign(searchParams, e);
  370. getList();
  371. getMachineNum();
  372. };
  373. // 跳转设备编辑
  374. const deviceSet = (e) => {
  375. router.push({ path: "deviceSet", query: { deviceId: e.id } });
  376. };
  377. // 常用操作弹窗展示触发
  378. const deviceOprShow = (e) => {
  379. oprRef.value.showOper(e);
  380. };
  381. // 消除报警
  382. const clearAlarm = async (e) => {
  383. const params = {
  384. id: e.id,
  385. name: e.name,
  386. selfName: e.selfName,
  387. areaId: e.areaId,
  388. channel: e.channel,
  389. contactName: e.contactName,
  390. contactPhone: e.contactPhone,
  391. flowers: e.flowers,
  392. operationalName: e.operationalName,
  393. operationalPhone: e.operationalPhone,
  394. timeRuleId: e.timeRuleId,
  395. };
  396. const { data } = await eliminate(Object.assign({}, params));
  397. if (data.code) {
  398. Toast.success(t("device.successfullyEliminatedTheAlarm"));
  399. e.alarmList = [];
  400. } else {
  401. Toast.fail(data.message);
  402. }
  403. console.log("/tEquipment/eliminate", e);
  404. };
  405. const showDateTime = (date) => {
  406. if (!date) {
  407. return "";
  408. }
  409. const currentDate = new Date(dateUtil.formateDate(new Date(date), "yyyy-MM-dd hh:mm:ss"));
  410. return dateUtil.timeZoneDate(currentDate);
  411. };
  412. // 点击查看定位
  413. const viewPosiClk = (row) => {
  414. console.log("row 是 >>>", row);
  415. if (row.latitude) {
  416. router.push({
  417. path: "viewPosition",
  418. query: {
  419. latitude: row.latitude,
  420. longitude: row.longitude,
  421. fullName: row.fullName,
  422. },
  423. });
  424. } else {
  425. Toast(`${t("device.noPosition")}!!!`);
  426. }
  427. };
  428. // 点击补料
  429. const replenishmentClk = (row) => {
  430. console.log("row >>>", row);
  431. Api_getReplenishment({ equipmentId: row.id }).then((res) => {
  432. console.log("res >>>", res);
  433. // Toast(res.data.message);
  434. Dialog.alert({
  435. message: t('device.sentSuccessfully'),
  436. }).then(() => {
  437. //返回上一页
  438. router.go(0);
  439. });
  440. setTimeout(() => {
  441. getList();
  442. }, 500);
  443. });
  444. };
  445. // 操作弹窗完成的回调
  446. const operFinish = () => {
  447. init();
  448. };
  449. // 设备状况
  450. const equipStatus = ref({});
  451. // 获取设备情况
  452. const getMachineNum = () => {
  453. Api_postMachineNum({
  454. adminId: user.id,
  455. companyType: searchParams.companyType
  456. }).then((res) => {
  457. equipStatus.value = res.data.data || {};
  458. });
  459. };
  460. // 点击运行总数和总设备数
  461. const eqeStatusClk = (val) => {
  462. searchParams.eqeStatus = val;
  463. // 初始化
  464. searchParams.current = 1;
  465. list.value = [];
  466. getList();
  467. };
  468. // 点击修改图标
  469. const editSleepDesc = () => {
  470. sleepDescBoxShow.value = !sleepDescBoxShow.value;
  471. }
  472. // 点击睡眠描述的确定按钮
  473. const sleepDescChg = async (sleepDesc, id) => {
  474. console.log(sleepDesc);
  475. if (!sleepDesc) {
  476. Toast(t("device.sleepDescPlace"));
  477. } else {
  478. const { data } = await changeSleepDesc({
  479. equipmentId: id,
  480. sleepDesc,
  481. });
  482. if (data.code === "00000") {
  483. sleepDescBoxShow.value = true;
  484. Toast(data.message);
  485. // setTimeout(() => {
  486. // gettAdminGetRelation();
  487. // }, 500);
  488. }
  489. }
  490. }
  491. return {
  492. ...toRefs(searchParams),
  493. list,
  494. loading,
  495. error,
  496. finished,
  497. onLoad,
  498. searchRef,
  499. searchClick,
  500. search,
  501. deviceSet,
  502. clearAlarm,
  503. oprRef,
  504. deviceOprShow,
  505. showDateTime,
  506. sys,
  507. viewPosiClk,
  508. replenishmentClk,
  509. Format_calcuDecial,
  510. operFinish,
  511. equipStatus,
  512. eqeStatusClk,
  513. editSleepDesc,
  514. sleepDescBoxShow,
  515. sleepDescChg,
  516. };
  517. },
  518. };
  519. </script>
  520. <style lang="less" scoped>
  521. @import "../../common/style/common";
  522. @import "../../styles/device/index";
  523. </style>