index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. const api = require("../api/api")
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. dateVisible: false,
  8. timerid: null,
  9. bindSignNameData: {
  10. "ownertable": "sa_workorder_confirmation",
  11. "ownerid": 0,
  12. "usetype": "signature",
  13. },
  14. paidServiceAmount: 0
  15. },
  16. async billData() {
  17. const res = await api._post({
  18. "id": "20230211105803",
  19. "content": {
  20. "sa_workorder_confirmationid": this.data.id
  21. }
  22. })
  23. let ishave = false
  24. res.data.confirmationcontent.forEach(item => {
  25. if (item.nextTreatmentTime) {
  26. ishave = true
  27. }
  28. })
  29. if (!ishave) {
  30. let arr = [{
  31. nextTreatmentTime: {
  32. confirm_value: ''
  33. }
  34. }, {
  35. treatment: {
  36. confirm_value: ''
  37. }
  38. }, {
  39. explain: {
  40. confirm_value: ''
  41. }
  42. }, {
  43. repairResult: {
  44. confirm_value: ''
  45. }
  46. }, {
  47. rebackTime: {
  48. confirm_value: ''
  49. }
  50. }, {
  51. nextRebackTime: {
  52. confirm_value: ''
  53. }
  54. }, {
  55. text: {
  56. confirm_value: ''
  57. }
  58. }]
  59. arr.forEach(e => {
  60. res.data.confirmationcontent.push(e)
  61. }, this)
  62. }
  63. console.log(res.data)
  64. this.setData({
  65. mainData: res.data,
  66. stopClick: res.data.status !== '新建' ? 'stopClick' : this.data.stopClick
  67. })
  68. this.setInputData()
  69. },
  70. setInputData() {
  71. let that = this
  72. that.data.mainData.confirmationcontent.forEach(e => {
  73. Object.keys(e).map((key, index) => {
  74. that.setData({
  75. paidServiceAmount: that.data.paidServiceAmount + e[key].amount
  76. })
  77. if (key === 'nextTreatmentTime') {
  78. this.setData({
  79. nextTreatmentTime: e[key].confirm_value
  80. })
  81. }
  82. if (key === 'treatment') {
  83. this.setData({
  84. treatment: e[key].confirm_value
  85. })
  86. }
  87. if (key === 'explain') {
  88. this.setData({
  89. explain: e[key].confirm_value
  90. })
  91. }
  92. if (key === 'nextRebackTime') {
  93. this.setData({
  94. nextRebackTime: e[key].confirm_value
  95. })
  96. }
  97. if (key === 'text') {
  98. this.setData({
  99. text: e[key].confirm_value
  100. })
  101. }
  102. })
  103. })
  104. },
  105. async updateBill() {
  106. if (this.data.mainData.status !== '新建') return wx.showToast({
  107. title: '非新建状态,修改的数据将不会保存',
  108. icon: 'none'
  109. })
  110. const res = await api._post({
  111. "id": "20230211105703",
  112. "content": this.data.mainData
  113. })
  114. },
  115. // 改变评分
  116. onChange(e) {
  117. this.data.mainData[e.currentTarget.dataset.name] = e.detail.value
  118. this.setData({
  119. mainData: this.data.mainData
  120. });
  121. this.updateBill()
  122. },
  123. async submit() {
  124. const res = await api._post({
  125. "id": "20230211110003",
  126. "content": {
  127. "sa_workorder_confirmationid": this.data.mainData.sa_workorder_confirmationid
  128. }
  129. })
  130. if (res.code == 1) {
  131. wx.showToast({
  132. title: '提交成功',
  133. icon: "success"
  134. })
  135. this.billData()
  136. }
  137. },
  138. async delete() {
  139. const res = await api._post({
  140. "id": "20230211110103",
  141. "content": {
  142. "sa_workorder_confirmationids": [this.data.mainData.sa_workorder_confirmationid]
  143. }
  144. })
  145. if (res.code == 1) {
  146. wx.navigateBack()
  147. }
  148. },
  149. inputChange(data) {
  150. console.log(data)
  151. let name = data.currentTarget.dataset.name
  152. this.data.mainData.confirmationcontent.forEach(e => {
  153. Object.keys(e).map((key, index) => {
  154. if (name === key) {
  155. e[key].confirm_value = data.detail.value
  156. }
  157. })
  158. })
  159. this.updateBill()
  160. },
  161. showNextTimePicker(data) {
  162. let name = data.currentTarget.dataset.name
  163. this.setData({
  164. pickkerName: name,
  165. dateVisible: !this.data.dateVisible
  166. })
  167. },
  168. onConfirm(data) {
  169. let name = this.data.pickkerName
  170. this.data.mainData.confirmationcontent.forEach(e => {
  171. Object.keys(e).map((key, index) => {
  172. if (name === key) {
  173. e[key].confirm_value = data.detail.value
  174. }
  175. })
  176. })
  177. this.setData({
  178. mainData: this.data.mainData
  179. })
  180. this.updateBill()
  181. this.setInputData()
  182. },
  183. createImage() {
  184. let token = wx.getStorageSync('userMsg').token
  185. let parentid = wx.getStorageSync('siteP').appfolderid
  186. let url = `${getApp().globalData.http.baseUrl}/yosweb/#/printTable?token=${token}&parentid=${parentid}&ownerid=${this.data.mainData.sa_workorder_confirmationid}`
  187. this.setData({
  188. url: url
  189. })
  190. wx.navigateTo({
  191. url: '/Eservice/webView/index',
  192. })
  193. },
  194. /**
  195. * 生命周期函数--监听页面加载
  196. */
  197. onLoad(options) {
  198. this.data.bindSignNameData.ownerid = options.id
  199. this.setData({
  200. stopClick: options.class,
  201. id: options.id,
  202. bindSignNameData: this.data.bindSignNameData
  203. })
  204. this.billData()
  205. },
  206. /**
  207. * 生命周期函数--监听页面初次渲染完成
  208. */
  209. onReady() {
  210. },
  211. /**
  212. * 生命周期函数--监听页面显示
  213. */
  214. onShow() {
  215. this.setData({
  216. SignName: true
  217. })
  218. },
  219. /**
  220. * 生命周期函数--监听页面隐藏
  221. */
  222. onHide() {
  223. this.setData({
  224. SignName: false
  225. })
  226. },
  227. /**
  228. * 生命周期函数--监听页面卸载
  229. */
  230. onUnload() {
  231. },
  232. /**
  233. * 页面相关事件处理函数--监听用户下拉动作
  234. */
  235. onPullDownRefresh() {
  236. },
  237. /**
  238. * 页面上拉触底事件的处理函数
  239. */
  240. onReachBottom() {
  241. },
  242. /**
  243. * 用户点击右上角分享
  244. */
  245. onShareAppMessage() {
  246. }
  247. })