BusinessData.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <!-- 业务数据 -->
  2. <template>
  3. <CategoryMenu :type="'business'" v-model:currVal="currCategory"></CategoryMenu>
  4. <div v-if="currCategory.id && currCategory.id !== ''" class="data">
  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="menuNameTwo" label="类别" width="80"/>
  44. <el-table-column prop="importType" label="导入类型" width="150"/>
  45. <el-table-column prop="address" label="地名地址库" width="150"/>
  46. <el-table-column prop="userName" label="修改人"/>
  47. <el-table-column prop="updateDate" label="修改时间" width="170">
  48. <template #default="scope">
  49. {{ $util.datetime.format(scope.row.updateDate) }}
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="createDate" label="创建时间" width="170">
  53. <template #default="scope">
  54. {{ $util.datetime.format(scope.row.createDate) }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column prop="operation" label="操作" width="150" fixed="right">
  58. <template #default="scope">
  59. <el-tooltip class="box-item" effect="dark" content="查看详情" placement="top-start">
  60. <el-button type="default" @click="viewData(scope.row)" circle>
  61. <el-icon>
  62. <ElIconView/>
  63. </el-icon>
  64. </el-button>
  65. </el-tooltip>
  66. <el-tooltip v-if="auth" class="box-item" effect="dark" content="编辑" placement="top-start">
  67. <el-button type="primary" @click="editData(scope.row)" circle>
  68. <el-icon>
  69. <ElIconEdit/>
  70. </el-icon>
  71. </el-button>
  72. </el-tooltip>
  73. <el-tooltip v-if="auth" class="box-item" effect="dark" content="删除" placement="top-start">
  74. <el-button type="danger" @click="deleteData(scope.row)" circle>
  75. <el-icon>
  76. <ElIconDelete/>
  77. </el-icon>
  78. </el-button>
  79. </el-tooltip>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <el-pagination style="float:right" background layout="sizes, prev, pager, next, jumper, total"
  84. v-model:current-page="pageInfo.page" v-model:page-size="pageInfo.pageSize"
  85. v-model:total="pageInfo.total"/>
  86. </div>
  87. </div>
  88. <BusinessDataDetail v-if="isDetailShow" :is-show="isDetailShow" :item="currRow" :curr-category="currCategory" :close="handleDetailShow"></BusinessDataDetail>
  89. </template>
  90. <script>
  91. import api from '@/api/data/BusinessData'
  92. import BusinessDataDetail from "@/components/dataManage/dataDetail/BusinessDataDetail";
  93. import CategoryMenu from "@/components/dataManage/CategoryMenu";
  94. export default {
  95. data() {
  96. return {
  97. auth: false,
  98. loading: false,
  99. filterForm: {},
  100. tableData: [],
  101. currRow: {},
  102. selectedRows: [],
  103. pageInfo: {
  104. page: 1,
  105. pageSize: 10,
  106. total: 0,
  107. },
  108. currCategory: {
  109. id: ''
  110. },
  111. isDetailShow: false,
  112. }
  113. },
  114. components: {
  115. BusinessDataDetail,
  116. CategoryMenu,
  117. },
  118. created() {
  119. let userInfo = this.$store.state.userInfo;
  120. if (userInfo.userLevel<2
  121. || (userInfo.userLevel===2) && userInfo.serviceId.split(',').indexOf(this.$constant.serviceId)>-1 ) {
  122. this.auth = true;
  123. }
  124. },
  125. mounted() {
  126. this.getData();
  127. },
  128. watch: {
  129. "pageInfo.page": function (val) {
  130. if (val > 0) {
  131. this.getData();
  132. }
  133. },
  134. "pageInfo.pageSize": function () {
  135. let app = this;
  136. this.pageInfo.page = -1;
  137. setTimeout(function () {
  138. app.pageInfo.page = 1;
  139. }, 50)
  140. },
  141. "currCategory.id": function () {
  142. this.resetCategory();
  143. this.getData();
  144. }
  145. },
  146. methods: {
  147. handleLoading(flag) {
  148. let app = this;
  149. if (flag) {
  150. app.loading = true;
  151. } else {
  152. setTimeout(() => {
  153. app.loading = false;
  154. }, 500);
  155. }
  156. },
  157. resetCategory() {
  158. let auth = this.$data.auth;
  159. let currCategory = this.$data.currCategory;
  160. Object.assign(this.$data, this.$options.data());
  161. this.auth = auth;
  162. this.currCategory = currCategory;
  163. },
  164. getData() {
  165. let app = this;
  166. if (app.currCategory && (!app.currCategory.id || app.currCategory.id==='')) {
  167. return;
  168. }
  169. app.tableData = [];
  170. let params = {
  171. menuId: app.currCategory.id,
  172. page: app.pageInfo.page,
  173. pageSize: app.pageInfo.pageSize,
  174. }
  175. Object.assign(params, app.filterForm)
  176. app.handleLoading(true)
  177. api.getData(params).then(res => {
  178. if (res.code === 200) {
  179. app.pageInfo.total = res.total;
  180. app.tableData = res.content
  181. }
  182. app.handleLoading(false)
  183. }).catch(err => {
  184. app.handleLoading(false)
  185. })
  186. },
  187. search() {
  188. let app = this;
  189. this.pageInfo.pageSize = -1;
  190. setTimeout(function () {
  191. app.pageInfo.pageSize = 10;
  192. })
  193. },
  194. handleTableSelect(val) {
  195. this.selectedRows = val;
  196. },
  197. handleDetailShow(flag) {
  198. if (flag) {
  199. this.getData()
  200. }
  201. this.isDetailShow = false
  202. },
  203. // 录入数据
  204. addDataClick() {
  205. this.currRow = {};
  206. this.isDetailShow = true;
  207. },
  208. // 批量删除数据
  209. batchDelete() {
  210. let app = this;
  211. if (!this.selectedRows || this.selectedRows.length===0) {
  212. app.$message({message:'请选择数据', type: 'warning'})
  213. return;
  214. }
  215. let ids = this.selectedRows.map(i=> {return i.id}).join(',');
  216. this.deleteData({id:ids})
  217. },
  218. // 查看详情
  219. viewData(item) {
  220. let app = this;
  221. let params = {
  222. baseId: item.id
  223. }
  224. app.$util.loading.handleLoading(true);
  225. api.getDataById(params).then(res=>{
  226. if (res.code===200) {
  227. if (!res.content.id || res.content.id==='') {
  228. app.$message({message: '该数据不存在', type: 'error'})
  229. return;
  230. }
  231. if (res.content.menuId) {
  232. res.content.menuId = Number(res.content.menuId);
  233. res.content.geometryStr = JSON.stringify(res.content.geometry);
  234. delete res.content.geometry;
  235. }
  236. app.currRow = JSON.parse(JSON.stringify(res.content))
  237. this.currRow.isDataView = true;
  238. app.isDetailShow = true
  239. }
  240. app.$util.loading.handleLoading(false);
  241. })
  242. },
  243. // 编辑数据
  244. editData(item) {
  245. let app = this;
  246. let params = {
  247. baseId: item.id
  248. }
  249. app.$util.loading.handleLoading(true);
  250. api.getDataById(params).then(res=>{
  251. if (!res.content.id || res.content.id==='') {
  252. app.$message({message: '该数据不存在', type: 'error'})
  253. return;
  254. }
  255. if (res.code===200) {
  256. if (res.content.menuId) {
  257. res.content.menuId = Number(res.content.menuId);
  258. res.content.geometryStr = JSON.stringify(res.content.geometry);
  259. delete res.content.geometry;
  260. }
  261. app.currRow = JSON.parse(JSON.stringify(res.content))
  262. app.currRow.isEdit = true;
  263. app.isDetailShow = true
  264. }
  265. app.$util.loading.handleLoading(false);
  266. })
  267. },
  268. // 删除数据
  269. deleteData(item) {
  270. let app = this;
  271. app.$msgbox.confirm('确认要删除此条数据吗?').then(()=>{
  272. api.deleteData({baseDataId: item.id}).then(res=>{
  273. if (res.code === 200) {
  274. app.getData();
  275. app.$message({message: '删除成功', type: 'success'});
  276. }
  277. })
  278. })
  279. },
  280. }
  281. }
  282. </script>
  283. <style>
  284. </style>