diff --git a/src/api/sbgl/contractPrice/index.ts b/src/api/sbgl/contractPrice/index.ts new file mode 100644 index 0000000..e43c195 --- /dev/null +++ b/src/api/sbgl/contractPrice/index.ts @@ -0,0 +1,55 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { ContractPriceVO, ContractPriceQuery, ContractPriceForm } from './types'; + +// 合同单价分页列表 +export function listContractPrice(query: ContractPriceQuery): AxiosPromise { + return request({ + url: '/sbgl/contractPrice/list', + method: 'get', + params: query + }); +} + +// 合同单价详情 +export function getContractPrice(id: string | number): AxiosPromise { + return request({ + url: '/sbgl/contractPrice/' + id, + method: 'get' + }); +} + +// 启用中的合同单价选项(完工提交用) +export function listContractPriceOptions(orderType?: string): AxiosPromise { + return request({ + url: '/sbgl/contractPrice/options', + method: 'get', + params: { orderType } + }); +} + +// 新增合同单价 +export function addContractPrice(data: ContractPriceForm) { + return request({ + url: '/sbgl/contractPrice', + method: 'post', + data + }); +} + +// 修改合同单价 +export function updateContractPrice(data: ContractPriceForm) { + return request({ + url: '/sbgl/contractPrice', + method: 'put', + data + }); +} + +// 删除合同单价 +export function delContractPrice(id: string | number | (string | number)[]) { + return request({ + url: '/sbgl/contractPrice/' + id, + method: 'delete' + }); +} diff --git a/src/api/sbgl/contractPrice/types.ts b/src/api/sbgl/contractPrice/types.ts new file mode 100644 index 0000000..3932802 --- /dev/null +++ b/src/api/sbgl/contractPrice/types.ts @@ -0,0 +1,28 @@ +export interface ContractPriceVO { + id: string | number; + orderType: string; + itemName: string; + unit?: string; + unitPrice: number; + status: string; + sort?: number; + remark?: string; + createTime?: string; +} + +export interface ContractPriceQuery extends PageQuery { + orderType?: string; + itemName?: string; + status?: string; +} + +export interface ContractPriceForm { + id?: string | number; + orderType: string; + itemName: string; + unit?: string; + unitPrice: number; + status: string; + sort?: number; + remark?: string; +} diff --git a/src/api/sbgl/device/index.ts b/src/api/sbgl/device/index.ts index e4678e8..803ddfa 100644 --- a/src/api/sbgl/device/index.ts +++ b/src/api/sbgl/device/index.ts @@ -111,11 +111,6 @@ export function getDeviceQrcode(id: string | number): Promise { }) as unknown as Promise; } -// 按当前筛选条件批量导出设备二维码(ZIP) -export function exportDeviceQrcode(query: DeviceQuery) { - return download('/sbgl/device/qrcode/batch', query, `设备二维码_${new Date().getTime()}.zip`); -} - // 扫码解析设备 export function resolveDeviceQrcode(content: string): AxiosPromise { return request({ diff --git a/src/api/sbgl/orderflow/index.ts b/src/api/sbgl/orderflow/index.ts new file mode 100644 index 0000000..42ee6bd --- /dev/null +++ b/src/api/sbgl/orderflow/index.ts @@ -0,0 +1,54 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { OrderFlowNodeVO, OrderFlowNodeForm, RoleOptionVO } from './types'; + +// 审批节点列表 +export function listOrderFlow(orderType?: string): AxiosPromise { + return request({ + url: '/sbgl/orderFlow/list', + method: 'get', + params: { orderType } + }); +} + +// 审批节点详情 +export function getOrderFlow(id: string | number): AxiosPromise { + return request({ + url: '/sbgl/orderFlow/' + id, + method: 'get' + }); +} + +// 可选择的审批角色 +export function listOrderFlowRoles(): AxiosPromise { + return request({ + url: '/sbgl/orderFlow/roleOptions', + method: 'get' + }); +} + +// 新增审批节点 +export function addOrderFlow(data: OrderFlowNodeForm) { + return request({ + url: '/sbgl/orderFlow', + method: 'post', + data + }); +} + +// 修改审批节点 +export function updateOrderFlow(data: OrderFlowNodeForm) { + return request({ + url: '/sbgl/orderFlow', + method: 'put', + data + }); +} + +// 删除审批节点 +export function delOrderFlow(id: string | number | (string | number)[]) { + return request({ + url: '/sbgl/orderFlow/' + id, + method: 'delete' + }); +} diff --git a/src/api/sbgl/orderflow/types.ts b/src/api/sbgl/orderflow/types.ts new file mode 100644 index 0000000..ea1d27e --- /dev/null +++ b/src/api/sbgl/orderflow/types.ts @@ -0,0 +1,37 @@ +export interface OrderFlowNodeVO { + id: string | number; + orderType: string; + nodeName: string; + nodeType: string; + approverRoleId: string | number; + approverRoleName?: string; + approverScope?: string; + approverDeptId?: string | number; + approverDeptName?: string; + sort: number; + status: string; + rejectAction: string; + remark?: string; + createTime?: string; +} + +export interface OrderFlowNodeForm { + id?: string | number; + orderType: string; + nodeName: string; + nodeType: string; + approverRoleId: string | number | ''; + approverScope: string; + approverDeptId?: string | number | ''; + sort: number; + status: string; + rejectAction: string; + remark?: string; +} + +export interface RoleOptionVO { + roleId: string | number; + roleName: string; + roleKey?: string; + status?: string; +} diff --git a/src/api/sbgl/roleScope/index.ts b/src/api/sbgl/roleScope/index.ts deleted file mode 100644 index 70cb1f6..0000000 --- a/src/api/sbgl/roleScope/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -import request from '@/utils/request'; - -/** 设备资产模块标识 */ -export type RoleScopeModule = 'device' | 'order' | 'report' | string; - -export interface RoleScopeVO { - roleId: string | number; - module: RoleScopeModule; - /** 数据范围;为空表示沿用角色自身数据权限 */ - scopeType?: string; -} - -export interface RoleScopeForm { - module: RoleScopeModule; - scopeType?: string; -} - -/** 查询角色在各模块的数据范围 */ -export function getRoleScopes(roleId: string | number) { - return request({ - url: '/sbgl/roleScope/' + roleId, - method: 'get' - }); -} - -/** 保存角色模块数据范围 */ -export function saveRoleScopes(roleId: string | number, data: RoleScopeForm[]) { - return request({ - url: '/sbgl/roleScope/' + roleId, - method: 'put', - data - }); -} diff --git a/src/api/sbgl/workorder/index.ts b/src/api/sbgl/workorder/index.ts index d5ec6e5..df95134 100644 --- a/src/api/sbgl/workorder/index.ts +++ b/src/api/sbgl/workorder/index.ts @@ -1,6 +1,24 @@ +// 运维工单接口 import request from '@/utils/request'; import { AxiosPromise } from 'axios'; -import { WorkOrderVO, WorkOrderQuery, WorkOrderForm, DispatchForm, HandleForm, VerifyForm, OrderRecordVO } from './types'; +import { WorkOrderVO, WorkOrderQuery, WorkOrderForm, HandleForm, VerifyForm, SuperviseForm, ApproveForm, InternalDispatchForm, OrderRecordVO, OrderConfigVO, OrderConfigForm } from './types'; + +// 查询固定受理部门 +export function getOrderConfig(): AxiosPromise { + return request({ + url: '/sbgl/orderConfig', + method: 'get' + }); +} + +// 保存固定受理部门 +export function saveOrderConfig(data: OrderConfigForm) { + return request({ + url: '/sbgl/orderConfig', + method: 'put', + data + }); +} // 工单分页列表 export function listOrder(query: WorkOrderQuery): AxiosPromise { @@ -37,19 +55,46 @@ export function updateOrder(data: WorkOrderForm) { }); } -// 派单 -export function dispatchOrder(data: DispatchForm) { +// 处理人操作:接单/完工提交 +export function handleOrder(data: HandleForm) { return request({ - url: '/sbgl/order/dispatch', + url: '/sbgl/order/handle', method: 'post', data }); } -// 处理人操作:接单/到场/完工提交 -export function handleOrder(data: HandleForm) { +// 内部派单可选处理人 +export function listDispatchHandlers(orderId: string | number): AxiosPromise { return request({ - url: '/sbgl/order/handle', + url: '/sbgl/order/handlerOptions', + method: 'get', + params: { orderId } + }); +} + +// 运维单位内部派单 +export function dispatchInternal(data: InternalDispatchForm) { + return request({ + url: '/sbgl/order/dispatchInternal', + method: 'post', + data + }); +} + +// 审批当前流程节点 +export function approveOrder(data: ApproveForm) { + return request({ + url: '/sbgl/order/approve', + method: 'post', + data + }); +} + +// 监理确认(通过后进入待验收) +export function superviseOrder(data: SuperviseForm) { + return request({ + url: '/sbgl/order/supervise', method: 'post', data }); diff --git a/src/api/sbgl/workorder/types.ts b/src/api/sbgl/workorder/types.ts index a404f14..789ae08 100644 --- a/src/api/sbgl/workorder/types.ts +++ b/src/api/sbgl/workorder/types.ts @@ -25,7 +25,32 @@ export interface WorkOrderVO { verifyResult?: number; verifyOpinion?: string; status: string; + currentNodeId?: string | number; + currentNodeName?: string; + currentNodeType?: string; + currentNodeRoleId?: string | number; + currentNodeScope?: string; + currentNodeDeptId?: string | number; + acceptedBy?: string | number; + acceptedName?: string; + canOperate?: boolean; + canApprove?: boolean; + canAccept?: boolean; + canDispatch?: boolean; + canFinish?: boolean; deadline?: string; + priceId?: string | number; + priceItem?: string; + priceUnit?: string; + unitPrice?: number; + workQty?: number; + calcAmount?: number; + amount?: number; + amountAdjustReason?: string; + supervisorName?: string; + superviseTime?: string; + superviseResult?: number; + superviseOpinion?: string; timeoutFlag?: number; createTime?: string; } @@ -50,20 +75,35 @@ export interface WorkOrderForm { reportLat?: number; } -export interface DispatchForm { - orderId: string | number; - handlerId: string | number; - handlerName?: string; - maintainer?: string; -} - export interface HandleForm { orderId: string | number; - action: 'ACCEPT' | 'ARRIVE' | 'SUBMIT_FINISH'; + action: 'ACCEPT' | 'SUBMIT_FINISH'; lng?: number; lat?: number; processDesc?: string; images?: string; + priceId?: string | number; + workQty?: number; + amount?: number; + amountAdjustReason?: string; +} + +export interface SuperviseForm { + orderId: string | number; + superviseResult: number; + superviseOpinion?: string; +} + +export interface ApproveForm { + orderId: string | number; + approveResult: number; + approveOpinion?: string; +} + +export interface InternalDispatchForm { + orderId: string | number; + handlerId: string | number; + handlerName?: string; } export interface VerifyForm { @@ -81,3 +121,14 @@ export interface OrderRecordVO { images?: string; createTime: string; } + +export interface OrderConfigVO { + id?: string | number; + maintainerDeptId: string | number; + maintainerDeptName?: string; + updateTime?: string; +} + +export interface OrderConfigForm { + maintainerDeptId: string | number; +} diff --git a/src/views/login.vue b/src/views/login.vue index ff2a51a..99353df 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -93,8 +93,8 @@ const loginRules: ElFormRules = { const codeUrl = ref(''); const loading = ref(false); -// 验证码开关 -const captchaEnabled = ref(true); +// 验证码开关(默认关闭,后端返回启用时再显示) +const captchaEnabled = ref(false); // 租户开关 const tenantEnabled = ref(true); diff --git a/src/views/sbgl/contractPrice/index.vue b/src/views/sbgl/contractPrice/index.vue new file mode 100644 index 0000000..0abfd6c --- /dev/null +++ b/src/views/sbgl/contractPrice/index.vue @@ -0,0 +1,215 @@ + + + diff --git a/src/views/sbgl/device/detail.vue b/src/views/sbgl/device/detail.vue index 59ad21a..d3c106d 100644 --- a/src/views/sbgl/device/detail.vue +++ b/src/views/sbgl/device/detail.vue @@ -42,8 +42,6 @@ {{ device.lng ?? '-' }} {{ device.lat ?? '-' }} {{ device.installLocation || '-' }} - {{ formatDate(device.scrapDate, '{y}-{m}-{d}') }} - {{ device.scrapReason || '-' }} {{ device.remark || '-' }} diff --git a/src/views/sbgl/device/index.vue b/src/views/sbgl/device/index.vue index 7aeadbb..c0d8b9a 100644 --- a/src/views/sbgl/device/index.vue +++ b/src/views/sbgl/device/index.vue @@ -43,9 +43,6 @@ 导出 - - 批量二维码 - 回收站 @@ -324,7 +321,7 @@ import { listType, listTypeOptions, listEnabledFields } from '@/api/sbgl/devicetype'; import { DeviceTypeVO, DeviceFieldVO } from '@/api/sbgl/devicetype/types'; import { parseFieldOptions, fieldValueArray, formatFieldValue, normalizeFieldValue } from '../devicetype/fieldTypes'; -import { listDevice, getDevice, addDevice, updateDevice, delDevice, importTemplate, importData, exportDevice, listRecycleDevice, restoreDevice, exportDeviceQrcode } from '@/api/sbgl/device'; +import { listDevice, getDevice, addDevice, updateDevice, delDevice, importTemplate, importData, exportDevice, listRecycleDevice, restoreDevice } from '@/api/sbgl/device'; import { DeviceVO, DeviceQuery, DeviceForm, ImportResultVO } from '@/api/sbgl/device/types'; import { getCommonDeptTree, listBusinessOss } from '@/api/sbgl/common'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -705,13 +702,6 @@ const handleExport = () => { }); }; -// ---------------- 设备二维码 ---------------- -const handleQrcodeBatch = () => { - proxy?.$modal.confirm('是否按当前筛选条件导出设备二维码?').then(() => { - return exportDeviceQrcode({ ...queryParams.value, deviceCode: keyword.value || undefined }); - }); -}; - // ---------------- 详情 ---------------- const goDetail = (row: DeviceVO) => { router.push(`/sbgl/device/detail/${row.id}`); diff --git a/src/views/sbgl/h5/order.vue b/src/views/sbgl/h5/order.vue index 129dd7b..63bb039 100644 --- a/src/views/sbgl/h5/order.vue +++ b/src/views/sbgl/h5/order.vue @@ -48,7 +48,7 @@ -
+ 发起工单
+
+ 发起工单
@@ -70,6 +70,24 @@
{{ detail.maintainer }}
{{ formatTime(detail.deadline) }}
{{ detail.processDesc }}
+
+ + {{ detail.priceItem }}:{{ formatMoney(detail.unitPrice) }} × {{ detail.workQty ?? '-' }} = + {{ formatMoney(detail.amount) }} +
+
{{ detail.amountAdjustReason }}
+
+ + {{ detail.superviseResult === 1 ? '确认通过' : '退回' }} · {{ detail.supervisorName }} + {{ detail.superviseOpinion ? ':' + detail.superviseOpinion : '' }} +
+
+ + + {{ nodePhaseLabel(detail.currentNodeType) || detail.currentNodeName }} + + +
{{ detail.verifyOpinion }}
@@ -98,15 +116,21 @@
- 接 单 - - 到场签到 + 接 单 + 接 单 + + 派 单 - 完工提交 + 完工提交 + + 审 批 + + 修 改 - - {{ dispatchBtnLabel }} 催 办 关 闭 @@ -129,6 +153,27 @@ + + + + +
该工单类型暂无合同单价,请先在 Web 端配置
+
+ + + + +
系统计算:{{ formatMoney(finishAutoAmount) }}
+ + 恢复系统计算 +
+ + + + + + + + + + + + + + + + + + + + {{ approveNode.nodeName }}({{ approveNodeTypeLabel(approveNode.nodeType) }}) + + + {{ formatMoney(approveNode.amount) }} + + + + 通过 + 驳回 + + + + + + + + + + + + + + + @@ -194,28 +288,6 @@ - - - - - - - - - - - - - - -

{{ loginError }}

@@ -231,12 +303,15 @@ import { getToken, setToken } from '@/utils/auth'; import { dingLogin, jsapiSign } from '@/api/sbgl/ding'; import { getInfo } from '@/api/login'; import { - listOrder, getOrder, submitOrder, updateOrder, dispatchOrder, - handleOrder, verifyOrder, closeOrder, urgeOrder, listOrderRecords + listOrder, getOrder, submitOrder, updateOrder, + handleOrder, superviseOrder, approveOrder, dispatchInternal, listDispatchHandlers, + verifyOrder, closeOrder, urgeOrder, listOrderRecords } from '@/api/sbgl/workorder'; +import { listContractPriceOptions } from '@/api/sbgl/contractPrice'; +import { ContractPriceVO } from '@/api/sbgl/contractPrice/types'; import { listTypeOptions } from '@/api/sbgl/devicetype'; import { getDeviceOptions, resolveDeviceQrcode } from '@/api/sbgl/device'; -import { getCommonDeptTree, getDeptUsers, listBusinessOss } from '@/api/sbgl/common'; +import { listBusinessOss } from '@/api/sbgl/common'; const corpId = import.meta.env.VITE_DINGTALK_CORP_ID as string; @@ -253,9 +328,11 @@ const perm = (p: string) => permissions.value.includes(p) || permissions.value.i /** 状态页签(与 Web 端状态口径一致;多状态用逗号分隔,后端 in 查询) */ const tabs = [ { label: '全部', value: '' }, - { label: '待派单', value: 'PENDING_DISPATCH,REJECTED' }, { label: '待接单', value: 'TO_ACCEPT' }, - { label: '处理中', value: 'ACCEPTED,ARRIVED' }, + { label: '待派单', value: 'PENDING_INTERNAL_DISPATCH' }, + { label: '处理中', value: 'ACCEPTED,PROCESSING' }, + { label: '待监理', value: 'PENDING_SUPERVISE' }, + { label: '待审批', value: 'PENDING_APPROVAL' }, { label: '待验收', value: 'PENDING_VERIFY' }, { label: '已完成', value: 'FINISHED' } ]; @@ -270,9 +347,32 @@ const detail = ref({}); const records = ref([]); const finishVisible = ref(false); -const finishForm = reactive({ processDesc: '', images: '' }); +const finishForm = reactive<{ + processDesc: string; images: string; priceId?: any; workQty?: number; amount?: number; amountAdjustReason?: string; +}>({ processDesc: '', images: '' }); +const priceOptions = ref([]); +const priceLoading = ref(false); +const finishAmountTouched = ref(false); +const finishSelectedPrice = computed( + () => priceOptions.value.find((p) => String(p.id) === String(finishForm.priceId)) +); +const finishAutoAmount = computed( + () => Number(((Number(finishSelectedPrice.value?.unitPrice) || 0) * (Number(finishForm.workQty) || 0)).toFixed(2)) +); +const finishAmountAdjusted = computed( + () => finishForm.amount !== undefined && finishForm.amount !== null + && Math.abs(Number(finishForm.amount) - finishAutoAmount.value) > 0.001 +); const rejectVisible = ref(false); const verifyOpinion = ref(''); +const superviseRejectVisible = ref(false); +const superviseOpinion = ref(''); +const approveVisible = ref(false); +const approveNode = reactive({ nodeName: '', nodeType: '', amount: 0 }); +const approveForm = reactive<{ approveResult: number; approveOpinion: string }>({ approveResult: 1, approveOpinion: '' }); +const internalDispatchVisible = ref(false); +const internalDispatchHandlerId = ref(''); +const internalDispatchOptions = ref([]); const closeVisible = ref(false); const closeReason = ref(''); @@ -289,29 +389,31 @@ const formTypeId = ref(''); const typeOpts = ref([]); const deviceOpts = ref([]); -/* ---------- 改派 ---------- */ -const reVisible = ref(false); -const reForm = reactive<{ deptId: any; handlerId: any }>({ deptId: '', handlerId: '' }); -const deptTree = ref([]); -const reUserOptions = ref([]); - /* ---------- 状态字典(与后台字典键一致) ---------- */ const STATUS_LABELS: Record = { - PENDING_DISPATCH: '待派单', TO_ACCEPT: '待接单', ACCEPTED: '已接单', - ARRIVED: '已到场', + PROCESSING: '处理中', + PENDING_SUPERVISE: '待监理确认', + PENDING_APPROVAL: '待审批', + PENDING_INTERNAL_DISPATCH: '待内部派单', PENDING_VERIFY: '待验收', FINISHED: '已完成', REJECTED: '已驳回', CLOSED: '已关闭' }; const statusLabel = (s: string) => STATUS_LABELS[s] || s; +/** 当前节点用“待办动作”展示,避免“运维单位完成”被误读为已经完成 */ +const nodePhaseLabel = (t?: string) => + ({ APPROVAL: '待审批', ACCEPT: '待接单', DISPATCH: '待派单', FINISH: '待完工', VERIFY: '待验收', SUPERVISE: '待监理确认' }[t || ''] || ''); const statusClass = (s: string) => - ({ FINISHED: 'is-ok', CLOSED: 'is-gray', PENDING_VERIFY: 'is-info' }[s] || 'is-warn'); + ({ FINISHED: 'is-ok', CLOSED: 'is-gray', PENDING_SUPERVISE: 'is-info', PENDING_APPROVAL: 'is-info', PENDING_VERIFY: 'is-info' }[s] || 'is-warn'); const ACTION_LABELS: Record = { - CREATE: '发起', SUBMIT: '发起工单', DISPATCH: '派单', RE_DISPATCH: '改派', - ACCEPT: '接单', ARRIVE: '到场签到', SUBMIT_FINISH: '完工提交', + CREATE: '发起', SUBMIT: '发起工单', DISPATCH: '派单', RE_DISPATCH: '改派', AUTO_DISPATCH: '自动分派', + ACCEPT: '接单', ARRIVE: '到场签到', SUBMIT_FINISH: '完工提交', COST_SUBMIT: '提交完工费用', + SUPERVISE_PASS: '监理确认通过', SUPERVISE_REJECT: '监理退回', + APPROVE_PASS: '审批通过', APPROVE_REJECT: '审批驳回', + FLOW_START: '进入审批', DISPATCH_INTERNAL: '内部派单', VERIFY_PASS: '验收通过', VERIFY_REJECT: '验收驳回', CLOSE: '关闭工单', URGE: '催办', UPDATE: '修改工单' }; @@ -319,15 +421,21 @@ const actionLabel = (a: string) => ACTION_LABELS[a] || a; const typeLabel = (t: string) => ORDER_TYPES[t] || t; const formatTime = (t?: string) => (t ? String(t).replace('T', ' ').slice(0, 16) : '-'); +const formatPrice = (v: any) => Number(v ?? 0).toFixed(2); +const formatMoney = (v: any) => (v === null || v === undefined || v === '' ? '-' : `¥${Number(v).toFixed(2)}`); /* ---------- 操作显隐(口径与 Web 端一致:权限码 + 身份双校验) ---------- */ const isHandler = computed(() => currentUserId.value && detail.value.handlerId == currentUserId.value); const isReporter = computed(() => currentUserId.value && detail.value.reportBy == currentUserId.value); const isAdmin = computed(() => String(currentUserId.value) === '1'); -const canAccept = computed(() => detail.value.status === 'TO_ACCEPT' && isHandler.value); -const canArrive = computed(() => detail.value.status === 'ACCEPTED' && isHandler.value); +const canAccept = computed( + () => + perm('sbgl:order:handle') && + detail.value.status === 'TO_ACCEPT' && + (!detail.value.handlerId || String(detail.value.handlerId) === String(currentUserId.value)) +); const canFinish = computed( - () => isHandler.value && (detail.value.status === 'ACCEPTED' || detail.value.status === 'ARRIVED') + () => isHandler.value && ['ACCEPTED', 'ARRIVED', 'PROCESSING'].includes(detail.value.status) ); /** 修改:发起人(或超管)+ 修改权限,且未进入处理流程(待派单/已驳回/待接单) */ const canEdit = computed( @@ -336,19 +444,30 @@ const canEdit = computed( (isReporter.value || isAdmin.value) && ['PENDING_DISPATCH', 'REJECTED', 'TO_ACCEPT'].includes(detail.value.status) ); -/** 派单/改派:派单权限,待派单/已驳回显示"派单"、待接单显示"改派"(已接单后不可改派,与 Web 端一致) */ -const canDispatch = computed( - () => - perm('sbgl:order:dispatch') && - ['PENDING_DISPATCH', 'REJECTED', 'TO_ACCEPT'].includes(detail.value.status) -); -const dispatchBtnLabel = computed(() => (detail.value.status === 'TO_ACCEPT' ? '改 派' : '派 单')); +/** 验收:验收权限 + 待验收状态 + 非处理人本人 */ const canVerify = computed( - () => perm('sbgl:order:verify') && detail.value.status === 'PENDING_VERIFY' && currentUserId.value && !isHandler.value + () => + perm('sbgl:order:verify') && + detail.value.status === 'PENDING_VERIFY' && + !detail.value.currentNodeId && + currentUserId.value && + !isHandler.value ); +const canSupervise = computed( + () => + perm('sbgl:order:supervise') && + detail.value.status === 'PENDING_SUPERVISE' && + !detail.value.currentNodeId && + currentUserId.value && + !isHandler.value +); +const canApproveNode = computed(() => perm('sbgl:order:query') && detail.value.canApprove === true); +const canAcceptNode = computed(() => perm('sbgl:order:handle') && detail.value.canAccept === true); +const approveNodeTypeLabel = (type: string) => + ({ SUPERVISE: '监理确认', VERIFY: '验收', APPROVAL: '审批' }[type] || '审批'); const canUrge = computed( () => - ['PENDING_DISPATCH', 'TO_ACCEPT', 'ACCEPTED', 'ARRIVED'].includes(detail.value.status) && + ['PENDING_DISPATCH', 'TO_ACCEPT', 'ACCEPTED', 'PROCESSING'].includes(detail.value.status) && (isReporter.value || isAdmin.value) ); const canClose = computed( @@ -579,20 +698,16 @@ const dingLocate = (): Promise<{ lng?: number; lat?: number }> => }); /** 获取定位:钉钉内只走原生 JSAPI 定位(失败/超时则不带坐标继续,绝不降级浏览器定位防卡死); - * 非钉钉环境(普通浏览器)走浏览器定位。均不阻断签到/完工流程。 */ + * 非钉钉环境(普通浏览器)走浏览器定位。均不阻断完工提交流程。 */ const getLocation = (): Promise<{ lng?: number; lat?: number }> => { if (isDingTalk()) return dingLocate(); return browserLocate(); }; -const doHandle = async (action: 'ACCEPT' | 'ARRIVE' | 'SUBMIT_FINISH', label: string) => { +const doHandle = async (action: 'ACCEPT') => { submitting.value = true; try { - let loc: any = {}; - if (action !== 'ACCEPT') { - loc = await getLocation(); - } - await handleOrder({ orderId: detail.value.id, action, ...loc } as any); + await handleOrder({ orderId: detail.value.id, action } as any); detailVisible.value = false; refresh(); } finally { @@ -600,22 +715,173 @@ const doHandle = async (action: 'ACCEPT' | 'ARRIVE' | 'SUBMIT_FINISH', label: st } }; -const doFinish = async () => { +const doFlowAccept = async () => { submitting.value = true; try { - const loc = await getLocation(); + await handleOrder({ orderId: detail.value.id, action: 'ACCEPT' } as any); + ElMessage.success('接单成功,请继续内部派单'); + detailVisible.value = false; + refresh(); + } finally { + submitting.value = false; + } +}; + +const openInternalDispatch = async () => { + internalDispatchHandlerId.value = ''; + internalDispatchOptions.value = []; + internalDispatchVisible.value = true; + const res = await listDispatchHandlers(detail.value.id); + internalDispatchOptions.value = res.data ?? []; +}; + +const doInternalDispatch = async () => { + if (!internalDispatchHandlerId.value) { + ElMessage.warning('请选择处理人'); + return; + } + const user = internalDispatchOptions.value.find((u) => String(u.userId) === String(internalDispatchHandlerId.value)); + submitting.value = true; + try { + await dispatchInternal({ + orderId: detail.value.id, + handlerId: internalDispatchHandlerId.value, + handlerName: user?.nickName + }); + internalDispatchVisible.value = false; + detailVisible.value = false; + refresh(); + } finally { + submitting.value = false; + } +}; + +const loadFinishPrices = async (orderType: string) => { + priceLoading.value = true; + try { + const res = await listContractPriceOptions(orderType); + priceOptions.value = res.data ?? []; + } catch { + priceOptions.value = []; + } finally { + priceLoading.value = false; + } +}; + +const openFinish = () => { + finishForm.processDesc = ''; + finishForm.images = ''; + finishForm.priceId = undefined; + finishForm.workQty = undefined; + finishForm.amount = undefined; + finishForm.amountAdjustReason = ''; + finishAmountTouched.value = false; + finishVisible.value = true; + void loadFinishPrices(detail.value.orderType); +}; + +const onFinishPriceChange = () => { + if (!finishAmountTouched.value) finishForm.amount = finishAutoAmount.value; +}; + +const onFinishQtyChange = () => { + if (!finishAmountTouched.value) finishForm.amount = finishAutoAmount.value; +}; + +const onFinishAmountChange = () => { + finishAmountTouched.value = Math.abs(Number(finishForm.amount ?? 0) - finishAutoAmount.value) > 0.001; +}; + +const resetFinishAmount = () => { + finishForm.amount = finishAutoAmount.value; + finishForm.amountAdjustReason = ''; + finishAmountTouched.value = false; +}; + +const doFinish = async () => { + if (!finishForm.processDesc?.trim()) { + ElMessage.warning('请填写处理说明'); + return; + } + if (!finishForm.priceId || !finishSelectedPrice.value) { + ElMessage.warning(priceOptions.value.length ? '请选择合同单价' : '该工单类型暂无合同单价'); + return; + } + if (!finishForm.workQty || Number(finishForm.workQty) <= 0) { + ElMessage.warning('请输入大于0的完工工作量'); + return; + } + if (finishAmountAdjusted.value && !finishForm.amountAdjustReason?.trim()) { + ElMessage.warning('手改金额时必须填写原因'); + return; + } + submitting.value = true; + try { + const finalAmount = finishForm.amount === undefined || finishForm.amount === null + ? finishAutoAmount.value : Number(finishForm.amount); await handleOrder( { orderId: detail.value.id, action: 'SUBMIT_FINISH', processDesc: finishForm.processDesc, images: finishForm.images || undefined, - ...loc + priceId: finishForm.priceId, + workQty: finishForm.workQty, + amount: finalAmount, + amountAdjustReason: finishAmountAdjusted.value ? finishForm.amountAdjustReason : undefined } as any ); finishVisible.value = false; - finishForm.processDesc = ''; - finishForm.images = ''; + detailVisible.value = false; + refresh(); + } finally { + submitting.value = false; + } +}; + +const doSupervise = async (result: number) => { + if (result === 0 && !superviseOpinion.value.trim()) { + ElMessage.warning('退回时请填写监理意见'); + return; + } + submitting.value = true; + try { + await superviseOrder({ + orderId: detail.value.id, + superviseResult: result, + superviseOpinion: superviseOpinion.value || undefined + }); + superviseOpinion.value = ''; + superviseRejectVisible.value = false; + detailVisible.value = false; + refresh(); + } finally { + submitting.value = false; + } +}; + +const openApproveNode = () => { + approveNode.nodeName = detail.value.currentNodeName || ''; + approveNode.nodeType = detail.value.currentNodeType || ''; + approveNode.amount = Number(detail.value.amount ?? 0); + approveForm.approveResult = 1; + approveForm.approveOpinion = ''; + approveVisible.value = true; +}; + +const doApproveNode = async () => { + if (approveForm.approveResult === 0 && !approveForm.approveOpinion.trim()) { + ElMessage.warning('驳回时请填写审批意见'); + return; + } + submitting.value = true; + try { + await approveOrder({ + orderId: detail.value.id, + approveResult: approveForm.approveResult, + approveOpinion: approveForm.approveOpinion || undefined + }); + approveVisible.value = false; detailVisible.value = false; refresh(); } finally { @@ -637,7 +903,9 @@ const doVerify = async (result: number) => { }; const doUrge = async () => { + const waitingAccept = detail.value.status === 'TO_ACCEPT' && !detail.value.handlerId; await urgeOrder(detail.value.id); + ElMessage.success(waitingAccept ? '已催办,已通知受理部门人员接单' : '已催办,已通知处理人'); detailVisible.value = false; }; @@ -745,7 +1013,7 @@ const doSubmitOrder = async () => { ElMessage.success('修改成功'); } else { await submitOrder({ ...createForm, images: createForm.images || undefined } as any); - ElMessage.success('发起成功'); + ElMessage.success('发起成功,已通知受理部门接单'); } submitVisible.value = false; detailVisible.value = false; @@ -755,59 +1023,6 @@ const doSubmitOrder = async () => { } }; -/* ---------- 改派 ---------- */ -const openReDispatch = async () => { - reForm.deptId = ''; - reForm.handlerId = ''; - reUserOptions.value = []; - if (deptTree.value.length === 0) { - const res = await getCommonDeptTree(); - deptTree.value = (res as any).data ?? []; - } - reVisible.value = true; -}; - -const onReDeptChange = async (deptId: any) => { - reForm.handlerId = ''; - if (!deptId) { - reUserOptions.value = []; - return; - } - const res = await getDeptUsers(deptId); - reUserOptions.value = (res as any).data ?? []; -}; - -/** 在部门树里找部门名称(作为维护单位名保存,与 Web 端一致) */ -const findDeptLabel = (nodes: any[], id: any): string | undefined => { - for (const n of nodes || []) { - if (n.id === id) return n.label; - const found = findDeptLabel(n.children || [], id); - if (found) return found; - } - return undefined; -}; - -const doReDispatch = async () => { - if (!reForm.deptId) return ElMessage.warning('请选择维护单位(部门)'); - if (!reForm.handlerId) return ElMessage.warning('请选择处理人'); - submitting.value = true; - try { - const user = reUserOptions.value.find((u) => u.userId === reForm.handlerId); - await dispatchOrder({ - orderId: detail.value.id, - handlerId: reForm.handlerId, - handlerName: user?.nickName, - maintainer: findDeptLabel(deptTree.value, reForm.deptId) - } as any); - ElMessage.success('已改派,钉钉消息已通知新处理人'); - reVisible.value = false; - detailVisible.value = false; - refresh(); - } finally { - submitting.value = false; - } -}; - /* ---------- 初始化 ---------- */ /** 钉钉通知卡片跳转:URL 带 orderId 时直达该工单详情 */ const openPendingOrder = async () => { @@ -834,6 +1049,22 @@ onMounted(async () => {