customerInformation.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. var util = require('../../utils/util.js')
  2. const app = getApp();
  3. Page({
  4. data: {
  5. calcDate: util.getToday(),
  6. isShow: true,
  7. noData:'../../images/noData.png',
  8. dataListTips: "暂无数据",
  9. inputvalue:"",
  10. //表格请求参数~~
  11. table: {
  12. getdataListParm: {
  13. name: 'getCustomerApp',
  14. page: 1,
  15. offset: 1,
  16. pagecount: 10,
  17. returntype: 'Map',
  18. parammaps: {
  19. inputvalue: "",
  20. }
  21. },
  22. tableKey: 0,
  23. list: [
  24. // {"content":"想做计步器宣传,目前已让任老师帮忙做。","customerId":378,"customerName":"天津振杰","id":827,"receiverId":1497,"receiverName":"张振强","receiverTel":"","remark":"","vdate":"2020-10-16","visiterId":30,"visiterName":"高占永"},
  25. // {"content":"兴安盟牧场已确定安装我司饲喂系统,目前正在走流程。","customerId":255,"customerName":"原阳富源牧业","id":826,"receiverId":1341,"receiverName":"贾又春","receiverTel":"","remark":"","vdate":"2020-09-27","visiterId":30,"visiterName":"高占永"},
  26. // {"content":"沟通款项,已支付","customerId":643,"customerName":"木易牧场","id":825,"receiverId":1333,"receiverName":"李宝丽","receiverTel":"","remark":"","vdate":"2020-09-24","visiterId":30,"visiterName":"高占永"}
  27. ],
  28. total: 0,
  29. listLoading: true,
  30. },
  31. },
  32. onReachBottom: function () {
  33. console.log('下拉分页')
  34. var offset = this.data.table.getdataListParm.offset + 1
  35. this.setData({['table.getdataListParm.offset']: offset})
  36. this.getList()
  37. },
  38. onLoad: function (options) {
  39. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  40. },
  41. //清空按钮
  42. on_error_tap(e) {
  43. console.log("搜索清空")
  44. this.setData({
  45. inputvalue:"",
  46. ['table.getdataListParm.parammaps.inputvalue']:""
  47. })
  48. this.setData({
  49. ['table.getdataListParm.offset']:1
  50. })
  51. console.log("表格请求数据:", this.data.table.getdataListParm)
  52. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  53. },
  54. //加载表格
  55. getList() {
  56. console.log("表格请求数据:", this.data.table.getdataListParm)
  57. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess2)
  58. },
  59. getListSuccess2: function (res) {
  60. console.log('table数据======>', res.data)
  61. var tempList = res.data.list;
  62. if (res.data.list !== null) {
  63. this.setData({
  64. isShow: true,
  65. ['table.list']: this.data.table.list.concat(tempList),
  66. ['table.getdataListParm.offset']: res.data.pageNum,
  67. ['table.total']: res.data.total
  68. })
  69. } else {
  70. this.setData({
  71. ['table.getdataListParm.offset']: res.data.pageNum
  72. })
  73. }
  74. },
  75. getListSuccess1: function (res) {
  76. console.log('table数据======>', res.data)
  77. var tempList = res.data.list;
  78. if (res.data.list !== null) {
  79. this.setData({
  80. isShow: true,
  81. ['table.list']: tempList,
  82. ['table.getdataListParm.offset']: res.data.pageNum,
  83. ['table.total']: res.data.total
  84. })
  85. } else {
  86. this.setData({
  87. ['table.list']: [],
  88. ['table.getdataListParm.offset']: res.data.pageNum,
  89. isShow: false,
  90. dataListTips: "暂无数据"
  91. })
  92. }
  93. },
  94. //搜索内容
  95. change_inputvalue:function(e){
  96. var value = e.detail.value
  97. this.setData({
  98. ['table.getdataListParm.parammaps.inputvalue']: value
  99. })
  100. },
  101. //搜索按钮
  102. on_search_tap(e) {
  103. this.setData({
  104. ['table.getdataListParm.offset']:1
  105. })
  106. console.log("表格请求数据:", this.data.table.getdataListParm)
  107. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  108. },
  109. //查看
  110. on_see_tap: function (e) {
  111. var id = e.currentTarget.dataset.id;
  112. wx.navigateTo({ url:"../customerInformationSee/customerInformationSee?id=" + id})
  113. },
  114. //编辑
  115. on_edit_tap: function (e) {
  116. var id = e.currentTarget.dataset.id;
  117. wx.navigateTo({ url:"../customerInformationEdit/customerInformationEdit?id=" + id})
  118. },
  119. //新增
  120. on_add_tap: function (e) {
  121. wx.navigateTo({ url:"../customerInformationAdd/customerInformationAdd"})
  122. },
  123. //删除
  124. on_del_tap: function (e) {
  125. var id = e.currentTarget.dataset.id;
  126. var send_data = {
  127. "name": 'delCustomer',
  128. "parammaps":{"id":id }
  129. }
  130. util.postDataByName(send_data, this.getDelSuccess)
  131. },
  132. getDelSuccess: function (res) {
  133. console.log('删除======>', res)
  134. var that = this
  135. if (res.msg !== 'fail') {
  136. wx.showToast({
  137. title: '删除成功',
  138. icon: 'success',
  139. duration: 2000,
  140. success: function(){
  141. that.getList()
  142. }
  143. })
  144. } else {
  145. wx.showToast({
  146. title: '删除失败'+res.data,
  147. icon: 'error',
  148. duration: 2000,
  149. })
  150. }
  151. },
  152. //联系人管理
  153. on_cont_tap: function (e) {
  154. var id = e.currentTarget.dataset.id;
  155. wx.navigateTo({ url:"../contact/contact?id=" + id})
  156. },
  157. //服务记录
  158. on_service_tap: function (e) {
  159. var id = e.currentTarget.dataset.id;
  160. wx.navigateTo({ url:"../servicepg/servicepg?id=" + id})
  161. },
  162. })