index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. const api = require("../api/api")
  2. Page({
  3. data: {
  4. dateVisible: false,
  5. timerid: null,
  6. bindSignNameData: {
  7. "ownertable": "sa_workorder_confirmation",
  8. "ownerid": 0,
  9. "usetype": "signature",
  10. },
  11. SignName: true,
  12. paidServiceAmount: 0
  13. },
  14. async billData() {
  15. const res = await api._post({
  16. "id": "20230211105803",
  17. "content": {
  18. "sa_workorder_confirmationid": this.data.id
  19. }
  20. })
  21. let ishave = false
  22. res.data.confirmationcontent.forEach(item => {
  23. if (item.nextTreatmentTime) {
  24. ishave = true
  25. }
  26. })
  27. if (!ishave) {
  28. let arr = [{
  29. nextTreatmentTime: {
  30. confirm_value: ''
  31. }
  32. }, {
  33. treatment: {
  34. confirm_value: ''
  35. }
  36. }, {
  37. explain: {
  38. confirm_value: ''
  39. }
  40. }, {
  41. repairResult: {
  42. confirm_value: ''
  43. }
  44. }, {
  45. rebackTime: {
  46. confirm_value: ''
  47. }
  48. }, {
  49. nextRebackTime: {
  50. confirm_value: ''
  51. }
  52. }, {
  53. text: {
  54. confirm_value: ''
  55. }
  56. }]
  57. arr.forEach(e => {
  58. res.data.confirmationcontent.push(e)
  59. }, this)
  60. }
  61. console.log(res.data)
  62. this.setData({
  63. mainData: res.data,
  64. stopClick: res.data.status !== '新建' ? 'stopClick' : this.data.stopClick
  65. })
  66. this.setInputData()
  67. },
  68. setInputData() {
  69. let that = this
  70. that.data.mainData.confirmationcontent.forEach(e => {
  71. Object.keys(e).map((key, index) => {
  72. that.setData({
  73. paidServiceAmount: that.data.paidServiceAmount + e[key].amount
  74. })
  75. if (key === 'nextTreatmentTime') {
  76. this.setData({
  77. nextTreatmentTime: e[key].confirm_value
  78. })
  79. }
  80. if (key === 'treatment') {
  81. this.setData({
  82. treatment: e[key].confirm_value
  83. })
  84. }
  85. if (key === 'explain') {
  86. this.setData({
  87. explain: e[key].confirm_value
  88. })
  89. }
  90. if (key === 'nextRebackTime') {
  91. this.setData({
  92. nextRebackTime: e[key].confirm_value
  93. })
  94. }
  95. if (key === 'text') {
  96. this.setData({
  97. text: e[key].confirm_value
  98. })
  99. }
  100. })
  101. })
  102. },
  103. async updateBill() {
  104. if (this.data.mainData.status !== '新建') return getApp().globalData.Language.showToast('非新建状态,修改的数据将不会保存')
  105. const res = await api._post({
  106. "id": "20230211105703",
  107. "content": this.data.mainData
  108. })
  109. },
  110. /* 查看单据 */
  111. checkImage() {
  112. let attinfos = this.data.mainData.attinfos.map(v => v.usetype);
  113. let index = attinfos.lastIndexOf("comfirmbill");
  114. //没有查询到有效单据 跳转生成
  115. if (index == -1) return this.createImage(true);
  116. wx.previewImage({
  117. urls: [this.data.mainData.attinfos[index].url],
  118. })
  119. },
  120. // 改变评分
  121. onChange(e) {
  122. this.data.mainData[e.currentTarget.dataset.name] = e.detail.value
  123. this.setData({
  124. mainData: this.data.mainData
  125. });
  126. this.updateBill()
  127. },
  128. async submit() {
  129. this.createImage(true);
  130. const res = await api._post({
  131. "id": "20230211110003",
  132. "content": {
  133. "sa_workorder_confirmationid": this.data.mainData.sa_workorder_confirmationid
  134. }
  135. })
  136. if (res.code == 1) {
  137. wx.showToast({
  138. title: getApp().globalData.Language.getMapText('提交成功'),
  139. icon: "success"
  140. })
  141. this.billData()
  142. }
  143. },
  144. async delete() {
  145. const res = await api._post({
  146. "id": "20230211110103",
  147. "content": {
  148. "sa_workorder_confirmationids": [this.data.mainData.sa_workorder_confirmationid]
  149. }
  150. })
  151. if (res.code == 1) {
  152. wx.navigateBack()
  153. }
  154. },
  155. inputChange(data) {
  156. console.log(data)
  157. let name = data.currentTarget.dataset.name
  158. this.data.mainData.confirmationcontent.forEach(e => {
  159. Object.keys(e).map((key, index) => {
  160. if (name === key) {
  161. e[key].confirm_value = data.detail.value
  162. }
  163. })
  164. })
  165. this.updateBill()
  166. },
  167. showNextTimePicker(data) {
  168. let name = data.currentTarget.dataset.name
  169. this.setData({
  170. pickkerName: name,
  171. dateVisible: !this.data.dateVisible
  172. })
  173. },
  174. onConfirm(data) {
  175. let name = this.data.pickkerName
  176. this.data.mainData.confirmationcontent.forEach(e => {
  177. Object.keys(e).map((key, index) => {
  178. if (name === key) {
  179. e[key].confirm_value = data.detail.value
  180. }
  181. })
  182. })
  183. this.setData({
  184. mainData: this.data.mainData
  185. })
  186. this.updateBill()
  187. this.setInputData()
  188. },
  189. createImage(active = false) {
  190. let token = wx.getStorageSync('userMsg').token
  191. let parentid = wx.getStorageSync('siteP').appfolderid
  192. let url = `${getApp().globalData.http.baseUrl}/yosweb/#/printTable??token=${token}&parentid=${parentid}&ownerid=${this.data.mainData.sa_workorder_confirmationid}${active==true?'&action=1':''}`
  193. this.setData({
  194. url: url
  195. })
  196. wx.navigateTo({
  197. url: '/Eservice/webView/index',
  198. })
  199. },
  200. onLoad(options) {
  201. this.data.bindSignNameData.ownerid = options.id
  202. this.setData({
  203. stopClick: options.class,
  204. id: options.id,
  205. bindSignNameData: this.data.bindSignNameData
  206. })
  207. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  208. },
  209. onReady() {
  210. },
  211. onShow() {
  212. this.setData({
  213. SignName: true
  214. })
  215. this.billData()
  216. },
  217. onHide() {
  218. this.setData({
  219. SignName: false
  220. })
  221. },
  222. })