Browse Source

1.1 批量升级盒子 增加盒子列表多选

64060764@qq.com 1 year ago
parent
commit
6dd86889c4

+ 1 - 1
src/api/consumble.js

@@ -81,5 +81,5 @@ export async function deleteConsumptionAlgorithmType(data) {
 }
 
 export async function syncRunTime(data) {
-  return post('http://linksee-box-api.linkseeiot.com/api/transport/syncRunTime', data);
+  return post('http://linksee-box-api.linkseeiot.com/api/transport/syncRuntime', data);
 }

+ 2 - 0
src/views/equip-management/box-debug-rebuild/public-method/index.js

@@ -6,6 +6,7 @@ import {
 // JSON转义并请求
 // 控制器命令
 export async function sendCtrlMessage(
+    newtrend_order,
   box_id,
   order = 0,
   ctrl,
@@ -14,6 +15,7 @@ export async function sendCtrlMessage(
   const req = {
     box_id,
     content: JSON.stringify({
+      newtrend_order,
       order,
       ctrl,
       content: body

+ 276 - 2
src/views/equip-management/box-manage/index.vue

@@ -23,15 +23,34 @@
 					</el-form-item>
 					<el-form-item>
 						<el-button type="primary" class="search-btn" @click="filterBoxListFnc()">搜 索</el-button>
+						<el-button
+								class="search-button"
+								type="warning"
+								@click="batchUpdate"
+						>批量升级网关
+						</el-button>
 					</el-form-item>
 				</el-form>
 				<el-button type="primary" circle class="el-icon-refresh-right refresh-button" @click="refreshList()"></el-button>
 
+
 				<el-button type="danger" class="add-new-button" @click="addBoxFnc()" v-if="modeShow === 'all'">新 建</el-button>
+
+<!--				<div class="search-button-container">-->
+
+<!--				</div>-->
 			</div>
 			<!-- 搜索end -->
 			<!-- 列表start -->
-			<el-table :data="boxList" v-loading="boxListLoading" style="width: 100%" border stripe>
+			<el-table :data="boxList" v-loading="boxListLoading" style="width: 100%" border stripe ref="multipleTable" @select="select" @select-all="selectAll"
+					  :key="randomKey"
+					  :row-key="getRowKey">
+				<el-table-column :reserve-selection ="true"
+								 label="选择" type="selection"
+								 width="66"
+								 align="center"
+				>
+				</el-table-column>
 				<el-table-column label="序号" align="center" width="60">
 					<template slot-scope="scope">{{ scope.$index + 1 + (pageIndex - 1) * pageSize }}</template>
 				</el-table-column>
@@ -75,11 +94,135 @@
 					@size-change="sizeChange"></el-pagination>
 			</div>
 		</div>
+		<el-dialog title="批量升级网关" :visible.sync="show" width="800px" append-to-body :close-on-click-modal="false">
+			<div class="operate-container">
+				<div class="operate-form">
+					<div class="form-item">
+						<div class="label">任务名称</div>
+						<div>
+							<el-input
+									v-model="name"
+							>
+							</el-input>
+						</div>
+					</div>
+
+					<div class="form-item">
+						<div class="label">升级时间</div>
+						<div>
+							<el-date-picker
+									value-format=" yyyy-MM-dd HH:mm:ss"
+									v-model="batch_update_time"
+									type="datetime"
+									placeholder="选择日期时间">
+							</el-date-picker>
+						</div>
+					</div>
+					<div class="form-item">
+						<div class="label">版本号</div>
+						<div>
+							<el-input
+									v-model="version"
+							>
+							</el-input>
+						</div>
+					</div>
+					<div class="form-item">
+						<div class="label">上传版本</div>
+						<div class="content">
+							<el-input
+									v-model="download_url"
+									clearable
+									placeholder
+									v-if="download_url"
+							></el-input>
+							<!-- <div class="upload-button" v-else>点击此处上传</div> -->
+							<el-upload
+									name="file"
+									class="upload-button"
+									drag
+									:on-success="handleFileSuccess1"
+									action="http://uploader.linkseeiot.com/upload/file"
+									v-else
+									:data="signData"
+									multiple
+							>点击此处上传</el-upload>
+						</div>
+					</div>
+				</div>
+				<div class="make-sure-container">
+					<el-button
+							class="make-sure-button"
+							type="danger"
+							@click="makeSureAddOperate1('delay')"
+					>定时升级</el-button>
+					<el-button
+							class="make-sure-button"
+							type="success"
+							@click="makeSureAddOperate1('now')"
+					>立即升级</el-button>
+				</div>
+			</div>
+<div>
+	<el-table
+			  :data="this.checkedList"
+			  style="width: 100%"
+			  border
+	>
+
+		<el-table-column
+				label="序号"
+				width="66"
+				:reserve-selection="true"
+				align="center"
+		>
+			<template slot-scope="scope">
+				<div>{{scope.$index + pageSize * (pageIndex -1)+1}}</div>
+			</template>
+		</el-table-column>
+		<el-table-column
+				label="项目名称"
+				prop="project_name"
+				align="left"
+		></el-table-column>
+		<el-table-column
+				label="盒子名称"
+				prop="box_name"
+				align="left"
+		></el-table-column>
+		<el-table-column
+				width="100"
+				label="网关版本"
+				prop="box_sversion"
+				align="center"
+		></el-table-column>
+		<el-table-column
+				label="操作"
+				width="100"
+				align="center"
+		>
+			<template slot-scope="scope">
+
+				<el-button
+						type="text"
+						style="color: #FF4949;"
+						@click="deleteSelected(scope.row)"
+				>删除
+				</el-button>
+
+			</template>
+		</el-table-column>
+	</el-table>
+
+</div>
+
+
+		</el-dialog>
 	</div>
 </template>
 <script>
 import { getBoxList, delBox, syncConf, getBoxDetail, createBox } from "@/api/box";
-import { getProjectList } from "@/api/project";
+import {batchCommitUpdate, getProjectList} from "@/api/project";
 import { currentUserName } from "@/utils/trace";
 import { dateFtt } from "@/utils/format";
 import { operatorList } from "@/api/project";
@@ -110,6 +253,20 @@ export default {
 	},
 	data() {
 		return {
+			gateWayTableData: [],
+			checkedList:[],
+			download_url:'',
+			name:'',
+			version:'',
+			formData:{
+				select_time:'',
+				req:[],
+				name:'',
+				download_url:'',
+				version:'',
+			},
+			batch_update_time: '',
+			randomKey: Math.random(),
 			modeShow: "view",
 			boxList: [],
 			boxListLoading: false,
@@ -120,6 +277,8 @@ export default {
 			searchProject: undefined, //搜索所属项目
 			searchOperate: undefined, //搜索运营商
 			operatorListOption: [],
+			open:false,
+			show:false,
 			pojectListOption: [
 				{
 					label: "全部",
@@ -133,7 +292,122 @@ export default {
 		this.pageIndex = currentPage || 1;
 		await Promise.all([this.operatorListFnc(), this.projectListFunc(), this.getBoxListFnc()]);
 	},
+	computed: {
+		signData() {
+			//   return signVal({ customer_id: currentUserName() });
+			return { customer_id: currentUserName() };
+		},
+		// operateTypeFilter() {
+		//     if (this._props.operateType === "create") {
+		//         return "确认新增"
+		//     } else if (this._props.operateType === "edit") {
+		//         return "确认修改"
+		//     }
+		// }
+	},
 	methods: {
+		deleteSelected(row){
+			console.log('deleteSelected row is:',row)
+		},
+		addRows (rows) {
+			console.log('rows is',rows)
+
+			rows.forEach(row => {
+				if (this.checkedList.find(item => item.box_auto_id == row.box_auto_id)) { return }
+				this.checkedList.push(row)
+			});
+			console.log('add then count is:',this.checkedList.length)
+			console.log('add this.checkedList is',this.checkedList)
+		},
+		//取消选中
+		deleteRows (rows) {
+			//当selectedItems为空数组时,不执行删除
+			if (this.checkedList.length == 0) { return }
+			rows.forEach(row => {
+				this.checkedList = this.checkedList.filter(item => item.box_auto_id != row.box_auto_id)
+			})
+			console.log('delete then count is:',this.checkedList.length)
+			console.log('delete this.checkedList is',this.checkedList)
+		},
+		selectAll (selection) {
+			console.log('///selection is:',selection)
+			console.log('///this.gateWayTableData is:',this.gateWayTableData)
+			//判断是选中还是取消
+			if (selection.length > 0) {
+				this.addRows(this.gateWayTableData)
+			} else {
+				this.deleteRows(this.gateWayTableData)
+			}
+		},
+		select (selection, row) {
+			console.log('///select ...',selection,row)
+			if (selection && selection.find(item => item && (item.box_auto_id == row.box_auto_id))) {
+				this.addRows([row])
+			} else {
+				this.deleteRows([row])
+			}
+		},
+		async makeSureAddOperate1(val) {
+			console.log('downloadurl is:',this.download_url);
+			console.log('signData is:', this.signData);
+			console.log(this.batch_update_time);
+			if (val === 'delay')
+			{this.formData.select_time = this.batch_update_time;}
+			else if (val === 'now'){
+				this.formData.select_time = 'now'
+			}
+			console.log('this.formData.select_time is:',this.formData.select_time )
+			this.formData.name = this.name;
+			this.formData.version = this.version;
+			this.formData.gateway_version = this.download_url;
+			for (var i = 0; i < this.checkedList.length; i++) {
+				let cell = {}
+				cell.project_auto_id = this.checkedList[i].project_auto_id
+				cell.box_auto_id = this.checkedList[i].box_auto_id
+				cell.box_id = this.checkedList[i].box_id
+				this.formData.req.push(cell)
+			}
+			console.log('formData is:', this.formData)
+			const res = await batchCommitUpdate({
+				name: this.formData.name,
+				gateway_version: this.formData.gateway_version,
+				select_time: this.formData.select_time,
+				req: this.formData.req,
+				version: this.formData.version,
+
+			});
+			console.log('res is', res)
+			if (res.code === 200) {
+				console.log('batch success')
+				this.$notify({
+					message: "提交成功",
+					type: "success"
+				});
+				this.show = false;
+			} else {
+				console.log('batch fail')
+
+			}
+		},
+		handleFileSuccess1(res, file) {
+			this.download_url = res.data;
+		},
+		// 批量升级
+		batchUpdate() {
+			console.log('batchUpdate.this.checkedList is: ',this.checkedList)
+			if (this.checkedList.length>0){
+				this.show = true;
+			}else{
+				this.show =false;
+				this.$notify({
+					message: "请至少选择一个盒子进行批量升级",
+					type: "warning"
+				});
+			}
+		},
+		getRowKey(row){
+			return row.box_auto_id;
+		},
 		boxStateFilterColor(state) {
 			switch (state) {
 				case 0:

+ 5 - 0
src/views/inner-management/version-update/index.vue

@@ -196,6 +196,11 @@
                         align="center"
                 ></el-table-column>
                 <el-table-column
+                        label="起始版本"
+                        prop="FromGatewayVersion"
+                        align="center"
+                ></el-table-column>
+                <el-table-column
                         label="目标版本"
                         prop="ToGatewayVersion"
                         align="center"

+ 3 - 1
src/views/oa-management/consumble-watch/index.vue

@@ -571,12 +571,14 @@ export default {
 			}).then(async () => {
 				const r = await syncRunTime({
 					box_id: row.box_id,
+					newtrend_order: row.newtrend_order,
 				});
 				if (r.code === 200) {
 					console.log('////////////r is:',r)
 					const res = await sendCtrlMessage(
-							row.box_id,
 							row.newtrend_order,
+							row.box_id,
+							r.result[0].order,
 							"newtrend",
 							[{ key: 'consumables', value: r.result[0].count }]
 					);

+ 5 - 1
src/views/oa-management/consumble-watch/operate-consumble/index.vue

@@ -21,6 +21,7 @@
         </el-select>
       </el-form-item>
       <el-form-item label="盒子名称">
+        a{{boxOptions}}b
         <el-select v-model="operateConsumbleForm.box_id" placeholder="">
           <el-option
             v-for="(item, index) in boxOptions"
@@ -236,7 +237,7 @@ export default {
         box_auto_id: -1,
         utilization_rate: 0,
         box_id: "",
-        box_auto_id: null
+        //box_auto_id: null
       },
       consumptionAlgorithmOption: [],
       consumptionAlgorithmTypeOption: [],
@@ -362,6 +363,7 @@ export default {
       }
     },
     async projectChange(item) {
+      console.log('/////////*******11***')
       this.operateConsumbleForm.box_id = "";
       this.operateConsumbleForm.box_auto_id = null;
       const res = await projectDetail({
@@ -369,9 +371,11 @@ export default {
       });
       if (res.code === 200) {
         this.boxOptions = res.result.boxes;
+        console.log('/////////**********',this.boxOptions)
       }
     },
     boxChange(item) {
+      console.log('////boxchanged...')
       this.operateConsumbleForm.box_id = item.box_id;
       this.operateConsumbleForm.box_auto_id = item.box_auto_id;
     }