You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
868 lines
30 KiB
868 lines
30 KiB
<template> |
|
<basic-container style="max-height: 800px; overflow: hidden"> |
|
<avue-crud :option="option" :table-loading="loading" :data="data" :search.sync="searchForm" :page.sync="page" |
|
ref="crud" v-model="form" :permission="permissionList" :before-open="beforeOpen" :before-close="beforeClose" |
|
@search-change="searchChange" @search-reset="searchReset" @current-change="currentChange" |
|
@size-change="sizeChange" @refresh-change="refreshChange" @selection-change="selectionChange" @on-load="onLoad"> |
|
<template slot-scope="{row}" slot="produceTime"> |
|
{{ row.produceTime.substring(0, 10) }} |
|
</template> |
|
<template slot-scope="{ row }" slot="status"> |
|
<el-tag size="small" :type="row.status == 0 |
|
? 'warning' |
|
: row.status == 1 |
|
? '' |
|
: '' |
|
"> |
|
{{ |
|
row.status == 0 |
|
? "待确认" |
|
: row.status == 1 |
|
? "已确认" |
|
: "" |
|
}} |
|
</el-tag> |
|
</template> |
|
<template slot-scope="{ row }" slot="runStatus"> |
|
<el-tag size="small" :type="row.runStatus == 0 |
|
? 'info' |
|
: row.runStatus == 1 |
|
? 'success' |
|
: row.runStatus == 2 |
|
? 'danger' |
|
: '' |
|
"> |
|
{{ |
|
row.runStatus == 0 |
|
? "关机" |
|
: row.runStatus == 1 |
|
? "运行中" |
|
: row.runStatus == 2 |
|
? '报警中' |
|
: "" |
|
}} |
|
</el-tag> |
|
</template> |
|
<template slot-scope="scope" slot="menuLeft"> |
|
<el-button v-show="permission.deviceAdd" size="small" @click="handleAdd" type="primary">新 增</el-button> |
|
<el-button v-show="permission.deviceAdd" size="small" @click="handleImport" type="success">导 入</el-button> |
|
<el-button type="warning" size="small" @click="handleExport">导 出</el-button> |
|
<!-- <el-button |
|
type="primary" |
|
size="small" |
|
@click="addOperation" |
|
>需求提报</el-button |
|
> --> |
|
</template> |
|
<template slot-scope="{ row }" slot="menu"> |
|
<el-button v-show="permission.deviceView" @click="handleView(row)">查看</el-button> |
|
<el-button v-show="permission.deviceEdit" @click="handleEdit(row)">编辑</el-button> |
|
<el-button v-show="permission.deviceSubmit" @click="addOperation(row)">需求提报</el-button> |
|
<el-button v-show="row.qrcode == '' && permission.createQrcode" @click="handleQrcode(row)">生成二维码</el-button> |
|
<el-button v-show="row.qrcode != '' && permission.qrcodeView" @click="lookQrcode(row)">查看二维码</el-button> |
|
<el-button v-show="permission.deviceDelete" @click="handleDelete(row)">删除</el-button> |
|
</template> |
|
</avue-crud> |
|
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" :append-to-body="true" width="70%"> |
|
<div style="height: 500px; overflow: auto"> |
|
<el-form ref="form" :model="addForm" :rules="addRules" label-width="120px" label-position="left"> |
|
<div> |
|
<div style=" |
|
color: #101010; |
|
font-size: 18px; |
|
font-weight: 550; |
|
margin-bottom: 20px; |
|
"> |
|
基本信息 |
|
</div> |
|
<!-- <el-form-item label="设备编号" prop="code"> |
|
<el-input placeholder="请输入设备编号" style="width: 98%;" :readonly="viewType == 'view'" v-model="addForm.code"></el-input> |
|
</el-form-item> --> |
|
<el-form-item label="设备名称" prop="name"> |
|
<el-input placeholder="请输入设备名称" style="width: 98%;" :disabled="viewType == 'view'" |
|
v-model="addForm.name"></el-input> |
|
</el-form-item> |
|
<el-form-item label="型号" prop="model"> |
|
<el-input placeholder="请输入型号" style="width: 98%;" :disabled="viewType == 'view'" |
|
v-model="addForm.model"></el-input> |
|
</el-form-item> |
|
<!-- <el-form-item label="设备位置"> |
|
<SelectTree |
|
style="width: 98%;" |
|
ref="childTree" |
|
v-model="addForm.position" |
|
:disabled="viewType == 'view'" |
|
:tree-options="treeOptions" |
|
:default-value="addForm.position.node" |
|
></SelectTree> |
|
</el-form-item> --> |
|
<el-form-item label="设备类型" prop="type"> |
|
<el-select style="width:98%;" placeholder="请选择设备类型" :disabled="viewType == 'view'" v-model="addForm.type"> |
|
<el-option v-for="item in typeList" :key="item.dictValue" :label="item.dictValue" |
|
:value="item.dictValue"></el-option> |
|
</el-select> |
|
</el-form-item> |
|
<el-form-item label="供应商" prop="supplier"> |
|
<el-input style="width: 98%;" :disabled="viewType == 'view'" placeholder="请输入供应商" |
|
v-model="addForm.supplier"></el-input> |
|
</el-form-item> |
|
<el-form-item label="品牌" prop="supplier"> |
|
<el-input style="width: 98%;" :disabled="viewType == 'view'" placeholder="请输入品牌" |
|
v-model="addForm.brand"></el-input> |
|
</el-form-item> |
|
<el-form-item label="生产时间" prop="produceTime"> |
|
<el-date-picker :disabled="viewType == 'view'" style="width:98%;" v-model="addForm.produceTime" |
|
format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date" placeholder="请选择生产时间"> |
|
</el-date-picker> |
|
</el-form-item> |
|
<el-form-item label="关联实验室" prop="lab"> |
|
<el-cascader :props="labProps" style="width:98%;" v-model="addForm.lab" |
|
:disabled="viewType == 'view'"></el-cascader> |
|
</el-form-item> |
|
<el-form-item label="" prop="lab" v-if="role_id=='1839536982874193922'"> |
|
<el-checkbox v-model="addForm.isMaintain" :disabled="viewType == 'view'"> 是否在保</el-checkbox> |
|
</el-form-item> |
|
</div> |
|
<div> |
|
<div style=" |
|
color: #101010; |
|
font-size: 18px; |
|
font-weight: 550; |
|
margin-bottom: 20px; |
|
"> |
|
附件 |
|
</div> |
|
<el-form-item label="附件名称" prop="attachName"> |
|
<el-input style="width: 98%;" :disabled="viewType == 'view'" placeholder="请输入附件名称" |
|
v-model="addForm.attachName"></el-input> |
|
</el-form-item> |
|
<el-form-item label="附件上传"> |
|
<!-- :limit="3" --> |
|
<el-upload class="upload-demo" action="/api/blade-resource/oss/endpoint/put-file" |
|
:on-success="handleSuccess" :on-remove="handleRemove" multiple :disabled="viewType == 'view'" |
|
accept=".jpeg,.jpg,.png,.pdf" :on-exceed="handleExceed" :file-list="imgList"> |
|
<el-button size="small" type="primary">点击上传</el-button> |
|
<div slot="tip" class="el-upload__tip">支持上传jpeg、jpg、pdf文件,且不超过10M</div> |
|
</el-upload> |
|
</el-form-item> |
|
</div> |
|
<div> |
|
<div style=" |
|
color: #101010; |
|
font-size: 18px; |
|
font-weight: 550; |
|
margin-bottom: 20px; |
|
"> |
|
巡检相关 |
|
</div> |
|
<el-form-item label="巡检内容" prop="xjcontent"> |
|
<el-input style="width: 98%;" type="textarea" :disabled="viewType == 'view'" v-model="addForm.xjcontent" |
|
placeholder="请输入巡检内容" @change="changeContent"></el-input> |
|
</el-form-item> |
|
<el-form-item label="工艺要求" prop="requirement"> |
|
<el-input style="width: 98%;" type="textarea" :disabled="viewType == 'view'" v-model="addForm.requirement" |
|
placeholder="请输入工艺要求" @change="changeRequire"></el-input> |
|
</el-form-item> |
|
<el-form-item label="巡检周期" prop="cycle"> |
|
<el-select v-model="addForm.cycle" :disabled="viewType == 'view'" placeholder="请选择巡检周期" |
|
style="width: 98%;" @change="changeCycle"> |
|
<el-option v-for="item in periodArr" :key="item.dictKey" :label="item.dictValue" |
|
:value="item.dictKey"></el-option> |
|
</el-select> |
|
</el-form-item> |
|
<el-form-item label="开始时间" prop="startTime"> |
|
<el-date-picker v-model="addForm.startTime" :disabled="viewType == 'view'" placeholder="请选择开始时间" |
|
format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 98%;" @change="changeTime"></el-date-picker> |
|
</el-form-item> |
|
</div> |
|
</el-form> |
|
<div v-if="tableData.length != 0"> |
|
<el-table :data="tableData"> |
|
<el-table-column label="巡检内容" prop="checkContent"></el-table-column> |
|
<el-table-column label="工艺要求" prop="craft"></el-table-column> |
|
<el-table-column label="巡检周期" prop="period"> |
|
<template slot-scope="scope"> |
|
<el-select v-model="scope.row.period" placeholder="巡检周期" :disabled="viewType == 'view'"> |
|
<el-option v-for="item in periodArr" :key="item.dictKey" :label="item.dictValue" |
|
:value="item.dictKey"></el-option> |
|
</el-select> |
|
</template> |
|
</el-table-column> |
|
<el-table-column label="开始时间" prop="startTime"> |
|
<template slot-scope="scope"> |
|
<el-date-picker v-model="scope.row.startTime" placeholder="开始时间" :disabled="viewType == 'view'" |
|
format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 98%;"></el-date-picker> |
|
</template> |
|
</el-table-column> |
|
</el-table> |
|
</div> |
|
</div> |
|
<span slot="footer" class="dialog-footer"> |
|
<el-button @click="handleClose">关 闭</el-button> |
|
<!-- <el-button v-show="viewType != 'view'" @click="handleSave">保 存</el-button> --> |
|
<el-button v-show="viewType != 'view'" type="primary" @click="handleConfirm">确 定</el-button> |
|
</span> |
|
</el-dialog> |
|
<el-dialog title="需求填报" :visible.sync="requestVisible" :append-to-body="true" width="50%"> |
|
<div style="height: 500px; overflow: auto"> |
|
<requestSub @close="closeRequest" title="需求填报" :form="requestForm"></requestSub> |
|
</div> |
|
</el-dialog> |
|
<el-dialog title="导入设备" :visible.sync="importVisible" :append-to-body="true" width="30%"> |
|
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"> |
|
<template slot="excelTemplate"> |
|
<el-button type="primary" @click="handleTemplate"> |
|
点击下载<i class="el-icon-download el-icon--right"></i> |
|
</el-button> |
|
</template> |
|
</avue-form> |
|
</el-dialog> |
|
<div id="qrcodePrint" style="width: 80%;margin-top: 10px;"> |
|
<img :src="qrcodeUrl" alt=""> |
|
</div> |
|
</basic-container> |
|
</template> |
|
|
|
<script> |
|
import printJS from 'print-js' |
|
import { mapGetters } from "vuex"; |
|
import requestSub from '../components/requestSub.vue' |
|
import { getDeviceList, addDevice, getDetail, editDevice, deleteDevice, qrcode, importFile } from '@/api/device/device' |
|
import { getChildList } from '@/api/system/dictbiz' |
|
import { getDeepData } from '@/api/labManagement/inspectionManagement' |
|
import SelectTree from '../../components/selectTree/tree' |
|
import { downloadXls } from "@/util/util"; |
|
import {exportBlob} from "@/api/common"; |
|
import {dateNow} from "@/util/date"; |
|
import NProgress from 'nprogress'; |
|
import 'nprogress/nprogress.css'; |
|
export default { |
|
components: { |
|
requestSub, |
|
SelectTree |
|
}, |
|
computed: { |
|
...mapGetters(["userInfo", "permission"]), |
|
}, |
|
data() { |
|
return { |
|
qrcodeUrl: '', |
|
tableData: [], |
|
searchForm: {}, |
|
selectionList: [], |
|
option: { |
|
height: "auto", |
|
calcHeight: 30, |
|
tip: false, |
|
searchShow: true, |
|
searchMenuSpan: 6, |
|
border: true, |
|
index: true, |
|
dialogType: "dialog", |
|
dialogClickModal: false, |
|
addBtn: false, |
|
viewBtn: false, |
|
editBtn: false, |
|
delBtn: false, |
|
searchShowBtn: false, |
|
refreshBtn: false, |
|
columnBtn: false, |
|
menuWidth: 400, |
|
selection: true, |
|
column: [ |
|
{ |
|
label: "设备编号", |
|
labelWidth: 120, |
|
prop: "code", |
|
overHidden: true, |
|
}, |
|
{ |
|
label: "设备名称", |
|
labelWidth: 120, |
|
prop: "name", |
|
search: true, |
|
overHidden: true, |
|
}, |
|
{ |
|
label: "型号", |
|
labelWidth: 120, |
|
prop: "model", |
|
overHidden: true, |
|
}, |
|
// { |
|
// label: "设备位置", |
|
// labelWidth: 120, |
|
// prop: "position", |
|
// type: 'tree', |
|
// overHidden: true, |
|
// // hide: true, |
|
// search: true, |
|
// // viewDisplay: false, |
|
// dicUrl: '/api/blade-system/dict-biz/child-list?current=1&size=100&parentId=1846792623628001282', |
|
// props: { |
|
// label: "dictValue", |
|
// value: "dictValue", |
|
// }, |
|
// }, |
|
{ |
|
label: "设备类型", |
|
labelWidth: 120, |
|
prop: "type", |
|
overHidden: true, |
|
type: "select", |
|
searchLabelWidth: 100, |
|
search: true, |
|
viewDisplay: false, |
|
dicUrl: '/api/blade-system/dict-biz/child-list?current=1&size=100&parentId=1846802246527463425', |
|
props: { |
|
label: "dictValue", |
|
value: "dictValue", |
|
}, |
|
}, |
|
{ |
|
label: "供应商", |
|
labelWidth: 120, |
|
prop: "supplier", |
|
overHidden: true, |
|
search: true, |
|
}, |
|
{ |
|
label: "品牌", |
|
labelWidth: 120, |
|
prop: "brand", |
|
overHidden: true, |
|
search: true, |
|
}, |
|
{ |
|
label: "生产时间", |
|
labelWidth: 120, |
|
prop: "produceTime", |
|
slot: true, |
|
}, |
|
{ |
|
label: "设备状态", |
|
labelWidth: 120, |
|
prop: "status", |
|
slot: true, |
|
formslot: true, |
|
}, |
|
{ |
|
label: "运行状态", |
|
labelWidth: 120, |
|
prop: "runStatus", |
|
slot: true, |
|
formslot: true, |
|
search: true, |
|
type: "select", |
|
dicData:[ |
|
{ |
|
label: "运行中", |
|
value: "1", |
|
}, |
|
{ |
|
label: "关机", |
|
value: "0", |
|
}, |
|
{ |
|
label: "报警中", |
|
value: "2", |
|
} |
|
] |
|
}, |
|
{ |
|
label: "附件", |
|
labelWidth: 120, |
|
prop: "attachName", |
|
overHidden: true, |
|
slot: true, |
|
}, |
|
], |
|
}, |
|
importVisible: false, |
|
treeOptions: [], |
|
data: [], |
|
page: { |
|
pageSize: 10, |
|
currentPage: 1, |
|
total: 0, |
|
}, |
|
dialogTitle: '设备新增', |
|
dialogVisible: false, |
|
addForm: { |
|
type: '', |
|
position: { node: undefined, data: {} } |
|
}, |
|
addRules: { |
|
name: { required: true, message: '请输入设备名称', trigger: 'blur' }, |
|
type: { required: true, message: '请选择设备类型', trigger: 'blur' }, |
|
}, |
|
typeList: [], |
|
fileList: [], |
|
imgList: [], |
|
requestVisible: false, |
|
requestForm: {}, |
|
viewType: '', |
|
periodArr: [], |
|
labProps: { |
|
lazy: true, |
|
lazyLoad(node, resolve) { |
|
const { level, value } = node; |
|
if (level == 0) { |
|
getDeepData({ parentId: 0 }).then(res => { |
|
let firstNode = [] |
|
res.data.data.map(item => { |
|
firstNode.push({ |
|
value: item.id, |
|
label: item.fullName, |
|
leaf: level >= 2 |
|
}) |
|
}) |
|
resolve(firstNode); |
|
}) |
|
} else { |
|
getDeepData({ parentId: value }).then(res => { |
|
let otherNode = [] |
|
res.data.data.map(item => { |
|
otherNode.push({ |
|
value: item.id, |
|
label: item.fullName, |
|
leaf: level >= 2 |
|
}) |
|
}) |
|
resolve(otherNode); |
|
}) |
|
} |
|
} |
|
}, |
|
excelForm: {}, |
|
excelOption: { |
|
submitBtn: false, |
|
emptyBtn: false, |
|
column: [ |
|
{ |
|
label: '模板上传', |
|
prop: 'excelFile', |
|
type: 'upload', |
|
drag: true, |
|
loadText: '模板上传中,请稍等', |
|
span: 24, |
|
propsHttp: { |
|
res: 'data' |
|
}, |
|
tip: '请上传 .xls,.xlsx 标准格式文件', |
|
action: "/api/device/import-device?isCovered=0" |
|
}, |
|
{ |
|
label: '模板下载', |
|
prop: 'excelTemplate', |
|
formslot: true, |
|
span: 24, |
|
} |
|
] |
|
}, |
|
role_id:'',//角色id |
|
} |
|
}, |
|
computed: { |
|
...mapGetters(["userInfo", "permission"]), |
|
}, |
|
mounted() { |
|
this.role_id = this.userInfo.role_id |
|
getChildList(1, 100, '1846792623628001282').then(res => { |
|
this.treeOptions = res.data.data |
|
}) |
|
getChildList(1, 100, '1846802246527463425').then(res => { |
|
this.typeList = res.data.data |
|
}) |
|
getChildList(1, 100, '1858710780677984257').then(res => { |
|
this.periodArr = res.data.data |
|
}) |
|
}, |
|
methods: { |
|
// 巡检内容修改 |
|
changeContent(val) { |
|
let arr = val.split(';') |
|
if (this.tableData.length != 0) { |
|
let arr1 = JSON.parse(JSON.stringify(this.tableData)) |
|
if (val == '' && this.addForm.requirement == '') { |
|
arr1 = [] |
|
} else { |
|
arr.map((item, index) => { |
|
// if(item != ''){ |
|
arr1[index] = { |
|
...arr1[index], |
|
checkContent: item, |
|
period: arr1[index] ? arr1[index].period : this.addForm.period, |
|
startTime: arr1[index] ? arr1[index].startTime : this.addForm.startTime |
|
} |
|
// } |
|
}) |
|
} |
|
this.tableData = arr1 |
|
} else { |
|
let arr1 = [] |
|
arr.map(item => { |
|
if (item != '') { |
|
arr1.push({ |
|
checkContent: item |
|
}) |
|
} |
|
}) |
|
this.tableData = arr1 |
|
} |
|
this.$forceUpdate() |
|
}, |
|
// 工艺要求修改 |
|
changeRequire(val) { |
|
let arr = val.split(';') |
|
if (this.tableData.length != 0) { |
|
let arr1 = JSON.parse(JSON.stringify(this.tableData)) |
|
arr.map((item, index) => { |
|
if (item != '') { |
|
arr1[index] = { |
|
...arr1[index], |
|
craft: item, |
|
period: arr1[index] ? arr1[index].period : this.addForm.period, |
|
startTime: arr1[index] ? arr1[index].startTime : this.addForm.startTime |
|
} |
|
} |
|
}) |
|
this.tableData = arr1 |
|
} else { |
|
let arr1 = [] |
|
arr.map(item => { |
|
if (item != '') { |
|
arr1.push({ |
|
craft: item |
|
}) |
|
} |
|
}) |
|
this.tableData = arr1 |
|
} |
|
this.$forceUpdate() |
|
}, |
|
// 巡检周期修改 |
|
changeCycle(val) { |
|
if (this.tableData.length != 0) { |
|
this.tableData.map(item => { |
|
item.period = val |
|
}) |
|
} |
|
}, |
|
// 巡检开始时间改变 |
|
changeTime(val) { |
|
if (this.tableData.length != 0) { |
|
this.tableData.map(item => { |
|
item.startTime = val |
|
}) |
|
} |
|
}, |
|
beforeOpen(done, type) { |
|
done(); |
|
}, |
|
beforeClose(done) { |
|
done(); |
|
}, |
|
searchReset(params, done) { |
|
this.query = params; |
|
this.onLoad(this.page); |
|
}, |
|
searchChange(params, done) { |
|
this.query = params; |
|
this.page.currentPage = 1; |
|
this.onLoad(this.page, params); |
|
done(); |
|
}, |
|
currentChange(currentPage) { |
|
this.page.currentPage = currentPage; |
|
this.onLoad() |
|
}, |
|
sizeChange(pageSize){ |
|
this.page.pageSize = pageSize; |
|
this.onLoad() |
|
}, |
|
selectionChange(list) { |
|
this.selectionList = list |
|
}, |
|
addOperation(val) { |
|
if (val && val.code) { |
|
this.requestForm = { |
|
deviceId: val.id |
|
} |
|
this.requestVisible = true |
|
} else { |
|
this.selectionList.map(item => { |
|
|
|
}) |
|
this.requestVisible = true |
|
} |
|
}, |
|
// 生成二维码 |
|
handleQrcode(row) { |
|
qrcode({ id: row.id }).then(res => { |
|
if (res.data.code == 200) { |
|
this.$message.success('二维码已生成') |
|
this.onLoad() |
|
} |
|
}) |
|
}, |
|
// 查看二维码 |
|
lookQrcode(row) { |
|
this.qrcodeUrl = row.qrcode |
|
setTimeout(() => { |
|
// this.$refs.listPrint.print(); |
|
const style = '@page {margin:0 10mm};' //打印时去掉眉页眉尾 |
|
printJS({ |
|
printable: 'qrcodePrint', // 标签元素id |
|
type: 'html', |
|
header: '', |
|
targetStyles: ['*'], |
|
scanStyles: true, //打印必须加上,不然页面上的css样式无效 |
|
style |
|
}); |
|
}, 200) |
|
}, |
|
closeRequest() { |
|
this.requestVisible = false |
|
}, |
|
// 点击新增按钮 |
|
handleAdd() { |
|
this.dialogTitle = '设备新增' |
|
this.addForm = { position: { node: undefined, data: {} } } |
|
this.viewType = 'add' |
|
this.tableData = [] |
|
this.fileList = [] |
|
this.imgList = [] |
|
this.dialogVisible = true |
|
// this.$refs.childTree.resetNode() |
|
}, |
|
// 点击查看按钮 |
|
handleView(row) { |
|
this.imgList = [] |
|
this.tableData = [] |
|
getDetail({ id: row.id }).then(res => { |
|
this.viewType = 'view' |
|
this.addForm = res.data.data |
|
this.addForm.position = { node: res.data.data.position, data: {} } |
|
this.addForm.lab = res.data.data.limsId != -1 && res.data.data.floorId != -1 && res.data.data.roomId != -1 ? [res.data.data.limsId, res.data.data.floorId, res.data.data.roomId] : [] |
|
res.data.data.attaches.map(item => { |
|
this.imgList.push({ |
|
name: item.name, |
|
url: item.link |
|
}) |
|
}) |
|
res.data.data.maintenances.map(item => { |
|
this.tableData.push({ ...item, period: item.period + '' }) |
|
}) |
|
this.addForm.xjcontent = this.tableData.length > 0 ? this.tableData.map(item => item.checkContent).join(';') : '' |
|
this.addForm.requirement = this.tableData.length > 0 ? this.tableData.map(item => item.craft).join(';') : '' |
|
this.addForm.cycle = this.tableData.length > 0 ? this.tableData.find(item => item.period).period : '' |
|
this.addForm.startTime = this.tableData.length > 0 ? this.tableData.find(item => item.startTime).startTime : '' |
|
this.dialogTitle = '设备查看' |
|
this.dialogVisible = true |
|
this.addForm.isMaintain = res.data.data.isMaintain//是否在保 |
|
}) |
|
}, |
|
handleImport() { |
|
this.importVisible = true |
|
}, |
|
handleExport() { |
|
this.$confirm("是否导出设备数据?", "提示", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}).then(() => { |
|
NProgress.start(); |
|
exportBlob(`/api/device/export-device`).then(res => { |
|
downloadXls(res.data, `设备数据表${dateNow()}.xlsx`); |
|
NProgress.done(); |
|
}) |
|
}); |
|
}, |
|
handleTemplate() { |
|
importFile().then(res => { |
|
downloadXls(res.data, "设备数据模板.xlsx"); |
|
}) |
|
}, |
|
// 点击编辑按钮 |
|
handleEdit(row) { |
|
this.fileList = [] |
|
this.imgList = [] |
|
this.tableData = [] |
|
getDetail({ id: row.id }).then(res => { |
|
this.viewType = 'edit' |
|
this.addForm = res.data.data |
|
this.addForm.position = { node: res.data.data.position, data: {} } |
|
this.addForm.lab = res.data.data.limsId != -1 && res.data.data.floorId != -1 && res.data.data.roomId != -1 ? [res.data.data.limsId, res.data.data.floorId, res.data.data.roomId] : [] |
|
res.data.data.attaches.map(item => { |
|
this.imgList.push({ |
|
name: item.name, |
|
url: item.link |
|
}) |
|
this.fileList.push({ |
|
name: item.name, |
|
link: item.link |
|
}) |
|
}) |
|
res.data.data.maintenances.map(item => { |
|
this.tableData.push({ ...item, period: item.period + '' }) |
|
}) |
|
this.addForm.xjcontent = |
|
this.addForm = { |
|
...this.addForm, |
|
xjcontent: this.tableData.length > 0 ? this.tableData.map(item => item.checkContent).join(';') : '', |
|
requirement: this.tableData.length > 0 ? this.tableData.map(item => item.craft).join(';') : '', |
|
cycle: this.tableData.length > 0 ? this.tableData.find(item => item.period).period : '', |
|
startTime: this.tableData.length > 0 ? this.tableData.find(item => item.startTime).startTime : '' |
|
} |
|
this.dialogTitle = '设备编辑' |
|
this.dialogVisible = true |
|
}) |
|
}, |
|
// 点击删除按钮 |
|
handleDelete(row) { |
|
this.$confirm('请确认是否删除该设备?', '提示', { |
|
confirmButtonText: '确定', |
|
cancelButtonText: '取消', |
|
type: 'warning' |
|
}).then(() => { |
|
deleteDevice(row.id).then(res => { |
|
if (res.data.code == 200) { |
|
this.onLoad() |
|
this.$message({ |
|
type: 'success', |
|
message: '删除成功!' |
|
}); |
|
} |
|
}) |
|
}).catch(() => { |
|
}); |
|
}, |
|
// 点击新增弹窗关闭按钮 |
|
handleClose() { |
|
this.dialogVisible = false |
|
this.tableData = [] |
|
this.$refs['form'].resetFields() |
|
this.addForm = { position: { node: undefined, data: {} } } |
|
}, |
|
// 点击新增弹窗保存按钮 |
|
handleSave() { |
|
this.$refs['form'].validate((valid) => { |
|
if (valid) { |
|
if (this.fileList.length == 0) { |
|
this.$message.error('请至少上传一个附件') |
|
} else { |
|
console.log('111111111111111', this.addForm) |
|
let query = { |
|
name: this.addForm.name, |
|
model: this.addForm.model, |
|
type: this.addForm.type, |
|
position: this.addForm.position.node, |
|
supplier: this.addForm.supplier, |
|
produceTime: this.addForm.produceTime, |
|
attachName: this.addForm.attachName, |
|
runStatus: 1, |
|
attaches: this.fileList |
|
} |
|
addDevice(query).then(res => { |
|
console.log('res==============>', res) |
|
}) |
|
// this.dialogVisible = false |
|
} |
|
} |
|
}) |
|
}, |
|
handleConfirm() { |
|
this.$refs['form'].validate((valid) => { |
|
if (valid) { |
|
let arr = [] |
|
this.fileList.map(item => { |
|
arr.push({ |
|
name: item.name, link: item.link |
|
}) |
|
}) |
|
let query = { |
|
id: this.viewType == 'edit' ? this.addForm.id : null, |
|
name: this.addForm.name ? this.addForm.name : null, |
|
model: this.addForm.model ? this.addForm.model : null, |
|
type: this.addForm.type ? this.addForm.type : null, |
|
position: this.addForm.position.node ? this.addForm.position.node : null, |
|
supplier: this.addForm.supplier ? this.addForm.supplier : null, |
|
produceTime: this.addForm.produceTime ? this.addForm.produceTime.length <= 10 ? this.addForm.produceTime + ' 00:00:00' : this.addForm.produceTime : null, |
|
attachName: this.addForm.attachName ? this.addForm.attachName : null, |
|
runStatus: 1, |
|
attaches: arr, |
|
maintenances: this.tableData, |
|
limsId: this.addForm.lab[0], //实验室id |
|
floorId: this.addForm.lab[1], //楼层id |
|
roomId: this.addForm.lab[2], //房间id |
|
brand:this.addForm.brand,//品牌 |
|
} |
|
if (this.viewType == 'add') { |
|
addDevice(query).then(res => { |
|
if (res.data.code == 200) { |
|
this.$message.success('新增成功!') |
|
this.dialogVisible = false |
|
this.onLoad() |
|
} |
|
}) |
|
} else if (this.viewType == 'edit') { |
|
editDevice(query).then(res => { |
|
if (res.data.code == 200) { |
|
this.$message.success('修改成功!') |
|
this.dialogVisible = false |
|
this.onLoad() |
|
} |
|
}) |
|
} |
|
} |
|
}) |
|
}, |
|
// 附件上传成功 |
|
handleSuccess(response, file, fileList) { |
|
this.fileList.push({ name: response.data.originalName, link: response.data.link }) |
|
}, |
|
// 附件删除 |
|
handleRemove(file, fileList) { |
|
this.imgList = [] |
|
this.fileList = [] |
|
fileList.map(item => { |
|
this.fileList.push({ name: item.name, link: item.response ? item.response.data.link : item.url }) |
|
this.imgList.push({ name: item.name, url: item.response ? item.response.data.link : item.url }) |
|
}) |
|
}, |
|
onLoad(page, params = {}) { |
|
console.log(1111111111,this.searchForm) |
|
let query = { |
|
name: this.searchForm.name ? this.searchForm.name : '', |
|
position: this.searchForm.position ? this.searchForm.position : '', |
|
type: this.searchForm.type ? this.searchForm.type : '', |
|
current: this.page.currentPage, |
|
runStatus:this.searchForm.runStatus?this.searchForm.runStatus:'',//运行状态 |
|
supplier:this.searchForm.supplier?this.searchForm.supplier:'',//供应商 |
|
brand:this.searchForm.brand?this.searchForm.brand:'',//品牌 |
|
size: this.page.pageSize, |
|
} |
|
getDeviceList(query).then(res => { |
|
this.data = res.data.data.records |
|
this.page.total = res.data.data.total |
|
this.loading = false |
|
}) |
|
}, |
|
} |
|
} |
|
</script> |
|
|
|
<style lang="scss"> |
|
.el-dialog { |
|
.el-dialog__title { |
|
font-size: 22px; |
|
color: rgb(16, 16, 16); |
|
font-weight: 550; |
|
} |
|
|
|
.el-dialog__headerbtn { |
|
font-size: 20px; |
|
} |
|
} |
|
</style>
|
|
|