|
|
@@ -293,6 +293,21 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <view v-if="showSelectTemplatePopup" class="popup-overlay" @click="closeSelectTemplatePopup">
|
|
|
+ <view class="popup-content" @click.stop>
|
|
|
+ <text class="popup-title">选择模板</text>
|
|
|
+ <picker :range="templateList" range-key="label" @change="onTemplateChange">
|
|
|
+ <view class="picker-value">
|
|
|
+ <text>{{ selectedTemplate?.label || '请选择' }}</text>
|
|
|
+ </view>
|
|
|
+ </picker>
|
|
|
+ <view class="popup-actions">
|
|
|
+ <button class="action-btn cancel-btn" @click="closeSelectTemplatePopup">取消</button>
|
|
|
+ <button class="action-btn confirm-btn" @click="handleConfirmTemplate">确定</button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -304,12 +319,14 @@ import {
|
|
|
PressureCheckerMyTaskStatusMap,
|
|
|
} from '@/utils/dictMap'
|
|
|
import { isCheckItemEditable, isAssignedToOthers } from '@/utils/equipmentPermissions'
|
|
|
-import { getApprovalDetail, getUserGroupUserList } from '@/api/task'
|
|
|
+import { getApprovalDetail, getUserGroupUserList, notVerifyPageApi, addMajorIssuesApi } from '@/api/task'
|
|
|
+import { getReportTemplateDetail } from '@/api'
|
|
|
import TipsPopup from './inspectProjectComponent/TipsPopup.vue'
|
|
|
import CalcCheckItemPopup from './inspectProject/component/calcCheckItemPopup.vue'
|
|
|
import ExchangeChecker from './inspectProject/component/ExchangeChecker.vue'
|
|
|
import UpdateConclusionPopup from './inspectProject/component/UpdateConclusionPopup.vue'
|
|
|
import eventBus from '@/utils/eventBus'
|
|
|
+import dayjs from 'dayjs'
|
|
|
|
|
|
interface CheckConclusionItem {
|
|
|
value: string
|
|
|
@@ -344,6 +361,7 @@ interface Props {
|
|
|
}
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
+ reportList: () => [],
|
|
|
useOnline: '1',
|
|
|
isMainChecker: false,
|
|
|
canModifyAssignments: false,
|
|
|
@@ -378,6 +396,10 @@ const currentReportItem = ref<any>(null)
|
|
|
const recheckUserGroupList = ref<any[]>([])
|
|
|
const currentReckUser = ref<any>(null)
|
|
|
|
|
|
+const showSelectTemplatePopup = ref(false)
|
|
|
+const templateList = ref<any[]>([])
|
|
|
+const selectedTemplate = ref<any>(null)
|
|
|
+
|
|
|
const userInfo = computed(() => uni.getStorageSync('userInfo'))
|
|
|
|
|
|
const canModifyChecker = computed(() => {
|
|
|
@@ -550,9 +572,10 @@ const getStatusColor = (item: CheckItem, useOnline?: string): string => {
|
|
|
|
|
|
const shouldShowFeeInput = (item: CheckItem): boolean => {
|
|
|
if (props.useOnline === '1') {
|
|
|
- return item.taskStatus !== undefined
|
|
|
+ return item.taskStatus !== undefined &&
|
|
|
+ [PressureReportType.MAIN, PressureReportType.SUB, PressureReportType.SINGLE].includes(item.reportType)
|
|
|
}
|
|
|
- return true
|
|
|
+ return [PressureReportType.MAIN, PressureReportType.SUB, PressureReportType.SINGLE].includes(item.reportType)
|
|
|
}
|
|
|
|
|
|
const shouldShowSign = (item: CheckItem): boolean => {
|
|
|
@@ -877,25 +900,199 @@ const handleAssociationOperation = (item: CheckItem) => {
|
|
|
}
|
|
|
|
|
|
const showAddWorkInstructionPopup = async () => {
|
|
|
- uni.showToast({ title: '添加指导书功能开发中', icon: 'none' })
|
|
|
+ try {
|
|
|
+ const result = await notVerifyPageApi({ type: '5', status: 200, pageNo: 1, pageSize: 9999 })
|
|
|
+ const list = (result?.data?.list || []).map((item: any) => ({
|
|
|
+ ...item,
|
|
|
+ label: item.name || '',
|
|
|
+ value: item.id || ''
|
|
|
+ }))
|
|
|
+
|
|
|
+ if (!list.length) {
|
|
|
+ uni.showToast({ title: '暂无指导书模板', icon: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ templateList.value = list
|
|
|
+ selectedTemplate.value = null
|
|
|
+ showSelectTemplatePopup.value = true
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取操作指导书模板失败:', error)
|
|
|
+ uni.showToast({ title: '获取操作指导书模板失败', icon: 'error' })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const closeSelectTemplatePopup = () => {
|
|
|
+ showSelectTemplatePopup.value = false
|
|
|
+ selectedTemplate.value = null
|
|
|
+}
|
|
|
+
|
|
|
+const onTemplateChange = (e: any) => {
|
|
|
+ const index = e.detail.value
|
|
|
+ selectedTemplate.value = templateList.value[index]
|
|
|
+}
|
|
|
+
|
|
|
+const handleConfirmTemplate = async () => {
|
|
|
+ if (!selectedTemplate.value) {
|
|
|
+ uni.showToast({ title: '请选择模板', icon: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ uni.showLoading({ title: '添加中...' })
|
|
|
+
|
|
|
+ const templateResult = await getReportTemplateDetail({ id: selectedTemplate.value.value })
|
|
|
+ const initTemplateJson = templateResult?.data?.reportDefaultJson
|
|
|
+ ? JSON.parse(templateResult?.data?.reportDefaultJson || '{}')
|
|
|
+ : {}
|
|
|
+
|
|
|
+ const defaultDataSource: Record<string, any> = {
|
|
|
+ ...initTemplateJson,
|
|
|
+ ...props.equipment,
|
|
|
+ prepareName: userInfo.value?.nickname || '',
|
|
|
+ prepareDate: dayjs().format('YYYY年MM月DD日')
|
|
|
+ }
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ orderId: props.orderId,
|
|
|
+ orderItemId: props.orderItemId,
|
|
|
+ userGroupCategory: selectedTemplate.value?.userGroupCategory || '',
|
|
|
+ templateId: selectedTemplate.value.value,
|
|
|
+ prepareId: userInfo.value?.id || '',
|
|
|
+ prepareName: userInfo.value?.nickname || '',
|
|
|
+ prepareJson: JSON.stringify(defaultDataSource)
|
|
|
+ }
|
|
|
+
|
|
|
+ const result = await addMajorIssuesApi(params)
|
|
|
+
|
|
|
+ if (result.code !== 0) {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: result?.msg || '添加失败', icon: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const newReportId = result?.data || ''
|
|
|
+ if (!newReportId) {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({ title: '添加失败', icon: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+ closeSelectTemplatePopup()
|
|
|
+ props.refreshDetail?.()
|
|
|
+
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/webview/webview?userId=${userInfo.value?.id}&orderItemId=${props.orderItemId}&checkItemId=${newReportId}&templateId=${selectedTemplate.value.id}&equipCode=${props.equipment?.equipCode || ''}&useOnline=1&reportUrl=`
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.error('添加指导书失败:', error)
|
|
|
+ uni.showToast({ title: '添加指导书失败', icon: 'error' })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const showCheckProjectPopup = () => {
|
|
|
props.showCheckProjectPopupFn?.()
|
|
|
}
|
|
|
|
|
|
-const handleCheckReport = () => {
|
|
|
+const handleCheckReport = async () => {
|
|
|
if (selectedProjects.value.length === 0) {
|
|
|
uni.showToast({ title: '请选择要上传的项目', icon: 'error' })
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- tipsPopupRef.value?.show({
|
|
|
- text: '是否上传已选择的检验项目?',
|
|
|
- confirm: async () => {
|
|
|
- uni.showToast({ title: '上传功能开发中', icon: 'none' })
|
|
|
- },
|
|
|
- })
|
|
|
+ try {
|
|
|
+ const itemArray = selectedProjects.value.map(id => props.reportList.find((i) => i.id === id)).filter(Boolean)
|
|
|
+
|
|
|
+ for (const checkItem of itemArray) {
|
|
|
+ const userId =
|
|
|
+ checkItem.reportType === PressureReportType.MAIN
|
|
|
+ ? props.equipment?.mainCheckerUser?.id
|
|
|
+ : checkItem?.checkUsers?.[0]?.id
|
|
|
+
|
|
|
+ if (userId && userId !== userInfo.value?.id) {
|
|
|
+ uni.showToast({ title: '已分配项目不支持上传', icon: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const { checkedCheckItemhasSubmited } = await import('@/api/task')
|
|
|
+ const promiseArr = itemArray.map(item => checkedCheckItemhasSubmited({ id: item.id }))
|
|
|
+ const result = await Promise.all(promiseArr)
|
|
|
+
|
|
|
+ const checkNameArr = []
|
|
|
+ for (const res of result) {
|
|
|
+ if (res?.code === 0 && res?.data?.isSubmit) {
|
|
|
+ checkNameArr.push(res?.data.checkName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checkNameArr?.length) {
|
|
|
+ tipsPopupRef.value?.show({
|
|
|
+ text: `检验员:${checkNameArr.join('、')}已经提交过,确定要覆盖吗?`,
|
|
|
+ confirm: handleBatchUpload,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ handleBatchUpload()
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('批量上传失败:', error)
|
|
|
+ uni.showToast({ title: '项目检验失败', icon: 'error' })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleBatchUpload = async () => {
|
|
|
+ try {
|
|
|
+ uni.showLoading({ title: '上传中...' })
|
|
|
+
|
|
|
+ const itemArray = selectedProjects.value.map(id => props.reportList.find((i) => i.id === id)).filter(Boolean)
|
|
|
+
|
|
|
+ const params: any = { addList: [], updateList: [] }
|
|
|
+
|
|
|
+ itemArray.forEach((item) => {
|
|
|
+ const dic = {
|
|
|
+ orderId: props.orderId,
|
|
|
+ orderItemId: props.orderItemId,
|
|
|
+ reportUrl: item.reportUrl || '',
|
|
|
+ dataJson: '',
|
|
|
+ prepareUrl: '',
|
|
|
+ prepareJson: item.prepareJson || '',
|
|
|
+ modifiedReason: '',
|
|
|
+ templateId: item.templateId,
|
|
|
+ reportType: item.reportType,
|
|
|
+ equipAddress: props.equipment?.equipAddress || '',
|
|
|
+ equipLatitude: props.equipment?.equipLatitude || '',
|
|
|
+ equipLongitude: props.equipment?.equipLongitude || '',
|
|
|
+ fee: item?.fee || 0,
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.isLocal) {
|
|
|
+ dic['localId'] = item.id
|
|
|
+ params['addList'].push(dic)
|
|
|
+ } else {
|
|
|
+ dic['id'] = item.id
|
|
|
+ params['updateList'].push(dic)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ const { postCheckItemRecordEnter } = await import('@/api/task')
|
|
|
+ const postResult = await postCheckItemRecordEnter(params)
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+
|
|
|
+ if (postResult.data) {
|
|
|
+ uni.showToast({ title: '提交成功', icon: 'success' })
|
|
|
+ props.refreshDetail?.()
|
|
|
+ initSelected()
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: postResult?.msg || '提交失败', icon: 'error' })
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.error('批量上传失败:', error)
|
|
|
+ uni.showToast({ title: '批量上传失败', icon: 'error' })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const handleDelReport = () => {
|
|
|
@@ -904,6 +1101,16 @@ const handleDelReport = () => {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ const hasMain = selectedProjects.value.some((id) => {
|
|
|
+ const item = props.reportList.find((i) => i.id === id)
|
|
|
+ return item?.reportType === PressureReportType.MAIN
|
|
|
+ })
|
|
|
+
|
|
|
+ if (hasMain) {
|
|
|
+ uni.showToast({ title: '主报告不能作废', icon: 'error' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
const hasReportEnd =
|
|
|
props.useOnline === '1' &&
|
|
|
selectedProjects.value.some((id) => {
|
|
|
@@ -919,7 +1126,36 @@ const handleDelReport = () => {
|
|
|
tipsPopupRef.value?.show({
|
|
|
text: '是否作废已选择的检验项目?',
|
|
|
confirm: async () => {
|
|
|
- uni.showToast({ title: '作废功能开发中', icon: 'none' })
|
|
|
+ try {
|
|
|
+ uni.showLoading({ title: '作废中...' })
|
|
|
+
|
|
|
+ const cancelIds = selectedProjects.value
|
|
|
+ let result = null
|
|
|
+
|
|
|
+ if (props.useOnline === '1') {
|
|
|
+ const { delReportApi } = await import('@/api/task')
|
|
|
+ const fetchResult = await delReportApi({ ids: cancelIds })
|
|
|
+ result = fetchResult.data
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: '离线模式作废功能开发中', icon: 'none' })
|
|
|
+ uni.hideLoading()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+
|
|
|
+ if (result) {
|
|
|
+ props.refreshDetail?.()
|
|
|
+ initSelected()
|
|
|
+ uni.showToast({ title: '作废成功', icon: 'success' })
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: '作废失败', icon: 'error' })
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.error('作废失败:', error)
|
|
|
+ uni.showToast({ title: '作废失败', icon: 'error' })
|
|
|
+ }
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
@@ -936,7 +1172,47 @@ const uploadFileAndSubmitCheckItemCallback = {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- uni.showToast({ title: '上传功能开发中', icon: 'none' })
|
|
|
+ try {
|
|
|
+ uni.showLoading({ title: '上传中...' })
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ orderId: props.orderId,
|
|
|
+ orderItemId: props.orderItemId,
|
|
|
+ reportUrl: item.reportUrl || '',
|
|
|
+ dataJson: '',
|
|
|
+ prepareUrl: '',
|
|
|
+ prepareJson: item.prepareJson || '',
|
|
|
+ modifiedReason: '',
|
|
|
+ templateId: item.templateId,
|
|
|
+ reportType: item.reportType,
|
|
|
+ fee: item?.fee || 0,
|
|
|
+ }
|
|
|
+
|
|
|
+ const newParams: any = {}
|
|
|
+ if (item.isLocal) {
|
|
|
+ params['localId'] = item.id
|
|
|
+ newParams['addList'] = [params]
|
|
|
+ } else {
|
|
|
+ params['id'] = item.id
|
|
|
+ newParams['updateList'] = [params]
|
|
|
+ }
|
|
|
+
|
|
|
+ const { postCheckItemRecordEnter } = await import('@/api/task')
|
|
|
+ const postResult = await postCheckItemRecordEnter(newParams)
|
|
|
+
|
|
|
+ uni.hideLoading()
|
|
|
+
|
|
|
+ if (postResult.data) {
|
|
|
+ uni.showToast({ title: '提交成功', icon: 'success' })
|
|
|
+ props.refreshDetail?.()
|
|
|
+ } else {
|
|
|
+ uni.showToast({ title: postResult?.msg || '提交失败', icon: 'error' })
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ uni.hideLoading()
|
|
|
+ console.error('上传失败:', error)
|
|
|
+ uni.showToast({ title: '上传失败', icon: 'error' })
|
|
|
+ }
|
|
|
},
|
|
|
}
|
|
|
</script>
|