EquipList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <div>
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item>设备管理</el-breadcrumb-item>
  5. </el-breadcrumb>
  6. <div class="search-box">
  7. <div class="filter-box">
  8. <el-select
  9. size="small"
  10. v-model="queryInfo.device_type_id"
  11. placeholder="请选择设备类型"
  12. @change="searchChange()"
  13. >
  14. <el-option label="全部" value="0"></el-option>
  15. <el-option label="性诱测报" value="4"></el-option>
  16. <el-option label="孢子仪" value="7"></el-option>
  17. <el-option label="虫情测报" value="3"></el-option>
  18. <el-option label="杀虫灯" value="2"></el-option>
  19. </el-select>
  20. <el-input
  21. size="small"
  22. clearable
  23. @change="searchChange()"
  24. placeholder="请输入设备ID"
  25. v-model="queryInfo.f_id"
  26. >
  27. <i slot="suffix" class="el-input__icon el-icon-search"></i>
  28. </el-input>
  29. </div>
  30. <el-date-picker
  31. size="small"
  32. @change="DateChange()"
  33. v-model="timeRange"
  34. type="daterange"
  35. range-separator="至"
  36. start-placeholder="开始日期"
  37. end-placeholder="结束日期"
  38. ></el-date-picker>
  39. </div>
  40. <el-row :gutter="10">
  41. <el-col
  42. :xs="24"
  43. :sm="24"
  44. :md="12"
  45. :lg="6"
  46. :xl="4"
  47. v-for="item in dataList"
  48. :key="item.id"
  49. >
  50. <el-card class="box-card pad0">
  51. <div class="img-box">
  52. <template v-if="item.equip_type == '2'">
  53. <img src="@/assets/images/equipdistribute/scdIconOn.png" />
  54. <p>杀虫灯</p>
  55. </template>
  56. <template v-if="item.equip_type == '3'">
  57. <img src="@/assets/images/equipdistribute/cbdIconOn.png" />
  58. <p>测报灯</p>
  59. </template>
  60. <template v-if="item.equip_type == '4'">
  61. <img src="@/assets/images/equipdistribute/znxyOn.png" />
  62. <p>智能性诱</p>
  63. </template>
  64. <template v-if="item.equip_type == '5'">
  65. <img src="@/assets/images/equipdistribute/hjjcIconOn.png" />
  66. <p>环境监测</p>
  67. </template>
  68. <template v-if="item.equip_type == '6'">
  69. <img src="@/assets/images/equipdistribute/jkIconOn.png" />
  70. <p>监控设备</p>
  71. </template>
  72. <template v-if="item.equip_type == '7'">
  73. <img src="@/assets/images/equipdistribute/bzyIconOn.png" />
  74. <p>孢子仪</p>
  75. </template>
  76. <template v-if="item.equip_type == '8'">
  77. <img src="@/assets/images/equipdistribute/xyOn.png" />
  78. <p>性诱设备</p>
  79. </template>
  80. <template v-if="item.equip_type == 9">
  81. <img src="@/assets/images/equipdistribute/tccbOn.png" />
  82. <p>糖醋测报</p>
  83. </template>
  84. </div>
  85. <div class="detail">
  86. <p>
  87. 设备ID
  88. <span>{{ item.equip_id }}</span>
  89. </p>
  90. <p>
  91. 适配用户
  92. <span>{{ item.equip_user || '无' }}</span>
  93. </p>
  94. <p>
  95. 设备名称
  96. <span>{{ item.equip_name || '无' }}</span>
  97. </p>
  98. <p>
  99. 设备添加时间
  100. <span>{{ item.equip_add_time }}</span>
  101. </p>
  102. </div>
  103. <div class="bottom">
  104. <span @click="modifyName(item.equip_id, item.equip_name)">
  105. <i class="el-icon-edit-outline"></i> 修改名称
  106. </span>
  107. </div>
  108. </el-card>
  109. </el-col>
  110. </el-row>
  111. <!-- 暂无数据 -->
  112. <div class="expertDiagnosis_referral_units_not" v-if="dataList.length <= 0">
  113. <img
  114. src="@/assets/images/zanwu.png"
  115. alt
  116. class="expertDiagnosis_referral_units_notImg"
  117. />
  118. </div>
  119. <el-pagination
  120. v-if="dataList.length > 0"
  121. background
  122. layout="prev, pager, next"
  123. :page-size="12"
  124. :total="totalNum"
  125. @current-change="changePage"
  126. ></el-pagination>
  127. <!-- 添加定位弹框 -->
  128. <el-dialog
  129. class="map_dialog"
  130. title="添加定位"
  131. v-if="addLocationDialogVisible"
  132. :visible.sync="addLocationDialogVisible"
  133. width="800px"
  134. @closed="addLocationDialogClosed"
  135. >
  136. <el-form
  137. :inline="true"
  138. :model="locationForm"
  139. class="demo-form-inline"
  140. size="mini"
  141. >
  142. <el-form-item label="经度">
  143. <el-input clearable v-model="locationForm.lng"></el-input>
  144. </el-form-item>
  145. <el-form-item label="维度">
  146. <el-input clearable v-model="locationForm.lat"></el-input>
  147. </el-form-item>
  148. <el-form-item>
  149. <el-button type="primary" size="mini" @click="locationSearch"
  150. >定位</el-button
  151. >
  152. </el-form-item>
  153. <el-form-item label="">
  154. <el-input
  155. placeholder="请输入地区检索"
  156. v-model="addr"
  157. clearable
  158. @change="addrChange()"
  159. ></el-input>
  160. </el-form-item>
  161. </el-form>
  162. <baidu-map
  163. class="Bmap"
  164. :center="center"
  165. :zoom="mapZoom"
  166. :scroll-wheel-zoom="true"
  167. @ready="handlerBMap"
  168. @click="locationPoint"
  169. >
  170. <bm-marker :position="point" :dragging="true"></bm-marker>
  171. </baidu-map>
  172. <span slot="footer" class="dialog-footer">
  173. <el-button @click="addLocationDialogVisible = false">取 消</el-button>
  174. <el-button type="primary" @click="addLocationSubm">确 定</el-button>
  175. </span>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. export default {
  181. data() {
  182. return {
  183. timeRange: '',
  184. queryInfo: {
  185. f_id: '',
  186. page: 1,
  187. device_type_id: '0',
  188. start_time: '',
  189. end_time: ''
  190. },
  191. dataList: [],
  192. totalNum: 0,
  193. addr: '',
  194. locationForm: {
  195. lat: '',
  196. lng: ''
  197. },
  198. device_id: '',
  199. mapZoom: 6,
  200. point: { lng: '', lat: '' },
  201. center: { lng: '', lat: '' },
  202. addLocationDialogVisible: false
  203. }
  204. },
  205. mounted() {
  206. this.getList()
  207. },
  208. beforeMount() {},
  209. methods: {
  210. //获取设备列表
  211. getList() {
  212. this.$axios({
  213. method: 'POST',
  214. url: '/api/equiplist_filter',
  215. data: this.qs.stringify({
  216. f_type: this.queryInfo.device_type_id,
  217. f_id: this.queryInfo.f_id,
  218. f_tbegin: this.queryInfo.start_time,
  219. f_tend: this.queryInfo.end_time,
  220. page: this.queryInfo.page,
  221. })
  222. }).then((res) => {
  223. this.dataList = res.data.dat
  224. this.totalNum = res.data.nums
  225. })
  226. },
  227. searchChange() {
  228. this.queryInfo.page = 1
  229. this.getList()
  230. },
  231. DateChange(val) {
  232. this.queryInfo.page = 1
  233. if (this.timeRange) {
  234. this.queryInfo.start_time = new Date(this.timeRange[0]).toLocaleDateString().replace(/\//g,'-');
  235. this.queryInfo.end_time = new Date(this.timeRange[1]).toLocaleDateString().replace(/\//g,'-');
  236. this.getList()
  237. } else {
  238. this.queryInfo.start_time = ''
  239. this.queryInfo.end_time = ''
  240. this.getList()
  241. }
  242. },
  243. //在地图中点击定位
  244. locationPoint(e) {
  245. let { point } = e
  246. this.point = point
  247. this.locationForm = point
  248. this.map.clearOverlays()
  249. this.map.addOverlay(new BMap.Marker(this.point))
  250. },
  251. addrChange() {
  252. let local = new this.BMap.LocalSearch(this.map, {
  253. renderOptions: { map: this.map, panel: 'r-result' }
  254. })
  255. local.search(this.addr)
  256. },
  257. // 修改设备名称
  258. modifyName(id, device_name) {
  259. let value = device_name
  260. this.$prompt('', '修改名字', {
  261. confirmButtonText: '确定',
  262. cancelButtonText: '取消',
  263. inputPlaceholder: device_name
  264. })
  265. .then(({ value }) => {
  266. if (value) {
  267. this.$axios({
  268. method: 'POST',
  269. url: '/api/equiplist',
  270. data: this.qs.stringify({
  271. req: 'rename',
  272. ename: value,
  273. eid: id
  274. })
  275. }).then((res) => {
  276. if (res.data == 0) {
  277. this.getList()
  278. this.$message({
  279. type: 'success',
  280. message: '修改成功'
  281. })
  282. }
  283. })
  284. } else {
  285. this.$message({
  286. type: 'info',
  287. message: '内容不能为空'
  288. })
  289. }
  290. })
  291. .catch(() => {
  292. this.$message({
  293. type: 'info',
  294. message: '取消输入'
  295. })
  296. })
  297. },
  298. //通过经纬度搜索定位
  299. locationSearch() {
  300. if (this.locationForm.lat && this.locationForm.lng) {
  301. this.point = this.locationForm
  302. this.map.clearOverlays()
  303. this.map.addOverlay(new BMap.Marker(this.point))
  304. }
  305. },
  306. handlerBMap({ BMap, map }) {
  307. this.BMap = BMap
  308. this.map = map
  309. let point = new BMap.Point(this.point.lng, this.point.lat)
  310. map.centerAndZoom(point, 15)
  311. },
  312. //点击“添加定位”按钮
  313. addPosition(device_id, lng, lat) {
  314. this.device_id = device_id
  315. this.point = { lng, lat }
  316. this.addLocationDialogVisible = true
  317. },
  318. changePage(val) {
  319. console.log(val)
  320. this.queryInfo.page = val
  321. this.getList()
  322. },
  323. //关闭定位弹框时调用
  324. addLocationDialogClosed() {
  325. this.locationForm = { lat: '', lng: '' }
  326. this.point = { lng: '', lat: '' }
  327. this.center = { lng: 113.271429, lat: 23.135336 }
  328. // this.map.clearOverlays();
  329. this.map = null
  330. this.BMap = null
  331. },
  332. //选择定位点后,提交
  333. addLocationSubm() {
  334. console.log(this.point)
  335. this.$axios({
  336. method: 'POST',
  337. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
  338. data: this.qs.stringify({
  339. device_id: this.device_id,
  340. lat: this.point.lat,
  341. lng: this.point.lng
  342. })
  343. }).then((res) => {
  344. if (res.data.message == '') {
  345. this.getList()
  346. this.$message({
  347. type: 'success',
  348. message: '定位成功'
  349. })
  350. } else {
  351. this.$message({
  352. type: 'error',
  353. message: '定位失败'
  354. })
  355. }
  356. })
  357. this.addLocationDialogVisible = false
  358. }
  359. }
  360. }
  361. </script>
  362. <style lang='less' scoped>
  363. .search-box {
  364. display: flex;
  365. justify-content: flex-left;
  366. justify-content: space-between;
  367. margin-bottom: 10px;
  368. .filter-box > div {
  369. margin-right: 15px;
  370. }
  371. .el-input {
  372. width: 200px;
  373. }
  374. .el-date-editor--daterange {
  375. width: 222px;
  376. }
  377. }
  378. .el-card.selected {
  379. border: 1px solid #14a478;
  380. }
  381. .el-card {
  382. .img-box {
  383. text-align: center;
  384. border-bottom: 1px solid #e1e1e1;
  385. padding: 20px 0;
  386. img {
  387. height: 55px;
  388. }
  389. p {
  390. font-size: 14px;
  391. font-weight: 800;
  392. margin-top: 10px;
  393. }
  394. }
  395. .detail {
  396. border-bottom: 1px solid #e1e1e1;
  397. padding: 10px 0;
  398. padding: 0 20px;
  399. p {
  400. display: flex;
  401. justify-content: space-between;
  402. font-size: 13px;
  403. line-height: 34px;
  404. color: #666;
  405. }
  406. }
  407. .bottom {
  408. display: flex;
  409. font-size: 13px;
  410. color: #666;
  411. line-height: 50px;
  412. span {
  413. flex: 1;
  414. text-align: center;
  415. cursor: pointer;
  416. i {
  417. font-size: 16px;
  418. }
  419. }
  420. span:first-child {
  421. border-right: 1px solid #e1e1e1;
  422. }
  423. }
  424. }
  425. .Bmap {
  426. width: 100%;
  427. height: 400px;
  428. }
  429. .map_dialog /deep/ .el-dialog__body {
  430. padding: 20px 20px 0 20px;
  431. }
  432. // 暂无数据
  433. .expertDiagnosis_referral_units_not {
  434. width: 272px;
  435. margin: 0 auto;
  436. }
  437. </style>