|
@@ -0,0 +1,311 @@
|
|
|
+<template>
|
|
|
+ <ContentWrap v-loading="formLoading">
|
|
|
+ <el-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="formData"
|
|
|
+ :rules="formRules"
|
|
|
+ v-loading="formLoading"
|
|
|
+ style="margin-right: 4em; margin-left: 0.5em; margin-top: 1em"
|
|
|
+ label-width="130px"
|
|
|
+ >
|
|
|
+ <div class="base-expandable-content">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="计划名称" prop="planTitle">
|
|
|
+ <el-input v-model="formData.routeName" placeholder="请输入计划名称" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="单位" prop="planUnit">
|
|
|
+ <el-select v-model="formData.planUnit" placeholder="请选择单位">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in getStrDictOptions(DICT_TYPE.PMS_INSPECT_UNIT)"
|
|
|
+ :key="dict.label"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="周期" prop="planCycle">
|
|
|
+ <el-input type="number" v-model="formData.planCycle" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="负责人" prop="charge">
|
|
|
+ <el-select v-model="formData.charge" multiple filterable clearable style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="item in deptUsers"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.nickname"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input type="textarea" v-model="formData.remark" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ </ContentWrap>
|
|
|
+ <ContentWrap>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <ContentWrap>
|
|
|
+ <ContentWrap>
|
|
|
+ <el-form
|
|
|
+ class="-mb-15px"
|
|
|
+ :model="queryParams"
|
|
|
+ ref="queryFormRef"
|
|
|
+ :inline="true"
|
|
|
+ label-width="68px"
|
|
|
+ >
|
|
|
+ <el-form-item>
|
|
|
+ <el-button @click="openForm" type="primary"
|
|
|
+ ><Icon icon="ep:plus" class="mr-5px" /> 选择巡检设备</el-button
|
|
|
+ >
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </ContentWrap>
|
|
|
+ <ContentWrap>
|
|
|
+ <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
+ <el-table-column label="资产编号" align="center" prop="deviceCode" />
|
|
|
+ <el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
|
+ <el-table-column label="路线名称" align="center" prop="routeName" />
|
|
|
+ <el-table-column label="操作" align="center" min-width="120px">
|
|
|
+ <template #default="scope">
|
|
|
+ <div style="display: flex; justify-content: center; align-items: center; width: 100%">
|
|
|
+ <div style="margin-right: 10px">
|
|
|
+ <Icon style="vertical-align: middle; color: #c36e5b" icon="ep:view" />
|
|
|
+ <el-button
|
|
|
+ style="vertical-align: middle"
|
|
|
+ link
|
|
|
+ type="warning"
|
|
|
+ @click="viewRoute(scope.row.itemJson)"
|
|
|
+ >
|
|
|
+ 巡检路线
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Icon style="vertical-align: middle; color: #ea3434" icon="ep:zoom-out" />
|
|
|
+ <el-button
|
|
|
+ style="vertical-align: middle"
|
|
|
+ link
|
|
|
+ type="danger"
|
|
|
+ @click="handleDelete(scope.row.code)"
|
|
|
+ >
|
|
|
+ 移除
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </ContentWrap>
|
|
|
+ </ContentWrap>
|
|
|
+ </ContentWrap>
|
|
|
+ <ContentWrap>
|
|
|
+ <el-form>
|
|
|
+ <el-form-item style="float: right">
|
|
|
+ <el-button @click="submitForm" type="primary" :disabled="formLoading">保 存</el-button>
|
|
|
+ <el-button @click="close">取 消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </ContentWrap>
|
|
|
+ <InspectItemList
|
|
|
+ ref="inspectItemFormRef"
|
|
|
+ :classify="formData.deviceClassify"
|
|
|
+ :deviceId="formData.deviceId"
|
|
|
+ @choose="inspectItemChoose"
|
|
|
+ />
|
|
|
+ <InspectRouteList ref="deviceFormRef" @choose="deviceChoose" />
|
|
|
+ <RouteInspectItemDrawer
|
|
|
+ ref="showDrawer"
|
|
|
+ :model-value="drawerVisible"
|
|
|
+ @update:model-value="(val) => (drawerVisible = val)"
|
|
|
+ />
|
|
|
+</template>
|
|
|
+<script setup lang="ts">
|
|
|
+import * as UserApi from '@/api/system/user'
|
|
|
+import { useUserStore } from '@/store/modules/user'
|
|
|
+import { ref } from 'vue'
|
|
|
+import { IotMaintainMaterialVO } from '@/api/pms/maintain/material'
|
|
|
+import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
|
+import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
|
+import { handleTree } from '@/utils/tree'
|
|
|
+import * as ProductClassifyApi from '@/api/pms/productclassify'
|
|
|
+import draggable from 'vuedraggable'
|
|
|
+import InspectItemList from '@/views/pms/inspect/route/InspectItemList.vue'
|
|
|
+import InspectRouteList from '@/views/pms/inspect/plan/InspectRouteList.vue'
|
|
|
+import { IotInspectRouteApi, IotInspectRouteVO } from '@/api/pms/inspect/route'
|
|
|
+import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
|
|
+import {IotInspectPlanApi} from "@/api/pms/inspect/plan";
|
|
|
+import RouteInspectItemDrawer from "@/views/pms/inspect/plan/RouteInspectItemDrawer.vue";
|
|
|
+
|
|
|
+
|
|
|
+/** 维修工单 表单 */
|
|
|
+defineOptions({ name: 'IotMaintainAe' })
|
|
|
+
|
|
|
+const { t } = useI18n() // 国际化
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
+const { delView } = useTagsViewStore() // 视图操作
|
|
|
+const { currentRoute, push } = useRouter()
|
|
|
+const dialogTitle = ref('') // 弹窗的标题
|
|
|
+const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
+const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
+const drawerVisible = ref<boolean>(false)
|
|
|
+const showDrawer = ref()
|
|
|
+const list = ref<IotInspectRouteVO[]>([]) // 列表的数据
|
|
|
+const { params, name } = useRoute() // 查询参数
|
|
|
+const id = params.id
|
|
|
+const productClassifyList = ref<Tree[]>([]) // 树形结构
|
|
|
+const deptUsers = ref<UserApi.UserVO[]>([]) // 用户列表
|
|
|
+const formData = ref({
|
|
|
+ id: undefined,
|
|
|
+ planTitle: undefined,
|
|
|
+ planCode: undefined,
|
|
|
+ planCycle: undefined,
|
|
|
+ planUnit: undefined,
|
|
|
+ charge: undefined,
|
|
|
+ deviceIds: undefined,
|
|
|
+ remark: undefined,
|
|
|
+ deptId: undefined
|
|
|
+})
|
|
|
+const formRules = reactive({
|
|
|
+ planTitle: [{ required: true, message: '巡检计划标题不能为空', trigger: 'blur' }],
|
|
|
+ planCode: [{ required: true, message: '巡检计划编号不能为空', trigger: 'blur' }],
|
|
|
+ planCycle: [{ required: true, message: '周期不能为空', trigger: 'blur' }],
|
|
|
+ planUnit: [{ required: true, message: '单位不能为空', trigger: 'blur' }],
|
|
|
+ charge: [{ required: true, message: '负责人不能为空', trigger: 'blur' }]
|
|
|
+})
|
|
|
+// 拖动状态管理
|
|
|
+const items = ref([])
|
|
|
+const deviceChoose = (rows) => {
|
|
|
+ // formData.value.deviceId = row.id
|
|
|
+ // formData.value.deviceName = row.deviceName
|
|
|
+ // formData.value.deptId = row.deptId
|
|
|
+ // deviceLabel.value = row.deviceName
|
|
|
+ list.value = rows
|
|
|
+}
|
|
|
+
|
|
|
+const viewRoute = (itemJson) => {
|
|
|
+ drawerVisible.value = true
|
|
|
+ showDrawer.value.openDrawer(itemJson)
|
|
|
+}
|
|
|
+const formRef = ref() // 表单 Ref
|
|
|
+const inspectItemChoose = (rows) => {
|
|
|
+ items.value = []
|
|
|
+ items.value = rows
|
|
|
+}
|
|
|
+const deviceFormRef = ref()
|
|
|
+const openForm = () => {
|
|
|
+ deviceFormRef.value.open()
|
|
|
+}
|
|
|
+
|
|
|
+const close = () => {
|
|
|
+ delView(unref(currentRoute))
|
|
|
+ push({
|
|
|
+ name: 'IotInspectRoute',
|
|
|
+ query: {
|
|
|
+ date: new Date().getTime()
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+const itemsWithIndex = computed(() => {
|
|
|
+ return items.value.map((item, index) => ({
|
|
|
+ itemId: item.id,
|
|
|
+ item: item.item,
|
|
|
+ standard: item.standard,
|
|
|
+ index: index + 1 // 序号从1开始
|
|
|
+ }))
|
|
|
+})
|
|
|
+const { wsCache } = useCache()
|
|
|
+/** 提交表单 */
|
|
|
+const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
+const submitForm = async () => {
|
|
|
+ // 校验表单
|
|
|
+ await formRef.value.validate()
|
|
|
+ // 提交请求
|
|
|
+ formLoading.value = true
|
|
|
+ try {
|
|
|
+ const newitems = itemsWithIndex
|
|
|
+ debugger
|
|
|
+ formData.value.itemJson = JSON.stringify(newitems.value)
|
|
|
+ const user = wsCache.get(CACHE_KEY.USER)
|
|
|
+ formData.value.deptId = user.user.deptId
|
|
|
+ const data = formData.value as unknown as IotInspectRouteVO
|
|
|
+ if (formType.value === 'create') {
|
|
|
+ await IotInspectRouteApi.createIotInspectRoute(data)
|
|
|
+ message.success(t('common.createSuccess'))
|
|
|
+ close()
|
|
|
+ } else {
|
|
|
+ await IotInspectRouteApi.updateIotInspectRoute(data)
|
|
|
+ message.success(t('common.updateSuccess'))
|
|
|
+ close()
|
|
|
+ }
|
|
|
+ // 发送操作成功的事件
|
|
|
+ emit('success')
|
|
|
+ } finally {
|
|
|
+ formLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置表单 */
|
|
|
+const resetForm = () => {
|
|
|
+ formData.value = {
|
|
|
+ id: undefined,
|
|
|
+ failureCode: undefined,
|
|
|
+ failureName: undefined,
|
|
|
+ deviceId: undefined,
|
|
|
+ status: undefined,
|
|
|
+ ifStop: undefined,
|
|
|
+ failureTime: undefined,
|
|
|
+ failureInfluence: undefined,
|
|
|
+ failureSystem: undefined,
|
|
|
+ description: undefined,
|
|
|
+ pic: undefined,
|
|
|
+ solution: undefined,
|
|
|
+ maintainStartTime: undefined,
|
|
|
+ maintainEndTime: undefined,
|
|
|
+ remark: undefined,
|
|
|
+ deviceName: undefined,
|
|
|
+ processInstanceId: undefined,
|
|
|
+ auditStatus: undefined,
|
|
|
+ deptId: undefined
|
|
|
+ }
|
|
|
+ formRef.value?.resetFields()
|
|
|
+}
|
|
|
+onMounted(async () => {
|
|
|
+ const deptId = useUserStore().getUser.deptId
|
|
|
+ deptUsers.value = await UserApi.getDeptUsersByDeptId(deptId)
|
|
|
+ if (id) {
|
|
|
+ formType.value = 'update'
|
|
|
+ const iotInspectRoute = await IotInspectPlanApi.getIotInspectPlan(id)
|
|
|
+ formData.value = iotInspectRoute
|
|
|
+ items.value = JSON.parse(iotInspectRoute.itemJson)
|
|
|
+ } else {
|
|
|
+ formData.value.type = 'in'
|
|
|
+ formType.value = 'create'
|
|
|
+ }
|
|
|
+})
|
|
|
+const handleDelete = async (id: number) => {
|
|
|
+ try {
|
|
|
+ const index = list.value.findIndex((item) => item.code === id)
|
|
|
+ if (index !== -1) {
|
|
|
+ // 通过 splice 删除元素
|
|
|
+ list.value.splice(index, 1)
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style scoped>
|
|
|
+.base-expandable-content {
|
|
|
+ overflow: hidden; /* 隐藏溢出的内容 */
|
|
|
+ transition: max-height 0.3s ease; /* 平滑过渡效果 */
|
|
|
+}
|
|
|
+/* 横向布局容器 */
|
|
|
+</style>
|