FileInfo.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="file-info bg-white">
  3. <view class="file-info-container">
  4. <cy-upload v-model:filename="form.imgInfo" :limit="3" />
  5. <u-textarea v-model="form.remark" placeholder="上传说明..." autoHeight style="min-height: 60px;"></u-textarea>
  6. <view class="flex flex-a-c flex-j-c">
  7. <u-button class="mt-24" type="primary" @click="handleUpload">上传(最多上传3张)</u-button>
  8. </view>
  9. </view>
  10. <view class="file-info-list">
  11. <view class="file-info-list-title text-center">已上传记录</view>
  12. <view class="file-info-list-content mt-24 mb-24 text-center" v-if="!fileList?.length">还没有上传记录</view>
  13. <view class="file-info-item" v-for="item in fileList" :key="item.id" v-else>
  14. <view class="file-info-item-img flex flex-a-c">
  15. <u-image v-for="(img,index) in item.imgInfo" :src="img" width="90" height="90" style="margin-right: 10px;" :key="img" @click="handlePreview(item.imgInfo,index)"></u-image>
  16. </view>
  17. <view class="file-info-item-info mt-10 font-14">
  18. <view class="file-info-item-info-name">上传说明:{{ item.remark }}</view>
  19. <view class="file-info-item-info-name mt-10">
  20. <text>{{ item.createTime }} </text>
  21. <text class="ml-20">{{ item.createName }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import { ref } from 'vue';
  30. import cyUpload from '@/components/cy-upload/index.vue';
  31. const form = ref({
  32. imgInfo: [],
  33. remark: ''
  34. })
  35. const props = defineProps({
  36. orderId: {
  37. type: String,
  38. default: ''
  39. },
  40. annexType: {
  41. type: Number,
  42. default: 1
  43. },
  44. isbn: {
  45. type: String,
  46. default: ''
  47. }
  48. })
  49. //获取附件信息
  50. const fileList = ref([])
  51. function getFileList() {
  52. uni.$u.http.get('/app/orderinfo/getOrderAnnexList', {
  53. params: {
  54. orderId: props.orderId,
  55. annexType: props.annexType,
  56. isbn: props.isbn
  57. }
  58. }).then(res => {
  59. if (res.code == 200) {
  60. fileList.value = res.data
  61. }
  62. })
  63. }
  64. getFileList()
  65. //预览图片
  66. const handlePreview = (imgList,index) => {
  67. uni.previewImage({
  68. urls: imgList,
  69. current: index
  70. })
  71. }
  72. const handleUpload = () => {
  73. console.log(form.value)
  74. let data = {
  75. orderId: props.orderId,
  76. annexType: props.annexType,
  77. isbn: props.isbn,
  78. ...form.value
  79. }
  80. uni.$u.http.post('/app/orderinfo/setOrderAnnex', data).then(res => {
  81. if (res.code == 200) {
  82. uni.$u.toast('上传成功')
  83. form.value.imgInfo = []
  84. form.value.remark = ''
  85. getFileList()
  86. } else {
  87. uni.$u.toast(res.msg)
  88. }
  89. })
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .file-info-container {
  94. padding: 20rpx 30rpx;
  95. box-sizing: border-box;
  96. }
  97. .file-info-item {
  98. padding: 20rpx;
  99. border-bottom: 1px solid #e5e5e5;
  100. }
  101. .file-info-list-title {
  102. background-color: #e5e5e5;
  103. padding: 10rpx 0;
  104. margin-top: 20px;
  105. }
  106. .file-info-list-content {
  107. color: #999;
  108. min-height: 100px;
  109. }
  110. </style>