deviceListOne.vue 35 KB

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