溯源操作
This commit is contained in:
parent
6c4ab07217
commit
76d1fc1df7
|
@ -38,4 +38,9 @@ export function apiDeviceDetail(params: any) {
|
|||
// 设备监控数据
|
||||
export function apiDeviceMonitorData(params: any) {
|
||||
return request.get({ url: '/device.device/monitorData', params })
|
||||
}
|
||||
|
||||
// 设备编码和ICCID
|
||||
export function apiDeviceIccid(params: any) {
|
||||
return request.get({ url: '/device.device/queryDeviceIccid', params })
|
||||
}
|
|
@ -40,12 +40,39 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备编码" prop="code">
|
||||
<el-input v-model="formData.code" clearable placeholder="请输入设备编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设备编码" prop="code">
|
||||
<el-select
|
||||
v-model="formData.code"
|
||||
remote
|
||||
filterable
|
||||
:remote-method="queryDeviceIccid"
|
||||
@change="deviceChange"
|
||||
:loading="loading"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in optionsData.deviceIccids"
|
||||
:key="index"
|
||||
:label="item.device_sn"
|
||||
:value="item.device_sn"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="设备编码" prop="code">-->
|
||||
<!-- <el-input v-model="formData.code" clearable placeholder="请输入设备编码" />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="硬件ICCID" prop="iccid">
|
||||
<el-input v-model="formData.iccid" clearable placeholder="请输入ICCID" />
|
||||
<el-input v-model="formData.iccid" disabled placeholder="请输入ICCID" />
|
||||
</el-form-item>
|
||||
<el-form-item label="监测项" prop="monitor_item" >
|
||||
<el-select class="flex-1" v-model="formData.monitor_item" multiple disabled placeholder="请选择设备监测项">
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.monitor_item"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备图" prop="image">
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
|
@ -70,16 +97,7 @@
|
|||
</el-upload>
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="监测项" prop="monitor_item">
|
||||
<el-select class="flex-1" v-model="formData.monitor_item" multiple clearable placeholder="请选择设备监测项">
|
||||
<el-option
|
||||
v-for="(item, index) in dictData.monitor_item"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="视频地址" prop="video_url">
|
||||
<el-input v-model="formData.video_url" clearable placeholder="请输入视频地址" />
|
||||
</el-form-item>
|
||||
|
@ -112,7 +130,7 @@
|
|||
import { useDictOptions } from '@/hooks/useDictOptions'
|
||||
import {type FormInstance } from 'element-plus'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import { apiDeviceAdd, apiDeviceEdit, apiDeviceDetail, getUserList, apiProductLists} from '@/api/device'
|
||||
import {apiDeviceAdd, apiDeviceEdit, apiDeviceDetail, getUserList, apiProductLists, apiDeviceIccid} from '@/api/device'
|
||||
import { timeFormat } from '@/utils/util'
|
||||
import type { PropType } from 'vue'
|
||||
import {ref} from "vue";
|
||||
|
@ -157,7 +175,7 @@ const formData = reactive({
|
|||
name: '',
|
||||
video_url: '',
|
||||
type: '',
|
||||
monitor_item: '',
|
||||
monitor_item: [],
|
||||
status: '',
|
||||
is_online: '',
|
||||
image: ''
|
||||
|
@ -191,7 +209,34 @@ const formRules = reactive<any>({
|
|||
trigger: ['blur']
|
||||
}],
|
||||
})
|
||||
const deviceChange = async (value: string) => {
|
||||
const temp = await apiDeviceIccid({
|
||||
deviceId: value ?? ''
|
||||
})
|
||||
formData.iccid = temp[0]['iccid']
|
||||
if ( temp[0]['type'] == 0) {
|
||||
formData.monitor_item = ['temperature']
|
||||
}
|
||||
if ( temp[0]['type'] == 1) {
|
||||
formData.monitor_item = ['ambient_temperature','ambient_humidity']
|
||||
}
|
||||
if ( temp[0]['type'] == 2) {
|
||||
formData.monitor_item = ['nitrogen']
|
||||
}
|
||||
if ( temp[0]['type'] == 3) {
|
||||
formData.monitor_item = ['methane']
|
||||
}
|
||||
if ( temp[0]['type'] == 4) {
|
||||
formData.monitor_item = ['noise']
|
||||
|
||||
}
|
||||
if ( temp[0]['type'] == 5) {
|
||||
formData.monitor_item = ['fireproof']
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
const setFormData = async (data: Record<any, any>) => {
|
||||
|
@ -204,13 +249,20 @@ const setFormData = async (data: Record<any, any>) => {
|
|||
}
|
||||
|
||||
const { optionsData } = useDictOptions<{
|
||||
product: any[]
|
||||
product: any[],
|
||||
deviceIccids: any[],
|
||||
}>({
|
||||
product: {
|
||||
api: apiProductLists,
|
||||
params: {
|
||||
all: 1
|
||||
}
|
||||
},
|
||||
deviceIccids:{
|
||||
api: apiDeviceIccid,
|
||||
params: {
|
||||
all: 1
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -225,6 +277,15 @@ const queryProduct = async (query: string) => {
|
|||
loading.value = false
|
||||
}
|
||||
|
||||
const queryDeviceIccid = async (query: string) => {
|
||||
loading.value = true
|
||||
const deviceList = await apiDeviceIccid({
|
||||
deviceId: query ?? ''
|
||||
})
|
||||
optionsData.deviceIccids = deviceList
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
const data = await apiDeviceDetail({
|
||||
|
@ -260,7 +321,7 @@ const generateUuid = (length: number) => {
|
|||
//打开弹窗
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
formData.code = generateUuid(3)
|
||||
// formData.code = generateUuid(3)
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ use app\adminapi\controller\BaseAdminController;
|
|||
use app\adminapi\lists\device\DeviceLists;
|
||||
use app\adminapi\logic\device\DeviceLogic;
|
||||
use app\adminapi\validate\device\DeviceValidate;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -122,4 +123,27 @@ class DeviceController extends BaseAdminController
|
|||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
public function queryDeviceIccid()
|
||||
{
|
||||
$iccid = $this->request->param('iccid', '');
|
||||
$deviceId = $this->request->param('deviceId', '');
|
||||
$requestResponse = HttpClient::create()->request('GET', env('PROJECT.MQTT_PROJECT_URL'). '/api/xumu/device/query', [
|
||||
'query' => ["iccid"=>$iccid, "deviceId"=>$deviceId],
|
||||
|
||||
]);
|
||||
$result = json_decode($requestResponse->getContent(), true);
|
||||
$re = $result['data']['values'];
|
||||
$datas = [];
|
||||
$iccidRow = $re[0];
|
||||
$typeRow = $re[1];
|
||||
$snRow = $re[2];
|
||||
foreach ($iccidRow as $key => $value){
|
||||
$datas[$key]['iccid'] = $value;
|
||||
$datas[$key]['device_sn'] = $snRow[$key];
|
||||
$datas[$key]['type'] = $typeRow[$key];
|
||||
}
|
||||
return $this->data($datas);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue