index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. console.log(this.data.form,'---')
  32. this.data.form = Object.assign({},this.data.form,data.detail)
  33. console.log(this.data.form)
  34. const res = await api._post({
  35. "id": "20230206091403",
  36. "version":1,
  37. "content": this.data.form
  38. })
  39. const rs = await api._post({
  40. "classname": "system.attachment.Attachment",
  41. "method": "createFileLink",
  42. "content": {
  43. "ownertable": "sa_serviceorder",
  44. "ownerid": res.data.sa_serviceorderid,
  45. "usetype": "附件",
  46. "attachmentids": data.detail.attachmentids
  47. }
  48. })
  49. if (res.code === 0) return wx.showToast({
  50. title: res.msg,
  51. duration: 3000,
  52. icon: 'none',
  53. })
  54. wx.navigateBack({
  55. delta:0
  56. })
  57. },
  58. /**
  59. * 生命周期函数--监听页面加载
  60. */
  61. onLoad(options) {
  62. let that = this
  63. let obj = getApp().globalData.handelSelect.data.orderMainData
  64. that.data.form = Object.assign({},this.data.form,obj)
  65. Object.keys(that.data.form).map((key,index)=>{
  66. that.data.data.formLayout.formInfo.forEach(e=>{
  67. if (e.id === key) {
  68. e.inputValue = obj[key]
  69. }
  70. if (e.id === 'provinceArr') {
  71. e.inputValue = `${obj.province},${obj.city},${obj.county}`
  72. }
  73. })
  74. })
  75. that.setData({
  76. data:that.data.data
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady() {
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide() {
  93. this.compData = this.selectComponent("#form")
  94. // this.compData.setObjectData(this.compData.data.formLayoutData.formInfo)
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload() {
  100. getApp().globalData.pageData = null
  101. },
  102. /**
  103. * 页面相关事件处理函数--监听用户下拉动作
  104. */
  105. onPullDownRefresh() {
  106. },
  107. /**
  108. * 页面上拉触底事件的处理函数
  109. */
  110. onReachBottom() {
  111. },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage() {
  116. }
  117. })