Browse Source

完成档案,待联调bug

yukai 1 year ago
parent
commit
135edffdc7

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

@@ -133,7 +133,10 @@ const getCateList = () => {
 
 
 const handleNodeClick = (data: any) => {
 const handleNodeClick = (data: any) => {
 	if(data.is_type==='2'){
 	if(data.is_type==='2'){
-		productIno.value=data;
+		productIno.value = data;
+		params.productKey = data.key
+		getList()
+
 	}else{
 	}else{
 		productIno.value='';
 		productIno.value='';
 
 

+ 57 - 29
src/views/iot/property/dossier/component/from.vue

@@ -1,50 +1,78 @@
 <template>
 <template>
   <div>
   <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 :label="info.title + ':'" :prop="info.name" class="form-item" v-if="info.types === 'input'">
+        <el-input v-model="formData[info.name]" :placeholder="'请输入' + info.title" @input="saveData()" />
       </el-form-item>
       </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 :label="info.title + ':'" :prop="info.name" class="form-item" v-if="info.types === 'textarea'">
+        <el-input v-model="formData[info.name]" type="textarea" @input="saveData()" />
       </el-form-item>
       </el-form-item>
-    </div>
+
+      <el-form-item v-if="info.types === 'date'" :label="info.title + ':'">
+        <el-date-picker v-model="formData[info.name]" type="date" value-format="YYYY-MM-DD" placeholder="请选择时间" class="w100" clearable   @change="saveData()"/>
+      </el-form-item>
+
+       <el-form-item :label="info.title + ':'" prop="path" v-if="info.types === 'file'">
+            <el-upload accept="*" :show-file-list="true"   :limit="1" :headers="headers" :action="uploadUrl"
+              :on-success="updateImg">
+              <el-button>
+                <el-icon> <ele-Upload /> </el-icon>
+                上传文件
+              </el-button>
+            </el-upload>
+            <div>{{ url }}</div>
+          </el-form-item>
+
+ 
+
   </div>
   </div>
 </template>
 </template>
 
 
 <script lang="ts" setup>
 <script lang="ts" setup>
 import { defineProps, ref, defineEmits } from 'vue';
 import { defineProps, ref, defineEmits } from 'vue';
+import getOrigin from '/@/utils/origin';
+import { ElMessage } from 'element-plus';
 
 
+const url = ref();
+const uploadUrl = getOrigin(import.meta.env.VITE_API_URL + '/common/singleFile');
+const headers = {
+  Authorization: 'Bearer ' + localStorage.token,
+};
 const emit = defineEmits(['SetSaveData']);
 const emit = defineEmits(['SetSaveData']);
 
 
 const props = defineProps({
 const props = defineProps({
-  Datalist: {
-    type: Array,
-    default: () => []
+  info: {
+    type: Object,
+    default: () => {}
   },
   },
+  index: {
+    type: Number,
+    default: () => 0
+  }
 });
 });
 
 
-const formData = ref({});
+const updateImg = (res: any) => {
+  if (res.code === 0) {
+    url.value= res.data.full_path
+    ElMessage.success('上传成功');
+  } else {
+    ElMessage.error(res.message);
+  }
+};
+const formData = ref({
+  productKey: props.info.productKey,
+  fieldName: props.info.fieldName,
+  name: props.info.name,
+  value: '',
+});
 
 
 const saveData = () => {
 const saveData = () => {
-  emit('SetSaveData', formData.value);
+    formData.value.value = formData.value[props.info.name];
+    
+    let newdata = {
+      index: props.index,
+      data: formData.value,
+    }
+  emit('SetSaveData', newdata);
 };
 };
 </script>
 </script>
 
 

+ 21 - 14
src/views/iot/property/dossier/edit.vue

@@ -85,7 +85,10 @@
 			</el-row>
 			</el-row>
 
 
     <el-divider content-position="left">自定义属性</el-divider>
     <el-divider content-position="left">自定义属性</el-divider>
-			<FromData :Datalist="Datalist" @SetSaveData="SetSaveData"></FromData>
+		    <div v-for="(item, index) in Datalist" :key="index">
+						<FromData :info="item" :index="index" @SetSaveData="SetSaveData"></FromData>
+			  </div>
+
 		</el-form>
 		</el-form>
 
 
 
 
@@ -118,6 +121,7 @@ const deviceList=ref();
 const productData=ref();
 const productData=ref();
 const deptData=ref();
 const deptData=ref();
 const Datalist=ref();
 const Datalist=ref();
+const newData = ref([]); 
 const baseForm = {
 const baseForm = {
 	id: undefined,
 	id: undefined,
 	productKey: '',
 	productKey: '',
@@ -133,10 +137,9 @@ const baseForm = {
 };
 };
 
 
 
 
-const SetSaveData = (data:any) => {
-	const jsonArray = [data];
-	const jsonString = JSON.stringify(jsonArray);
-	formData.data=jsonString;
+const SetSaveData = (data: any) => {
+		newData.value[data.index] = data.data;
+		formData.data= newData;
 }
 }
 
 
 const formData = reactive({
 const formData = reactive({
@@ -188,13 +191,17 @@ const open = async (row: any,productInfo:any) => {
 	resetForm();
 	resetForm();
 	showDialog.value = true;		
 	showDialog.value = true;		
 	nextTick(() => {
 	nextTick(() => {
-
+		//获取区域
 		system.org.getList({ status: 1 }).then((res: any) => {
 		system.org.getList({ status: 1 }).then((res: any) => {
+			res.forEach((item) => {
+				item.id = item.id.toString();
+			});
 			orgData.value = res || [];
 			orgData.value = res || [];
 		});
 		});
+		
 		//获取 所有的产品
 		//获取 所有的产品
-		api.product.getLists({}).then((res: any) => {
-			productData.value = res.product;
+		api.product.getLists({}).then((resp: any) => {
+			productData.value = resp.product;
 			if(row.id){
 			if(row.id){
 				productInfo={
 				productInfo={
 					id:getIdByKey(row.productKey),
 					id:getIdByKey(row.productKey),
@@ -202,17 +209,18 @@ const open = async (row: any,productInfo:any) => {
 				}
 				}
 			}
 			}
 			//根据产品ID获取设备列表
 			//根据产品ID获取设备列表
-			api.device.allList({ productId: productInfo.id }).then((res: any) => {
-				deviceList.value = res.device || [];
+			api.device.allList({ productId: productInfo.id }).then((resd: any) => {
+				deviceList.value = resd.device || [];
 			});
 			});
 				api.dev_asset_metadata.getList({ productKey: productInfo.key,pageSize:50,pageNum:1,status:-1,total:0 }).then((res: any) => {
 				api.dev_asset_metadata.getList({ productKey: productInfo.key,pageSize:50,pageNum:1,status:-1,total:0 }).then((res: any) => {
-        Datalist.value = res.Data || [];
-      });
+					Datalist.value = res.Data || [];
+				});
 
 
 			//获取档案属性
 			//获取档案属性
 		})
 		})
 
 
-		
+
+
 		//获取部门
 		//获取部门
 		api.dept.getList({ status: -1 }).then((res: any) => {
 		api.dept.getList({ status: -1 }).then((res: any) => {
 				res.forEach((item) => {
 				res.forEach((item) => {
@@ -221,7 +229,6 @@ const open = async (row: any,productInfo:any) => {
         deptData.value = res || [];
         deptData.value = res || [];
     });
     });
 
 
-		console.log(row);
 		Object.assign(formData, { ...row });
 		Object.assign(formData, { ...row });
 		formData.productKey=productInfo.key
 		formData.productKey=productInfo.key
 
 

+ 2 - 0
src/views/iot/property/dossier/index.vue

@@ -137,6 +137,8 @@ const getCateList = () => {
 const handleNodeClick = (data: any) => {
 const handleNodeClick = (data: any) => {
 	if (data.is_type === '2') {
 	if (data.is_type === '2') {
 		productIno.value = data
 		productIno.value = data
+		params.productKey = data.key
+		getList()
 	} else {
 	} else {
 		productIno.value = ''
 		productIno.value = ''
 	}
 	}