a.html 5.6 KB

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