a.html 5.4 KB

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