diao.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. // StepPage/pages/diao/diao.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. searchValue:'',
  8. show:false,
  9. searchList:[],
  10. searchValue_in:'',
  11. show_in:false,
  12. searchListIn:[],
  13. searchValue_out:'',
  14. show_out:false,
  15. searchListOut:[],
  16. company_id:"",
  17. company_name:'',
  18. out_title:'',
  19. in_title:'',
  20. storehouseList:[],
  21. from_storehouse_id:'',
  22. to_storehouse_id:'',
  23. mark:'',
  24. set_status:''
  25. },
  26. handleClick(){
  27. this.setData({
  28. show:true,
  29. searchList:this.data.companyList
  30. })
  31. },
  32. handleChoose(item){
  33. this.setData({
  34. show:false,
  35. company_id:item.target.dataset.item.id,
  36. company_name:item.target.dataset.item.title,
  37. in_title:'',
  38. out_title:'',
  39. to_storehouse_id:'',
  40. from_storehouse_id:''
  41. })
  42. },
  43. onSearch(event){
  44. let arr = this.data.companyList.filter(v=>v.title.indexOf(event.detail)!=-1);
  45. this.setData({
  46. searchList:arr
  47. })
  48. },
  49. handleCancel(){
  50. this.setData({
  51. show:false
  52. })
  53. },
  54. handleClickIn(){
  55. let app = getApp();
  56. let openid = app.globalData.openID;
  57. let id = this.data.company_id;
  58. wx.p.request({
  59. url: `${app.globalData.url}wx/companyAndStoreHouse`,
  60. method:'POST',
  61. data:{
  62. openid,
  63. id
  64. }
  65. }).then(res=>{
  66. this.setData({
  67. show_in:true,
  68. storehouseList:res.data.data,
  69. searchListIn:res.data.data
  70. })
  71. })
  72. },
  73. handleChooseIn(item){
  74. this.setData({
  75. show_in:false,
  76. to_storehouse_id:item.target.dataset.item.id,
  77. in_title:item.target.dataset.item.title
  78. })
  79. },
  80. onSearchIn(event){
  81. let arr = this.data.storehouseList.filter(v=>v.title.indexOf(event.detail)!=-1);
  82. console.log(arr)
  83. this.setData({
  84. searchListIn:arr
  85. })
  86. },
  87. handleCancelIn(){
  88. this.setData({
  89. show_in:false
  90. })
  91. },
  92. handleClickOut(){
  93. let app = getApp();
  94. let openid = app.globalData.openID;
  95. let id = this.data.company_id;
  96. wx.p.request({
  97. url: `${app.globalData.url}wx/companyAndStoreHouse`,
  98. method:'POST',
  99. data:{
  100. openid,
  101. id
  102. }
  103. }).then(res=>{
  104. this.setData({
  105. show_out:true,
  106. storehouseList:res.data.data,
  107. searchListOut:res.data.data
  108. })
  109. })
  110. },
  111. handleChooseOut(item){
  112. this.setData({
  113. show_out:false,
  114. from_storehouse_id:item.target.dataset.item.id,
  115. out_title:item.target.dataset.item.title
  116. })
  117. },
  118. onSearchOut(event){
  119. let arr = this.data.storehouseList.filter(v=>v.title.indexOf(event.detail)!=-1);
  120. this.setData({
  121. searchListOut:arr
  122. })
  123. },
  124. handleCancelOut(){
  125. this.setData({
  126. show_out:false
  127. })
  128. },
  129. handleChangeremark(e){
  130. this.setData({
  131. mark:e.detail.value
  132. })
  133. },
  134. handleReturn(){
  135. wx.navigateBack({
  136. delta:1
  137. })
  138. },
  139. handleNext(){
  140. if(this.data.company_id&&this.data.to_storehouse_id&&this.data.from_storehouse_id){
  141. let app = getApp();
  142. app.globalData.company_id = this.data.company_id;
  143. app.globalData.to_storehouse_id = this.data.to_storehouse_id;
  144. app.globalData.from_storehouse_id = this.data.from_storehouse_id;
  145. app.globalData.storehouse_id = this.data.from_storehouse_id;
  146. app.globalData.mark = this.data.mark;
  147. wx.navigateTo({
  148. url: '../diaoNext/diaoNext',
  149. })
  150. }else{
  151. return wx.showToast({
  152. icon:'none',
  153. title: '请填写必填信息',
  154. })
  155. }
  156. },
  157. /**
  158. * 生命周期函数--监听页面加载
  159. */
  160. onLoad(options) {
  161. let app = getApp();
  162. let openid = app.globalData.openID;
  163. // 获取集团
  164. wx.p.request({
  165. url: `${app.globalData.url}wx/companyList`,
  166. method:'POST',
  167. data:{
  168. openid
  169. }
  170. }).then(res=>{
  171. this.setData({
  172. companyList:res.data.data.data
  173. })
  174. })
  175. if(app.globalData.set_status){
  176. this.setData({
  177. set_status:app.globalData.set_status,
  178. company_name:app.globalData.detailData.company_name,
  179. company_id:app.globalData.detailData.company_id,
  180. in_title:app.globalData.detailData.to_storehouse_name,
  181. out_title:app.globalData.detailData.from_storehouse_name,
  182. mark:app.globalData.detailData.mark,
  183. to_storehouse_id:app.globalData.detailData.to_storehouse_id,
  184. from_storehouse_id:app.globalData.detailData.from_storehouse_id,
  185. })
  186. }else{
  187. this.setData({
  188. set_status:''
  189. })
  190. }
  191. },
  192. /**
  193. * 生命周期函数--监听页面初次渲染完成
  194. */
  195. onReady() {
  196. },
  197. /**
  198. * 生命周期函数--监听页面显示
  199. */
  200. onShow() {
  201. },
  202. /**
  203. * 生命周期函数--监听页面隐藏
  204. */
  205. onHide() {
  206. },
  207. /**
  208. * 生命周期函数--监听页面卸载
  209. */
  210. onUnload() {
  211. },
  212. /**
  213. * 页面相关事件处理函数--监听用户下拉动作
  214. */
  215. onPullDownRefresh() {
  216. },
  217. /**
  218. * 页面上拉触底事件的处理函数
  219. */
  220. onReachBottom() {
  221. },
  222. /**
  223. * 用户点击右上角分享
  224. */
  225. onShareAppMessage() {
  226. }
  227. })