siteService.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // 生产计划 - 二级 - 新生成及发料顺序调整
  2. var util = require('../../../utils/util.js')
  3. const app = getApp();
  4. Page({
  5. data: {
  6. calcDate: util.getToday(),
  7. isShow: true,
  8. noData:'../../../images/noData.png',
  9. dataListTips: "暂无数据",
  10. g_createrId:"",
  11. inputvalue:"",
  12. statusNameList: [
  13. { "name": "服务中", "id": "服务中" },
  14. { "name": "已完成", "id": "已完成" },
  15. { "name": "已撤销", "id": "已撤销" },
  16. { "name": "超时", "id": "超时" },
  17. ],
  18. statusIndex: "",
  19. statusName:'',
  20. isShowDel: false,
  21. delId:"",
  22. //表格请求参数~~
  23. table: {
  24. getdataListParm: {
  25. name: 'getServiceApp',
  26. page: 1,
  27. offset: 1,
  28. pagecount: 20,
  29. returntype: 'Map',
  30. parammaps: {
  31. inputvalue: "",
  32. beginDate: util.get7daysAgo(),
  33. endDate: util.getToday(),
  34. statusName: "",
  35. userId: "",
  36. roleId: "",
  37. }
  38. },
  39. tableKey: 0,
  40. list: [
  41. // {"content":"想做计步器宣传,目前已让任老师帮忙做。","customerId":378,"customerName":"天津振杰","id":827,"receiverId":1497,"receiverName":"张振强","receiverTel":"","remark":"","vdate":"2020-10-16","visiterId":30,"visiterName":"高占永"},
  42. // {"content":"兴安盟牧场已确定安装我司饲喂系统,目前正在走流程。","customerId":255,"customerName":"原阳富源牧业","id":826,"receiverId":1341,"receiverName":"贾又春","receiverTel":"","remark":"","vdate":"2020-09-27","visiterId":30,"visiterName":"高占永"},
  43. // {"content":"沟通款项,已支付","customerId":643,"customerName":"木易牧场","id":825,"receiverId":1333,"receiverName":"李宝丽","receiverTel":"","remark":"","vdate":"2020-09-24","visiterId":30,"visiterName":"高占永"}
  44. ],
  45. total: 0,
  46. listLoading: true,
  47. },
  48. },
  49. onReachBottom: function () {
  50. console.log('下拉分页')
  51. var offset = this.data.table.getdataListParm.offset + 1
  52. this.setData({['table.getdataListParm.offset']: offset})
  53. this.getList()
  54. },
  55. onLoad: function (options) {
  56. this.setData({
  57. g_createrId:app.globalData.g_createrId,
  58. ['table.getdataListParm.parammaps.userId']:app.globalData.g_userId,
  59. ['table.getdataListParm.parammaps.roleId']:app.globalData.g_roleId
  60. })
  61. this.getList()
  62. },
  63. //搜索内容
  64. change_inputvalue:function(e){
  65. var value = e.detail.value
  66. console.log(value)
  67. this.setData({
  68. ['table.getdataListParm.parammaps.inputvalue']: value
  69. })
  70. },
  71. //搜索按钮
  72. on_search_tap(e) {
  73. this.setData({
  74. ['table.getdataListParm.offset']:1,
  75. })
  76. console.log("表格请求数据:", this.data.table.getdataListParm)
  77. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  78. },
  79. //清空按钮
  80. on_error_tap(e) {
  81. console.log("搜索清空")
  82. this.setData({
  83. inputvalue:"",
  84. ['table.getdataListParm.parammaps.inputvalue']:"",
  85. ['table.getdataListParm.parammaps.statusName']:"",
  86. statusIndex: "",
  87. statusName: "",
  88. })
  89. this.setData({
  90. ['table.getdataListParm.offset']:1,
  91. })
  92. console.log("表格请求数据:", this.data.table.getdataListParm)
  93. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  94. },
  95. //下拉框:服务状态
  96. change_statusName:function(e){
  97. console.log('change_statusName的选项', e.detail.value)
  98. var newId = this.data.statusNameList[e.detail.value]['id']
  99. console.log('change_statusName的newId', newId)
  100. this.setData({
  101. statusIndex: e.detail.value,
  102. statusName: newId,
  103. ['table.getdataListParm.parammaps.statusName']: newId,
  104. })
  105. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  106. },
  107. //加载表格
  108. getList() {
  109. console.log("表格请求数据:", this.data.table.getdataListParm)
  110. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess2)
  111. },
  112. getListSuccess1: function (res) {
  113. console.log('table数据======>', res.data.list)
  114. if (res.data.list !== null) {
  115. this.setData({
  116. isShow: true,
  117. ['table.list']: res.data.list,
  118. ['table.getdataListParm.offset']: res.data.pageNum,
  119. ['table.total']: res.data.total
  120. })
  121. } else {
  122. this.setData({
  123. ['table.list']: [],
  124. ['table.getdataListParm.offset']: res.data.pageNum,
  125. isShow: false,
  126. dataListTips: "暂无数据"
  127. })
  128. }
  129. },
  130. getListSuccess2: function (res) {
  131. console.log('table数据======>', res.data)
  132. var tempList = res.data.list;
  133. if (res.data.list !== null) {
  134. this.setData({
  135. isShow: true,
  136. ['table.list']: this.data.table.list.concat(tempList),
  137. ['table.getdataListParm.offset']: res.data.pageNum,
  138. ['table.total']: res.data.total
  139. })
  140. } else {
  141. this.setData({
  142. ['table.getdataListParm.offset']: res.data.pageNum
  143. })
  144. }
  145. },
  146. //搜索按钮
  147. formSubmit(e) {
  148. console.log('搜索按钮:', e.detail.value)
  149. this.setData({
  150. ['table.getdataListParm.parammaps.inputvalue']: e.detail.value.inputvalue,
  151. ['table.getdataListParm.offset']:1,
  152. })
  153. console.log("表格请求数据:", this.data.table.getdataListParm)
  154. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  155. },
  156. //日期1
  157. bindDateChange1: function (e) {
  158. this.setData({
  159. ['table.getdataListParm.offset']:1,
  160. ['table.getdataListParm.parammaps.beginDate']: e.detail.value
  161. })
  162. console.log("表格请求数据:", this.data.table.getdataListParm)
  163. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  164. },
  165. //日期2
  166. bindDateChange2: function (e) {
  167. this.setData({
  168. ['table.getdataListParm.offset']:1,
  169. ['table.getdataListParm.parammaps.endDate']: e.detail.value
  170. })
  171. console.log("表格请求数据:", this.data.table.getdataListParm)
  172. util.getDataByName(this.data.table.getdataListParm, this.getListSuccess1)
  173. },
  174. //查看
  175. on_see_tap: function (e) {
  176. var id = e.currentTarget.dataset.id;
  177. wx.navigateTo({ url:"../siteServiceSee/siteServiceSee?id=" + id})
  178. },
  179. //编辑
  180. on_edit_tap: function (e) {
  181. var id = e.currentTarget.dataset.id;
  182. wx.navigateTo({ url:"../siteServiceEdit/siteServiceEdit?id=" + id})
  183. },
  184. //新增
  185. on_add_tap: function (e) {
  186. wx.redirectTo({ url:"../siteServiceAdd/siteServiceAdd"})
  187. },
  188. //删除
  189. on_del_tap: function (e) {
  190. var id = e.currentTarget.dataset.id;
  191. this.setData({
  192. isShowDel: true,
  193. delId: id
  194. })
  195. },
  196. on_del_tap_sure(e){
  197. console.log(e)
  198. var that = this
  199. var send_data = {"name":"delService","parammaps":{"id":this.data.delId}}
  200. util.postDataByName(send_data, that.getDelListSuccess)
  201. },
  202. getDelListSuccess: function (res) {
  203. var that = this
  204. console.log('table数据======>', res)
  205. if (res.msg !== 'fail') {
  206. wx.showToast({
  207. title: '删除成功',
  208. icon: 'success',
  209. duration: 2000,
  210. success: function(){
  211. setTimeout(() => {
  212. util.getDataByName(that.data.table.getdataListParm, that.getListSuccess1)
  213. }, 1500)
  214. }
  215. })
  216. } else {
  217. wx.showToast({
  218. title: '删除失败'+res.data,
  219. icon: 'error',
  220. duration: 2000,
  221. })
  222. }
  223. },
  224. })