sharedList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <script setup name="SheetETAList">
  2. import apiSheet from '@/api/sheet'
  3. import {ref,reactive,watch,computed} from 'vue'
  4. import { useRouter } from "vue-router";
  5. import useLocaleStore from "@/store/modules/i18n";
  6. import CatalogTree from './components/CatalogTree.vue';
  7. import CatalogItem from './components/CatalogItem.vue';
  8. import { useNoAuth } from '@/hooks/useNoAuth'
  9. import { showToast } from "vant";
  10. //激活的目录路径
  11. const catalogMenu = ref('')
  12. const router = useRouter()
  13. //表格列表
  14. const listState = reactive({
  15. cid:0,
  16. list:[],
  17. page:1,
  18. pageSize:15,
  19. finished:false,
  20. loading:false,
  21. total:0,
  22. IsShowMe:false
  23. })
  24. //是否展示目录列表
  25. const IsShowCatalog = ref(false)
  26. const localeStore = useLocaleStore()
  27. const temp = localeStore.locale === 'zhCn' ? 'zhCn' : 'en'; //根据当前i18n语言设置表格默认语言
  28. localeStore.SET_LOCALE(temp)
  29. watch(()=>listState.IsShowMe,()=>{
  30. window.scrollTo({top:0})
  31. listState.list=[]
  32. listState.page=1
  33. //设置数据已加载完毕,因为当滚动条不在顶部时,清空列表内容会触发onLoad
  34. listState.finished = true
  35. //这个函数调用完成后,会把finished重置成正确的值
  36. getSheetList()
  37. })
  38. getSheetList()
  39. //获取表格列表
  40. async function getSheetList(){
  41. const {pageSize,cid,page,IsShowMe} = listState
  42. const res = await apiSheet.sheetList({
  43. PageSize: pageSize,
  44. CurrentIndex: page,
  45. Source: 1,
  46. ExcelClassifyId: cid,
  47. IsShowMe,
  48. })
  49. if(res.Ret!==200) return
  50. const arr = res.Data?res.Data.List:[]
  51. listState.list = [...listState.list,...arr]
  52. listState.total = res.Data?res.Data.Paging.Totals:0
  53. listState.finished = res.Data?res.Data.Paging.IsEnd:true
  54. listState.loading=false
  55. }
  56. //目录被点击 type:['top'一级目录,'node'二级目录,'item'三级目录]
  57. function catalogItemClick({item,type='node',parent={}}){
  58. console.log(item);
  59. console.log(type);
  60. console.log(parent);
  61. const topMenu = type==='top'?item.ExcelClassifyName:type==='node'?item.parentName:parent.parentName
  62. const nodeMenu = type==='node'?item.ExcelClassifyName:type==='item'?parent.ExcelClassifyName:''
  63. const itemMenu = type==='item'?item.ExcelClassifyName:''
  64. catalogMenu.value = `${topMenu}${nodeMenu.length?`/${nodeMenu}`:''}${itemMenu.length?`/${itemMenu}`:''}`
  65. console.log();
  66. listState.cid = item.ExcelClassifyId
  67. listState.list=[]
  68. listState.page=1
  69. getSheetList()
  70. }
  71. //展示目录列表
  72. function showCatalog(){
  73. IsShowCatalog.value = true
  74. }
  75. //下拉加载
  76. function onLoad(){
  77. if(IsShowCatalog.value) return
  78. listState.page++
  79. getSheetList()
  80. }
  81. //展开的目录
  82. const activeCatalogs = ref([])
  83. //目录列表
  84. const catalogNodes = ref([])
  85. const dataNodes = ref([])
  86. getCatalogList()
  87. //获取目录列表
  88. async function getCatalogList(){
  89. const {IsShowMe} = listState
  90. const res = await apiSheet.excelClassifyList({
  91. Source: 1,
  92. IsShowMe: IsShowMe
  93. })
  94. if(res.Ret!==200) return
  95. console.log(res);
  96. dataNodes.value = res.Data?res.Data.AllNodes:[]||[]
  97. catalogNodes.value = dataNodes.value.map(node=>{
  98. if(node.Children){
  99. node.Children = node.Children.map(child=>{
  100. child.parentName = node.ExcelClassifyName //添加子分类时需要显示父级分类名称
  101. if(child.Children){//改成三级目录了
  102. child.Children = child.Children.map(_child=>{
  103. _child.parentName = child.ExcelClassifyName
  104. return _child
  105. })
  106. }
  107. return child
  108. })
  109. }
  110. return node
  111. })
  112. }
  113. function showFileOpt(item){
  114. console.log(item);
  115. }
  116. //跳转至详情页
  117. const goSheetDetail = (item)=>{
  118. if(!item.HaveOperaAuth) return showToast(useNoAuth().sheet)
  119. router.push({
  120. path:'/shared/detail',
  121. query:{
  122. id:item.ExcelInfoId,
  123. Source:item.Source,
  124. }
  125. })
  126. }
  127. function goSheetSearch(){
  128. router.push({
  129. path:'/shared/search',
  130. query:{
  131. Source: 1,
  132. }
  133. })
  134. }
  135. </script>
  136. <template>
  137. <div class="excel-eta-list-wrap">
  138. <div class="select-wrap">
  139. <div class="search-box">
  140. <van-search
  141. shape="round"
  142. readonly
  143. :placeholder="$t('shared_table.enter_table_name')"
  144. style="flex:1;padding-left:0"
  145. @click-input="goSheetSearch"
  146. />
  147. <div class="list-icon icon" @click="showCatalog">
  148. <img src="@/assets/imgs/chartETA/list-icon.png" alt="">
  149. </div>
  150. </div>
  151. <p style="font-weight: bold;word-break: break-all;margin-bottom: 5px;">{{ catalogMenu }}</p>
  152. <div class="select-box">
  153. <span>{{ $t('shared_table.tables_total', {totalNum: listState.total}) }}</span>
  154. <span> <van-checkbox v-model="listState.IsShowMe">{{ $t('shared_table.just_look_mine') }}</van-checkbox></span>
  155. </div>
  156. </div>
  157. <div class="excel-list-wrap">
  158. <van-list
  159. v-model:loading="listState.loading"
  160. :finished="listState.finished"
  161. :finished-text="listState.list.length > 0 ? $t('shared_table.no_more') : $t('shared_table.no_table')"
  162. :immediate-check="false"
  163. @load="onLoad"
  164. >
  165. <img v-if="listState.list.length==0&&listState.finished" class="list-empty-img" src="https://hzstatic.hzinsights.com/static/ETA_mobile/empty_img.png" alt="">
  166. <ul class="excel-list">
  167. <li
  168. class="excel-list-item"
  169. v-for="item in listState.list"
  170. :key="item.ChartInfoId"
  171. @click="goSheetDetail(item)"
  172. >
  173. <div class="title">{{item.ExcelName}}</div>
  174. <img class="img" :src="!item.HaveOperaAuth?useNoAuth().noAuthImg:item.ExcelImage" alt="">
  175. <div class="time">
  176. <span>{{item.CreateTime.slice(0,10)}}</span>
  177. </div>
  178. </li>
  179. </ul>
  180. </van-list>
  181. </div>
  182. <!-- 目录列表 -->
  183. <van-popup v-model:show="IsShowCatalog" position="right" class="catalog-list-wrap" style="height:100%">
  184. <div class="catalog-list">
  185. <div class="top sticky-part">
  186. <h3>{{ $t('shared_table.choose_category') }}</h3>
  187. <van-icon name="cross" @click.stop="IsShowCatalog=false"/>
  188. </div>
  189. <!-- 将目录改为三级 -->
  190. <div class="list-box catalog-tree-wrap">
  191. <van-collapse v-model="activeCatalogs" :border="false">
  192. <van-collapse-item
  193. v-for="catalog in catalogNodes" :key="catalog.UniqueCode" :name="catalog.UniqueCode"
  194. @click.stop="catalogItemClick({item:catalog,type:'top'})">
  195. <template #title>
  196. <CatalogItem
  197. :node="catalog"
  198. @showPopup="showFileOpt"/>
  199. </template>
  200. <CatalogTree
  201. :catalog-nodes="catalog.Children"
  202. :showFileOpt="showFileOpt"
  203. :activeId="listState.cid"
  204. @handleCatalogItemClick="catalogItemClick"
  205. />
  206. </van-collapse-item>
  207. </van-collapse>
  208. </div>
  209. </div>
  210. </van-popup>
  211. </div>
  212. </template>
  213. <style lang="scss">
  214. .excel-eta-list-wrap{
  215. .catalog-list-wrap{
  216. width: 65%;
  217. }
  218. .rename-wrap{
  219. padding:48px;
  220. input{
  221. padding: 24px 32px;
  222. border-radius: 12px;
  223. background-color: #F6F6F6;
  224. width: 100%;
  225. }
  226. .label{
  227. color: #666666;
  228. margin-bottom: 32px;
  229. text-align: center;
  230. }
  231. }
  232. @media screen and (min-width:$media-width){
  233. .catalog-list-wrap{
  234. width: 30%;
  235. }
  236. .move-popup{
  237. width:375px;
  238. }
  239. .rename-wrap{
  240. padding:24px;
  241. input{
  242. padding: 12px 16px;
  243. border-radius: 6px;
  244. background-color: #F6F6F6;
  245. width: 100%;
  246. }
  247. .label{
  248. margin-bottom: 16px;
  249. }
  250. }
  251. }
  252. }
  253. </style>
  254. <style scoped lang="scss">
  255. .excel-eta-list-wrap{
  256. .select-wrap{
  257. padding: 0 30px 30px 30px;
  258. position: sticky;
  259. top:0;
  260. background-color: #fff;
  261. .search-box{
  262. display: flex;
  263. align-items: center;
  264. .icon{
  265. margin-left: 10px;
  266. width: 70px;
  267. height:70px;
  268. background-color: #F2F3FF;
  269. border-radius: 50%;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. img{
  274. width:45px;
  275. height:45px;
  276. }
  277. }
  278. }
  279. .select-box{
  280. display: flex;
  281. justify-content: space-between;
  282. flex-wrap: wrap;
  283. }
  284. }
  285. .excel-list-wrap{
  286. //margin-top:15px;
  287. padding: 0 30px;
  288. padding-bottom: 30px;
  289. .excel-list{
  290. display: flex;
  291. justify-content: space-between;
  292. flex-wrap: wrap;
  293. gap: 30px 0;
  294. .excel-list-item{
  295. box-sizing: border-box;
  296. width: 330px;
  297. padding: 10px 14px;
  298. border: 1px solid $border-color;
  299. border-radius: 12px;
  300. .title{
  301. min-height: 70px;
  302. overflow: hidden;
  303. -webkit-line-clamp: 2;
  304. text-overflow: ellipsis;
  305. display:-webkit-box !important;
  306. -webkit-box-orient:vertical;
  307. word-break: break-word;
  308. }
  309. .img{
  310. width: 100%;
  311. height: 220px;
  312. display: block;
  313. margin: 10px 0;
  314. }
  315. .time{
  316. display: flex;
  317. justify-content: space-between;
  318. font-size: 28px;
  319. color: $font-grey_999;
  320. .tool-icon{
  321. width:30px;
  322. text-align: right;
  323. img{
  324. width:5px;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. }
  331. .catalog-list{
  332. box-sizing: border-box;
  333. height: 100%;
  334. .sticky-part{
  335. position:sticky;
  336. background-color: white;
  337. z-index: 99;
  338. left:0;
  339. right:0;
  340. }
  341. .top{
  342. display: flex;
  343. justify-content: space-between;
  344. border-bottom: 1px solid #DCDFE6;
  345. padding: 0 15px;
  346. align-items: center;
  347. top:0;
  348. }
  349. .bottom{
  350. display: flex;
  351. padding:48px;
  352. bottom:0;
  353. span{
  354. flex: 1;
  355. background-color: #0052D9;
  356. color: white;
  357. text-align: center;
  358. border-radius: 6px;
  359. padding:16px;
  360. box-sizing: border-box;
  361. }
  362. }
  363. }
  364. @media screen and (min-width:$media-width){
  365. .select-wrap{
  366. // top:60px;
  367. padding:30px;
  368. .search-box{
  369. .icon{
  370. margin-left: 10px;
  371. width: 40px;
  372. height:40px;
  373. background-color: #F2F3FF;
  374. border-radius: 50%;
  375. img{
  376. width:25px;
  377. height:25px;
  378. }
  379. }
  380. }
  381. .select-box{
  382. margin-top:20px;
  383. }
  384. }
  385. .excel-list-wrap{
  386. padding:0 30px;
  387. .excel-list{
  388. gap: 20px 4%;
  389. justify-content:flex-start;
  390. .excel-list-item{
  391. box-sizing: border-box;
  392. width: 22%;
  393. padding: 10px 14px;
  394. border: 1px solid $border-color;
  395. border-radius: 6px;
  396. .title{
  397. min-height: 36px;
  398. }
  399. .img{
  400. width: 100%;
  401. height: 120px;
  402. display: block;
  403. margin: 10px 0;
  404. }
  405. .time{
  406. font-size: 14px;
  407. .tool-icon>img{
  408. width:3px;
  409. }
  410. }
  411. }
  412. }
  413. }
  414. .catalog-list{
  415. .bottom{
  416. display: flex;
  417. padding:24px;
  418. bottom:0;
  419. span{
  420. flex: 1;
  421. background-color: #0052D9;
  422. color: white;
  423. text-align: center;
  424. border-radius: 6px;
  425. padding:8px;
  426. box-sizing: border-box;
  427. }
  428. }
  429. }
  430. }
  431. }
  432. </style>