index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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-5 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. <!-- <span class="txt1 o-ptb-8">{{ item.fullName }}</span>
  134. <div>
  135. <span v-if="item.latitude" class="txt5 o-ptb-5 kBordBott l-flex-RC">
  136. <span class="info1">{{
  137. $t("device.position") }}:</span>
  138. <van-button @click="viewPosiClk(item)" type="primary">{{
  139. $t("device.view")
  140. }}</van-button>
  141. </span>
  142. </div> -->
  143. <!-- 定位-->
  144. <div>
  145. <span v-if="item.latitude" class="txt5 o-ptb-4 kBordBott l-flex-RC">
  146. <span class="info1">{{ $t("device.position") }}:</span>
  147. <a class="clickable-link o-ptb-8" @click="viewPosiClk(item)">{{ item.fullName }}</a>
  148. </span>
  149. </div>
  150. <van-row class="layer5 o-ptb-8 kBordBott" justify="space-between"
  151. v-if="(item.machineType == '0' || item.machineType == null) && item.equimentType != 'POP320'">
  152. <van-col class="word5">{{ $t("device.furnaceHeadTemperature") }}:{{
  153. item.furnaceTm
  154. }}{{ $t("device.degree") }}</van-col>
  155. <van-col class="word5">{{ $t("device.temperatureInCabinet") }}:{{
  156. item.cabinetTm
  157. }}{{ $t("device.degree") }}</van-col>
  158. <van-col class="word5">{{ $t("device.humidityInCabinet") }}:{{ item.cabinetHd
  159. }}{{ $t("device.humidity") }}</van-col>
  160. </van-row>
  161. <van-row class="layer5 o-ptb-8 kBordBott" justify="space-between" v-else>
  162. <van-col class="word5">{{ $t("device.stirringTemperature") }}:{{
  163. item.stirTm
  164. }}{{ $t("device.degree") }}</van-col>
  165. <van-col class="word5">{{ $t("device.cornGeneratorTemperature") }}:{{
  166. item.cornGeneratorTm
  167. }}{{ $t("device.degree") }}</van-col>
  168. <van-col class="word5">{{ $t("device.cupQuantity") }}:{{ item.cupQuantity
  169. }}</van-col>
  170. </van-row>
  171. <template v-if="item.isMaterialUse === '1' && (item.machineType == '0' || item.machineType == null)">
  172. <van-row justify="space-between" class="sugarTxt o-ptb-8 kBordBott">
  173. <van-col>
  174. {{ $t("device.whiteSugar") }}:{{ Format_calcuDecial(item.whiteSugar) }}%
  175. </van-col>
  176. <van-col>
  177. {{ $t("device.redSugar") }}:{{ Format_calcuDecial(item.redSugar) }}%
  178. </van-col>
  179. <van-col>
  180. {{ $t("device.yellowSugar") }}:{{ Format_calcuDecial(item.yellowSugar) }}%
  181. </van-col>
  182. <van-col>
  183. {{ $t("device.blueSugar") }}:{{ Format_calcuDecial(item.blueSugar) }}%
  184. </van-col>
  185. </van-row>
  186. <div class="sugarTxt o-ptb-8 kBordBott">
  187. <span>{{ $t("device.stick") }}:{{
  188. Format_calcuDecial(item.stick)
  189. }}%</span>
  190. </div>
  191. <van-row gutter="50" class="sugarTxt o-ptb-8 kBordBott">
  192. <van-col>
  193. {{ $t("device.water") }}:{{ Format_calcuDecial(item.water) }}%
  194. </van-col>
  195. <van-col>
  196. {{ $t("device.wasteWater") }}:{{ Format_calcuDecial(item.wasteWater) }}%
  197. </van-col>
  198. </van-row>
  199. <span class="txt5 o-ptb-8 kBordBott l-flex-RC"><span>{{ $t("device.oneKeyFeed") }}:</span>
  200. <van-button @click="replenishmentClk(item)" type="primary">{{ $t("device.replenishment") }}
  201. </van-button>
  202. </span>
  203. </template>
  204. <span class="info1 o-ptb-8 kBordBott">{{ $t("device.lastRefreshTime") }}:{{
  205. showDateTime(item.lastUpdateTime)
  206. }}</span>
  207. <span class="info2 o-ptb-8 kBordBott">{{ $t("device.volume") }}:{{ item.volume }}</span>
  208. <div class="l-flex-RC o-ptb-7">
  209. <span class="info3 o-pr-8 kBordBott">{{ $t("device.alarmContent") }}:{{
  210. item.alarmList && item.alarmList[0]
  211. ? item.alarmList[0].alarmContent
  212. : item.alarmContent
  213. }}
  214. </span>
  215. <van-button v-if="item.alarmList && item.alarmList[0]" type="primary" size="small" color="#07c160"
  216. :text="$t('device.eliminateAlarm')" @click="clearAlarm(item.alarmList[0])"></van-button>
  217. </div>
  218. <div class="editDeviceBtnCon l-flex-center o-mt-10">
  219. <div class="l-flex-RC" @click="deviceSet(item)">
  220. <span class="c-text-14">{{
  221. $t("device.editDevice")
  222. }}</span>
  223. <div class="box2 flex-col"></div>
  224. </div>
  225. <div class="l-flex-RC o-ml-30" @click="deviceOprShow(item)">
  226. <span class="c-text-14">{{
  227. $t("device.commonOperations")
  228. }}</span>
  229. <div class="box2 flex-col"></div>
  230. </div>
  231. </div>
  232. </div>
  233. <div class="bd6 l-flex-center o-ptb-10" @click="item.checkType = !item.checkType">
  234. <div class="l-flex-RC">
  235. <span class="info2 o-mr-2">{{
  236. item.checkType ? $t("device.stow") : $t("device.seeMore")
  237. }}</span>
  238. <div class="group2 flex-col" :class="{ checkType: item.checkType }"></div>
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. </van-list>
  246. </div>
  247. <deviceOper ref="oprRef" @operfinish="operFinish"></deviceOper>
  248. <!-- 搜索弹出框 -->
  249. <deviceSearch ref="searchRef" @search="search($event)"></deviceSearch>
  250. <nav-bar></nav-bar>
  251. </div>
  252. </template>
  253. <script>
  254. import {
  255. Api_postMachineNum,
  256. } from "../../service/home";
  257. import { onMounted, reactive, toRefs, ref } from "vue";
  258. import { Toast, Dialog } from "vant";
  259. import navBar from "../../components/NavBar";
  260. import sHeader from "../../components/SimpleHeader";
  261. import { getLoginUser, Format_calcuDecial, styleUrl } from "../../common/js/utils";
  262. import {
  263. getDeviceList,
  264. eliminate,
  265. Api_getReplenishment,
  266. changeSleepDesc,
  267. } from "../../service/device/index";
  268. import deviceSearch from "./deviceSearch";
  269. import deviceOper from "./deviceOper";
  270. import { useRouter } from "vue-router";
  271. import dateUtil from "../../utils/dateUtil";
  272. import { useI18n } from "vue-i18n";
  273. export default {
  274. name: "device",
  275. components: { sHeader, navBar, deviceSearch, deviceOper },
  276. setup() {
  277. const { t } = useI18n();
  278. const searchRef = ref(null);
  279. const oprRef = ref(null);
  280. const list = ref([]);
  281. const loading = ref(true);
  282. const error = ref(false);
  283. const finished = ref(false);
  284. const router = useRouter();
  285. const sys = ref(null);
  286. const user = getLoginUser();
  287. //控制睡眠描述的显示隐藏
  288. const sleepDescBoxShow = ref(true);
  289. // 页面列表查询参数
  290. let searchParams = reactive({
  291. id: "", // 用户账户id
  292. // adminName: '', // 用户登录名
  293. current: 1, // 页数
  294. size: 10, // 页大小
  295. todayDate: dateUtil.formateDate(new Date(), "yyyy-MM-dd"), // 当天时间
  296. });
  297. // 初始化页面获取列表
  298. onMounted(() => {
  299. init();
  300. //加载样式
  301. styleUrl('device');
  302. });
  303. // 初始化
  304. const init = () => {
  305. // 获取设备情况
  306. getMachineNum();
  307. if (localStorage.getItem("loginSys")) {
  308. const loginSysString = localStorage.getItem("loginSys");
  309. sys.value = JSON.parse(loginSysString);
  310. }
  311. list.value = [];
  312. searchParams.current = 1;
  313. if (user) {
  314. searchParams.id = user.id;
  315. // if (user.isAdmined) {
  316. // searchParams.adminName = user.username;
  317. // }
  318. getList();
  319. }
  320. };
  321. // 获取设备列表数据
  322. const getList = async () => {
  323. finished.value = false;
  324. const { data } = await getDeviceList(Object.assign({}, searchParams));
  325. if (data.code === "00000") {
  326. if (searchParams.current === 0) {
  327. list.value = [];
  328. }
  329. // 列表值叠加
  330. list.value = list.value.concat(
  331. data.data.records.map((item) => {
  332. if (item.sleepDesc == null) {
  333. item.sleepDesc = t("device.SuspendBusiness");
  334. }
  335. return {
  336. ...item,
  337. checkType: false,
  338. };
  339. })
  340. );
  341. if (list.value.length === data.data.total) {
  342. finished.value = true;
  343. }
  344. loading.value = false;
  345. } else {
  346. Toast.fail(data.message);
  347. }
  348. };
  349. // 滚动加载
  350. const onLoad = () => {
  351. if (!finished.value) {
  352. searchParams.current = searchParams.current + 1;
  353. getList();
  354. }
  355. };
  356. // 搜索点击
  357. const searchClick = () => {
  358. searchRef.value.showSearch();
  359. };
  360. // 搜索条件触发查询
  361. const search = (e) => {
  362. list.value = [];
  363. loading.value = true;
  364. searchParams.current = 1;
  365. searchParams = Object.assign(searchParams, e);
  366. getList();
  367. getMachineNum();
  368. };
  369. // 跳转设备编辑
  370. const deviceSet = (e) => {
  371. router.push({ path: "deviceSet", query: { deviceId: e.id } });
  372. };
  373. // 常用操作弹窗展示触发
  374. const deviceOprShow = (e) => {
  375. oprRef.value.showOper(e);
  376. };
  377. // 消除报警
  378. const clearAlarm = async (e) => {
  379. const params = {
  380. id: e.id,
  381. name: e.name,
  382. selfName: e.selfName,
  383. areaId: e.areaId,
  384. channel: e.channel,
  385. contactName: e.contactName,
  386. contactPhone: e.contactPhone,
  387. flowers: e.flowers,
  388. operationalName: e.operationalName,
  389. operationalPhone: e.operationalPhone,
  390. timeRuleId: e.timeRuleId,
  391. };
  392. const { data } = await eliminate(Object.assign({}, params));
  393. if (data.code) {
  394. Toast.success(t("device.successfullyEliminatedTheAlarm"));
  395. e.alarmList = [];
  396. } else {
  397. Toast.fail(data.message);
  398. }
  399. console.log("/tEquipment/eliminate", e);
  400. };
  401. const showDateTime = (date) => {
  402. if (!date) {
  403. return "";
  404. }
  405. const currentDate = new Date(dateUtil.formateDate(new Date(date), "yyyy-MM-dd hh:mm:ss"));
  406. return dateUtil.timeZoneDate(currentDate);
  407. };
  408. // 点击查看定位
  409. const viewPosiClk = (row) => {
  410. if (row.latitude) {
  411. router.push({
  412. path: "viewPosition",
  413. query: {
  414. latitude: row.latitude,
  415. longitude: row.longitude,
  416. fullName: row.fullName,
  417. },
  418. });
  419. } else {
  420. Toast(`${t("device.noPosition")}!!!`);
  421. }
  422. };
  423. // 点击补料
  424. const replenishmentClk = (row) => {
  425. console.log("row", row);
  426. Api_getReplenishment({ equipmentId: row.id }).then((res) => {
  427. console.log("res", res);
  428. // Toast(res.data.message);
  429. Dialog.alert({
  430. message: t('device.sentSuccessfully'),
  431. }).then(() => {
  432. //返回上一页
  433. router.go(0);
  434. });
  435. setTimeout(() => {
  436. getList();
  437. }, 500);
  438. });
  439. };
  440. // 操作弹窗完成的回调
  441. const operFinish = () => {
  442. init();
  443. };
  444. // 设备状况
  445. const equipStatus = ref({});
  446. // 获取设备情况
  447. const getMachineNum = () => {
  448. Api_postMachineNum({
  449. adminId: user.id,
  450. companyType: searchParams.companyType
  451. }).then((res) => {
  452. equipStatus.value = res.data.data || {};
  453. });
  454. };
  455. // 点击运行总数和总设备数
  456. const eqeStatusClk = (val) => {
  457. searchParams.eqeStatus = val;
  458. // 初始化
  459. searchParams.current = 1;
  460. list.value = [];
  461. getList();
  462. };
  463. // 点击修改图标
  464. const editSleepDesc = () => {
  465. sleepDescBoxShow.value = !sleepDescBoxShow.value;
  466. }
  467. // 点击睡眠描述的确定按钮
  468. const sleepDescChg = async (sleepDesc, id) => {
  469. console.log(sleepDesc);
  470. if (!sleepDesc) {
  471. Toast(t("device.sleepDescPlace"));
  472. } else {
  473. const { data } = await changeSleepDesc({
  474. equipmentId: id,
  475. sleepDesc,
  476. });
  477. if (data.code === "00000") {
  478. sleepDescBoxShow.value = true;
  479. Toast(data.message);
  480. // setTimeout(() => {
  481. // gettAdminGetRelation();
  482. // }, 500);
  483. }
  484. }
  485. }
  486. return {
  487. ...toRefs(searchParams),
  488. list,
  489. loading,
  490. error,
  491. finished,
  492. onLoad,
  493. searchRef,
  494. searchClick,
  495. search,
  496. deviceSet,
  497. clearAlarm,
  498. oprRef,
  499. deviceOprShow,
  500. showDateTime,
  501. sys,
  502. viewPosiClk,
  503. replenishmentClk,
  504. Format_calcuDecial,
  505. operFinish,
  506. equipStatus,
  507. eqeStatusClk,
  508. editSleepDesc,
  509. sleepDescBoxShow,
  510. sleepDescChg,
  511. };
  512. },
  513. };
  514. </script>
  515. <style lang="less" scoped>
  516. @import "../../common/style/common";
  517. @import "../../styles/device/index";
  518. </style>