videoSurveillance.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <!--硬件管理/视频监控-->
  2. <template>
  3. <div class="videoSurveillance">
  4. <!--<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" class="form-box">-->
  5. <!--<el-form-item label="学院" prop="deptId">-->
  6. <!--<el-select v-model="queryParams.deptId" placeholder="请选择学院" clearable @change="handleNodeClick">-->
  7. <!--<el-option-->
  8. <!--v-for="dict in deptOptions"-->
  9. <!--:key="dict.deptId"-->
  10. <!--:label="dict.deptName"-->
  11. <!--:value="dict.deptId"-->
  12. <!--&gt;</el-option>-->
  13. <!--</el-select>-->
  14. <!--</el-form-item>-->
  15. <!--<el-form-item label="实验室" prop="subjectId">-->
  16. <!--<el-select v-model="queryParams.subjectId" clearable placeholder="请选择实验室">-->
  17. <!--<el-option-->
  18. <!--v-for="item in subjectOptions"-->
  19. <!--:key="item.id"-->
  20. <!--:label="item.name"-->
  21. <!--:value="item.id">-->
  22. <!--</el-option>-->
  23. <!--</el-select>-->
  24. <!--</el-form-item>-->
  25. <!--<el-form-item label="状态" prop="operate">-->
  26. <!--<el-select v-model="queryParams.operate" placeholder="请选择状态" clearable size="small">-->
  27. <!--<el-option label="在线" value="ONLINE" />-->
  28. <!--<el-option label="离线" value="OFFLINE" />-->
  29. <!--<el-option label="开启" value="OPEN" />-->
  30. <!--<el-option label="关闭" value="CLOSE" />-->
  31. <!--</el-select>-->
  32. <!--</el-form-item>-->
  33. <!--<el-form-item style="float: right;">-->
  34. <!--<el-col :span="1.5">-->
  35. <!--<p class="add-button-one-120"-->
  36. <!--@click="handleAdd"-->
  37. <!--v-hasPermi="['laboratory:hardware:add']"-->
  38. <!--&gt;<i class="el-icon-plus"></i>新增硬件</p>-->
  39. <!--</el-col>-->
  40. <!--</el-form-item>-->
  41. <!--<el-form-item>-->
  42. <!--<p class="inquire-button-one" @click="handleQuery">查询</p>-->
  43. <!--<p class="reset-button-one" @click="resetQuery">重置</p>-->
  44. <!--</el-form-item>-->
  45. <!--</el-form>-->
  46. <el-table v-loading="loading" border :data="hardwareList" @selection-change="handleSelectionChange">
  47. <el-table-column label="名称" align="left" prop="name" />
  48. <el-table-column label="学院" align="left" prop="deptName" />
  49. <el-table-column label="实验室" align="left" prop="subjectName" />
  50. <el-table-column label="设备编号" align="left" prop="hardwareNum" />
  51. <el-table-column label="状态" align="left" >
  52. <template slot-scope="scope">
  53. <!-- <p :class="'table-type-color-red'">{{'离线'}}</p> -->
  54. <p :class="scope.row.status==0?'table-type-color-ash':(scope.row.status==2?'table-type-color-green':(!scope.row.status?'table-type-color-red':''))">{{scope.row.status==0?'离线':(scope.row.status==2?'在线':(!scope.row.status?'离线':''))}}</p>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120" v-if="tableButtonType">
  58. <template slot-scope="scope">
  59. <div class="button-box">
  60. <!--<p class="table-min-button"-->
  61. <!--@click="handleView(scope.row)"-->
  62. <!--style="margin-right:20px;"-->
  63. <!--v-hasPermi="['laboratory:hardware:query']"-->
  64. <!--&gt;查看</p>-->
  65. <el-dropdown @command="moreClick" v-hasPermi="['laboratory:hardware:query','laboratory:hardware:edit','laboratory:hardware:remove']">
  66. <p class="table-min-button">更多>></p>
  67. <el-dropdown-menu slot="dropdown">
  68. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:1}"
  69. v-hasPermiAnd="['laboratory:hardware:query','laboratory:hardware:edit']">修改设备</el-dropdown-item>
  70. <el-dropdown-item style="margin:0 10px;" :command="{row:scope.row,command:2}"
  71. v-hasPermi="['laboratory:hardware:remove']">删除设备</el-dropdown-item>
  72. </el-dropdown-menu>
  73. </el-dropdown>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <pagination :page-sizes="[20, 30, 40, 50]"
  79. v-show="total>0"
  80. :total="total"
  81. layout="total, prev, pager, next, sizes, jumper"
  82. :page.sync="queryParams.pageNum"
  83. :limit.sync="queryParams.pageSize"
  84. @pagination="getList"
  85. />
  86. <el-drawer
  87. class="videoSurveillance-drawer"
  88. :visible.sync="drawer"
  89. direction="rtl"
  90. ref="drawer"
  91. :with-header="false"
  92. :show-close="false"
  93. :before-close="handleClose">
  94. <div class="videoSurveillance-drawer-max-box">
  95. <div class="videoSurveillance-drawer-content">
  96. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  97. <el-form-item label="硬件名称" prop="name">
  98. <el-input
  99. :disabled="disabledType"
  100. v-model="form.name"
  101. placeholder="请输入硬件名称"
  102. clearable
  103. size="small"
  104. maxLength="8"
  105. />
  106. </el-form-item>
  107. <el-form-item label="硬件类型" v-if="pageType==''" prop="type">
  108. <el-select v-model="form.type" placeholder="请选择硬件类型">
  109. <el-option v-for="hardType in hardTypeOptions"
  110. :key="hardType.enumName"
  111. :label="hardType.name"
  112. :value="hardType.enumName">
  113. </el-option>
  114. </el-select>
  115. </el-form-item>
  116. <el-form-item label="设备编号" prop="hardwareNum">
  117. <el-input
  118. :disabled="disabledType"
  119. v-model="form.hardwareNum"
  120. placeholder="请输入设备编号"
  121. clearable
  122. maxlength="30"
  123. size="small"
  124. />
  125. </el-form-item>
  126. <el-form-item label="实验室" prop="subjectId">
  127. <el-select v-model="form.subjectId" placeholder="请选择实验室" :disabled="disabledType">
  128. <el-tooltip class="item" effect="dark" :content="lab.name" placement="top" v-for="lab in labListOptions">
  129. <el-option style="max-width: 200px"
  130. :key="lab.id"
  131. :label="lab.name"
  132. :value="lab.id">
  133. </el-option>
  134. </el-tooltip>
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item label="硬件IP" prop="ipAddress">
  138. <el-input
  139. :disabled="disabledType"
  140. v-model="form.ipAddress"
  141. placeholder="请输入硬件IP"
  142. clearable
  143. size="small"
  144. maxLength="20"
  145. />
  146. </el-form-item>
  147. <!--<el-form-item label="硬件位置" prop="position">-->
  148. <!--<div class="map-box" :style="'width:'+mapData.widthData*3+'px;height:'+mapData.heightData*3+'px;'">-->
  149. <!--<div v-for="(item,index1) in mapData.list" v-if="isUpdate"-->
  150. <!--:style="'top:'+item.y*3+'px;left:'+item.x*3+'px;'"-->
  151. <!--@mouseenter="moveClick(index1)"-->
  152. <!--@mousedown="move">-->
  153. <!--{{form.name?form.name:'未命名'}}-->
  154. <!--</div>-->
  155. <!--<p class="map-p" v-for="(item) in mapList" :style="'top:'+item.y*3+'px;left:'+item.x*3+'px;'">{{item.name}}</p>-->
  156. <!--</div>-->
  157. <!--</el-form-item>-->
  158. </el-form>
  159. </div>
  160. <div class="videoSurveillance-bottom-button-box">
  161. <p></p>
  162. <p @click="offDrawer">{{buttonType?'取消':'关闭'}}</p>
  163. <p @click="submitForm" v-if="buttonType">提交</p>
  164. </div>
  165. </div>
  166. </el-drawer>
  167. </div>
  168. </template>
  169. <script>
  170. import { subjectDictList } from "@/api/laboratory/group";
  171. import { listDepartments } from "@/api/system/dept";
  172. import { listHardware, getHardware, delHardware, addHardware, updateHardware,queryHardwareType,getHardwareDetail,getSubjectLayout } from "@/api/laboratory/hardware";
  173. import { done } from 'element-ui'
  174. import { treeselect } from "@/api/system/dept";
  175. import Treeselect from "@riophae/vue-treeselect";
  176. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  177. import { listRelay } from "@/api/laboratory/relay";
  178. export default {
  179. props:{
  180. pageType:{},
  181. queryParams:{}
  182. },
  183. components: { Treeselect },
  184. name: "videoSurveillance",
  185. data() {
  186. return {
  187. tableButtonType:this.hasPermiDom(['laboratory:hardware:query','laboratory:hardware:query','laboratory:hardware:edit','laboratory:hardware:remove']),
  188. index:'',
  189. // 遮罩层
  190. loading: true,
  191. // 选中数组
  192. ids: [],
  193. // 非单个禁用
  194. single: true,
  195. // 非多个禁用
  196. multiple: true,
  197. // 显示搜索条件
  198. showSearch: true,
  199. // 总条数
  200. total: 0,
  201. // 硬件表格数据
  202. hardwareList: [],
  203. // 弹出层标题
  204. title: "",
  205. // 是否显示弹出层
  206. open: false,
  207. // 部门树选项
  208. deptOptions: [],
  209. subjectOptions: undefined,
  210. isUpdate:false,
  211. // 查询参数
  212. // queryParams: {
  213. // pageNum: 1,
  214. // pageSize:20,
  215. // name: null,
  216. // factory: null,
  217. // type: null,
  218. // hardwareNum: null,
  219. // subjectId: null,
  220. // deptId: null,
  221. // deptName: null,
  222. // operate: null,
  223. // userId: null,
  224. // status: null
  225. // },
  226. hardTypeOptions:{},
  227. // 表单参数
  228. form: {},
  229. // 表单校验
  230. rules: {
  231. name: [
  232. { required: true, message: "请输入硬件名称", trigger: "blur" },
  233. { required: true, message: "请输入硬件名称", validator: this.spaceJudgment, trigger: "blur" }
  234. ],
  235. type: [
  236. { required: true, message: "请选择硬件类型", trigger: "blur" }
  237. ],
  238. hardwareNum: [
  239. { required: true, message: "请输入设备编号", trigger: "blur" },
  240. { required: true, message: "请输入设备编号", validator: this.spaceJudgment, trigger: "blur" }
  241. ],
  242. subjectId:[
  243. { required: true, message: "请选择实验室", trigger: "blur" },
  244. ],
  245. ipAddress: [
  246. { required: true, message: "请输入硬件IP", trigger: "blur" },
  247. { required: true, message: "请输入硬件IP", validator: this.spaceJudgment, trigger: "blur" }
  248. ],
  249. // position: [
  250. // { required: true, message: "请选择实验室", trigger: "blur" },
  251. // ],
  252. },
  253. labListOptions:{},
  254. // 关联实验室弹窗开关
  255. drawer:false,
  256. drawerData:{
  257. name:"甲烷检测实验室",
  258. text:"描述内容描述内容描述内容描述内容描述内容描述内容描述内容描述内容描述内容描述内容",
  259. img:"",
  260. },
  261. mapData:{
  262. widthData:"60",
  263. heightData:"123",
  264. list:[
  265. {
  266. id: "",
  267. top:0,
  268. left:0
  269. }
  270. ]
  271. },
  272. mapList:[],
  273. buttonType:false,
  274. disabledType:false,
  275. // 继电器
  276. // relayList: [],
  277. // relayNumList:[],
  278. };
  279. },
  280. created() {
  281. this.getList();
  282. this.getDeptList();
  283. },
  284. methods: {
  285. //删除
  286. delBox(item){
  287. console.log(item)
  288. },
  289. moveClick(index){
  290. this.moveIndex = index
  291. console.log(",index",index)
  292. },
  293. //锚点拖动
  294. move(e){
  295. let odiv = e.target; //获取目标元素
  296. //算出鼠标相对元素的位置
  297. let disX = e.clientX - odiv.offsetLeft;
  298. let disY = e.clientY - odiv.offsetTop;
  299. document.onmousemove = (e)=>{ //鼠标按下并移动的事件
  300. //用鼠标的位置减去鼠标相对元素的位置,得到元素的位置
  301. let left = e.clientX - disX;
  302. let top = e.clientY - disY;
  303. //绑定元素位置到positionX和positionY上面
  304. //移动当前元素
  305. if(left>0&&left<(this.mapData.widthData*3-60)){
  306. odiv.style.left = left + 'px';
  307. this.mapData.list[this.moveIndex].left = left;
  308. this.mapData.list[this.moveIndex].minLeft = parseInt(left/6);
  309. }
  310. if(top>0&&top<(this.mapData.heightData*3-60)){
  311. odiv.style.top = top + 'px';
  312. this.mapData.list[this.moveIndex].top = top;
  313. this.mapData.list[this.moveIndex].minTop = parseInt(top/6);
  314. }
  315. };
  316. document.onmouseup = (e) => {
  317. document.onmousemove = null;
  318. document.onmouseup = null;
  319. };
  320. },
  321. getHardTypeList(){
  322. queryHardwareType().then(response => {
  323. if(response.code==200){
  324. this.hardTypeOptions=response.data;
  325. }
  326. console.log(this.hardTypeOptions)
  327. });
  328. },
  329. //关联实验室弹窗
  330. drawerBoxOnTwo(){
  331. this.drawerTwo = true;
  332. },
  333. //关联实验室弹窗
  334. drawerBoxOn(){
  335. this.drawer = true;
  336. },
  337. //关闭弹窗
  338. offDrawer(){
  339. this.$refs.drawer.closeDrawer();
  340. },
  341. //弹窗关闭前回调
  342. handleClose(done) {
  343. this.$confirm('确认关闭?')
  344. .then(_ => {
  345. done();
  346. })
  347. .catch(_ => {});
  348. },
  349. //更多选项
  350. moreClick(item){
  351. if(item.command == 1){
  352. this.disabledType = false;
  353. this.buttonType = true;
  354. this.handleUpdate(item.row)
  355. }else if(item.command == 2){
  356. this.handleDelete(item.row)
  357. }
  358. },
  359. /** 查询实验室字典列表 */
  360. getSubjectDictList (deptId) {
  361. this.subjectOptions = null;
  362. this.loading = true;
  363. // this.queryParams.deptId = deptId;
  364. let params = {};
  365. params.deptId = deptId;
  366. this.queryParams.subjectId = "";
  367. subjectDictList(params).then(response => {
  368. this.subjectOptions = response.data;
  369. this.loading = false;
  370. });
  371. },
  372. // loadRelayNum(e){
  373. // let self = this;
  374. // let num = ""
  375. // for(let i=0;i<self.relayList.length;i++){
  376. // if(self.relayList[i].code == e){
  377. // num = self.relayList[i].routeNum
  378. // }
  379. // }
  380. // let list = [];
  381. // for(let i=0;i<num;i++){
  382. // let obj = {
  383. // name:i+1
  384. // }
  385. // list.push(obj);
  386. // }
  387. // this.relayNumList = list;
  388. // },
  389. loadHardware(){
  390. let self = this;
  391. this.mapList = [];
  392. let newId = this.mapData.list[0].id;
  393. // this.mapData.list = [];
  394. let queryParam = {};
  395. if(this.form.id){
  396. queryParam.id = this.form.id;
  397. }else{
  398. queryParam.id = -1;
  399. }
  400. queryParam.subjectId = this.form.subjectId;
  401. getHardwareDetail(queryParam).then(response => {
  402. let subHardList = response.data.subjectHardPosiList;
  403. for(var i=0;i<subHardList.length;i++){
  404. if(response.data.subjectHardPosiList[i].id!=newId){
  405. this.mapList.push({"name":response.data.subjectHardPosiList[i].hardName,"y":(response.data.subjectHardPosiList[i].horizontalAxis/3).toFixed(0),"x":(response.data.subjectHardPosiList[i].verticalAxis/3).toFixed(0)});
  406. }
  407. }
  408. this.$forceUpdate()
  409. });
  410. getSubjectLayout(this.form.subjectId).then(response => {
  411. if(response.data){
  412. this.mapData.widthData = response.data.layWidth;
  413. this.mapData.heightData = response.data.layHeight;
  414. }else{
  415. this.mapData.widthData = 60;
  416. this.mapData.heightData = 123;
  417. }
  418. this.$forceUpdate()
  419. });
  420. let obj = JSON.parse(JSON.stringify(this.mapData.list[0]));
  421. obj.x = 0;
  422. obj.y = 0;
  423. obj.top = 0;
  424. obj.left = 0;
  425. this.mapData.list.splice(0,1);
  426. setTimeout(function(){
  427. self.mapData.list.push(obj);
  428. },50);
  429. this.$forceUpdate()
  430. // if(this.mapData.list[0]){
  431. // console.log("heightData",this.mapData.heightData)
  432. // console.log("y",this.mapData.list[0].top)
  433. // if(this.mapData.list[0].top-10>this.mapData.heightData){
  434. // console.log("heightData",this.mapData.heightData)
  435. // console.log("y",this.mapData.list[0].top)
  436. // this.mapData.list[0].top = stringify(this.mapData.heightData-10)
  437. // }
  438. // console.log("heightData",this.mapData.widthData)
  439. // console.log("x",this.mapData.list[0].left)
  440. // if(this.mapData.list[0].left-10>this.mapData.widthData){
  441. // console.log("heightData",this.mapData.widthData)
  442. // console.log("x",this.mapData.list[0].left)
  443. // this.mapData.list[0].left = stringify(this.mapData.heightData-10)
  444. // }
  445. // this.$forceUpdate()
  446. // }
  447. },
  448. /** 查询硬件列表 */
  449. getList() {
  450. this.loading = true;
  451. this.queryParams.type = this.pageType;
  452. console.log("this.queryParams.type",this.queryParams.type)
  453. listHardware(this.queryParams).then(response => {
  454. this.hardwareList = response.rows;
  455. this.total = response.total;
  456. this.loading = false;
  457. });
  458. },
  459. getLabList(){
  460. subjectDictList().then(response => {
  461. console.log(response)
  462. if(response.code==200){
  463. this.labListOptions=response.data;
  464. }
  465. });
  466. },
  467. // 取消按钮
  468. cancel() {
  469. this.open = false;
  470. this.reset();
  471. },
  472. /** 查询学院列表 */
  473. getDeptList() {
  474. listDepartments().then(response => {
  475. this.$set(this, 'deptOptions', response.data)
  476. });
  477. },
  478. // 筛选节点
  479. filterNode(value, data) {
  480. if (!value) return true;
  481. return data.label.indexOf(value) !== -1;
  482. },
  483. // 节点单击事件
  484. handleNodeClick(data) {
  485. this.queryParams.deptId = data;
  486. // console.log("data",data);
  487. this.getSubjectDictList(data);
  488. // this.getList();
  489. },
  490. // 表单重置
  491. reset() {
  492. this.form = {
  493. id: null,
  494. name: null,
  495. factory: null,
  496. type: null,
  497. hardwareNum: null,
  498. subjectId: null,
  499. deptId: null,
  500. deptName: null,
  501. operate: 0,
  502. createTime: null,
  503. userId: null,
  504. createBy: null,
  505. updateTime: null,
  506. updateBy: null,
  507. remark: null,
  508. hardwarePosition:{
  509. horizontalAxis:'',
  510. verticalAxis:''
  511. },
  512. mapData:{
  513. widthData:"60",
  514. heightData:"123",
  515. list:[
  516. {
  517. id: "",
  518. top:0,
  519. left:0
  520. }
  521. ]
  522. },
  523. mapList:[],
  524. // 弹窗确定按钮
  525. buttonType:false,
  526. };
  527. this.resetForm("form");
  528. },
  529. /** 搜索按钮操作 */
  530. handleQuery() {
  531. this.queryParams.pageNum = 1;
  532. this.getList();
  533. },
  534. /** 重置按钮操作 */
  535. resetQuery() {
  536. this.resetForm("queryForm");
  537. this.handleQuery();
  538. },
  539. // 多选框选中数据
  540. handleSelectionChange(selection) {
  541. this.ids = selection.map(item => item.id)
  542. this.single = selection.length!==1
  543. this.multiple = !selection.length
  544. },
  545. //乘法
  546. accMul(arg1,arg2){
  547. var m=0,s1=arg1.toString(),s2=arg2.toString();
  548. try{m+=s1.split(".")[1].length}catch(e){}
  549. try{m+=s2.split(".")[1].length}catch(e){}
  550. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
  551. },
  552. //加法
  553. accAdd(arg1,arg2){
  554. var r1,r2,m;
  555. try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
  556. try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
  557. m=Math.pow(10,Math.max(r1,r2))
  558. return ((arg1*m+arg2*m)/m).toFixed(0);
  559. },
  560. /** 新增按钮操作 */
  561. handleAdd() {
  562. this.reset();
  563. this.disabledType = false;
  564. this.buttonType = true;
  565. this.mapList = []
  566. this.mapData.list = [{
  567. id: "",
  568. top:0,
  569. left:0
  570. }];
  571. this.isUpdate=true;
  572. this.form.type=this.pageType;
  573. this.drawer = true;
  574. this.title = "添加硬件";
  575. this.getHardTypeList();
  576. this.getLabList();
  577. },
  578. /** 修改按钮操作 */
  579. handleUpdate(row) {
  580. this.reset();
  581. this.mapList = [];
  582. this.mapData.list = [];
  583. this.isUpdate=true;
  584. this.form.type=this.pageType;
  585. this.getHardTypeList();
  586. this.getLabList();
  587. const id = row.id || this.ids
  588. let queryParam = {};
  589. queryParam.id = id;
  590. queryParam.subjectId = row.subjectId;
  591. getHardwareDetail(queryParam).then(response => {
  592. this.form = response.data;
  593. this.$forceUpdate;
  594. this.title = "修改硬件";
  595. this.drawer = true;
  596. });
  597. },
  598. /** 查看按钮操作 */
  599. handleView(row) {
  600. this.reset();
  601. this.mapList = [];
  602. this.mapData.list = [];
  603. this.disabledType = true;
  604. this.buttonType = false;
  605. this.isUpdate=false;
  606. this.form.type=this.pageType;
  607. //this.getHardTypeList();
  608. this.getLabList();
  609. const id = row.id || this.ids
  610. let queryParam = {};
  611. queryParam.id = id;
  612. queryParam.subjectId = row.subjectId;
  613. getHardwareDetail(queryParam).then(response => {
  614. this.form = response.data;
  615. let subHardList = response.data.subjectHardPosiList;
  616. for(var i=0;i<subHardList.length;i++){
  617. this.mapList.push({"name":response.data.subjectHardPosiList[i].hardName,"y":(response.data.subjectHardPosiList[i].horizontalAxis/3).toFixed(0),"x":(response.data.subjectHardPosiList[i].verticalAxis/3).toFixed(0)});
  618. }
  619. this.$forceUpdate;
  620. this.drawer = true;
  621. this.title = "查看硬件";
  622. });
  623. getSubjectLayout(row.subjectId).then(response => {
  624. this.mapData.widthData = response.data.layWidth;
  625. this.mapData.heightData = response.data.layHeight;
  626. this.$forceUpdate;
  627. });
  628. // const id = row.id || this.ids
  629. // getHardware(id).then(response => {
  630. // this.form = response.data;
  631. // this.open = true;
  632. // this.title = "修改硬件";
  633. // });
  634. },
  635. /** 提交按钮 */
  636. submitForm() {
  637. this.form.hardwarePosition={
  638. horizontalAxis:'',
  639. verticalAxis:''
  640. }
  641. this.form.type=this.pageType;
  642. // this.form.hardwarePosition.horizontalAxis=this.mapData.list[0].top;
  643. // this.form.hardwarePosition.verticalAxis=this.mapData.list[0].left;
  644. this.$refs["form"].validate(valid => {
  645. if (valid) {
  646. if (this.form.id != null) {
  647. updateHardware(this.form).then(response => {
  648. this.msgSuccess("修改成功");
  649. this.drawer = false;
  650. this.getList();
  651. });
  652. } else {
  653. addHardware(this.form).then(response => {
  654. this.msgSuccess("新增成功");
  655. this.drawer = false;
  656. this.getList();
  657. });
  658. }
  659. }
  660. });
  661. },
  662. /** 删除按钮操作 */
  663. handleDelete(row) {
  664. const ids = row.id || this.ids;
  665. this.$confirm('是否确认删除硬件?', "警告", {
  666. confirmButtonText: "确定",
  667. cancelButtonText: "取消",
  668. type: "warning"
  669. }).then(function() {
  670. return delHardware(ids);
  671. }).then(() => {
  672. this.getList();
  673. this.msgSuccess("删除成功");
  674. }).catch(() => {});
  675. },
  676. /** 导出按钮操作 */
  677. handleExport() {
  678. this.download('laboratory/hardware/export', {
  679. ...this.queryParams
  680. }, `laboratory_hardware.xlsx`)
  681. }
  682. }
  683. };
  684. </script>
  685. <style scoped lang="scss">
  686. .videoSurveillance{
  687. flex: 1;
  688. display: flex!important;
  689. flex-direction: column;
  690. padding:20px!important;
  691. overflow: hidden;
  692. .form-box{
  693. }
  694. .button-box{
  695. width:230px;
  696. display: flex;
  697. }
  698. }
  699. </style>