detail.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // pages/login/login.js
  2. import WxValidate from '../../utils/wxValidate';
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
  10. // 主体高度
  11. infoHeight: '',
  12. form: {},
  13. // 弹框
  14. dialog: { title: '添加商品', show: false, type: '1' },
  15. // 入库商品
  16. order: [],
  17. // 库存已存
  18. oneorderForm: {},
  19. // 查询库存
  20. shoppinginput: '',
  21. stockList: [{ name: '1111' }],
  22. //查询
  23. shoopingtext: '',
  24. },
  25. initValidate() {
  26. const rules = { register_name: { required: true, }, register_phone: { required: true, }, register_date: { required: true, }, reason: { required: true, } }
  27. // 验证字段的提示信息,若不传则调用默认的信息
  28. const messages = { register_name: { required: '请输入登记人', }, register_phone: { required: '请输入电话', }, register_date: { required: '请选择登记时间', }, reason: { required: '请输入入库原因', } };
  29. this.WxValidate = new WxValidate(rules, messages)
  30. },
  31. back: function () {
  32. wx.navigateBack({ url: '/pages/indepot/index' })
  33. },
  34. // 选择登记时间
  35. registerdateChange: function (e) {
  36. let { value } = e.detail;
  37. this.setData({ 'form.register_date': value })
  38. },
  39. // 添加商品
  40. addOrder: function () {
  41. this.setData({ dialog: { title: '添加商品', show: true, type: '1' } })
  42. },
  43. // 已有库存
  44. // 取消保存
  45. oneorderReset: function () {
  46. this.setData({ dialog: { title: '添加商品', show: false, type: '1' } })
  47. },
  48. // 查询
  49. shoppinginput: function (e) {
  50. this.setData({ shoopingtext: e.detail.value })
  51. },
  52. // 查询库存
  53. searchStock: function () {
  54. wx.showToast({ title: `查询库存`, icon: 'error', duration: 2000 })
  55. },
  56. // 确认选择商品
  57. stockChange: function (e) {
  58. const { item } = e.currentTarget.dataset;
  59. this.setData({ 'oneorderForm.stock_market_id': item.id })
  60. this.setData({ 'oneorderForm.name': item.name })
  61. this.setData({ 'oneorderForm.stockNum': item.num })
  62. },
  63. // 提交保存
  64. oneorderSubmit: function (e) {
  65. console.log(e.detail.value);
  66. },
  67. // 取消保存
  68. onReset: function (e) {
  69. this.back()
  70. },
  71. // 提交保存
  72. onSubmit: function (e) {
  73. console.log(e.detail.value);
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. onLoad: function (options) {
  79. //验证规则函数
  80. this.initValidate()
  81. // 计算高度
  82. this.searchHeight()
  83. },
  84. // 计算高度
  85. searchHeight: function () {
  86. let frameStyle = this.data.frameStyle;
  87. let client = app.globalData.client;
  88. // 减去状态栏
  89. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  90. // 是否减去底部菜单
  91. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  92. if (infoHeight) this.setData({ infoHeight: infoHeight })
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady: function () {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow: function () {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload: function () {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh: function () {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom: function () {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage: function () {
  128. }
  129. })