report.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="top">
  5. <text class="title">证明上传</text>
  6. </view>
  7. <view class="item">
  8. <view class="l">核酸证明:</view>
  9. <view class="r">
  10. <view class="img">
  11. <uni-file-picker v-model="nucleicReport" fileMediatype="image" mode="grid" limit="1"
  12. @select="nucleicSelect" @delete="form.nucleicReport=''" :image-styles="imageStyles" />
  13. </view>
  14. </view>
  15. </view>
  16. <view class="item">
  17. <view class="l">消杀合格证明:</view>
  18. <view class="r">
  19. <view class="img">
  20. <uni-file-picker v-model="disinfectReport" fileMediatype="image" mode="grid" limit="1"
  21. @select="disinfectSelect" @delete="form.disinfectReport=''" :image-styles="imageStyles" />
  22. </view>
  23. </view>
  24. </view>
  25. <view class="item">
  26. <view class="l">检验检疫证:</view>
  27. <view class="r">
  28. <view class="img">
  29. <uni-file-picker ref="checkReport" v-model="checkReport" fileMediatype="image" mode="grid"
  30. limit="1" @select="checkSelect" @delete="form.checkReport=''" :image-styles="imageStyles" />
  31. </view>
  32. </view>
  33. </view>
  34. <view class="item">
  35. <view class="l">签发出库证明:</view>
  36. <view class="r">
  37. <view class="img">
  38. <uni-file-picker v-model="outReport" fileMediatype="image" mode="grid" limit="1"
  39. @select="outSelect" @delete="form.outReport=''" :image-styles="imageStyles" />
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <u-button type="primary" @click="confirmFn">保存</u-button>
  45. </view>
  46. </template>
  47. <script>
  48. import request from '../../utils/request.js'
  49. export default {
  50. data() {
  51. return {
  52. id: '',
  53. form: {
  54. partMoney: 0
  55. },
  56. imgList: [],
  57. outReport: [],
  58. checkReport:[],
  59. disinfectReport:[],
  60. nucleicReport:[],
  61. imageStyles: {
  62. width: 150,
  63. height: 100,
  64. border: {
  65. color: "#eee",
  66. width: 1,
  67. style: 'dashed',
  68. radius: '5px'
  69. }
  70. },
  71. uploadImageUrl: request.server + '/upload/image',
  72. }
  73. },
  74. onLoad(options) {
  75. this.id = options.id;
  76. },
  77. onShow() {
  78. this.getBusinessById();
  79. },
  80. methods: {
  81. outSelect(e) {
  82. let that = this;
  83. uni.uploadFile({
  84. url: that.uploadImageUrl,
  85. filePath: e.tempFilePaths[0],
  86. name: 'file',
  87. success: (resp => {
  88. that.form.outReport= JSON.parse(resp.data).data;
  89. })
  90. })
  91. },
  92. checkSelect(e) {
  93. let that = this;
  94. uni.uploadFile({
  95. url: that.uploadImageUrl,
  96. filePath: e.tempFilePaths[0],
  97. name: 'file',
  98. success: (resp => {
  99. that.form.checkReport= JSON.parse(resp.data).data;
  100. })
  101. })
  102. },
  103. disinfectSelect(e) {
  104. let that = this;
  105. uni.uploadFile({
  106. url: that.uploadImageUrl,
  107. filePath: e.tempFilePaths[0],
  108. name: 'file',
  109. success: (resp => {
  110. that.form.disinfectReport= JSON.parse(resp.data).data;
  111. })
  112. })
  113. },
  114. nucleicSelect(e) {
  115. let that = this;
  116. uni.uploadFile({
  117. url: that.uploadImageUrl,
  118. filePath: e.tempFilePaths[0],
  119. name: 'file',
  120. success: (resp => {
  121. that.form.nucleicReport= JSON.parse(resp.data).data;
  122. })
  123. })
  124. },
  125. handlerUpload(e, target) {
  126. let that = this;
  127. uni.uploadFile({
  128. url: that.uploadImageUrl,
  129. filePath: e.tempFilePaths[0],
  130. name: 'file',
  131. success: (resp => {
  132. that.form[target] = JSON.parse(resp.data).data;
  133. })
  134. })
  135. },
  136. getBusinessById() {
  137. this.$api.getBusinessById({
  138. id: this.id
  139. }).then(resp => {
  140. this.form = resp.data;
  141. if(this.form.nucleicReport){
  142. this.nucleicReport=[{
  143. 'name':'payTicket.png',
  144. 'extname':'.png',
  145. 'url':this.form.nucleicReport
  146. }]
  147. }
  148. if(this.form.disinfectReport){
  149. this.disinfectReport=[{
  150. 'name':'payTicket.png',
  151. 'extname':'.png',
  152. 'url':this.form.disinfectReport
  153. }]
  154. }
  155. if(this.form.checkReport){
  156. this.checkReport=[{
  157. 'name':'payTicket.png',
  158. 'extname':'.png',
  159. 'url':this.form.checkReport
  160. }]
  161. }
  162. if(this.form.outReport){
  163. this.outReport=[{
  164. 'name':'payTicket.png',
  165. 'extname':'.png',
  166. 'url':this.form.outReport
  167. }]
  168. }
  169. })
  170. },
  171. confirmFn() {
  172. console.log(this.form)
  173. if (!this.form.nucleicReport) {
  174. this.$common.toast('请上传核酸报告');
  175. return;
  176. }
  177. if (!this.form.disinfectReport) {
  178. this.$common.toast('请上传消杀合格证明');
  179. return;
  180. }
  181. if (!this.form.checkReport) {
  182. this.$common.toast('请上传入关检验检疫证');
  183. return;
  184. }
  185. if (!this.form.outReport) {
  186. this.$common.toast('请上传签发出库证明');
  187. return;
  188. }
  189. this.$api.uploadReport(this.form).then(Resp => {
  190. this.$common.toast('上传成功');
  191. setTimeout(() => {
  192. this.$common.back()
  193. }, 500)
  194. })
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. page {
  201. background-color: #fff;
  202. }
  203. .item-line {
  204. color: #a2a2a2;
  205. padding: 5px 0 10px 29px;
  206. border-bottom: 1px solid #E5E5E5;
  207. }
  208. @import '@/common/common.scss'
  209. </style>