a.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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="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.valueJson" ref="generateForm"
  22. :edit='isEdit'>
  23. </fm-generate-vant-form>
  24. <div>
  25. <!-- <van-form>
  26. <van-cell-group inset>
  27. <van-field type="textarea" v-model="form.reason" label="意见" placeholder="" rows="2" autosize
  28. show-word-limit />
  29. </van-cell-group>
  30. </van-form> -->
  31. <div
  32. style="display: flex;justify-content: space-between; padding: 30px 30px; position: fixed; bottom: 0; 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="onClickLeft">取消
  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. title: '',
  57. jsonData: {},
  58. editData: {},
  59. form: {},
  60. headers: {},
  61. }
  62. },
  63. created() {
  64. this.headers = this.getQueryParams('headers');
  65. let params = this.getQueryParams('params');
  66. const APIUrl = this.headers.serverInfo
  67. axios({
  68. method: 'get',
  69. url: APIUrl + `/flowable/bpmcustomform/getById/${params.id}`,
  70. headers: this.headers,
  71. }).then((res) => {
  72. if (res.data.code != '-1') {
  73. this.form = res.data.data
  74. this.title = this.form.name
  75. this.jsonData = JSON.parse(res.data.data.formJson.makingJson);
  76. this.jsonData.list.forEach(item => {
  77. item.options.headers = [{
  78. key: 'Authorization',
  79. value: this.headers.Authorization
  80. }]
  81. item.options.action = item.options.action && item.options.action.replace(
  82. '/api', APIUrl)
  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. })
  93. this.jsonData.config.dataSource && this.jsonData.config.dataSource.forEach(item => {
  94. item.headers = {
  95. Authorization: this.headers.Authorization
  96. }
  97. item.url = item.url && item.url.replace('/api', APIUrl)
  98. })
  99. this.isFlag = true
  100. }
  101. });
  102. axios({
  103. method: 'get',
  104. url: APIUrl + `/bpm/task/list-by-process-instance-id?processInstanceId=${params.id}`,
  105. headers: this.headers,
  106. }).then((res) => {
  107. console.log(res)
  108. if (res.data.code != '-1') {
  109. }
  110. });
  111. },
  112. methods: {
  113. getQueryParams(queryName) {
  114. const urlSearchParams = new URLSearchParams(window.location.search);
  115. const query = urlSearchParams.get(queryName);
  116. return JSON.parse(query);
  117. },
  118. generateFormValid(validate = true) {
  119. return this.$refs.generateForm.getData(validate).then((data) => {
  120. return data;
  121. });
  122. },
  123. async handleAudit(status) {
  124. this.form.valueJson = await this.generateFormValid();
  125. console.log(this.form.valueJson)
  126. this.form.processType = '1';
  127. let API = APIUrl + '/bpm/process-instance/create'
  128. axios({
  129. method: 'post',
  130. url: API,
  131. headers: this.headers,
  132. data: {
  133. ...this.form,
  134. }
  135. }).then((res) => {
  136. if (res.data.code != '-1') {
  137. vant.showNotify({
  138. type: 'success',
  139. message: `提交成功!`,
  140. duration: 1000,
  141. });
  142. setTimeout(() => {
  143. this.onClickLeft()
  144. }, 1000)
  145. }
  146. });
  147. },
  148. onClickLeft() {
  149. uni.navigateBack({
  150. delta: 1
  151. });
  152. }
  153. }
  154. }).use(vant).use(FormMakingV3).mount('#app')
  155. </script>
  156. </body>
  157. </html>