|
|
@@ -0,0 +1,269 @@
|
|
|
+<template>
|
|
|
+ <a-button type="primary" :disabled="disabled" @click="editBtn">编辑</a-button>
|
|
|
+ <a-drawer
|
|
|
+ v-model:visible="visible"
|
|
|
+ class="custom-class"
|
|
|
+ title="编辑设备"
|
|
|
+ placement="right"
|
|
|
+ width="500px"
|
|
|
+ :closable="false"
|
|
|
+ @close="visible = false"
|
|
|
+ >
|
|
|
+ <a-form ref="formRef" :model="form" size="small" layout="vertical" mode="multiple">
|
|
|
+ <a-row :gutter="16">
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="设备编码" name="serialnumber" :rules="[{ required: true, message: '请输入设备编码' }]">
|
|
|
+ <a-input v-model:value="form.serialnumber" placeholder="请输入设备编码"></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="设备名称" name="devicename" :rules="[{ required: true, message: '请输入设备名称' }]">
|
|
|
+ <a-input v-model:value="form.devicename" placeholder="请输入设备名称"></a-input>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="所属产品" name="prodname" :rules="[{required:true,message:'请选择所属产品'}]">
|
|
|
+ <!-- @handleList="handleList" -->
|
|
|
+ <SelectModel
|
|
|
+ ref="product"
|
|
|
+ @selectRowData="selectProduct"
|
|
|
+ rowKey="w_productid"
|
|
|
+ :param="productParam"
|
|
|
+ :filterMultiple="true"
|
|
|
+ :columns="utils.TBLayout('productListTable')" title="选择所属产品"
|
|
|
+ >
|
|
|
+ <template v-slot:slot1>
|
|
|
+ <a-input-search
|
|
|
+ v-model:value="form.prodname"
|
|
|
+ enter-button="选择"
|
|
|
+ readonly
|
|
|
+ @search="$refs.product.modeVisible=true"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </SelectModel>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="所属区域" name="areaname" :rules="[{required:true,message:'请选择所属区域'}]">
|
|
|
+ <SelectModel
|
|
|
+ ref="area"
|
|
|
+ @selectRowData="selectArea"
|
|
|
+ rowKey="w_areaid"
|
|
|
+ :param="areaParam"
|
|
|
+ :filterMultiple="true"
|
|
|
+ :columns="utils.TBLayout('areaTable')" title="选择所属区域"
|
|
|
+ @handleList="handleList"
|
|
|
+ >
|
|
|
+ <template v-slot:slot1>
|
|
|
+ <a-input-search
|
|
|
+ v-model:value="form.areaname"
|
|
|
+ enter-button="选择"
|
|
|
+ readonly
|
|
|
+ @search="$refs.area.modeVisible=true"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </SelectModel>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="物联卡" name="iccid" :rules="[{required:true,message:'请选择物联卡'}]">
|
|
|
+ <SelectModel
|
|
|
+ ref="card"
|
|
|
+ @selectRowData="selectCard"
|
|
|
+ rowKey="w_iotcardid"
|
|
|
+ :param="cardParam"
|
|
|
+ :filterMultiple="true"
|
|
|
+ :columns="utils.TBLayout('cardTable')" title="选择物联卡"
|
|
|
+ >
|
|
|
+ <template v-slot:slot1>
|
|
|
+ <a-input-search
|
|
|
+ v-model:value="form.iccid"
|
|
|
+ enter-button="选择"
|
|
|
+ readonly
|
|
|
+ @search="$refs.card.modeVisible=true"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </SelectModel>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="消息协议" name="sys_msgprotocolid" :rules="[{required:true,message:'请选择消息协议'}]">
|
|
|
+ <a-select
|
|
|
+ v-model:value="form.sys_msgprotocolid"
|
|
|
+ placeholder="请选择消息协议"
|
|
|
+ >
|
|
|
+ <a-select-option v-for="item in msgprotocolList" :key="item.sys_msgprotocolid" :value="item.sys_msgprotocolid">{{ item.protocolname }}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="省市县" name="province">
|
|
|
+ <a-cascader v-model:value="form.province" :options="province" placeholder="请选择" change-on-select />
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="描述" name="remarks">
|
|
|
+ <a-textarea v-model:value="form.remarks" placeholder="请输入描述"></a-textarea>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="是否启用" name="isused">
|
|
|
+ <a-checkbox v-model:checked="form.isused"></a-checkbox>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-form>
|
|
|
+ <template #extra>
|
|
|
+ <a-space>
|
|
|
+ <a-button @click="visible=false">关闭</a-button>
|
|
|
+ <a-button type="primary" @click="onSubmit">保存</a-button>
|
|
|
+ </a-space>
|
|
|
+ </template>
|
|
|
+ </a-drawer>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import {ref, defineProps, defineEmits, onMounted} from 'vue'
|
|
|
+import SelectModel from '@/components/selectModel/index.vue'
|
|
|
+import Api from '@/api/api'
|
|
|
+import utils from '@/utils/utils'
|
|
|
+import { useBaseStore } from '@/stores/modules/base'
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
+import { log } from 'mathjs'
|
|
|
+
|
|
|
+let base = useBaseStore()
|
|
|
+let emit = defineEmits(['onSuccess'])
|
|
|
+let props = defineProps(['disabled','data'])
|
|
|
+let searchType = ref([{label:'搜索',key:'condition',type:'input'}])
|
|
|
+let visible = ref(false)
|
|
|
+let form = ref({
|
|
|
+ "w_deviceid": 0,
|
|
|
+ "w_productid": 1,
|
|
|
+ "prodname":'',
|
|
|
+ "serialnumber": "",
|
|
|
+ "devicename": "",
|
|
|
+ "w_areaid": 1,
|
|
|
+ "areaname":'',
|
|
|
+ "longitude": "",
|
|
|
+ "latitude": "",
|
|
|
+ "province": "",
|
|
|
+ "city": "",
|
|
|
+ "county": "",
|
|
|
+ "address": "",
|
|
|
+ "isused": 1,
|
|
|
+ "remarks": "",
|
|
|
+ "sys_msgprotocolid": 1,//自定义
|
|
|
+ "w_iotcardid":'',
|
|
|
+ "iccid":''
|
|
|
+})
|
|
|
+let productParam = ref({
|
|
|
+ "id": 20230612103202,
|
|
|
+ "content": {
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 20,
|
|
|
+ "where": {
|
|
|
+ "condition": "",
|
|
|
+ "prodtype": "",
|
|
|
+ "enterprisename": "",
|
|
|
+ "isused": "" //0,1
|
|
|
+ }
|
|
|
+ },
|
|
|
+})
|
|
|
+let areaParam = ref({
|
|
|
+ "id": 20230608152602,
|
|
|
+ "content": {
|
|
|
+
|
|
|
+ },
|
|
|
+})
|
|
|
+let province = ref([])
|
|
|
+let formRef = ref()
|
|
|
+let msgprotocolList = ref([])
|
|
|
+
|
|
|
+let editBtn = () => {
|
|
|
+ visible.value = true
|
|
|
+ form.value = Object.assign({},form.value,props.data)
|
|
|
+ if (form.value.province) form.value.province = [form.value.province,form.value.city,form.value.county]
|
|
|
+ console.log(props.data);
|
|
|
+}
|
|
|
+let onSubmit = async () => {
|
|
|
+ console.log(form.value);
|
|
|
+ let isCheck = await formRef.value.validateFields()
|
|
|
+ if (!isCheck) return
|
|
|
+ if (form.value.province) {
|
|
|
+ form.value.city = form.value.province[1]
|
|
|
+ form.value.county = form.value.province[2]
|
|
|
+ form.value.province = form.value.province[0]
|
|
|
+ }
|
|
|
+ form.value.isused = form.value.isused ? 1 : 0
|
|
|
+ let res = await Api.requested({
|
|
|
+ id:20230615091502,
|
|
|
+ content: form.value
|
|
|
+ })
|
|
|
+ utils.message(res,'操作成功',() => {
|
|
|
+ visible.value = false
|
|
|
+ emit('onSuccess')
|
|
|
+ formRef.value.resetFields()
|
|
|
+ console.log(res);
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+let selectProduct = (data) => {
|
|
|
+ console.log(data);
|
|
|
+ form.value.w_productid = data[data.length - 1].w_productid
|
|
|
+ form.value.prodname = data[data.length - 1].prodname
|
|
|
+}
|
|
|
+
|
|
|
+let selectArea = (data) => {
|
|
|
+ form.value.w_areaid = data[data.length -1].w_areaid
|
|
|
+ form.value.areaname = data[data.length - 1].areaname
|
|
|
+}
|
|
|
+
|
|
|
+let handleList = (res) => {
|
|
|
+ res.data = createDeep(res.data)
|
|
|
+}
|
|
|
+
|
|
|
+let createDeep = (array) => {
|
|
|
+ let arr = []
|
|
|
+ function deepFun (node) {
|
|
|
+ console.log(node,'触发');
|
|
|
+ let elNode = {
|
|
|
+ areaname:node['areaname'],
|
|
|
+ areanum:node['areanum'],
|
|
|
+ isused:node['isused'],
|
|
|
+ parentid:node['parentid'],
|
|
|
+ parentname:node['parentname'],
|
|
|
+ remarks:node['remarks'],
|
|
|
+ sequence:node['sequence'],
|
|
|
+ w_areaid:node['w_areaid'],
|
|
|
+ children:[]
|
|
|
+ }
|
|
|
+ if (node.sub && node.sub.length > 0) {
|
|
|
+ // 如果存在子节点
|
|
|
+ for (var index = 0; index < node.sub.length; index++) {
|
|
|
+ // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
|
|
|
+ elNode.children.push(deepFun(node.sub[index]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!elNode.children.length) delete elNode.children
|
|
|
+ return elNode
|
|
|
+ }
|
|
|
+ array.forEach(item => {
|
|
|
+ console.log(item);
|
|
|
+ arr.push(deepFun(item))
|
|
|
+ })
|
|
|
+ return arr
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ let res = await base.optiontypeselect('msgprotocol')
|
|
|
+ msgprotocolList.value = res.data
|
|
|
+ console.log(msgprotocolList.value,'消息协议');
|
|
|
+ province.value = await base.ProvincesData()
|
|
|
+})
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|