selectDoc.vue 8.1 KB

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