handDesc.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. // pages/tabber/builds/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. number: "",
  9. data: "",
  10. show: false,
  11. results: 0,
  12. radio: 1,
  13. isshow: false,
  14. inpuval: "",
  15. placeholder: "",
  16. hand_up_count: 0,
  17. need_hand_up_count: 0,
  18. order_no:"",
  19. popuptype: 0,
  20. },
  21. onLoad(option) {
  22. this.setData({
  23. pylon_no:option.pylon_no
  24. })
  25. },
  26. onShow(){
  27. this.getdata();
  28. },
  29. getScancode: function () {
  30. var _this = this;
  31. // 允许从相机和相册扫码
  32. wx.scanCode({
  33. onlyFromCamera: true,
  34. scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
  35. success: (res) => {
  36. console.log(res);
  37. var result = res.result;
  38. _this.setData({
  39. inpuval: result,
  40. })
  41. },
  42. fail: (err) => {
  43. console.log(err);
  44. }
  45. })
  46. },
  47. getdata() {
  48. var that = this;
  49. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/hand/hand_desc", {
  50. pylon_no: this.data.pylon_no
  51. }, "get").then(function (res) {
  52. console.log(res);
  53. if (res.code != 200) {
  54. wx.showLoading({
  55. title: res.message.msg,
  56. })
  57. setTimeout(function () {
  58. wx.hideLoading();
  59. }, 1000);
  60. } else {
  61. wx.hideLoading();
  62. let data = res.message.data
  63. data.new_length = that.length(data.new_hand_ups);
  64. that.setData({
  65. data,
  66. hand_up_count: res.message.hand_up_count,
  67. need_hand_up_count: res.message.need_hand_up_count,
  68. order_no:res.message.order_no
  69. })
  70. }
  71. }).catch(function (err) {
  72. console.log(222);
  73. })
  74. },
  75. onClick(e) {
  76. var butt = e.currentTarget.dataset.butt;
  77. if (butt == '扫描') {
  78. this.scan();
  79. } else {
  80. this.sub();
  81. }
  82. },
  83. length(obj) {
  84. var count = 0;
  85. for (var i in obj) {
  86. count++;
  87. }
  88. return count;
  89. },
  90. show(e) {
  91. var tid = e.currentTarget.dataset.id
  92. var type = e.currentTarget.dataset.type
  93. this.setData({popuptype: type})
  94. console.log(tid)
  95. if (tid==1) {
  96. this.setData({
  97. show: !this.data.show,
  98. placeholder: '扫描或人工输入水洗码扫描',
  99. butt: '扫描'
  100. })
  101. } else {
  102. this.setData({
  103. isshow: !this.data.isshow,
  104. show: !this.data.show,
  105. placeholder: '扫描或输入封签号打包',
  106. butt: '绑定'
  107. })
  108. }
  109. if(this.data.show){
  110. this.setData({inpuval:''})
  111. }
  112. },
  113. isshow() {
  114. this.setData({
  115. isshow: !this.data.isshow,
  116. })
  117. },
  118. bindinput(e) {
  119. this.setData({
  120. inpuval: e.detail.value,
  121. })
  122. },
  123. onClose() {
  124. this.setData({
  125. show: !this.data.show,
  126. popuptype: 0
  127. })
  128. },
  129. Close() {
  130. this.setData({
  131. isshow: !this.data.isshow,
  132. })
  133. },
  134. onClose_del() {
  135. this.setData({
  136. show: !this.data.show,
  137. inpuval: "",
  138. })
  139. },
  140. sub() {
  141. this.onClose()
  142. var that = this;
  143. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/pack/pack", {
  144. keyword: this.data.inpuval,
  145. type: this.data.results,
  146. order_no:this.data.order_no
  147. }, "post").then(function (res) {
  148. console.log(res);
  149. if (res.code != 200) {
  150. wx.showLoading({
  151. title: res.message.msg,
  152. })
  153. setTimeout(function () {
  154. wx.hideLoading();
  155. }, 1000);
  156. } else {
  157. wx.hideLoading();
  158. let data = res.message.data
  159. wx.showLoading({
  160. title: res.message.msg,
  161. })
  162. setTimeout(()=>{
  163. wx.hideLoading();
  164. wx.navigateTo({
  165. url: '/pages/record/recorddetailsinfo/recorddetailsinfo?si=1&id='+data.id.id,
  166. })
  167. },1000)
  168. }
  169. }).catch(function (err) {
  170. console.log(222);
  171. })
  172. },
  173. onChange(event) {
  174. console.log(event.detail)
  175. this.setData({
  176. results: event.detail,
  177. });
  178. },
  179. scan() {
  180. var that = this;
  181. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/pack/HandCode", {
  182. wash_code: this.data.inpuval
  183. }, "post").then(function (res) {
  184. console.log(res);
  185. if (res.code != 200) {
  186. wx.showLoading({
  187. title: res.message.msg,
  188. })
  189. setTimeout(function () {
  190. wx.hideLoading();
  191. }, 1000);
  192. } else {
  193. wx.hideLoading();
  194. let data = res.message.data
  195. wx.showLoading({
  196. title: res.message.msg,
  197. })
  198. setTimeout(function () {
  199. wx.hideLoading();
  200. that.onClose()
  201. that.getdata()
  202. }, 1000);
  203. }
  204. }).catch(function (err) {
  205. console.log(222);
  206. })
  207. },
  208. })