inspect.nvue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view>
  3. <view style="height: 5px;"></view>
  4. <view class="uni-navigate-item-my" @click="InspctOperate">
  5. <text class="uni-navigate-text-my">质检操作</text>
  6. <text class="uni-navigate-icon-my uni-icon">&#xe470;</text>
  7. </view>
  8. <view style="height: 5px;"></view>
  9. <view class="uni-navigate-item-my" @click="InspectRecordQuery">
  10. <text class="uni-navigate-text-my">质检记录查询</text>
  11. <text class="uni-navigate-icon-my uni-icon">&#xe470;</text>
  12. </view>
  13. <view style="height: 5px;"></view>
  14. <view class="uni-navigate-item-my" @click="PrintLabelFun">
  15. <text class="uni-navigate-text-my">交验单标签打印</text>
  16. <text class="uni-navigate-icon-my uni-icon">&#xe470;</text>
  17. </view>
  18. <view style="height: 5px;"></view>
  19. <view class="uni-navigate-item-my" @click="InspectOneClickOutStore">
  20. <text class="uni-navigate-text-my">质检结果-快速出库</text>
  21. <text class="uni-navigate-icon-my uni-icon">&#xe470;</text>
  22. </view>
  23. <!-- 以下代码用于测试选择相册图片和拍照图片。 建议不要删除。保留好。 -->
  24. <!-- <view class="demo">
  25. <block v-if="imageSrc">
  26. <image :src="imageSrc" class="image" mode="widthFix" @click="previewImage11(1)"></image>
  27. </block>
  28. <block v-else>
  29. <view class="uni-hello-addfile" @click="chooseImage">+ 选择图片</view>
  30. </block>
  31. </view>
  32. <view class="uni-flex uni-row">
  33. <button type="primary" style="-webkit-flex: 1;flex: 1;margin-left: 5px;" @click="deletePic">删除</button>
  34. </view>
  35. <view class="demo">
  36. <block v-if="imageSrc1">
  37. <image :src="imageSrc1" class="image" mode="widthFix" @click="previewImage11(2)"></image>
  38. </block>
  39. </view>
  40. <view class="uni-flex uni-row">
  41. <button type="primary" style="-webkit-flex: 1;flex: 1;margin-left: 5px;" @click="downloadPic">下载图片</button>
  42. </view> -->
  43. </view>
  44. </template>
  45. <script>
  46. // TODO 修复Android v3 加载过慢问题
  47. // #ifdef APP-PLUS
  48. var domModule = weex.requireModule('dom');
  49. domModule.addRule('fontFace', {
  50. 'fontFamily': "uniicons",
  51. 'src': "url('/static/uni.ttf')"
  52. });
  53. // #endif
  54. export default {
  55. data() {
  56. return {
  57. imageSrc: '',
  58. imageSrc1: '',
  59. previewImagePath: '',
  60. previewImagePath1: '',
  61. }
  62. },
  63. onUnload() {
  64. this.imageSrc = '';
  65. },
  66. methods: {
  67. InspctOperate() {
  68. uni.navigateTo({
  69. url:"/pages/Inspect/inspect01",
  70. })
  71. },
  72. InspectRecordQuery() {
  73. // 以下代码用于测试选择相册图片和拍照图片。 建议不要删除。保留好。
  74. // uni.chooseImage({
  75. // count: 6, //默认9
  76. // sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
  77. // sourceType: ['camera'], //从相册选择
  78. // success: function (res) {
  79. // console.log(JSON.stringify(res.tempFilePaths));
  80. // }
  81. // });
  82. uni.navigateTo({
  83. url:"/pages/Inspect/inspectRecordQuery",
  84. })
  85. },
  86. PrintLabelFun() {
  87. uni.navigateTo({
  88. url:"/pages/Inspect/PrintLabel",
  89. })
  90. },
  91. InspectOneClickOutStore() {
  92. uni.navigateTo({
  93. url:"/pages/Inspect/FastOutStoreInspect01",
  94. })
  95. },
  96. chooseImage: function() {
  97. let userMsg = uni.getStorageSync('userInfo')
  98. uni.chooseImage({
  99. count: 1,
  100. sizeType: ['compressed'],
  101. sourceType: ['camera'],
  102. success: (res) => {
  103. // console.log(res.tempFilePaths)
  104. // console.log('chooseImage success, temp path is', res.tempFilePaths[0])
  105. var imageSrc = res.tempFilePaths[0]
  106. this.previewImagePath = res.tempFilePaths
  107. this.imageSrc = imageSrc
  108. uni.uploadFile({
  109. url: getApp().globalData.baseUrl + '/Common/UploadFile',
  110. filePath: imageSrc,
  111. fileType: 'image',
  112. header: { //自定义请求头信息
  113. Authorization: 'Bearer ' + userMsg.tokenStr + ''
  114. },
  115. formData: {
  116. 'FileName': 'test',
  117. 'FileDir': '1111',
  118. 'FileNameType': '1',
  119. 'File' : res.tempFiles[0]
  120. },
  121. name: 'data',
  122. success: (res) => {
  123. // console.log('uploadImage success, res is:', res)
  124. uni.showToast({
  125. title: '上传成功',
  126. icon: 'success',
  127. duration: 1000
  128. })
  129. },
  130. fail: (err) => {
  131. // console.log('uploadImage fail', err);
  132. uni.showModal({
  133. content: err.errMsg,
  134. showCancel: false
  135. });
  136. }
  137. });
  138. },
  139. fail: (err) => {
  140. // console.log('chooseImage fail', err)
  141. // #ifdef MP
  142. uni.getSetting({
  143. success: (res) => {
  144. let authStatus = res.authSetting['scope.album'];
  145. if (!authStatus) {
  146. uni.showModal({
  147. title: '授权失败',
  148. content: 'Hello uni-app需要从您的相册获取图片,请在设置界面打开相关权限',
  149. success: (res) => {
  150. if (res.confirm) {
  151. uni.openSetting()
  152. }
  153. }
  154. })
  155. }
  156. }
  157. })
  158. // #endif
  159. }
  160. })
  161. },
  162. deletePic() {
  163. this.imageSrc = ''
  164. this.imageSrc1 = ''
  165. },
  166. downloadPic() {
  167. let userMsg = uni.getStorageSync('userInfo')
  168. let that = this
  169. uni.downloadFile({
  170. url: getApp().globalData.baseUrl + '/business/Testimage/GetQrCode', //GetTestimage?Id=4
  171. method: 'GET',
  172. header: { //自定义请求头信息
  173. Authorization: 'Bearer ' + userMsg.tokenStr + ''
  174. },
  175. success: res => {
  176. // console.log(res)
  177. // const arrayBuffer = new Uint8Array(res.data)
  178. // this.imageSrc1 = 'data:image/png;base64,' + uni.arrayBufferToBase64(arrayBuffer);
  179. // this.previewImagePath1 = this.imageSrc1
  180. this.imageSrc1 = res.tempFilePath
  181. uni.saveFile({
  182. tempFilePath: res.tempFilePath,
  183. success: function (res) {
  184. var savedFilePath = res.savedFilePath;
  185. that.previewImagePath1 = res.savedFilePath
  186. }
  187. });
  188. },
  189. fail: (err) => {
  190. // console.log(err)
  191. }
  192. });
  193. },
  194. previewImage11(res) {
  195. // ToDo: 暂未实现 从后端获取图片并预览大图 孙亚龙
  196. // 预览图片
  197. uni.previewImage({
  198. urls: res == 1 ? this.previewImagePath : this.previewImagePath1
  199. });
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss">
  205. @import '../../../common/uni-nvue.css';
  206. .image {
  207. width: 100%;
  208. }
  209. .demo {
  210. background: #FFF;
  211. padding: 50rpx;
  212. }
  213. </style>