recognizerManage.vue 15 KB

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