lb #3
@@ -1,14 +1,22 @@
 | 
			
		||||
<template>
 | 
			
		||||
	<!-- 设备异常分析 -->
 | 
			
		||||
	<!-- 设备效率分析 -->
 | 
			
		||||
	<div class="mod-config">
 | 
			
		||||
		<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
 | 
			
		||||
			<!-- 月份 -->
 | 
			
		||||
			<el-form-item>
 | 
			
		||||
				<el-input v-model="dataForm.key" :placeholder="$t('eq.name') + ' / ' + $t('eq.code')" clearable></el-input>
 | 
			
		||||
				<el-date-picker key="month-picker" v-model="rawTime" type="month" :placeholder="'请选择月份'" format="yyyy-MM" />
 | 
			
		||||
			</el-form-item>
 | 
			
		||||
			<!-- 产线 -->
 | 
			
		||||
			<el-form-item>
 | 
			
		||||
				<el-select v-model="dataForm.productlines" :placeholder="'产线'" multiple clearable>
 | 
			
		||||
					<el-option v-for="productLine in productLineList" :key="productLine.id" :value="productLine.id" :label="productLine.name" />
 | 
			
		||||
				</el-select>
 | 
			
		||||
			</el-form-item>
 | 
			
		||||
 | 
			
		||||
			<!-- 按钮 -->
 | 
			
		||||
			<el-form-item>
 | 
			
		||||
				<el-button @click="getDataList()">{{ $t('search') }}</el-button>
 | 
			
		||||
				<el-button v-if="$hasPermission('monitoring:equipment:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
 | 
			
		||||
				<el-button v-if="$hasPermission('monitoring:equipment:export')" @click="exportHandle()">{{ $t('export') }}</el-button>
 | 
			
		||||
				<!-- <el-button v-if="$hasPermission('monitoring:equipmentEffiency:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button> -->
 | 
			
		||||
			</el-form-item>
 | 
			
		||||
		</el-form>
 | 
			
		||||
 | 
			
		||||
@@ -22,311 +30,154 @@
 | 
			
		||||
			:total="totalPage"
 | 
			
		||||
			layout="total, sizes, prev, pager, next, jumper"
 | 
			
		||||
		></el-pagination>
 | 
			
		||||
		<!-- 弹窗, 新增 / 修改 -->
 | 
			
		||||
		<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" :configs="addOrUpdateConfigs" @refreshDataList="getDataList" @destory-dialog="addOrUpdateVisible = false" />
 | 
			
		||||
	</div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import i18n from '@/i18n'
 | 
			
		||||
import AddOrUpdate from '@/components/base-dialog/addOrUpdate'
 | 
			
		||||
// import AddOrUpdate from './equipment-add-or-update'
 | 
			
		||||
import BaseTable from '@/components/base-table'
 | 
			
		||||
import TableOperateComponent from '@/components/base-table/components/operationComponent'
 | 
			
		||||
import TableTextComponent from '@/components/base-table/components/detailComponent'
 | 
			
		||||
import CKEditor from 'ckeditor4-vue'
 | 
			
		||||
 | 
			
		||||
import { calcMaxHeight } from '@/utils'
 | 
			
		||||
import { timeFilter } from '@/utils/filters'
 | 
			
		||||
import Cookies from 'js-cookie'
 | 
			
		||||
import moment from 'moment'
 | 
			
		||||
 | 
			
		||||
const tableConfigs = [
 | 
			
		||||
	{
 | 
			
		||||
		type: 'index',
 | 
			
		||||
		name: i18n.t('index')
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		prop: 'createTime',
 | 
			
		||||
		name: i18n.t('createTime'),
 | 
			
		||||
		filter: timeFilter
 | 
			
		||||
	},
 | 
			
		||||
	{ prop: 'name', name: i18n.t('eq.name') },
 | 
			
		||||
	{ prop: 'code', name: i18n.t('eq.code') },
 | 
			
		||||
	{ prop: 'equipmentTypeName', name: i18n.t('eq.type') },
 | 
			
		||||
	{ prop: 'groupName', name: i18n.t('eq.group') },
 | 
			
		||||
	{ prop: 'enName', name: i18n.t('enname') },
 | 
			
		||||
	{ prop: 'abbr', name: i18n.t('abbr') },
 | 
			
		||||
	{
 | 
			
		||||
		prop: 'details',
 | 
			
		||||
		name: i18n.t('detail'),
 | 
			
		||||
		subcomponent: TableTextComponent,
 | 
			
		||||
		actionName: 'view-detail'
 | 
			
		||||
	},
 | 
			
		||||
	{ prop: 'pdlName', name: '产线名称' },
 | 
			
		||||
	{ prop: 'wsName', name: '工序' },
 | 
			
		||||
	{ prop: 'eqName', name: '设备' },
 | 
			
		||||
	{ prop: 'mtbf', name: '平均故障间隔时间[MTBF] (h)', width: 220 },
 | 
			
		||||
	{ prop: 'mttr', name: '平均维修时间[MTTR] (h)', width: 190 },
 | 
			
		||||
	{ prop: 'workTime', name: '工作时长 (h)' },
 | 
			
		||||
	{ prop: 'downTime', name: '故障时长 (h)' },
 | 
			
		||||
	{ prop: 'downCount', name: '故障次数' },
 | 
			
		||||
	{
 | 
			
		||||
		prop: 'operations',
 | 
			
		||||
		name: i18n.t('handle'),
 | 
			
		||||
		fixed: 'right',
 | 
			
		||||
		width: 180,
 | 
			
		||||
		subcomponent: TableOperateComponent,
 | 
			
		||||
		options: ['edit', 'delete']
 | 
			
		||||
		// options: ['edit', 'delete']
 | 
			
		||||
		options: ['view-trend'] // 查看趋势
 | 
			
		||||
	}
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
const addOrUpdateConfigs = {
 | 
			
		||||
	type: 'dialog',
 | 
			
		||||
	infoUrl: '/monitoring/equipment',
 | 
			
		||||
	fields: [
 | 
			
		||||
		{ name: 'name', label: i18n.t('eq.name'), required: true },
 | 
			
		||||
		{ name: 'code', label: i18n.t('eq.code') },
 | 
			
		||||
		{ name: 'enName', label: i18n.t('enname') },
 | 
			
		||||
		{ name: 'abbr', label: i18n.t('abbr') },
 | 
			
		||||
		{
 | 
			
		||||
			name: 'equipmentTypeId',
 | 
			
		||||
			label: i18n.t('eq.type'),
 | 
			
		||||
			required: true,
 | 
			
		||||
			type: 'select',
 | 
			
		||||
			options: []
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'groupId',
 | 
			
		||||
			label: i18n.t('eq.group'),
 | 
			
		||||
			required: true,
 | 
			
		||||
			type: 'select',
 | 
			
		||||
			options: []
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'productionTime',
 | 
			
		||||
			label: i18n.t('produceTime'),
 | 
			
		||||
			type: 'date',
 | 
			
		||||
			props: {
 | 
			
		||||
				'type': 'date', // element-ui 的配置
 | 
			
		||||
				'placeholder': i18n.t('hints.date'),
 | 
			
		||||
				'value-format': 'yyyy-MM-ddTHH:mm:ss',
 | 
			
		||||
				'style': {
 | 
			
		||||
					width: '100%'
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'enterTime',
 | 
			
		||||
			label: i18n.t('enterTime'),
 | 
			
		||||
			type: 'date',
 | 
			
		||||
			props: {
 | 
			
		||||
				'type': 'date', // element-ui 的配置
 | 
			
		||||
				'placeholder': i18n.t('hints.date'),
 | 
			
		||||
				'value-format': 'yyyy-MM-ddTHH:mm:ss',
 | 
			
		||||
				'style': {
 | 
			
		||||
					width: '100%'
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'tvalue',
 | 
			
		||||
			label: i18n.t('eq.tvalue'),
 | 
			
		||||
			required: true,
 | 
			
		||||
			rules: [
 | 
			
		||||
				{
 | 
			
		||||
					type: 'number',
 | 
			
		||||
					message: i18n.t('hints.number'),
 | 
			
		||||
					trigger: 'blur',
 | 
			
		||||
					transform: val => Number(val)
 | 
			
		||||
				}
 | 
			
		||||
			]
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'processingTime',
 | 
			
		||||
			label: i18n.t('eq.processingTime'),
 | 
			
		||||
			rules: [
 | 
			
		||||
				{
 | 
			
		||||
					type: 'number',
 | 
			
		||||
					message: i18n.t('hints.number'),
 | 
			
		||||
					trigger: 'blur',
 | 
			
		||||
					transform: val => Number(val)
 | 
			
		||||
				}
 | 
			
		||||
			]
 | 
			
		||||
		},
 | 
			
		||||
		{ name: 'manufacturer', label: i18n.t('manufacturer') },
 | 
			
		||||
		{ name: 'spec', label: i18n.t('eq.grade') },
 | 
			
		||||
		{
 | 
			
		||||
			name: 'dataType',
 | 
			
		||||
			label: i18n.t('eq.dtype'),
 | 
			
		||||
			required: true,
 | 
			
		||||
			type: 'select',
 | 
			
		||||
			options: [
 | 
			
		||||
				{ value: 0, label: i18n.t('eq.dtypenone') },
 | 
			
		||||
				{ value: 1, label: i18n.t('eq.dtypeinput') },
 | 
			
		||||
				{ value: 2, label: i18n.t('eq.dtypeoutput') }
 | 
			
		||||
			]
 | 
			
		||||
		},
 | 
			
		||||
		{ name: 'remark', label: i18n.t('remark') }
 | 
			
		||||
	],
 | 
			
		||||
	extraComponents: [
 | 
			
		||||
		{
 | 
			
		||||
			name: 'description',
 | 
			
		||||
			hasModel: true,
 | 
			
		||||
			label: i18n.t('desc'),
 | 
			
		||||
			fieldType: 'string',
 | 
			
		||||
			component: CKEditor.component,
 | 
			
		||||
			props: {
 | 
			
		||||
				// value: 'tests',
 | 
			
		||||
				config: {
 | 
			
		||||
					// ckeditor 的配置: https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html
 | 
			
		||||
					// toolbar: [['Bold']]
 | 
			
		||||
					language: Cookies.get('language') || 'en'
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'files',
 | 
			
		||||
			label: i18n.t('upload.title'),
 | 
			
		||||
			fieldType: 'array',
 | 
			
		||||
			component: () => import('@/components/base-upload'),
 | 
			
		||||
			props: {
 | 
			
		||||
				// 上传组件需要的 props
 | 
			
		||||
				url: '/monitoring/attachment/uploadFileFormData',
 | 
			
		||||
				extraParams: { typeCode: 'EquipmentInfoFile' },
 | 
			
		||||
				buttonContent: i18n.t('upload.button'),
 | 
			
		||||
				tip: i18n.t('hints.upload2m')
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'files',
 | 
			
		||||
			label: i18n.t('eq.image'),
 | 
			
		||||
			fieldType: 'array',
 | 
			
		||||
			component: () => import('@/components/base-upload'),
 | 
			
		||||
			props: {
 | 
			
		||||
				// 上传组件需要的 props
 | 
			
		||||
				url: '/monitoring/attachment/uploadFileFormData',
 | 
			
		||||
				extraParams: { typeCode: 'EquipmentInfoImage' },
 | 
			
		||||
				buttonContent: i18n.t('upload.button'),
 | 
			
		||||
				tip: i18n.t('hints.upload2mPic')
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	],
 | 
			
		||||
	subtable: {
 | 
			
		||||
		title: i18n.t('eq.viewattr'),
 | 
			
		||||
		url: '/monitoring/equipmentAttr',
 | 
			
		||||
		relatedField: 'equipmentId',
 | 
			
		||||
		tableConfigs: [
 | 
			
		||||
			{ type: 'index', width: 100, name: i18n.t('index') },
 | 
			
		||||
			{ prop: 'createTime', name: i18n.t('createTime'), filter: timeFilter },
 | 
			
		||||
			{ prop: 'attrName', name: i18n.t('attrName'), formField: true },
 | 
			
		||||
			{ prop: 'attrValue', name: i18n.t('attrValue'), formField: true },
 | 
			
		||||
			{
 | 
			
		||||
				prop: 'operations',
 | 
			
		||||
				name: i18n.t('handle'),
 | 
			
		||||
				fixed: 'right',
 | 
			
		||||
				width: 180,
 | 
			
		||||
				subcomponent: TableOperateComponent,
 | 
			
		||||
				options: ['edit', 'delete']
 | 
			
		||||
			}
 | 
			
		||||
		]
 | 
			
		||||
	},
 | 
			
		||||
	operations: [
 | 
			
		||||
		{ name: 'cancel', showAlways: true },
 | 
			
		||||
		{
 | 
			
		||||
			name: 'save',
 | 
			
		||||
			url: '/monitoring/equipment',
 | 
			
		||||
			permission: 'monitoring:equipment:save',
 | 
			
		||||
			showOnEdit: false
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			name: 'update',
 | 
			
		||||
			url: '/monitoring/equipment',
 | 
			
		||||
			permission: 'monitoring:equipment:update',
 | 
			
		||||
			showOnEdit: true
 | 
			
		||||
		}
 | 
			
		||||
	]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			/** hfxny part */
 | 
			
		||||
			factoryList: [],
 | 
			
		||||
			productLineList: [],
 | 
			
		||||
			/** */
 | 
			
		||||
			calcMaxHeight,
 | 
			
		||||
			tableConfigs,
 | 
			
		||||
			addOrUpdateConfigs,
 | 
			
		||||
			timeType: 'range',
 | 
			
		||||
			rawTime: null, // [] or datetime
 | 
			
		||||
			dataForm: {
 | 
			
		||||
				key: ''
 | 
			
		||||
				type: 1,
 | 
			
		||||
				ftId: null,
 | 
			
		||||
				productlines: [],
 | 
			
		||||
				startTime: null,
 | 
			
		||||
				entTime: null
 | 
			
		||||
			},
 | 
			
		||||
			dataList: [],
 | 
			
		||||
			pageIndex: 1,
 | 
			
		||||
			pageSize: 10,
 | 
			
		||||
			totalPage: 0,
 | 
			
		||||
			dataListLoading: false,
 | 
			
		||||
			dataListSelections: [],
 | 
			
		||||
			addOrUpdateVisible: false
 | 
			
		||||
			dataListLoading: false
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	components: {
 | 
			
		||||
		AddOrUpdate,
 | 
			
		||||
		BaseTable
 | 
			
		||||
	},
 | 
			
		||||
	activated() {
 | 
			
		||||
		console.log('activated')
 | 
			
		||||
		this.getDataList()
 | 
			
		||||
		this.getGroupList()
 | 
			
		||||
		this.getTypeList()
 | 
			
		||||
 | 
			
		||||
	created() {
 | 
			
		||||
		this.getFactoryList()
 | 
			
		||||
		// this.getProductLineList()
 | 
			
		||||
	},
 | 
			
		||||
	watch: {},
 | 
			
		||||
	methods: {
 | 
			
		||||
		// 获取设备类型列表
 | 
			
		||||
		getTypeList() {
 | 
			
		||||
		// 获取工厂列表
 | 
			
		||||
		getFactoryList() {
 | 
			
		||||
			this.$http({
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/equipmentType/page'),
 | 
			
		||||
				method: 'get',
 | 
			
		||||
				params: this.$http.adornParams({
 | 
			
		||||
					// page: this.pageIndex,
 | 
			
		||||
					// limit: this.pageSize,
 | 
			
		||||
					// key: this.dataForm.key
 | 
			
		||||
				})
 | 
			
		||||
			}).then(({ data }) => {
 | 
			
		||||
				const eqTypeConfig = this.addOrUpdateConfigs.fields.find(item => item.name === 'equipmentTypeId')
 | 
			
		||||
				eqTypeConfig.options =
 | 
			
		||||
					data.data?.list?.map(item => ({
 | 
			
		||||
						value: item.id,
 | 
			
		||||
						label: item.name
 | 
			
		||||
					})) || []
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 获取设备分组列表
 | 
			
		||||
		getGroupList() {
 | 
			
		||||
			this.$http({
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/equipmentGroup/page'),
 | 
			
		||||
				method: 'get',
 | 
			
		||||
				params: this.$http.adornParams({
 | 
			
		||||
					// page: this.pageIndex,
 | 
			
		||||
					// limit: this.pageSize,
 | 
			
		||||
					// key: this.dataForm.key
 | 
			
		||||
				})
 | 
			
		||||
			}).then(({ data }) => {
 | 
			
		||||
				const groupConfig = this.addOrUpdateConfigs.fields.find(item => item.name === 'groupId')
 | 
			
		||||
				groupConfig.options =
 | 
			
		||||
					data.data?.list?.map(item => ({
 | 
			
		||||
						value: item.id,
 | 
			
		||||
						label: item.name
 | 
			
		||||
					})) || []
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 获取数据列表
 | 
			
		||||
		getDataList() {
 | 
			
		||||
			this.dataListLoading = true
 | 
			
		||||
			this.$http({
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/equipment/page'),
 | 
			
		||||
				method: 'get',
 | 
			
		||||
				params: this.$http.adornParams({
 | 
			
		||||
					page: this.pageIndex,
 | 
			
		||||
					limit: this.pageSize,
 | 
			
		||||
					key: this.dataForm.key
 | 
			
		||||
				})
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/factory/page'),
 | 
			
		||||
				method: 'get'
 | 
			
		||||
			}).then(({ data }) => {
 | 
			
		||||
				if (data && data.code === 0) {
 | 
			
		||||
					this.dataList = data.data.list
 | 
			
		||||
					// this.dataList = new Array(20).fill('1')
 | 
			
		||||
					// console.log('data list', this.dataList)
 | 
			
		||||
					this.totalPage = data.data.total
 | 
			
		||||
					this.factoryList = data.data.list
 | 
			
		||||
					/** set default */
 | 
			
		||||
					if (this.factoryList.length) {
 | 
			
		||||
						this.dataForm.ftId = this.factoryList[0].id
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					this.dataList = []
 | 
			
		||||
					this.totalPage = 0
 | 
			
		||||
					this.factoryList = []
 | 
			
		||||
					this.dataForm.ftId = null
 | 
			
		||||
				}
 | 
			
		||||
				this.dataListLoading = false
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 获取产线列表
 | 
			
		||||
		getProductLineList() {
 | 
			
		||||
			this.$http({
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/productionLine/page'),
 | 
			
		||||
				method: 'get'
 | 
			
		||||
			}).then(({ data }) => {
 | 
			
		||||
				if (data && data.code === 0) {
 | 
			
		||||
					this.productLineList = data.data.list
 | 
			
		||||
					/** set default */
 | 
			
		||||
					if (this.productLineList.length) {
 | 
			
		||||
						this.dataForm.productlines = [this.productLineList[0].id]
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					this.productLineList = []
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		// 时间类型预处理
 | 
			
		||||
		getTimeRange() {
 | 
			
		||||
			let startTime
 | 
			
		||||
			let endTime
 | 
			
		||||
			if (this.rawTime instanceof Array) {
 | 
			
		||||
				startTime = this.rawTime[0] ? moment(this.rawTime[0]).format('YYYY-MM-DDTHH:mm:ss') : '' // 强制axios使用北京时间
 | 
			
		||||
				endTime = this.rawTime[1] ? moment(this.rawTime[1]).format('YYYY-MM-DDTHH:mm:ss') : ''
 | 
			
		||||
			} else {
 | 
			
		||||
				if (this.rawTime) {
 | 
			
		||||
					startTime = moment(this.rawTime).format('YYYY-MM-DDTHH:mm:ss')
 | 
			
		||||
					endTime = moment(startTime)
 | 
			
		||||
						.add(1, 'd')
 | 
			
		||||
						.format('YYYY-MM-DDTHH:mm:ss')
 | 
			
		||||
				} else {
 | 
			
		||||
					startTime = ''
 | 
			
		||||
					endTime = ''
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return { startTime, endTime }
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		// 获取数据列表
 | 
			
		||||
		getDataList() {
 | 
			
		||||
			const { startTime, endTime } = this.getTimeRange()
 | 
			
		||||
 | 
			
		||||
			this.dataListLoading = true
 | 
			
		||||
			this.$http({
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/eqAnalysis/oee'),
 | 
			
		||||
				method: 'post',
 | 
			
		||||
				data: {
 | 
			
		||||
					startTime,
 | 
			
		||||
					endTime,
 | 
			
		||||
					ftId: this.dataForm.ftId,
 | 
			
		||||
					productlines: this.dataForm.productlines,
 | 
			
		||||
					limit: this.pageIndex,
 | 
			
		||||
					page: this.pageSize,
 | 
			
		||||
					type: 1
 | 
			
		||||
				}
 | 
			
		||||
			}).then(({ data: res }) => {
 | 
			
		||||
				console.log('oee data:', res)
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 每页数
 | 
			
		||||
@@ -347,98 +198,12 @@ export default {
 | 
			
		||||
		handleOperations({ type, data: id }) {
 | 
			
		||||
			switch (type) {
 | 
			
		||||
				case 'view-detail':
 | 
			
		||||
					// const { name, code } = this.dataList.find(item => item.id === id)
 | 
			
		||||
					// this.$router.push({
 | 
			
		||||
					// 	name: 'monitoring-equipmentAdd',
 | 
			
		||||
					// 	params: {
 | 
			
		||||
					// 		isdetail: true,
 | 
			
		||||
					// 		equipmentId: id
 | 
			
		||||
					// 	}
 | 
			
		||||
					// })
 | 
			
		||||
					// break
 | 
			
		||||
					return this.addOrUpdateHandle(id, true)
 | 
			
		||||
				case 'edit':
 | 
			
		||||
					return this.addOrUpdateHandle(id)
 | 
			
		||||
				case 'delete':
 | 
			
		||||
					return this.deleteHandle(id)
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		exportHandle() {
 | 
			
		||||
			// this.$http.get(this.$http.adornUrl('/monitoring/equipment/export')).then(({ data: res }) => {
 | 
			
		||||
			this.$http({
 | 
			
		||||
				url: this.$http.adornUrl('/monitoring/equipment/export'),
 | 
			
		||||
				method: 'get',
 | 
			
		||||
				responseType: 'blob'
 | 
			
		||||
			}).then(res => {
 | 
			
		||||
				let fileName = 'equipment-list.xls'
 | 
			
		||||
				if (res.headers['content-disposition']) {
 | 
			
		||||
					const contentDisposition = res.headers['content-disposition']
 | 
			
		||||
					fileName = contentDisposition.slice(contentDisposition.indexOf('filename=') + 9)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				fileName = decodeURIComponent(fileName)
 | 
			
		||||
 | 
			
		||||
				const blob = new Blob([res.data])
 | 
			
		||||
 | 
			
		||||
				if ('download' in document.createElement('a')) {
 | 
			
		||||
					const alink = document.createElement('a')
 | 
			
		||||
					alink.download = fileName
 | 
			
		||||
					alink.style.display = 'none'
 | 
			
		||||
					alink.target = '_blank'
 | 
			
		||||
					alink.href = URL.createObjectURL(blob)
 | 
			
		||||
					document.body.appendChild(alink)
 | 
			
		||||
					alink.click()
 | 
			
		||||
					URL.revokeObjectURL(alink.href)
 | 
			
		||||
					document.body.removeChild(alink)
 | 
			
		||||
				} else {
 | 
			
		||||
					navigator.msSaveBlob(blob, fileName)
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 新增 / 修改
 | 
			
		||||
		addOrUpdateHandle(id, isdetail = false) {
 | 
			
		||||
			this.addOrUpdateVisible = true
 | 
			
		||||
			this.$nextTick(() => {
 | 
			
		||||
				this.$refs.addOrUpdate.init(id, isdetail)
 | 
			
		||||
			})
 | 
			
		||||
			// this.$router.push({
 | 
			
		||||
			// 	name: 'monitoring-equipmentAdd',
 | 
			
		||||
			// 	params: {
 | 
			
		||||
			// 		equipmentId: id
 | 
			
		||||
			// 	}
 | 
			
		||||
			// })
 | 
			
		||||
		},
 | 
			
		||||
		// 删除
 | 
			
		||||
		deleteHandle(id) {
 | 
			
		||||
			var ids = id
 | 
			
		||||
				? [id]
 | 
			
		||||
				: this.dataListSelections.map(item => {
 | 
			
		||||
						return item.id
 | 
			
		||||
				  })
 | 
			
		||||
			this.$confirm(`${i18n.t('prompt.info', { handle: id ? i18n.t('delete').toLowerCase() : i18n.t('deleteBatch').toLowerCase() })}`, i18n.t('prompt.title'), {
 | 
			
		||||
				confirmButtonText: i18n.t('confirm'),
 | 
			
		||||
				cancelButtonText: i18n.t('cancel'),
 | 
			
		||||
				type: 'warning'
 | 
			
		||||
			}).then(() => {
 | 
			
		||||
				this.$http({
 | 
			
		||||
					url: this.$http.adornUrl('/monitoring/equipment'),
 | 
			
		||||
					method: 'delete',
 | 
			
		||||
					data: this.$http.adornData(ids, false, 'raw')
 | 
			
		||||
				}).then(({ data }) => {
 | 
			
		||||
					if (data && data.code === 0) {
 | 
			
		||||
						this.$message({
 | 
			
		||||
							message: i18n.t('prompt.success'),
 | 
			
		||||
							type: 'success',
 | 
			
		||||
							duration: 1500,
 | 
			
		||||
							onClose: () => {
 | 
			
		||||
								this.getDataList()
 | 
			
		||||
							}
 | 
			
		||||
						})
 | 
			
		||||
					} else {
 | 
			
		||||
						this.$message.error(data.msg)
 | 
			
		||||
					}
 | 
			
		||||
				})
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user