recognizerManage.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <!--识别器管理-->
  2. <template>
  3. <div class="app-container certification">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" class="form-box">
  5. <el-form-item label="关键字" prop="name">
  6. <el-input
  7. v-model="queryParams.searchValue"
  8. placeholder="设备编号/所属实验室"
  9. clearable
  10. maxLength="30"
  11. size="small"
  12. />
  13. </el-form-item>
  14. <el-form-item>
  15. <p class="inquire-button-one" @click="handleQuery">查询</p>
  16. <p class="reset-button-one" @click="resetQuery">重置</p>
  17. </el-form-item>
  18. <el-form-item style="float: right;">
  19. <el-col :span="1.5">
  20. <p class="add-button-one-120"
  21. @click="handleAdd"
  22. v-hasPermi="['laboratory:hardware7:add']"
  23. ><i class="el-icon-plus"></i>新增</p>
  24. </el-col>
  25. </el-form-item>
  26. </el-form>
  27. <el-table border v-loading="loading" :data="sensorList">
  28. <el-table-column label="设备名称" align="left" prop="deviceName" show-overflow-tooltip/>
  29. <el-table-column label="设备编号" align="left" prop="hardwareNum" show-overflow-tooltip/>
  30. <el-table-column label="学院" align="center" prop="deptName" width="200" show-overflow-tooltip/>
  31. <el-table-column label="位置" align="center" prop="position" width="250" show-overflow-tooltip/>
  32. <el-table-column label="设备状态" align="center" prop="status" width="120">
  33. <template slot-scope="scope">
  34. <el-switch
  35. v-hasPermi="['laboratory:hardware7:changeStatus']"
  36. class="switch"
  37. @change="switchChange(scope.row)"
  38. v-model="scope.row.onOff+''"
  39. active-value="1"
  40. inactive-value="0"
  41. active-text="开"
  42. inactive-text="关"
  43. >
  44. </el-switch>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="创建时间" align="center" prop="createTime" width="200" show-overflow-tooltip/>
  48. <el-table-column label="创建人" align="center" prop="createBy" width="200" show-overflow-tooltip/>
  49. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="150">
  50. <template slot-scope="scope">
  51. <div class="button-box">
  52. <p class="table-min-button"
  53. @click="handleUpdate(scope.row)"
  54. style="margin-right:20px;"
  55. v-hasPermiAnd="['laboratory:hardware7:query','laboratory:hardware7:edit']"
  56. >修改</p>
  57. <p class="table-min-button"
  58. @click="handleDelete(scope.row)"
  59. v-hasPermi="['laboratory:hardware7:remove']"
  60. >删除</p>
  61. </div>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <pagination
  66. v-show="total>0"
  67. :total="total"
  68. layout="total, prev, pager, next, sizes, jumper"
  69. :page.sync="queryParams.pageNum"
  70. :limit.sync="queryParams.pageSize"
  71. @pagination="getList"
  72. />
  73. <!-- 添加或修改传感器对话框 -->
  74. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body class="recognizer recognizer-manage add-hardware-dialog-box">
  75. <el-form ref="form" :model="form" :rules="rules" :inline="true" label-width="130px">
  76. <el-form-item label="设备名称" prop="deviceName">
  77. <el-input v-model="form.deviceName" maxlength="30" placeholder="请输入识别器编号" style="width: 400px"/>
  78. </el-form-item>
  79. <el-form-item label="识别器编号" prop="hardwareNum">
  80. <el-input v-model="form.hardwareNum" maxlength="30" placeholder="请输入识别器编号" style="width: 400px"/>
  81. </el-form-item>
  82. <el-form-item label="所属实验室" prop="subjectId">
  83. <el-select v-model="form.subjectId" placeholder="请选择实验室" style="width: 400px">
  84. <el-option
  85. v-for="item in subjectAddOptions"
  86. :key="item.id"
  87. :label="item.name"
  88. :value="item.id">
  89. </el-option>
  90. </el-select>
  91. </el-form-item>
  92. <div class="form-input-ip-box">
  93. <el-form-item label="IP地址" label-width="130px" prop="ipAddress" class="form-ip">
  94. <el-input v-model="form.ipAddress" maxlength="30" placeholder="请输入IP地址"/>
  95. </el-form-item>
  96. <el-form-item label="端口" label-width="54px" prop="port" class="form-port">
  97. <el-input style="width:120px;" maxlength="5" v-model="form.port" placeholder="请输入端口"/>
  98. </el-form-item>
  99. </div>
  100. <el-form-item label="连接方式" prop="manufacturerType">
  101. <el-select v-model="form.manufacturerType" placeholder="请选择" style="width:400px;" >
  102. <el-option :label="item.dictLabel" :value="item.dictValue" v-for="(item,index) in materialTypeList" :key="index"></el-option>
  103. </el-select>
  104. </el-form-item>
  105. <el-form-item label="推送频率" prop="sessionIndex">
  106. <el-select v-model="form.sessionIndex" placeholder="请选择设备推送频率" style="width:400px;">
  107. <el-option label="最大" value="0"></el-option>
  108. <el-option label="中等" value="1"></el-option>
  109. <el-option label="最小" value="2"></el-option>
  110. </el-select>
  111. </el-form-item>
  112. <el-form-item label="天线数量" prop="channels">
  113. <el-select v-model="form.channels" placeholder="请选择信道数量" @change="antennaNumFun()" style="width:400px;">
  114. <el-option label="1" value="1"></el-option>
  115. <el-option label="2" value="2"></el-option>
  116. <el-option label="4" value="4"></el-option>
  117. <el-option label="8" value="8"></el-option>
  118. <el-option label="16" value="16"></el-option>
  119. </el-select>
  120. </el-form-item>
  121. <el-row v-for="(item,index) in antennaNum" :key="index">
  122. <el-col :span="12">
  123. <el-form-item :label="(index+1)+'号天线感应距离'">
  124. <el-input-number v-model="uniformPower[index]" maxlength="10" placeholder="请输入设备输出频率" style="width:140px;"/>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="12">
  128. <el-form-item :label="(index+1)+'号天线检测类型'">
  129. <el-select v-model="detection[index]" placeholder="请选择检测类型" style="width:140px;">
  130. <el-option
  131. v-for="item in detectionArr"
  132. :key="item.id"
  133. :label="item.name"
  134. :value="item.id">
  135. </el-option>
  136. </el-select>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. <!-- <el-form-item :label="(index+1)+'号天线感应距离'" v-for="(item,index) in antennaNum" :key="index">-->
  141. <!-- <el-input-number v-model="uniformPower[index]" placeholder="请输入设备输出频率" />-->
  142. <!-- </el-form-item>-->
  143. </el-form>
  144. <div slot="footer" class="dialog-footer">
  145. <el-button @click="cancel">取 消</el-button>
  146. <el-button type="primary" @click="submitForm">确 定</el-button>
  147. </div>
  148. </el-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import { subjectDictList } from "@/api/laboratory/group";
  153. import Treeselect from "@riophae/vue-treeselect";
  154. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  155. import {
  156. recognizerAdd,
  157. recognizerAnew,
  158. recognizerDelete,
  159. recognizerList,
  160. recognizerSwitch,
  161. supplierStop, RFIDTypeList, recognizerNettyFrid
  162. } from '@/api/gasManage3_0/gasManage'
  163. export default {
  164. name: "Sensor",
  165. components: { Treeselect },
  166. data() {
  167. const ipVerification = (rule, value, callback) => {
  168. 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)) {
  169. callback(new Error("IP地址错误"));
  170. } else {
  171. callback()
  172. }
  173. };
  174. const portVerification = (rule, value, callback) => {
  175. if(!/^[0-9]+$/.test(value)) {
  176. callback(new Error("端口号错误"));
  177. } else {
  178. callback()
  179. }
  180. };
  181. return {
  182. // 遮罩层
  183. loading: true,
  184. // 总条数
  185. total: 0,
  186. // 传感器表格数据
  187. sensorList: [],
  188. // 弹出层标题
  189. title: "",
  190. // 是否显示弹出层
  191. open: false,
  192. subjectAddOptions: [],
  193. // 查询参数
  194. queryParams: {
  195. pageNum: 1,
  196. pageSize:20,
  197. searchValue:'',
  198. deviceType:'7'
  199. },
  200. // 表单参数
  201. form: {
  202. id:'',
  203. hardwareNum:'',
  204. subjectId:'',
  205. deviceType:'7',
  206. ipAddress:'',//ip地址
  207. channels:4,//信道
  208. sessionIndex:0,//设备推送频率
  209. uniformPower:'',//设备推送频率
  210. manufacturerType:null,//连接方式
  211. },
  212. materialTypeList:[],
  213. uniformPower:[20,20,20,20],
  214. antennaNum:[1,2,3,4],//天线数量
  215. detection:['0','0','0','0',],//检测类型选择的值
  216. detectionArr:[],//检测类型数组
  217. // 表单校验
  218. rules: {
  219. deviceName:[
  220. {required: true, message: '设备名称不能为空', trigger: 'blur'}
  221. ],
  222. hardwareNum:[
  223. {required: true, message: '识别器编号不能为空', trigger: 'blur'}
  224. ],
  225. subjectId:[
  226. {required: true, message: '所属实验室不能为空', trigger: 'blur'}
  227. ],
  228. ipAddress:[
  229. {required: true, message: 'IP地址不能为空', trigger: 'blur'},
  230. { required: true, validator: ipVerification, trigger: "blur" },
  231. ],
  232. port:[
  233. {required: true, message: '端口不能为空', trigger: 'blur'},
  234. { required: true, validator: portVerification, trigger: "blur" },
  235. ],
  236. manufacturerType:[
  237. {required: true, message: '请选择连接方式', trigger: 'blur'},
  238. ],
  239. sessionIndex:[
  240. {required: true, message: '请选择推送频率', trigger: 'blur'},
  241. ],
  242. channels:[
  243. {required: true, message: '请选择天线数量', trigger: 'blur'},
  244. ],
  245. },
  246. };
  247. },
  248. created() {
  249. },
  250. mounted(){
  251. this.getList();
  252. this.getSubjectAddDictList();
  253. this.supplierTypeList();
  254. this.recognizerNettyFrid();
  255. },
  256. methods: {
  257. //根据选择的天线数量循环距离和检测类型
  258. antennaNumFun(){
  259. this.uniformPower=[];
  260. this.antennaNum=[];
  261. this.detection=[];
  262. for(let i=0;i<this.form.channels;i++){
  263. this.antennaNum.push(i)
  264. this.uniformPower.push(20)
  265. this.detection.push('0')
  266. }
  267. },
  268. //供应商类型
  269. supplierTypeList(){
  270. let _this=this;
  271. RFIDTypeList().then( response => {
  272. let res=response.rows;
  273. _this.materialTypeList=res;
  274. });
  275. },
  276. //状态
  277. switchChange(row){
  278. console.log(row)
  279. //1上架0下架
  280. this.$confirm('是否确定'+(row.onOff==1?'关闭':'打开')+'?', '提示', {
  281. confirmButtonText: '确定',
  282. cancelButtonText: '取消',
  283. type: 'warning'
  284. }).then(() => {
  285. this.upDownShelf(row.id)
  286. }).catch(() => {
  287. this.$message({
  288. type: 'info',
  289. message: '已取消'
  290. });
  291. });
  292. },
  293. //上架下架
  294. upDownShelf(id){
  295. recognizerSwitch(id).then( response => {
  296. this.msgSuccess("修改成功");
  297. this.getList();
  298. });
  299. },
  300. /** 查询实验室字典列表 */
  301. getSubjectAddDictList () {
  302. this.subjectAddOptions = null;
  303. this.loading = true;
  304. let params = {};
  305. subjectDictList(params).then(response => {
  306. this.subjectAddOptions = response.data;
  307. this.loading = false;
  308. });
  309. },
  310. /** 查询传感器列表 */
  311. getList() {
  312. this.loading = true;
  313. recognizerList(this.queryParams).then(response => {
  314. this.sensorList = response.rows;
  315. this.total = response.total;
  316. this.loading = false;
  317. });
  318. },
  319. //检测类型
  320. recognizerNettyFrid(){
  321. let _this=this;
  322. recognizerNettyFrid().then(response => {
  323. _this.detectionArr = []
  324. response.data.forEach(function(item,index) {
  325. for(let i in item){
  326. console.log(item[i])
  327. _this.detectionArr.push({'id':i,'name':item[i]})
  328. }
  329. })
  330. });
  331. },
  332. // 取消按钮
  333. cancel() {
  334. this.open = false;
  335. this.reset();
  336. },
  337. // 表单重置
  338. reset() {
  339. this.form = {
  340. id: null,
  341. name: null,
  342. deviceType:'7',
  343. hardwareNum: null,
  344. subjectId: null,
  345. ipAddress: null,
  346. port: null,
  347. manufacturerType:null,
  348. channels: '4',
  349. sessionIndex: '0',
  350. uniformPower: '',
  351. };
  352. this.resetForm("form");
  353. },
  354. /** 搜索按钮操作 */
  355. handleQuery() {
  356. this.queryParams.pageNum = 1;
  357. this.getList();
  358. },
  359. /** 重置按钮操作 */
  360. resetQuery() {
  361. this.queryParams.searchValue = '';
  362. this.handleQuery();
  363. },
  364. // 20:10,30:20
  365. /** 新增按钮操作 */
  366. handleAdd() {
  367. this.reset();
  368. this.open = true;
  369. this.title = "新增识别器";
  370. this.uniformPower=[20,20,20,20];
  371. this.detection=['0','0','0','0']
  372. this.antennaNum=[1,2,3,4]//天线数量
  373. },
  374. /** 修改按钮操作 */
  375. handleUpdate(row) {
  376. if(row.onOff == 1){
  377. this.msgError("修改检测门前请先关闭设备");
  378. return
  379. }
  380. let _this=this;
  381. this.open = true;
  382. this.title = "修改识别器";
  383. this.form.id=row.id
  384. this.form.deviceType='7'
  385. this.form.hardwareNum=row.hardwareNum
  386. this.form.subjectId=row.subjectId
  387. this.form.ipAddress=row.ipAddress
  388. this.form.port=row.port
  389. this.form.channels=row.channels+''
  390. this.form.sessionIndex=row.sessionIndex+''
  391. this.form.manufacturerType=row.manufacturerType+''
  392. //this.uniformPower=row.uniformPower.split(',')
  393. this.antennaNum=[];
  394. this.uniformPower=[];
  395. this.detection=[];
  396. //天线感应距离和检测类型编辑
  397. let arr=[]
  398. this.form.uniformPower=row.uniformPower//天线感应距离和检测类型
  399. arr=row.uniformPower.split(',')
  400. arr.forEach(function(item,index) {
  401. console.log(item.split(':'))
  402. _this.antennaNum.push(index)//天线数量
  403. _this.uniformPower.push(item.split(':')[0])
  404. _this.detection.push(item.split(':')[1])
  405. })
  406. },
  407. /** 提交按钮 */
  408. submitForm() {
  409. this.$refs["form"].validate(valid => {
  410. if (valid) {
  411. //this.form.uniformPower=this.uniformPower.join(',')
  412. let uniformArr=[]
  413. for(let i=0;i<this.uniformPower.length;i++){
  414. uniformArr.push(this.uniformPower[i]+':'+this.detection[i])
  415. }
  416. this.form.uniformPower=uniformArr.join(',')
  417. console.log(uniformArr.join(','))
  418. this.form.channels=Number(this.form.channels)
  419. this.form.sessionIndex=Number(this.form.sessionIndex)
  420. if (this.form.id != null) {
  421. this.form.senseState = null
  422. recognizerAnew(this.form).then(response => {
  423. this.msgSuccess("修改成功,请重新开启设备");
  424. this.open = false;
  425. this.getList();
  426. });
  427. } else {
  428. recognizerAdd(this.form).then(response => {
  429. this.msgSuccess("新增成功");
  430. this.open = false;
  431. this.getList();
  432. });
  433. }
  434. }
  435. });
  436. },
  437. /** 删除按钮操作 */
  438. handleDelete(row) {
  439. const ids = row.id || this.ids;
  440. this.$confirm('确认删除传感器吗?', "警告", {
  441. confirmButtonText: "确定",
  442. cancelButtonText: "取消",
  443. type: "warning"
  444. }).then(function() {
  445. return recognizerDelete(ids);
  446. }).then(() => {
  447. this.getList();
  448. this.msgSuccess("删除成功");
  449. }).catch(() => {});
  450. },
  451. /** 导出按钮操作 */
  452. handleExport() {
  453. this.download('laboratory/sensor/export', {
  454. ...this.queryParams
  455. }, `laboratory_sensor.xlsx`)
  456. }
  457. },
  458. };
  459. </script>
  460. <style scoped lang="scss">
  461. .certification{
  462. display: flex!important;
  463. flex-direction: column;
  464. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  465. padding:20px!important;
  466. .button-box{
  467. width:200px;
  468. display: flex;
  469. }
  470. .form-box{
  471. }
  472. }
  473. </style>
  474. <style lang="scss">
  475. .certification{
  476. .switch .el-switch__label {
  477. position: absolute;
  478. display: none;
  479. color: #fff !important;
  480. }
  481. .switch .el-switch__label--right {
  482. z-index: 1;
  483. }
  484. .switch .el-switch__label--right span{
  485. margin-left:10px;
  486. }
  487. .switch .el-switch__label--left {
  488. z-index: 1;
  489. }
  490. .switch .el-switch__label--left span{
  491. margin-left: 34px;
  492. }
  493. .switch .el-switch__label.is-active {
  494. display: block;
  495. }
  496. .switch.el-switch .el-switch__core,
  497. .el-switch .el-switch__label {
  498. width: 64px !important;
  499. margin: 0;
  500. }
  501. }
  502. .add-hardware-dialog-box{
  503. .el-form-item__error {
  504. left: 21%!important;
  505. }
  506. }
  507. .recognizer-manage{
  508. .el-form-item__error {
  509. left: 0 !important;
  510. }
  511. //.el-input--suffix{
  512. // width:340px!important;
  513. //}
  514. //.el-input__inner{
  515. // width:340px!important;
  516. //}
  517. //.el-input--medium{
  518. // width:340px!important;
  519. //}
  520. //.el-input-number--medium{
  521. // width:240px!important;
  522. //}
  523. .form-input-ip-box{
  524. display: flex;
  525. width:550px;
  526. .form-ip{
  527. margin-right:0;
  528. width:340px;
  529. input{
  530. width:200px;
  531. }
  532. }
  533. .form-port{
  534. margin-right:0;
  535. flex:1;
  536. input{
  537. width:136px;
  538. }
  539. input{
  540. /*width:120px;*/
  541. }
  542. }
  543. }
  544. }
  545. </style>