c.html 6.2 KB

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