deviceListOne.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. <!--物联设备配置-->
  2. <template>
  3. <div class="deviceList scrollbar-box">
  4. <div class="title-box">
  5. <p class="left-title">传感器</p>
  6. <p class="right-button reset-button-one" @click="backPage">返回</p>
  7. </div>
  8. <div class="for-max-box">
  9. <div class="for-big-box" v-for="(item,index) in listCgq" :key="index">
  10. <p class="for-title-p">{{subjectData.room}}-{{item.type.name}}传感器{{index+1}}</p>
  11. <div class="for-text-box">
  12. <p>网关编号:</p>
  13. <el-tooltip class="item" effect="dark" :content="item.gatewayId" placement="top">
  14. <p>{{item.gatewayId}}</p>
  15. </el-tooltip>
  16. </div>
  17. <div class="for-button-box">
  18. <p @click="editData(5,item)"><i class="el-icon-edit-outline"></i>编辑</p>
  19. <p></p>
  20. <p @click="delSensor(item)"><i class="el-icon-delete"></i>删除</p>
  21. </div>
  22. </div>
  23. <p class="add-for-p" @click="addData(1)"><i class="el-icon-plus"></i>添加传感器</p>
  24. </div>
  25. <div class="title-box">
  26. <p class="left-title">智能门禁</p>
  27. </div>
  28. <div class="for-max-box">
  29. <div class="for-big-box-two" v-for="(item,index) in listZnmj" :key="index">
  30. <p class="for-title-p">{{subjectData.room}}-智能门禁{{index+1}}</p>
  31. <div class="for-text-box">
  32. <p>锁编号:</p>
  33. <el-tooltip class="item" effect="dark" :content="item.lockCode" placement="top">
  34. <p style="flex:2;">{{item.lockCode}}</p>
  35. </el-tooltip>
  36. </div>
  37. <div class="for-text-box">
  38. <p>房间名称:</p>
  39. <p style="flex:2;">{{item.roomName}}</p>
  40. </div>
  41. <div class="for-text-box">
  42. <p>管理员:</p>
  43. <p style="flex:2;">{{item.safeUserName}}</p>
  44. </div>
  45. <div class="for-button-box">
  46. <p @click="delLockRoom(item)"><i class="el-icon-delete" style="color:#ff6868;margin-right:10px;"></i>删除</p>
  47. </div>
  48. </div>
  49. <p class="add-for-p-two" style="height:188px;line-height:188px;" @click="listLockRoom"><i class="el-icon-plus"></i>添加智能门禁</p>
  50. </div>
  51. <!--
  52. lockCode锁编号
  53. roomName房间名称
  54. -->
  55. <!--<div class="title-box">-->
  56. <!--<p class="left-title">一体机</p>-->
  57. <!--</div>-->
  58. <!--<div class="for-max-box">-->
  59. <!--<div class="for-big-box" v-for="(item,index) in listYtj" :key="index">-->
  60. <!--<p class="for-title-p">{{subjectData.room}}-{{item.type.name}}{{index+1}}</p>-->
  61. <!--<div class="for-text-box">-->
  62. <!--<p>一体机编号:</p>-->
  63. <!--<el-tooltip class="item" effect="dark" :content="item.hardwareNum" placement="top">-->
  64. <!--<p>{{item.hardwareNum}}</p>-->
  65. <!--</el-tooltip>-->
  66. <!--</div>-->
  67. <!--<div class="for-button-box">-->
  68. <!--<p @click="editData(6,item)"><i class="el-icon-edit-outline"></i>编辑</p>-->
  69. <!--<p></p>-->
  70. <!--<p @click="delHardware(item)"><i class="el-icon-delete"></i>删除</p>-->
  71. <!--</div>-->
  72. <!--</div>-->
  73. <!--<p class="add-for-p" @click="addData(2)"><i class="el-icon-plus"></i>添加一体机</p>-->
  74. <!--</div>-->
  75. <!--<div class="title-box">-->
  76. <!--<p class="left-title">控制设备</p>-->
  77. <!--</div>-->
  78. <!--<div class="for-max-box">-->
  79. <!--<div class="for-big-box-two" v-for="(item,index) in listkzsb" :key="index">-->
  80. <!--<p class="for-title-p">{{subjectData.room}}-{{item.type.name}}传感器{{index+1}}</p>-->
  81. <!--<div class="for-text-box">-->
  82. <!--<p>设备编号:</p>-->
  83. <!--<el-tooltip class="item" effect="dark" :content="item.relayCode" placement="top">-->
  84. <!--<p>{{item.relayCode}}</p>-->
  85. <!--</el-tooltip>-->
  86. <!--</div>-->
  87. <!--<div class="for-text-box">-->
  88. <!--<p>设备路由:</p>-->
  89. <!--<p>{{item.bit}}</p>-->
  90. <!--</div>-->
  91. <!--<div class="for-button-box">-->
  92. <!--<p @click="editData(7,item)"><i class="el-icon-edit-outline"></i>编辑</p>-->
  93. <!--<p></p>-->
  94. <!--<p @click="delHardwareTwo(item)"><i class="el-icon-delete"></i>删除</p>-->
  95. <!--</div>-->
  96. <!--</div>-->
  97. <!--<p class="add-for-p-two" @click="addData(3)"><i class="el-icon-plus"></i>添加控制设备</p>-->
  98. <!--</div>-->
  99. <!--<div class="title-box">-->
  100. <!--<p class="left-title">摄像头</p>-->
  101. <!--</div>-->
  102. <!--<div class="for-max-box">-->
  103. <!--<div class="for-big-box" v-for="(item,index) in listSpjk" :key="index">-->
  104. <!--<p class="for-title-p">{{subjectData.room}}-{{item.type.name}}{{index+1}}</p>-->
  105. <!--<div class="for-text-box">-->
  106. <!--<p>摄像头编号:</p>-->
  107. <!--<p></p>-->
  108. <!--</div>-->
  109. <!--<div class="for-text-box">-->
  110. <!--<p></p>-->
  111. <!--<el-tooltip class="item" effect="dark" :content="item.hardwareNum" placement="top">-->
  112. <!--<p>{{item.hardwareNum}}</p>-->
  113. <!--</el-tooltip>-->
  114. <!--</div>-->
  115. <!--<div class="for-button-box">-->
  116. <!--<p @click="editData(8,item)"><i class="el-icon-edit-outline"></i>编辑</p>-->
  117. <!--<p></p>-->
  118. <!--<p @click="delHardwareThree(item)"><i class="el-icon-delete"></i>删除</p>-->
  119. <!--</div>-->
  120. <!--</div>-->
  121. <!--<p class="add-for-p-two" @click="addData(4)"><i class="el-icon-plus"></i>添加摄像头</p>-->
  122. <!--</div>-->
  123. <el-dialog :title="title" :visible.sync="addType" v-if="addType" width="500px" append-to-body>
  124. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  125. <div v-if="upType == 1 || upType == 5">
  126. <el-form-item label="传感器类型" prop="type">
  127. <el-select v-model="form.type" placeholder="请选择传感器类型" style="width:320px;">
  128. <el-option
  129. v-for="item in sensorAddOptions"
  130. :key="item.enumName"
  131. :label="item.name"
  132. :value="item.enumName">
  133. </el-option>
  134. </el-select>
  135. </el-form-item>
  136. <el-form-item label="网关编号" prop="gatewayId">
  137. <el-input v-model="form.gatewayId" placeholder="请输入网关编号"
  138. maxlength="30" style="width:320px;"/>
  139. </el-form-item>
  140. <el-form-item label="路由" prop="routeNum">
  141. <el-input v-model="form.routeNum" oninput="value=value.replace(/[^0-9.]/g,'')" maxlength="2" placeholder="请输入路由" style="width:320px;"></el-input>
  142. </el-form-item>
  143. <el-form-item label="传感器参数" prop="configName">
  144. <el-input v-model="form.configName" placeholder="请输入传感器参数"
  145. maxlength="30" style="width:320px;"></el-input>
  146. </el-form-item>
  147. <el-form-item label="状态参数" prop="configStatus">
  148. <el-input v-model="form.configStatus" placeholder="请输入状态参数"
  149. maxlength="30" style="width:320px;"></el-input>
  150. </el-form-item>
  151. </div>
  152. <div v-if="upType == 2 || upType == 6">
  153. <el-form-item label="一体机名称" prop="name">
  154. <el-input
  155. style="width:320px;"
  156. v-model="form.name"
  157. placeholder="请输入一体机名称"
  158. maxlength="8"
  159. size="small"
  160. />
  161. </el-form-item>
  162. <el-form-item label="一体机类型" prop="pcType">
  163. <el-select v-model="form.pcType" placeholder="请选择一体机类型" style="width:320px;">
  164. <el-option label="管控一体机" value="0" />
  165. <el-option label="学习一体机" value="1" />
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item label="一体机编号" prop="hardwareNum">
  169. <el-input
  170. style="width:320px;"
  171. v-model="form.hardwareNum"
  172. placeholder="请输入一体机编号"
  173. maxlength="30"
  174. size="small"
  175. />
  176. </el-form-item>
  177. </div>
  178. <div v-if="upType == 3 || upType == 7">
  179. <el-form-item label="设备类型" prop="type">
  180. <el-select v-model="form.type" placeholder="请选择设备类型" style="width:320px;" :disabled="disabledType">
  181. <el-option key="1" label="电源开关" value="1"></el-option>
  182. <el-option key="2" label="智能通风" value="2"></el-option>
  183. </el-select>
  184. </el-form-item>
  185. <el-form-item label="设备版本" prop="hardwareType">
  186. <el-radio-group v-model="form.hardwareType">
  187. <el-radio :label="1">老继电器</el-radio>
  188. <el-radio :label="2">新继电器</el-radio>
  189. </el-radio-group>
  190. </el-form-item>
  191. <el-form-item label="设备编号" prop="relayCode">
  192. <el-input v-model="form.relayCode" placeholder="请输入设备编号"
  193. maxlength="30" style="width:320px;"/>
  194. </el-form-item>
  195. <el-form-item label="设备路由" prop="bit">
  196. <el-input v-model="form.bit" oninput="value=value.replace(/[^0-9.]/g,'')" maxlength="2" placeholder="请输入路由" style="width:320px;"></el-input>
  197. </el-form-item>
  198. <el-form-item label="设备参数" prop="configName" v-if="form.hardwareType == 2">
  199. <el-input v-model="form.configName" maxlength="30" placeholder="请输入设备参数" style="width:320px;"></el-input>
  200. </el-form-item>
  201. <el-form-item label="参数状态" prop="configStatus" v-if="form.hardwareType == 2">
  202. <el-input v-model="form.configStatus" maxlength="30" placeholder="请输入参数状态" style="width:320px;"></el-input>
  203. </el-form-item>
  204. </div>
  205. <div v-if="upType == 4 || upType == 8">
  206. <el-form-item label="摄像头编号" prop="hardwareNum">
  207. <el-input v-model="form.hardwareNum" placeholder="摄像头编号"
  208. maxlength="30" style="width:320px;"/>
  209. </el-form-item>
  210. </div>
  211. </el-form>
  212. <div slot="footer" class="dialog-footer">
  213. <el-button @click="cancel">取 消</el-button>
  214. <el-button type="primary" @click="submitForm">确 定</el-button>
  215. </div>
  216. </el-dialog>
  217. <el-dialog :title="titleOne" :visible.sync="addTypeOne" v-if="addTypeOne" width="800px" append-to-body>
  218. <div style="height:500px;overflow: hidden;display: flex;flex-direction: column">
  219. <el-table border :data="tableList" @select-all="handleSelectionChange" @select="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  220. <el-table-column type="selection" width="50" align="center" :reserve-selection="true"/>
  221. <el-table-column label="房间名称" align="center" prop="roomname" width="123px"/>
  222. <el-table-column label="门锁编号" align="center" prop="roomcode2" show-overflow-tooltip/>
  223. <el-table-column label="位置" align="center" prop="roomlocation" show-overflow-tooltip/>
  224. <el-table-column label="管理员" align="center" prop="roomlocation">
  225. <template slot-scope="scope">
  226. <el-select v-model="scope.row.safeUserId" placeholder="请选择">
  227. <el-option
  228. v-for="item in userListOption"
  229. :key="item.id"
  230. :label="item.user"
  231. :value="item.id">
  232. </el-option>
  233. </el-select>
  234. </template>
  235. </el-table-column>
  236. <!--
  237. 房间名称: roomname 门锁编号:roomcode2 位置:roomlocation
  238. -->
  239. </el-table>
  240. <pagination :page-sizes="[20, 30, 40, 50]"
  241. v-show="total>0"
  242. :total="total"
  243. style="margin:0;"
  244. :page.sync="queryParams.pageNum"
  245. :limit.sync="queryParams.pageSize"
  246. @pagination="listLockRoom"
  247. />
  248. </div>
  249. <div slot="footer" class="dialog-footer">
  250. <el-button @click="cancelOne">取 消</el-button>
  251. <el-button type="primary" @click="submitFormOne">确 定</el-button>
  252. </div>
  253. </el-dialog>
  254. </div>
  255. </template>
  256. <script>
  257. import { listBySubjectId,addSensor,putSensor,delSensor,addHardware,putHardware,
  258. delHardware,subjectRelationList,listLockRoom,subjectRelation,delSubjectRelation } from "@/api/laboratory/subject";
  259. import { getSensorList } from "@/api/laboratory/sensor";
  260. export default {
  261. name: "deviceList",
  262. props:{
  263. subjectData:{},
  264. },
  265. data() {
  266. return {
  267. title:"",
  268. addType:false,
  269. listCgq:[], //传感器
  270. listYtj:[], //一体机
  271. listkzsb:[],
  272. listSpjk:[], //摄像头
  273. listZnmj:[],//智能门禁
  274. form:{},
  275. // 表单校验
  276. rules: {
  277. name:[
  278. {required: true, message: '一体机名称不能为空', trigger: 'blur'},
  279. { required: true, message: "一体机名称不能为空", validator: this.spaceJudgment, trigger: "blur" }
  280. ],
  281. type:[
  282. {required: true, message: '类型不能为空', trigger: 'blur'}
  283. ],
  284. gatewayId:[
  285. {required: true, message: '网关不能为空', trigger: 'blur'},
  286. { required: true, message: "网关不能为空", validator: this.spaceJudgment, trigger: "blur" }
  287. ],
  288. hardwareNum:[
  289. { required: true, message: "请输入编号", trigger: "blur" },
  290. { required: true, message: "请输入编号", validator: this.spaceJudgment, trigger: "blur" }
  291. ],
  292. pcType: [
  293. { required: true, message: "请选择类型", trigger: "blur" },
  294. ],
  295. hardwareType: [
  296. { required: true, message: "请选择设备版本", trigger: "blur" },
  297. ],
  298. relayCode: [
  299. { required: true, message: "请输入设备编号", trigger: "blur" },
  300. { required: true, message: "请输入设备编号", validator: this.spaceJudgment, trigger: "blur" }
  301. ],
  302. bit: [
  303. { required: true, message: "请输入路由", trigger: "blur" },
  304. { required: true, message: "请输入路由", validator: this.spaceJudgment, trigger: "blur" }
  305. ],
  306. },
  307. //提交类型
  308. upType:"",
  309. //传感器类型
  310. sensorAddOptions: [],
  311. titleOne:'新增智能门禁',
  312. addTypeOne:false,
  313. queryParams: {
  314. pageNumber: 1,
  315. pageSize:20,
  316. },
  317. tableList:[],
  318. total:0,
  319. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  320. selectedNum:0,
  321. // 选中数组
  322. ids: [],
  323. // 非单个禁用
  324. single: true,
  325. // 非多个禁用
  326. multiple: true,
  327. multipleTableList:[],
  328. //智能门禁管理员数据列表
  329. userListOption:[],
  330. }
  331. },
  332. created() {
  333. this.listBySubjectId();
  334. this.subjectRelationList();
  335. this.getSensorList();
  336. },
  337. mounted(){
  338. this.getUserData();
  339. },
  340. methods:{
  341. getUserData(){
  342. let self = this;
  343. let list = [];
  344. let userNewList = this.subjectData.safeUserNameAdminPhone.split(',');
  345. for(let i=0;i<userNewList.length;i++){
  346. let minList = userNewList[i].split('@');
  347. let obj = {
  348. id:self.subjectData.safeUserId[i],
  349. user:minList[0],
  350. phone:minList[1],
  351. };
  352. list.push(obj);
  353. }
  354. this.$set(this,'userListOption',list);
  355. },
  356. // 取消按钮
  357. cancel() {
  358. this.addType = false;
  359. },
  360. cancelOne() {
  361. this.addTypeOne = false;
  362. },
  363. submitFormOne(){
  364. let self = this;
  365. if(!this.multipleTableList[0]){
  366. this.msgError("请勾选智能门禁")
  367. return
  368. }
  369. let obj = {
  370. slSubjectList:[],
  371. };
  372. for(let i=0;i<self.multipleTableList.length;i++){
  373. if(!self.multipleTableList[i].safeUserId){
  374. this.msgError("请选择管理员")
  375. return
  376. }
  377. let minObj = {
  378. subjectId:self.subjectData.id,
  379. subjectName:self.subjectData.name,
  380. lockRoomId:self.multipleTableList[i].roomid,
  381. lockCode:self.multipleTableList[i].roomcode2,
  382. roomLocation:self.multipleTableList[i].roomlocation,
  383. roomName:self.multipleTableList[i].roomname,
  384. }
  385. for(let o=0;o<self.userListOption.length;o++){
  386. if(self.multipleTableList[i].safeUserId == self.userListOption[o].id){
  387. minObj.safeUserId = self.userListOption[o].id;
  388. minObj.safeUserName = self.userListOption[o].user;
  389. minObj.safeUserPhone = self.userListOption[o].phone;
  390. }
  391. }
  392. obj.slSubjectList.push(minObj);
  393. }
  394. subjectRelation(obj).then(response => {
  395. this.addTypeOne = false;
  396. this.$set(this,'multipleTableList',[]);
  397. this.$set(this.queryParams,'pageNumber',1);
  398. this.subjectRelationList();
  399. this.msgSuccess(response.msg);
  400. });
  401. },
  402. listLockRoom(){
  403. this.$set(this,'multipleTableList',[]);
  404. this.$set(this.queryParams,'pageNumber',1);
  405. this.addTypeOne = true;
  406. let obj = JSON.parse(JSON.stringify(this.queryParams))
  407. obj.subjectId = this.subjectData.id;
  408. listLockRoom(this.queryParams).then(response => {
  409. for(let i=0;i<response.rows.length;i++){
  410. }
  411. this.$set(this,'tableList',response.rows);
  412. this.$set(this,'total',response.total);
  413. });
  414. },
  415. //删除门禁
  416. delLockRoom(item){
  417. this.$confirm('确认要删除该智能门禁?', "警告", {
  418. confirmButtonText: "确定",
  419. cancelButtonText: "取消",
  420. type: "warning"
  421. }).then(() => {
  422. // 确定
  423. delSubjectRelation(item.id).then((response) => {
  424. this.msgSuccess(response.msg)
  425. this.addType = false;
  426. this.subjectRelationList();
  427. });
  428. }).catch(function() {
  429. // 取消
  430. });
  431. },
  432. // 提交
  433. submitForm() {
  434. this.$refs["form"].validate(valid => {
  435. if (valid) {
  436. if(this.upType == 1){
  437. //新增传感器
  438. this.addSensor();
  439. }else if(this.upType == 5){
  440. //编辑传感器
  441. this.putSensor();
  442. }else if(this.upType == 2){
  443. //新增一体机
  444. this.addHardware();
  445. }else if(this.upType == 6){
  446. //编辑一体机
  447. this.putHardware();
  448. }else if(this.upType == 3){
  449. //新增控制设备
  450. this.addHardwareTwo();
  451. }else if(this.upType == 7){
  452. //编辑控制设备
  453. this.putHardwareTwo();
  454. }else if(this.upType == 4){
  455. //新增控制设备
  456. this.addHardwareThree();
  457. }else if(this.upType == 8){
  458. //编辑控制设备
  459. this.putHardwareThree();
  460. }
  461. }
  462. });
  463. },
  464. //新增摄像头
  465. addHardwareThree(){
  466. let obj = {
  467. type:4,
  468. hardwareNum:this.form.hardwareNum,
  469. subjectId:this.subjectData.id,
  470. deptId:this.subjectData.deptId,
  471. deptName:this.subjectData.deptName,
  472. }
  473. addHardware(obj).then(response => {
  474. this.msgSuccess(response.msg)
  475. this.addType = false;
  476. this.listBySubjectId();
  477. });
  478. },
  479. //编辑摄像头
  480. putHardwareThree(){
  481. let obj = {
  482. id:this.form.id,
  483. hardwareNum:this.form.hardwareNum,
  484. subjectId:this.form.subjectId,
  485. deptId:this.form.deptId,
  486. deptName:this.form.deptName,
  487. }
  488. putHardware(obj).then(response => {
  489. this.msgSuccess(response.msg)
  490. this.addType = false;
  491. this.listBySubjectId();
  492. });
  493. },
  494. //删除摄像头
  495. delHardwareThree(item){
  496. this.$confirm('确认要删除该摄像头?', "警告", {
  497. confirmButtonText: "确定",
  498. cancelButtonText: "取消",
  499. type: "warning"
  500. }).then(() => {
  501. // 确定
  502. delHardware(item.id).then((response) => {
  503. this.msgSuccess(response.msg)
  504. this.addType = false;
  505. this.listBySubjectId();
  506. });
  507. }).catch(function() {
  508. // 取消
  509. });
  510. },
  511. //新增控制设备
  512. addHardwareTwo(){
  513. let obj = {
  514. type:this.form.type,
  515. hardwareType:this.form.hardwareType,
  516. relayCode:this.form.relayCode,
  517. bit:this.form.bit,
  518. configName:this.form.configName,
  519. configStatus:this.form.configStatus,
  520. subjectId:this.subjectData.id,
  521. deptId:this.subjectData.deptId,
  522. deptName:this.subjectData.deptName,
  523. }
  524. addHardware(obj).then(response => {
  525. this.msgSuccess(response.msg)
  526. this.addType = false;
  527. this.listBySubjectId();
  528. });
  529. },
  530. //编辑控制设备
  531. putHardwareTwo(){
  532. let obj = {
  533. id:this.form.id,
  534. hardwareType:this.form.hardwareType,
  535. relayCode:this.form.relayCode,
  536. bit:this.form.bit,
  537. configName:this.form.configName,
  538. configStatus:this.form.configStatus,
  539. subjectId:this.form.subjectId,
  540. deptId:this.form.deptId,
  541. deptName:this.form.deptName,
  542. }
  543. putHardware(obj).then(response => {
  544. this.msgSuccess(response.msg)
  545. this.addType = false;
  546. this.listBySubjectId();
  547. });
  548. },
  549. //删除控制设备
  550. delHardwareTwo(item){
  551. this.$confirm('确认要删除该一体机?', "警告", {
  552. confirmButtonText: "确定",
  553. cancelButtonText: "取消",
  554. type: "warning"
  555. }).then(() => {
  556. // 确定
  557. delHardware(item.id).then((response) => {
  558. this.msgSuccess(response.msg)
  559. this.addType = false;
  560. this.listBySubjectId();
  561. });
  562. }).catch(function() {
  563. // 取消
  564. });
  565. },
  566. //添加一体机
  567. addHardware(){
  568. let obj = {
  569. type:0,
  570. name:this.form.name,
  571. pcType:this.form.pcType,
  572. hardwareNum:this.form.hardwareNum,
  573. subjectId:this.subjectData.id,
  574. deptId:this.subjectData.deptId,
  575. deptName:this.subjectData.deptName,
  576. }
  577. addHardware(obj).then(response => {
  578. this.msgSuccess(response.msg)
  579. this.addType = false;
  580. this.listBySubjectId();
  581. });
  582. },
  583. //编辑一体机
  584. putHardware(){
  585. let obj = {
  586. id:this.form.id,
  587. name:this.form.name,
  588. pcType:this.form.pcType,
  589. hardwareNum:this.form.hardwareNum,
  590. }
  591. putHardware(obj).then(response => {
  592. this.msgSuccess(response.msg)
  593. this.addType = false;
  594. this.listBySubjectId();
  595. });
  596. },
  597. //删除一体机
  598. delHardware(item){
  599. this.$confirm('确认要删除该一体机?', "警告", {
  600. confirmButtonText: "确定",
  601. cancelButtonText: "取消",
  602. type: "warning"
  603. }).then(() => {
  604. // 确定
  605. delHardware(item.id).then((response) => {
  606. this.msgSuccess(response.msg)
  607. this.addType = false;
  608. this.listBySubjectId();
  609. });
  610. }).catch(function() {
  611. // 取消
  612. });
  613. },
  614. //添加传感器
  615. addSensor(){
  616. let obj = {
  617. type:this.form.type,
  618. gatewayId:this.form.gatewayId,
  619. routeNum:this.form.routeNum,
  620. configName:this.form.configName,
  621. configStatus:this.form.configStatus,
  622. subjectId:this.subjectData.id
  623. }
  624. addSensor(obj).then(response => {
  625. this.msgSuccess(response.msg)
  626. this.addType = false;
  627. this.listBySubjectId();
  628. });
  629. },
  630. //编辑传感器
  631. putSensor(){
  632. let obj = {
  633. type:this.form.type,
  634. id:this.form.id,
  635. gatewayId:this.form.gatewayId,
  636. routeNum:this.form.routeNum,
  637. configName:this.form.configName,
  638. configStatus:this.form.configStatus,
  639. }
  640. putSensor(obj).then(response => {
  641. this.msgSuccess(response.msg)
  642. this.addType = false;
  643. this.listBySubjectId();
  644. });
  645. },
  646. //删除传感器
  647. delSensor(item){
  648. this.$confirm('确认要删除该传感器?', "警告", {
  649. confirmButtonText: "确定",
  650. cancelButtonText: "取消",
  651. type: "warning"
  652. }).then(() => {
  653. // 确定
  654. delSensor(item.id).then((response) => {
  655. this.msgSuccess(response.msg)
  656. this.addType = false;
  657. this.listBySubjectId();
  658. });
  659. }).catch(function() {
  660. // 取消
  661. });
  662. },
  663. //添加
  664. addData(type){
  665. // this.resetForm("form");
  666. if(type == 1){
  667. this.title = '新增传感器';
  668. this.$set(this,'form',{
  669. type:"",
  670. gatewayId:"",
  671. routeNum:"",
  672. configName:"",
  673. configStatus:"",
  674. });
  675. }else if(type == 2){
  676. this.title = '新增一体机';
  677. this.$set(this,'form',{
  678. name:"",
  679. pcType:"",
  680. hardwareNum:"",
  681. });
  682. }else if(type == 3){
  683. this.title = '新增控制设备';
  684. this.form.hardwareType = 1;
  685. this.disabledType = false;
  686. this.$set(this,'form',{
  687. type:"",
  688. hardwareType:"",
  689. relayCode:"",
  690. bit:"",
  691. configName:"",
  692. configStatus:"",
  693. });
  694. }else if(type == 4){
  695. this.title = '新增摄像头';
  696. this.$set(this,'form',{
  697. hardwareNum:"",
  698. });
  699. }
  700. this.addType = true;
  701. this.upType = type;
  702. },
  703. //编辑
  704. editData(type,row){
  705. if(type == 5){
  706. this.title = '编辑传感器';
  707. this.$set(this,'form',JSON.parse(JSON.stringify(row)));
  708. this.$set(this.form,'type',JSON.parse(JSON.stringify(row.type.enumName)));
  709. }else if(type == 6){
  710. this.title = '编辑一体机';
  711. this.$set(this,'form',JSON.parse(JSON.stringify(row)));
  712. this.$set(this.form,'pcType',JSON.parse(JSON.stringify(row.pcType+'')));
  713. }else if(type == 7){
  714. this.title = '编辑控制设备';
  715. this.disabledType = true;
  716. this.$set(this,'form',JSON.parse(JSON.stringify(row)));
  717. this.$set(this.form,'type',JSON.parse(JSON.stringify(row.type.code+'')));
  718. }else if(type == 8){
  719. this.title = '编辑摄像头';
  720. this.$set(this,'form',JSON.parse(JSON.stringify(row)));
  721. }
  722. this.addType = true;
  723. this.upType = type;
  724. },
  725. //获取锁列表
  726. subjectRelationList(){
  727. let obj = {
  728. subjectId:this.subjectData.id
  729. };
  730. subjectRelationList(obj).then(response => {
  731. this.$set(this,'listZnmj',response.rows);
  732. });
  733. },
  734. //获取列表
  735. listBySubjectId(){
  736. let obj = {
  737. subjectId:this.subjectData.id
  738. };
  739. console.log("obj",obj)
  740. listBySubjectId(obj).then(response => {
  741. this.$set(this,'listCgq',response.data.listCgq);
  742. this.$set(this,'listYtj',response.data.listYtj);
  743. this.$set(this,'listkzsb',response.data.listkzsb);
  744. this.$set(this,'listSpjk',response.data.listSpjk);
  745. });
  746. },
  747. //返回上一页
  748. backPage(){
  749. this.$parent.clickPage(1);
  750. },
  751. //传感器类型
  752. getSensorList(){
  753. getSensorList().then(response => {
  754. this.sensorAddOptions = response.data;
  755. });
  756. },
  757. // 多选框选中数据
  758. handleSelectionChange(selection) {
  759. let self = this;
  760. this.$refs.multipleTable.clearSelection();
  761. let list = [];
  762. for(let i=0;i<selection.length;i++){
  763. if(i>3){
  764. self.$refs.multipleTable.toggleRowSelection(selection[i],false);
  765. }else{
  766. list.push(selection[i])
  767. self.$refs.multipleTable.toggleRowSelection(selection[i],true);
  768. }
  769. }
  770. this.$set(this,'multipleTableList',list);
  771. if (selection.length>4){
  772. this.msgError("一次最多勾选4个智能门禁")
  773. }
  774. },
  775. /*===记录勾选数据===
  776. 需要再el-table 添加 :row-key="getRowKeys"
  777. 需要在selection 添加 :reserve-selection="true"
  778. */
  779. getRowKeys(row) {
  780. return row.id
  781. },
  782. }
  783. }
  784. </script>
  785. <style scoped lang="scss">
  786. .deviceList{
  787. flex:1;
  788. display: flex;
  789. flex-direction: column;
  790. padding-bottom:20px;
  791. border-radius:10px!important;
  792. margin:5px 20px 20px 10px!important;
  793. box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
  794. *{
  795. margin:0;
  796. }
  797. .title-box{
  798. display: flex;
  799. margin:0 20px;
  800. .left-title{
  801. flex:1;
  802. height:80px;
  803. line-height:80px;
  804. color:#0045AF;
  805. font-size:18px;
  806. }
  807. .right-button{
  808. margin:20px 0;
  809. }
  810. }
  811. .for-max-box{
  812. margin:0 40px;
  813. font-weight:500;
  814. .for-big-box{
  815. border: 1px solid #E0E0E0;
  816. display: inline-block;
  817. overflow: hidden;
  818. width:280px;
  819. min-height:130px;
  820. padding-bottom:10px;
  821. border-radius: 6px;
  822. margin:0 15px 15px 0;
  823. .for-title-p{
  824. background: rgba(182,214,254,1);
  825. color:#0183FA;
  826. font-size:16px;
  827. line-height:40px;
  828. display:block;
  829. overflow:hidden;
  830. text-overflow:ellipsis;
  831. white-space:nowrap;
  832. padding:0 16px;
  833. margin-bottom:10px;
  834. font-weight:700;
  835. }
  836. .for-text-box{
  837. display: flex;
  838. padding:0 23px;
  839. p{
  840. font-size:14px;
  841. line-height:30px;
  842. flex:1;
  843. }
  844. p:nth-child(1){
  845. text-align: left;
  846. color:#333;
  847. }
  848. p:nth-child(2){
  849. color:#999;
  850. text-align: right;
  851. overflow:hidden;
  852. text-overflow:ellipsis;
  853. white-space:nowrap;
  854. }
  855. }
  856. .for-button-box{
  857. display: flex;
  858. line-height:26px;
  859. margin-top:10px;
  860. p{
  861. text-align: center;
  862. font-size:14px;
  863. color:#666666;
  864. }
  865. p:nth-child(1){
  866. flex:1;
  867. cursor: pointer;
  868. i{
  869. color:#1151b4;
  870. margin-right:10px;
  871. }
  872. }
  873. p:nth-child(2){
  874. width:2px;
  875. height:14px;
  876. margin:6px 0;
  877. background: #CCCCCC;
  878. }
  879. p:nth-child(3){
  880. flex:1;
  881. cursor: pointer;
  882. i{
  883. color:#ff6868;
  884. margin-right:10px;
  885. }
  886. }
  887. }
  888. }
  889. .for-big-box-two{
  890. border: 1px solid #E0E0E0;
  891. display: inline-block;
  892. overflow: hidden;
  893. width:280px;
  894. min-height:158px;
  895. padding-bottom:10px;
  896. border-radius: 6px;
  897. margin:0 15px 15px 0;
  898. .for-title-p{
  899. background: rgba(182,214,254,1);
  900. color:#0183FA;
  901. font-size:16px;
  902. line-height:40px;
  903. display:block;
  904. overflow:hidden;
  905. text-overflow:ellipsis;
  906. white-space:nowrap;
  907. padding:0 16px;
  908. margin-bottom:10px;
  909. font-weight:700;
  910. }
  911. .for-text-box{
  912. display: flex;
  913. padding:0 23px;
  914. p{
  915. font-size:14px;
  916. line-height:30px;
  917. flex:1;
  918. }
  919. p:nth-child(1){
  920. text-align: left;
  921. color:#333;
  922. }
  923. p:nth-child(2){
  924. color:#999;
  925. text-align: right;
  926. overflow:hidden;
  927. text-overflow:ellipsis;
  928. white-space:nowrap;
  929. }
  930. }
  931. .for-button-box{
  932. display: flex;
  933. line-height:26px;
  934. margin-top:10px;
  935. p{
  936. text-align: center;
  937. font-size:14px;
  938. color:#666666;
  939. }
  940. p:nth-child(1){
  941. flex:1;
  942. cursor: pointer;
  943. i{
  944. color:#1151b4;
  945. margin-right:10px;
  946. }
  947. }
  948. p:nth-child(2){
  949. width:2px;
  950. height:14px;
  951. margin:6px 0;
  952. background: #CCCCCC;
  953. }
  954. p:nth-child(3){
  955. flex:1;
  956. cursor: pointer;
  957. i{
  958. color:#ff6868;
  959. margin-right:10px;
  960. }
  961. }
  962. }
  963. }
  964. .add-for-p{
  965. font-size:14px;
  966. border: 1px solid #E0E0E0;
  967. display: inline-block;
  968. overflow: hidden;
  969. width:280px;
  970. height:130px;
  971. line-height:130px;
  972. text-align: center;
  973. border-radius: 6px;
  974. color:#999999;
  975. cursor: pointer;
  976. margin:0 15px 15px 0;
  977. i{
  978. margin-right:10px;
  979. }
  980. }
  981. .add-for-p-two{
  982. font-size:14px;
  983. border: 1px solid #E0E0E0;
  984. display: inline-block;
  985. overflow: hidden;
  986. width:280px;
  987. height:158px;
  988. line-height:158px;
  989. text-align: center;
  990. border-radius: 6px;
  991. color:#999999;
  992. cursor: pointer;
  993. margin:0 15px 15px 0;
  994. i{
  995. margin-right:10px;
  996. }
  997. }
  998. }
  999. }
  1000. </style>