videoSurveillance.vue 25 KB

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