Merge branch 'test' into zhp
This commit is contained in:
		@@ -247,7 +247,7 @@ Router.prototype.push = function push(location) {
 | 
			
		||||
 | 
			
		||||
export default new Router({
 | 
			
		||||
  base: process.env.VUE_APP_APP_NAME ? process.env.VUE_APP_APP_NAME : "/",
 | 
			
		||||
  mode: 'history', // 去掉url中的#
 | 
			
		||||
  mode: 'hash', // 去掉url中的#
 | 
			
		||||
  scrollBehavior: () => ({y: 0}),
 | 
			
		||||
  routes: constantRoutes
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										219
									
								
								src/views/base/equipmentBindSection/dialogForm.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										219
									
								
								src/views/base/equipmentBindSection/dialogForm.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,219 @@
 | 
			
		||||
<!-- 
 | 
			
		||||
    filename: dialogForm.vue
 | 
			
		||||
    author: liubin
 | 
			
		||||
    date: 2023-09-11 15:55:13
 | 
			
		||||
    description: DialogForm for equipmentBindSection only
 | 
			
		||||
-->
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
	<el-form
 | 
			
		||||
		ref="form"
 | 
			
		||||
		:model="dataForm"
 | 
			
		||||
		label-width="100px"
 | 
			
		||||
		v-loading="formLoading">
 | 
			
		||||
		<el-row :gutter="20">
 | 
			
		||||
			<el-col :span="12">
 | 
			
		||||
				<el-form-item
 | 
			
		||||
					label="产线"
 | 
			
		||||
					prop="productionLineId"
 | 
			
		||||
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
 | 
			
		||||
					<el-select
 | 
			
		||||
						v-model="dataForm.productionLineId"
 | 
			
		||||
						placeholder="请选择产线"
 | 
			
		||||
						@change="handleProductlineChange">
 | 
			
		||||
						<el-option
 | 
			
		||||
							v-for="opt in productionLineList"
 | 
			
		||||
							:key="opt.value"
 | 
			
		||||
							:label="opt.label"
 | 
			
		||||
							:value="opt.value" />
 | 
			
		||||
					</el-select>
 | 
			
		||||
				</el-form-item>
 | 
			
		||||
			</el-col>
 | 
			
		||||
 | 
			
		||||
			<el-col :span="12">
 | 
			
		||||
				<el-form-item
 | 
			
		||||
					label="工段"
 | 
			
		||||
					prop="workshopSectionId"
 | 
			
		||||
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
 | 
			
		||||
					<el-select
 | 
			
		||||
						v-model="dataForm.workshopSectionId"
 | 
			
		||||
						placeholder="请选择工段"
 | 
			
		||||
						@change="$emit('update', dataForm)">
 | 
			
		||||
						<el-option
 | 
			
		||||
							v-for="opt in worksectionList"
 | 
			
		||||
							:key="opt.value"
 | 
			
		||||
							:label="opt.label"
 | 
			
		||||
							:value="opt.value" />
 | 
			
		||||
					</el-select>
 | 
			
		||||
				</el-form-item>
 | 
			
		||||
			</el-col>
 | 
			
		||||
		</el-row>
 | 
			
		||||
		<el-row :gutter="20">
 | 
			
		||||
			<el-col :span="12">
 | 
			
		||||
				<el-form-item
 | 
			
		||||
					label="设备"
 | 
			
		||||
					prop="equipmentId"
 | 
			
		||||
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
 | 
			
		||||
					<el-select
 | 
			
		||||
						v-model="dataForm.equipmentId"
 | 
			
		||||
						placeholder="请选择设备"
 | 
			
		||||
						@change="$emit('update', dataForm)">
 | 
			
		||||
						<el-option
 | 
			
		||||
							v-for="opt in equipmentList"
 | 
			
		||||
							:key="opt.value"
 | 
			
		||||
							:label="opt.label"
 | 
			
		||||
							:value="opt.value" />
 | 
			
		||||
					</el-select>
 | 
			
		||||
				</el-form-item>
 | 
			
		||||
			</el-col>
 | 
			
		||||
 | 
			
		||||
			<el-col :span="12">
 | 
			
		||||
				<el-form-item label="工段排序" prop="sort">
 | 
			
		||||
					<el-input
 | 
			
		||||
						v-model="dataForm.sort"
 | 
			
		||||
						@change="$emit('update', dataForm)"
 | 
			
		||||
						placeholder="请输入工段排序" />
 | 
			
		||||
				</el-form-item>
 | 
			
		||||
			</el-col>
 | 
			
		||||
		</el-row>
 | 
			
		||||
		<el-row :gutter="20">
 | 
			
		||||
			<el-col :span="12">
 | 
			
		||||
				<el-form-item label="产线数据类型" prop="lineDataType">
 | 
			
		||||
					<el-select
 | 
			
		||||
						v-model="dataForm.lineDataType"
 | 
			
		||||
						placeholder="请选择产线数据类型"
 | 
			
		||||
						@change="$emit('update', dataForm)">
 | 
			
		||||
						<el-option
 | 
			
		||||
							v-for="opt in [
 | 
			
		||||
								{ label: '无类型', value: 0 },
 | 
			
		||||
								{ label: '进口统计', value: 1 },
 | 
			
		||||
								{ label: '出口统计', value: 2 },
 | 
			
		||||
							]"
 | 
			
		||||
							:key="opt.value"
 | 
			
		||||
							:label="opt.label"
 | 
			
		||||
							:value="opt.value" />
 | 
			
		||||
					</el-select>
 | 
			
		||||
				</el-form-item>
 | 
			
		||||
			</el-col>
 | 
			
		||||
			<el-col :span="12">
 | 
			
		||||
				<el-form-item label="工段数据类型" prop="sectionDataType">
 | 
			
		||||
					<el-select
 | 
			
		||||
						v-model="dataForm.sectionDataType"
 | 
			
		||||
						placeholder="请选择工段数据类型"
 | 
			
		||||
						@change="$emit('update', dataForm)">
 | 
			
		||||
						<el-option
 | 
			
		||||
							v-for="opt in [
 | 
			
		||||
								{ label: '无类型', value: 0 },
 | 
			
		||||
								{ label: '进口统计', value: 1 },
 | 
			
		||||
								{ label: '出口统计', value: 2 },
 | 
			
		||||
							]"
 | 
			
		||||
							:key="opt.value"
 | 
			
		||||
							:label="opt.label"
 | 
			
		||||
							:value="opt.value" />
 | 
			
		||||
					</el-select>
 | 
			
		||||
				</el-form-item>
 | 
			
		||||
			</el-col>
 | 
			
		||||
		</el-row>
 | 
			
		||||
	</el-form>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
	name: 'DialogForm',
 | 
			
		||||
	model: {
 | 
			
		||||
		prop: 'dataForm',
 | 
			
		||||
		event: 'update',
 | 
			
		||||
	},
 | 
			
		||||
	emits: ['update'],
 | 
			
		||||
	components: {},
 | 
			
		||||
	props: {
 | 
			
		||||
		dataForm: {
 | 
			
		||||
			type: Object,
 | 
			
		||||
			default: () => ({}),
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			formLoading: true,
 | 
			
		||||
			productionLineList: [],
 | 
			
		||||
			equipmentList: [],
 | 
			
		||||
			worksectionList: [],
 | 
			
		||||
			dataFormCache: null,
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	mounted() {
 | 
			
		||||
		Promise.all([this.getProductLineList(), this.getEquipmentList()]).then(
 | 
			
		||||
			() => {
 | 
			
		||||
				this.formLoading = false;
 | 
			
		||||
			}
 | 
			
		||||
		);
 | 
			
		||||
	},
 | 
			
		||||
	watch: {
 | 
			
		||||
		'dataForm.productionLineId': {
 | 
			
		||||
			handler: async function (plId) {
 | 
			
		||||
				if (plId) await this.getWorksectionList(plId);
 | 
			
		||||
			},
 | 
			
		||||
			immediate: true,
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		/** 模拟透传 ref  */
 | 
			
		||||
		validate(cb) {
 | 
			
		||||
			return this.$refs.form.validate(cb);
 | 
			
		||||
		},
 | 
			
		||||
		resetFields(args) {
 | 
			
		||||
			return this.$refs.form.resetFields(args);
 | 
			
		||||
		},
 | 
			
		||||
		async handleProductlineChange(id) {
 | 
			
		||||
			await this.getWorksectionList(id);
 | 
			
		||||
			this.dataForm.workshopSectionId = null;
 | 
			
		||||
			this.$emit('update', this.dataForm);
 | 
			
		||||
		},
 | 
			
		||||
		// getCode
 | 
			
		||||
		async getCode(url) {
 | 
			
		||||
			const response = await this.$axios(url);
 | 
			
		||||
			return response.data;
 | 
			
		||||
		},
 | 
			
		||||
		// 获取产线列表
 | 
			
		||||
		async getProductLineList() {
 | 
			
		||||
			const response = await this.$axios('/base/production-line/listAll');
 | 
			
		||||
			this.productionLineList = response.data.map((item) => ({
 | 
			
		||||
				label: item.name,
 | 
			
		||||
				value: item.id,
 | 
			
		||||
			}));
 | 
			
		||||
		},
 | 
			
		||||
		// 获取设备列表
 | 
			
		||||
		async getEquipmentList() {
 | 
			
		||||
			const response = await this.$axios(
 | 
			
		||||
				'/base/equipment/page?pageNo=1&pageSize=100'
 | 
			
		||||
			);
 | 
			
		||||
			this.equipmentList = response.data.list.map((item) => ({
 | 
			
		||||
				label: item.name,
 | 
			
		||||
				value: item.id,
 | 
			
		||||
			}));
 | 
			
		||||
		},
 | 
			
		||||
		// 获取工段列表
 | 
			
		||||
		async getWorksectionList(plId) {
 | 
			
		||||
			const response = await this.$axios(
 | 
			
		||||
				'/base/workshop-section/listByParentId',
 | 
			
		||||
				{
 | 
			
		||||
					params: {
 | 
			
		||||
						id: plId,
 | 
			
		||||
					},
 | 
			
		||||
				}
 | 
			
		||||
			);
 | 
			
		||||
			this.worksectionList = response.data.map((item) => ({
 | 
			
		||||
				label: item.name,
 | 
			
		||||
				value: item.id,
 | 
			
		||||
			}));
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped lang="scss">
 | 
			
		||||
.el-date-editor,
 | 
			
		||||
.el-select {
 | 
			
		||||
	width: 100%;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -37,7 +37,7 @@
 | 
			
		||||
			@close="cancel"
 | 
			
		||||
			@cancel="cancel"
 | 
			
		||||
			@confirm="submitForm">
 | 
			
		||||
			<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
 | 
			
		||||
			<DialogForm v-if="open" ref="form" v-model="form" :rows="rows" />
 | 
			
		||||
		</base-dialog>
 | 
			
		||||
	</div>
 | 
			
		||||
</template>
 | 
			
		||||
@@ -53,10 +53,10 @@ import {
 | 
			
		||||
} from '@/api/base/equipmentBindSection';
 | 
			
		||||
import moment from 'moment';
 | 
			
		||||
import basicPageMixin from '@/mixins/lb/basicPageMixin';
 | 
			
		||||
 | 
			
		||||
import DialogForm from './dialogForm.vue';
 | 
			
		||||
export default {
 | 
			
		||||
	name: 'EquipmentBindSection',
 | 
			
		||||
	components: {},
 | 
			
		||||
	components: { DialogForm },
 | 
			
		||||
	mixins: [basicPageMixin],
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
@@ -181,8 +181,8 @@ export default {
 | 
			
		||||
						select: true,
 | 
			
		||||
						label: '工段',
 | 
			
		||||
						url: '/base/workshop-section/listByParentId', // 根据产线获取
 | 
			
		||||
            // depends: '__product_line', // 依赖产线获取数据
 | 
			
		||||
            depends: 'productionLineId',
 | 
			
		||||
						// depends: '__product_line', // 依赖产线获取数据
 | 
			
		||||
						depends: 'productionLineId',
 | 
			
		||||
						prop: 'workshopSectionId',
 | 
			
		||||
						rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
 | 
			
		||||
					},
 | 
			
		||||
 
 | 
			
		||||
@@ -12,31 +12,7 @@
 | 
			
		||||
			ref="search-bar"
 | 
			
		||||
			@headBtnClick="handleSearchBarBtnClick" />
 | 
			
		||||
 | 
			
		||||
		<!-- <base-table
 | 
			
		||||
			:table-props="[
 | 
			
		||||
				{ type: 'index', label: '序号' },
 | 
			
		||||
				{ prop: 'name', label: '设备名称', align: 'center' },
 | 
			
		||||
				{ prop: 'code', label: '设备代码', align: 'center' },
 | 
			
		||||
				{ prop: 'time', label: '时间', align: 'center' },
 | 
			
		||||
			]"
 | 
			
		||||
			:table-data="[
 | 
			
		||||
				{ index: 1, name: '1', code: 'c1', time: '2021-08-31 09:14:19' },
 | 
			
		||||
				{ index: 2, name: '2', code: 'c2', time: '2021-08-31 09:14:19' },
 | 
			
		||||
				{ index: 3, name: '3', code: 'c3', time: '2021-08-31 09:14:19' },
 | 
			
		||||
				{ index: 4, name: '4', code: 'c4', time: '2021-08-31 09:14:19' },
 | 
			
		||||
				{ index: 5, name: '5', code: 'c5', time: '2021-08-31 09:14:19' },
 | 
			
		||||
			]"
 | 
			
		||||
			:span-method="
 | 
			
		||||
				({ rowIndex, columnIndex }) => {
 | 
			
		||||
					if (rowIndex == 1 && columnIndex == 0) {
 | 
			
		||||
						return [1, 3];
 | 
			
		||||
					}
 | 
			
		||||
					return [1, 1];
 | 
			
		||||
				}
 | 
			
		||||
			"
 | 
			
		||||
			@emitFun="(val) => handleEmitFun(table, val)"></base-table> -->
 | 
			
		||||
 | 
			
		||||
		<div class="tables">
 | 
			
		||||
		<div v-if="tableList.length" class="tables">
 | 
			
		||||
			<div class="custom-table" v-for="table in tableList" :key="table.key">
 | 
			
		||||
				<!-- {{ JSON.stringify(spanMethod) }} -->
 | 
			
		||||
				<base-table
 | 
			
		||||
@@ -58,16 +34,14 @@
 | 
			
		||||
							getListFor(table, { page, limit, current })
 | 
			
		||||
					" />
 | 
			
		||||
			</div>
 | 
			
		||||
			<!-- v-show="table.dataManager?.total > 0"
 | 
			
		||||
				:total="table.dataManager?.total || 0" -->
 | 
			
		||||
			<!-- @size-change="($event) => handleSizeChange(table, $event)" -->
 | 
			
		||||
		</div>
 | 
			
		||||
		<div v-else style="margin-top: 20px; color: #c7c7c7; text-align: center;">暂无数据</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import LocalDataManager from './utils/local-data-manager';
 | 
			
		||||
import response from './response';
 | 
			
		||||
// import response from './response';
 | 
			
		||||
import moment from 'moment';
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
@@ -123,14 +97,14 @@ export default {
 | 
			
		||||
				time: [new Date(aWeekAgo), new Date(today)],
 | 
			
		||||
			},
 | 
			
		||||
			tableList: [
 | 
			
		||||
				{
 | 
			
		||||
					key: 'base-table__key__1',
 | 
			
		||||
					tableProps: [],
 | 
			
		||||
					list: [],
 | 
			
		||||
					pageNo: 1,
 | 
			
		||||
					pageSize: 3,
 | 
			
		||||
					total: 0,
 | 
			
		||||
				},
 | 
			
		||||
				// {
 | 
			
		||||
				// 	key: 'base-table__key__1',
 | 
			
		||||
				// 	tableProps: [],
 | 
			
		||||
				// 	list: [],
 | 
			
		||||
				// 	pageNo: 1,
 | 
			
		||||
				// 	pageSize: 3,
 | 
			
		||||
				// 	total: 0,
 | 
			
		||||
				// },
 | 
			
		||||
			],
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
@@ -152,7 +126,7 @@ export default {
 | 
			
		||||
		if (this.name)
 | 
			
		||||
			this.$set(this.searchBarFormConfig[1], 'defaultSelect', this.name);
 | 
			
		||||
 | 
			
		||||
		this.handleResponse();
 | 
			
		||||
		// this.handleResponse();
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		buildProps(table) {
 | 
			
		||||
@@ -199,11 +173,9 @@ export default {
 | 
			
		||||
			return { props, firstLineData };
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		handleResponse() {
 | 
			
		||||
		handleResponse(response) {
 | 
			
		||||
			const { code, data } = response;
 | 
			
		||||
			if (code == 0) {
 | 
			
		||||
				console.log('response', code, data);
 | 
			
		||||
 | 
			
		||||
				// 处理一个表格
 | 
			
		||||
				data.forEach((table, index) => {
 | 
			
		||||
					console.log('handle index:', index, table);
 | 
			
		||||
@@ -220,26 +192,28 @@ export default {
 | 
			
		||||
 | 
			
		||||
					// 处理某一表格的各个行
 | 
			
		||||
					const { data } = table;
 | 
			
		||||
					data.forEach((row, idx) => {
 | 
			
		||||
						const listItem = {
 | 
			
		||||
							index: idx + 1,
 | 
			
		||||
							time: moment(+row.time).format('YYYY-MM-DD HH:mm:ss'),
 | 
			
		||||
							plcCode: row.plcCode,
 | 
			
		||||
						};
 | 
			
		||||
						row.data.forEach((column) => {
 | 
			
		||||
							listItem[column.dynamicName] = column.dynamicValue;
 | 
			
		||||
					if (data) {
 | 
			
		||||
						data.forEach((row, idx) => {
 | 
			
		||||
							const listItem = {
 | 
			
		||||
								index: idx + 1,
 | 
			
		||||
								time: moment(+row.time).format('YYYY-MM-DD HH:mm:ss'),
 | 
			
		||||
								plcCode: row.plcCode,
 | 
			
		||||
							};
 | 
			
		||||
							row.data.forEach((column) => {
 | 
			
		||||
								listItem[column.dynamicName] = column.dynamicValue;
 | 
			
		||||
							});
 | 
			
		||||
							this.tableList[index].list.push(listItem);
 | 
			
		||||
							this.tableList[index].total++;
 | 
			
		||||
						});
 | 
			
		||||
						this.tableList[index].list.push(listItem);
 | 
			
		||||
						this.tableList[index].total++;
 | 
			
		||||
					});
 | 
			
		||||
 | 
			
		||||
					// 处理分页
 | 
			
		||||
					const { pageNo, pageSize, list } = this.tableList[index];
 | 
			
		||||
					this.tableList[index].dataManager = new LocalDataManager(
 | 
			
		||||
						list,
 | 
			
		||||
						pageNo,
 | 
			
		||||
						pageSize
 | 
			
		||||
					);
 | 
			
		||||
						// 处理分页
 | 
			
		||||
						const { pageNo, pageSize, list } = this.tableList[index];
 | 
			
		||||
						this.tableList[index].dataManager = new LocalDataManager(
 | 
			
		||||
							list,
 | 
			
		||||
							pageNo,
 | 
			
		||||
							pageSize
 | 
			
		||||
						);
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
@@ -255,12 +229,13 @@ export default {
 | 
			
		||||
 | 
			
		||||
		/** 查询 */
 | 
			
		||||
		async handleQuery() {
 | 
			
		||||
			const { data } = this.$axios({
 | 
			
		||||
				url: '/monitoring/equipment-monitor/runLog',
 | 
			
		||||
				method: 'get',
 | 
			
		||||
				params: this.queryParams,
 | 
			
		||||
			});
 | 
			
		||||
			console.log('data', data);
 | 
			
		||||
			this.handleResponse(
 | 
			
		||||
				await this.$axios({
 | 
			
		||||
					url: '/monitoring/equipment-monitor/runLog',
 | 
			
		||||
					method: 'get',
 | 
			
		||||
					params: this.queryParams,
 | 
			
		||||
				})
 | 
			
		||||
			);
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		async handleSearchBarBtnClick({ btnName, timeVal }) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user