Jelajahi Sumber

代码同步(档案待测试)

yukai 1 tahun lalu
induk
melakukan
547d02af98

+ 1 - 0
src/api/device/index.ts

@@ -114,6 +114,7 @@ export default {
   },
   dev_asset_metadata:{
     getList: (params: object) => get('/product/dev_asset_metadata/list', params),
+    getprokey: (params: object) => get('/product/dev_asset_metadata/key', params),
     add: (params: object) => post('/product/dev_asset_metadata/add', params),
     edit: (params: object) => put('/product/dev_asset_metadata/edit', params),
     detail: (params: object) => get('/product/dev_asset_metadata/get', params),

+ 6 - 4
src/views/iot/property/attribute/index.vue

@@ -2,8 +2,8 @@
 	<el-card shadow="hover">
 		<div class="search">
 			<el-form :inline="true" ref="queryRef" @keyup.enter="getList(1)">
-				<el-form-item label="名称:" prop="keyWord">
-					<el-input v-model="params.keyWord" placeholder="请输入名称" clearable size="default" style="width: 240px" />
+				<el-form-item label="关键字:" prop="keyWord">
+					<el-input v-model="params.keyWord" placeholder="请输入关键字" clearable size="default" style="width: 240px" />
 				</el-form-item>
 
 				<el-form-item>
@@ -45,6 +45,8 @@
 					</el-tree>
 			</el-col>
 			<el-col :span="18"><el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
+					<el-table-column type="selection" width="55" align="center" />
+
 					<el-table-column prop="id" label="ID" min-width="100" show-overflow-tooltip></el-table-column>
 					<el-table-column prop="name" label="字段名称" show-overflow-tooltip></el-table-column>
 					<el-table-column prop="title" label="字段标题" show-overflow-tooltip></el-table-column>
@@ -98,7 +100,7 @@ const editFormRef = ref()
 const productIno=ref();
 
 
-const { params, tableData, getList, loading } = useSearch<any[]>(device.dev_asset_metadata.getList, 'Data', { keyWord: '' })
+const { params, tableData, getList, loading } = useSearch<any[]>(device.dev_asset_metadata.getList, 'Data', { keyWord: ''})
 getList()
 const toDetail = (id: number) => {
 	router.push(`/device/dossier/manage/${id}`)
@@ -183,7 +185,7 @@ const del = (row: any) => {
 		cancelButtonText: '取消',
 		type: 'warning',
 	}).then(async () => {
-		await device.dev_asset_metadata.delete(row.id)
+		await device.dev_asset_metadata.delete({ids:row.id})
 		ElMessage.success('删除成功')
 		getList()
 	})

+ 55 - 0
src/views/iot/property/dossier/component/from.vue

@@ -0,0 +1,55 @@
+<template>
+  <div>
+    <div v-for="(item, index) in Datalist" :key="index">
+      <el-form-item
+        :label="item.title + ':'"
+        :prop="item.name"
+        class="form-item"
+        v-if="item.types === 'input'"
+      >
+        <el-input
+          v-model="formData[item.name]"
+          :placeholder="'请输入' + item.title"
+          @input="saveData"
+        />
+      </el-form-item>
+      <el-form-item
+        :label="item.title + ':'"
+        :prop="item.name"
+        class="form-item"
+        v-if="item.types === 'textarea'"
+      >
+        <el-input
+          v-model="formData[item.name]"
+          type="textarea"
+          @input="saveData"
+        />
+      </el-form-item>
+    </div>
+  </div>
+</template>
+
+<script lang="ts" setup>
+import { defineProps, ref, defineEmits } from 'vue';
+
+const emit = defineEmits(['SetSaveData']);
+
+const props = defineProps({
+  Datalist: {
+    type: Array,
+    default: () => []
+  },
+});
+
+const formData = ref({});
+
+const saveData = () => {
+  emit('SetSaveData', formData.value);
+};
+</script>
+
+<style scoped lang="scss">
+.form-item {
+  flex: 0 0 25%;
+}
+</style>

+ 51 - 100
src/views/iot/property/dossier/edit.vue

@@ -6,7 +6,7 @@
 			<el-row>
 				<el-col :span="12">
 					<el-form-item label="选择产品" prop="productKey">
-						<el-select v-model="formData.productKey" placeholder="请选择产品" class="w100" clearable>
+						<el-select v-model="formData.productKey" placeholder="请选择产品" class="w100" disabled>
 							<el-option v-for="item in productData" :key="item.key" :label="item.name" :value="item.key">
 							<span style="float: left">{{ item.name }}</span>
 							<span style="float: right; font-size: 13px">{{ item.key }}</span>
@@ -30,13 +30,13 @@
 			<el-row>
 				<el-col :span="12">
 					<el-form-item label="设备名称" prop="deviceName">
-						<el-input v-model.trim="formData.deviceName" placeholder="请输入设备名称" />
+						<el-input v-model.trim="formData.deviceName" placeholder="请输入设备名称" disabled />
 					</el-form-item>
 				</el-col>
 
 				<el-col :span="12">
-					<el-form-item label="设备编码" prop="name">
-						<el-input v-model.trim="formData.name" placeholder="请输入场景名称" />
+					<el-form-item label="设备编码" prop="deviceNumber">
+						<el-input v-model.trim="formData.deviceNumber" placeholder="请输入设备编码" />
 					</el-form-item>
 				</el-col>
 			</el-row>
@@ -58,108 +58,35 @@
 
 				<el-col :span="12">
 					<el-form-item label="安装时间">
-						<el-date-picker v-model="formData.date" type="date" placeholder="请选择时间" class="w100" clearable />
+						<el-date-picker v-model="formData.installTime" type="date" value-format="YYYY-MM-DD"
+ placeholder="请选择时间" class="w100" clearable />
 					</el-form-item>
 				</el-col>
 			</el-row>
 
 
+	<el-row>
+				<el-col :span="12">
+					<el-form-item label="所属部门" prop="deptId">
+          <el-cascader :options="deptData" :props="{ checkStrictly: true, emitPath: false, value: 'deptId', label: 'deptName' }" placeholder="请选择所属部门" clearable class="w100" v-model="formData.deptId">
+            <template #default="{ node, data }">
+              <span>{{ data.deptName }}</span>
+              <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
+            </template>
+          </el-cascader>
+        </el-form-item>
+				</el-col>
 
+				<el-col :span="12">
+					<el-form-item label="设备类型">
+						<el-input v-model.trim="formData.deviceCategory" placeholder="请输入设备类型"  />
+					</el-form-item>
+				</el-col>
+			</el-row>
 
+    <el-divider content-position="left">自定义属性</el-divider>
 
-
-
-			<el-form-item label="详细地址">
-				<el-input v-model.trim="formData.name" placeholder="请输入详细地址" />
-			</el-form-item>
-
-
-			<el-form-item label="地图坐标">
-				<el-row>
-					<el-col :span="7" class="mr10">
-						<el-select v-model="formData.name" placeholder="请选择坐标系" class="w100 " clearable>
-							<el-option label="Zone one" value="shanghai" />
-							<el-option label="Zone two" value="beijing" />
-						</el-select>
-					</el-col>
-
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="经度" class="w100" />
-
-					</el-col>
-					<el-col :span="8">
-						<el-input v-model.trim="formData.name" placeholder="纬度" class="w100" />
-
-					</el-col>
-				</el-row>
-			</el-form-item>
-
-			<el-form-item label="建设单位">
-				<el-row>
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="单位名称" class="w100" />
-
-					</el-col>
-
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="单位联系人" class="w100" />
-
-					</el-col>
-					<el-col :span="8">
-						<el-input v-model.trim="formData.name" placeholder="联系电话" class="w100" />
-
-					</el-col>
-				</el-row>
-			</el-form-item>
-
-			<el-form-item label="管理单位">
-				<el-row>
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="单位名称" class="w100" />
-
-					</el-col>
-
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="单位联系人" class="w100" />
-
-					</el-col>
-					<el-col :span="8">
-						<el-input v-model.trim="formData.name" placeholder="联系电话" class="w100" />
-
-					</el-col>
-				</el-row>
-			</el-form-item>
-
-			<el-form-item label="维护单位">
-				<el-row>
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="单位名称" class="w100" />
-
-					</el-col>
-
-					<el-col :span="7" class="mr10">
-						<el-input v-model.trim="formData.name" placeholder="单位联系人" class="w100" />
-
-					</el-col>
-					<el-col :span="8">
-						<el-input v-model.trim="formData.name" placeholder="联系电话" class="w100" />
-
-					</el-col>
-				</el-row>
-			</el-form-item>
-
-			<el-form-item label="设备类型">
-				<el-select v-model="formData.name" placeholder="请选择设备类型" class="w100 " clearable>
-							<el-option label="Zone one" value="shanghai" />
-							<el-option label="Zone two" value="beijing" />
-						</el-select>
-				</el-form-item>
-
-			
-			<el-form-item label="备注">
-				<el-input v-model.trim="formData.name" placeholder="备注" />
-			</el-form-item>
-
+			<FromData :Datalist="Datalist" @SetSaveData="SetSaveData"></FromData>
 
 
 		</el-form>
@@ -180,6 +107,7 @@
 import { ref, reactive, nextTick } from 'vue';
 import api from '/@/api/device'
 import system from '/@/api/system';
+import FromData from './component/from.vue';
 
 import { ruleRequired } from '/@/utils/validator';
 import { ElMessage } from 'element-plus';
@@ -191,22 +119,35 @@ const formRef = ref();
 const orgData = ref();
 const deviceList=ref();
 const productData=ref();
+const deptData=ref();
+const Datalist=ref();
 const baseForm = {
 	id: undefined,
 	productKey: '',
 	deviceKey:'',
 	deviceName:'',
 	area: "",
-	description: '',
+	deviceNumber: '',
+	deviceCategory: '',
+	installTime: '',
+	deptId: '',
+	data:[],
 
 };
 
+
+const SetSaveData = (data:any) => {
+	formData.data=data;
+}
+
 const formData = reactive({
 	...baseForm,
 });
 
 const ruleForm = {
-	name: [ruleRequired('场景名称不能为空')],
+	productKey: [ruleRequired('所属产品不能为空')],
+	deviceName: [ruleRequired('设备名称不能为空')],
+	deviceKey: [ruleRequired('设备不能为空')],
 };
 const handleSelectionChange=(value:any)=> {
       const selectedOption = deviceList.value.find(option => option.key === value);
@@ -251,6 +192,16 @@ const open = async (row: any,productInfo:any) => {
 		api.device.allList({ productId: productInfo.id }).then((res: any) => {
 			deviceList.value = res.device || [];
 		});
+		//获取部门
+		api.dept.getList({ status: -1 }).then((res: any) => {
+        deptData.value = res || [];
+      });
+
+			api.dev_asset_metadata.getList({ productKey: productInfo.key,pageSize:50,pageNum:1,status:-1,total:0 }).then((res: any) => {
+        Datalist.value = res.Data || [];
+      });
+
+			//获取档案属性
 		formData.productKey=productInfo.key
 	});
 };

+ 81 - 95
src/views/iot/property/dossier/index.vue

@@ -22,71 +22,61 @@
 						新增档案
 					</el-button>
 
-					<el-button type="primary" @click="addOrEdit()" v-if="productIno">
+					<!-- <el-button type="primary" @click="addOrEdit()" v-if="productIno">
 						<el-icon>
 							<ele-FolderAdd />
 						</el-icon>
 						批量添加
-					</el-button>
+					</el-button> -->
 
-					<el-button type="danger" @click="addOrEdit()">
+					<!-- <el-button type="danger" @click="addOrEdit()">
 						<el-icon>
 							<ele-FolderAdd />
 						</el-icon>
 						批量删除
-					</el-button>
+					</el-button> -->
 				</el-form-item>
 			</el-form>
 		</div>
 		<el-row>
 			<el-col :span="6">
-				<el-tree :data="mergedData" :props="defaultProps" accordion default-expand-all	 @node-click="handleNodeClick" style="border: 1px solid #eee;padding: 10px;margin-right: 10px;">
+				<el-tree
+					:data="mergedData"
+					:props="defaultProps"
+					accordion
+					default-expand-all
+					@node-click="handleNodeClick"
+					style="border: 1px solid #eee; padding: 10px; margin-right: 10px"
+				>
 					<template #default="{ node, data }">
 						<span :style="data.is_type === '2' ? { color: '#409eff' } : {}">
-							<el-icon  v-if="data.is_type == '2'"><Expand /></el-icon>
-						{{ node.label }}
+							<el-icon v-if="data.is_type == '2'"><Check /></el-icon>
+							{{ node.label }}
 						</span>
 					</template>
-					</el-tree>
+				</el-tree>
 			</el-col>
-			<el-col :span="18"><el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
-					<el-table-column prop="id" label="设备名称" min-width="100" show-overflow-tooltip></el-table-column>
-					<el-table-column prop="name" label="设备ID" show-overflow-tooltip></el-table-column>
-					<el-table-column prop="sceneType" label="设备编码" align="center">
-						<template #default="scope">
-							<el-tag size="small" v-if="scope.row.sceneType == 'device'">设备触发</el-tag>
-							<el-tag size="small" v-if="scope.row.sceneType == 'manual'">手动触发</el-tag>
-							<el-tag size="small" v-if="scope.row.sceneType == 'timer'">定时触发</el-tag>
-						</template>
-					</el-table-column>
+			<el-col :span="18"
+				><el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
+					<el-table-column type="selection" width="55" align="center" />
 
-					<el-table-column prop="name" label="所属区域" show-overflow-tooltip></el-table-column>
-					<el-table-column prop="name" label="管理单位" show-overflow-tooltip></el-table-column>
-					<el-table-column prop="name" label="建设单位" show-overflow-tooltip></el-table-column>
-					<el-table-column prop="name" label="维护单位" show-overflow-tooltip></el-table-column>
-					<el-table-column prop="name" label="设备类型" show-overflow-tooltip></el-table-column>
+					<el-table-column prop="deviceName" label="设备名称" min-width="100" show-overflow-tooltip></el-table-column>
+					<el-table-column prop="deviceKey" label="设备KEY" show-overflow-tooltip></el-table-column>
 
-					<el-table-column prop="status" label="状态" align="center">
-						<template #default="scope">
-							<el-tag size="small" type="success" v-if="scope.row.status == 1">启用</el-tag>
-							<el-tag size="small" type="info" v-if="scope.row.status == 0">禁用</el-tag>
-						</template>
-					</el-table-column>
+					<el-table-column prop="deviceNumber" label="设备编码" show-overflow-tooltip></el-table-column>
+
+					<el-table-column prop="deviceCategory" label="设备类型" show-overflow-tooltip></el-table-column>
 
-					<el-table-column prop="createdAt" label="创建时间" width="160" align="center"></el-table-column>
+					<el-table-column prop="installTime" label="安装时间" width="160" align="center"></el-table-column>
 					<el-table-column label="操作" width="200" align="center">
 						<template #default="scope">
-							<el-button size="small" text type="primary" v-if="!scope.row.folderName"
-								@click="toDetail(scope.row.id)">属性</el-button>
-							<el-button size="small" text type="warning" v-auth="'edit'"
-								@click="addOrEdit(scope.row)">编辑</el-button>
+							<el-button size="small" text type="warning" v-auth="'edit'" @click="addOrEdit(scope.row)">编辑</el-button>
 
 							<el-button size="small" text type="info" v-auth="'del'" @click="del(scope.row)">删除</el-button>
 						</template>
 					</el-table-column>
 				</el-table>
-				<pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum"
-					v-model:limit="params.pageSize" @pagination="getList()" />
+				<pagination v-if="params.total" :total="params.total" v-model:page="params.pageNum" v-model:limit="params.pageSize" @pagination="getList()" />
 			</el-col>
 		</el-row>
 
@@ -97,19 +87,19 @@
 <script lang="ts" setup>
 import device from '/@/api/device'
 import { useSearch } from '/@/hooks/useCommon'
-import {  Expand } from '@element-plus/icons-vue';
+import { Check } from '@element-plus/icons-vue'
 
 import { ElMessageBox, ElMessage } from 'element-plus'
 import EditForm from './edit.vue'
 interface Tree {
-  label: string
-  children?: Tree[]
+	label: string
+	children?: Tree[]
 }
-import { ref,onMounted} from 'vue'
+import { ref, onMounted } from 'vue'
 import { useRouter } from 'vue-router'
 const defaultProps = {
-  children: 'children',
-  label: 'label',
+	children: 'children',
+	label: 'label',
 }
 
 const queryRef = ref()
@@ -118,8 +108,7 @@ const productData = ref([])
 const mergedData = ref()
 const cateData = ref()
 const editFormRef = ref()
-const productIno=ref();
-
+const productIno = ref()
 
 const { params, tableData, getList, loading } = useSearch<any[]>(device.dev_asset.getList, 'Data', { keyWord: '' })
 getList()
@@ -128,76 +117,72 @@ const toDetail = (id: number) => {
 }
 onMounted(() => {
 	getCateList()
-
-});
+})
 const addOrEdit = async (row?: any) => {
 	if (row) {
-		editFormRef.value.open(row,productIno.value)
+		editFormRef.value.open(row, productIno.value)
 		return
 	} else {
-		editFormRef.value.open({},productIno.value)
+		editFormRef.value.open({}, productIno.value)
 	}
 }
 
-
 const getCateList = () => {
 	device.category.getList({}).then((res: any) => {
-		cateData.value = res.category;
+		cateData.value = res.category
 
 		device.product.getLists({}).then((res: any) => {
-			productData.value = res.product;
-			mergedData.value = matchProductsToCategories(productData.value, cateData.value);
+			productData.value = res.product
+			mergedData.value = matchProductsToCategories(productData.value, cateData.value)
 		})
-
 	})
 }
 
 const handleNodeClick = (data: any) => {
-	if(data.is_type==='2'){
-		productIno.value=data;
-	}else{
-		productIno.value='';
-
+	if (data.is_type === '2') {
+		productIno.value = data
+	} else {
+		productIno.value = ''
 	}
 }
 
-const matchProductsToCategories = (productData:any, cateData:any) => {
-  const treeData = []
-  for (let category of cateData) {
-    const treeNode = buildTree(category, productData)
-    treeData.push(treeNode)
-  }
-  return treeData
+const matchProductsToCategories = (productData: any, cateData: any) => {
+	const treeData = []
+	for (let category of cateData) {
+		const treeNode = buildTree(category, productData)
+		treeData.push(treeNode)
+	}
+	return treeData
 }
 
-const buildTree = (category:any, productData:any) => {
-  const treeNode = {
-    id: category.id,
-    label: category.name,
-	key: category.key,
-    is_type: '1', // 1是分类
-    children: [],
-  }
-
-  if (category.children && category.children.length > 0) {
-    for (let child of category.children) {
-      const childNode = buildTree(child, productData)
-      treeNode.children.push(childNode)
-    }
-  } else {
-    const products = productData.filter((product:any) => product.categoryId === category.id)
-    for (let product of products) {
-      const productNode = {
-        id: product.id,
-        label: product.name,
-        key: product.key,
-        is_type: '2', // 2是产品
-      }
-      treeNode.children.push(productNode)
-    }
-  }
-
-  return treeNode
+const buildTree = (category: any, productData: any) => {
+	const treeNode = {
+		id: category.id,
+		label: category.name,
+		key: category.key,
+		is_type: '1', // 1是分类
+		children: [],
+	}
+
+	if (category.children && category.children.length > 0) {
+		for (let child of category.children) {
+			const childNode = buildTree(child, productData)
+			treeNode.children.push(childNode)
+		}
+	} else {
+		const products = productData.filter((product: any) => product.categoryId === category.id)
+		for (let product of products) {
+			const productNode = {
+				id: product.id,
+				label: product.name,
+				key: product.key,
+				is_type: '2', // 2是产品
+			}
+			treeNode.children.push(productNode)
+		}
+	}
+
+	return treeNode
 }
 
 const del = (row: any) => {
@@ -206,11 +191,12 @@ const del = (row: any) => {
 		cancelButtonText: '取消',
 		type: 'warning',
 	}).then(async () => {
-		await device.dev_asset.delete(row.id)
+		await device.dev_asset.delete({ids:row.id})
 		ElMessage.success('删除成功')
 		getList()
 	})
 }
-getCateList()
 
+
+getCateList()
 </script>