inspect.nvue 6.6 KB

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