| | |
| | | <div class="table-header"> |
| | | <div class="search-bar"> |
| | | <el-row :gutter="20"> |
| | | <el-col :span="15"> |
| | | <el-col :span="8"> |
| | | <el-form ref="form" :inline="true" :model="searchData"> |
| | | <el-form-item> |
| | | <el-input v-model="searchData.keyword" placeholder="请输入编号/设备名称/型号规格"> |
| | |
| | | <el-form-item> |
| | | <el-button type="primary" @click="filterTableData">查询</el-button> |
| | | <el-button type="primary" plain @click="resetBtn">重置</el-button> |
| | | <!-- <el-button type="text">高级搜索<i class="el-icon-arrow-down el-icon--right" /></el-button> --> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-col> |
| | | <el-col :span="9"> |
| | | <el-col :span="16"> |
| | | <el-radio-group v-model="radioValue" @change="getConditionTable"> |
| | | <!-- <el-radio-button label="0">全部</el-radio-button> --> |
| | | <el-radio-button v-for="item in conditionsOptions" :key="item.value" :label="item.value"> |
| | | {{ item.label }} |
| | | </el-radio-button> |
| | |
| | | </div> |
| | | <el-tabs v-model="activeTabsName"> |
| | | <el-tab-pane label="设备码点" name="codePoints"> |
| | | <el-button v-show="!codePointesTableStatus" :style="{ marginBottom: '18px' }" |
| | | @click="addCodePoints">新增设备码点</el-button> |
| | | <div v-show="codePointesTableStatus" :style="{ marginBottom: '18px' }" class="btns"> |
| | | <div :style="{ marginBottom: '18px' }" class="btns"> |
| | | <el-button @click="addNewCodePoints">添加</el-button> |
| | | <el-button @click="saveCodePoins">保存</el-button> |
| | | <el-button v-show="codePointesTableStatus" @click="saveCodePoins">保存</el-button> |
| | | <el-button @click="closeCodePoins">取消</el-button> |
| | | </div> |
| | | |
| | |
| | | <el-table-column type="index" label="序号" min-width="90" /> |
| | | <el-table-column prop="equipmentPoint" label="码点编码" min-width="150"> |
| | | <template slot-scope="scope"> |
| | | <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPoint }}</span> |
| | | <el-input v-show="codePointesTableStatus" v-model="scope.row.equipmentPoint" /> |
| | | <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.equipmentPoint" /> |
| | | <span v-else>{{ scope.row.equipmentPoint }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column prop="equipmentPointName" label="码点名称" min-width="150"> |
| | | <template slot-scope="scope"> |
| | | <span v-show="!codePointesTableStatus">{{ scope.row.equipmentPointName }}</span> |
| | | <el-input v-show="codePointesTableStatus" v-model="scope.row.equipmentPointName" /> |
| | | <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.equipmentPointName" /> |
| | | <span v-else>{{ scope.row.equipmentPointName }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="unit" label="单位" min-width="150"> |
| | | <template slot-scope="scope"> |
| | | <span v-show="!codePointesTableStatus">{{ scope.row.unit }}</span> |
| | | <el-input v-show="codePointesTableStatus" v-model="scope.row.unit" /> |
| | | <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.unit" /> |
| | | <span v-else>{{ scope.row.unit }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <!-- <el-table-column prop="name" label="更新人" min-width="100" /> |
| | | <el-table-column prop="updateTime" label="更新日期" min-width="120" /> --> |
| | | <el-table-column prop="descriptiveness" label="描述" min-width="200"> |
| | | <template slot-scope="scope"> |
| | | <span v-show="!codePointesTableStatus">{{ scope.row.descriptiveness }}</span> |
| | | <el-input v-show="codePointesTableStatus" v-model="scope.row.descriptiveness" /> |
| | | <el-input v-if="codePointesTableStatus && scope.row.isInput" v-model="scope.row.descriptiveness" /> |
| | | <span v-else>{{ scope.row.descriptiveness }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | |
| | |
| | | <el-col :span="11"> |
| | | <el-form-item label="状态:" prop="conditions" |
| | | :rules="[{ required: true, message: '请选择仪器设备状态', trigger: 'blur' }]" label-width="80"> |
| | | <el-select v-model="equipmentform.conditions" clearable filterable :allow-create="true" |
| | | <el-select v-model="equipmentform.conditions" clearable :allow-create="true" |
| | | placeholder="请选择仪器设备状态" style="width:100%"> |
| | | <el-option v-for="item in conditionsOptions" :key="item.value" :label="item.label" |
| | | :value="item.value" /> |
| | |
| | | </el-col> |
| | | <el-col :span="11"> |
| | | <el-form-item label="保管人:" label-width="80"> |
| | | <el-select v-model="equipmentform.userId" clearable filterable :allow-create="true" placeholder="请选择保管人" |
| | | <el-select v-model="equipmentform.userId" clearable :allow-create="true" placeholder="请选择保管人" |
| | | style="width:100%"> |
| | | <el-option v-for="item in userOpetions" :key="item.id" :label="item.label" :value="item.value" /> |
| | | </el-select> |
| | |
| | | // 码点表格 |
| | | codePointsTable: [ |
| | | { |
| | | 'isInput':false, |
| | | 'unit': '', |
| | | 'descriptiveness': '', |
| | | 'equipmentPoint': '', |
| | |
| | | }, |
| | | // 显示仪器详情 |
| | | async openDetail(row) { |
| | | // console.log(row) |
| | | this.detailDrawer = true |
| | | const { data } = await getInstrumentDetail({ InstrumentId: row.id }) |
| | | this.equipmentDetail = data |
| | |
| | | addCodePoints() { |
| | | // 添加新码点,清空原数组 |
| | | this.codePointesTableStatus = true |
| | | this.codePointsTable = undefined |
| | | }, |
| | | // 新增设备码点 |
| | | addNewCodePoints() { |
| | | // |
| | | if (!this.codePointsTable) { |
| | | this.codePointsTable = [] |
| | | } |
| | | console.log(this.equipmentDetail.id); |
| | | this.codePointesTableStatus = true; |
| | | const newObj = {} |
| | | newObj.isInput = true, |
| | | newObj.name = '' // 当前用户的名称 |
| | | newObj.updateTime = '' // 获取当前时间 |
| | | newObj.equipmentPoint = '' |
| | |
| | | newObj.descriptiveness = '' |
| | | newObj.unit = '' |
| | | newObj.instrumentId = this.equipmentDetail.id |
| | | this.codePointsTable.push(newObj) |
| | | this.codePointsTable.unshift(newObj) |
| | | }, |
| | | // 保存提交新增设备码点 |
| | | async saveCodePoins() { |
| | | console.log(this.codePointsTable) |
| | | if (!this.codePointsTable) { |
| | | this.codePointsTable = [] |
| | | if (this.codePointsTable.length === 0) { |
| | | return this.$message.error('请点击添加按钮添加数据') |
| | | } |
| | | if (this.codePointsTable.length === 0) return this.$message.error('请点击添加按钮添加数据') |
| | | try { |
| | | for (const item of this.codePointsTable) { |
| | | const { code, data, message } = await addEquipmentPoint(item) |
| | | console.log(data) |
| | | if (code !== 200) throw new Error(message) |
| | | this.$message.success('添加成功') |
| | | } |
| | | } catch (error) { |
| | | let data = this.codePointsTable.filter(item => { |
| | | return item.instrumentId != null; |
| | | }) |
| | | await addEquipmentPoint(data).then(()=>{ |
| | | this.$message.success('添加成功') |
| | | }).catch(error=>{ |
| | | this.$message.error(error.message) |
| | | } |
| | | }) |
| | | await this.closeCodePoins() |
| | | }, |
| | | // 取消新增设备码点 |
| | |
| | | }, |
| | | // 点击新增仪器设备或当存在仪器详情时是修改仪器设备信息 |
| | | async addNewEquipment() { |
| | | let v = this.submitForm('addNewEquipment') |
| | | if (!v) { |
| | | return |
| | | } |
| | | if (Array.isArray(this.equipmentform.classifyId)) { |
| | | this.equipmentform.classifyId = this.equipmentform.classifyId.pop() |
| | | } |
| | | if (!this.equipmentDetail.id) { |
| | | // 格式化日期 |
| | | this.equipmentform.arrivalDate = parseTime(this.equipmentform.arrivalDate, '{y}-{m}-{d}') |
| | | this.equipmentform.acceptanceDate = parseTime(this.equipmentform.acceptanceDate, '{y}-{m}-{d}') |
| | | // this.equipmentform.termValidity = parseTime(this.equipmentform?.termValidity, '{y}-{m}-{d}') |
| | | try { |
| | | const res = await addInstrument(this.equipmentform) |
| | | console.log(res) |
| | | } catch (error) { |
| | | this.$message.error('添加失败') |
| | | this.$refs["addNewEquipment"].validate(async(valid)=>{ |
| | | if(valid){ |
| | | if (Array.isArray(this.equipmentform.classifyId)) { |
| | | this.equipmentform.classifyId = this.equipmentform.classifyId.pop() |
| | | } |
| | | if (!this.equipmentDetail.id) { |
| | | // 格式化日期 |
| | | this.equipmentform.arrivalDate = parseTime(this.equipmentform.arrivalDate, '{y}-{m}-{d}') |
| | | this.equipmentform.acceptanceDate = parseTime(this.equipmentform.acceptanceDate, '{y}-{m}-{d}') |
| | | // this.equipmentform.termValidity = parseTime(this.equipmentform?.termValidity, '{y}-{m}-{d}') |
| | | await addInstrument(this.equipmentform).then(()=>{ |
| | | this.$message.success('添加成功') |
| | | }).catch(error=>{ |
| | | this.$message.error(error.message); |
| | | }) |
| | | let d = this.nodeclicked; |
| | | this.nodeClickHandler(d); |
| | | this.addDrawerVisible = false |
| | | this.equipmentform = {} |
| | | return |
| | | } |
| | | console.log('修改仪器参数', this.equipmentform) |
| | | await changeInstrument(this.equipmentform).then(()=>{ |
| | | this.$message.success('修改成功') |
| | | let d = this.nodeclicked; |
| | | this.nodeClickHandler(d); |
| | | this.addDrawerVisible = false |
| | | this.detailDrawer = false |
| | | }).catch(error=>{ |
| | | this.$message.error(error.message); |
| | | }) |
| | | } |
| | | this.$message.success('添加成功') |
| | | let d = this.nodeclicked; |
| | | this.nodeClickHandler(d); |
| | | this.addDrawerVisible = false |
| | | this.equipmentform = {} |
| | | return |
| | | } |
| | | console.log('修改仪器参数', this.equipmentform) |
| | | try { |
| | | const res = await changeInstrument(this.equipmentform) |
| | | this.$message.success('修改成功') |
| | | let d = this.nodeclicked; |
| | | this.nodeClickHandler(d); |
| | | this.addDrawerVisible = false |
| | | this.detailDrawer = false |
| | | } catch (error) { |
| | | this.$message.error('添加失败') |
| | | } |
| | | }); |
| | | }, |
| | | cancelAddEq() { |
| | | this.resetForm('addDrawer') |
| | |
| | | }, |
| | | resetBtn() { |
| | | this.searchData.keyword = '' |
| | | this.radioValue = 0; |
| | | this.isOut = false; |
| | | this.equipmentTable = this.oldtableData |
| | | }, |
| | | getConditionTable() { |
| | |
| | | display: flex; |
| | | justify-content: space-between; |
| | | padding: 15px 24px 12px 24px; |
| | | |
| | | .serve-btn{ |
| | | position: relative; |
| | | left: 92%; |
| | | } |
| | | .search-bar { |
| | | .el-radio-button.is-active { |
| | | color: #409EFF !important; |