index.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import api from '../../api/api'
  2. import data from './formData'
  3. Page({
  4. data: {
  5. data,
  6. form:{
  7. "sa_serviceorderid":0, //sa_brandid<=0时 为新增
  8. "servicetype":"0",
  9. "sa_orderid":0,
  10. "remarks":"",
  11. "class1":"",
  12. "class2":"",
  13. "reason":"",
  14. "province":"",
  15. "city":"",
  16. "county":"",
  17. "address":"",
  18. "scenecontact":"",
  19. "scenecontactrole":"",
  20. "scenecontactphonenumber":"",
  21. "billdate":"",
  22. "begdate":"",
  23. "enddate":""
  24. }
  25. },
  26. async onClick (data) {
  27. this.data.form = Object.assign({},this.data.form,data.detail)
  28. const res = await api._post({
  29. "id": "20230206091403",
  30. "version":1,
  31. "content": this.data.form
  32. })
  33. const rs = await api._post({
  34. "classname": "system.attachment.Attachment",
  35. "method": "createFileLink",
  36. "content": {
  37. "ownertable": "sa_serviceorder",
  38. "ownerid": res.data.sa_serviceorderid,
  39. "usetype": "附件",
  40. "attachmentids": data.detail.attachmentids
  41. }
  42. })
  43. if (res.code === 0) return wx.showToast({
  44. title: res.msg,
  45. duration: 3000,
  46. icon: 'none',
  47. })
  48. wx.navigateBack({
  49. delta:0
  50. })
  51. },
  52. onLoad(options) {
  53. let that = this
  54. let obj = getApp().globalData.handelSelect.data.orderMainData
  55. that.data.form = Object.assign({},this.data.form,obj)
  56. Object.keys(that.data.form).map((key,index)=>{
  57. // console.log(key)
  58. that.data.data.formLayout.formInfo.forEach(e=>{
  59. if (e.id === 'servicetype') {
  60. if (e.inputValue === '售前' || e.inputValue === '历史售后') {
  61. console.log(e)
  62. if (e.id === 'sa_orderid') {
  63. console.log(e)
  64. // e.force = false
  65. }
  66. }
  67. }
  68. if (e.id === key) {
  69. e.inputValue = obj[key]
  70. }
  71. if (e.id === 'provinceArr') {
  72. e.inputValue = `${obj.province},${obj.city},${obj.county}`
  73. }
  74. })
  75. })
  76. that.setData({
  77. data:that.data.data
  78. })
  79. },
  80. onHide() {
  81. this.compData = this.selectComponent("#form")
  82. // this.compData.setObjectData(this.compData.data.formLayoutData.formInfo)
  83. },
  84. onUnload() {
  85. getApp().globalData.pageData = null
  86. },
  87. })