index.js 5.6 KB

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