selectOrderNo.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view>
  3. <view class="body">
  4. 订单编号:<input class="input" v-model="orderNo" />
  5. <button type="primary" @click="select(orderNo)" class="" size="mini">
  6. 搜索
  7. </button>
  8. <button type="primary" @click="expert(orderNo)" class="" size="mini">
  9. 导出
  10. </button>
  11. </view>
  12. <view class="">
  13. <uni-collapse :accordion="true">
  14. <uni-list>
  15. <view v-for="machine in machineList" :key="machine.id">
  16. <uni-list-item :title="machine.coding" @click="trun(machine.coding)"/>
  17. </view>
  18. </uni-list>
  19. </uni-collapse>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. mapState,
  26. mapActions,
  27. mapMutations
  28. } from 'vuex'
  29. import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
  30. import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
  31. import uniList from '@/components/uni-list/uni-list.vue'
  32. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  33. export default {
  34. components: {
  35. uniCollapse,
  36. uniCollapseItem,
  37. uniList,
  38. uniListItem,
  39. },
  40. data() {
  41. return {
  42. orderNo:'',
  43. machineList:''
  44. }
  45. },
  46. methods: {
  47. select(orderNo) {
  48. var that = this;
  49. var serverUrl = that.serverurl;
  50. var token = uni.getStorageSync("token");
  51. uni.request({
  52. url: serverUrl + "/TMachine/selectMachineByOrderNo?orderNo=" + orderNo,
  53. method: "GET",
  54. header: {
  55. 'token': token
  56. },
  57. success: (Result) => {
  58. var res = Result;
  59. if (res.data.code == true) {
  60. that.machineList = res.data.data;
  61. } else {
  62. uni.showModal({
  63. title: '提示',
  64. content: res.data.message,
  65. });
  66. }
  67. }
  68. });
  69. },
  70. trun(coding) {
  71. var item = {
  72. coding:'',
  73. type:''
  74. };
  75. item.coding = coding;
  76. uni.navigateTo({
  77. url:'selectMachine?item='+encodeURIComponent(JSON.stringify(item))
  78. });
  79. },
  80. expert(orderNo) {
  81. var that = this;
  82. var serverUrl = that.serverurl;
  83. var token = uni.getStorageSync("token");
  84. uni.request({
  85. url: serverUrl + "/TMachine/expert?orderNo=" + orderNo,
  86. method: "GET",
  87. header: {
  88. 'token': token
  89. },
  90. success: (Result) => {
  91. var res = Result;
  92. if (res.data.code == true) {
  93. var url = res.data.data;
  94. var a= [];
  95. a=url.split("machine/");
  96. // a=url.split("excel/");
  97. var fileName = a[1];
  98. wx.downloadFile({
  99. url: url,
  100. /* 这里指定filePath属性,不然会是一个临时文件,不能用对应的程序打开 */
  101. filePath:wx.env.USER_DATA_PATH + '/' + fileName,
  102. success(result) {
  103. const filePath = result.filePath;
  104. wx.openDocument({
  105. filePath: filePath,
  106. showMenu: true,
  107. fileType: "xls",
  108. success: rlt => {
  109. console.log("打开文档成功",rlt);
  110. },
  111. fail: err => {
  112. wx.showModal({
  113. content: JSON.stringify(err),
  114. showCancel: false
  115. })
  116. }
  117. });
  118. },
  119. fail(error){
  120. wx.showModal({
  121. content: JSON.stringify(error),
  122. showCancel: false
  123. })
  124. }
  125. })
  126. } else {
  127. uni.showModal({
  128. title: '提示',
  129. content: res.data.message,
  130. });
  131. }
  132. }
  133. });
  134. }
  135. }
  136. }
  137. </script>
  138. <style>
  139. .body {
  140. background-color: #FFFFFF;
  141. padding: 20upx;
  142. display: flex;
  143. flex-direction: row;
  144. justify-content: flex-start;
  145. }
  146. .input {
  147. padding-left: 10upx;
  148. background-color: #FFFFFF;
  149. width: 280upx;
  150. height: 55upx;
  151. box-shadow: 0upx 0upx 20upx #D3D3D3;
  152. border-radius: 5upx;
  153. }
  154. </style>