ModelData.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!-- 模型数据 -->
  2. <template>
  3. <CategoryMenu :type="'model'" v-model:currVal="currCategory"></CategoryMenu>
  4. <div class="data" v-if="currCategory.id && currCategory.id!==''">
  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: 22%">
  10. <el-input v-model="filterForm.title" placeholder="请输入标题"></el-input>
  11. </el-form-item>
  12. <el-form-item label="描述:" style="width: 22%">
  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: 28%">
  19. <el-select v-model="filterForm.importType" placeholder="请选择类型">
  20. <el-option value="单条数据录入">单条数据录入</el-option>
  21. <el-option value="Shape文件导入">Shape文件导入</el-option>
  22. <el-option value="Excel文件导入">Excel文件导入</el-option>
  23. <el-option value="Geojson文件导入">Geojson文件导入</el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" @click="search">搜索</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. <div class="list">
  32. <el-table ref="dataTable" v-loading="loading" element-loading-text="正在加载,请稍后..." :data="tableData"
  33. :border="true" :stripe="true" :height="$store.state.tableHeight" style="width: 100%;margin-bottom: 15px;"
  34. @selection-change="handleTableSelect">
  35. <el-table-column type="selection" width="55"/>
  36. <el-table-column prop="id" label="ID" width="100" :show-overflow-tooltip="true">
  37. <template #default="scope">
  38. <span style="cursor: pointer" @click="$util.clipboard.copyText(scope.row.id)"> {{ scope.row.id }} </span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="title" label="标题" width="200"/>
  42. <el-table-column prop="content" label="描述" width="250"/>
  43. <el-table-column prop="modelType" label="类型" width="120"/>
  44. <el-table-column prop="menuNameTwo" label="类别" width="120"/>
  45. <el-table-column prop="lon" label="位置" width="180">
  46. <template #default="scope">
  47. [
  48. <span v-if="scope.row.lon && scope.row.lon!=='' && scope.row.lat && scope.row.lat!==''">
  49. {{ scope.row.lon }},<br/> {{ scope.row.lat }}
  50. </span>
  51. ]
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="address" label="地名地址库" width="150"/>
  55. <el-table-column prop="userName" label="修改人"/>
  56. <el-table-column prop="updateDate" label="修改时间" width="170">
  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="170">
  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. <ModelDataDetail v-if="isDetailShow" :is-show="isDetailShow" :dialog-title="dialogTitle" :item="currRow" :curr-category="currCategory" :close="handleDetailShow"></ModelDataDetail>
  98. </template>
  99. <script>
  100. import api from '@/api/data/ModelData'
  101. import ModelDataDetail from "@/components/dataManage/dataDetail/ModelDataDetail";
  102. import CategoryMenu from "@/components/dataManage/CategoryMenu";
  103. export default {
  104. data() {
  105. return {
  106. dialogTitle: '',
  107. auth: false,
  108. loading: false,
  109. filterForm: {},
  110. tableData: [],
  111. currRow: {},
  112. selectedRows: [],
  113. pageInfo: {
  114. page: 1,
  115. pageSize: 10,
  116. total: 0,
  117. },
  118. currCategory: {
  119. id: ''
  120. },
  121. isDetailShow: false,
  122. }
  123. },
  124. components: {
  125. ModelDataDetail,
  126. CategoryMenu,
  127. },
  128. created() {
  129. let userInfo = this.$store.state.userInfo;
  130. if (userInfo.userLevel<2
  131. || (userInfo.userLevel===2) && userInfo.serviceId.split(',').indexOf(this.$constant.serviceId)>-1 ) {
  132. this.auth = true;
  133. }
  134. },
  135. mounted() {
  136. this.getData();
  137. },
  138. watch: {
  139. "pageInfo.page": function (val) {
  140. if (val > 0) {
  141. this.getData();
  142. }
  143. },
  144. "pageInfo.pageSize": function () {
  145. let app = this;
  146. this.pageInfo.page = -1;
  147. setTimeout(function () {
  148. app.pageInfo.page = 1;
  149. }, 50)
  150. },
  151. "currCategory.id": function () {
  152. this.resetCategory();
  153. this.getData();
  154. }
  155. },
  156. methods: {
  157. handleLoading(flag) {
  158. let app = this;
  159. if (flag) {
  160. app.loading = true;
  161. } else {
  162. setTimeout(() => {
  163. app.loading = false;
  164. }, 500);
  165. }
  166. },
  167. resetCategory() {
  168. let auth = this.$data.auth;
  169. let currCategory = this.$data.currCategory;
  170. Object.assign(this.$data, this.$options.data());
  171. this.auth = auth;
  172. this.currCategory = currCategory;
  173. },
  174. getData() {
  175. let app = this;
  176. if (app.currCategory && (!app.currCategory.id || app.currCategory.id==='')) {
  177. return;
  178. }
  179. app.tableData = [];
  180. let params = {
  181. menuId: app.currCategory.id,
  182. page: app.pageInfo.page,
  183. pageSize: app.pageInfo.pageSize,
  184. }
  185. Object.assign(params, app.filterForm)
  186. app.handleLoading(true)
  187. api.getData(params).then(res => {
  188. if (res.code === 200) {
  189. app.pageInfo.total = res.total;
  190. app.tableData = res.content
  191. }
  192. app.handleLoading(false)
  193. }).catch(err => {
  194. app.handleLoading(false)
  195. })
  196. },
  197. search() {
  198. let app = this;
  199. this.pageInfo.pageSize = -1;
  200. setTimeout(function () {
  201. app.pageInfo.pageSize = 10;
  202. })
  203. },
  204. handleTableSelect(val) {
  205. this.selectedRows = val;
  206. },
  207. handleDetailShow(flag) {
  208. if (flag) {
  209. this.getData()
  210. }
  211. this.isDetailShow = false
  212. },
  213. // 录入数据
  214. addDataClick() {
  215. this.currRow = {};
  216. this.dialogTitle = '录入数据'
  217. this.isDetailShow = true;
  218. },
  219. // 批量删除数据
  220. batchDelete() {
  221. let app = this;
  222. if (!this.selectedRows || this.selectedRows.length===0) {
  223. app.$message({message:'请选择数据', type: 'warning'})
  224. return;
  225. }
  226. let ids = this.selectedRows.map(i=> {return i.id}).join(',');
  227. this.deleteData({id:ids})
  228. },
  229. // 查看详情
  230. viewData(item) {
  231. let app = this;
  232. this.dialogTitle = '数据详情'
  233. app.currRow = JSON.parse(JSON.stringify(item))
  234. if (app.currRow.menuId) {
  235. app.currRow.menuId = Number(app.currRow.menuId)
  236. }
  237. this.currRow.isDataView = true;
  238. app.isDetailShow = true
  239. },
  240. // 编辑数据
  241. editData(item) {
  242. let app = this;
  243. this.dialogTitle = '编辑数据'
  244. app.currRow = JSON.parse(JSON.stringify(item))
  245. if (app.currRow.menuId) {
  246. app.currRow.menuId = Number(app.currRow.menuId)
  247. }
  248. app.currRow.isEdit = true;
  249. app.isDetailShow = true
  250. },
  251. // 删除数据
  252. deleteData(item) {
  253. let app = this;
  254. app.$msgbox.confirm('确认要删除此条数据吗?').then(()=>{
  255. api.deleteData({modelId : item.id}).then(res=>{
  256. if (res.code === 200) {
  257. app.getData();
  258. app.$message({message: '删除成功', type: 'success'});
  259. }
  260. })
  261. })
  262. },
  263. }
  264. }
  265. </script>
  266. <style>
  267. </style>