BusinessData.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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" :dialog-title="dialogTitle" :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. dialogTitle: '',
  98. auth: false,
  99. loading: false,
  100. filterForm: {},
  101. tableData: [],
  102. currRow: {},
  103. selectedRows: [],
  104. pageInfo: {
  105. page: 1,
  106. pageSize: 10,
  107. total: 0,
  108. },
  109. currCategory: {
  110. id: ''
  111. },
  112. isDetailShow: false,
  113. }
  114. },
  115. components: {
  116. BusinessDataDetail,
  117. CategoryMenu,
  118. },
  119. created() {
  120. let userInfo = this.$store.state.userInfo;
  121. if (userInfo.userLevel<2
  122. || (userInfo.userLevel===2) && userInfo.serviceId.split(',').indexOf(this.$constant.serviceId)>-1 ) {
  123. this.auth = true;
  124. }
  125. },
  126. mounted() {
  127. this.getData();
  128. },
  129. watch: {
  130. "pageInfo.page": function (val) {
  131. if (val > 0) {
  132. this.getData();
  133. }
  134. },
  135. "pageInfo.pageSize": function () {
  136. let app = this;
  137. this.pageInfo.page = -1;
  138. setTimeout(function () {
  139. app.pageInfo.page = 1;
  140. }, 50)
  141. },
  142. "currCategory.id": function () {
  143. this.resetCategory();
  144. this.getData();
  145. }
  146. },
  147. methods: {
  148. handleLoading(flag) {
  149. let app = this;
  150. if (flag) {
  151. app.loading = true;
  152. } else {
  153. setTimeout(() => {
  154. app.loading = false;
  155. }, 500);
  156. }
  157. },
  158. resetCategory() {
  159. let auth = this.$data.auth;
  160. let currCategory = this.$data.currCategory;
  161. Object.assign(this.$data, this.$options.data());
  162. this.auth = auth;
  163. this.currCategory = currCategory;
  164. },
  165. getData() {
  166. let app = this;
  167. if (app.currCategory && (!app.currCategory.id || app.currCategory.id==='')) {
  168. return;
  169. }
  170. app.tableData = [];
  171. let params = {
  172. menuId: app.currCategory.id,
  173. page: app.pageInfo.page,
  174. pageSize: app.pageInfo.pageSize,
  175. }
  176. Object.assign(params, app.filterForm)
  177. app.handleLoading(true)
  178. api.getData(params).then(res => {
  179. if (res.code === 200) {
  180. app.pageInfo.total = res.total;
  181. app.tableData = res.content
  182. }
  183. app.handleLoading(false)
  184. }).catch(err => {
  185. app.handleLoading(false)
  186. })
  187. },
  188. search() {
  189. let app = this;
  190. this.pageInfo.pageSize = -1;
  191. setTimeout(function () {
  192. app.pageInfo.pageSize = 10;
  193. })
  194. },
  195. handleTableSelect(val) {
  196. this.selectedRows = val;
  197. },
  198. handleDetailShow(flag) {
  199. if (flag) {
  200. this.getData()
  201. }
  202. this.isDetailShow = false
  203. },
  204. // 录入数据
  205. addDataClick() {
  206. this.currRow = {};
  207. this.dialogTitle = '录入数据'
  208. this.isDetailShow = true;
  209. },
  210. // 批量删除数据
  211. batchDelete() {
  212. let app = this;
  213. if (!this.selectedRows || this.selectedRows.length===0) {
  214. app.$message({message:'请选择数据', type: 'warning'})
  215. return;
  216. }
  217. let ids = this.selectedRows.map(i=> {return i.id}).join(',');
  218. this.deleteData({id:ids})
  219. },
  220. // 查看详情
  221. viewData(item) {
  222. let app = this;
  223. this.dialogTitle = '数据详情'
  224. let params = {
  225. baseId: item.id
  226. }
  227. app.$util.loading.handleLoading(true);
  228. api.getDataById(params).then(res=>{
  229. if (res.code===200) {
  230. if (!res.content.id || res.content.id==='') {
  231. app.$message({message: '该数据不存在', type: 'error'})
  232. return;
  233. }
  234. if (res.content.menuId) {
  235. res.content.menuId = Number(res.content.menuId);
  236. res.content.geometryStr = JSON.stringify(res.content.geometry);
  237. delete res.content.geometry;
  238. }
  239. app.currRow = JSON.parse(JSON.stringify(res.content))
  240. this.currRow.isDataView = true;
  241. app.isDetailShow = true
  242. }
  243. app.$util.loading.handleLoading(false);
  244. })
  245. },
  246. // 编辑数据
  247. editData(item) {
  248. let app = this;
  249. this.dialogTitle = '编辑数据'
  250. let params = {
  251. baseId: item.id
  252. }
  253. app.$util.loading.handleLoading(true);
  254. api.getDataById(params).then(res=>{
  255. if (!res.content.id || res.content.id==='') {
  256. app.$message({message: '该数据不存在', type: 'error'})
  257. return;
  258. }
  259. if (res.code===200) {
  260. if (res.content.menuId) {
  261. res.content.menuId = Number(res.content.menuId);
  262. res.content.geometryStr = JSON.stringify(res.content.geometry);
  263. delete res.content.geometry;
  264. }
  265. app.currRow = JSON.parse(JSON.stringify(res.content))
  266. app.currRow.isEdit = true;
  267. app.isDetailShow = true
  268. }
  269. app.$util.loading.handleLoading(false);
  270. })
  271. },
  272. // 删除数据
  273. deleteData(item) {
  274. let app = this;
  275. app.$msgbox.confirm('确认要删除此条数据吗?').then(()=>{
  276. api.deleteData({baseDataId: item.id}).then(res=>{
  277. if (res.code === 200) {
  278. app.getData();
  279. app.$message({message: '删除成功', type: 'success'});
  280. }
  281. })
  282. })
  283. },
  284. }
  285. }
  286. </script>
  287. <style>
  288. </style>