selectDoc.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="选择" @clickLeft="back">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <u-button type="success" size="small" class="u-reset-button" @click="$refs.treePicker._show()"
  7. text="文件夹"></u-button>
  8. </template>
  9. </uni-nav-bar>
  10. <view class="wrapper">
  11. <u-list class="listContent">
  12. <checkbox-group v-for="(item, index) in listData" :key="index" @change="e => selectVal(e, item, index)">
  13. <label>
  14. <view class="listBox">
  15. <view class="listBox-sel">
  16. <checkbox :value="item.code" color="#fff" :disabled="item.disabled"
  17. :checked="item.checked" />
  18. </view>
  19. <view class="listBox-con">
  20. <view class="listBox-top">
  21. <view class="listBox-name">
  22. {{ item.name }}
  23. </view>
  24. <view class="listBox-code">
  25. {{ item.code }}
  26. </view>
  27. </view>
  28. <view class="listBox-bottom">
  29. <view>文件名称:{{ item.storagePath[0].name }}</view>
  30. <view>版本:{{ item.version }}</view>
  31. <view>创建人:{{ item.createUserName }}</view>
  32. <view>创建时间:{{ item.createTime }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </label>
  37. </checkbox-group>
  38. <u-empty class="noDate" style="margin-top: 20vh" v-if="!listData.length"></u-empty>
  39. </u-list>
  40. </view>
  41. <view class="footer">
  42. <view class="bottom" v-if="this.isAll==1">
  43. <checkbox v-if="!seletedAll" color="#fff" :checked="seletedAll" @tap="_seletedAll">全选</checkbox>
  44. <checkbox class="select-all" color="#fff" v-else :checked="seletedAll" @tap="_seletedAll">取消全选
  45. </checkbox>
  46. </view>
  47. <u-button type="success" size="small" class="u-reset-button" :disabled="!checkListLen" @click="jumpAdd">
  48. <view class="selBtn">选择( {{ checkListLen }} )</view>
  49. </u-button>
  50. </view>
  51. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择文件夹"
  52. :localdata="classificationList" valueKey="id" textKey="name" childrenKey='sonDirectoryList' />
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. getDocTreeListAPI,
  58. filePageAPI
  59. } from './api';
  60. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  61. export default {
  62. components: {
  63. baTreePicker
  64. },
  65. data() {
  66. return {
  67. pickTabIndex: 1,
  68. popupShow: false, //右侧搜索窗
  69. typeIndex: 1,
  70. listData: [], //列表数据
  71. classificationList: [], //分类数据
  72. seletedAll: false, //全选状态,
  73. isAll: '',
  74. fileId:[]
  75. }
  76. },
  77. //选择的列表长度
  78. computed: {
  79. checkListLen() {
  80. return this.listData.filter(el => el.checked).length
  81. },
  82. },
  83. onLoad({
  84. isAll,fileId
  85. }) {
  86. this.isAll = isAll //1多选 2单选
  87. this.fileId=JSON.parse(fileId)
  88. this.userInfo = uni.getStorageSync('userInfo')
  89. this.getClassify()
  90. },
  91. onShow() {},
  92. methods: {
  93. //列表数据
  94. async getList() {
  95. this._getClassifyList()
  96. },
  97. async _getClassifyList() {
  98. uni.showLoading({
  99. title: '数据加载中'
  100. })
  101. const params = {
  102. directoryId: this.categoryLevelId,
  103. fileType: 0,
  104. lcyStatus: "1"
  105. }
  106. filePageAPI(params).then(res => {
  107. uni.hideLoading()
  108. this.listData = res.list.map(item=>{
  109. if(this.fileId.includes(item.id)){
  110. item['disabled']=true
  111. }
  112. return item
  113. })
  114. })
  115. },
  116. confirm([id]) {
  117. this.categoryLevelId = id
  118. this.getList()
  119. },
  120. async getClassify() {
  121. getDocTreeListAPI({
  122. type: 0,
  123. currentUserId: this.userInfo.userId
  124. }).then(res => {
  125. this.classificationList = res
  126. this.categoryLevelId=res[0].id
  127. console.log(this.classificationList, 'this.classificationList')
  128. this.getList()
  129. });
  130. },
  131. //勾选
  132. selectVal(e, val, index) {
  133. this.$set(this.listData[index], 'checked', !this.listData[index].checked)
  134. if (this.isAll != 1) {
  135. this.listData.forEach((item, i) => {
  136. if (item.id != val.id) {
  137. this.$set(this.listData[i], 'checked', false)
  138. }
  139. })
  140. } else {
  141. this.seletedAll = !this.listData.some(item => !item.checked)
  142. }
  143. },
  144. //全选按钮
  145. _seletedAll() {
  146. if (!this.seletedAll) {
  147. this.seletedAll = true
  148. this.listData.map(item => {
  149. this.$set(item, 'checked', true)
  150. })
  151. } else {
  152. this.seletedAll = false
  153. this.listData.map(item => {
  154. this.$set(item, 'checked', false)
  155. })
  156. }
  157. },
  158. //跳转回添加页面
  159. jumpAdd() {
  160. uni.$emit(
  161. 'setDocList',
  162. this.listData.filter(item => item.checked).map(item=>item.id)
  163. )
  164. uni.navigateBack()
  165. },
  166. //返回添加页
  167. backAdd() {
  168. uni.navigateBack()
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. .mainBox {
  175. height: 100vh;
  176. display: flex;
  177. flex-direction: column;
  178. .wrapper {
  179. flex: 1;
  180. overflow: hidden;
  181. }
  182. .searchBox {
  183. padding: 10rpx 0;
  184. box-sizing: border-box;
  185. background-color: #dedede;
  186. height: 90rpx;
  187. width: 100%;
  188. line-height: 90rpx;
  189. display: flex;
  190. justify-content: space-around;
  191. align-items: center;
  192. input {
  193. height: 78rpx;
  194. width: 65%;
  195. background: #f9f9f9 !important;
  196. margin: 0 10rpx;
  197. padding: 0 10rpx;
  198. box-sizing: border-box;
  199. border-radius: 5rpx;
  200. }
  201. .searchBtn {
  202. height: 80rpx;
  203. background: #f9f9f9 !important;
  204. color: #676767;
  205. font-size: 28rpx;
  206. padding: 0 42rpx;
  207. box-sizing: border-box;
  208. outline: none;
  209. border: none;
  210. width: 260rpx;
  211. .icon-sousuo {
  212. font-size: 22px;
  213. }
  214. .text {
  215. font-size: 16px;
  216. margin-left: 10px;
  217. }
  218. }
  219. }
  220. .tab-title {
  221. position: fixed;
  222. top: 190rpx;
  223. z-index: 99;
  224. width: 100%;
  225. display: flex;
  226. justify-content: space-between;
  227. align-items: center;
  228. height: $tab-height;
  229. line-height: $tab-height;
  230. background-color: #ffffff;
  231. border-bottom: 2rpx solid #f2f2f2;
  232. box-sizing: border-box;
  233. .tab-item {
  234. width: 25%;
  235. text-align: center;
  236. font-size: 32rpx;
  237. color: $uni-text-color-grey;
  238. }
  239. .tab-item.active {
  240. color: $j-primary-border-green;
  241. border-bottom: 1px solid $j-primary-border-green;
  242. font-weight: bold;
  243. }
  244. .tab-item.filter {
  245. flex: 1;
  246. padding: 0px 30rpx;
  247. .uni-icons {
  248. display: flex;
  249. padding-top: 5px;
  250. }
  251. }
  252. .screenIcon {
  253. display: flex;
  254. width: 80px;
  255. justify-content: center;
  256. .screenText {
  257. font-size: 32rpx;
  258. color: $uni-text-color-grey;
  259. }
  260. }
  261. }
  262. .listContent {
  263. height: 100% !important;
  264. .listBox {
  265. display: flex;
  266. // height: 180rpx;
  267. padding: 20rpx 0;
  268. border-bottom: 2rpx solid #e5e5e5;
  269. .listBox-sel {
  270. height: 90rpx;
  271. width: 80rpx;
  272. // line-height: 90rpx;
  273. text-align: center;
  274. checkbox {
  275. transform: scale(1.2);
  276. }
  277. }
  278. .listBox-con {
  279. width: 100%;
  280. // display: flex;
  281. // flex-wrap: wrap;
  282. // justify-content: space-between;
  283. align-items: center;
  284. padding: 0 18rpx 0 0;
  285. .listBox-top {
  286. width: 100%;
  287. display: flex;
  288. justify-content: space-between;
  289. padding-bottom: 10rpx;
  290. .listBox-name,
  291. .listBox-code {
  292. display: inline-block;
  293. font-size: $uni-font-size-sm;
  294. font-weight: bold;
  295. }
  296. }
  297. .listBox-bottom {
  298. width: 100%;
  299. display: flex;
  300. justify-content: space-between;
  301. font-size: $uni-font-size-sm;
  302. flex-wrap: wrap;
  303. >view {
  304. width: 50%;
  305. overflow: hidden;
  306. white-space: nowrap;
  307. text-overflow: ellipsis;
  308. }
  309. }
  310. }
  311. }
  312. .noDate {
  313. height: 100%;
  314. }
  315. }
  316. //底部按钮
  317. .footer {
  318. height: 90rpx;
  319. position: relative;
  320. display: flex;
  321. justify-content: space-between;
  322. align-items: center;
  323. bottom: 0;
  324. width: 100%;
  325. height: 100rpx;
  326. border-top: 1rpx solid #eeecec;
  327. background-color: #ffffff;
  328. z-index: 999;
  329. .bottom {
  330. margin-left: 10rpx;
  331. }
  332. .u-reset-button {
  333. position: absolute;
  334. right: 10rpx;
  335. top: 20rpx;
  336. width: 150rpx;
  337. }
  338. }
  339. }
  340. </style>