index.vue 19 KB

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