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