| | |
| | | <template> |
| | | <view class="inspection-management-page"> |
| | | <PageHeader title="巡检任务管理" |
| | | <PageHeader title="定时任务管理" |
| | | @back="goBack" /> |
| | | <view class="toolbar"> |
| | | <view class="tab-wrap"> |
| | | <view v-for="tab in tabs" |
| | | :key="tab.name" |
| | | class="tab-item" |
| | | :class="{ active: activeTab === tab.name }" |
| | | @click="switchTab(tab.name)"> |
| | | {{ tab.label }} |
| | | </view> |
| | | </view> |
| | | <view class="search-section"> |
| | | <view class="search-bar"> |
| | | <view class="search-input"> |
| | |
| | | <uni-swipe-action> |
| | | <uni-swipe-action-item v-for="item in tableData" |
| | | :key="item.id" |
| | | :right-options="activeTab === 'taskManage' ? swipeOptions : []" |
| | | :disabled="activeTab !== 'taskManage'" |
| | | :right-options="swipeOptions" |
| | | @click="onSwipeActionClick($event, item)"> |
| | | <view class="ledger-item"> |
| | | <view class="item-header"> |
| | |
| | | </view> |
| | | <up-divider></up-divider> |
| | | <view class="card-actions"> |
| | | <u-button v-if="activeTab === 'taskManage'" |
| | | type="primary" |
| | | <u-button type="primary" |
| | | size="small" |
| | | class="action-btn" |
| | | @click.stop="handleAdd(item)">编辑</u-button> |
| | | <u-button v-else |
| | | type="success" |
| | | <u-button type="error" |
| | | size="small" |
| | | plain |
| | | class="action-btn" |
| | | @click.stop="viewFile(item)">查看附件</u-button> |
| | | @click.stop="deleteOne(item)">删除</u-button> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | <text>暂无数据</text> |
| | | </view> |
| | | </view> |
| | | <view v-if="activeTab === 'taskManage'" |
| | | class="fab-button" |
| | | <view class="fab-button" |
| | | @click="handleAdd()"> |
| | | <up-icon name="plus" |
| | | size="24" |
| | |
| | | </view> |
| | | <form-dia ref="formDia" |
| | | @closeDia="handleQuery" /> |
| | | <view-files ref="viewFiles" /> |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | import { onShow, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import FormDia from "@/pages/inspectionManagement/components/formDia.vue"; |
| | | import ViewFiles from "@/pages/inspectionManagement/components/viewFiles.vue"; |
| | | import { |
| | | delTimingTask, |
| | | inspectionTaskList, |
| | | timingTaskList, |
| | | } from "@/api/inspectionManagement/index.js"; |
| | | |
| | | const formDia = ref(); |
| | | const viewFiles = ref(); |
| | | const activeTab = ref("taskManage"); |
| | | const tabs = [ |
| | | { name: "taskManage", label: "定时任务管理" }, |
| | | { name: "task", label: "定时任务记录" }, |
| | | ]; |
| | | const queryParams = reactive({ |
| | | taskName: "", |
| | | }); |
| | |
| | | return [String(val)]; |
| | | }; |
| | | |
| | | const switchTab = tabName => { |
| | | if (activeTab.value === tabName) return; |
| | | activeTab.value = tabName; |
| | | handleQuery(); |
| | | }; |
| | | |
| | | const getList = async () => { |
| | | if (loading.value) return; |
| | | loading.value = true; |
| | |
| | | current: pageParams.current, |
| | | size: pageParams.size, |
| | | }; |
| | | const request = activeTab.value === "task" ? inspectionTaskList : timingTaskList; |
| | | const res = await request(params); |
| | | const res = await timingTaskList(params); |
| | | const records = res?.data?.records || []; |
| | | const normalized = records.map(item => ({ |
| | | ...item, |
| | |
| | | }); |
| | | }; |
| | | |
| | | const viewFile = row => { |
| | | nextTick(() => { |
| | | viewFiles.value?.openDialog(row); |
| | | }); |
| | | }; |
| | | |
| | | const deleteOne = async row => { |
| | | if (!row?.id) return; |
| | | const canDelete = await new Promise(resolve => { |
| | |
| | | }; |
| | | |
| | | const onSwipeActionClick = (event, row) => { |
| | | if (activeTab.value !== "taskManage") return; |
| | | if (event?.position !== "right") return; |
| | | deleteOne(row); |
| | | }; |
| | |
| | | z-index: 10; |
| | | } |
| | | |
| | | .tab-wrap { |
| | | display: flex; |
| | | background: #f4f5f8; |
| | | border-radius: 16rpx; |
| | | padding: 6rpx; |
| | | } |
| | | |
| | | .tab-item { |
| | | flex: 1; |
| | | text-align: center; |
| | | padding: 14rpx 0; |
| | | font-size: 26rpx; |
| | | color: #666; |
| | | border-radius: 12rpx; |
| | | } |
| | | |
| | | .tab-item.active { |
| | | background: #1677ff; |
| | | color: #fff; |
| | | font-weight: 600; |
| | | } |
| | | |
| | | .search-section { |
| | | margin-top: 20rpx; |
| | | margin-top: 0; |
| | | } |
| | | |
| | | .search-bar { |