index.vue 19 KB

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