93c2220dddca2f0462ca1e3e3a50c65ffebd99fa.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  8. <a-form-item label="图层名称">
  9. <a-input placeholder="请输入图层名称" v-model="queryParam.name"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  13. <a-form-item label="图层别名">
  14. <a-input placeholder="请输入图层别名" v-model="queryParam.alias"></a-input>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  18. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  19. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  20. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  21. <!-- <a @click="handleToggleSearch" style="margin-left: 8px">-->
  22. <!-- {{ toggleSearchStatus ? '收起' : '展开' }}-->
  23. <!-- <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
  24. <!-- </a>-->
  25. </span>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 查询区域-END -->
  31. <!-- 操作按钮区域 -->
  32. <div class="table-operator">
  33. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  34. <a-button type="primary" icon="download" @click="handleExportXls('资源目录')">导出</a-button>
  35. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  36. <a-button type="primary" icon="import">导入</a-button>
  37. </a-upload>
  38. <!-- 高级查询区域 -->
  39. <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
  40. <a-dropdown v-if="selectedRowKeys.length > 0">
  41. <a-menu slot="overlay">
  42. <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
  43. </a-menu>
  44. <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
  45. </a-dropdown>
  46. </div>
  47. <!-- table区域-begin -->
  48. <div>
  49. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  50. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  51. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  52. </div>
  53. <a-table
  54. ref="table"
  55. size="middle"
  56. rowKey="id"
  57. class="j-table-force-nowrap"
  58. :scroll="{x:true}"
  59. :columns="columns"
  60. :dataSource="dataSource"
  61. :pagination="ipagination"
  62. :loading="loading"
  63. :expandedRowKeys="expandedRowKeys"
  64. @change="handleTableChange"
  65. @expand="handleExpand"
  66. v-bind="tableProps">
  67. <template slot="imgSlot" slot-scope="text">
  68. <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
  69. <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
  70. </template>
  71. <template slot="fileSlot" slot-scope="text">
  72. <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
  73. <a-button
  74. v-else
  75. :ghost="true"
  76. type="primary"
  77. icon="download"
  78. size="small"
  79. @click="downloadFile(text)">
  80. 下载
  81. </a-button>
  82. </template>
  83. <span slot="action" slot-scope="text, record">
  84. <a @click="handleEdit(record)">编辑</a>
  85. <a-divider type="vertical" />
  86. <a-dropdown>
  87. <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
  88. <a-menu slot="overlay">
  89. <a-menu-item>
  90. <a @click="handleAddChild(record)">添加下级</a>
  91. </a-menu-item>
  92. <a-menu-item>
  93. <a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteNode(record.id)" placement="topLeft">
  94. <a>删除</a>
  95. </a-popconfirm>
  96. </a-menu-item>
  97. </a-menu>
  98. </a-dropdown>
  99. </span>
  100. </a-table>
  101. </div>
  102. <rescatalog-modal ref="modalForm" @ok="modalFormOk"></rescatalog-modal>
  103. </a-card>
  104. </template>
  105. <script>
  106. import { getAction, deleteAction } from '@/api/manage'
  107. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  108. import RescatalogModal from './modules/RescatalogModal'
  109. import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  110. import { filterObj } from '@/utils/util';
  111. export default {
  112. name: "RescatalogList",
  113. mixins:[JeecgListMixin],
  114. components: {
  115. RescatalogModal
  116. },
  117. data () {
  118. return {
  119. description: '资源目录管理页面',
  120. // 表头
  121. columns: [
  122. {
  123. title:'图层别名',
  124. align:"left",
  125. dataIndex: 'alias'
  126. },
  127. {
  128. title:'图层名称',
  129. align:"center",
  130. dataIndex: 'name'
  131. },
  132. {
  133. title:'图层服务地址',
  134. align:"left",
  135. dataIndex: 'url'
  136. },
  137. {
  138. title:'是否显示',
  139. align:"center",
  140. dataIndex: 'visible_dictText'
  141. },
  142. {
  143. title:'数据源名称',
  144. align:"center",
  145. dataIndex: 'sourcename'
  146. },
  147. {
  148. title:'显示层级',
  149. align:"center",
  150. dataIndex: 'zindex'
  151. },
  152. {
  153. title:'列表显示顺序',
  154. align:"center",
  155. dataIndex: 'displayorder'
  156. },
  157. {
  158. title:'图例',
  159. align:"center",
  160. dataIndex: 'legend',
  161. scopedSlots: {customRender: 'imgSlot'}
  162. },
  163. {
  164. title: '操作',
  165. dataIndex: 'action',
  166. align:"center",
  167. fixed:"right",
  168. width:147,
  169. scopedSlots: { customRender: 'action' },
  170. }
  171. ],
  172. url: {
  173. list: "/resManager.catalog/rescatalog/rootList",
  174. childList: "/resManager.catalog/rescatalog/childList",
  175. getChildListBatch: "/resManager.catalog/rescatalog/getChildListBatch",
  176. delete: "/resManager.catalog/rescatalog/delete",
  177. deleteBatch: "/resManager.catalog/rescatalog/deleteBatch",
  178. exportXlsUrl: "/resManager.catalog/rescatalog/exportXls",
  179. importExcelUrl: "resManager.catalog/rescatalog/importExcel",
  180. },
  181. expandedRowKeys:[],
  182. hasChildrenField:"hasChild",
  183. pidField:"pid",
  184. dictOptions: {},
  185. loadParent: false,
  186. superFieldList:[],
  187. }
  188. },
  189. created() {
  190. this.getSuperFieldList();
  191. },
  192. computed: {
  193. importExcelUrl(){
  194. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  195. },
  196. tableProps() {
  197. let _this = this
  198. return {
  199. // 列表项是否可选择
  200. rowSelection: {
  201. selectedRowKeys: _this.selectedRowKeys,
  202. onChange: (selectedRowKeys) => _this.selectedRowKeys = selectedRowKeys
  203. }
  204. }
  205. }
  206. },
  207. methods: {
  208. loadData(arg){
  209. if(arg==1){
  210. this.ipagination.current=1
  211. }
  212. this.loading = true
  213. let params = this.getQueryParams()
  214. params.hasQuery = 'true'
  215. getAction(this.url.list,params).then(res=>{
  216. if(res.success){
  217. let result = res.result
  218. if(Number(result.total)>0){
  219. this.ipagination.total = Number(result.total)
  220. this.dataSource = this.getDataByResult(res.result.records)
  221. return this.loadDataByExpandedRows(this.dataSource)
  222. }else{
  223. this.ipagination.total=0
  224. this.dataSource=[]
  225. }
  226. }else{
  227. this.$message.warning(res.message)
  228. }
  229. }).finally(()=>{
  230. this.loading = false
  231. })
  232. },
  233. // 根据已展开的行查询数据(用于保存后刷新时异步加载子级的数据)
  234. loadDataByExpandedRows(dataList) {
  235. if (this.expandedRowKeys.length > 0) {
  236. return getAction(this.url.getChildListBatch,{ parentIds: this.expandedRowKeys.join(',') }).then(res=>{
  237. if (res.success && res.result.records.length>0) {
  238. //已展开的数据批量子节点
  239. let records = res.result.records
  240. const listMap = new Map();
  241. for (let item of records) {
  242. let pid = item[this.pidField];
  243. if (this.expandedRowKeys.join(',').includes(pid)) {
  244. let mapList = listMap.get(pid);
  245. if (mapList == null) {
  246. mapList = [];
  247. }
  248. mapList.push(item);
  249. listMap.set(pid, mapList);
  250. }
  251. }
  252. let childrenMap = listMap;
  253. let fn = (list) => {
  254. if(list) {
  255. list.forEach(data => {
  256. if (this.expandedRowKeys.includes(data.id)) {
  257. data.children = this.getDataByResult(childrenMap.get(data.id))
  258. fn(data.children)
  259. }
  260. })
  261. }
  262. }
  263. fn(dataList)
  264. }
  265. })
  266. } else {
  267. return Promise.resolve()
  268. }
  269. },
  270. getQueryParams(arg) {
  271. //获取查询条件
  272. let sqp = {}
  273. let param = {}
  274. if(this.superQueryParams){
  275. sqp['superQueryParams']=encodeURI(this.superQueryParams)
  276. sqp['superQueryMatchType'] = this.superQueryMatchType
  277. }
  278. if(arg){
  279. param = Object.assign(sqp, this.isorter ,this.filters);
  280. }else{
  281. param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
  282. }
  283. if(JSON.stringify(this.queryParam) === "{}" || arg){
  284. param.hasQuery = 'false'
  285. }else{
  286. param.hasQuery = 'true'
  287. }
  288. param.field = this.getQueryField();
  289. param.pageNo = this.ipagination.current;
  290. param.pageSize = this.ipagination.pageSize;
  291. return filterObj(param);
  292. },
  293. searchReset() {
  294. //重置
  295. this.expandedRowKeys = []
  296. this.queryParam = {}
  297. this.loadData(1);
  298. },
  299. getDataByResult(result){
  300. if(result){
  301. return result.map(item=>{
  302. //判断是否标记了带有子节点
  303. if(item[this.hasChildrenField]=='1'){
  304. let loadChild = { id: item.id+'_loadChild', name: 'loading...', isLoading: true }
  305. item.children = [loadChild]
  306. }
  307. return item
  308. })
  309. }
  310. },
  311. handleExpand(expanded, record){
  312. // 判断是否是展开状态
  313. if (expanded) {
  314. this.expandedRowKeys.push(record.id)
  315. if (record.children.length>0 && record.children[0].isLoading === true) {
  316. let params = this.getQueryParams(1);//查询条件
  317. params[this.pidField] = record.id
  318. params.hasQuery = 'false'
  319. params.superQueryParams=""
  320. getAction(this.url.childList,params).then((res)=>{
  321. if(res.success){
  322. if(res.result.records){
  323. record.children = this.getDataByResult(res.result.records)
  324. this.dataSource = [...this.dataSource]
  325. }else{
  326. record.children=''
  327. record.hasChildrenField='0'
  328. }
  329. }else{
  330. this.$message.warning(res.message)
  331. }
  332. })
  333. }
  334. }else{
  335. let keyIndex = this.expandedRowKeys.indexOf(record.id)
  336. if(keyIndex>=0){
  337. this.expandedRowKeys.splice(keyIndex, 1);
  338. }
  339. }
  340. },
  341. handleAddChild(record){
  342. this.loadParent = true
  343. let obj = {}
  344. obj[this.pidField] = record['id']
  345. this.$refs.modalForm.add(obj);
  346. },
  347. handleDeleteNode(id) {
  348. if(!this.url.delete){
  349. this.$message.error("请设置url.delete属性!")
  350. return
  351. }
  352. var that = this;
  353. deleteAction(that.url.delete, {id: id}).then((res) => {
  354. if (res.success) {
  355. that.loadData(1)
  356. } else {
  357. that.$message.warning(res.message);
  358. }
  359. });
  360. },
  361. batchDel(){
  362. if(this.selectedRowKeys.length<=0){
  363. this.$message.warning('请选择一条记录!');
  364. return false;
  365. }else{
  366. let ids = "";
  367. let that = this;
  368. that.selectedRowKeys.forEach(function(val) {
  369. ids+=val+",";
  370. });
  371. that.$confirm({
  372. title:"确认删除",
  373. content:"是否删除选中数据?",
  374. onOk: function(){
  375. that.handleDeleteNode(ids)
  376. that.onClearSelected();
  377. }
  378. });
  379. }
  380. },
  381. getSuperFieldList(){
  382. let fieldList=[];
  383. fieldList.push({type:'string',value:'pid',text:'父级节点',dictCode:''})
  384. fieldList.push({type:'string',value:'name',text:'图层名称',dictCode:''})
  385. fieldList.push({type:'string',value:'alias',text:'图层别名',dictCode:''})
  386. fieldList.push({type:'string',value:'url',text:'图层服务地址',dictCode:''})
  387. fieldList.push({type:'string',value:'dataport',text:'数据服务接口',dictCode:''})
  388. fieldList.push({type:'string',value:'relfield',text:'数据关联字段',dictCode:''})
  389. fieldList.push({type:'string',value:'visible',text:'是否显示',dictCode:'visible'})
  390. fieldList.push({type:'string',value:'sourcename',text:'数据源名称',dictCode:''})
  391. fieldList.push({type:'int',value:'zindex',text:'显示层级',dictCode:''})
  392. fieldList.push({type:'int',value:'displayorder',text:'列表显示顺序',dictCode:''})
  393. fieldList.push({type:'string',value:'legend',text:'图例',dictCode:''})
  394. this.superFieldList = fieldList
  395. }
  396. }
  397. }
  398. </script>
  399. <style scoped>
  400. @import '~@assets/less/common.less';
  401. </style>