吉安感知网项目-前端
chenyao
10 hours ago 08a8157bcea47af44cc5477e5f698a0cea22a69c
applications/task-work-order/src/views/orderView/deviceInvocation/deviceCallRecord/FormDiaLog.vue
@@ -2,39 +2,41 @@
   <el-dialog class="gd-dialog" v-model="visible" :title="dialogTitle" @closed="handleClosed" destroy-on-close
                   :close-on-click-modal="false">
      <!--      <div class="detail-row-view" v-if="dialogReadonly">-->
      <el-table :data="list" class="gd-dialog-table">
         <el-table-column prop="resultCode" show-overflow-tooltip label="序号" />
         <el-table-column prop="resultCode" show-overflow-tooltip label="设备状态" />
         <el-table-column prop="shootTime" show-overflow-tooltip label="发生时间" />
      <el-table :data="detailsList" class="gd-dialog-table">
         <el-table-column type="index" show-overflow-tooltip label="序号" />
         <el-table-column prop="deviceStatus" show-overflow-tooltip label="设备状态" />
         <el-table-column prop="occurTime" show-overflow-tooltip label="发生时间" />
      </el-table>
      <div class="gd-pagination-parent">
         <el-pagination
            popper-class="gd-select-popper"
            v-model:current-page="formData.current"
            v-model:page-size="formData.size"
            layout="total, prev, pager, next, sizes"
            :total="total"
            @change="loadDetail"
         />
      </div>
   </el-dialog>
</template>
<script setup>
import { computed, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { add, getUser, update } from '@/api/system/user'
import { getDeviceCallRecordDetails } from './deviceCallRecordApi'
import { getDeptTree } from '@/api/system/dept'
import { getRoleTree } from '@/api/system/role'
import func from '@/utils/func'
import { saveOperationLog } from '@ztzf/apis'
import { useRoute } from 'vue-router'
const list = ref([])
const detailsList = ref([])
const total = ref(0)
const initForm = () => ({
   account: '',
   password: '',
   password2: '',
   realName: '',
   phone: '',
   email: '',
   sex: null,
   birthday: '',
   code: '',
   roleId: '',
   deptId: '',
   // sysType: 6
   callId: '',
   size: 10,
   current: 1
})
const treeProps = {
@@ -63,45 +65,40 @@
const deptTree = ref([])
const route = useRoute()
const validatePass = (rule, value, callback) => {
   if (value === '') {
      callback(new Error('请输入密码'))
   } else {
      callback()
const statusList = ref(['待机','起飞准备','起飞准备完毕','手动飞行','自动起飞','航线飞行','全景拍照','智能跟随',
'ADS-B 躲避','自动返航','自动降落','强制降落','三桨叶降落','升级中','未连接','APAS','虚拟摇杆状态','指令飞行','空中 RTK 收敛模式',
'机场选址中','POI环绕'])
function getStatusText(statusIndex) {
   // 如果状态索引为 null、undefined 或无效
   if (statusIndex === null || statusIndex === undefined || statusIndex === '') {
      return '--';
   }
}
const validatePass2 = (rule, value, callback) => {
   if (value === '') {
      callback(new Error('请再次输入密码'))
   } else if (value !== formData.value.password) {
      callback(new Error('两次输入密码不一致'))
   } else {
      callback()
   // 将状态索引转换为数字
   const index = Number(statusIndex);
   // 检查索引是否有效(在数组范围内)
   if (!isNaN(index) && index >= 0 && index < statusList.value.length) {
      return statusList.value[index];
   }
   // 无效索引返回默认值
   console.warn(`无效的设备状态索引: ${statusIndex}`);
   return '未知状态';
}
async function getRoleTreeData() {
   const res = await getRoleTree('000000')
   roleTree.value = res.data.data
}
async function getDeptTreeData() {
   const res = await getDeptTree('000000')
   deptTree.value = res.data.data
}
function handleCancel() {
   visible.value = false
}
async function loadDetail() {
   if (!formData.value.id) return
   const res = await getUser(formData.value.id)
   const data = res?.data?.data ?? {}
   if (data.roleId) {
      data.roleId = func.split(data.roleId)[0] || data.roleId
   }
   formData.value = data
   const res = await getDeviceCallRecordDetails(formData.value)
   detailsList.value = res?.data?.data.records || []
   total.value = res?.data?.data.total || 0
}
function handleClosed() {
@@ -111,17 +108,11 @@
async function open({ mode, row } = {}) {
   dialogMode.value = mode || 'add'
   visible.value = true
   if (dialogMode.value === 'add') {
      formData.value = initForm()
      return
   }
   formData.value = { id: row.id }
   formData.value.callId = row.id || ''
   await loadDetail()
}
onMounted(() => {
   getRoleTreeData()
   getDeptTreeData()
})
defineExpose({ open })