a.html 5.3 KB

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