123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <template>
- <!-- 设备参数调整 -->
- <div class="paramsSetPage flex-col">
- <s-header :name="paramsTitle" :noback="false"></s-header>
- <div class="paramsSetBox mod1 flex-col">
- <div class="wrap2 flex-col van-hairline--bottom">
- <div class="outer1 flex-row justify-between">
- <div class="block1 flex-col"></div>
- <span class="txt2">{{ $t('device.equipmentName') }}:{{ deviceDetal ? deviceDetal.name : "" }}</span>
- </div>
- </div>
- <!-- <van-divider :style="{ margin: '5px 16px' }" /> -->
- <div class="" v-if="type == '3'">
- <van-field :label="$t('device.numberOneTm')"
- :model-value="(deviceDetal.numberOne == null ? $t('device.noData') : deviceDetal.numberOne + $t('device.degree'))"
- readonly />
- <van-field :label="$t('device.furnaceHeadTemperature')"
- :model-value="(deviceDetal.furnaceTm == null ? $t('device.noData') : deviceDetal.furnaceTm + $t('device.degree'))"
- readonly />
- <van-field :label="$t('device.candyGeneratorTm')"
- :model-value="(deviceDetal.candyGeneratorTm == null ? $t('device.noData') : deviceDetal.candyGeneratorTm + $t('device.degree'))"
- readonly />
- <van-field :label="$t('device.temperatureInCabinet')"
- :model-value="(deviceDetal.cabinetTm == null ? $t('device.noData') : deviceDetal.cabinetTm + $t('device.degree'))"
- readonly />
- <van-field :label="$t('device.humidityInCabinet')"
- :model-value="(deviceDetal.cabinetHd == null ? $t('device.noData') : deviceDetal.cabinetHd + $t('device.humidity'))"
- readonly />
- <van-field :label="$t('device.outsideTm')"
- :model-value="(deviceDetal.outsideTm == null ? $t('device.noData') : deviceDetal.outsideTm + $t('device.degree'))"
- readonly />
- <van-field :label="$t('device.outsidehd')"
- :model-value="(deviceDetal.outsideHd == null ? $t('device.noData') : deviceDetal.outsideHd + $t('device.humidity'))"
- readonly />
- </div>
- <div v-if="type == '2'">
- <van-field :label="$t('device.humidityInCabinet')"
- :model-value="(deviceDetal.cabinetHd == null ? $t('device.noData') : deviceDetal.cabinetHd + $t('device.humidity'))"
- readonly />
- <van-field v-model="interval" :label="$t('device.increaseOrDecrease')" class="paramsList">
- <template #button>
- <van-button size="small" type="primary" class="updataButton" @click="updateInterval(0)">{{
- $t('device.submitUpdates') }}</van-button>
- </template>
- </van-field>
- <van-field :label="$t('device.winterParameters')" class="inputButton">
- <template #input>
- <van-button size="small" type="primary" class="updataButton" @click="updateInterval(1)">{{
- $t('device.submitUpdates') }}</van-button>
- </template>
- </van-field>
- <van-field :label="$t('device.summerParameters')" class="inputButton">
- <template #input>
- <van-button size="small" type="primary" class="updataButton" @click="updateInterval(2)">{{
- $t('device.submitUpdates') }}</van-button>
- </template>
- </van-field>
- </div>
- <div class="paramsList" v-for="(item, key) in paramsList" :key="key">
- <van-field :model-value="item.val" @update:model-value="onUpdateParameters(item, key, $event)"
- v-if="item.name != 'M502' && item.name != 'M506'" name="phone" type="tel" :label="paramName[key]">
- <template #button>
- <van-button size="small" type="primary" class="updataButton" @click="updateParams(item, key)">{{
- $t('device.submitUpdates') }}</van-button>
- </template>
- </van-field>
- <div class="flex-row" v-else>
- <span class="txt3 o-pl-15 o-mtb-18" v-if="item.name != 'M502'">{{ paramName[key] }}
- </span>
- <van-switch v-if="item.name != 'M502'" class="o-mt-8" :model-value="checked[key]"
- @update:model-value="onUpdateValue(item, key)">
- </van-switch>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { onMounted, ref } from "vue";
- import sHeader from "@/components/SimpleHeader";
- import { useRoute } from "vue-router";
- import { getDeviceDetal, getParameters, updateParameters, humidityParameters } from "@/service/device";
- import { showFailToast, showSuccessToast, showConfirmDialog, showToast } from "vant";
- import { useI18n } from 'vue-i18n';
- import { styleUrl } from "../../../common/js/utils";
- export default {
- components: { sHeader },
- setup() {
- const { t } = useI18n();
- const route = useRoute();
- const deviceId = route.query.deviceId;
- const deviceDetal = ref([]);
- const paramsTitle = ref("");
- const paramsList = ref([]);
- const comParams = ref([]);
- const paramName = ref([]);
- const checked = ref([]);
- const type = ref("");
- const isChange = ref(false);
- const howLong = ref([]);
- const interval = ref("");
- // 初始化页面获取列表
- onMounted(async () => {
- // 加载样式
- styleUrl('paramsSet');
- type.value = route.query.type;
- if (route.query.type === "0") {
- paramsTitle.value = t('device.generalParameterConfiguration');
- }
- if (route.query.type === "1") {
- paramsTitle.value = t('device.advancedParameterConfiguration');
- }
- if (route.query.type === "2") {
- paramsTitle.value = t('device.debuggingParameterConfiguration');
- }
- if (route.query.type === "3") {
- paramsTitle.value = t('device.humidityParameterConfiguration');
- }
- getDeviceDetalFun();
- });
- // 获取设备列表数据
- const getDeviceDetalFun = async () => {
- const { data } = await getDeviceDetal({ id: deviceId });
- if (data.code === "00000") {
- deviceDetal.value = data.data;
- if (route.query.type != "2") {
- getParametersFun();
- }
- } else {
- showFailToast(data.message);
- }
- };
- // 获取参数列表
- const getParametersFun = async () => {
- paramsList.value = [];
- const params = {
- id: deviceId,
- status: route.query.type,
- clientId: deviceDetal.value.clientId,
- };
- const { data } = await getParameters(params);
- if (data.code) {
- paramsList.value = data.data;
- paramsList.value.forEach((paramItem) => {
- // console.log("paramItem:", paramItem);
- comParams.value.push(paramItem.name);
- paramName.value.push(t("paramNames." + paramItem.name));
- if (paramItem.val === '1') {
- checked.value.push(true);
- } else {
- checked.value.push(false);
- }
- howLong.value.push(paramItem.val != null ? paramItem.val.length : 0);
- })
- } else {
- showToast(t('device.noParameterData'));
- }
- };
- const onUpdateParameters = (item, key, e) => {
- // console.log(e);
- // console.log(howLong.value[key]);
- if (howLong.value[key] != e.length) {
- isChange.value = true;
- } else {
- isChange.value = false;
- }
- item.val = e;
- }
- // 更新参数值
- const updateParams = async (item, key) => {
- const params = {
- id: deviceId,
- name: item.name,
- val: item.val,
- };
- showConfirmDialog({
- title: t('device.tips'),
- message: t('device.isUpdate') + paramName.value[key] + t('device.to') + item.val + '?' + (isChange.value ? t('device.attention') : ''),
- }).then(async () => {
- const { data } = await updateParameters(params);
- if (data.code) {
- showSuccessToast(t('device.modificationSucceeded'));
- } else {
- showFailToast(data.message);
- }
- }).catch(() => {
- })
- }
- const onUpdateValue = (item, key) => {
- console.log(item);
- const params = {
- id: deviceId,
- name: item.name,
- val: item.val == '0' ? '1' : '0',
- };
- showConfirmDialog({
- title: t('device.tips'),
- message: t('device.content'),
- }).then(async () => {
- const { data } = await updateParameters(params);
- if (data.code) {
- checked.value[key] = !checked.value[key];
- showSuccessToast(t('device.modificationSucceeded'));
- } else {
- showFailToast(data.message);
- }
- }).catch(() => {
- // on cancel
- });
- };
- // 一键递增递减
- const updateInterval = (value) => {
- const params = {
- id: deviceId,
- name: "allUpdate",
- val: interval.value,
- };
- if (value === 0) {
- params.name = "allUpdate";
- params.val = interval.value;
- } else if (value === 1) {
- params.name = "winter";
- params.val = "winter";
- } else {
- params.name = "summer";
- params.val = "summer";
- }
- showConfirmDialog({
- title: t('device.tips'),
- message: t('device.isUpdate') + '?',
- }).then(async () => {
- const { data } = await humidityParameters(params);
- if (data.code) {
- showSuccessToast(t('device.modificationSucceeded'));
- } else {
- showFailToast(data.message);
- }
- }).catch(() => {
- })
- }
- return {
- deviceDetal,
- paramsTitle,
- paramsList,
- // getParamName,
- updateParams,
- paramName,
- checked,
- onUpdateValue,
- type,
- onUpdateParameters,
- interval,
- updateInterval
- };
- },
- };
- </script>
- <style lang="less" scoped>
- @import "../../../common/style/common";
- .paramsValue {
- margin: 0 40px;
- }
- </style>
|