index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // pages/agent/addServiceBill/index.js
  2. import api from '../../api/api'
  3. import data from './formData'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. data,
  10. form:{
  11. "sa_serviceorderid":0, //sa_brandid<=0时 为新增
  12. "servicetype":"0",
  13. "sa_orderid":0,
  14. "remarks":"",
  15. "class1":"",
  16. "class2":"",
  17. "reason":"",
  18. "province":"",
  19. "city":"",
  20. "county":"",
  21. "address":"",
  22. "scenecontact":"",
  23. "scenecontactrole":"",
  24. "scenecontactphonenumber":"",
  25. "billdate":"",
  26. "begdate":"",
  27. "enddate":""
  28. }
  29. },
  30. async onClick (data) {
  31. this.data.form = Object.assign({},this.data.form,data.detail)
  32. const res = await api._post({
  33. "id": "20230206091403",
  34. "version":1,
  35. "content": this.data.form
  36. })
  37. const rs = await api._post({
  38. "classname": "system.attachment.Attachment",
  39. "method": "createFileLink",
  40. "content": {
  41. "ownertable": "sa_serviceorder",
  42. "ownerid": res.data.sa_serviceorderid,
  43. "usetype": "附件",
  44. "attachmentids": data.detail.attachmentids
  45. }
  46. })
  47. if (res.code === 0) return wx.showToast({
  48. title: res.msg,
  49. duration: 3000,
  50. icon: 'none',
  51. })
  52. wx.navigateBack({
  53. delta:0
  54. })
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad(options) {
  60. let that = this
  61. let obj = getApp().globalData.handelSelect.data.orderMainData
  62. that.data.form = Object.assign({},this.data.form,obj)
  63. Object.keys(that.data.form).map((key,index)=>{
  64. // console.log(key)
  65. that.data.data.formLayout.formInfo.forEach(e=>{
  66. if (e.id === 'servicetype') {
  67. if (e.inputValue === '售前' || e.inputValue === '历史售后') {
  68. console.log(e)
  69. if (e.id === 'sa_orderid') {
  70. console.log(e)
  71. // e.force = false
  72. }
  73. }
  74. }
  75. if (e.id === key) {
  76. e.inputValue = obj[key]
  77. }
  78. if (e.id === 'provinceArr') {
  79. e.inputValue = `${obj.province},${obj.city},${obj.county}`
  80. }
  81. })
  82. })
  83. that.setData({
  84. data:that.data.data
  85. })
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow() {
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide() {
  101. this.compData = this.selectComponent("#form")
  102. // this.compData.setObjectData(this.compData.data.formLayoutData.formInfo)
  103. },
  104. /**
  105. * 生命周期函数--监听页面卸载
  106. */
  107. onUnload() {
  108. getApp().globalData.pageData = null
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh() {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom() {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage() {
  124. }
  125. })