siteServiceCompleteService.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. var util = require('../../../utils/util.js')
  2. const app = getApp();
  3. Page({
  4. data: {
  5. allDisabled:true,//有客户下拉时临时用来控制其他下拉不显示
  6. c_txt_Show:false,
  7. customerShow:false,
  8. //款项状态
  9. moneyStatusList: [
  10. { "name": "需要收款", "id": "需要收款" },
  11. { "name": "无需收款", "id": "无需收款" },
  12. ],
  13. moneyIndex: 0,
  14. moneyId:'需要收款',
  15. isCost: true,
  16. id:"",
  17. rules: {
  18. costStatus: [{ required: true, message: '款项状态必填', trigger: 'blur' }],
  19. serviceCost: [{ required: true, message: '服务费用必填', trigger: 'blur' }],
  20. },
  21. // 新增/编辑
  22. create: {
  23. dialogStatus: '',
  24. temp: {
  25. costStatus: '需要收款',
  26. serviceCost: '',
  27. payDate: '',
  28. remoteSummary: '',
  29. created: util.getToday(),
  30. id:"",
  31. receiverChoose: 'true'
  32. },
  33. }
  34. },
  35. onLoad: function (options) {
  36. // 表单初始化
  37. wx.lin.initValidateForm(this)
  38. var id = options.id;
  39. this.setData({
  40. id:id,
  41. ['create.temp.id']:id
  42. })
  43. //被投诉人
  44. //util.getDataByName({name: 'getEmployeesSelect',parammaps: {}}, this.getPickerList3)
  45. },
  46. getPickerList3: function (res) {
  47. console.log('被投诉人下拉数据======>', res.data.list)
  48. this.setData({
  49. moneyStatusList: res.data.list
  50. })
  51. },
  52. //日期选择触发
  53. on_payDate_tap:function(e){
  54. this.setData({
  55. ['create.temp.payDate']:e.detail.value
  56. })
  57. },
  58. //下拉框:款项状态
  59. change_costStatus:function(e){
  60. console.log('change_costStatus的选项', e.detail.value)
  61. var newId = this.data.moneyStatusList[e.detail.value]['id']
  62. console.log('change_costStatus的newId', newId)
  63. this.setData({
  64. moneyIndex: e.detail.value,
  65. moneyId: newId,
  66. ['create.temp.costStatus']: newId,
  67. })
  68. if(newId == '需要收款'){
  69. this.setData({
  70. isCost: true,
  71. })
  72. } else {
  73. this.setData({
  74. isCost: false,
  75. })
  76. }
  77. },
  78. //保存
  79. submit:function(e){
  80. var detail_value = e.detail.values
  81. var detail_errors = e.detail.errors
  82. var detail_errors = e.detail.errors
  83. console.log("detail_value",detail_value)
  84. console.log("create.temp",this.data.create.temp)
  85. const submit_data = Object.assign({}, this.data.create.temp, detail_value)
  86. console.log("保存发送:",submit_data)
  87. var send_data = {
  88. "name":"completeService",
  89. "parammaps":{
  90. "costStatus":submit_data.costStatus,
  91. "serviceCost":submit_data.serviceCost,
  92. "payDate":submit_data.payDate,
  93. "remoteSummary":submit_data.remoteSummary,
  94. "id":this.data.id
  95. }
  96. }
  97. console.log("send_data",JSON.stringify(send_data))
  98. if(submit_data.costStatus == '需要收款'){
  99. if(submit_data.serviceCost == ""){
  100. wx.showToast({title: '服务费用必填',icon: 'none',duration: 2000})
  101. return false
  102. }
  103. }
  104. //验证必填项是否为空
  105. if(submit_data.costStatus == ""){
  106. wx.showToast({title: '款项状态必填',icon: 'none',duration: 2000})
  107. } else {
  108. if( wx.getStorageSync('isLoading') == "true"){
  109. wx.showToast({
  110. title: '正在保存中,请稍等!',
  111. icon: 'none',
  112. duration: 2000
  113. })
  114. } else {
  115. util.postDataByName(send_data, this.getListSuccess)
  116. }
  117. }
  118. },
  119. getListSuccess: function (res) {
  120. console.log('table数据======>', res)
  121. if (res.msg !== 'fail') {
  122. wx.showToast({
  123. title: '保存成功',
  124. icon: 'success',
  125. duration: 2000,
  126. success: function(){
  127. setTimeout(() => {
  128. wx.redirectTo({ url:"../siteService/siteService"})
  129. }, 1500)
  130. }
  131. })
  132. } else {
  133. wx.showToast({
  134. title: '保存失败'+res.data,
  135. icon: 'error',
  136. duration: 2000,
  137. })
  138. }
  139. },
  140. onReady: function () {
  141. },
  142. onShow: function () {
  143. },
  144. onHide: function () {
  145. },
  146. onUnload: function () {
  147. },
  148. /**
  149. * 页面相关事件处理函数--监听用户下拉动作
  150. */
  151. onPullDownRefresh: function () {
  152. },
  153. /**
  154. * 页面上拉触底事件的处理函数
  155. */
  156. onReachBottom: function () {
  157. },
  158. onShareAppMessage: function () {
  159. }
  160. })