test #47
@@ -34,8 +34,8 @@
 | 
			
		||||
				<div class="table" v-if="mode == 'table'">
 | 
			
		||||
					<base-table
 | 
			
		||||
						:table-props="tableProps"
 | 
			
		||||
						:page="queryParams.pageNo"
 | 
			
		||||
						:limit="queryParams.pageSize"
 | 
			
		||||
						:page="1"
 | 
			
		||||
						:limit="999"
 | 
			
		||||
						:table-data="list"
 | 
			
		||||
						@emitFun="handleEmitFun">
 | 
			
		||||
						<!-- <method-btn
 | 
			
		||||
@@ -63,49 +63,91 @@ export default {
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			sidebarContent: [
 | 
			
		||||
				{
 | 
			
		||||
					id: 'fc1',
 | 
			
		||||
					name: '工厂',
 | 
			
		||||
					lines: [
 | 
			
		||||
						{
 | 
			
		||||
							name: '产线1',
 | 
			
		||||
							id: 'pl1',
 | 
			
		||||
							sections: [
 | 
			
		||||
								{
 | 
			
		||||
									name: '工段1',
 | 
			
		||||
									id: 'pl1ws1',
 | 
			
		||||
								},
 | 
			
		||||
								{
 | 
			
		||||
									name: '工段2',
 | 
			
		||||
									id: 'pl1ws2',
 | 
			
		||||
								},
 | 
			
		||||
								{
 | 
			
		||||
									name: '工段3',
 | 
			
		||||
									id: 'pl1ws3',
 | 
			
		||||
								},
 | 
			
		||||
							],
 | 
			
		||||
						},
 | 
			
		||||
				// {
 | 
			
		||||
				// 	id: 'fc1',
 | 
			
		||||
				// 	name: '工厂',
 | 
			
		||||
				// 	lines: [
 | 
			
		||||
				// 		{
 | 
			
		||||
				// 			name: '产线1',
 | 
			
		||||
				// 			id: 'pl1',
 | 
			
		||||
				// 			sections: [
 | 
			
		||||
				// 				{
 | 
			
		||||
				// 					name: '工段1',
 | 
			
		||||
				// 					id: 'pl1ws1',
 | 
			
		||||
				// 					equipments: [
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备1',
 | 
			
		||||
				// 							id: 'pl1ws1--eq1',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备2',
 | 
			
		||||
				// 							id: 'pl1ws1--eq2',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备3',
 | 
			
		||||
				// 							id: 'pl1ws1--eq3',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 					],
 | 
			
		||||
				// 				},
 | 
			
		||||
				// 				{
 | 
			
		||||
				// 					name: '工段2',
 | 
			
		||||
				// 					id: 'pl1ws2',
 | 
			
		||||
				// 					equipments: [
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备1',
 | 
			
		||||
				// 							id: 'pl2ws1--eq1',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备2',
 | 
			
		||||
				// 							id: 'pl2ws1--eq2',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备3',
 | 
			
		||||
				// 							id: 'pl2ws1--eq3',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 					],
 | 
			
		||||
				// 				},
 | 
			
		||||
				// 				{
 | 
			
		||||
				// 					name: '工段3',
 | 
			
		||||
				// 					id: 'pl1ws3',
 | 
			
		||||
				// 					equipments: [
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备1',
 | 
			
		||||
				// 							id: 'pl3ws1--eq1',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备2',
 | 
			
		||||
				// 							id: 'pl3ws1--eq2',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 						{
 | 
			
		||||
				// 							name: '设备3',
 | 
			
		||||
				// 							id: 'pl3ws1--eq3',
 | 
			
		||||
				// 						},
 | 
			
		||||
				// 					],
 | 
			
		||||
				// 				},
 | 
			
		||||
				// 			],
 | 
			
		||||
				// 		},
 | 
			
		||||
 | 
			
		||||
						{
 | 
			
		||||
							name: '产线2',
 | 
			
		||||
							id: 'pl2',
 | 
			
		||||
							sections: [
 | 
			
		||||
								{
 | 
			
		||||
									name: '工段1',
 | 
			
		||||
									id: 'pl2ws1',
 | 
			
		||||
								},
 | 
			
		||||
								{
 | 
			
		||||
									name: '工段2',
 | 
			
		||||
									id: 'pl2ws2',
 | 
			
		||||
								},
 | 
			
		||||
								{
 | 
			
		||||
									name: '工段3',
 | 
			
		||||
									id: 'pl2ws3',
 | 
			
		||||
								},
 | 
			
		||||
							],
 | 
			
		||||
						},
 | 
			
		||||
					],
 | 
			
		||||
				},
 | 
			
		||||
				// 		{
 | 
			
		||||
				// 			name: '产线2',
 | 
			
		||||
				// 			id: 'pl2',
 | 
			
		||||
				// 			sections: [
 | 
			
		||||
				// 				{
 | 
			
		||||
				// 					name: '工段1',
 | 
			
		||||
				// 					id: 'pl2ws1',
 | 
			
		||||
				// 				},
 | 
			
		||||
				// 				{
 | 
			
		||||
				// 					name: '工段2',
 | 
			
		||||
				// 					id: 'pl2ws2',
 | 
			
		||||
				// 				},
 | 
			
		||||
				// 				{
 | 
			
		||||
				// 					name: '工段3',
 | 
			
		||||
				// 					id: 'pl2ws3',
 | 
			
		||||
				// 				},
 | 
			
		||||
				// 			],
 | 
			
		||||
				// 		},
 | 
			
		||||
				// 	],
 | 
			
		||||
				// },
 | 
			
		||||
			],
 | 
			
		||||
			searchBarFormConfig: [
 | 
			
		||||
				{
 | 
			
		||||
@@ -127,6 +169,29 @@ export default {
 | 
			
		||||
					name: 'search',
 | 
			
		||||
					color: 'primary',
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					type: 'separate',
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					type: 'button',
 | 
			
		||||
					btnName: '表格',
 | 
			
		||||
					name: 'table',
 | 
			
		||||
					plain: true,
 | 
			
		||||
					color: 'success',
 | 
			
		||||
				},
 | 
			
		||||
				{
 | 
			
		||||
					type: 'button',
 | 
			
		||||
					btnName: '图表',
 | 
			
		||||
					name: 'graph',
 | 
			
		||||
					plain: true,
 | 
			
		||||
					color: 'warning',
 | 
			
		||||
				},
 | 
			
		||||
				// {
 | 
			
		||||
				// 	type: this.$auth.hasPermi('base:equipment-group:export') ? 'button' : '',
 | 
			
		||||
				// 	btnName: '导出',
 | 
			
		||||
				// 	name: 'export',
 | 
			
		||||
				// 	color: 'warning',
 | 
			
		||||
				// },
 | 
			
		||||
			],
 | 
			
		||||
			tableProps: [
 | 
			
		||||
				{ prop: 'lineName', label: '产线', align: 'center' },
 | 
			
		||||
@@ -137,8 +202,8 @@ export default {
 | 
			
		||||
			],
 | 
			
		||||
			mode: 'table', // table | graph
 | 
			
		||||
			queryParams: {
 | 
			
		||||
				pageNo: 1,
 | 
			
		||||
				pageSize: 999,
 | 
			
		||||
				// pageNo: 1,
 | 
			
		||||
				// pageSize: 999,
 | 
			
		||||
				recordTime: [],
 | 
			
		||||
				equipmentId: null,
 | 
			
		||||
				lineId: null,
 | 
			
		||||
@@ -153,53 +218,103 @@ export default {
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	mounted() {
 | 
			
		||||
		this.getList();
 | 
			
		||||
		this.getTree();
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		/** build side bar tree */
 | 
			
		||||
		buildTree(data) {
 | 
			
		||||
			data.forEach((factory) => {
 | 
			
		||||
				this.$set(factory, 'label', factory.name);
 | 
			
		||||
				this.$set(factory, 'type', '工厂');
 | 
			
		||||
				delete factory.name;
 | 
			
		||||
				factory.children = factory.lines;
 | 
			
		||||
				delete factory.lines;
 | 
			
		||||
				factory.children.forEach((line) => {
 | 
			
		||||
				factory.children?.forEach((line) => {
 | 
			
		||||
					this.$set(line, 'label', line.name);
 | 
			
		||||
					this.$set(line, 'type', '产线');
 | 
			
		||||
					delete line.name;
 | 
			
		||||
					line.children = line.sections;
 | 
			
		||||
					delete line.sections;
 | 
			
		||||
					line.children.forEach((ws) => {
 | 
			
		||||
					line.children?.forEach((ws) => {
 | 
			
		||||
						this.$set(ws, 'label', ws.name);
 | 
			
		||||
						this.$set(ws, 'type', '工段');
 | 
			
		||||
						delete ws.name;
 | 
			
		||||
						ws.children = ws.equipments;
 | 
			
		||||
						delete ws.equipments;
 | 
			
		||||
						ws.children?.forEach((eq) => {
 | 
			
		||||
							this.$set(eq, 'label', eq.name);
 | 
			
		||||
							this.$set(eq, 'type', '设备');
 | 
			
		||||
							delete eq.name;
 | 
			
		||||
						});
 | 
			
		||||
					});
 | 
			
		||||
				});
 | 
			
		||||
			});
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		async getList() {
 | 
			
		||||
			this.buildTree(this.sidebarContent);
 | 
			
		||||
			console.log('sidebar final', this.sidebarContent);
 | 
			
		||||
		async getTree() {
 | 
			
		||||
			const { data } = await this.$axios('/base/factory/getTree');
 | 
			
		||||
			this.sidebarContent = data;
 | 
			
		||||
			this.buildTree(data);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
		handleSidebarItemClick({ label, id }) {
 | 
			
		||||
			console.log('lable clicked!', label, id);
 | 
			
		||||
		handleSidebarItemClick({ label, id, type }) {
 | 
			
		||||
			console.log('lable clicked!', label, id, type);
 | 
			
		||||
			switch (type) {
 | 
			
		||||
				case '设备':
 | 
			
		||||
					this.queryParams.equipmentId = id;
 | 
			
		||||
					break;
 | 
			
		||||
				case '工段':
 | 
			
		||||
					this.queryParams.equipmentId = null;
 | 
			
		||||
					this.queryParams.sectionId = id;
 | 
			
		||||
					break;
 | 
			
		||||
				case '产线':
 | 
			
		||||
					this.queryParams.equipmentId = null;
 | 
			
		||||
					this.queryParams.sectionId = null;
 | 
			
		||||
					this.queryParams.lineId = id;
 | 
			
		||||
					break;
 | 
			
		||||
				case '工厂':
 | 
			
		||||
					this.queryParams.equipmentId = null;
 | 
			
		||||
					this.queryParams.sectionId = null;
 | 
			
		||||
					this.queryParams.lineId = null;
 | 
			
		||||
					break;
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		handleEmitFun() {},
 | 
			
		||||
 | 
			
		||||
		handleSearchBarBtnClick(btn) {
 | 
			
		||||
			console.log('btn', btn);
 | 
			
		||||
			this.queryParams.recordTime = btn.timeVal;
 | 
			
		||||
			this.handleQuery();
 | 
			
		||||
			switch (btn.btnName) {
 | 
			
		||||
				case 'table':
 | 
			
		||||
					this.mode = 'table';
 | 
			
		||||
					break;
 | 
			
		||||
				case 'graph':
 | 
			
		||||
					this.mode = 'graph';
 | 
			
		||||
					break;
 | 
			
		||||
				case 'search':
 | 
			
		||||
					if (btn.timeVal != null && btn.timeVal.length > 0)
 | 
			
		||||
						this.queryParams.recordTime = btn.timeVal;
 | 
			
		||||
					else this.queryParams.recordTime = null;
 | 
			
		||||
					this.handleQuery();
 | 
			
		||||
					break;
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		handleQuery() {
 | 
			
		||||
			console.log(this.queryParams)
 | 
			
		||||
		}
 | 
			
		||||
		async handleQuery() {
 | 
			
		||||
			console.log('queryParams', this.queryParams);
 | 
			
		||||
			const { data } = await this.$axios({
 | 
			
		||||
				url: '/monitoring/equipment-monitor/quantity-det-list',
 | 
			
		||||
				method: 'get',
 | 
			
		||||
				params: this.queryParams,
 | 
			
		||||
			});
 | 
			
		||||
			this.list = data;
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped lang="scss"></style>
 | 
			
		||||
<style scoped>
 | 
			
		||||
.side-bar__left >>> .is-current {
 | 
			
		||||
	color: #111;
 | 
			
		||||
	background: #f2f4f7;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user