historyFill.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. var util = require('../../../utils/util.js')
  2. Page({
  3. data: {
  4. orderId: null,
  5. noData: '../../../images/noData.png',
  6. dataListTips: '暂无数据',
  7. // 初始日期范围
  8. form: {
  9. beginDate: util.get7daysAgo(),
  10. endDate: util.getRealToday(),
  11. orderId: null,
  12. staffId: '',
  13. },
  14. serviceStaffname: '',
  15. records: [],
  16. installerList: [],
  17. },
  18. onLoad(options) {
  19. const id = options.id
  20. this.setData({
  21. orderId: id,
  22. ['form.orderId']: id,
  23. })
  24. this.getDetail()
  25. // this.getinstallerList()
  26. },
  27. getDetail() {
  28. var send_data = [
  29. { name: 'getInstallationDailyDetailByOrderId', returntype: 'Map', parammaps: this.data.form },
  30. ]
  31. util.getDataByNames(send_data, this.handleDetail)
  32. },
  33. handleDetail(res) {
  34. var data = res.data
  35. if (data.getInstallationDailyDetailByOrderId.list != null) {
  36. var list = data.getInstallationDailyDetailByOrderId.list
  37. var service = list.map((item, indexx) => {
  38. const obj = {
  39. name: item.installUserName,
  40. id: item.installUserId,
  41. }
  42. return obj
  43. })
  44. const uniqueData = service.filter((item, index, self) => {
  45. return index === self.findIndex((t) => t.id === item.id)
  46. })
  47. console.log(uniqueData, 'service')
  48. this.setData({
  49. records: data.getInstallationDailyDetailByOrderId.list,
  50. installerList: uniqueData,
  51. })
  52. } else {
  53. this.setData({
  54. records: [],
  55. })
  56. }
  57. },
  58. onInstallerChange: function (e) {
  59. console.log(e, 'eee')
  60. this.setData({
  61. serviceStaffname: this.data.installerList[e.detail.value].name,
  62. ['form.staffId']: this.data.installerList[e.detail.value].id,
  63. })
  64. },
  65. onInputChangeClear(e) {
  66. this.setData({
  67. serviceStaffname: '',
  68. ['form.staffId']: '',
  69. })
  70. },
  71. // 服务人员
  72. getinstallerList() {
  73. var send_data = [
  74. {
  75. name: 'getUsersSelect',
  76. offset: 0,
  77. pagecount: 0,
  78. parammaps: {
  79. enable: '1',
  80. orderId: this.data.orderId,
  81. },
  82. },
  83. ]
  84. util.getDataByNames(send_data, this.handleInstallerList)
  85. },
  86. handleInstallerList(res) {
  87. const obj = res.data
  88. if (obj.getUsersSelect) {
  89. this.setData({
  90. installerList: obj.getUsersSelect.list,
  91. })
  92. }
  93. },
  94. onStaffChange(e) {
  95. this.setData({
  96. serverPerson: this.data.serviceList[e.detail.value],
  97. })
  98. },
  99. onContactChange(e) {
  100. this.setData({
  101. serverPerson: e.detail.value,
  102. })
  103. },
  104. onDateChange(e) {
  105. this.setData({
  106. 'formObj.acceptanceDate': e.detail.value,
  107. })
  108. },
  109. onSelectPerson(event) {
  110. this.setData({
  111. 'formObj.serverPerson': this.data.serviceList[event.detail.value],
  112. })
  113. },
  114. onBack() {
  115. wx.navigateBack()
  116. },
  117. uploadReceipt() {
  118. // 上传验收单的逻辑
  119. const that = this
  120. wx.chooseImage({
  121. count: 1,
  122. sizeType: ['compressed'],
  123. sourceType: ['album', 'camera'],
  124. success(res) {
  125. that.setData({
  126. 'formObj.acceptanceFile': res.tempFilePaths[0],
  127. 'errors.acceptanceFile': '',
  128. })
  129. },
  130. })
  131. },
  132. validateForm() {
  133. const { serverPerson, acceptanceDate, acceptanceFile } = this.data.formObj
  134. if (!serverPerson) {
  135. wx.showToast({ title: '请填写服务人员', icon: 'none' })
  136. return false
  137. }
  138. if (!acceptanceDate) {
  139. wx.showToast({ title: '请选择验收日期', icon: 'none' })
  140. return false
  141. }
  142. if (!acceptanceFile) {
  143. wx.showToast({ title: '请上传验收单', icon: 'none' })
  144. return false
  145. }
  146. return true
  147. },
  148. formSubmit(e) {
  149. console.log('this.data.formObj:', this.data.formObj)
  150. wx.showToast({ title: '提交成功', icon: 'success' })
  151. if (!this.validateForm()) return
  152. },
  153. formReset(e) {
  154. console.log('form发生了reset事件,携带数据为:', e.detail.value)
  155. this.setData({
  156. chosen: '',
  157. })
  158. },
  159. goBack() {
  160. wx.navigateBack()
  161. },
  162. //日期1
  163. bindDateChange1: function (e) {
  164. this.setData({
  165. ['form.beginDate']: e.detail.value,
  166. })
  167. },
  168. //日期2
  169. bindDateChange2: function (e) {
  170. this.setData({
  171. ['form.endDate']: e.detail.value,
  172. })
  173. },
  174. viewHistory() {
  175. // 查看历史记录
  176. wx.navigateTo({
  177. url: '/pages/workbench/historyRecord/historyRecord',
  178. })
  179. },
  180. // 更新今日完成量
  181. updateTodayQuantity(e) {
  182. const value = parseInt(e.detail.value) || 0
  183. const remaining = this.data.totalQuantity - this.data.completedQuantity - value
  184. this.setData({
  185. todayQuantity: value,
  186. remainingQuantity: remaining >= 0 ? remaining : 0,
  187. })
  188. },
  189. // 保存记录
  190. saveRecord() {
  191. wx.showLoading({
  192. title: '保存中...',
  193. })
  194. // 这里添加保存逻辑
  195. setTimeout(() => {
  196. wx.hideLoading()
  197. wx.showToast({
  198. title: '保存成功',
  199. icon: 'success',
  200. })
  201. }, 1500)
  202. },
  203. })