index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // pages/market_buy/index.js
  2. const { buy_status } = require('../../utils/dict');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '采买需求信息', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. // 采买列表
  13. list: [],
  14. // 弹框
  15. dialog: { title: '详细信息', show: false, type: '1' },
  16. // 详细信息
  17. info: {},
  18. // 导出条件
  19. exportForm: {},
  20. // 商品状态
  21. statusList: buy_status
  22. },
  23. back: function () {
  24. wx.navigateBack({ url: '/pages/home/index' })
  25. },
  26. // 导出条件
  27. export_term: function () {
  28. this.setData({ dialog: { title: '导出条件', show: true, type: '2' }, })
  29. },
  30. // 选择状态
  31. statusChange: function (e) {
  32. let { value } = e.detail;
  33. if (value) {
  34. let data = this.data.statusList[value];
  35. this.setData({ 'exportForm.status': data.value })
  36. }
  37. },
  38. // 开始时间
  39. startChange: function (e) {
  40. let { value } = e.detail;
  41. this.setData({ 'exportForm.apply_date@start': value })
  42. },
  43. // 结束时间
  44. endChange: function (e) {
  45. let { value } = e.detail;
  46. this.setData({ 'exportForm.apply_date@end': value })
  47. },
  48. // 重置条件
  49. expertReset: function (e) {
  50. this.setData({ exportForm: { user_name: '', mech_name: '', receive_user_name: '', status: null } })
  51. },
  52. // 确认导出
  53. exportSubmit: function (e) {
  54. console.log(e.detail.value);
  55. console.log('打开文档成功')
  56. },
  57. // 添加采购申请
  58. toAdd: function () {
  59. wx.navigateTo({ url: `/pages/market_buy/detail` })
  60. },
  61. // 详细信息
  62. toView: function (e) {
  63. let item = e.currentTarget.dataset.item;
  64. this.setData({ info: item })
  65. this.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
  66. },
  67. // 订单签收
  68. toSign: function (e) {
  69. wx.showModal({
  70. title: '是否确认签收订单',
  71. success(res) {
  72. if (res.confirm) {
  73. wx.showToast({ title: `订单签收完成`, icon: 'success', duration: 2000 })
  74. } else if (res.cancel) {
  75. }
  76. }
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面加载
  81. */
  82. onLoad: function (options) {
  83. this.watchLogin();
  84. // 计算高度
  85. this.searchHeight();
  86. },
  87. // 监听用户是否登录
  88. watchLogin: function () {
  89. let data = [
  90. { order_num: 'Hgj4757945hdFueu', receive_user_name: '胡图图', mech_name: '翻斗幼儿园-小豆班', status_name: '待供货单位确认', status: '1', user_name: '采购人员', user_phone: '12345678901', money: '3344', receive_user_phone: '98765432109', receive_address: '翻斗大街翻斗花园2号楼1001室', order: [{ name: '小洋人', num: '123', money: '3000' }, { name: '娃哈哈', num: '123', money: '344' }] }
  91. ]
  92. this.setData({ list: data })
  93. // wx.getStorage({
  94. // key: 'user',
  95. // success: res => {
  96. // if (res.data) {
  97. // // 查询菜单
  98. // if (res.data) this.searchRouter(res.data);
  99. // res.data.type = type.find((i) => i.value == res.data.type).label;
  100. // if (res.data) this.setData({ userInfo: res.data });
  101. // if (res.data && res.data.avatarUrl) this.setData({ avatarUrl: res.data.avatarUrl });
  102. // } else {
  103. // wx.redirectTo({ url: '/pages/login/index', })
  104. // }
  105. // }
  106. // })
  107. },
  108. // 计算高度
  109. searchHeight: function () {
  110. let frameStyle = this.data.frameStyle;
  111. let client = app.globalData.client;
  112. // 减去状态栏
  113. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  114. // 是否减去底部菜单
  115. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  116. if (infoHeight) this.setData({ infoHeight: infoHeight })
  117. },
  118. /**
  119. * 生命周期函数--监听页面初次渲染完成
  120. */
  121. onReady: function () {
  122. },
  123. /**
  124. * 生命周期函数--监听页面显示
  125. */
  126. onShow: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面隐藏
  130. */
  131. onHide: function () {
  132. },
  133. /**
  134. * 生命周期函数--监听页面卸载
  135. */
  136. onUnload: function () {
  137. },
  138. /**
  139. * 页面相关事件处理函数--监听用户下拉动作
  140. */
  141. onPullDownRefresh: function () {
  142. },
  143. /**
  144. * 页面上拉触底事件的处理函数
  145. */
  146. onReachBottom: function () {
  147. },
  148. /**
  149. * 用户点击右上角分享
  150. */
  151. onShareAppMessage: function () {
  152. }
  153. })