Browse Source

feat: 设备信息调整

master
betaqi 2 weeks ago
parent
commit
c99aff4817
  1. 1
      src/api/module/eam/device/index.ts
  2. 88
      src/pages/deviceInfo/components/BasicInfo.vue
  3. 2
      src/pages/deviceInfo/components/DeliveryInfo.vue
  4. 1
      src/pages/deviceInfo/components/TestInfo.vue
  5. 26
      src/pages/deviceInfo/index.vue
  6. 7
      src/pages/deviceInfo/info.vue
  7. 1
      src/pages/deviceInfo/utils.ts

1
src/api/module/eam/device/index.ts

@ -31,6 +31,7 @@ export interface IDeviceOV {
cost: string cost: string
currentFirmwareId: string currentFirmwareId: string
targetFirmwareId: string targetFirmwareId: string
iccid?: string
} }
export const operantDevice = (type: OperantAction, data: IDeviceOV) => { export const operantDevice = (type: OperantAction, data: IDeviceOV) => {

88
src/pages/deviceInfo/components/BasicInfo.vue

@ -30,18 +30,19 @@
class="input" class="input"
v-model="params.categoryId" v-model="params.categoryId"
:options="categoryTreeData" :options="categoryTreeData"
:disabled="disabled" :disabled="true"
:props="{ :props="{
checkStrictly: true, checkStrictly: true,
value: 'id', value: 'id',
label: 'name', label: 'name',
emitPath: false, emitPath: false,
}" }"
@change="onChangeCategoryId"
/> />
</div> </div>
</div> </div>
<div class="group-box"> <div class="group-box">
<div class="from-row"> <!-- <div class="from-row">
<div class="label">设备固件:</div> <div class="label">设备固件:</div>
<el-select <el-select
v-model="params.targetFirmwareId" v-model="params.targetFirmwareId"
@ -58,7 +59,7 @@
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
</div> </div> -->
<!--<div class="from-row"> <!--<div class="from-row">
<div class="label">测试模板:</div> <div class="label">测试模板:</div>
<FormItemSelect <FormItemSelect
@ -83,23 +84,22 @@
{{ params.currentFirmwareId }} {{ params.currentFirmwareId }}
</div> </div>
</div> </div>
<div class="from-row">
<div class="label">物联网卡:</div>
<el-input class="input" :disabled="action === 'view'" v-model="params.iccid" placeholder="请输入物联网卡号" />
</div>
<div class="from-row"> <div class="from-row">
<div class="label">设备成本:</div> <div class="label">设备成本:</div>
<number-input <number-input class="input" :disabled="action === 'view'" v-model="params.cost" placeholder="请输入成本" />
class="input"
:disabled="disabled"
v-model="params.cost"
placeholder="请输入成本"
/>
</div> </div>
</div> </div>
<div class="group-box"> <div class="group-box">
<div class="from-row"> <div class="from-row">
<div class="label">备注:</div> <div class="label">备注:</div>
<el-input <el-input
:disabled="disabled"
class="input" class="input"
type="textarea" type="textarea"
:disabled="action === 'view'"
v-model="params.description" v-model="params.description"
placeholder="请输入备注" placeholder="请输入备注"
:autosize="{ minRows: 5, maxRows: 4 }" :autosize="{ minRows: 5, maxRows: 4 }"
@ -107,20 +107,22 @@
/> />
</div> </div>
</div> </div>
<EdfsButton <div class="btns" style="margin-left: auto; margin-right: 20px; margin-top: auto">
inner-text="提交基础信息" <EdfsButton
type="primary" inner-text="提交基础信息"
class="save-button" type="primary"
v-if="isShowSaveButton" class="save-button"
@click="onSave" v-if="isShowSaveButton"
/> @click="onSave"
<EdfsButton />
inner-text="固件升级" <EdfsButton
type="primary" inner-text="固件升级"
class="save-button" type="primary"
v-if="isShowFirmwareUpgradeButton" class="save-button"
@click="onFirmwareUpgrade" v-if="isShowFirmwareUpgradeButton"
/> @click="onFirmwareUpgrade"
/>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -148,6 +150,14 @@ const props = defineProps<{
}>() }>()
const emit = defineEmits(['on-save']) const emit = defineEmits(['on-save'])
const updatedField: Array<keyof IDeviceOV> = [
'iccid',
'description',
'cost',
'serialNo',
'categoryId',
'sn',
]
const paramsData: IDeviceOV = { const paramsData: IDeviceOV = {
currentFirmwareId: '', currentFirmwareId: '',
@ -158,11 +168,13 @@ const paramsData: IDeviceOV = {
description: '', description: '',
cost: '', cost: '',
targetFirmwareId: '', targetFirmwareId: '',
iccid: '',
} }
const isShowSaveButton = computed(() => { const isShowSaveButton = computed(() => {
if (action === 'view') return false if (action === 'view') return false
return props.info?.status === undefined ? true : props.info.status < 2 // return props.info?.status === undefined ? true : props.info.status < 2
return true
}) })
const isShowFirmwareUpgradeButton = computed(() => { const isShowFirmwareUpgradeButton = computed(() => {
@ -179,7 +191,11 @@ async function onSave() {
if (!validate()) return if (!validate()) return
const type = !!params.value.serialNo ? 'update' : 'create' const type = !!params.value.serialNo ? 'update' : 'create'
const options = cloneDeep(params.value) let options = cloneDeep(params.value)
if (type === 'update' && props.info.status > 2) {
options = Object.fromEntries(updatedField.map(key => [key, options[key]]))
}
options.templateId = 0 options.templateId = 0
if (type === 'update') options.id = props.info?.id if (type === 'update') options.id = props.info?.id
const res = await operantDevice(type, options) const res = await operantDevice(type, options)
@ -201,17 +217,23 @@ watch(
{ immediate: true } { immediate: true }
) )
function onChangeCategoryId() {
params.value.targetFirmwareId = ''
}
watch( watch(
() => params.value.categoryId, () => params.value.targetFirmwareId,
val => { val => {
params.value.targetFirmwareId = '' console.log(val)
} }
) )
function validate() { function validate() {
if (isEmpty(params.value.targetFirmwareId)) { if (!params.value.currentFirmwareId) {
message.error('请选择固件') if (isEmpty(params.value.targetFirmwareId)) {
return false message.error('请选择固件')
return false
}
} }
if (isEmpty(params.value.sn)) { if (isEmpty(params.value.sn)) {
@ -307,14 +329,16 @@ onMounted(() => {
display: flex; display: flex;
width: 100%; width: 100%;
column-gap: 30px; column-gap: 30px;
row-gap: 10px;
flex-wrap: wrap; flex-wrap: wrap;
max-width: 1340px;
.group-box { .group-box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
row-gap: 10px; row-gap: 10px;
} }
.from-row { .from-row {
width: 320px; width: 346px;
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
min-height: 32px; min-height: 32px;

2
src/pages/deviceInfo/components/DeliveryInfo.vue

@ -20,7 +20,7 @@
<number-input <number-input
v-model="params.price" v-model="params.price"
:disabled="action === 'view' || !isShowSaveButton" :disabled="action === 'view' || !isShowSaveButton"
placeholder="请输入成本" placeholder="请输入设备价格"
/> />
</div> </div>
</div> </div>

1
src/pages/deviceInfo/components/TestInfo.vue

@ -124,7 +124,6 @@ async function loadDeviceTestSheet() {
}) })
if (isResError(res)) return if (isResError(res)) return
list.value = res.data list.value = res.data
console.log(list.value)
} }
const isShowDetail = ref(false) const isShowDetail = ref(false)
const sheetDetail = ref<any>([]) const sheetDetail = ref<any>([])

26
src/pages/deviceInfo/index.vue

@ -10,7 +10,7 @@
</div> </div>
<EdfsWrap title="设备信息列表" class="device-info-table"> <EdfsWrap title="设备信息列表" class="device-info-table">
<template #title-right> <template #title-right>
<EdfsButton type="primary" inner-text="新增设备" @click="addDevice" /> <!-- <EdfsButton type="primary" inner-text="新增设备" @click="addDevice" /> -->
</template> </template>
<EdfsTable <EdfsTable
class="table" class="table"
@ -66,7 +66,7 @@
> >
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item command="info" v-if="scope.row.status < 2"> <el-dropdown-item command="info">
<Icon icon="solar:clapperboard-edit-linear" />编辑基础信息 <Icon icon="solar:clapperboard-edit-linear" />编辑基础信息
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="test" v-if="scope.row.status === 1"> <el-dropdown-item command="test" v-if="scope.row.status === 1">
@ -105,7 +105,7 @@ import EdfsTable from '@/components/dashboard/Edfs-table/index.vue'
import EdfsButton from '@/components/dashboard/Edfs-button/index.vue' import EdfsButton from '@/components/dashboard/Edfs-button/index.vue'
import { isResError } from '@/hooks/useMessage' import { isResError } from '@/hooks/useMessage'
import type { TableColumnCtx } from 'element-plus' import type { TableColumnCtx } from 'element-plus'
import { useRouter } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import PieChart from './components/pie-chart.vue' import PieChart from './components/pie-chart.vue'
import { import {
getDeviceLabelBase64, getDeviceLabelBase64,
@ -113,6 +113,7 @@ import {
getDeviceSummaryByStatus, getDeviceSummaryByStatus,
getDeviceReportPDF, getDeviceReportPDF,
type IDevice, type IDevice,
getDeviceInfo,
} from '@/api/module/eam/device' } from '@/api/module/eam/device'
import { ElLoading } from 'element-plus' import { ElLoading } from 'element-plus'
import { deviceTableCol, DeviceStatus } from './utils' import { deviceTableCol, DeviceStatus } from './utils'
@ -122,6 +123,24 @@ import jsPDF from 'jspdf'
defineOptions({ defineOptions({
name: 'DeviceList', name: 'DeviceList',
}) })
const route = useRoute()
// updateId number undefined
const updateId = ref<number | undefined>(
route.query.updateId !== undefined && route.query.updateId !== null
? Number(route.query.updateId)
: undefined
)
onActivated(async () => {
await nextTick()
const index = list.value.findIndex(r => r.id === updateId.value)
if (updateId.value && index !== -1) {
const res = await getDeviceInfo(updateId.value)
if (!isResError(res)) {
list.value[index] = res.data
}
}
})
const loading = ref(true) const loading = ref(true)
const total = ref(0) const total = ref(0)
@ -262,7 +281,6 @@ function handleCommand(command: string, row: any) {
onPrint(row) onPrint(row)
return return
} }
debugger
editDevice(row, command) editDevice(row, command)
} }

7
src/pages/deviceInfo/info.vue

@ -6,7 +6,12 @@
class="back-btn" class="back-btn"
@click=" @click="
() => { () => {
router.go(-1) router.push({
path: '/device/data',
query: {
updateId: deviceInfoId,
},
})
} }
" "
/> />

1
src/pages/deviceInfo/utils.ts

@ -12,6 +12,7 @@ export const deviceTableCol = [
{ label: '设备类型', prop: 'categoryName', minWidth: '10%' }, { label: '设备类型', prop: 'categoryName', minWidth: '10%' },
{ label: '设备状态', prop: 'status', minWidth: '10%' }, { label: '设备状态', prop: 'status', minWidth: '10%' },
{ label: '创建时间', prop: 'createTime', minWidth: '10%' }, { label: '创建时间', prop: 'createTime', minWidth: '10%' },
{ label: 'sd', prop: 'cost', minWidth: '10%' }
] ]
export type OptAction = 'create' | 'update' | 'view' export type OptAction = 'create' | 'update' | 'view'

Loading…
Cancel
Save