index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import api from '../../api/api'
  2. Page({
  3. data: {
  4. param: {
  5. "id": "20220920083901",
  6. "content": {
  7. nocache: true,
  8. "pageSize": 20,
  9. "pageNumber": 1,
  10. "where": {
  11. "condition": "",
  12. type: 17
  13. }
  14. }
  15. },
  16. list: []
  17. },
  18. async listData() {
  19. const res = await api._post(this.data.param)
  20. if (res.data.length > 0) {
  21. this.setData({
  22. list: this.data.list.concat(res.data)
  23. })
  24. } else {
  25. getApp().globalData.Language.showToast('没有更多了!')
  26. }
  27. },
  28. onSubmit(data) {
  29. this.data.param.content.where.condition = data.detail.value
  30. this.setData({
  31. list: []
  32. })
  33. this.data.param.content.pageNumber = 1
  34. this.listData()
  35. },
  36. onClick(data) {
  37. let item = data.currentTarget.dataset.item
  38. let form = getApp().globalData.formData
  39. let index = form.data.formLayoutData.formInfo.findIndex(v => v.label == '经销商');
  40. if (index == -1) {
  41. form.data.formLayoutData.formInfo.unshift({
  42. label: '经销商', //标题
  43. type: 'cell', //表单类型 text,upload,picker,datepicker
  44. id: 'enterprisename', //表单id
  45. placeholder: '', //设置文本框默认提示
  46. inputValue: item.enterprisename,
  47. data: [], //填充表单的数据 例如下拉框
  48. role: {
  49. type: 'reg',
  50. },
  51. force: false, //是否必输入
  52. })
  53. } else {
  54. form.data.formLayoutData.formInfo[index].inputValue = item.enterprisename;
  55. }
  56. form.data.formLayoutData.formInfo.forEach(e => {
  57. if (e.id === 'sys_enterpriseid') {
  58. e.inputValue = item.sys_enterpriseid
  59. }
  60. })
  61. form.setData({
  62. formLayoutData: form.data.formLayoutData
  63. })
  64. wx.navigateBack({
  65. delta: 0
  66. })
  67. },
  68. onLoad(options) {
  69. this.listData()
  70. this.setData({
  71. loadingTexts: ['下拉刷新', '松手刷新', '正在刷新', '刷新完成'].map(v => getApp().globalData.Language.getMapText(v))
  72. })
  73. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  74. },
  75. onPullDownRefresh() {
  76. this.data.list = []
  77. this.data.param.content.pageNumber = 1
  78. this.listData()
  79. },
  80. onReachBottom() {
  81. this.data.param.content.pageNumber++
  82. this.listData()
  83. },
  84. })