a.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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 {
  27. background: #4298fd0d;
  28. }
  29. ::v-deep.fm-form-item {
  30. margin-bottom: 10px !important;
  31. }
  32. </style>
  33. <div id="app">
  34. <van-nav-bar height='100rpx;margin-top:100rpx' @click-left="onClickLeft"
  35. style="background-color: rgb(21, 122, 44);color: rgb(255, 255, 255);" :title="title" left-arrow
  36. :safe-area-inset-top='true' :placeholder='true' :fixed='true'></van-nav-bar>
  37. <fm-generate-vant-form style='height: 81vh !important;overflow: auto;background: #a3a6ad1c;margin-top:44px'
  38. v-if='isFlag' :data="jsonData" :value="form.valueJson" ref="generateForm" :edit='isEdit'>
  39. <template v-slot:blank_adopzrdd="scope">
  40. <div style="width: 100%;">
  41. <van-button type="primary" size="small" @click="addNewRow('blank_adopzrdd')"
  42. style="margin-bottom: 10px">添加报销事项</van-button>
  43. <div v-for="(item, index) in scope.model.blank_adopzrdd" :key="index" style="width: 100%;">
  44. <div class="blank_adopzrdd">
  45. <span>{{ index + 1 }}报销事项:</span>
  46. <van-field rows="1" v-model="scope.model.blank_adopzrdd[index].remark" type="textarea"
  47. autosize style="width: calc(100% - 80px)"></van-field>
  48. </div>
  49. <div class="blank_adopzrdd">
  50. <span>
  51. <van-icon @click="delNewRow('blank_adopzrdd', index)" name="delete"
  52. style="color: #f56c6c;"></van-icon>
  53. 金额:</span>
  54. <van-field v-model="scope.model.blank_adopzrdd[index].price" type="number"
  55. style="width: calc(100% - 80px)"
  56. @change="changePrice(scope.model.blank_adopzrdd)"></van-field>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <template v-slot:manage_workorder="scope">
  62. <van-field v-model="scope.model.manage_workorder.code" readonly @click="addWorkOrder()"></van-field>
  63. </template>
  64. </fm-generate-vant-form>
  65. <div>
  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. let _this = this
  101. window.x_sun = (e) => {
  102. _this.setSalesServiceWork(JSON.parse(e))
  103. }
  104. this.headers = this.getQueryParams('headers');
  105. let params = this.getQueryParams('params');
  106. this.isEdit = params.isEdit || true
  107. this.APIUrl = this.headers.serverInfo || 'http://192.168.1.105:18086'
  108. axios({
  109. method: 'get',
  110. url: this.APIUrl + `/flowable/bpmcustomform/getById/${params.id}`,
  111. headers: this.headers,
  112. }).then((res) => {
  113. if (res.data.code != '-1') {
  114. this.form = res.data.data
  115. this.form.formId = res.data.data.id
  116. this.form.id = ''
  117. this.form.valueJson = {}
  118. this.title = this.form.name
  119. this.jsonData = JSON.parse(res.data.data.formJson.makingJson);
  120. this.jsonData.list.forEach(item => {
  121. item.options.headers = [{
  122. key: 'Authorization',
  123. value: this.headers.Authorization
  124. }]
  125. item.options.action = item.options.action && item.options.action.replace(
  126. '/api', this.APIUrl)
  127. if (item.type == "deptAndUserCascader") {
  128. item.type = 'cascader'
  129. }
  130. if (item.type == "deptCascader") {
  131. item.type = 'cascader'
  132. /* item.isPathValue = false */
  133. if (item.options.isDefaultLoginUser) {
  134. /* this.form.valueJson[item.model] = [1,1765997946953797633]; */
  135. this.form.valueJson[item.model] = params.userInfo.groupIdList;
  136. }
  137. }
  138. if (item.type == "userSelect") {
  139. item.type = 'select'
  140. if (item.options.isDefaultLoginUser) {
  141. this.form.valueJson[item.model] = params.userInfo.userId;
  142. }
  143. }
  144. })
  145. this.jsonData.config.dataSource && this.jsonData.config.dataSource.forEach(item => {
  146. item.headers = {
  147. Authorization: this.headers.Authorization
  148. }
  149. item.url = item.url && item.url.replace('/api', this.APIUrl)
  150. })
  151. this.isFlag = true
  152. this.$nextTick(() => {
  153. if (params.manage_workorder) {
  154. this.setSalesServiceWork(params.manage_workorder)
  155. }
  156. })
  157. }
  158. });
  159. // axios({
  160. // method: 'get',
  161. // url: this.APIUrl + `/bpm/task/list-by-process-instance-id?processInstanceId=${params.id}`,
  162. // headers: this.headers,
  163. // }).then((res) => {
  164. // console.log(res)
  165. // if (res.data.code != '-1') {
  166. // }
  167. // });
  168. },
  169. methods: {
  170. addWorkOrder() {
  171. uni.postMessage({
  172. data: {
  173. type: 'selectWork',
  174. }
  175. });
  176. },
  177. async addNewRow(key) {
  178. console.log(key);
  179. let data = await this.$refs.generateForm.getData(false);
  180. data[key].push({
  181. price: '',
  182. remark: ''
  183. });
  184. this.$refs.generateForm.setData({
  185. key: data[key]
  186. });
  187. },
  188. async delNewRow(key, index) {
  189. let data = await this.$refs.generateForm.getData(false);
  190. data[key] = data[key].filter((item, index1) => index1 != index);
  191. this.$refs.generateForm.setData({
  192. [key]: data[key]
  193. });
  194. this.changePrice(data[key]);
  195. },
  196. changePrice(data) {
  197. let num = 0;
  198. data.forEach((item) => {
  199. num += Number(item.price);
  200. });
  201. this.$refs.generateForm.setData({
  202. input_jd9ouzyh: num
  203. });
  204. },
  205. setSalesServiceWork(data) {
  206. this.$refs.generateForm.setData({
  207. manage_workorder: data
  208. });
  209. this.$refs.generateForm.setRules('manage_workorder', [{
  210. required: false,
  211. message: '必须填写'
  212. }])
  213. setTimeout(() => {
  214. this.$refs.generateForm.validate(['manage_workorder'])
  215. })
  216. },
  217. getQueryParams(queryName) {
  218. const urlSearchParams = new URLSearchParams(window.location.search);
  219. const query = urlSearchParams.get(queryName);
  220. console.log(query, 'query')
  221. return JSON.parse(query);
  222. },
  223. generateFormValid(validate = true) {
  224. return this.$refs.generateForm.getData(validate).then((data) => { //清空content
  225. for (key in data) {
  226. if (key.includes('fileupload')) {
  227. data[key].forEach(item => {
  228. item['content'] = ''
  229. })
  230. }
  231. }
  232. return data;
  233. });
  234. },
  235. async handleAudit(status) {
  236. this.form.valueJson = await this.generateFormValid();
  237. console.log(this.form.valueJson)
  238. this.form.processType = '1';
  239. let API = this.APIUrl + '/bpm/process-instance/create'
  240. axios({
  241. method: 'post',
  242. url: API,
  243. headers: this.headers,
  244. data: {
  245. ...this.form,
  246. }
  247. }).then((res) => {
  248. if (res.data.code != '-1') {
  249. vant.showNotify({
  250. type: 'success',
  251. message: `提交成功!`,
  252. duration: 1000,
  253. });
  254. setTimeout(() => {
  255. this.onClickLeft()
  256. }, 1000)
  257. }
  258. });
  259. },
  260. onClickLeft() {
  261. uni.navigateBack({
  262. delta: 1
  263. });
  264. }
  265. }
  266. }).use(vant).use(FormMakingV3).mount('#app')
  267. </script>
  268. </body>
  269. </html>