a.html 7.7 KB

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