吉安感知网项目-前端
罗广辉
6 days ago 1d552a3bad95caae4af15322df28e6240b797693
applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue
@@ -1,6 +1,6 @@
<template>
   <el-dialog
      class="gd-dialog"
      class="gd-dialog orderManageFormDlg"
      v-model="visible"
      :title="titleEnum[dialogMode]"
      @closed="visible = false"
@@ -8,10 +8,23 @@
      destroy-on-close
      :close-on-click-modal="false"
   >
      <div class="content" style="display: flex">
         <div class="processBox" v-if="dialogMode !== 'add' && processList.length">
<!--            <div class="detail-title">工单记录</div>-->
            <OrderStepBar :processList="processList" />
      <el-tabs
         class="gd-tabs"
         v-model="activeName"
         @tab-click="tabsClick"
         v-if="dialogReadonly && formData.workOrderStatus >= '30'"
      >
         <el-tab-pane label="基础信息" name="basic"></el-tab-pane>
         <el-tab-pane label="成果数据" name="result">
            <OutcomeData :workOrderId="formData.id" />
         </el-tab-pane>
      </el-tabs>
      <div class="content" style="display: flex" v-if="activeName === 'basic'">
         <div class="processBox" v-if="dialogMode !== 'add'">
            <div class="detail-title">工单记录</div>
            <div class="process">
               <OrderStepBar :processList="processList" />
            </div>
         </div>
         <div class="leftBox">
            <div v-if="dialogReadonly">
@@ -23,7 +36,7 @@
                  </el-col>
                  <el-col :span="12">
                     <div class="label">工单类型</div>
                     <div class="val">{{ getDictLabel(formData.workOrderType, dictObj.workOrderType) }}</div>
                     <div class="val">{{ getTaskTypeLabel(formData.workOrderType, workOrderTypeXT) }}</div>
                  </el-col>
                  <el-col :span="12">
                     <div class="label">执行时间范围</div>
@@ -34,7 +47,7 @@
                  </el-col>
                  <el-col :span="12">
                     <div class="label">设备需求</div>
                     <div class="val">{{ getDictLabel(formData.deviceLoadDemand, dictObj.deviceLoadDemand) }}</div>
                     <div class="val">{{ formData.deviceLoadDemand }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div class="label">工单备注</div>
@@ -54,7 +67,7 @@
                     <el-table-column prop="patrolTaskName" show-overflow-tooltip label="巡查任务名称" />
                     <el-table-column prop="patrolTaskType" show-overflow-tooltip label="巡查任务类型">
                        <template v-slot="{ row }">
                           {{ getDictLabel(row.patrolTaskType, dictObj.workOrderType) }}
                           {{ getTaskTypeLabel(row.patrolTaskType, workOrderTypeXT) }}
                        </template>
                     </el-table-column>
                     <el-table-column prop="taskStatus" show-overflow-tooltip label="任务状态">
@@ -86,27 +99,22 @@
                  </el-col>
                  <el-col :span="12">
                     <el-form-item label="工单类型" prop="workOrderType">
                        <el-select
                           class="gd-select"
                           popper-class="gd-select-popper"
                        <el-cascader
                           class="gd-cascader"
                           popper-class="gd-cascader-popper"
                           v-model="formData.workOrderType"
                           :options="workOrderTypeXT"
                           :props="{...taskTypeCascaderProps,multiple:true }"
                           placeholder="请选择"
                           clearable
                        >
                           <el-option
                              v-for="item in dictObj.workOrderType"
                              :key="item.dictKey"
                              :label="item.dictValue"
                              :value="item.dictKey"
                           />
                        </el-select>
                           collapse-tags
                        />
                     </el-form-item>
                  </el-col>
                  <el-col :span="12">
                     <el-form-item label="执行时间" prop="executeStartTime">
                        <el-date-picker
                           class="gd-date-picker"
                           popper-class="gd-date-picker-popper"
                           v-model="dateRange"
                           type="daterange"
                           range-separator="至"
@@ -126,21 +134,16 @@
                           clearable
                           @change="loadDemandChange"
                        >
                           <el-option
                              v-for="item in dictObj.deviceLoadDemand"
                              :key="item.dictKey"
                              :label="item.dictValue"
                              :value="item.dictKey"
                           />
                           <el-option v-for="item in payloadList" :key="item.name" :label="item.name" :value="item.name" />
                        </el-select>
                     </el-form-item>
                  </el-col>
                  <el-col :span="24">
                     <el-form-item label="工单备注" prop="remark">
                        <el-input
                           class="gd-input"
                           class="gd-input-text"
                           type="textarea"
                           :rows="4"
                           :rows="3"
                           v-model="formData.remark"
                           placeholder="请输入"
                           clearable
@@ -149,7 +152,7 @@
                  </el-col>
               </el-row>
            </el-form>
            <div class="detail-title" :style="{ marginTop: pxToRem(20) }">
            <div class="detail-title" :style="{ marginTop: pxToRem(10) }">
               <span class="required-star" v-if="!dialogReadonly">*</span>
               工单执行范围
            </div>
@@ -172,11 +175,9 @@
            </div>
            <el-table
               class="separateTable"
               :empty-text="
                  formData.deviceLoadDemand && pointList.length ? '暂无数据' : '请先选择设备需求并在地图上绘制工单范围'
               "
               :empty-text="pointList.length ? '暂无数据' : '请先在地图上绘制工单范围'"
               ref="deviceTableRef"
               :data="formData.deviceLoadDemand && pointList.length ? deviceList : []"
               :data="pointList.length ? deviceList : []"
               row-key="id"
               @selection-change="handleDeviceSelectionChange"
            >
@@ -188,23 +189,31 @@
         </div>
      </div>
      <template #footer>
         <el-button v-if="['11', '21', '23', '31', '60'].includes(gdStatus)" @click="viewDescription" color="#F2F3F5">
      <template #footer v-if="activeName === 'basic' && detailLoaded">
         <el-button
            v-if="['11', '21', '23', '31', '60'].includes(gdStatus)"
            :disabled="footerLoading"
            @click="viewDescription"
            color="#F2F3F5"
         >
            {{ gdStatusObj[gdStatus]?.reason }}
         </el-button>
         <template v-if="!suddenlyEdit">
            <el-button
               @click="addDescription"
               v-if="['20'].includes(gdStatus) && permission.order_applyCancel"
               :disabled="footerLoading"
               @click="addDescription"
               color="#F2F3F5"
            >
               申请取消
            </el-button>
            <el-button
               color="#4C34FF"
               @click="requestModification"
               v-if="['20'].includes(gdStatus) && permission.order_applyEdit"
               :loading="modifying"
               :disabled="footerLoading"
               @click="requestModification"
               color="#4C34FF"
            >
               申请修改
            </el-button>
@@ -212,32 +221,86 @@
         <el-button
            v-if="(['11'].includes(gdStatus) || suddenlyEdit || !formData.id) && permission.order_release"
            :loading="submitting"
            :disabled="submitting"
            :disabled="footerLoading"
            color="#4C34FF"
            @click="handleSubmit"
         >
            {{ gdStatus === '11' || !gdStatus ? '发布' : '提交修改' }}
         </el-button>
         <el-button v-if="gdStatus === '50' && permission.order_settlement" @click="addDescription" color="#F2F3F5">
         <el-button
            v-if="gdStatus === '50' && permission.order_settlement"
            :disabled="footerLoading"
            @click="addDescription"
            color="#F2F3F5"
         >
            结算
         </el-button>
         <template v-if="permission.order_controlOrder">
            <el-button v-if="gdStatus === '10'" @click="addDescription" color="#F2F3F5">拒绝接单</el-button>
            <el-button v-if="gdStatus === '10'" @click="statusChange(1)" color="#4C34FF">接单</el-button>
            <el-button v-if="gdStatus === '10'" :disabled="footerLoading" @click="addDescription" color="#F2F3F5">
               拒绝接单
            </el-button>
            <el-button
               v-if="gdStatus === '10'"
               :loading="statusLoading === 1"
               :disabled="footerLoading"
               @click="statusChange(1)"
               color="#4C34FF"
            >
               接单
            </el-button>
         </template>
         <template v-if="permission.order_controlEdit">
            <el-button v-if="gdStatus === '22'" @click="statusChange(8)" color="#F2F3F5">驳回</el-button>
            <el-button v-if="gdStatus === '22'" @click="statusChange(7)" color="#4C34FF">同意</el-button>
            <el-button
               v-if="gdStatus === '22'"
               :loading="statusLoading === 8"
               :disabled="footerLoading"
               @click="statusChange(8)"
               color="#F2F3F5"
            >
               驳回
            </el-button>
            <el-button
               v-if="gdStatus === '22'"
               :loading="statusLoading === 7"
               :disabled="footerLoading"
               @click="statusChange(7)"
               color="#4C34FF"
            >
               同意
            </el-button>
         </template>
         <template v-if="permission.order_controlCancel">
            <el-button v-if="gdStatus === '21'" @click="statusChange(6)" color="#F2F3F5">驳回</el-button>
            <el-button v-if="gdStatus === '21'" @click="statusChange(5)" color="#4C34FF">通过</el-button>
            <el-button
               v-if="gdStatus === '21'"
               :loading="statusLoading === 6"
               :disabled="footerLoading"
               @click="statusChange(6)"
               color="#F2F3F5"
            >
               驳回
            </el-button>
            <el-button
               v-if="gdStatus === '21'"
               :loading="statusLoading === 5"
               :disabled="footerLoading"
               @click="statusChange(5)"
               color="#4C34FF"
            >
               通过
            </el-button>
         </template>
         <el-button v-if="gdStatus === '30' && permission.order_applyNegotiation" @click="addDescription" color="#4C34FF">
         <el-button
            v-if="gdStatus === '30' && permission.order_applyNegotiation"
            :disabled="footerLoading"
            @click="addDescription"
            color="#4C34FF"
         >
            协商修改
         </el-button>
         <el-button
            v-if="gdStatus === '31' && permission.order_controlNegotiation"
            :loading="statusLoading === 10"
            :disabled="footerLoading"
            @click="statusChange(10)"
            color="#4C34FF"
         >
@@ -255,7 +318,7 @@
</template>
<script setup>
import { computed, ref, nextTick } from 'vue'
import { computed, ref, nextTick, inject } from 'vue'
import { ElMessage } from 'element-plus'
import { dateRangeFormat, fieldRules, flyVisual, geomAnalysis, getDictLabel } from '@ztzf/utils'
import {
@@ -264,38 +327,47 @@
   gdWorkOrderHandleStatusApi,
   gdWorkOrderSaveApi,
} from './orderManageApi'
import { gdManageDeviceListApi } from './gdManageDeviceApi'
import { gdDevicePayloadListApi, gdManageDeviceListApi } from './gdManageDeviceApi'
import { cartesian3Convert } from '@/utils/cesium/mapUtil'
import * as Cesium from 'cesium'
import { DrawPolygon } from '@/utils/cesium/DrawPolygon'
import { DrawPolygon } from '@ztzf/utils'
import { pxToRem } from '@/utils/rem'
import dayjs from 'dayjs'
import RefuseOrderDialog from '@/views/orderView/orderManage/orderManage/RefuseOrderDialog.vue'
import CommonCesiumMap from '@/components/map-container/common-cesium-map.vue'
import { gdPatrolTaskPageApi } from '@/views/orderView/orderManage/inspectionRequest/inspectionRequestApi'
import { Check } from '@element-plus/icons-vue'
import { Check, Search, RefreshRight } from '@element-plus/icons-vue'
import droneIcon from '@/assets/images/orderView/orderManage/drone.png'
import droneActiveIcon from '@/assets/images/orderView/orderManage/droneActive.png'
import { useStore } from 'vuex'
import OrderStepBar from '@/views/orderView/orderManage/orderManage/OrderStepBar.vue'
import OutcomeData from './outcomeData.vue'
import { getDictListApi } from '@/api/zkxt'
import {
   getTaskTypeLabel,
   taskTypeCascaderProps,
} from '../taskTypeOptions'
const store = useStore()
const permission = computed(() => store.state.user.permission)
const activeName = ref('basic')
// 初始化表单数据
const initForm = () => ({
   workOrderName: '',
   workOrderType: '',
   workOrderType: [],
   executeStartTime: '',
   executeEndTime: '',
   deviceLoadDemand: '',
   remark: '',
   geom: '',
   recommendDeviceIds: '',
   typePinyinFirst: '',
})
const mapRef = ref(null)
const rejectVisible = ref(false)
const dictObj = inject('dictObj')
const workOrderTypeXT = inject('workOrderTypeXT', ref([]))
const dateRange = ref([])
const patrolTaskList = ref([])
const emit = defineEmits(['success'])
@@ -304,6 +376,10 @@
const visible = defineModel() // 弹框显隐
const dialogMode = ref('add') // 弹框模式
const submitting = ref(false) // 提交中
const modifying = ref(false) // 申请修改中
const statusLoading = ref(null) // 状态操作中
const footerLoading = computed(() => submitting.value || modifying.value || statusLoading.value !== null)
const detailLoaded = ref(false) // 详情加载完成
const dialogReadonly = computed(() => dialogMode.value === 'view')
const titleEnum = ref({ edit: '编辑', view: '查看', add: '新增' })
const deviceList = ref([]) // 设备列表
@@ -316,6 +392,7 @@
const suddenlyEdit = ref(false)
const processList = ref([])
let viewPlane
let allDeviceList = []
const hasPatrolTaskList = computed(() => ['30', '40', '50', '60'].includes(String(formData.value.workOrderStatus)))
const gdStatusObj = {
@@ -339,31 +416,41 @@
   workOrderName: fieldRules(true, 50),
   workOrderType: fieldRules(true),
   executeStartTime: fieldRules(true),
   deviceLoadDemand: fieldRules(true),
}
// 操作类型:1接单,2拒接接单,3申请取消,4申请修改, 5同意取消
// 6不同意取消 7.同意修改 8.不同意修改 9.协商修改,10:同意协商修改,11.结算
function statusChange(operationType) {
   gdWorkOrderHandleStatusApi({
      operationType: operationType,
      workOrderId: formData.value.id,
   }).then(res => {
async function statusChange(operationType) {
   if (footerLoading.value) return
   statusLoading.value = operationType
   try {
      await gdWorkOrderHandleStatusApi({
         operationType: operationType,
         workOrderId: formData.value.id,
      })
      visible.value = false
      emit('success')
   })
   } finally {
      statusLoading.value = null
   }
}
// 申请修改按钮
async function requestModification() {
   suddenlyEdit.value = true
   dialogMode.value = 'edit'
   await getDeviceList()
   nextTick(() => {
      syncSelection()
      viewPlane && viewer.entities.remove(viewPlane)
      editPolygon()
   })
   if (footerLoading.value) return
   modifying.value = true
   try {
      suddenlyEdit.value = true
      dialogMode.value = 'edit'
      await getDeviceList()
      nextTick(() => {
         syncSelection()
         viewPlane && viewer.entities.remove(viewPlane)
         editPolygon()
      })
   } finally {
      modifying.value = false
   }
}
// 填写说明弹框回调
@@ -430,16 +517,17 @@
// 提交新增/编辑
async function handleSubmit() {
   const isValid = await formRef.value?.validate().catch(() => false)
   if (!isValid) return
   if (!pointList.value.length) {
      return ElMessage.warning('请绘制范围')
   }
   if (!formData.value.recommendDeviceIds) {
      return ElMessage.warning('请选择设备')
   }
   if (footerLoading.value) return
   submitting.value = true
   try {
      const isValid = await formRef.value?.validate().catch(() => false)
      if (!isValid) return
      if (!pointList.value.length) {
         return ElMessage.warning('请绘制范围')
      }
      if (!formData.value.recommendDeviceIds) {
         return ElMessage.warning('请选择设备')
      }
      const str = [...pointList.value, pointList.value[0]].map(item => `${item.longitude} ${item.latitude}`).join(',')
      formData.value.geom = `POLYGON((${str}))`
      if (!formData.value.id) {
@@ -472,7 +560,7 @@
// 新增模式绘制
function addPolygon() {
   drawPolygonExample = new DrawPolygon(viewer)
   drawPolygonExample = new DrawPolygon({ deviceList: allDeviceList })
   drawPolygonExample.initHandler(viewer)
   drawPolygonExample.subscribe('getPolygonPositions', drawFinished)
}
@@ -494,7 +582,7 @@
   if (!formData.value?.geom) return
   pointList.value = geomAnalysis(formData.value.geom)
   drawPolygonExample?.destroy()
   drawPolygonExample = new DrawPolygon(viewer)
   drawPolygonExample = new DrawPolygon({ deviceList: allDeviceList })
   let noClosedList = _.cloneDeep(pointList.value)
   noClosedList.pop()
   drawPolygonExample.initPolygon(
@@ -512,11 +600,17 @@
   viewPlane = viewer.entities?.add({
      customType: 'control_group',
      position: Cesium.Cartesian3.fromDegrees(result[0], result[1]),
      polygon: {
         hierarchy: Cesium.Cartesian3.fromDegreesArray(result),
         material: Cesium.Color.fromBytes(45, 140, 240, 99),
         outline: false,
         heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
      },
      polyline: {
         positions: Cesium.Cartesian3.fromDegreesArray(result),
         clampToGround: true,
         width: 3,
         material: Cesium.Color.RED,
         width: 2,
         material: Cesium.Color.fromBytes(45, 140, 240, 255),
      },
   })
   flyVisual({
@@ -544,10 +638,24 @@
   })
}
//  生成圆形坐标点
function buildCirclePositions(center, radius, segments = 120) {
   const cartographic = Cesium.Cartographic.fromCartesian(center)
   const positions = []
   for (let i = 0; i < segments; i++) {
      const angle = (i / segments) * 2 * Math.PI
      const lat = cartographic.latitude + (radius / 6378137) * Math.cos(angle)
      const lon = cartographic.longitude + (radius / (6378137 * Math.cos(cartographic.latitude))) * Math.sin(angle)
      positions.push(Cesium.Cartesian3.fromRadians(lon, lat))
   }
   return positions
}
//  渲染
function renderingAllDevice(list) {
   list.forEach(item => {
      const position = Cesium.Cartesian3.fromDegrees(item.longitude || 115.0, item.latitude || 27.11)
      if (!item.longitude || !item.latitude) return
      const position = Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude)
      viewer.entities.add({
         position: position,
         billboard: {
@@ -555,6 +663,7 @@
            width: 30,
            height: 30,
            verticalOrigin: Cesium.VerticalOrigin.CENTER,
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
         },
         label: {
            text: item.nickname,
@@ -563,20 +672,52 @@
            outlineWidth: 2,
            outlineColor: Cesium.Color.WHITE,
            horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            pixelOffset: new Cesium.Cartesian2(0, -20),
         },
      })
      // 覆盖范围 - 5km圆形区域
      viewer.entities.add({
         position: position,
         ellipse: {
            semiMajorAxis: 5000,
            semiMinorAxis: 5000,
            material: Cesium.Color.fromBytes(45, 140, 240, 80),
            outline: false,
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
         },
      })
      // 覆盖范围描边线 - 贴地
      const circlePositions = buildCirclePositions(position, 5000)
      viewer.entities.add({
         polyline: {
            positions: [...circlePositions, circlePositions[0]],
            clampToGround: true,
            width: 2,
            material: Cesium.Color.fromBytes(45, 140, 240, 255),
         },
      })
   })
}
const payloadList = ref([])
function getPayloadList() {
   gdDevicePayloadListApi().then(res => {
      payloadList.value = res.data.data
   })
}
// 打开弹框
async function open({ mode = 'add', row } = {}) {
   detailLoaded.value = false
   dialogMode.value = mode
   getPayloadList()
   initMap()
   const allDeviceRes = await gdManageDeviceListApi()
   formData.value = dialogMode.value === 'add' ? initForm() : row
   renderingAllDevice(allDeviceRes?.data?.data || [])
   allDeviceList = allDeviceRes?.data?.data || []
   renderingAllDevice(allDeviceList)
   if (dialogMode.value === 'add') {
      addPolygon()
   } else {
@@ -584,6 +725,7 @@
      hasPatrolTaskList.value && gdPatrolTaskPage()
      dialogMode.value === 'edit' ? editPolygon() : viewPolygon()
   }
   detailLoaded.value = true
   await nextTick()
   await getDeviceList()
@@ -622,6 +764,36 @@
   }
)
// 取汉字(或英文)首字的拼音首字母,大写。如「占」→ Z
function getFirstPinyinLetter(text) {
   const char = String(text ?? '').trim().charAt(0)
   if (!char) return ''
   // 英文/数字直接取大写
   if (/[a-zA-Z]/.test(char)) return char.toUpperCase()
   // 按拼音排序的各首字母边界字,用 zh-CN 本地化比较定位所属字母
   const boundaries = [
      ['A', '啊'], ['B', '芭'], ['C', '擦'], ['D', '搭'], ['E', '蛾'],
      ['F', '发'], ['G', '噶'], ['H', '哈'], ['J', '击'], ['K', '喀'],
      ['L', '垃'], ['M', '妈'], ['N', '拿'], ['O', '哦'], ['P', '啪'],
      ['Q', '期'], ['R', '然'], ['S', '撒'], ['T', '塌'], ['W', '挖'],
      ['X', '昔'], ['Y', '压'], ['Z', '匝'],
   ]
   for (let i = boundaries.length - 1; i >= 0; i--) {
      if (char.localeCompare(boundaries[i][1], 'zh-CN') >= 0) return boundaries[i][0]
   }
   return ''
}
// 工单类型变化时,用类型名称第一个字的拼音首字母(大写)赋值给 typePinyinFirst
watch(
   () => formData.value.workOrderType,
   value => {
      const label = getTaskTypeLabel(value, workOrderTypeXT.value)
      formData.value.typePinyinFirst = getFirstPinyinLetter(label)
   },
   { deep: true }
)
// 地图加载完毕
function mapReady() {
   dialogMode.value === 'add' && mapRef.value.flyBoundary()
@@ -630,7 +802,20 @@
defineExpose({ open })
</script>
<style lang="scss" scoped>
<style lang="scss">
.orderManageFormDlg {
   .el-dialog__body {
      display: flex;
      flex-direction: column;
      .content {
         height: 0;
         flex: 1;
      }
   }
}
</style>
<style scoped lang="scss">
.separateTable {
   height: 0;
   flex: 1;
@@ -643,10 +828,11 @@
      }
   }
}
.content {
   display: flex;
   gap: 0 20px;
   height: 680px;
   //height: 630px;
   .leftBox {
      width: 0;
@@ -656,9 +842,10 @@
      flex-direction: column;
      .gd-cesium {
         position: relative;
         overflow: hidden;
         width: 100%;
         min-height: 380px;
         flex: 1;
         height: 390px;
      }
   }
@@ -666,20 +853,33 @@
      width: 350px;
      display: flex;
      flex-direction: column;
      .title {
         font-weight: 500;
         font-size: 14px;
         color: #272e37;
      }
      ::v-deep(.el-table) {
         tr th {
            font-weight: normal;
         }
      }
   }
   .processBox {
      padding: 12px 16px 24px 16px;
      width: 312px;
      border: 1px solid #e4e4e4;
      border-radius: 8px;
      overflow: auto;
      background: #fff;
      display: flex;
      flex-direction: column;
      .process {
         height: 100%;
         padding: 12px 16px 24px 16px;
         width: 312px;
         border: 1px solid #e4e4e4;
         border-radius: 8px;
         background: #fff;
         overflow: auto;
      }
   }
}