c.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport"
  6. content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
  7. <link rel="stylesheet" href="./resource/vantIndex.css" />
  8. <link rel="stylesheet" href="./vue-form-making/index.css">
  9. </head>
  10. <body>
  11. <style>
  12. :root:root {
  13. --van-nav-bar-background: rgb(21, 122, 44);
  14. --van-nav-bar-title-text-color: rgb(255, 255, 255);
  15. --van-nav-bar-icon-color: rgb(255, 255, 255);
  16. }
  17. </style>
  18. <div id="app">
  19. <van-nav-bar @click-left="onClickLeft" style="background-color: rgb(21, 122, 44);color: rgb(255, 255, 255);"
  20. title="审核" left-arrow :safe-area-inset-top='true' :placeholder='true' :fixed='true'></van-nav-bar>
  21. <fm-generate-vant-form v-if='isFlag' :data="jsonData" :value="form.formVariables" ref="generateForm" :edit='false'>
  22. </fm-generate-vant-form>
  23. <div>
  24. <van-form>
  25. <van-cell-group inset>
  26. <van-field type="textarea" v-model="form.reason" label="意见" placeholder="" rows="2" autosize
  27. show-word-limit />
  28. </van-cell-group>
  29. </van-form>
  30. <div
  31. style="display: flex;justify-content: space-between; padding: 30px 30px; position: fixed; bottom: 0; width: 100%; height: 80px;">
  32. <van-button style="width:48%" type="primary" @click="handleAudit(1)">通过
  33. </van-button>
  34. <van-button style="width:48%" type="danger" @click="handleAudit(0)">驳回
  35. </van-button>
  36. </div>
  37. </div>
  38. </div>
  39. <script src="./resource/vue.global.prod.js"></script>
  40. <script src="./resource/vant.min.js"></script>
  41. <script src="./resource/axios.min.js"></script>
  42. <script src="./resource/uni.webview.js"></script>
  43. <script src="./vue-form-making/form-making-v3.umd.js"></script>
  44. <script>
  45. let EnvObj = {}
  46. uni.getEnv(function(res) {
  47. EnvObj = res;
  48. console.log('当前环境:' + JSON.stringify(res));
  49. });
  50. Vue.createApp({
  51. data() {
  52. return {
  53. isFlag:false,
  54. isEdit:true,
  55. jsonData: {},
  56. editData: {},
  57. form: {},
  58. headers: {},
  59. }
  60. },
  61. created() {
  62. this.headers = this.getQueryParams('headers');
  63. let params = this.getQueryParams('params');
  64. const APIUrl = this.headers.serverInfo
  65. console.log(APIUrl)
  66. axios({
  67. method: 'get',
  68. url: APIUrl + `/bpm/process-instance/get?id=${params.processInstanceId}`,
  69. headers: this.headers,
  70. }).then((res) => {
  71. console.log(res)
  72. if (res.data.code != '-1') {
  73. this.form = res.data.data
  74. this.form.submitId = params.id
  75. this.jsonData = JSON.parse(res.data.data.formJson.makingJson);
  76. this.jsonData.list.forEach(item=>{
  77. item.options.headers = [{key:'Authorization',value:this.headers.Authorization}]
  78. if(item.type=="deptAndUserCascader"){
  79. item.type = 'cascader'
  80. }
  81. if(item.type=="deptCascader"){
  82. item.type = 'cascader'
  83. }
  84. if(item.type=="userSelect"){
  85. item.type = 'select'
  86. }
  87. })
  88. this.jsonData.config.dataSource && this.jsonData.config.dataSource.forEach(item => {
  89. item.headers = {
  90. Authorization: this.headers.Authorization
  91. }
  92. item.url = item.url && item.url.replace('/api', APIUrl)
  93. })
  94. this.isFlag = true
  95. console.log(this.jsonData)
  96. }
  97. });
  98. },
  99. methods: {
  100. getQueryParams(queryName) {
  101. const urlSearchParams = new URLSearchParams(window.location.search);
  102. const query = urlSearchParams.get(queryName);
  103. return JSON.parse(query);
  104. },
  105. async handleAudit(status) {
  106. await this._approveTaskWithVariables(status);
  107. },
  108. async _approveTaskWithVariables(status) {
  109. let variables = {
  110. pass: !!status,
  111. ...this.form.formVariables
  112. };
  113. if (!this.form.reason) this.form.reason = !!status ? '通过' : '驳回'
  114. let API = !!status ? APIUrl + '/bpm/task/approveTaskWithVariables' :
  115. APIUrl + '/bpm/task/reject'
  116. axios({
  117. method: 'put',
  118. url: API,
  119. headers: this.headers,
  120. data: {
  121. id: this.form.submitId,
  122. reason: this.form.reason,
  123. variables
  124. }
  125. }).then((res) => {
  126. if (res.data.code != '-1') {
  127. let params = {
  128. status,
  129. title: status === 0 ? '驳回' : ''
  130. }
  131. vant.showNotify({
  132. type: 'success',
  133. message: `审批${params.title}成功!`,
  134. duration: 1000,
  135. });
  136. setTimeout(() => {
  137. this.onClickLeft()
  138. }, 1000)
  139. }
  140. });
  141. },
  142. onClickLeft() {
  143. uni.navigateBack({
  144. delta: 1
  145. });
  146. }
  147. }
  148. }).use(vant).use(FormMakingV3).mount('#app')
  149. </script>
  150. </body>
  151. </html>