c.html 5.3 KB

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