一单四制优化及加入工作流
This commit is contained in:
@@ -4,16 +4,16 @@
|
||||
<scroll-view class="status-tabs" scroll-x :show-scrollbar="false">
|
||||
<view class="status-tabs-inner">
|
||||
<view v-for="(tab, index) in statusTabs" :key="index" class="status-tab-item"
|
||||
:class="{ 'status-tab-active': activeTab === index }" @click="activeTab = index">
|
||||
:class="{ 'status-tab-active': activeTab === index }" @click="switchStatusTab(index)">
|
||||
<text class="status-tab-text">{{ tab.label }}</text>
|
||||
<view v-if="activeTab === index" class="status-tab-bar"></view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view v-if="filteredList.length === 0" class="empty-tip text-gray text-center padding">暂无数据</view>
|
||||
<view v-if="hiddenDangerList.length === 0 && !listLoading" class="empty-tip text-gray text-center padding">暂无数据</view>
|
||||
|
||||
<view class="padding radius bg-white list-list margin-bottom" v-for="item in filteredList"
|
||||
<view class="padding radius bg-white list-list margin-bottom" v-for="item in hiddenDangerList"
|
||||
:key="item.hazardId">
|
||||
<view class="flex justify-between margin-bottom">
|
||||
<view class="text-bold text-black" style="word-break: break-all; flex: 1;">{{item.title}}</view>
|
||||
@@ -43,12 +43,22 @@
|
||||
class="round cu-btn bg-blue" @click="Rectification(item)">立即整改</button>
|
||||
<button v-if="item.statusName === '待验收' && item.canEdit"
|
||||
class="round cu-btn light bg-blue" @click="editRectification(item)">编辑整改信息</button>
|
||||
<button v-if="item.statusName === '待验收' && canAcceptance"
|
||||
<button v-if="canShowAcceptanceButton(item, userRole)"
|
||||
class="round cu-btn bg-blue" @click="acceptance(item)">立即验收</button>
|
||||
<button v-if="item.statusName === '待交办'"
|
||||
class="round cu-btn bg-blue" @click="assignHazard(item)">隐患交办</button>
|
||||
<button v-if="canShowWriteoffApplyButton(item)"
|
||||
class="round cu-btn bg-blue" @click="goWriteoffApply(item)">销号申请</button>
|
||||
<button v-if="canShowWriteoffApprovalButton(item, userRole)"
|
||||
class="round cu-btn bg-blue" @click="goWriteoffApproval(item)">销号审批</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<u-loadmore
|
||||
v-if="hiddenDangerList.length > 0"
|
||||
:status="loadStatus"
|
||||
style="margin-top: 20rpx; margin-bottom: 140rpx;"
|
||||
/>
|
||||
|
||||
<view class="fixed-add-btn" @click="goToAdd">
|
||||
<text class="cuIcon-add"></text>
|
||||
@@ -58,35 +68,42 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
|
||||
import {
|
||||
enterCheckPlan,
|
||||
getCheckTaskDetail,
|
||||
getMyHiddenDangerList
|
||||
} from '@/request/api.js'
|
||||
import {
|
||||
buildRectificationUrl,
|
||||
buildEditRectificationUrl,
|
||||
buildAssignmentUrl,
|
||||
buildAcceptanceUrl,
|
||||
buildWriteoffApplyUrl,
|
||||
buildWriteoffApprovalUrl,
|
||||
canShowAcceptanceButton,
|
||||
canShowWriteoffApplyButton,
|
||||
canShowWriteoffApprovalButton
|
||||
} from '@/utils/hazardNav.js'
|
||||
import { resolveUserRoleKey } from '@/utils/userInfo.js'
|
||||
|
||||
const taskId = ref('')
|
||||
const checkPointId = ref('')
|
||||
const oneTableId = ref('')
|
||||
|
||||
const userRole = ref('')
|
||||
const canAcceptance = computed(() => {
|
||||
return userRole.value === 'admin' || userRole.value === 'manage'
|
||||
})
|
||||
|
||||
const getUserRole = () => {
|
||||
try {
|
||||
const userInfoStr = uni.getStorageSync('userInfo')
|
||||
if (userInfoStr) {
|
||||
const userInfo = JSON.parse(userInfoStr)
|
||||
userRole.value = userInfo.role || ''
|
||||
userRole.value = resolveUserRoleKey(JSON.parse(userInfoStr))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
}
|
||||
getUserRole()
|
||||
|
||||
const fetchTaskInfo = async (oneTableId) => {
|
||||
try {
|
||||
@@ -105,19 +122,82 @@
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
getUserRole()
|
||||
if (options.id) {
|
||||
oneTableId.value = options.id
|
||||
fetchTaskInfo(options.id)
|
||||
}
|
||||
})
|
||||
|
||||
const HAZARD_PAGE_SIZE = 10
|
||||
const hiddenDangerList = ref([])
|
||||
const pageNum = ref(1)
|
||||
const listLoading = ref(false)
|
||||
const loadStatus = ref('loadmore')
|
||||
|
||||
const statusTabs = ref([
|
||||
{ label: '全部', value: null },
|
||||
{ label: '待交办', value: 1 },
|
||||
{ label: '待整改', value: 2 },
|
||||
{ label: '待验收', value: 3 },
|
||||
{ label: '待销号', value: 4 },
|
||||
{ label: '已完成', value: 5 }
|
||||
])
|
||||
const activeTab = ref(0)
|
||||
|
||||
const buildListParams = () => {
|
||||
const params = {
|
||||
pageNum: pageNum.value,
|
||||
pageSize: HAZARD_PAGE_SIZE
|
||||
}
|
||||
const currentTab = statusTabs.value[activeTab.value]
|
||||
if (currentTab?.value != null) {
|
||||
params.status = currentTab.value
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
const resetHiddenDangerList = () => {
|
||||
pageNum.value = 1
|
||||
hiddenDangerList.value = []
|
||||
loadStatus.value = 'loadmore'
|
||||
}
|
||||
|
||||
const switchStatusTab = (index) => {
|
||||
if (activeTab.value === index) return
|
||||
activeTab.value = index
|
||||
resetHiddenDangerList()
|
||||
fetchHiddenDangerList()
|
||||
}
|
||||
|
||||
const fetchHiddenDangerList = async () => {
|
||||
if (listLoading.value) return
|
||||
if (pageNum.value > 1 && loadStatus.value === 'nomore') return
|
||||
|
||||
listLoading.value = true
|
||||
if (pageNum.value > 1) {
|
||||
loadStatus.value = 'loading'
|
||||
}
|
||||
try {
|
||||
const res = await getMyHiddenDangerList()
|
||||
const res = await getMyHiddenDangerList(buildListParams())
|
||||
if (res.code === 0) {
|
||||
hiddenDangerList.value = res.data.records
|
||||
const records = res.data?.records || []
|
||||
const total = Number(res.data?.total ?? 0)
|
||||
if (pageNum.value === 1) {
|
||||
hiddenDangerList.value = records
|
||||
} else {
|
||||
hiddenDangerList.value = [...hiddenDangerList.value, ...records]
|
||||
}
|
||||
if (hiddenDangerList.value.length >= total || records.length < HAZARD_PAGE_SIZE) {
|
||||
loadStatus.value = 'nomore'
|
||||
} else {
|
||||
loadStatus.value = 'loadmore'
|
||||
}
|
||||
} else {
|
||||
if (pageNum.value === 1) {
|
||||
hiddenDangerList.value = []
|
||||
}
|
||||
loadStatus.value = 'nomore'
|
||||
uni.showToast({
|
||||
title: res.msg || '获取隐患列表失败',
|
||||
icon: 'none'
|
||||
@@ -125,15 +205,33 @@
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
if (pageNum.value > 1) {
|
||||
pageNum.value--
|
||||
}
|
||||
loadStatus.value = 'loadmore'
|
||||
uni.showToast({
|
||||
title: '请求失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
listLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
const loadMoreHiddenDangerList = () => {
|
||||
if (loadStatus.value !== 'loadmore' || listLoading.value) return
|
||||
pageNum.value++
|
||||
fetchHiddenDangerList()
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getUserRole()
|
||||
resetHiddenDangerList()
|
||||
fetchHiddenDangerList()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
loadMoreHiddenDangerList()
|
||||
})
|
||||
|
||||
const goToAdd = () => {
|
||||
@@ -156,59 +254,33 @@
|
||||
|
||||
const details = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/detail2?hazardId=${item.hazardId}&assignId=${item.assignId || ''}`
|
||||
url: `/pages/hiddendanger/process-chain?hazardId=${item.hazardId}`
|
||||
})
|
||||
}
|
||||
|
||||
const Rectification = (item) => {
|
||||
let url = `/pages/hiddendanger/rectification?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
||||
if (item.deadline) {
|
||||
url += `&deadline=${encodeURIComponent(item.deadline)}`
|
||||
}
|
||||
if (item.assigneeId) {
|
||||
url += `&assigneeId=${item.assigneeId}`
|
||||
}
|
||||
if (item.assigneeName) {
|
||||
url += `&assigneeName=${encodeURIComponent(item.assigneeName)}`
|
||||
}
|
||||
uni.navigateTo({ url })
|
||||
uni.navigateTo({ url: buildRectificationUrl(item) });
|
||||
}
|
||||
|
||||
const editRectification = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/rectification?rectifyId=${item.rectifyId}&isEdit=1`
|
||||
})
|
||||
uni.navigateTo({ url: buildEditRectificationUrl(item) });
|
||||
}
|
||||
|
||||
const acceptance = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/acceptance?hazardId=${item.hazardId}&assignId=${item.assignId}&rectifyId=${item.rectifyId}`
|
||||
})
|
||||
uni.navigateTo({ url: buildAcceptanceUrl(item) });
|
||||
}
|
||||
|
||||
const assignHazard = (item) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/hiddendanger/assignment?hazardId=${item.hazardId}&assignId=${item.assignId}`
|
||||
})
|
||||
uni.navigateTo({ url: buildAssignmentUrl(item) });
|
||||
}
|
||||
|
||||
const statusTabs = ref([
|
||||
{ label: '全部', value: null },
|
||||
{ label: '待交办', value: 1 },
|
||||
{ label: '待整改', value: 2 },
|
||||
{ label: '待验收', value: 3 },
|
||||
{ label: '待销号', value: 4 },
|
||||
{ label: '已完成', value: 5 }
|
||||
])
|
||||
const activeTab = ref(0)
|
||||
const goWriteoffApply = (item) => {
|
||||
uni.navigateTo({ url: buildWriteoffApplyUrl(item) });
|
||||
}
|
||||
|
||||
const filteredList = computed(() => {
|
||||
const currentTab = statusTabs.value[activeTab.value]
|
||||
if (!currentTab || currentTab.value === null) {
|
||||
return hiddenDangerList.value
|
||||
}
|
||||
return hiddenDangerList.value.filter(item => item.status === currentTab.value)
|
||||
})
|
||||
const goWriteoffApproval = (item) => {
|
||||
uni.navigateTo({ url: buildWriteoffApprovalUrl(item) });
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user