Przeglądaj źródła

修复接口传参

yanglzh 11 miesięcy temu
rodzic
commit
e042dcb439

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

@@ -123,7 +123,7 @@ export default {
   assetRelationship: {
     getList: (params: object) => get('/asset/assetRelationship/list', params),
     bind: (params: object) => post('/asset/assetRelationship/bind', params),
-    unBind: (id: number) => post('/asset/assetRelationship/unBind', { id }),
+    unBind: (ids: number[]) => post('/asset/assetRelationship/unBind', { ids }),
     editRuleInfo: (params: object) => put('/asset/assetRelationship/editRuleInfo', params),
     editStatus: (id: number, status: number) => put('/asset/assetRelationship/editStatus', { id, status }),
     detail: (id: number) => get('/asset/assetRelationship/getById', { id }),

+ 4 - 4
src/views/iot/property/relationship/edit.vue

@@ -12,7 +12,7 @@
             </template>
           </el-cascader>
         </el-form-item>
-        <el-form-item label="已选档案" prop="assetId">
+        <el-form-item label="已选档案" prop="assetIds">
           <el-tag v-for="name in assetName" class="mr-2">{{ name }} </el-tag>
         </el-form-item>
       </el-form>
@@ -53,21 +53,21 @@ const assetName = ref<string[]>([]);
 const baseForm = {
   id: undefined,
   roleId: '',
-  assetId: [],
+  assetIds: [],
 };
 
 const formData = reactive<any>(deepClone(baseForm));
 
 const ruleForm = {
   roleId: [ruleRequired('角色不能为空')],
-  assetId: [ruleRequired('档案不能为空')],
+  assetIds: [ruleRequired('档案不能为空')],
 };
 
 const { params, tableData, getList, loading } = useSearch<any[]>(api.dev_asset.getList, 'Data', { pageSize: 10 })
 getList()
 
 const handleSelectionChange = (selection: any[]) => {
-  formData.assetId = selection.map((item) => item.id);
+  formData.assetIds = selection.map((item) => item.id);
   assetName.value = selection.map((item) => item.deviceName);
 };
 

+ 37 - 27
src/views/iot/property/relationship/index.vue

@@ -19,11 +19,11 @@
 					</el-icon>
 					新增资产关系
 				</el-button>
-				<el-button type="info" @click="batchdel()" v-auth="'batchdel'">
+				<el-button type="info" @click="batchUnbind()" v-auth="'batchUnbind'" :disabled="!ids.length">
 					<el-icon>
 						<ele-FolderAdd />
 					</el-icon>
-					删除
+					解绑
 				</el-button>
 			</el-form-item>
 		</el-form>
@@ -55,7 +55,6 @@
 						<el-table-column label="操作" width="170" v-col="'handle'" align="center">
 							<template #default="scope">
 								<el-button size="small" text type="warning" v-auth="'unbind'" @click="unbind(scope.row)">解绑</el-button>
-								<el-button size="small" text type="info" v-auth="'del'" @click="del(scope.row)">删除</el-button>
 								<el-button size="small" text type="primary" v-auth="'set'" @click="set(scope.row)">设置筛选条件</el-button>
 							</template>
 						</el-table-column>
@@ -113,29 +112,29 @@ const handleNodeClick = (data: any) => {
 	getList()
 }
 
-const batchdel = () => {
-	ElMessageBox.confirm('是否确认要批量删除这些数据吗?', '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-	}).then(async () => {
-		await device.assetRelationship.delete(ids.value)
-		ElMessage.success('删除成功')
-		getList()
-	})
-}
-
-const del = (row: any) => {
-	ElMessageBox.confirm('是否确认删除该设备档案', '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-	}).then(async () => {
-		await device.assetRelationship.delete([row.id])
-		ElMessage.success('删除成功')
-		getList()
-	})
-}
+// const batchdel = () => {
+// 	ElMessageBox.confirm('是否确认要批量删除这些数据吗?', '提示', {
+// 		confirmButtonText: '确认',
+// 		cancelButtonText: '取消',
+// 		type: 'warning',
+// 	}).then(async () => {
+// 		await device.assetRelationship.delete(ids.value)
+// 		ElMessage.success('删除成功')
+// 		getList()
+// 	})
+// }
+
+// const del = (row: any) => {
+// 	ElMessageBox.confirm('是否确认删除该设备档案', '提示', {
+// 		confirmButtonText: '确认',
+// 		cancelButtonText: '取消',
+// 		type: 'warning',
+// 	}).then(async () => {
+// 		await device.assetRelationship.delete([row.id])
+// 		ElMessage.success('删除成功')
+// 		getList()
+// 	})
+// }
 
 // 状态修改
 const handleStatusChange = (row: any) => {
@@ -162,12 +161,23 @@ const unbind = (row: any) => {
 		cancelButtonText: '取消',
 		type: 'warning',
 	}).then(async () => {
-		await device.assetRelationship.unBind(row.id)
+		await device.assetRelationship.unBind([row.id])
 		ElMessage.success('解绑成功')
 		getList()
 	})
 }
 
+const batchUnbind = () => {
+	ElMessageBox.confirm('是否确认要批量解绑这些数据吗?', '提示', {
+		confirmButtonText: '确认',
+		cancelButtonText: '取消',
+		type: 'warning',
+	}).then(async () => {
+		await device.assetRelationship.unBind(ids.value)
+		ElMessage.success('解绑成功')
+		getList()
+	})
+}
 
 // getCateList()
 </script>