handDesc.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. pylon_no:res.message.pylon_no,
  67. hand_up_count: res.message.hand_up_count,
  68. need_hand_up_count: res.message.need_hand_up_count,
  69. order_no:res.message.order_no
  70. })
  71. }
  72. }).catch(function (err) {
  73. console.log(222);
  74. })
  75. },
  76. onClick(e) {
  77. var butt = e.currentTarget.dataset.butt;
  78. if (butt == '扫描') {
  79. this.scan();
  80. } else {
  81. this.sub();
  82. }
  83. },
  84. length(obj) {
  85. var count = 0;
  86. for (var i in obj) {
  87. count++;
  88. }
  89. return count;
  90. },
  91. show(e) {
  92. let that = this
  93. var tid = e.currentTarget.dataset.id
  94. var type = e.currentTarget.dataset.type
  95. this.setData({popuptype: type})
  96. console.log(tid)
  97. if (tid==1) {
  98. this.setData({
  99. show: !this.data.show,
  100. placeholder: '扫描或人工输入水洗码扫描',
  101. butt: '扫描'
  102. })
  103. } else {
  104. if(that.data.results==1){
  105. that.setData({
  106. isshow: !this.data.isshow,
  107. show: !this.data.show,
  108. placeholder: '扫描或输入封签号打包',
  109. butt: '绑定'
  110. })
  111. }else{
  112. wx.showToast({
  113. title: '请先勾选使用封签打包',
  114. icon: 'none',
  115. duration: 1000
  116. })
  117. }
  118. }
  119. if(this.data.show){
  120. this.setData({inpuval:''})
  121. }
  122. },
  123. isshow() {
  124. this.setData({
  125. isshow: !this.data.isshow,
  126. })
  127. },
  128. bindinput(e) {
  129. this.setData({
  130. inpuval: e.detail.value,
  131. })
  132. },
  133. onClose() {
  134. this.setData({
  135. show: !this.data.show,
  136. popuptype: 0
  137. })
  138. },
  139. Close() {
  140. this.setData({
  141. isshow: !this.data.isshow,
  142. })
  143. },
  144. onClose_del() {
  145. this.setData({
  146. show: !this.data.show,
  147. inpuval: "",
  148. })
  149. },
  150. sub() {
  151. this.onClose()
  152. var that = this;
  153. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/pack/pack", {
  154. keyword: this.data.inpuval,
  155. type: this.data.results,
  156. order_no:this.data.order_no
  157. }, "post").then(function (res) {
  158. console.log(res);
  159. if (res.code != 200) {
  160. wx.showLoading({
  161. title: res.message.msg,
  162. })
  163. setTimeout(function () {
  164. wx.hideLoading();
  165. }, 1000);
  166. } else {
  167. wx.hideLoading();
  168. let data = res.message.data
  169. wx.showLoading({
  170. title: res.message.msg,
  171. })
  172. setTimeout(()=>{
  173. wx.hideLoading();
  174. wx.navigateTo({
  175. url: '/pages/record/recorddetailsinfo/recorddetailsinfo?si=1&id='+data.id.id,
  176. })
  177. },1000)
  178. }
  179. }).catch(function (err) {
  180. console.log(222);
  181. })
  182. },
  183. onChange(event) {
  184. console.log(event.detail)
  185. this.setData({
  186. results: event.detail,
  187. });
  188. },
  189. scan() {
  190. var that = this;
  191. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/pack/HandCode", {
  192. wash_code: this.data.inpuval
  193. }, "post").then(function (res) {
  194. console.log(res);
  195. if (res.code != 200) {
  196. wx.showLoading({
  197. title: res.message.msg,
  198. })
  199. setTimeout(function () {
  200. wx.hideLoading();
  201. }, 1000);
  202. } else {
  203. wx.hideLoading();
  204. let data = res.message.data
  205. wx.showLoading({
  206. title: res.message.msg,
  207. })
  208. setTimeout(function () {
  209. wx.hideLoading();
  210. that.onClose()
  211. that.getdata()
  212. }, 1000);
  213. }
  214. }).catch(function (err) {
  215. console.log(222);
  216. })
  217. },
  218. })