IotData.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!-- 物联感知数据 -->
  2. <template>
  3. <CategoryMenu :type="'iot'" v-model:currVal="currCategory"></CategoryMenu>
  4. <div class="data" v-if="currCategory && currCategory!==''">
  5. <el-button v-if="auth" type="primary" @click="addDataClick">录入物联感知数据</el-button>
  6. <el-button v-if="auth" type="warning" @click="batchDelete">批量删除</el-button>
  7. <div class="operation">
  8. <el-form :model="filterForm" :inline="true">
  9. <el-form-item label="标题:" style="width: 15%">
  10. <el-input v-model="filterForm.title" placeholder="请输入标题"></el-input>
  11. </el-form-item>
  12. <el-form-item label="描述:" style="width: 17%">
  13. <el-input v-model="filterForm.content" placeholder="请输入描述"></el-input>
  14. </el-form-item>
  15. <el-form-item label="地名地址库:" style="width: 20%">
  16. <el-input v-model="filterForm.address" placeholder="请输入名称"></el-input>
  17. </el-form-item>
  18. <el-form-item label="导入类型:" style="width: 20%">
  19. <el-select v-model="filterForm.importType" placeholder="请选择类型">
  20. <el-option value="单条数据录入">单条数据录入</el-option>
  21. <el-option value="Shape文件导入">Shape文件导入</el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" @click="search">搜索</el-button>
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. <div class="list">
  30. <el-table ref="dataTable" v-loading="loading" element-loading-text="正在加载,请稍后..." :data="tableData"
  31. :border="true" :stripe="true" :height="440" style="width: 100%;margin-bottom: 15px;"
  32. @selection-change="handleTableSelect">
  33. <el-table-column type="selection" width="55"/>
  34. <el-table-column prop="id" label="ID" width="100" :show-overflow-tooltip="true">
  35. <template #default="scope">
  36. <span style="cursor: pointer" @click="$util.clipboard.copyText(scope.row.id)"> {{ scope.row.id }} </span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="title" label="标题" width="200"/>
  40. <el-table-column prop="content" label="描述" width="250"/>
  41. <el-table-column prop="menuNameTwo" label="类别" width="80"/>
  42. <el-table-column prop="mediaType" label="媒体类型" width="120"/>
  43. <el-table-column prop="url" label="媒体路径" width="120"/>
  44. <el-table-column prop="lon" label="位置" width="180">
  45. <template #default="scope">
  46. [
  47. <span v-if="scope.row.lon && scope.row.lon!=='' && scope.row.lat && scope.row.lat!==''">
  48. {{ scope.row.lon }},<br/> {{ scope.row.lat }}
  49. </span>
  50. ]
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="importType" label="导入类型" width="150"/>
  54. <el-table-column prop="address" label="地名地址库" width="150"/>
  55. <el-table-column prop="userName" label="修改人"/>
  56. <el-table-column prop="updateDate" label="修改时间" width="160">
  57. <template #default="scope">
  58. {{ $util.datetime.format(scope.row.updateDate) }}
  59. </template>
  60. </el-table-column>
  61. <el-table-column prop="createDate" label="创建时间" width="160">
  62. <template #default="scope">
  63. {{ $util.datetime.format(scope.row.createDate) }}
  64. </template>
  65. </el-table-column>
  66. <el-table-column prop="operation" label="操作" width="150" fixed="right">
  67. <template #default="scope">
  68. <el-tooltip class="box-item" effect="dark" content="查看详情" placement="top-start">
  69. <el-button type="default" @click="viewData(scope.row)" circle>
  70. <el-icon>
  71. <ElIconView/>
  72. </el-icon>
  73. </el-button>
  74. </el-tooltip>
  75. <el-tooltip v-if="auth" class="box-item" effect="dark" content="编辑" placement="top-start">
  76. <el-button type="primary" @click="editData(scope.row)" circle>
  77. <el-icon>
  78. <ElIconEdit/>
  79. </el-icon>
  80. </el-button>
  81. </el-tooltip>
  82. <el-tooltip v-if="auth" class="box-item" effect="dark" content="删除" placement="top-start">
  83. <el-button type="danger" @click="deleteData(scope.row)" circle>
  84. <el-icon>
  85. <ElIconDelete/>
  86. </el-icon>
  87. </el-button>
  88. </el-tooltip>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination style="float:right" background layout="sizes, prev, pager, next, jumper, total"
  93. v-model:current-page="pageInfo.page" v-model:page-size="pageInfo.pageSize"
  94. v-model:total="pageInfo.total"/>
  95. </div>
  96. </div>
  97. <IotDataDetail v-if="isDetailShow" :is-show="isDetailShow" :item="currRow" :close="handleDetailShow"></IotDataDetail>
  98. </template>
  99. <script>
  100. import api from '@/api/data/IotData'
  101. import IotDataDetail from "@/components/dataManage/dataDetail/IotDataDetail";
  102. import CategoryMenu from "@/components/dataManage/CategoryMenu";
  103. export default {
  104. data() {
  105. return {
  106. auth: false,
  107. loading: false,
  108. filterForm: {},
  109. tableData: [],
  110. currRow: {},
  111. selectedRows: [],
  112. pageInfo: {
  113. page: 1,
  114. pageSize: 10,
  115. total: 0,
  116. },
  117. currCategory: '',
  118. isDetailShow: false,
  119. }
  120. },
  121. components: {
  122. IotDataDetail,
  123. CategoryMenu,
  124. },
  125. created() {
  126. let userInfo = this.$store.state.userInfo;
  127. if (userInfo.userLevel<2
  128. || (userInfo.userLevel===2) && userInfo.serviceId.split(',').indexOf(this.$constant.serviceId)>-1 ) {
  129. this.auth = true;
  130. }
  131. },
  132. mounted() {
  133. this.getData();
  134. },
  135. watch: {
  136. "pageInfo.page": function (val) {
  137. if (val > 0) {
  138. this.getData();
  139. }
  140. },
  141. "pageInfo.pageSize": function () {
  142. let app = this;
  143. this.pageInfo.page = -1;
  144. setTimeout(function () {
  145. app.pageInfo.page = 1;
  146. }, 50)
  147. },
  148. "currCategory": function () {
  149. this.resetCategory();
  150. this.getData();
  151. }
  152. },
  153. methods: {
  154. handleLoading(flag) {
  155. let app = this;
  156. if (flag) {
  157. app.loading = true;
  158. } else {
  159. setTimeout(() => {
  160. app.loading = false;
  161. }, 500);
  162. }
  163. },
  164. resetCategory() {
  165. let auth = this.$data.auth;
  166. let currCategory = this.$data.currCategory;
  167. Object.assign(this.$data, this.$options.data());
  168. this.auth = auth;
  169. this.currCategory = currCategory;
  170. },
  171. getData() {
  172. let app = this;
  173. if (!(app.currCategory && app.currCategory!=='')) {
  174. return;
  175. }
  176. let params = {
  177. menuId: app.currCategory,
  178. page: app.pageInfo.page,
  179. pageSize: app.pageInfo.pageSize,
  180. }
  181. Object.assign(params, app.filterForm)
  182. app.handleLoading(true)
  183. api.getData(params).then(res => {
  184. if (res.code === 200) {
  185. app.pageInfo.total = res.total;
  186. app.tableData = res.content
  187. }
  188. app.handleLoading(false)
  189. }).catch(err => {
  190. app.handleLoading(false)
  191. })
  192. },
  193. search() {
  194. let app = this;
  195. this.pageInfo.pageSize = -1;
  196. setTimeout(function () {
  197. app.pageInfo.pageSize = 10;
  198. })
  199. },
  200. handleTableSelect(val) {
  201. this.selectedRows = val;
  202. },
  203. handleDetailShow(flag) {
  204. if (flag) {
  205. this.getData()
  206. }
  207. this.isDetailShow = false
  208. },
  209. // 录入数据
  210. addDataClick() {
  211. this.currRow = {};
  212. this.isDetailShow = true;
  213. },
  214. // 批量删除数据
  215. batchDelete() {
  216. let app = this;
  217. if (!this.selectedRows) {
  218. return;
  219. }
  220. let ids = this.selectedRows.map(i=> {return i.id}).join(',');
  221. let params = {
  222. latlonDataId: ids
  223. }
  224. this.$msgbox.confirm('确定要删除吗?').then(()=>{
  225. api.deleteData(params).then(res=>{
  226. if (res.code===200) {
  227. app.getData();
  228. app.$message({message: '删除成功', type: 'success'})
  229. }
  230. })
  231. })
  232. },
  233. // 查看详情
  234. viewData(item) {
  235. let app = this;
  236. let params = {
  237. latlonDataId: item.id
  238. }
  239. app.$util.loading.handleLoading(true);
  240. api.getDataById(params).then(res=>{
  241. if (res.code===200) {
  242. if (!res.content.id || res.content.id==='') {
  243. app.$message({message: '该数据不存在', type: 'error'})
  244. return;
  245. }
  246. if (res.content.menuId) {
  247. res.content.menuId = Number(res.content.menuId);
  248. res.content.geometryStr = JSON.stringify(res.content.geometry);
  249. delete res.content.geometry;
  250. }
  251. app.currRow = JSON.parse(JSON.stringify(res.content))
  252. this.currRow.isDataView = true;
  253. app.isDetailShow = true
  254. }
  255. app.$util.loading.handleLoading(false);
  256. })
  257. },
  258. // 编辑数据
  259. editData(item) {
  260. let app = this;
  261. let params = {
  262. latlonDataId: item.id
  263. }
  264. app.$util.loading.handleLoading(true);
  265. api.getDataById(params).then(res=>{
  266. if (!res.content.id || res.content.id==='') {
  267. app.$message({message: '该数据不存在', type: 'error'})
  268. return;
  269. }
  270. if (res.code===200) {
  271. if (res.content.menuId) {
  272. res.content.menuId = Number(res.content.menuId);
  273. res.content.geometryStr = JSON.stringify(res.content.geometry);
  274. delete res.content.geometry;
  275. }
  276. app.currRow = JSON.parse(JSON.stringify(res.content))
  277. app.currRow.isEdit = true;
  278. app.isDetailShow = true
  279. }
  280. app.$util.loading.handleLoading(false);
  281. })
  282. },
  283. // 删除数据
  284. deleteData(item) {
  285. let app = this;
  286. app.$msgbox.confirm('确认要删除此条数据吗?').then(()=>{
  287. api.deleteData({latlonDataId: item.id}).then(res=>{
  288. if (res.code === 200) {
  289. app.getData();
  290. app.$message({message: '删除成功', type: 'success'});
  291. }
  292. })
  293. })
  294. },
  295. }
  296. }
  297. </script>
  298. <style>
  299. </style>