index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
  4. <!-- <el-form-item label="房间" prop="roomId">-->
  5. <!-- <template>-->
  6. <!-- <el-select v-model="queryParams.roomId" filterable placeholder="请选择">-->
  7. <!-- <el-option-->
  8. <!-- v-for="item in roomList"-->
  9. <!-- :key="item.roomId"-->
  10. <!-- :label="item.roomName"-->
  11. <!-- :value="item.roomId">-->
  12. <!-- </el-option>-->
  13. <!-- </el-select>-->
  14. <!-- </template>-->
  15. <!-- </el-form-item>-->
  16. <el-form-item label="大楼" prop="buildingId">
  17. <template>
  18. <el-select v-model="queryParams.buildingId" filterable placeholder="请选择">
  19. <el-option
  20. v-for="item in buildingList"
  21. :key="item.buildingId"
  22. :label="item.buildingName"
  23. :value="item.buildingId">
  24. </el-option>
  25. </el-select>
  26. </template>
  27. </el-form-item>
  28. <el-form-item label="区域" prop="areaId">
  29. <template>
  30. <el-select v-model="queryParams.areaId" filterable placeholder="请选择">
  31. <el-option
  32. v-for="item in areaList"
  33. :key="item.areaId"
  34. :label="item.areaName"
  35. :value="item.areaId">
  36. </el-option>
  37. </el-select>
  38. </template>
  39. </el-form-item>
  40. <el-form-item label="园区" prop="parkId">
  41. <el-select v-model="queryParams.parkId" placeholder="请选择" clearable size="small">
  42. <el-option
  43. v-for="item in parkList"
  44. :key="item.parkId"
  45. :label="item.parkName"
  46. :value="item.parkId"
  47. />
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item label="名称" prop="equipmentName">
  51. <el-input
  52. v-model="queryParams.equipmentName"
  53. placeholder="请输入名称"
  54. clearable
  55. size="small"
  56. @keyup.enter.native="handleQuery"
  57. />
  58. </el-form-item>
  59. <!-- <el-form-item label="二维坐标" prop="lngLat">-->
  60. <!-- <el-input-->
  61. <!-- v-model="queryParams.lngLat"-->
  62. <!-- placeholder="请输入二维坐标"-->
  63. <!-- clearable-->
  64. <!-- size="small"-->
  65. <!-- @keyup.enter.native="handleQuery"-->
  66. <!-- />-->
  67. <!-- </el-form-item>-->
  68. <!-- <el-form-item label="三维坐标" prop="rasterLngLat">-->
  69. <!-- <el-input-->
  70. <!-- v-model="queryParams.rasterLngLat"-->
  71. <!-- placeholder="请输入三维坐标"-->
  72. <!-- clearable-->
  73. <!-- size="small"-->
  74. <!-- @keyup.enter.native="handleQuery"-->
  75. <!-- />-->
  76. <!-- </el-form-item>-->
  77. <el-form-item label="类型" prop="typeName">
  78. <template>
  79. <el-select v-model="queryParams.typeId" filterable placeholder="请选择">
  80. <el-option
  81. v-for="item in equipmentTypeList"
  82. :key="item.typeId"
  83. :label="item.typeName"
  84. :value="item.typeId">
  85. </el-option>
  86. </el-select>
  87. </template>
  88. </el-form-item>
  89. <el-form-item label="状态" prop="status">
  90. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  91. <el-option
  92. v-for="dict in dict.type.equipment_info_type"
  93. :key="dict.value"
  94. :label="dict.label"
  95. :value="dict.value"
  96. />
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item>
  100. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  101. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  102. </el-form-item>
  103. </el-form>
  104. <el-row :gutter="10" class="mb8">
  105. <el-col :span="1.5">
  106. <el-button
  107. type="primary"
  108. plain
  109. icon="el-icon-plus"
  110. size="mini"
  111. @click="handleAdd"
  112. v-hasPermi="['info:equipmentInfo:add']"
  113. >新增</el-button>
  114. </el-col>
  115. <el-col :span="1.5">
  116. <el-button
  117. type="success"
  118. plain
  119. icon="el-icon-edit"
  120. size="mini"
  121. :disabled="single"
  122. @click="handleUpdate"
  123. v-hasPermi="['info:equipmentInfo:edit']"
  124. >修改</el-button>
  125. </el-col>
  126. <el-col :span="1.5">
  127. <el-button
  128. type="danger"
  129. plain
  130. icon="el-icon-delete"
  131. size="mini"
  132. :disabled="multiple"
  133. @click="handleDelete"
  134. v-hasPermi="['info:equipmentInfo:remove']"
  135. >删除</el-button>
  136. </el-col>
  137. <el-col :span="1.5">
  138. <el-button
  139. type="warning"
  140. plain
  141. icon="el-icon-download"
  142. size="mini"
  143. :loading="exportLoading"
  144. @click="handleExport"
  145. v-hasPermi="['info:equipmentInfo:export']"
  146. >导出</el-button>
  147. </el-col>
  148. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  149. </el-row>
  150. <el-table v-loading="loading" :data="equipmentInfoList" @selection-change="handleSelectionChange">
  151. <el-table-column type="selection" width="55" align="center" />
  152. <el-table-column label="设备id" align="center" prop="equipmentId" />
  153. <el-table-column label="房间" align="center">
  154. <template slot-scope="scope">
  155. {{ getRoomName(scope.row.roomId) }}
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="大楼" align="center">
  159. <template slot-scope="scope">
  160. {{ getBuildingName(scope.row.buildingId) }}
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="区域" align="center">
  164. <template slot-scope="scope">
  165. {{ getAreaName(scope.row.areaId) }}
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="名称" align="center" prop="equipmentName" />
  169. <el-table-column label="二维坐标" align="center" prop="lngLat" />
  170. <el-table-column label="三维坐标" align="center" prop="rasterLngLat" />
  171. <el-table-column label="类型" align="center">
  172. <template slot-scope="scope">
  173. {{ getEquipmentTypeName(scope.row.typeId) }}
  174. </template>
  175. </el-table-column>
  176. <el-table-column label="状态" align="center" prop="status">
  177. <template slot-scope="scope">
  178. <dict-tag :options="dict.type.equipment_info_type" :value="scope.row.status"/>
  179. </template>
  180. </el-table-column>
  181. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
  182. <template slot-scope="scope">
  183. <el-button
  184. size="mini"
  185. type="text"
  186. icon="el-icon-edit"
  187. @click="handleUpdate(scope.row)"
  188. v-hasPermi="['info:equipmentInfo:edit']"
  189. >修改</el-button>
  190. <el-button
  191. size="mini"
  192. type="text"
  193. icon="el-icon-delete"
  194. @click="handleDelete(scope.row)"
  195. v-hasPermi="['info:equipmentInfo:remove']"
  196. >删除</el-button>
  197. </template>
  198. </el-table-column>
  199. </el-table>
  200. <pagination
  201. v-show="total>0"
  202. :total="total"
  203. :page.sync="queryParams.pageNum"
  204. :limit.sync="queryParams.pageSize"
  205. @pagination="getList"
  206. />
  207. <!-- 添加或修改设备信息对话框 -->
  208. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  209. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  210. <el-form-item label="类别" prop="typeId">
  211. <template>
  212. <el-select v-model="form.typeId" filterable placeholder="请选择">
  213. <el-option
  214. v-for="item in equipmentTypeList"
  215. :key="item.typeId"
  216. :label="item.typeName"
  217. :value="item.typeId">
  218. </el-option>
  219. </el-select>
  220. </template>
  221. </el-form-item>
  222. <el-form-item label="房间" prop="roomId">
  223. <template>
  224. <el-select v-model="form.roomId" filterable placeholder="请选择">
  225. <el-option
  226. v-for="item in roomList"
  227. :key="item.roomId"
  228. :label="item.roomName"
  229. :value="item.roomId">
  230. </el-option>
  231. </el-select>
  232. </template>
  233. </el-form-item>
  234. <el-form-item label="大楼" prop="buildingId">
  235. <template>
  236. <el-select v-model="form.buildingId" filterable placeholder="请选择">
  237. <el-option
  238. v-for="item in buildingList"
  239. :key="item.buildingId"
  240. :label="item.buildingName"
  241. :value="item.buildingId">
  242. </el-option>
  243. </el-select>
  244. </template>
  245. </el-form-item>
  246. <el-form-item label="区域" prop="areaId">
  247. <template>
  248. <el-select v-model="form.areaId" filterable placeholder="请选择">
  249. <el-option
  250. v-for="item in areaList"
  251. :key="item.areaId"
  252. :label="item.areaName"
  253. :value="item.areaId">
  254. </el-option>
  255. </el-select>
  256. </template>
  257. </el-form-item>
  258. <el-form-item label="园区" prop="parkId">
  259. <el-select v-model="form.parkId" placeholder="请选择" clearable size="small">
  260. <el-option
  261. v-for="item in parkList"
  262. :key="item.parkId"
  263. :label="item.parkName"
  264. :value="item.parkId"
  265. />
  266. </el-select>
  267. </el-form-item>
  268. <el-form-item label="设备编号" prop="equipCode">
  269. <el-input v-model="form.equipCode" placeholder="请输入" />
  270. </el-form-item>
  271. <el-form-item label="名称" prop="equipmentName">
  272. <el-input v-model="form.equipmentName" placeholder="请输入名称" />
  273. </el-form-item>
  274. <el-form-item label="二维坐标" prop="lngLat">
  275. <el-input v-model="form.lngLat" placeholder="请输入二维坐标" />
  276. </el-form-item>
  277. <el-form-item label="三维坐标" prop="rasterLngLat">
  278. <el-input v-model="form.rasterLngLat" @focus="openditu">
  279. {{ form.rasterLngLat}}
  280. </el-input>
  281. </el-form-item>
  282. <el-form-item label="状态" prop="status">
  283. <el-select v-model="form.status" placeholder="请选择状态">
  284. <el-option
  285. v-for="dict in dict.type.equipment_info_type"
  286. :key="dict.value"
  287. :label="dict.label"
  288. :value="parseInt(dict.value)"
  289. ></el-option>
  290. </el-select>
  291. </el-form-item>
  292. <el-form-item label="使用状态" prop="status">
  293. <el-select v-model="form.deviceStatus" placeholder="请选择">
  294. <el-option
  295. v-for="dict in dict.type.device_status"
  296. :key="dict.value"
  297. :label="dict.label"
  298. :value="parseInt(dict.value)"
  299. ></el-option>
  300. </el-select>
  301. </el-form-item>
  302. <el-form-item label="品牌" prop="status">
  303. <el-select v-model="form.brand" placeholder="请选择">
  304. <el-option
  305. v-for="dict in dict.type.equip_brand"
  306. :key="dict.value"
  307. :label="dict.label"
  308. :value="parseInt(dict.value)"
  309. ></el-option>
  310. </el-select>
  311. </el-form-item>
  312. </el-form>
  313. <div slot="footer" class="dialog-footer">
  314. <el-button type="primary" @click="submitForm">确 定</el-button>
  315. <el-button @click="cancel">取 消</el-button>
  316. </div>
  317. </el-dialog>
  318. <el-dialog title="地图" :visible.sync="dialogVisible" width="80%">
  319. <div id='mainMap'>
  320. <div id="mapDiv" style="width:100%; height:700px">
  321. </div>
  322. </div>
  323. <input type="button" value="清除" @click='clearmian()' />
  324. <input type="button" value="标点工具" @click='openMarkTool()' />
  325. <span slot="footer" class="dialog-footer">
  326. <el-button @click="dialogVisible = false">取 消</el-button>
  327. <el-button type="primary" @click='tijiao'>确定</el-button>
  328. </span>
  329. </el-dialog>
  330. </div>
  331. </template>
  332. <script>
  333. import { listEquipmentInfo, getEquipmentInfo, delEquipmentInfo, addEquipmentInfo, updateEquipmentInfo, exportEquipmentInfo } from "@/api/info/equipmentInfo";
  334. import { listBuildingInfo, getBuildingInfo } from "@/api/info/buildingInfo";
  335. import { listAreaInfo, getAreaInfo } from "@/api/info/areaInfo";
  336. import { listRoomInfo, getRoomInfo } from "@/api/info/roomInfo";
  337. import { listEquipmentType, getEquipmentType } from "@/api/type/equipmentType";
  338. import { listParkInfo, getParkInfo, delParkInfo, addParkInfo, updateParkInfo, exportParkInfo } from "@/api/info/parkInfo";
  339. export default {
  340. name: "EquipmentInfo",
  341. dicts: ['equipment_info_type', 'device_status', 'equip_brand'],
  342. data() {
  343. return {
  344. parkList: [],
  345. dialogVisible: false,
  346. map: null,
  347. handler: null,
  348. markPoints: '', // 保存标记点的坐标
  349. equipmentTypeList: [],
  350. areaList: [],
  351. roomList: [],
  352. buildingList: [],
  353. // 遮罩层
  354. loading: true,
  355. // 导出遮罩层
  356. exportLoading: false,
  357. // 选中数组
  358. ids: [],
  359. // 非单个禁用
  360. single: true,
  361. // 非多个禁用
  362. multiple: true,
  363. // 显示搜索条件
  364. showSearch: true,
  365. // 总条数
  366. total: 0,
  367. // 设备信息表格数据
  368. equipmentInfoList: [],
  369. // 弹出层标题
  370. title: "",
  371. // 是否显示弹出层
  372. open: false,
  373. // 查询参数
  374. queryParams: {
  375. pageNum: 1,
  376. pageSize: 10,
  377. roomId: null,
  378. buildingId: null,
  379. areaId: null,
  380. equipmentName: null,
  381. lngLat: null,
  382. rasterLngLat: null,
  383. typeName: null,
  384. status: null,
  385. parkId: null,
  386. },
  387. queryBuildingParams: {
  388. pageNum: 1,
  389. pageSize: 999999,
  390. },
  391. // 表单参数
  392. form: {},
  393. // 表单校验
  394. rules: {
  395. equipmentId: [
  396. { required: true, message: "设备id不能为空", trigger: "blur" }
  397. ],
  398. }
  399. };
  400. },
  401. created() {
  402. this.getList();
  403. this.getBuilding();
  404. this.getRoomList();
  405. this.getAreaList();
  406. this.getEquipmentTypeList();
  407. this.getParkList();
  408. },
  409. methods: {
  410. getParkList() {
  411. listParkInfo(this.queryBuildingParams).then(response => {
  412. this.parkList = response.data.list;
  413. });
  414. },
  415. // 销毁天地图
  416. destructionTMap () {
  417. if (this.map) {
  418. this.map = null;
  419. // 直接将节点给删掉
  420. console.log('1qsad');
  421. const parentEl = document.getElementById('mainMap');
  422. const cahildrenEl1 = document.getElementById('mapDiv');
  423. if(cahildrenEl1) parentEl.removeChild(cahildrenEl1);
  424. // 然后再手动将节点加进来
  425. const newCahildrenEl = document.createElement("div");
  426. newCahildrenEl.id = 'mapDiv'
  427. newCahildrenEl.style = 'height: 700px;width: 100%;'
  428. parentEl.appendChild(newCahildrenEl)
  429. }
  430. },
  431. tijiao() {
  432. console.log('多边形数据:', this.form.rasterLngLat);
  433. console.log('多边形数据:', this.markPoints);
  434. this.form.rasterLngLat = this.markPoints
  435. this.destructionTMap()
  436. this.dialogVisible = false;
  437. },
  438. clearmian() {
  439. if (this.handler) this.handler.close();
  440. this.map.clearOverLays(); // 清除所有覆盖物
  441. this.markPoints = ''; // 清除保存的标记点坐标
  442. },
  443. openMarkTool() {
  444. console.log("1111111111")
  445. if (this.handler) this.handler.close(); // 关闭之前的工具
  446. this.handler = new T.MarkTool(this.map); // 创建标点工具
  447. this.handler.open(); // 打开标点工具
  448. this.handler.on("mouseup", (e) => {
  449. let drawData1 = e.currentLnglat.lat+","+e.currentLnglat.lng;
  450. this.markPoints = drawData1;
  451. });
  452. this.handler.on("close", () => {
  453. // 标点工具关闭时的处理
  454. this.handler = null;
  455. });
  456. },
  457. openditu() {
  458. console.log('打开地图对话框');
  459. this.dialogVisible = true;
  460. this.$nextTick(() => {
  461. const T = window.T;
  462. const zoom = 12;
  463. this.map = new T.Map('mapDiv');
  464. this.map.centerAndZoom(new T.LngLat(103.96, 30.66), zoom);
  465. // 创建标注工具对象
  466. this.handler = new T.MarkTool(this.map);
  467. console.log('handler 初始化完成:', this.handler);
  468. console.log('kanknak1', this.form.rasterLngLat);
  469. let points = new T.LngLat();
  470. if (this.form.rasterLngLat) {
  471. const coordinates = this.form.rasterLngLat.split(',');
  472. points = new T.LngLat(coordinates[1], coordinates[0]);
  473. }
  474. // 创建面对象
  475. console.log('kanknak2', points);
  476. const marker = new T.Marker(points);
  477. // 向地图上添加面
  478. this.map.addOverLay(marker);
  479. });
  480. },
  481. getEquipmentTypeName(typeId) {
  482. const type = this.equipmentTypeList.find(b => b.typeId === typeId);
  483. return type ? type.typeName : '未知';
  484. },
  485. getAreaName(areaId) {
  486. const area = this.areaList.find(b => b.areaId === areaId);
  487. return area ? area.areaName : '未知';
  488. },
  489. getRoomName(roomId) {
  490. const room = this.roomList.find(b => b.roomId === roomId);
  491. return room ? room.roomName : '未知';
  492. },
  493. getBuildingName(buildingId) {
  494. const building = this.buildingList.find(b => b.buildingId === buildingId);
  495. return building ? building.buildingName : '未知';
  496. },
  497. getEquipmentTypeList() {
  498. listEquipmentType(this.queryBuildingParams).then(response => {
  499. this.equipmentTypeList = response.data.list;
  500. });
  501. },
  502. getAreaList() {
  503. listAreaInfo(this.queryBuildingParams).then(response => {
  504. this.areaList = response.data.list;
  505. });
  506. },
  507. getRoomList() {
  508. listRoomInfo(this.queryBuildingParams).then(response => {
  509. this.roomList = response.data.list;
  510. });
  511. },
  512. getBuilding() {
  513. listBuildingInfo(this.queryBuildingParams).then(response => {
  514. this.buildingList = response.data.list;
  515. });
  516. },
  517. /** 查询设备信息列表 */
  518. getList() {
  519. this.loading = true;
  520. listEquipmentInfo(this.queryParams).then(response => {
  521. this.equipmentInfoList = response.data.list;
  522. this.total = response.data.total;
  523. this.loading = false;
  524. });
  525. },
  526. // 取消按钮
  527. cancel() {
  528. this.open = false;
  529. this.reset();
  530. },
  531. // 表单重置
  532. reset() {
  533. this.form = {
  534. equipmentId: null,
  535. typeId: null,
  536. roomId: null,
  537. buildingId: null,
  538. areaId: null,
  539. equipmentName: null,
  540. lngLat: null,
  541. rasterLngLat: null,
  542. typeName: null,
  543. status: null,
  544. brand: null,
  545. equipCode: null,
  546. parkId: null,
  547. };
  548. this.resetForm("form");
  549. },
  550. /** 搜索按钮操作 */
  551. handleQuery() {
  552. this.queryParams.pageNum = 1;
  553. this.getList();
  554. },
  555. /** 重置按钮操作 */
  556. resetQuery() {
  557. this.resetForm("queryForm");
  558. this.handleQuery();
  559. },
  560. // 多选框选中数据
  561. handleSelectionChange(selection) {
  562. this.ids = selection.map(item => item.equipmentId)
  563. this.single = selection.length!==1
  564. this.multiple = !selection.length
  565. },
  566. /** 新增按钮操作 */
  567. handleAdd() {
  568. this.reset();
  569. this.open = true;
  570. this.title = "添加设备信息";
  571. },
  572. /** 修改按钮操作 */
  573. handleUpdate(row) {
  574. this.reset();
  575. const equipmentId = row.equipmentId || this.ids
  576. getEquipmentInfo(equipmentId).then(response => {
  577. this.form = response.data;
  578. this.open = true;
  579. this.title = "修改设备信息";
  580. });
  581. },
  582. /** 提交按钮 */
  583. submitForm() {
  584. this.$refs["form"].validate(valid => {
  585. if (valid) {
  586. if (this.form.equipmentId != null) {
  587. updateEquipmentInfo(this.form).then(response => {
  588. this.$modal.msgSuccess("修改成功");
  589. this.open = false;
  590. this.getList();
  591. });
  592. } else {
  593. addEquipmentInfo(this.form).then(response => {
  594. this.$modal.msgSuccess("新增成功");
  595. this.open = false;
  596. this.getList();
  597. });
  598. }
  599. }
  600. });
  601. },
  602. /** 删除按钮操作 */
  603. handleDelete(row) {
  604. const equipmentIds = row.equipmentId || this.ids;
  605. this.$modal.confirm('是否确认删除设备信息编号为"' + equipmentIds + '"的数据项?').then(function() {
  606. return delEquipmentInfo(equipmentIds);
  607. }).then(() => {
  608. this.getList();
  609. this.$modal.msgSuccess("删除成功");
  610. }).catch(() => {});
  611. },
  612. /** 导出按钮操作 */
  613. handleExport() {
  614. const queryParams = this.queryParams;
  615. this.$modal.confirm('是否确认导出所有设备信息数据项?').then(() => {
  616. this.exportLoading = true;
  617. return exportEquipmentInfo(queryParams);
  618. }).then(response => {
  619. this.$download.name(response.msg);
  620. this.exportLoading = false;
  621. }).catch(() => {});
  622. }
  623. }
  624. };
  625. </script>