index.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. const api = require("../api/api")
  2. Page({
  3. data: {
  4. timerid: null,
  5. bindSignNameData: {
  6. "ownertable": "sa_workorder_confirmation",
  7. "ownerid": 0,
  8. "usetype": "signature",
  9. },
  10. paidServiceAmount: 0,
  11. SignName: true
  12. },
  13. async billData() {
  14. const res = await api._post({
  15. "id": "20230211105803",
  16. "content": {
  17. "sa_workorder_confirmationid": this.data.id
  18. }
  19. })
  20. this.setData({
  21. mainData: res.data,
  22. sa_serviceorderid: res.data.workorder.sa_serviceorderid || "0",
  23. sa_orderid: res.data.workorder.sa_orderid || "0",
  24. stopClick: res.data.status !== '新建' ? 'stopClick' : this.data.stopClick
  25. })
  26. this.setInputData()
  27. },
  28. setInputData() {
  29. let that = this
  30. that.data.mainData.confirmationcontent.forEach(e => {
  31. Object.keys(e).map((key, index) => {
  32. that.setData({
  33. paidServiceAmount: that.data.paidServiceAmount + e[key].amount
  34. })
  35. if (key.includes('是否需要拆卸配件或整拆')) {
  36. that.setData({
  37. node1: e[key].confirm_value
  38. })
  39. }
  40. if (key.includes('与现场协商确认维修方案')) {
  41. that.setData({
  42. node2: e[key].confirm_value ? e[key].confirm_value : e[key].textcontent
  43. })
  44. }
  45. if (key.includes('实施内容')) {
  46. that.setData({
  47. node3: e[key].confirm_value ? e[key].confirm_value : e[key].textcontent
  48. })
  49. }
  50. if (key.includes('与现场协商试运行')) {
  51. that.setData({
  52. node4: e[key].confirm_value ? e[key].confirm_value : e[key].textcontent
  53. })
  54. }
  55. if (key.includes('现场交代事项')) {
  56. that.setData({
  57. node5: e[key].confirm_value ? e[key].confirm_value : e[key].textcontent
  58. })
  59. }
  60. })
  61. })
  62. },
  63. async updateBill() {
  64. if (this.data.mainData.status !== '新建') return getApp().globalData.Language.modeBoxPrompts('非新建状态,修改的数据将不会保存')
  65. const res = await api._post({
  66. "id": "20230211105703",
  67. "content": this.data.mainData
  68. })
  69. },
  70. // 跳转到物料添加
  71. addProduct() {
  72. wx.navigateTo({
  73. url: '/Eservice/agent/billCanUseProduct/index?id=' + this.data.mainData.sa_workorderid,
  74. })
  75. },
  76. // 添加物料
  77. async getAdd(selection) {
  78. let arr = selection.map(e => {
  79. return {
  80. "sa_workorder_node_itemsid": 0,
  81. "itemid": e,
  82. "qty": 1
  83. }
  84. })
  85. this.data.mainData.trainertitems = this.data.mainData.trainertitems.concat(arr)
  86. this.updateMaterial(this.data.mainData.trainertitems)
  87. },
  88. async updateMaterial(trainertitems) {
  89. const res = await api._post({
  90. "id": "20230215201903",
  91. "content": {
  92. "sa_workorder_confirmationid": this.data.mainData.sa_workorder_confirmationid,
  93. "sa_workorderid": this.data.mainData.workorder.sa_workorderid,
  94. "iteminfos": trainertitems
  95. }
  96. })
  97. this.billData()
  98. },
  99. // 删除物料
  100. async deleteMaterial(data) {
  101. let itemid = data.detail.sa_workorder_node_itemsid
  102. const res = await api._post({
  103. "id": "20230215202003",
  104. "version": 1,
  105. "content": {
  106. "sa_workorder_node_itemsids": [itemid]
  107. }
  108. })
  109. this.billData()
  110. },
  111. // 改变评分
  112. onChange(e) {
  113. this.data.mainData[e.currentTarget.dataset.name] = e.detail.value
  114. this.setData({
  115. mainData: this.data.mainData
  116. });
  117. this.updateBill()
  118. },
  119. async submit() {
  120. this.createImage(true);
  121. const res = await api._post({
  122. "id": "20230211110003",
  123. "content": {
  124. "sa_workorder_confirmationid": this.data.mainData.sa_workorder_confirmationid
  125. }
  126. })
  127. if (res.code == 1) {
  128. wx.showToast({
  129. title: getApp().globalData.Language.getMapText('提交成功'),
  130. icon: "success"
  131. })
  132. this.billData()
  133. }
  134. },
  135. async delete() {
  136. const res = await api._post({
  137. "id": "20230211110103",
  138. "content": {
  139. "sa_workorder_confirmationids": [this.data.mainData.sa_workorder_confirmationid]
  140. }
  141. })
  142. if (res.code == 1) {
  143. wx.navigateBack()
  144. }
  145. },
  146. inputChange(data) {
  147. let keyValue = data.currentTarget.dataset.name
  148. this.data.mainData.confirmationcontent.forEach(e => {
  149. Object.keys(e).map((key, index) => {
  150. if (key.includes(keyValue)) {
  151. e[key].confirm_value = data.detail.value
  152. }
  153. })
  154. })
  155. this.updateBill()
  156. },
  157. createImage(active = false) {
  158. let token = wx.getStorageSync('userMsg').token
  159. let parentid = wx.getStorageSync('siteP').appfolderid
  160. let url = `${getApp().globalData.http.baseUrl}/yosweb/#/printTable?token=${token}&parentid=${parentid}&ownerid=${this.data.mainData.sa_workorder_confirmationid}${active==true?'&action=1':''}`
  161. this.setData({
  162. url: url
  163. })
  164. wx.navigateTo({
  165. url: '/Eservice/webView/index',
  166. })
  167. },
  168. /* 查看单据 */
  169. checkImage() {
  170. let attinfos = this.data.mainData.attinfos.map(v => v.usetype);
  171. let index = attinfos.lastIndexOf("comfirmbill");
  172. //没有查询到有效单据 跳转生成
  173. if (index == -1) return this.createImage(true);
  174. wx.previewImage({
  175. urls: [this.data.mainData.attinfos[index].url],
  176. })
  177. },
  178. /**
  179. * 生命周期函数--监听页面加载
  180. */
  181. onLoad(options) {
  182. this.data.bindSignNameData.ownerid = options.id
  183. this.setData({
  184. id: options.id,
  185. bindSignNameData: this.data.bindSignNameData
  186. })
  187. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  188. },
  189. onShow() {
  190. this.setData({
  191. SignName: true
  192. })
  193. this.billData()
  194. },
  195. onHide() {
  196. this.setData({
  197. SignName: false
  198. })
  199. },
  200. })