|
|
@@ -137,10 +137,33 @@
|
|
|
|
|
|
<!-- 设备档案弹窗 -->
|
|
|
<EquipPipeForm ref="EquipPipeFormRef" :selectedItem="selectedItem" :allReportList="allReportList" />
|
|
|
+
|
|
|
+ <!-- 设备选择弹窗 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="equipmentSelectDialogVisible"
|
|
|
+ title="选择设备"
|
|
|
+ width="600px"
|
|
|
+ >
|
|
|
+ <div class="equipment-list">
|
|
|
+ <div
|
|
|
+ v-for="equip in equipmentList"
|
|
|
+ :key="equip.id"
|
|
|
+ class="equipment-item"
|
|
|
+ @click="handleEquipmentClick(equip)"
|
|
|
+ >
|
|
|
+ {{ equip.projectNo }} - {{ equip.projectName }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="equipmentSelectDialogVisible = false">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import {onMounted, ref} from 'vue'
|
|
|
+import {onMounted, ref, onUnmounted} from 'vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import {
|
|
|
@@ -598,6 +621,30 @@ const handleVoidItem = async (item: ReportItemVO) => {
|
|
|
}
|
|
|
})();
|
|
|
|
|
|
+// 监听设备编辑成功事件
|
|
|
+const handleEquipmentEditSuccess = async () => {
|
|
|
+ console.log('收到设备编辑成功事件,同步报表')
|
|
|
+ try {
|
|
|
+ await PipeTaskOrderApi.syncAllReportDataByOrderId({
|
|
|
+ orderId: orderId.value
|
|
|
+ })
|
|
|
+ ElMessage.success('报表数据同步成功')
|
|
|
+ // 同步成功后刷新页面数据
|
|
|
+ await handleRefresh()
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步报表数据失败:', error)
|
|
|
+ ElMessage.error('同步报表数据失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 注册事件监听
|
|
|
+emitter.on('equipment-edit-success', handleEquipmentEditSuccess)
|
|
|
+
|
|
|
+// 组件卸载时移除监听器,避免重复调用
|
|
|
+onUnmounted(() => {
|
|
|
+ emitter.off('equipment-edit-success', handleEquipmentEditSuccess)
|
|
|
+})
|
|
|
+
|
|
|
watch(() => route.path, async () => {
|
|
|
if (route.path === '/gdjy/my-task/pipe/detail') {
|
|
|
const idFromQuery = route.query.id
|
|
|
@@ -614,8 +661,51 @@ watch(() => route.path, async () => {
|
|
|
|
|
|
// 设备档案弹窗
|
|
|
const EquipPipeFormRef = ref<InstanceType<typeof EquipPipeForm>>()
|
|
|
-const handleViewEquipment = () => {
|
|
|
- EquipPipeFormRef.value.open(orderId.value)
|
|
|
+const equipmentSelectDialogVisible = ref(false)
|
|
|
+const equipmentList = ref<any[]>([])
|
|
|
+
|
|
|
+const handleViewEquipment = async () => {
|
|
|
+ try {
|
|
|
+ // 获取订单关联的所有设备
|
|
|
+ const res = await PipeTaskOrderApi.getEquipsByOrderId(orderId.value)
|
|
|
+ equipmentList.value = res || []
|
|
|
+
|
|
|
+ if (equipmentList.value.length === 0) {
|
|
|
+ ElMessage.warning('暂无设备信息')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果只有一个设备,直接跳转到编辑页
|
|
|
+ if (equipmentList.value.length === 1) {
|
|
|
+ router.push({
|
|
|
+ name: 'PipeEquipmentForm',
|
|
|
+ query: {
|
|
|
+ type: 'update',
|
|
|
+ id: equipmentList.value[0].id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 如果有多个设备,显示选择弹窗
|
|
|
+ equipmentSelectDialogVisible.value = true
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取设备列表失败:', error)
|
|
|
+ ElMessage.error('获取设备列表失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleEquipmentClick = (equip: any) => {
|
|
|
+ equipmentSelectDialogVisible.value = false
|
|
|
+ // 延时300ms后再跳转,让弹窗关闭动画完成
|
|
|
+ setTimeout(() => {
|
|
|
+ router.push({
|
|
|
+ name: 'PipeEquipmentForm',
|
|
|
+ query: {
|
|
|
+ type: 'update',
|
|
|
+ id: equip.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, 300)
|
|
|
}
|
|
|
|
|
|
const toTaskOrderDetail = () => {
|
|
|
@@ -847,4 +937,28 @@ async function fetchTaskDetail(id: string, activeReportId = '') {
|
|
|
align-items: center;
|
|
|
gap: 12px;
|
|
|
}
|
|
|
+
|
|
|
+.equipment-list {
|
|
|
+ max-height: 400px;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.equipment-item {
|
|
|
+ padding: 12px 16px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ border: 1px solid var(--el-border-color);
|
|
|
+ border-radius: 4px;
|
|
|
+ cursor: pointer;
|
|
|
+ transition: all 0.3s;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ background-color: var(--el-color-primary-light-9);
|
|
|
+ border-color: var(--el-color-primary);
|
|
|
+ color: var(--el-color-primary);
|
|
|
+ }
|
|
|
+
|
|
|
+ &:last-child {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|