routerView.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="blacklog-container">
  3. <!-- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" @clickLeft="back">
  4. </uni-nav-bar> -->
  5. <!-- <div style="height: 88rpx;width: 100%;"></div> -->
  6. <web-view style="margin-top: 88rpx;" :src="webViewUrl" ref="webViewRef" @message="getMessage"></web-view>
  7. <fileMain ref="fileMainRef" @getFiles="getFiles"></fileMain>
  8. </view>
  9. </template>
  10. <script>
  11. import Vue from "vue";
  12. import {
  13. getParentIdListByDeptId
  14. } from '@/api/common.js'
  15. import fileMain from '@/pages/doc/docList.vue';
  16. export default {
  17. components: {
  18. fileMain
  19. },
  20. data() {
  21. return {
  22. isShow: false,
  23. webViewUrl: '',
  24. title: '申请',
  25. selectFilesField: null // 记录需要更新哪个字段
  26. }
  27. },
  28. methods: {
  29. getMessage(event) {
  30. let data = event.detail.data
  31. console.log(data, 'dsdsd')
  32. if (data[0].type == 'selectWork') {
  33. uni.navigateTo({
  34. url: `/pages/salesServiceManagement/accessory/components/selectWork?isPieCar=1`
  35. })
  36. } else if (data[0].type == 'selectFiles') {
  37. this.selectFilesField = data[0].field // 保存字段名
  38. console.log(this.selectFilesField, data[0].isEdit, 'this.selectFilesField')
  39. uni.navigateTo({
  40. url: `/pages/home/wt/components/formParser/filesChoose/index?isEdit=${data[0].isEdit}&files=${encodeURIComponent(JSON.stringify(data[0].files || []))}`,
  41. })
  42. }
  43. },
  44. // 接收选中文件后的回调
  45. selectedFilesCallback(fileIds) {
  46. console.log('选中的文件ID:', fileIds)
  47. // 通知 webview 更新表单数据
  48. this.$nextTick(() => {
  49. let webView = this.$scope.$getAppWebview()
  50. if (webView) {
  51. webView.children()[0].evalJS(`window.x_selectFiles('${JSON.stringify({
  52. field: this.selectFilesField,
  53. files: fileIds
  54. })}')`)
  55. }
  56. })
  57. },
  58. getFiles(val = []) {
  59. console.log(val, 'val')
  60. }
  61. },
  62. mounted() {
  63. uni.$off('updateWorkData')
  64. uni.$on('updateWorkData', ({
  65. data
  66. }) => {
  67. this.$nextTick(() => {
  68. console.log(this.$scope.$getAppWebview(), 'this.$refs.webViewRef')
  69. let webView = this.$scope.$getAppWebview()
  70. if (webView) {
  71. webView.children()[0].evalJS(`window.x_sun('${
  72. JSON.stringify({
  73. id: data.id, // 列表工单ID
  74. code: data.code, // 列表工单编号(要显示的code)
  75. name: data.planName // 列表工单名称(可选,根据弹窗需求传递)
  76. })
  77. }')`)
  78. }
  79. })
  80. })
  81. // 监听文件选择结果
  82. uni.$off('selectFilesResult')
  83. uni.$on('selectFilesResult', (res) => {
  84. console.log('收到文件选择结果:', res)
  85. // 通知 webview 更新表单数据
  86. this.$nextTick(() => {
  87. let webView = this.$scope.$getAppWebview()
  88. if (webView) {
  89. webView.children()[0].evalJS(`window.x_selectFiles('${JSON.stringify({
  90. field: this.selectFilesField,
  91. files: res.files
  92. })}')`)
  93. }
  94. })
  95. })
  96. },
  97. async onLoad(option = {}) {
  98. let headers = {};
  99. const value = uni.getStorageSync("token"); //取存本地的token
  100. // const apiInfo = uni.getStorageSync("apiInfo"); //取存本地的token
  101. console.log(Vue.prototype.apiUrl, 'apiInfo')
  102. headers = {
  103. "content-type": "application/json",
  104. "zoomwin-token": value,
  105. Authorization: value,
  106. "zoomwin-sid": uni.getStorageSync("userInfo").sessionId,
  107. serverInfo: Vue.prototype.apiUrl || '',
  108. };
  109. //http://192.168.1.105:18086
  110. let params = JSON.parse(option.params)
  111. let userInfo = uni.getStorageSync("userInfo")
  112. params.userInfo = {
  113. userId: userInfo.userId,
  114. groupId: userInfo.groupId
  115. }
  116. let html = params.type == 'add' ? 'a.html' : 'c.html'
  117. this.title = params.type == 'add' ? '申请' : '审批'
  118. try {
  119. params.userInfo.groupIdList = await getParentIdListByDeptId(params.userInfo.groupId)
  120. } catch {
  121. params.userInfo.groupIdList = []
  122. }
  123. console.log(params)
  124. setTimeout(() => {
  125. this.webViewUrl =
  126. `/hybrid/html/${html}?params=${JSON.stringify(params)}&headers=${JSON.stringify(headers)}`
  127. this.isShow = true
  128. })
  129. },
  130. }
  131. </script>
  132. <style>
  133. </style>