index.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <!-- 硬件设备 -->
  2. <template>
  3. <div class="app-container hardwareEquipment">
  4. <div class="page-container hardwareEquipmentPage" v-if="pageType === 1">
  5. <div class="page-form-title-box">
  6. <el-form :model="queryParams" class="form-box" ref="queryForm"
  7. :inline="true" style="width:100%;">
  8. <el-form-item label="" prop="searchValue">
  9. <el-input
  10. maxLength="30"
  11. v-model="queryParams.searchValue"
  12. placeholder="请输入名称/编号"
  13. style="width: 200px"
  14. />
  15. </el-form-item>
  16. <el-form-item label="" prop="hardwareTypeId">
  17. <el-select v-model="queryParams.hardwareTypeId" placeholder="请选择类型"
  18. style="width: 160px">
  19. <el-option
  20. v-for="dict in typeList"
  21. :key="dict.hardwareTypeId"
  22. :label="dict.hardwareTypeName"
  23. :value="dict.hardwareTypeId"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="" prop="schoolId">
  28. <el-select v-model="queryParams.schoolId" @change="changeSchool"
  29. placeholder="请选择校区" style="width: 150px">
  30. <el-option v-for="(item,index) in schoolOption"
  31. :key="item.id"
  32. :label="item.name"
  33. :value="item.id"/>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item label="" prop="buildId">
  37. <el-select v-model="queryParams.buildId" @change="buildSchool"
  38. placeholder="请选择楼栋" style="width: 150px">
  39. <el-option v-for="(item,index) in buildOption"
  40. :key="item.id"
  41. :label="item.name"
  42. :value="item.id"/>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="" prop="subjectId">
  46. <el-select v-model="queryParams.subjectId"
  47. placeholder="请选择实验室" style="width: 150px">
  48. <el-option v-for="(item,index) in subjectOption"
  49. :key="item.subId"
  50. :label="item.subName"
  51. :value="item.subId"/>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="" prop="operatingState">
  55. <el-select v-model="queryParams.operatingState" placeholder="请选择工作状态"
  56. style="width: 160px">
  57. <el-option
  58. v-for="dict in operatingStateList"
  59. :key="dict.value"
  60. :label="dict.label"
  61. :value="dict.value"
  62. />
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item label="" prop="state">
  66. <el-select v-model="queryParams.state" placeholder="请选择状态"
  67. style="width: 160px">
  68. <el-option
  69. v-for="dict in optionList"
  70. :key="dict.value"
  71. :label="dict.label"
  72. :value="dict.value"
  73. />
  74. </el-select>
  75. </el-form-item>
  76. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  77. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  78. <p class="page-add-common-style-button"
  79. style="float: right;"
  80. @click="dialogFormReset"
  81. v-hasPermiRouter="['iot:hardware:add']"
  82. >新增</p>
  83. </el-form>
  84. </div>
  85. <div class="page-content-box">
  86. <el-table class="table-box" v-loading="loading" border :data="dataList">
  87. <el-table-column label="设备名" prop="hardwareName" show-overflow-tooltip/>
  88. <el-table-column label="编号" prop="hardwareNo" width="200" show-overflow-tooltip/>
  89. <el-table-column label="设备类型" prop="hardwareTypeName" width="200" show-overflow-tooltip/>
  90. <el-table-column label="实验室" prop="subjectName" width="200" show-overflow-tooltip>
  91. <template slot-scope="scope">{{scope.row.subjectName?scope.row.subjectName:'-'}}</template>
  92. </el-table-column>
  93. <el-table-column label="物联编号" prop="relayNum" width="200" show-overflow-tooltip>
  94. <template slot-scope="scope">{{scope.row.deviceNo?scope.row.deviceNo:'-'}}</template>
  95. </el-table-column>
  96. <el-table-column label="工作状态" prop="operatingState" width="100" show-overflow-tooltip>
  97. <template slot-scope="scope">
  98. <span v-if="scope.row.operatingState" style="color: #0183FA">运行中</span>
  99. <span v-if="!scope.row.operatingState">未运行</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="状态" prop="state" width="100" show-overflow-tooltip
  103. v-hasPermiRouter="['iot:hardware:edit']">
  104. <template slot-scope="scope">
  105. <el-switch
  106. @click.native="tableButton(5,scope.row)"
  107. class="switch captcha-img"
  108. :active-value="true"
  109. :inactive-value="false"
  110. active-color="#0183FA"
  111. inactive-color="#999"
  112. v-model="scope.row.state"
  113. active-text="启用"
  114. inactive-text="停用"
  115. disabled
  116. ></el-switch>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="创建时间" prop="createTime" width="200" show-overflow-tooltip>
  120. <template slot-scope="scope">
  121. <span>{{ parseTime(scope.row.createTime,'{y}-{m}-{d} {h}:{i}') }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="操作" width="200" show-overflow-tooltip v-if="tableButtonType">
  125. <template slot-scope="scope">
  126. <div class="table-button-box">
  127. <p class="table-button-null"></p>
  128. <p class="table-button-p"
  129. @click="tableButton(7,scope.row)"
  130. v-hasPermiRouter="['iot:hardware:detail']"
  131. >详情</p>
  132. <p class="table-button-p"
  133. @click="tableButton(3,scope.row)"
  134. v-hasPermiRouter="['iot:hardware:edit']"
  135. >编辑</p>
  136. <p class="table-button-p"
  137. @click="tableButton(4,scope.row)"
  138. v-hasPermiRouter="['iot:hardware:del']"
  139. >删除</p>
  140. <p class="table-button-null"></p>
  141. </div>
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. <pagination :page-sizes="[20, 30, 40, 50]"
  146. v-show="total>0"
  147. :total="total"
  148. :page.sync="queryParams.page"
  149. :limit.sync="queryParams.pageSize"
  150. @pagination="getList"
  151. />
  152. </div>
  153. </div>
  154. <info-page v-if="pageType === 2" :propsData="propsData"></info-page>
  155. <!--新增弹窗-->
  156. <el-dialog class="iotClassification-dialog" :title='dialogTitle' width="540px" append-to-body
  157. :visible.sync="dialogType" v-if="dialogType" @close="dialogOff()"
  158. :close-on-click-modal="false" :close-on-press-escape="false">
  159. <el-form :model="dialogForm" ref="dialogForm" :inline="true"
  160. :rules="dialogRules" class="addCheckPage-min" label-width="120px">
  161. <el-form-item label="名称" prop="hardwareName">
  162. <el-input v-model="dialogForm.hardwareName" placeholder="请输入名称"
  163. maxLength="20" style="width:320px;"/>
  164. </el-form-item>
  165. <el-form-item label="编号" prop="hardwareNo">
  166. <el-input v-model="dialogForm.hardwareNo" :disabled="!!dialogForm.id"
  167. placeholder="请输入编号" maxLength="50" style="width:320px;"/>
  168. </el-form-item>
  169. <el-form-item label="类型" prop="hardwareTypeId">
  170. <el-select v-model="dialogForm.hardwareTypeId" placeholder="请选择类型"
  171. style="width: 320px" @change="typeFun">
  172. <el-option
  173. v-for="dict in typeList"
  174. :key="dict.hardwareTypeId"
  175. :label="dict.hardwareTypeName"
  176. :value="dict.hardwareTypeId"
  177. />
  178. </el-select>
  179. </el-form-item>
  180. <el-form-item label="楼栋楼层:" prop="address">
  181. <el-cascader
  182. style="width:320px;"
  183. v-model="dialogForm.address"
  184. @change="cascaderChange"
  185. placeholder="请选择楼栋楼层"
  186. :props="{value: 'id', label: 'name',children:'buildFloorVoList'}"
  187. :options="treeOptions" :show-all-levels="false"></el-cascader>
  188. </el-form-item>
  189. <el-form-item label="实验室:" prop="subId">
  190. <el-select v-model="dialogForm.subId" placeholder="请选择实验室"
  191. @change="subChange"
  192. clearable style="width: 320px">
  193. <el-option v-for="item in subOptions" :key="item.subId" :label="item.subName+'('+item.roomNum+')'" :value="item.subId"/>
  194. </el-select>
  195. </el-form-item>
  196. <el-form-item label="物联设备" prop="deviceId">
  197. <el-select v-model="dialogForm.deviceId" @change="deviceChange" placeholder="请选择物联设备" style="width: 320px">
  198. <el-option
  199. v-for="dict in relayList"
  200. :key="dict.id"
  201. :label="dict.deviceName"
  202. :value="dict.id"
  203. />
  204. </el-select>
  205. </el-form-item>
  206. <el-form-item :label="reservedNameOne" prop="reservedOne" v-if="reservedTypeOne">
  207. <el-input v-model="dialogForm.reservedOne" :placeholder="'请输入'+reservedNameOne"
  208. maxLength="10" style="width:320px;"/>
  209. </el-form-item>
  210. <el-form-item :label="reservedNameTwo" prop="reservedTwo" v-if="reservedTypeTwo">
  211. <el-input v-model="dialogForm.reservedTwo" :placeholder="'请输入'+reservedNameTwo"
  212. maxLength="10" style="width:320px;"/>
  213. </el-form-item>
  214. <el-form-item :label="reservedNameThree" prop="reservedThree" v-if="reservedTypeThree">
  215. <el-input v-model="dialogForm.reservedThree" :placeholder="'请输入'+reservedNameThree"
  216. maxLength="10" style="width:320px;"/>
  217. </el-form-item>
  218. <el-form-item label="状态" prop="state">
  219. <el-radio-group v-model="dialogForm.state">
  220. <el-radio :label="true" style="margin-left:20px;">启用</el-radio>
  221. <el-radio :label="false">禁用</el-radio>
  222. </el-radio-group>
  223. </el-form-item>
  224. </el-form>
  225. <div slot="footer" class="dialog-footer dialog-footer-box">
  226. <p class="dialog-footer-button-null"></p>
  227. <p class="dialog-footer-button-info" @click="dialogOff()">取消</p>
  228. <p class="dialog-footer-button-primary" @click="dialogSubmit">提交</p>
  229. <p class="dialog-footer-button-null"></p>
  230. </div>
  231. </el-dialog>
  232. </div>
  233. </template>
  234. <script>
  235. import {
  236. iotHardwareAdd,
  237. iotHardwareUpdate,
  238. iotHardwareList,
  239. iotHardwareDelete,
  240. iotHardwareTypeFindHardwareType,
  241. iotAttributeDetail
  242. } from '@/api/iotDevice/index'
  243. import { systemBuildingGetTreeList, laboratorySubRelInfoGetListByFloor,iotDeviceFindByType } from '@/api/commonality/permission'
  244. import infoPage from "./infoPage.vue";
  245. export default {
  246. name: 'index',
  247. components: {
  248. infoPage,
  249. },
  250. data() {
  251. return {
  252. tableButtonType: this.hasPermiDom(['iot:hardware:edit', 'iot:hardware:del']),
  253. //页面状态
  254. pageType: 1,
  255. //页面遮罩
  256. loading: false,
  257. //下拉列表数据
  258. optionList: [{ value: true, label: '启用' }, { value: false, label: '停用' }],
  259. operatingStateList: [{ value: true, label: '运行中' }, { value: false, label: '未运行' }],
  260. terminalList: [{ value: 1, label: '1' }, { value: 2, label: '2' }, { value: 3, label: '3' }, {
  261. value: 4,
  262. label: '4'
  263. }, { value: 5, label: '5' }, { value: 6, label: '6' }, { value: 7, label: '7' }, { value: 8, label: '8' }],
  264. //查询条件
  265. queryParams: {
  266. page: 1,
  267. pageSize: 20,
  268. searchValue: '',
  269. hardwareTypeId: null,
  270. schoolId: null,
  271. buildId: null,
  272. subjectId: null,
  273. operatingState: null,
  274. state: null
  275. },
  276. typeList: [],//类型
  277. relayList: [],//继电器
  278. //列表数据
  279. dataList: [],
  280. //数据数量
  281. total: 0,
  282. //组件传参
  283. propsData: {},
  284. //弹窗相关
  285. subOptions:[],
  286. treeOptions:[],
  287. dialogTitle: '',
  288. dialogType: false,
  289. dialogForm: {},
  290. dialogRules: {
  291. hardwareName: [
  292. { required: true, message: '请输入名称', trigger: 'blur' },
  293. { required: true, message: '请输入名称', validator: this.spaceJudgment, trigger: 'blur' }
  294. ],
  295. hardwareNo: [
  296. { required: true, message: '请输入编号', trigger: 'blur' },
  297. { required: true, message: '请输入编号', validator: this.spaceJudgment, trigger: 'blur' }
  298. ],
  299. hardwareTypeId: [
  300. { required: true, message: '请选择类型', trigger: 'blur' },
  301. { required: true, message: '请选择类型', validator: this.spaceJudgment, trigger: 'blur' }
  302. ],
  303. deviceId: [
  304. { required: true, message: '请选择物联设备', trigger: 'blur' },
  305. { required: true, message: '请选择物联设备', validator: this.spaceJudgment, trigger: 'blur' }
  306. ],
  307. subjectId: [
  308. { required: true, message: '请搜索选择实验室', trigger: 'blur' },
  309. { required: true, message: '请搜索选择实验室', validator: this.spaceJudgment, trigger: 'blur' }
  310. ],
  311. relayId: [
  312. { required: true, message: '请选择继电器', trigger: 'blur' },
  313. { required: true, message: '请选择继电器', validator: this.spaceJudgment, trigger: 'blur' }
  314. ],
  315. relayBit: [
  316. { required: true, message: '请选择继电器端子', trigger: 'blur' },
  317. { required: true, message: '请选择继电器端子', validator: this.spaceJudgment, trigger: 'blur' }
  318. ],
  319. state: [
  320. { required: true, message: '请选择状态', trigger: 'blur' },
  321. { required: true, message: '请选择状态', validator: this.spaceJudgment, trigger: 'blur' }
  322. ],
  323. reservedOne: [
  324. { required: true, message: '请输入参数', trigger: 'blur' },
  325. { required: true, message: '请输入参数', validator: this.spaceJudgment, trigger: 'blur' }
  326. ],
  327. reservedTwo: [
  328. { required: true, message: '请输入参数', trigger: 'blur' },
  329. { required: true, message: '请输入参数', validator: this.spaceJudgment, trigger: 'blur' }
  330. ],
  331. reservedThree: [
  332. { required: true, message: '请输入参数', trigger: 'blur' },
  333. { required: true, message: '请输入参数', validator: this.spaceJudgment, trigger: 'blur' }
  334. ],
  335. address: [
  336. { required: true, message: "请选择楼栋楼层", trigger: "blur" },
  337. ],
  338. },
  339. //校区楼栋原始数据
  340. addressList: [],
  341. //校区下拉列表
  342. schoolOption: [],
  343. //楼栋下拉列表
  344. buildOption: [],
  345. //实验室下拉列表
  346. subjectOption: [],
  347. //物联分类下拉列表
  348. iotTypeOptions:[],
  349. //硬件参数数据
  350. reservedNameOne:'',
  351. reservedTypeOne:false,
  352. reservedNameTwo:'',
  353. reservedTypeTwo:false,
  354. reservedNameThree:'',
  355. reservedTypeThree:false,
  356. }
  357. },
  358. created() {
  359. },
  360. mounted() {
  361. this.systemBuildingGetTreeList()
  362. this.iotHardwareTypeFindHardwareType()
  363. this.getList()
  364. },
  365. methods: {
  366. //查询按钮
  367. handleQuery() {
  368. this.$set(this.queryParams, 'page', 1)
  369. this.getList()
  370. },
  371. //重置按钮
  372. resetQuery() {
  373. this.$set(this, 'buildOption', [])
  374. this.$set(this, 'subjectOption', [])
  375. this.$set(this, 'queryParams', {
  376. page: 1,
  377. pageSize: 20,
  378. searchValue: '',
  379. hardwareTypeId: null,
  380. schoolId: null,
  381. buildId: null,
  382. subjectId: null,
  383. operatingState: null,
  384. state: null
  385. })
  386. this.getList()
  387. },
  388. //获取类型
  389. iotHardwareTypeFindHardwareType() {
  390. let obj = {
  391. searchValue: ''
  392. }
  393. iotHardwareTypeFindHardwareType(obj).then(response => {
  394. this.$set(this, 'typeList', response.data)
  395. })
  396. },
  397. //楼栋楼层选中
  398. cascaderChange(val){
  399. laboratorySubRelInfoGetListByFloor({floorId:val[val.length-1]}).then(response => {
  400. this.$set(this.dialogForm,'subId','');
  401. this.$set(this,'subOptions',response.data);
  402. this.$set(this.dialogForm, 'deviceId', '')
  403. this.$set(this.dialogForm, 'deviceNo','')
  404. this.$set(this, 'reservedNameOne', '')
  405. this.$set(this, 'reservedTypeOne', false)
  406. this.$set(this, 'reservedNameTwo', '')
  407. this.$set(this, 'reservedTypeTwo', false)
  408. this.$set(this, 'reservedNameThree', '')
  409. this.$set(this, 'reservedTypeThree', false)
  410. this.$nextTick(()=>{
  411. this.iotDeviceFindByType();
  412. })
  413. })
  414. },
  415. //实验室选中
  416. subChange(){
  417. this.$set(this.dialogForm, 'deviceId', '')
  418. this.$set(this.dialogForm, 'deviceNo','')
  419. this.$set(this, 'reservedNameOne', '')
  420. this.$set(this, 'reservedTypeOne', false)
  421. this.$set(this, 'reservedNameTwo', '')
  422. this.$set(this, 'reservedTypeTwo', false)
  423. this.$set(this, 'reservedNameThree', '')
  424. this.$set(this, 'reservedTypeThree', false)
  425. this.$nextTick(()=>{
  426. this.iotDeviceFindByType();
  427. })
  428. },
  429. //类型选中
  430. typeFun(val) {
  431. let self = this;
  432. this.typeList.forEach((item) => {
  433. if(val == item.hardwareTypeId){
  434. self.$set(self.dialogForm, 'hardwareTypeKey', item.hardwareTypeKey)
  435. self.$set(self.dialogForm, 'hardwareTypeName', item.hardwareTypeName)
  436. self.$set(self.dialogForm, 'deviceTypeKey', item.deviceTypeKey)
  437. self.$set(self.dialogForm, 'deviceId', '')
  438. self.$set(self.dialogForm, 'deviceNo','')
  439. self.$set(self, 'reservedNameOne', '')
  440. self.$set(self, 'reservedTypeOne', false)
  441. self.$set(self, 'reservedNameTwo', '')
  442. self.$set(self, 'reservedTypeTwo', false)
  443. self.$set(self, 'reservedNameThree', '')
  444. self.$set(self, 'reservedTypeThree', false)
  445. self.$nextTick(()=>{
  446. self.iotDeviceFindByType();
  447. })
  448. }
  449. });
  450. },
  451. //属性选中
  452. deviceChange(val){
  453. let self = this;
  454. this.relayList.forEach((item) => {
  455. if(val == item.id){
  456. self.$set(self.dialogForm, 'deviceNo', item.deviceNo)
  457. self.$set(self.dialogForm, 'attributeId', item.attributeId)
  458. this.iotAttributeDetail(item.attributeId);
  459. }
  460. });
  461. },
  462. //查询物联分类属性详情
  463. iotAttributeDetail(attributeId){
  464. iotAttributeDetail({id:attributeId}).then(response => {
  465. let list = response.data.relateField?JSON.parse(response.data.relateField):[];
  466. list.forEach((item,index)=>{
  467. if(index == 0){
  468. if(item.state){
  469. this.$set(this, 'reservedNameOne', item.relateFieldName)
  470. this.$set(this, 'reservedTypeOne', true)
  471. }else{
  472. this.$set(this, 'reservedNameOne', '')
  473. this.$set(this, 'reservedTypeOne', false)
  474. }
  475. }else if(index == 1){
  476. if(item.state){
  477. this.$set(this, 'reservedNameTwo', item.relateFieldName)
  478. this.$set(this, 'reservedTypeTwo', true)
  479. }else{
  480. this.$set(this, 'reservedNameTwo', '')
  481. this.$set(this, 'reservedTypeTwo', false)
  482. }
  483. }else if(index == 2){
  484. if(item.state){
  485. this.$set(this, 'reservedNameThree', item.relateFieldName)
  486. this.$set(this, 'reservedTypeThree', true)
  487. }else{
  488. this.$set(this, 'reservedNameThree', '')
  489. this.$set(this, 'reservedTypeThree', false)
  490. }
  491. }
  492. })
  493. })
  494. },
  495. //根据类型查询物联设备
  496. iotDeviceFindByType() {
  497. if (this.dialogForm.address[0]&&this.dialogForm.deviceTypeKey){
  498. let obj = {
  499. floorId: this.dialogForm.address[this.dialogForm.address.length-1],
  500. subjectId: this.dialogForm.subId,
  501. typeKeyList: [this.dialogForm.deviceTypeKey]//(relay 继电器,sensor 传感器)
  502. }
  503. iotDeviceFindByType(obj).then(response => {
  504. this.$set(this, 'relayList', response.data)
  505. })
  506. }
  507. },
  508. //获取数据列表
  509. getList() {
  510. this.$set(this, 'loading', true)
  511. let obj = JSON.parse(JSON.stringify(this.queryParams))
  512. iotHardwareList(obj).then(response => {
  513. this.$set(this, 'loading', false)
  514. this.$set(this, 'dataList', response.data.records)
  515. this.$set(this, 'total', response.data.total)
  516. })
  517. },
  518. //操作按钮
  519. tableButton(type, row) {
  520. let self = this
  521. if (type == 3) {
  522. //编辑
  523. this.$set(this, 'dialogTitle', '编辑')
  524. let obj = JSON.parse(JSON.stringify(row))
  525. this.$set(this, 'dialogForm', {
  526. id: obj.id,
  527. hardwareName: obj.hardwareName,
  528. hardwareNo: obj.hardwareNo,
  529. hardwareTypeId: obj.hardwareTypeId,
  530. hardwareTypeName: obj.hardwareTypeName,
  531. hardwareTypeKey: obj.hardwareTypeKey,
  532. deviceTypeKey: obj.deviceTypeKey,
  533. deviceId: obj.deviceId,
  534. deviceNo: obj.deviceNo,
  535. attributeId:obj.attributeId,
  536. address:[obj.schoolId,obj.buildId,obj.floorId],
  537. subId:obj.subjectId,
  538. state: obj.state,
  539. reservedOne:obj.reservedOne,
  540. reservedTwo:obj.reservedTwo,
  541. reservedThree:obj.reservedThree,
  542. })
  543. laboratorySubRelInfoGetListByFloor({floorId:obj.floorId}).then(response => {
  544. this.$set(this,'subOptions',response.data);
  545. })
  546. this.iotAttributeDetail(row.attributeId);
  547. this.$nextTick(()=>{
  548. this.iotDeviceFindByType();
  549. })
  550. this.$set(this, 'dialogType', true)
  551. } else if (type == 4) {
  552. //删除
  553. this.$confirm('是否确认删除?', '警告', {
  554. confirmButtonText: '确定',
  555. cancelButtonText: '取消',
  556. type: 'warning'
  557. }).then(function() {
  558. }).then(() => {
  559. iotHardwareDelete({ id: row.id }).then(response => {
  560. self.msgSuccess(response.message)
  561. self.getList()
  562. })
  563. }).catch(() => {
  564. })
  565. } else if (type == 5) {
  566. //启用&停用
  567. let text = row.state ? '停用' : '启用'
  568. this.$confirm('是否确认' + text + '?', '警告', {
  569. confirmButtonText: '确定',
  570. cancelButtonText: '取消',
  571. type: 'warning'
  572. }).then(function() {
  573. }).then(() => {
  574. iotHardwareUpdate({ id: row.id, state: !row.state }).then(response => {
  575. self.msgSuccess(response.message)
  576. self.getList()
  577. })
  578. }).catch(() => {
  579. })
  580. } else if (type == 6) {
  581. //返回并刷新
  582. this.$set(this, 'pageType', 1)
  583. this.getList()
  584. }else if(type == 7){
  585. this.$set(this,'propsData',JSON.parse(JSON.stringify(row)));
  586. this.$set(this, 'pageType', 2)
  587. }
  588. },
  589. //**************************弹窗相关**************************
  590. //弹层关闭
  591. dialogOff() {
  592. this.$set(this, 'dialogType', false)
  593. },
  594. //弹层新增
  595. dialogFormReset() {
  596. this.$set(this, 'dialogTitle', '新增')
  597. this.$set(this, 'dialogForm', {
  598. hardwareName: '',
  599. hardwareNo: '',
  600. hardwareTypeId: '',
  601. hardwareTypeName: '',
  602. hardwareTypeKey: '',
  603. deviceTypeKey: '',
  604. deviceId: '',
  605. deviceNo: '',
  606. attributeId:'',
  607. address:[],
  608. subId:'',
  609. state: true,
  610. reservedOne:'',
  611. reservedTwo:'',
  612. reservedThree:'',
  613. })
  614. this.$set(this, 'reservedNameOne', '')
  615. this.$set(this, 'reservedTypeOne', false)
  616. this.$set(this, 'reservedNameTwo', '')
  617. this.$set(this, 'reservedTypeTwo', false)
  618. this.$set(this, 'reservedNameThree', '')
  619. this.$set(this, 'reservedTypeThree', false)
  620. this.$set(this, 'relayList', [])
  621. this.$set(this, 'dialogType', true)
  622. },
  623. //dialog提交按钮
  624. dialogSubmit() {
  625. let self = this;
  626. this.$refs['dialogForm'].validate(valid => {
  627. if (valid) {
  628. let obj = {
  629. id: this.dialogForm.id,
  630. hardwareName: this.dialogForm.hardwareName,
  631. hardwareNo: this.dialogForm.hardwareNo,
  632. hardwareTypeId: this.dialogForm.hardwareTypeId,
  633. hardwareTypeName: this.dialogForm.hardwareTypeName,
  634. hardwareTypeKey: this.dialogForm.hardwareTypeKey,
  635. deviceTypeKey: this.dialogForm.deviceTypeKey,
  636. deviceId: this.dialogForm.deviceId,
  637. deviceNo: this.dialogForm.deviceNo,
  638. attributeId: this.dialogForm.attributeId,
  639. state: this.dialogForm.state,
  640. reservedOne:this.reservedTypeOne?this.dialogForm.reservedOne:'',
  641. reservedTwo:this.reservedTypeTwo?this.dialogForm.reservedTwo:'',
  642. reservedThree:this.reservedTypeThree?this.dialogForm.reservedThree:'',
  643. }//获取校区-楼栋-楼层数据
  644. if(self.dialogForm.address[0]){
  645. for(let i=0;i<self.treeOptions.length;i++){
  646. if(self.treeOptions[i].id == self.dialogForm.address[0]){
  647. for(let o=0;o<self.treeOptions[i].buildFloorVoList.length;o++){
  648. if(self.treeOptions[i].buildFloorVoList[o].id == self.dialogForm.address[1]){
  649. for(let x=0;x<self.treeOptions[i].buildFloorVoList[o].buildFloorVoList.length;x++){
  650. if(self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].id == self.dialogForm.address[2]){
  651. obj.schoolId = self.treeOptions[i].id;
  652. obj.schoolName = self.treeOptions[i].name;
  653. obj.buildId = self.treeOptions[i].buildFloorVoList[o].id;
  654. obj.buildName = self.treeOptions[i].buildFloorVoList[o].name;
  655. obj.floorId = self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].id;
  656. obj.floorName = self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].name;
  657. }
  658. }
  659. }
  660. }
  661. }
  662. }
  663. }else{
  664. obj.schoolId = '';
  665. obj.schoolName = '';
  666. obj.buildId = '';
  667. obj.buildName = '';
  668. obj.floorId = '';
  669. obj.floorName = '';
  670. }
  671. //获取实验室数据
  672. if(this.dialogForm.subId){
  673. for(let i=0;i<self.subOptions.length;i++){
  674. if(self.subOptions[i].subId == self.dialogForm.subId){
  675. obj.subjectId = self.subOptions[i].subId
  676. obj.subjectName = self.subOptions[i].subName
  677. obj.room = self.subOptions[i].roomNum
  678. }
  679. }
  680. }else{
  681. obj.subjectId = ''
  682. obj.subjectName = ''
  683. obj.room = ''
  684. }
  685. if (this.dialogForm.id) {
  686. iotHardwareUpdate(obj).then(response => {
  687. this.msgSuccess(response.message)
  688. this.dialogOff()
  689. this.getList()
  690. })
  691. } else {
  692. iotHardwareAdd(obj).then(response => {
  693. this.msgSuccess(response.message)
  694. this.dialogOff()
  695. this.getList()
  696. })
  697. }
  698. }
  699. })
  700. },
  701. //获取校区
  702. systemBuildingGetTreeList() {
  703. //楼栋楼层
  704. systemBuildingGetTreeList({}).then(response => {
  705. let listOne = []
  706. for (let i = 0; i < response.data.length; i++) {
  707. listOne.push({
  708. id: response.data[i].id,
  709. name: response.data[i].name
  710. })
  711. }
  712. this.$set(this, 'schoolOption', listOne)
  713. this.$set(this, 'addressList', response.data)
  714. let list = JSON.parse(JSON.stringify(response.data));
  715. pushNode(list)
  716. function pushNode(list){
  717. for(let i=0;i<list.length;i++){
  718. if(list[i].type != 3 && !list[i].buildFloorVoList[0]){
  719. list.splice(i,1)
  720. i--
  721. }else if(list[i].type == 3){
  722. delete list[i].buildFloorVoList;
  723. }else{
  724. pushNode(list[i].buildFloorVoList)
  725. }
  726. }
  727. }
  728. this.$set(this,'treeOptions',list);
  729. })
  730. },
  731. //校区选中
  732. changeSchool(val) {
  733. let self = this
  734. let list = []
  735. for (let i = 0; i < self.addressList.length; i++) {
  736. if (val == self.addressList[i].id && self.addressList[i].buildFloorVoList[0]) {
  737. for (let o = 0; o < self.addressList[i].buildFloorVoList.length; o++) {
  738. list.push({
  739. id: self.addressList[i].buildFloorVoList[o].id,
  740. name: self.addressList[i].buildFloorVoList[o].name
  741. })
  742. }
  743. }
  744. }
  745. this.$set(this.queryParams, 'buildId', null)
  746. this.$set(this.queryParams, 'subjectId', null)
  747. this.$set(this, 'buildOption', list)
  748. this.$set(this, 'subjectOption', [])
  749. },
  750. //楼栋选中
  751. buildSchool(val) {
  752. laboratorySubRelInfoGetListByFloor({ buildId: val }).then(response => {
  753. this.$set(this.queryParams, 'subjectId', null)
  754. this.$set(this, 'subjectOption', response.data)
  755. })
  756. }
  757. }
  758. }
  759. </script>
  760. <style scoped lang="scss">
  761. .hardwareEquipment {
  762. .hardwareEquipmentPage {
  763. }
  764. }
  765. </style>