file.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <view style="padding:5rpx 20rpx 45rpx 20rpx;">
  4. <view class="desc">
  5. <uni-row>
  6. <uni-col :span="5">
  7. <view class="desc" style="font-size: 25rpx;">
  8. 文件名称
  9. </view>
  10. </uni-col>
  11. <uni-col :span="19">
  12. <view>
  13. <uni-easyinput primaryColor="#37babd" v-model="form.totalTime">
  14. </uni-easyinput>
  15. </view>
  16. </uni-col>
  17. </uni-row>
  18. </view>
  19. <view class="desc">
  20. <uni-row>
  21. <uni-col :span="5">
  22. <view class="desc" style="font-size: 25rpx;">
  23. 文件类型
  24. </view>
  25. </uni-col>
  26. <uni-col :span="19">
  27. <view>
  28. <uni-easyinput primaryColor="#37babd" v-model="form.totalTime">
  29. </uni-easyinput>
  30. </view>
  31. </uni-col>
  32. </uni-row>
  33. </view>
  34. <view class="desc">
  35. <view class="desc" style="font-size: 25rpx;">
  36. 文件审批事由:
  37. </view>
  38. <view>
  39. <uni-easyinput type="textarea" primaryColor="#37babd" v-model="form.totalTime">
  40. </uni-easyinput>
  41. </view>
  42. </view>
  43. <view class="desc">
  44. <view>
  45. 请上传文件照片
  46. </view>
  47. <view style="width: 100%;overflow-x: scroll;white-space: nowrap">
  48. <u-upload style="margin: 0;" :fileList="fileList" @afterRead="afterRead" @delete="deletePic"
  49. name="1" multiple :maxCount="6" width="120" height="120" uploadIcon="plus-circle">
  50. </u-upload>
  51. </view>
  52. </view>
  53. </view>
  54. <u-gap height="70" bgColor="#ffffff"></u-gap>
  55. <view class="bottim_view">
  56. <view>
  57. <u-row>
  58. <u-col span="11">
  59. <u-button :disabled="isDisabled" class="btnDoPay" shape="circle" @click="submit"
  60. color="rgb(55,186,189)" text="提交"></u-button>
  61. </u-col>
  62. </u-row>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. isDisabled: false,
  72. index: 0,
  73. fileList: [],
  74. wpTypes: ['办公用品', '固定资产', '低值易耗品', '广告印刷品', '其他']
  75. }
  76. },
  77. methods: {
  78. submit() {
  79. },
  80. onchange(e) {
  81. setTimeout(() => {
  82. }, 200)
  83. },
  84. maskClick(e) {},
  85. bindPickerChange: function(e) {
  86. this.index = e.detail.value
  87. },
  88. // 删除图片
  89. deletePic(event) {
  90. this.fileList.splice(event.index, 1)
  91. },
  92. // 新增图片
  93. async afterRead(event) {
  94. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  95. let lists = [].concat(event.file)
  96. let fileListLen
  97. if (this.fileList) {
  98. fileListLen = this.fileList.length
  99. } else {
  100. this.fileList = []
  101. fileListLen = 0
  102. }
  103. lists.map((item) => {
  104. this.fileList.push({
  105. ...item,
  106. status: 'uploading',
  107. message: '上传中'
  108. })
  109. })
  110. for (let i = 0; i < lists.length; i++) {
  111. const result = await this.uploadFilePromise(lists[i].url)
  112. let item = this.fileList[fileListLen]
  113. this.fileList.splice(fileListLen, 1, Object.assign(item, {
  114. status: 'success',
  115. message: '',
  116. url: result
  117. }))
  118. fileListLen++
  119. }
  120. // uni.setStorageSync("listImg", this.fileList)
  121. // console.log(this.fileList)
  122. },
  123. uploadFilePromise(url) {
  124. return new Promise((resolve, reject) => {
  125. let a = uni.uploadFile({
  126. url: this.$BASE_URL + '/common/upload', // 仅为示例,非真实的接口地址
  127. filePath: url,
  128. name: 'file',
  129. header: this.header,
  130. success: (res) => {
  131. // console.log(JSON.parse(res.data).url);
  132. setTimeout(() => {
  133. resolve(JSON.parse(res.data).url)
  134. }, 1000)
  135. }
  136. });
  137. })
  138. },
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .desc {
  144. padding: 15rpx 5rpx;
  145. }
  146. .bottim_view {
  147. padding: 5px 20px 30px;
  148. position: fixed;
  149. left: 0px;
  150. bottom: 0px;
  151. width: 100%;
  152. height: 40px;
  153. background-color: #ffffff;
  154. }
  155. </style>