189 lines
4.3 KiB
Vue
189 lines
4.3 KiB
Vue
<style>
|
||
.example-body {
|
||
padding: 12px;
|
||
background-color: #FFFFFF;
|
||
|
||
}
|
||
|
||
.result-box {
|
||
text-align: center;
|
||
padding: 20px 0px;
|
||
font-size: 16px;
|
||
}
|
||
|
||
// 搜索框
|
||
.search-bar {
|
||
width: 100%;
|
||
height: 100rpx;
|
||
margin-top: 2%;
|
||
}
|
||
|
||
.search-bar-box {
|
||
display: flex;
|
||
margin: 0 auto;
|
||
width: 620rpx;
|
||
height: 74rpx;
|
||
border: 5rpx solid #00a8cc;
|
||
border-radius: 50rpx;
|
||
}
|
||
|
||
.search-text {
|
||
width: 100%;
|
||
margin-top: 10rpx;
|
||
margin-left: 20rpx;
|
||
font-size: 30rpx;
|
||
color: #7f7f81;
|
||
}
|
||
|
||
.search-btn {
|
||
background-color: #00a8cc;
|
||
/* Green */
|
||
color: white;
|
||
text-align: center;
|
||
display: inline-block;
|
||
font-size: 35rpx;
|
||
width: 240rpx;
|
||
height: 70rpx;
|
||
line-height: 65rpx;
|
||
border-radius: 30rpx;
|
||
letter-spacing: 3rpx;
|
||
}
|
||
</style>
|
||
<template>
|
||
<view>
|
||
<uni-easyinput suffixIcon="scan" placeholder="请输入设备编码" @iconClick="scanBar" v-model="equipmentCode" type="text"
|
||
@confirm="scanBarCode" />
|
||
|
||
<selectLay :zindex="1211" :options="equipmentbrandArr" :value="equipmentbrand" placeholder="请选择设备厂家" @selectitem="equipmentbrandFuc"></selectLay>
|
||
|
||
|
||
<button type="primary" size="mini" @click="reset"
|
||
style="margin-top: 5px;text-align: center;display: block;width: 30%;">重置</button>
|
||
|
||
|
||
|
||
<view class="cu-card article ">
|
||
<view class="cu-item shadow borderBottom" v-for="(item,index) in list" :key="index">
|
||
<view class="title">
|
||
<view class="text-cut">设备编码 : {{item.equipmentCode}}</view>
|
||
<!-- <view>
|
||
<u-button type="primary" size="mini" @click="detail(item)" style="float: right;">查看任务</u-button>
|
||
</view> -->
|
||
</view>
|
||
<view class="content">
|
||
<view class="desc">
|
||
<view class="text-content">
|
||
<view>设备名称 : {{item.equipmentTitle}}</view>
|
||
<view>设备厂家 : {{item.equipmentBrand}}</view>
|
||
<view>设备所属单位 : {{item.belongDept}}</view>
|
||
<view>数量 : {{item.amount}}</view>
|
||
<view>开机状态:
|
||
<u-switch v-model="item.openStatus" activeColor="#5AC725" :inactiveValue="'0'"
|
||
:activeValue="'1'" style="display: inline-flex;"
|
||
@change="switchChange(item)"></u-switch>
|
||
</view>
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
listEquipment,
|
||
updateEquipment
|
||
} from "@/api/tpm/index.js";
|
||
import {
|
||
listEqpClass
|
||
} from "@/api/basic/equipment.js"
|
||
import selectLay from "@/components/select-lay/select-lay.vue"
|
||
export default {
|
||
mounted() {
|
||
this.getList()
|
||
},
|
||
components: {
|
||
selectLay
|
||
},
|
||
data() {
|
||
return {
|
||
list: [],
|
||
originalList: [], // 存储原始的设备列表数据
|
||
equipmentCode: null,
|
||
equipmentbrand: "",
|
||
equipmentbrandArr: [],
|
||
isAllBrandsSelected: false,
|
||
}
|
||
},
|
||
created() {
|
||
listEqpClass().then(res => {
|
||
this.equipmentbrandArr = res.rows.map(item=>{
|
||
|
||
return {
|
||
value:item.equipmentBrand,
|
||
label:item.equipmentBrand
|
||
}
|
||
})
|
||
})
|
||
},
|
||
methods: {
|
||
equipmentbrandFuc(index,items) {
|
||
this.equipmentbrand = items.value
|
||
if (this.equipmentbrand == null) {
|
||
// 如果选择了"所有品牌",则展示所有设备
|
||
this.list = this.originalList;
|
||
} else {
|
||
// 根据选中的品牌筛选设备
|
||
this.list = this.originalList.filter(item => {
|
||
return item.equipmentBrand === this.equipmentbrand;
|
||
});
|
||
}
|
||
},
|
||
reset() {
|
||
this.equipmentCode = null;
|
||
this.equipmentbrand = "";
|
||
this.isAllBrandsSelected = true; // 重置品牌选择
|
||
this.getList(); // 重新获取原始列表
|
||
},
|
||
getList() {
|
||
listEquipment().then(response => {
|
||
this.originalList = response.rows.map(item => {
|
||
if (item.openStatus == null) item.openStatus = '0';
|
||
return item;
|
||
});
|
||
this.list = this.originalList;
|
||
});
|
||
},
|
||
scanBarCode() {
|
||
if (this.equipmentCode) {
|
||
let obj = {
|
||
equipmentCode: this.equipmentCode
|
||
}
|
||
listEquipment(obj).then(response => {
|
||
this.list = response.rows;
|
||
});
|
||
}
|
||
},
|
||
scanBar() {
|
||
const _this = this;
|
||
uni.scanCode({
|
||
scanType: ['qrCode', 'barCode'],
|
||
success: function(res) {
|
||
_this.equipmentCode = res.result;
|
||
_this.scanBarCode();
|
||
}
|
||
});
|
||
},
|
||
detail() {
|
||
|
||
},
|
||
switchChange(item) {
|
||
updateEquipment(item).then((response) => {
|
||
this.$modal.msgSuccess("开关状态修改成功!");
|
||
});
|
||
}
|
||
}
|
||
}
|
||
</script> |