a.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. margin-bottom: 10px;
  21. }
  22. .blank_adopzrdd>span {
  23. display: inline-block;
  24. width: 80px;
  25. }
  26. :root#app{ background: #4298fd0d;
  27. }
  28. ::v-deep.fm-form-item{ margin-bottom:10px !important;
  29. }
  30. </style>
  31. <div id="app">
  32. <van-nav-bar height='100rpx;margin-top:100rpx' @click-left="onClickLeft"
  33. style="background-color: rgb(21, 122, 44);color: rgb(255, 255, 255);" :title="title" left-arrow
  34. :safe-area-inset-top='true' :placeholder='true' :fixed='true'></van-nav-bar>
  35. <fm-generate-vant-form style='height: 81vh !important;overflow: auto;background: #a3a6ad1c;margin-top:44px'
  36. v-if='isFlag' :data="jsonData" :value="form.valueJson" ref="generateForm" :edit='isEdit'>
  37. <template v-slot:blank_adopzrdd="scope">
  38. <div style="width: 100%;">
  39. <van-button type="primary" size="small" @click="addNewRow('blank_adopzrdd')"
  40. style="margin-bottom: 10px">添加报销事项</van-button>
  41. <div v-for="(item, index) in scope.model.blank_adopzrdd" :key="index" style="width: 100%;">
  42. <div class="blank_adopzrdd">
  43. <span>{{ index + 1 }}报销事项:</span>
  44. <van-field rows="1" v-model="scope.model.blank_adopzrdd[index].remark" type="textarea" autosize
  45. style="width: calc(100% - 80px)"></van-field>
  46. </div>
  47. <div class="blank_adopzrdd">
  48. <span>
  49. <van-icon @click="delNewRow('blank_adopzrdd', index)" name="delete"
  50. style="color: #f56c6c;"></van-icon>
  51. 金额:</span>
  52. <van-field v-model="scope.model.blank_adopzrdd[index].price" type="number"
  53. style="width: calc(100% - 80px)"
  54. @change="changePrice(scope.model.blank_adopzrdd)"></van-field>
  55. </div>
  56. </div>
  57. </div>
  58. </template>
  59. </fm-generate-vant-form>
  60. <div>
  61. <!-- <van-form>
  62. <van-cell-group inset>
  63. <van-field type="textarea" v-model="form.reason" label="意见" placeholder="" rows="2" autosize
  64. show-word-limit />
  65. </van-cell-group>
  66. </van-form> -->
  67. <div v-if='isEdit'
  68. style="display: flex;justify-content: space-between; padding: 30px 30px; position: fixed; bottom: 0; width: 100%; height: 80px;">
  69. <van-button style="width:48%" type="primary" @click="handleAudit(1)">提交
  70. </van-button>
  71. <van-button style="width:48%" type="danger" @click="onClickLeft">取消
  72. </van-button>
  73. </div>
  74. </div>
  75. </div>
  76. <script src="./resource/vue.global.prod.js"></script>
  77. <script src="./resource/vant.min.js"></script>
  78. <script src="./resource/axios.min.js"></script>
  79. <script src="./resource/uni.webview.js"></script>
  80. <script src="./vue-form-making/form-making-v3.umd.js"></script>
  81. <script>
  82. let EnvObj = {}
  83. uni.getEnv(function(res) {
  84. EnvObj = res;
  85. console.log('当前环境:' + JSON.stringify(res));
  86. });
  87. Vue.createApp({
  88. data() {
  89. return {
  90. isFlag: false,
  91. isEdit: true,
  92. title: '',
  93. jsonData: {},
  94. editData: {},
  95. form: {},
  96. headers: {},
  97. APIUrl: '',
  98. }
  99. },
  100. created() {
  101. this.headers = this.getQueryParams('headers');
  102. let params = this.getQueryParams('params');
  103. this.isEdit = params.isEdit || true
  104. this.APIUrl = this.headers.serverInfo || 'http://192.168.1.105:18086'
  105. console.log(params)
  106. axios({
  107. method: 'get',
  108. url: this.APIUrl + `/flowable/bpmcustomform/getById/${params.id}`,
  109. headers: this.headers,
  110. }).then((res) => {
  111. if (res.data.code != '-1') {
  112. this.form = res.data.data
  113. this.form.formId = res.data.data.id
  114. this.form.id = ''
  115. this.form.valueJson = {}
  116. this.title = this.form.name
  117. this.jsonData = JSON.parse(res.data.data.formJson.makingJson);
  118. this.jsonData.list.forEach(item => {
  119. item.options.headers = [{
  120. key: 'Authorization',
  121. value: this.headers.Authorization
  122. }]
  123. item.options.action = item.options.action && item.options.action.replace(
  124. '/api', this.APIUrl)
  125. if (item.type == "deptAndUserCascader") {
  126. item.type = 'cascader'
  127. }
  128. if (item.type == "deptCascader") {
  129. item.type = 'cascader'
  130. /* item.isPathValue = false */
  131. if (item.options.isDefaultLoginUser) {
  132. /* this.form.valueJson[item.model] = [1,1765997946953797633]; */
  133. this.form.valueJson[item.model] = params.userInfo.groupIdList;
  134. }
  135. }
  136. if (item.type == "userSelect") {
  137. item.type = 'select'
  138. if (item.options.isDefaultLoginUser) {
  139. this.form.valueJson[item.model] = params.userInfo.userId;
  140. }
  141. }
  142. })
  143. this.jsonData.config.dataSource && this.jsonData.config.dataSource.forEach(item => {
  144. item.headers = {
  145. Authorization: this.headers.Authorization
  146. }
  147. item.url = item.url && item.url.replace('/api', this.APIUrl)
  148. })
  149. this.isFlag = true
  150. }
  151. });
  152. // axios({
  153. // method: 'get',
  154. // url: this.APIUrl + `/bpm/task/list-by-process-instance-id?processInstanceId=${params.id}`,
  155. // headers: this.headers,
  156. // }).then((res) => {
  157. // console.log(res)
  158. // if (res.data.code != '-1') {
  159. // }
  160. // });
  161. },
  162. methods: {
  163. async addNewRow(key) {
  164. console.log(key);
  165. let data = await this.$refs.generateForm.getData(false);
  166. data[key].push({
  167. price: '',
  168. remark: ''
  169. });
  170. this.$refs.generateForm.setData({
  171. key: data[key]
  172. });
  173. },
  174. async delNewRow(key, index) {
  175. let data = await this.$refs.generateForm.getData(false);
  176. data[key] = data[key].filter((item, index1) => index1 != index);
  177. this.$refs.generateForm.setData({
  178. [key]: data[key]
  179. });
  180. this.changePrice(data[key]);
  181. },
  182. changePrice(data) {
  183. let num = 0;
  184. data.forEach((item) => {
  185. num += Number(item.price);
  186. });
  187. this.$refs.generateForm.setData({
  188. input_jd9ouzyh: num
  189. });
  190. },
  191. getQueryParams(queryName) {
  192. const urlSearchParams = new URLSearchParams(window.location.search);
  193. const query = urlSearchParams.get(queryName);
  194. console.log(query,'query')
  195. return JSON.parse(query);
  196. },
  197. generateFormValid(validate = true) {
  198. return this.$refs.generateForm.getData(validate).then((data) => { //清空content
  199. for (key in data) {
  200. if (key.includes('fileupload')) {
  201. data[key].forEach(item => {
  202. item['content'] = ''
  203. })
  204. }
  205. }
  206. return data;
  207. });
  208. },
  209. async handleAudit(status) {
  210. this.form.valueJson = await this.generateFormValid();
  211. console.log(this.form.valueJson)
  212. this.form.processType = '1';
  213. let API = this.APIUrl + '/bpm/process-instance/create'
  214. axios({
  215. method: 'post',
  216. url: API,
  217. headers: this.headers,
  218. data: {
  219. ...this.form,
  220. }
  221. }).then((res) => {
  222. if (res.data.code != '-1') {
  223. vant.showNotify({
  224. type: 'success',
  225. message: `提交成功!`,
  226. duration: 1000,
  227. });
  228. setTimeout(() => {
  229. this.onClickLeft()
  230. }, 1000)
  231. }
  232. });
  233. },
  234. onClickLeft() {
  235. uni.navigateBack({
  236. delta: 1
  237. });
  238. }
  239. }
  240. }).use(vant).use(FormMakingV3).mount('#app')
  241. </script>
  242. </body>
  243. </html>