index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. this.createImage(true);
  125. const res = await api._post({
  126. "id": "20230211110003",
  127. "content": {
  128. "sa_workorder_confirmationid": this.data.mainData.sa_workorder_confirmationid
  129. }
  130. })
  131. if (res.code == 1) {
  132. wx.showToast({
  133. title: getApp().globalData.Language.getMapText('提交成功'),
  134. icon: "success"
  135. })
  136. this.billData()
  137. }
  138. },
  139. async delete() {
  140. const res = await api._post({
  141. "id": "20230211110103",
  142. "content": {
  143. "sa_workorder_confirmationids": [this.data.mainData.sa_workorder_confirmationid]
  144. }
  145. })
  146. if (res.code == 1) {
  147. wx.navigateBack()
  148. }
  149. },
  150. inputChange(data) {
  151. console.log(data)
  152. let name = data.currentTarget.dataset.name
  153. this.data.mainData.confirmationcontent.forEach(e => {
  154. Object.keys(e).map((key, index) => {
  155. if (name === key) {
  156. e[key].confirm_value = data.detail.value
  157. }
  158. })
  159. })
  160. this.updateBill()
  161. },
  162. showNextTimePicker(data) {
  163. let name = data.currentTarget.dataset.name
  164. this.setData({
  165. pickkerName: name,
  166. dateVisible: !this.data.dateVisible
  167. })
  168. },
  169. onConfirm(data) {
  170. let name = this.data.pickkerName
  171. this.data.mainData.confirmationcontent.forEach(e => {
  172. Object.keys(e).map((key, index) => {
  173. if (name === key) {
  174. e[key].confirm_value = data.detail.value
  175. }
  176. })
  177. })
  178. this.setData({
  179. mainData: this.data.mainData
  180. })
  181. this.updateBill()
  182. this.setInputData()
  183. },
  184. /* 查看单据 */
  185. checkImage() {
  186. let attinfos = this.data.mainData.attinfos.map(v => v.usetype);
  187. let index = attinfos.lastIndexOf("comfirmbill");
  188. //没有查询到有效单据 跳转生成
  189. if (index == -1) return this.createImage(true);
  190. wx.previewImage({
  191. urls: [this.data.mainData.attinfos[index].url],
  192. })
  193. },
  194. createImage(active = false) {
  195. let token = wx.getStorageSync('userMsg').token
  196. let parentid = wx.getStorageSync('siteP').appfolderid
  197. let url = `${getApp().globalData.http.baseUrl}/yosweb/#/printTable?token=${token}&parentid=${parentid}&ownerid=${this.data.mainData.sa_workorder_confirmationid}${active==true?'&action=1':''}`
  198. this.setData({
  199. url: url
  200. })
  201. wx.navigateTo({
  202. url: '/Eservice/webView/index',
  203. })
  204. },
  205. /**
  206. * 生命周期函数--监听页面加载
  207. */
  208. onLoad(options) {
  209. this.data.bindSignNameData.ownerid = options.id
  210. this.setData({
  211. stopClick: options.class,
  212. id: options.id,
  213. bindSignNameData: this.data.bindSignNameData
  214. })
  215. },
  216. onShow() {
  217. this.setData({
  218. SignName: true
  219. })
  220. this.billData()
  221. },
  222. onHide() {
  223. this.setData({
  224. SignName: false
  225. })
  226. }
  227. })