|
@@ -0,0 +1,247 @@
|
|
|
+<template>
|
|
|
+ <oa-scroll
|
|
|
+ customClass="unitInfoCollection-container scroll-height"
|
|
|
+ :refresherLoad="false"
|
|
|
+ :refresherEnabled="false"
|
|
|
+ :refresherEnabledTitle="false"
|
|
|
+ :refresherDefaultStyle="'none'"
|
|
|
+ :refresherThreshold="44"
|
|
|
+ :refresherBackground="'#f5f6f7'"
|
|
|
+ :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
|
|
|
+ >
|
|
|
+ <template #default>
|
|
|
+
|
|
|
+ <view class="centerOne">
|
|
|
+ <u--form ref="uForm" :model="form" :rules="rules" labelWidth="130">
|
|
|
+ <view style="padding: 10px 0">
|
|
|
+ <view style="padding: 10px 10px 20px 10px; background: #ffffff">
|
|
|
+ <view style="padding-left: 9px">
|
|
|
+ <u-form-item label="命令" prop="commandName" required :borderBottom="true">
|
|
|
+ <u-input v-model="form.commandName" placeholder="请输入命令名称" border="none">
|
|
|
+
|
|
|
+ </u-input>
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="命令属性" v-if="form.dataType==1" prop="commandValue" required :borderBottom="true" @click="handleAction('命令属性')">
|
|
|
+ <u-input v-model="form.commandName1" placeholder="请选择命令属性" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item v-else label="参数值" prop="commandValue" required :borderBottom="true">
|
|
|
+ <u-input v-model="form.commandValue" placeholder="请输入参数值" border="none">
|
|
|
+
|
|
|
+ </u-input>
|
|
|
+ </u-form-item>
|
|
|
+
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </u--form>
|
|
|
+
|
|
|
+ <view class="app-button">
|
|
|
+ <view class="app-button-padding"></view>
|
|
|
+ <view class="app-button-fixed">
|
|
|
+ <u-button class="app-buttom" type="primary" @click="handleSubmit('命令下发')" shape="circle"> 命 令 下 发 </u-button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+
|
|
|
+ <u-picker
|
|
|
+ :show="actionShow"
|
|
|
+ :columns="actionsList"
|
|
|
+ :title="'请选择' + actionTitle"
|
|
|
+ keyName="name"
|
|
|
+ visibleItemCount="6"
|
|
|
+ :defaultIndex="[actionDefaultIndex]"
|
|
|
+ :closeOnClickOverlay="true"
|
|
|
+ @close="actionShow = false"
|
|
|
+ @cancel="actionShow = false"
|
|
|
+ @confirm="selectAction"
|
|
|
+ ></u-picker>
|
|
|
+
|
|
|
+
|
|
|
+ </template>
|
|
|
+ </oa-scroll>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+/*----------------------------------依赖引入-----------------------------------*/
|
|
|
+import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
|
+import { ref, reactive, toRefs, getCurrentInstance } from "vue";
|
|
|
+/*----------------------------------接口引入-----------------------------------*/
|
|
|
+import { getList,doorControl} from "@/api/business/fireIot/deviceManage.js";
|
|
|
+/*----------------------------------组件引入-----------------------------------*/
|
|
|
+/*----------------------------------store引入-----------------------------------*/
|
|
|
+/*----------------------------------公共方法引入-----------------------------------*/
|
|
|
+/*----------------------------------公共变量-----------------------------------*/
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+/*----------------------------------变量声明-----------------------------------*/
|
|
|
+
|
|
|
+const deviceId=ref('')
|
|
|
+
|
|
|
+const dataList = reactive({
|
|
|
+ form: {
|
|
|
+ commandName: "", //命令名称
|
|
|
+ commandCode: "", //命令编码
|
|
|
+ productCode: "", //产品编码
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ commandName: [{ required: true, message: "请输入命令", trigger: "blur" }],
|
|
|
+ commandValue:[
|
|
|
+ { required: true},
|
|
|
+ { validator: commandValueScale,trigger: 'blur'}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ actionTitle: "",
|
|
|
+ actionShow: false,
|
|
|
+ actionDefaultIndex: 0,
|
|
|
+ actionsList: [[]],
|
|
|
+});
|
|
|
+
|
|
|
+const {
|
|
|
+ form,
|
|
|
+ rules,
|
|
|
+ actionTitle,
|
|
|
+ actionsList,
|
|
|
+ actionShow,
|
|
|
+ actionDefaultIndex,
|
|
|
+} = toRefs(dataList);
|
|
|
+
|
|
|
+const scanBool = ref(false);
|
|
|
+
|
|
|
+//参数值校验范围
|
|
|
+function commandValueScale(rule, value, callback) {
|
|
|
+ console.log(form.value.maximum,222)
|
|
|
+ if(form.value.maximum&&form.value.minimum){
|
|
|
+ if (value > form.value.minimum && value <form.value.maximum) {
|
|
|
+ callback();
|
|
|
+ } else {
|
|
|
+ callback(new Error(`输入的参数值必须大于${form.value.minimum}且小于${form.value.maximum}`));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//详情数据
|
|
|
+function getData(){
|
|
|
+ getList({
|
|
|
+ current: 1,
|
|
|
+ size: 10,
|
|
|
+ productCode:form.value.productCode,
|
|
|
+ commandCode:form.value.commandCode,
|
|
|
+ }).then((response) => {
|
|
|
+ form.value=response.data.records[0];
|
|
|
+ form.value.commandDict = form.value.commandDict?JSON.parse(form.value.commandDict):'';
|
|
|
+ rules.value.commandValue[0].message=form.value.dataType==1?'请选择命令属性':"请输入参数值"
|
|
|
+ rules.value.commandValue[0].tigger=form.value.dataType==1?'change':"blur";
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @上一步
|
|
|
+ * @命令下发
|
|
|
+ * @提交
|
|
|
+ * @按钮点击事件
|
|
|
+ */
|
|
|
+function handleSubmit(value) {
|
|
|
+ proxy.$refs["uForm"]
|
|
|
+ .validate()
|
|
|
+ .then((res) => {
|
|
|
+ proxy.$modal.msg("校验通过");
|
|
|
+ var params={
|
|
|
+ commandCode:form.value.commandCode,
|
|
|
+ commandValue:form.value.commandValue,
|
|
|
+ productCode:form.value.productCode,
|
|
|
+ deviceId:deviceId.value,
|
|
|
+ }
|
|
|
+ doorControl(params).then((res) => {
|
|
|
+ if (res.status == "SUCCESS") {
|
|
|
+ if (scanBool.value) {
|
|
|
+ proxy.$tab.reLaunch(`/pages/common/success/index?codeName=提交成功&showNow=${false}`);
|
|
|
+ } else {
|
|
|
+ proxy.$modal.msg("提交成功");
|
|
|
+ setTimeout(() => {
|
|
|
+ proxy.$tab.redirectTo("/pages/business/fireIot/deviceManage/index"); //返回到需要执行方法的页面
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch((errors) => {
|
|
|
+ // proxy.$modal.msg("校验失败");
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @action弹出框点击事件
|
|
|
+ */
|
|
|
+function handleAction(value, index, ind) {
|
|
|
+ if (value == "命令属性") {
|
|
|
+ actionTitle.value = "命令属性";
|
|
|
+ actionsList.value = [
|
|
|
+ form.value.commandDict
|
|
|
+ ];
|
|
|
+ if (form.value.commandDict) {
|
|
|
+ actionsList.value[0].forEach((el, ind) => {
|
|
|
+ if (el.value === form.value.commandValue) {
|
|
|
+ actionDefaultIndex.value = ind;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ actionDefaultIndex.value = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ actionShow.value = true;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @action弹出框选择事件
|
|
|
+ */
|
|
|
+function selectAction(e) {
|
|
|
+ if (actionTitle.value == "命令属性") {
|
|
|
+ form.value.commandValue = e.value[0].value;
|
|
|
+ form.value.commandName1 = e.value[0].name;
|
|
|
+ }
|
|
|
+ actionShow.value = false;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+onLoad((options) => {
|
|
|
+ if ("commandCode" in options) {
|
|
|
+ form.value.commandCode = options.commandCode;
|
|
|
+
|
|
|
+ }
|
|
|
+ if ("productCode" in options) {
|
|
|
+ form.value.productCode = options.productCode;
|
|
|
+ }
|
|
|
+ if ("deviceId" in options) {
|
|
|
+ deviceId.value = options.deviceId;
|
|
|
+ }
|
|
|
+ getData()
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
+onShow(() => {
|
|
|
+ //调用系统主题颜色
|
|
|
+ proxy.$settingStore.systemThemeColor([1]);
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.unitInfoCollection-container {
|
|
|
+ .centerOne,
|
|
|
+ .centerTwo {
|
|
|
+ .title {
|
|
|
+ color: #333333;
|
|
|
+ text-align: center;
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.u-picker__view__column__item) {
|
|
|
+ font-size: 13px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|