c.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 height='100rpx' @click-left="onClickLeft" style="background-color: rgb(21, 122, 44);color: rgb(255, 255, 255);"
  20. :title="title" left-arrow :safe-area-inset-top='true' :placeholder='true' :fixed='true'></van-nav-bar>
  21. <fm-generate-vant-form style='height: 75vh !important;overflow: auto;' v-if='isFlag' :data="jsonData" :value="form.valueJson" ref="generateForm" :edit='false'>
  22. </fm-generate-vant-form>
  23. <div v-if="type!='view'" style='position: fixed; bottom: 0;background: #f9fafb;width:100%;height:20%'>
  24. <van-form label-width='30px'>
  25. <van-cell-group inset>
  26. <van-field style="background: #f9fafb;" type="textarea" v-model="form.reason" label="意见" placeholder="" rows="2" :autosize='{maxHeight: 50}'
  27. show-word-limit />
  28. </van-cell-group>
  29. </van-form>
  30. <div
  31. style="display: flex;justify-content: space-between; padding: 0px 30px; 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. type:'',
  56. jsonData: {},
  57. editData: {},
  58. form: {},
  59. headers: {},
  60. APIUrl: '',
  61. title: '',
  62. }
  63. },
  64. created() {
  65. this.headers = this.getQueryParams('headers');
  66. let params = this.getQueryParams('params');
  67. this.APIUrl = this.headers.serverInfo || 'http://192.168.1.105:80/api'
  68. this.title = params.type =='view'?'查看':'审核'
  69. this.type = params.type
  70. axios({
  71. method: 'get',
  72. url: this.APIUrl + `/bpm/process-instance/get?id=${params.processInstanceId}`,
  73. headers: this.headers,
  74. }).then((res) => {
  75. console.log(res)
  76. if (res.data.code != '-1') {
  77. this.form = res.data.data
  78. this.form.submitId = params.id
  79. this.jsonData = JSON.parse(res.data.data.formJson.makingJson);
  80. this.jsonData.list.forEach(item=>{
  81. item.options.headers = [{key:'Authorization',value:this.headers.Authorization}]
  82. if(item.type=="deptAndUserCascader"){
  83. item.type = 'cascader'
  84. }
  85. if(item.type=="deptCascader"){
  86. item.type = 'cascader'
  87. }
  88. if(item.type=="userSelect"){
  89. item.type = 'select'
  90. }
  91. if (item.type == "imgupload") {
  92. this.form.valueJson[item.model].length && this.form.valueJson[item.model].forEach(
  93. item => {
  94. //item.objectUrl = this.APIUrl +'/kd-aiot' + item.storePath
  95. item.objectUrl = item.url
  96. })
  97. }
  98. })
  99. this.jsonData.config.dataSource && this.jsonData.config.dataSource.forEach(item => {
  100. item.headers = {
  101. Authorization: this.headers.Authorization
  102. }
  103. item.url = item.url && item.url.replace('/api', this.APIUrl)
  104. })
  105. this.isFlag = true
  106. }
  107. });
  108. },
  109. methods: {
  110. getQueryParams(queryName) {
  111. const urlSearchParams = new URLSearchParams(window.location.search);
  112. const query = urlSearchParams.get(queryName);
  113. return JSON.parse(query);
  114. },
  115. async handleAudit(status) {
  116. await this._approveTaskWithVariables(status);
  117. },
  118. async _approveTaskWithVariables(status) {
  119. let variables = {
  120. pass: !!status,
  121. ...this.form.formVariables
  122. };
  123. if (!this.form.reason) this.form.reason = !!status ? '通过' : '驳回'
  124. let API = !!status ? this.APIUrl + '/bpm/task/approveTaskWithVariables' :
  125. this.APIUrl + '/bpm/task/reject'
  126. axios({
  127. method: 'put',
  128. url: API,
  129. headers: this.headers,
  130. data: {
  131. id: this.form.submitId,
  132. reason: this.form.reason,
  133. variables
  134. }
  135. }).then((res) => {
  136. if (res.data.code != '-1') {
  137. let params = {
  138. status,
  139. title: status === 0 ? '驳回' : ''
  140. }
  141. vant.showNotify({
  142. type: 'success',
  143. message: `审批${params.title}成功!`,
  144. duration: 1000,
  145. });
  146. setTimeout(() => {
  147. this.onClickLeft()
  148. }, 1000)
  149. }
  150. });
  151. },
  152. onClickLeft() {
  153. uni.navigateBack({
  154. delta: 1
  155. });
  156. }
  157. }
  158. }).use(vant).use(FormMakingV3).mount('#app')
  159. </script>
  160. </body>
  161. </html>