DocumentFile.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="单据附件" @clickLeft="back">
  4. <!--右菜单-->
  5. <template slot="float">
  6. <view class="nav-icon-caozuo rightNav" @click="getsure"><u-button type="success" size="small" class="u-reset-button" text="确定"></u-button></view>
  7. </template>
  8. </uni-nav-bar>
  9. <view class="soBox"><u-search placeholder="请输入关键词查询" :searchIconSize="40" :show-action="false" @search="getKeyword" height="70" v-model="keywords"></u-search></view>
  10. <view class="listBox">
  11. <view class="itemBox" v-for="(item, index) in listData" :key="index" @click="cleanchecked(index)">
  12. <view class="chooseBox"> <uni-icons :type="choose===index?'checkbox-filled':'circle'" size="28" :color="choose===index?'#19be6b':'#eee'"></uni-icons></view>
  13. <view class="infoBox">
  14. <view class="tit u-line-1">{{item.title}}</view>
  15. <text class="tip">{{item.name}} {{item.department}}</text>
  16. </view>
  17. <view class="stateBox">
  18. <text class="tip">{{item.time}}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="footBox">
  23. <view class="reg" style="width:100%;" @click="upfiles"><uni-icons custom-prefix="iconfont" type="icon-shixiangxinzeng" size="20" color="#fff"></uni-icons> 添加附件</view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { post } from "@/utils/api.js";
  29. export default {
  30. name:"DocumentFile",
  31. data() {
  32. return {
  33. listData:[
  34. {
  35. title:'省财务局账单',
  36. name:'图片格式',
  37. department:'123456.jpg',
  38. time:'2021-11-06 18:00'
  39. },
  40. {
  41. title:'省财务局账单',
  42. name:'图片格式',
  43. department:'123456.jpg',
  44. time:'2021-11-06 18:00'
  45. },
  46. {
  47. title:'省财务局账单',
  48. name:'图片格式',
  49. department:'123456.jpg',
  50. time:'2021-11-06 18:00'
  51. },
  52. {
  53. title:'省财务局账单',
  54. name:'图片格式',
  55. department:'123456.jpg',
  56. time:'2021-11-06 18:00'
  57. },
  58. {
  59. title:'省财务局账单',
  60. name:'图片格式',
  61. department:'123456.jpg',
  62. time:'2021-11-06 18:00'
  63. },
  64. {
  65. title:'省财务局账单',
  66. name:'图片格式',
  67. department:'123456.jpg',
  68. time:'2021-11-06 18:00'
  69. },
  70. {
  71. title:'省财务局账单',
  72. name:'图片格式',
  73. department:'123456.jpg',
  74. time:'2021-11-06 18:00'
  75. },
  76. {
  77. title:'省财务局账单',
  78. name:'图片格式',
  79. department:'123456.jpg',
  80. time:'2021-11-06 18:00'
  81. },
  82. {
  83. title:'省财务局账单',
  84. name:'图片格式',
  85. department:'123456.jpg',
  86. time:'2021-11-06 18:00'
  87. },
  88. {
  89. title:'省财务局账单',
  90. name:'图片格式',
  91. department:'123456.jpg',
  92. time:'2021-11-06 18:00'
  93. },
  94. {
  95. title:'省财务局账单',
  96. name:'图片格式',
  97. department:'123456.jpg',
  98. time:'2021-11-06 18:00'
  99. },
  100. {
  101. title:'省财务局账单',
  102. name:'图片格式',
  103. department:'123456.jpg',
  104. time:'2021-11-06 18:00'
  105. }
  106. ], //列表数据
  107. screenHeight:'', //设备高度
  108. choose:'', //选择id
  109. chooseItem:{}, //传参信息
  110. fileList:{}, //添加附件
  111. keywords:'' //搜索关键词
  112. };
  113. },
  114. onLoad(){
  115. // 获取屏幕高度
  116. uni.getSystemInfo({
  117. success(res) {
  118. this.screenHeight = (res.screenHeight * (750 / res.windowWidth));
  119. }
  120. });
  121. },
  122. //加载更多
  123. onReachBottom(){
  124. console.log("加载更多");
  125. },
  126. methods: {
  127. //确定
  128. getsure() {
  129. console.log("点击确定");
  130. uni.$emit('updateFile', this.chooseItem);
  131. uni.navigateBack({
  132. delta: 1
  133. })
  134. },
  135. //选择信息
  136. cleanchecked(e){
  137. this.choose = e;
  138. this.chooseItem = this.listData[e];
  139. },
  140. //搜索
  141. getKeyword(){
  142. console.log("搜索关键词");
  143. },
  144. //添加附件
  145. upfiles(){
  146. //显示loading
  147. uni.showLoading({
  148. title: '上传中…'
  149. });
  150. uni.chooseImage({
  151. success: (chooseImageRes) => {
  152. const tempFilePaths = chooseImageRes.tempFilePaths;
  153. uni.uploadFile({
  154. url: '/',
  155. filePath: tempFilePaths[0],
  156. name: 'file',
  157. formData: {
  158. },
  159. success: (uploadFileRes) => {
  160. //隐藏loading
  161. uni.hideLoading();
  162. console.log(uploadFileRes.data);
  163. }
  164. });
  165. }
  166. });
  167. //监听上传进度
  168. uploadTask.onProgressUpdate((res) => {
  169. console.log('上传进度' + res.progress);
  170. });
  171. },
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .mainBox{
  177. padding-bottom: 120rpx;
  178. }
  179. .soBox{
  180. padding:30rpx 20rpx 0 20rpx;
  181. }
  182. .itemBox{
  183. padding:30rpx 20rpx;
  184. display: flex;
  185. font-size: $uni-font-size-base;
  186. border-bottom: 1px #f2f2f2 solid;
  187. .chooseBox{
  188. margin-right: 20rpx;
  189. }
  190. .infoBox{
  191. .tit{max-width:100%;overflow: hidden;}
  192. .tip{
  193. color: #999;
  194. font-size: $uni-font-size-sm;
  195. }
  196. }
  197. .stateBox{
  198. margin-left: auto;
  199. text-align: right;
  200. .tit{
  201. }
  202. .tip{
  203. color: #999;
  204. font-size: $uni-font-size-sm;
  205. }
  206. }
  207. }
  208. .footBox{
  209. position: fixed;
  210. left:0px;
  211. bottom: 0px;
  212. height: 100rpx;
  213. width: 100%;
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. view{
  218. width:50%;
  219. height: 100%;
  220. text-align: center;
  221. color: #fff;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. }
  226. .reg{
  227. background: $u-success-dark;
  228. }
  229. .uni-icons{margin-right: 8rpx !important;}
  230. }
  231. </style>