|
@@ -17,7 +17,7 @@
|
|
|
<view class="info-column">
|
|
|
<label-text
|
|
|
label="所属产品"
|
|
|
- :text="formatTxt(state.deviceInfo.productName)"
|
|
|
+ :text="formatTxt(state.deviceInfo.productName)"
|
|
|
/>
|
|
|
<label-text
|
|
|
label="设备编码"
|
|
@@ -105,10 +105,127 @@
|
|
|
:placeholder="false"
|
|
|
:safeAreaInsetBottom="false"
|
|
|
>
|
|
|
- <view class="warning-btn">报废</view>
|
|
|
- <view class="def-btn">禁用</view>
|
|
|
- <view class="def-btn">编辑</view>
|
|
|
+ <view class="warning-btn" @click="state.handleForm=true">报废</view>
|
|
|
+ <view class="def-btn"
|
|
|
+ v-if="DeviceState.UNACTIVATED.value !== state.deviceInfo.status"
|
|
|
+ @click="state.showDisableModal = true">禁用
|
|
|
+ </view>
|
|
|
+ <view
|
|
|
+ class="def-btn"
|
|
|
+ v-if="DeviceState.UNACTIVATED.value === state.deviceInfo.status"
|
|
|
+ @click="state.showEnableModal = true"
|
|
|
+ >激活
|
|
|
+ </view>
|
|
|
</up-tabbar>
|
|
|
+ <up-action-sheet
|
|
|
+ :show="state.handleForm"
|
|
|
+ @close="state.handleForm = false"
|
|
|
+ title="报废设备"
|
|
|
+ :round="10"
|
|
|
+ >
|
|
|
+ <view class="action-content common-form">
|
|
|
+ <up-form
|
|
|
+ labelPosition="left"
|
|
|
+ :model="state.model"
|
|
|
+ :rules="state.rules"
|
|
|
+ ref="formRef"
|
|
|
+ labelWidth="120"
|
|
|
+ >
|
|
|
+ <up-form-item
|
|
|
+ label="设备名称"
|
|
|
+ borderBottom
|
|
|
+ :required="true"
|
|
|
+ >
|
|
|
+ <up-input
|
|
|
+ :modelValue="state.deviceInfo.deviceNickname"
|
|
|
+ border="none"
|
|
|
+ disabled
|
|
|
+ ></up-input>
|
|
|
+ </up-form-item>
|
|
|
+ <up-form-item
|
|
|
+ label="设备编码"
|
|
|
+ borderBottom
|
|
|
+ :required="true"
|
|
|
+ >
|
|
|
+ <up-input
|
|
|
+ :modelValue="state.deviceInfo.name"
|
|
|
+ border="none"
|
|
|
+ disabled
|
|
|
+ ></up-input>
|
|
|
+ </up-form-item>
|
|
|
+
|
|
|
+ <up-form-item
|
|
|
+ label="报废时间"
|
|
|
+ prop="order.startDate"
|
|
|
+ borderBottom
|
|
|
+ :required="true"
|
|
|
+ @click="state.showStartClendar = true; hideKeyboard()"
|
|
|
+ >
|
|
|
+ <up-input
|
|
|
+ :modelValue="timestampToDate(state.model.order.startDate)"
|
|
|
+ disabled
|
|
|
+ disabledColor="#ffffff"
|
|
|
+ placeholder="请选择预计开始日期"
|
|
|
+ border="none"
|
|
|
+ ></up-input>
|
|
|
+ <template #right>
|
|
|
+ <up-icon
|
|
|
+ name="arrow-right"
|
|
|
+ ></up-icon>
|
|
|
+ </template>
|
|
|
+ </up-form-item>
|
|
|
+ <up-form-item
|
|
|
+ label="报废原因"
|
|
|
+ borderBottom
|
|
|
+ >
|
|
|
+ <up-textarea
|
|
|
+ placeholder="报废原因"
|
|
|
+ v-model="state.model.order.desc"
|
|
|
+ ></up-textarea>
|
|
|
+ </up-form-item>
|
|
|
+ <up-button @click="submit" style="margin-top: 20rpx;">提交</up-button>
|
|
|
+ </up-form>
|
|
|
+ </view>
|
|
|
+ </up-action-sheet>
|
|
|
+
|
|
|
+ <up-modal
|
|
|
+ :show="state.showDisableModal"
|
|
|
+ title="禁用设备"
|
|
|
+ :closeOnClickOverlay="true"
|
|
|
+ :showCancelButton="true"
|
|
|
+ @close="state.showDisableModal = false"
|
|
|
+ @cancel="state.showDisableModal = false"
|
|
|
+ @confirm="onConfirmDisable"
|
|
|
+ >
|
|
|
+ <view class="modal-content">
|
|
|
+ 设备禁用后将导致该设备无法连接
|
|
|
+ </view>
|
|
|
+ </up-modal>
|
|
|
+
|
|
|
+ <up-modal
|
|
|
+ :show="state.showEnableModal"
|
|
|
+ title="启用设备"
|
|
|
+ :closeOnClickOverlay="true"
|
|
|
+ :showCancelButton="true"
|
|
|
+ @close="state.showEnableModal = false"
|
|
|
+ @cancel="state.showEnableModal = false"
|
|
|
+ @confirm="onConfirmEnable"
|
|
|
+ >
|
|
|
+ <view class="modal-content">
|
|
|
+ 设备禁用后将导致该设备无法连接
|
|
|
+ </view>
|
|
|
+ </up-modal>
|
|
|
+
|
|
|
+ <up-datetime-picker
|
|
|
+ :show="state.showStartClendar"
|
|
|
+ v-model="state.model.order.startDate"
|
|
|
+ mode="datetime"
|
|
|
+ @close="state.showStartClendar = false"
|
|
|
+ :closeOnClickOverlay="true"
|
|
|
+ @confirm="(e)=>confirm(e,'showStartClendar')"
|
|
|
+ @cancel="state.showStartClendar = false"
|
|
|
+ ></up-datetime-picker>
|
|
|
+ <up-toast ref="uToastRef"></up-toast>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -118,20 +235,35 @@ import list from "@/static/aiot/list.svg";
|
|
|
import Panel from "@/components/pannel/index.vue";
|
|
|
import LabelText from "@/components/labeltext/index.vue";
|
|
|
import {onMounted, reactive, ref} from 'vue';
|
|
|
-import {getDeviceDetail, getDeviceMeta} from "@/api/device.js";
|
|
|
+import {forbidDevice, getDeviceDetail, getDeviceMeta, scrapDevice, startDevice} from "@/api/device.js";
|
|
|
import {onLoad} from "@dcloudio/uni-app";
|
|
|
-import {formatTxt, getDevImg} from "@/util/index.js";
|
|
|
+import {DateFormat, formatTxt, getDevImg, hideKeyboard, reloadPage, timestampToDate} from "@/util/index.js";
|
|
|
import {valueToConst} from "@/common/consts/CommonConst.js";
|
|
|
import {DeviceState} from "@/common/consts/DeviceConst.js";
|
|
|
+import dayjs from "dayjs";
|
|
|
|
|
|
+const uToastRef = ref(null)
|
|
|
const state = reactive({
|
|
|
+ handleForm: false,
|
|
|
+ showDisableModal: false,
|
|
|
+ showEnableModal: false,
|
|
|
deviceInfo: {},
|
|
|
metaInfo: {
|
|
|
dataMetaRunInfo: [],
|
|
|
dataOnlineRunInfo: [],
|
|
|
},
|
|
|
+ model: {
|
|
|
+ order: {
|
|
|
+ startDate: dayjs().valueOf(),
|
|
|
+ desc: '',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ 'order.startDate': [
|
|
|
+ {required: true, message: '请选择报废日期'},
|
|
|
+ ],
|
|
|
+ },
|
|
|
});
|
|
|
-const metaInfo = reactive({});
|
|
|
const deviceId = ref('')
|
|
|
onLoad((option) => {
|
|
|
deviceId.value = option.id
|
|
@@ -149,6 +281,46 @@ onMounted(() => {
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
+const onConfirmDisable = () => {
|
|
|
+ forbidDevice([deviceId.value]).then(() => {
|
|
|
+ uni.showToast({title: '操作成功', icon: "success"});
|
|
|
+ state.showDisableModal = false;
|
|
|
+ })
|
|
|
+};
|
|
|
+const onConfirmEnable = () => {
|
|
|
+ state.showEnableModal = false;
|
|
|
+ startDevice([deviceId.value]).then(() => {
|
|
|
+ uni.showToast({title: '操作成功', icon: "success"});
|
|
|
+ state.showEnableModal = false;
|
|
|
+ })
|
|
|
+}
|
|
|
+const confirm = (e, type) => {
|
|
|
+ state[type] = false;
|
|
|
+};
|
|
|
+const submit = () => {
|
|
|
+ hideKeyboard()
|
|
|
+ let formData = {
|
|
|
+ id: deviceId.value,
|
|
|
+ isScrap: true,
|
|
|
+ scrapReason: state.model.order.desc,
|
|
|
+ scrapTimeStr: timestampToDate(state.model.order.startDate, DateFormat.YYYYMMDDHHMMSS),
|
|
|
+ };
|
|
|
+
|
|
|
+ scrapDevice(formData).then(() => {
|
|
|
+ state.handleForm = false;
|
|
|
+ uToastRef.value.show({
|
|
|
+ type: 'default',
|
|
|
+ message: "操作成功",
|
|
|
+ complete() {
|
|
|
+ uni.$emit('refreshData', {refresh: true});
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
|
|
@@ -230,5 +402,9 @@ onMounted(() => {
|
|
|
align-items: center;
|
|
|
justify-content: space-between;
|
|
|
}
|
|
|
+
|
|
|
+ .action-content {
|
|
|
+ padding: 0 $uni-pop-padding;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|