123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- <!--识别器管理-->
- <template>
- <div class="app-container certification">
- <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" class="form-box">
- <el-form-item label="关键字" prop="name">
- <el-input
- v-model="queryParams.searchValue"
- placeholder="设备编号/所属实验室"
- clearable
- maxLength="30"
- size="small"
- />
- </el-form-item>
- <el-form-item>
- <p class="inquire-button-one" @click="handleQuery">查询</p>
- <p class="reset-button-one" @click="resetQuery">重置</p>
- </el-form-item>
- <el-form-item style="float: right;">
- <el-col :span="1.5">
- <p class="add-button-one-120"
- @click="handleAdd"
- v-hasPermi="['laboratory:hardware7:add']"
- ><i class="el-icon-plus"></i>新增</p>
- </el-col>
- </el-form-item>
- </el-form>
- <el-table border v-loading="loading" :data="sensorList">
- <el-table-column label="设备名称" align="left" prop="deviceName" show-overflow-tooltip/>
- <el-table-column label="设备编号" align="left" prop="hardwareNum" show-overflow-tooltip/>
- <el-table-column label="学院" align="center" prop="deptName" width="200" show-overflow-tooltip/>
- <el-table-column label="位置" align="center" prop="position" width="250" show-overflow-tooltip/>
- <el-table-column label="设备状态" align="center" prop="status" width="120">
- <template slot-scope="scope">
- <el-switch
- v-hasPermi="['laboratory:hardware7:changeStatus']"
- class="switch"
- @change="switchChange(scope.row)"
- v-model="scope.row.onOff+''"
- active-value="1"
- inactive-value="0"
- active-text="开"
- inactive-text="关"
- >
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" align="center" prop="createTime" width="200" show-overflow-tooltip/>
- <el-table-column label="创建人" align="center" prop="createBy" width="200" show-overflow-tooltip/>
- <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="150">
- <template slot-scope="scope">
- <div class="button-box">
- <p class="table-min-button"
- @click="handleUpdate(scope.row)"
- style="margin-right:20px;"
- v-hasPermiAnd="['laboratory:hardware7:query','laboratory:hardware7:edit']"
- >修改</p>
- <p class="table-min-button"
- @click="handleDelete(scope.row)"
- v-hasPermi="['laboratory:hardware7:remove']"
- >删除</p>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- layout="total, prev, pager, next, sizes, jumper"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 添加或修改传感器对话框 -->
- <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body class="recognizer recognizer-manage add-hardware-dialog-box">
- <el-form ref="form" :model="form" :rules="rules" :inline="true" label-width="130px">
- <el-form-item label="设备名称" prop="deviceName">
- <el-input v-model="form.deviceName" maxlength="30" placeholder="请输入识别器编号" style="width: 400px"/>
- </el-form-item>
- <el-form-item label="识别器编号" prop="hardwareNum">
- <el-input v-model="form.hardwareNum" maxlength="30" placeholder="请输入识别器编号" style="width: 400px"/>
- </el-form-item>
- <el-form-item label="所属实验室" prop="subjectId">
- <el-select v-model="form.subjectId" placeholder="请选择实验室" style="width: 400px">
- <el-option
- v-for="item in subjectAddOptions"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <div class="form-input-ip-box">
- <el-form-item label="IP地址" label-width="130px" prop="ipAddress" class="form-ip">
- <el-input v-model="form.ipAddress" maxlength="30" placeholder="请输入IP地址"/>
- </el-form-item>
- <el-form-item label="端口" label-width="54px" prop="port" class="form-port">
- <el-input style="width:120px;" maxlength="5" v-model="form.port" placeholder="请输入端口"/>
- </el-form-item>
- </div>
- <el-form-item label="连接方式" prop="manufacturerType">
- <el-select v-model="form.manufacturerType" placeholder="请选择" style="width:400px;" >
- <el-option :label="item.dictLabel" :value="item.dictValue" v-for="(item,index) in materialTypeList" :key="index"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="推送频率" prop="sessionIndex">
- <el-select v-model="form.sessionIndex" placeholder="请选择设备推送频率" style="width:400px;">
- <el-option label="最大" value="0"></el-option>
- <el-option label="中等" value="1"></el-option>
- <el-option label="最小" value="2"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="天线数量" prop="channels">
- <el-select v-model="form.channels" placeholder="请选择信道数量" @change="antennaNumFun()" style="width:400px;">
- <el-option label="1" value="1"></el-option>
- <el-option label="2" value="2"></el-option>
- <el-option label="4" value="4"></el-option>
- <el-option label="8" value="8"></el-option>
- <el-option label="16" value="16"></el-option>
- </el-select>
- </el-form-item>
- <el-row v-for="(item,index) in antennaNum" :key="index">
- <el-col :span="12">
- <el-form-item :label="(index+1)+'号天线感应距离'">
- <el-input-number v-model="uniformPower[index]" maxlength="10" placeholder="请输入设备输出频率" style="width:140px;"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item :label="(index+1)+'号天线检测类型'">
- <el-select v-model="detection[index]" placeholder="请选择检测类型" style="width:140px;">
- <el-option
- v-for="item in detectionArr"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <!-- <el-form-item :label="(index+1)+'号天线感应距离'" v-for="(item,index) in antennaNum" :key="index">-->
- <!-- <el-input-number v-model="uniformPower[index]" placeholder="请输入设备输出频率" />-->
- <!-- </el-form-item>-->
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancel">取 消</el-button>
- <el-button type="primary" @click="submitForm">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { subjectDictList } from "@/api/laboratory/group";
- import Treeselect from "@riophae/vue-treeselect";
- import "@riophae/vue-treeselect/dist/vue-treeselect.css";
- import {
- recognizerAdd,
- recognizerAnew,
- recognizerDelete,
- recognizerList,
- recognizerSwitch,
- supplierStop, RFIDTypeList, recognizerNettyFrid
- } from '@/api/gasManage3_0/gasManage'
- export default {
- name: "Sensor",
- components: { Treeselect },
- data() {
- const ipVerification = (rule, value, callback) => {
- if(!/^((2((5[0-5])|([0-4]\d)))|([0-1]?\d{1,2}))(\.((2((5[0-5])|([0-4]\d)))|([0-1]?\d{1,2}))){3}$/.test(value)) {
- callback(new Error("IP地址错误"));
- } else {
- callback()
- }
- };
- const portVerification = (rule, value, callback) => {
- if(!/^[0-9]+$/.test(value)) {
- callback(new Error("端口号错误"));
- } else {
- callback()
- }
- };
- return {
- // 遮罩层
- loading: true,
- // 总条数
- total: 0,
- // 传感器表格数据
- sensorList: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- subjectAddOptions: [],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize:20,
- searchValue:'',
- deviceType:'7'
- },
- // 表单参数
- form: {
- id:'',
- hardwareNum:'',
- subjectId:'',
- deviceType:'7',
- ipAddress:'',//ip地址
- channels:4,//信道
- sessionIndex:0,//设备推送频率
- uniformPower:'',//设备推送频率
- manufacturerType:null,//连接方式
- },
- materialTypeList:[],
- uniformPower:[20,20,20,20],
- antennaNum:[1,2,3,4],//天线数量
- detection:['0','0','0','0',],//检测类型选择的值
- detectionArr:[],//检测类型数组
- // 表单校验
- rules: {
- deviceName:[
- {required: true, message: '设备名称不能为空', trigger: 'blur'}
- ],
- hardwareNum:[
- {required: true, message: '识别器编号不能为空', trigger: 'blur'}
- ],
- subjectId:[
- {required: true, message: '所属实验室不能为空', trigger: 'blur'}
- ],
- ipAddress:[
- {required: true, message: 'IP地址不能为空', trigger: 'blur'},
- { required: true, validator: ipVerification, trigger: "blur" },
- ],
- port:[
- {required: true, message: '端口不能为空', trigger: 'blur'},
- { required: true, validator: portVerification, trigger: "blur" },
- ],
- manufacturerType:[
- {required: true, message: '请选择连接方式', trigger: 'blur'},
- ],
- sessionIndex:[
- {required: true, message: '请选择推送频率', trigger: 'blur'},
- ],
- channels:[
- {required: true, message: '请选择天线数量', trigger: 'blur'},
- ],
- },
- };
- },
- created() {
- },
- mounted(){
- this.getList();
- this.getSubjectAddDictList();
- this.supplierTypeList();
- this.recognizerNettyFrid();
- },
- methods: {
- //根据选择的天线数量循环距离和检测类型
- antennaNumFun(){
- this.uniformPower=[];
- this.antennaNum=[];
- this.detection=[];
- for(let i=0;i<this.form.channels;i++){
- this.antennaNum.push(i)
- this.uniformPower.push(20)
- this.detection.push('0')
- }
- },
- //供应商类型
- supplierTypeList(){
- let _this=this;
- RFIDTypeList().then( response => {
- let res=response.rows;
- _this.materialTypeList=res;
- });
- },
- //状态
- switchChange(row){
- console.log(row)
- //1上架0下架
- this.$confirm('是否确定'+(row.onOff==1?'关闭':'打开')+'?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.upDownShelf(row.id)
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消'
- });
- });
- },
- //上架下架
- upDownShelf(id){
- recognizerSwitch(id).then( response => {
- this.msgSuccess("修改成功");
- this.getList();
- });
- },
- /** 查询实验室字典列表 */
- getSubjectAddDictList () {
- this.subjectAddOptions = null;
- this.loading = true;
- let params = {};
- subjectDictList(params).then(response => {
- this.subjectAddOptions = response.data;
- this.loading = false;
- });
- },
- /** 查询传感器列表 */
- getList() {
- this.loading = true;
- recognizerList(this.queryParams).then(response => {
- this.sensorList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- //检测类型
- recognizerNettyFrid(){
- let _this=this;
- recognizerNettyFrid().then(response => {
- _this.detectionArr = []
- response.data.forEach(function(item,index) {
- for(let i in item){
- console.log(item[i])
- _this.detectionArr.push({'id':i,'name':item[i]})
- }
- })
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- },
- // 表单重置
- reset() {
- this.form = {
- id: null,
- name: null,
- deviceType:'7',
- hardwareNum: null,
- subjectId: null,
- ipAddress: null,
- port: null,
- manufacturerType:null,
- channels: '4',
- sessionIndex: '0',
- uniformPower: '',
- };
- this.resetForm("form");
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.queryParams.searchValue = '';
- this.handleQuery();
- },
- // 20:10,30:20
- /** 新增按钮操作 */
- handleAdd() {
- this.reset();
- this.open = true;
- this.title = "新增识别器";
- this.uniformPower=[20,20,20,20];
- this.detection=['0','0','0','0']
- this.antennaNum=[1,2,3,4]//天线数量
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- if(row.onOff == 1){
- this.msgError("修改检测门前请先关闭设备");
- return
- }
- let _this=this;
- this.open = true;
- this.title = "修改识别器";
- this.form.id=row.id
- this.form.deviceType='7'
- this.form.hardwareNum=row.hardwareNum
- this.form.subjectId=row.subjectId
- this.form.ipAddress=row.ipAddress
- this.form.port=row.port
- this.form.channels=row.channels+''
- this.form.sessionIndex=row.sessionIndex+''
- this.form.manufacturerType=row.manufacturerType+''
- //this.uniformPower=row.uniformPower.split(',')
- this.antennaNum=[];
- this.uniformPower=[];
- this.detection=[];
- //天线感应距离和检测类型编辑
- let arr=[]
- this.form.uniformPower=row.uniformPower//天线感应距离和检测类型
- arr=row.uniformPower.split(',')
- arr.forEach(function(item,index) {
- console.log(item.split(':'))
- _this.antennaNum.push(index)//天线数量
- _this.uniformPower.push(item.split(':')[0])
- _this.detection.push(item.split(':')[1])
- })
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- //this.form.uniformPower=this.uniformPower.join(',')
- let uniformArr=[]
- for(let i=0;i<this.uniformPower.length;i++){
- uniformArr.push(this.uniformPower[i]+':'+this.detection[i])
- }
- this.form.uniformPower=uniformArr.join(',')
- console.log(uniformArr.join(','))
- this.form.channels=Number(this.form.channels)
- this.form.sessionIndex=Number(this.form.sessionIndex)
- if (this.form.id != null) {
- this.form.senseState = null
- recognizerAnew(this.form).then(response => {
- this.msgSuccess("修改成功,请重新开启设备");
- this.open = false;
- this.getList();
- });
- } else {
- recognizerAdd(this.form).then(response => {
- this.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- });
- }
- }
- });
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const ids = row.id || this.ids;
- this.$confirm('确认删除传感器吗?', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(function() {
- return recognizerDelete(ids);
- }).then(() => {
- this.getList();
- this.msgSuccess("删除成功");
- }).catch(() => {});
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download('laboratory/sensor/export', {
- ...this.queryParams
- }, `laboratory_sensor.xlsx`)
- }
- },
- };
- </script>
- <style scoped lang="scss">
- .certification{
- display: flex!important;
- flex-direction: column;
- box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
- padding:20px!important;
- .button-box{
- width:200px;
- display: flex;
- }
- .form-box{
- }
- }
- </style>
- <style lang="scss">
- .certification{
- .switch .el-switch__label {
- position: absolute;
- display: none;
- color: #fff !important;
- }
- .switch .el-switch__label--right {
- z-index: 1;
- }
- .switch .el-switch__label--right span{
- margin-left:10px;
- }
- .switch .el-switch__label--left {
- z-index: 1;
- }
- .switch .el-switch__label--left span{
- margin-left: 34px;
- }
- .switch .el-switch__label.is-active {
- display: block;
- }
- .switch.el-switch .el-switch__core,
- .el-switch .el-switch__label {
- width: 64px !important;
- margin: 0;
- }
- }
- .add-hardware-dialog-box{
- .el-form-item__error {
- left: 21%!important;
- }
- }
- .recognizer-manage{
- .el-form-item__error {
- left: 0 !important;
- }
- //.el-input--suffix{
- // width:340px!important;
- //}
- //.el-input__inner{
- // width:340px!important;
- //}
- //.el-input--medium{
- // width:340px!important;
- //}
- //.el-input-number--medium{
- // width:240px!important;
- //}
- .form-input-ip-box{
- display: flex;
- width:550px;
- .form-ip{
- margin-right:0;
- width:340px;
- input{
- width:200px;
- }
- }
- .form-port{
- margin-right:0;
- flex:1;
- input{
- width:136px;
- }
- input{
- /*width:120px;*/
- }
- }
- }
- }
- </style>
|