a.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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" :loading="loading" @click="handleAudit(1)">提交
  69. </van-button>
  70. <van-button style="width:48%" type="danger" :loading="loading" @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. loading: false,
  90. isFlag: false,
  91. isEdit: true,
  92. title: '',
  93. jsonData: {},
  94. editData: {},
  95. form: {},
  96. headers: {},
  97. APIUrl: '',
  98. }
  99. },
  100. created() {
  101. let _this = this
  102. window.x_sun = (e) => {
  103. _this.setSalesServiceWork(JSON.parse(e))
  104. }
  105. this.headers = this.getQueryParams('headers');
  106. let params = this.getQueryParams('params');
  107. this.isEdit = params.isEdit || true
  108. this.APIUrl = this.headers.serverInfo || 'http://192.168.1.105:18086'
  109. axios({
  110. method: 'get',
  111. url: this.APIUrl + `/flowable/bpmcustomform/getById/${params.id}`,
  112. headers: this.headers,
  113. }).then((res) => {
  114. if (res.data.code != '-1') {
  115. this.form = res.data.data
  116. this.form.formId = res.data.data.id
  117. this.form.id = ''
  118. this.form.valueJson = {}
  119. this.title = this.form.name
  120. this.jsonData = JSON.parse(res.data.data.formJson.makingJson);
  121. this.jsonData.list.forEach(item => {
  122. item.options.headers = [{
  123. key: 'Authorization',
  124. value: this.headers.Authorization
  125. }]
  126. item.options.action = item.options.action && item.options.action.replace(
  127. '/api', this.APIUrl)
  128. if (item.type == "deptAndUserCascader") {
  129. item.type = 'cascader'
  130. }
  131. if (item.type == "deptCascader") {
  132. item.type = 'cascader'
  133. /* item.isPathValue = false */
  134. if (item.options.isDefaultLoginUser) {
  135. /* this.form.valueJson[item.model] = [1,1765997946953797633]; */
  136. this.form.valueJson[item.model] = params.userInfo.groupIdList;
  137. }
  138. }
  139. if (item.type == "userSelect") {
  140. item.type = 'select'
  141. if (item.options.isDefaultLoginUser) {
  142. this.form.valueJson[item.model] = params.userInfo.userId;
  143. }
  144. }
  145. })
  146. this.jsonData.config.dataSource && this.jsonData.config.dataSource.forEach(item => {
  147. item.headers = {
  148. Authorization: this.headers.Authorization
  149. }
  150. item.url = item.url && item.url.replace('/api', this.APIUrl)
  151. })
  152. this.isFlag = true
  153. this.$nextTick(() => {
  154. if (params.manage_workorder) {
  155. this.setSalesServiceWork(params.manage_workorder)
  156. }
  157. })
  158. }
  159. });
  160. // axios({
  161. // method: 'get',
  162. // url: this.APIUrl + `/bpm/task/list-by-process-instance-id?processInstanceId=${params.id}`,
  163. // headers: this.headers,
  164. // }).then((res) => {
  165. // console.log(res)
  166. // if (res.data.code != '-1') {
  167. // }
  168. // });
  169. },
  170. methods: {
  171. addWorkOrder() {
  172. uni.postMessage({
  173. data: {
  174. type: 'selectWork',
  175. }
  176. });
  177. },
  178. async addNewRow(key) {
  179. console.log(key);
  180. let data = await this.$refs.generateForm.getData(false);
  181. data[key].push({
  182. price: '',
  183. remark: ''
  184. });
  185. this.$refs.generateForm.setData({
  186. key: data[key]
  187. });
  188. },
  189. async delNewRow(key, index) {
  190. let data = await this.$refs.generateForm.getData(false);
  191. data[key] = data[key].filter((item, index1) => index1 != index);
  192. this.$refs.generateForm.setData({
  193. [key]: data[key]
  194. });
  195. this.changePrice(data[key]);
  196. },
  197. changePrice(data) {
  198. let num = 0;
  199. data.forEach((item) => {
  200. num += Number(item.price);
  201. });
  202. this.$refs.generateForm.setData({
  203. input_jd9ouzyh: num
  204. });
  205. },
  206. setSalesServiceWork(data) {
  207. this.$refs.generateForm.setData({
  208. manage_workorder: data
  209. });
  210. this.$refs.generateForm.setRules('manage_workorder', [{
  211. required: false,
  212. message: '必须填写'
  213. }])
  214. setTimeout(() => {
  215. this.$refs.generateForm.validate(['manage_workorder'])
  216. })
  217. },
  218. getQueryParams(queryName) {
  219. const urlSearchParams = new URLSearchParams(window.location.search);
  220. const query = urlSearchParams.get(queryName);
  221. console.log(query, 'query')
  222. return JSON.parse(query);
  223. },
  224. generateFormValid(validate = true) {
  225. return this.$refs.generateForm.getData(validate).then((data) => { //清空content
  226. for (key in data) {
  227. if (key.includes('fileupload')) {
  228. data[key].forEach(item => {
  229. item['content'] = ''
  230. })
  231. }
  232. }
  233. return data;
  234. });
  235. },
  236. async handleAudit(status) {
  237. this.loading = true;
  238. try {
  239. this.form.valueJson = await this.generateFormValid();
  240. } catch (error) {
  241. this.loading = false;
  242. return;
  243. }
  244. console.log(this.form.valueJson)
  245. this.form.processType = '1';
  246. let API = this.APIUrl + '/bpm/process-instance/create'
  247. axios({
  248. method: 'post',
  249. url: API,
  250. headers: this.headers,
  251. data: {
  252. ...this.form,
  253. }
  254. }).then((res) => {
  255. this.loading = false;
  256. if (res.data.code != '-1') {
  257. vant.showNotify({
  258. type: 'success',
  259. message: `提交成功!`,
  260. duration: 1000,
  261. });
  262. setTimeout(() => {
  263. this.onClickLeft()
  264. }, 1000)
  265. } else {
  266. vant.showNotify({
  267. type: 'danger',
  268. message: `提交失败!${res.data.message}`,
  269. duration: 1000,
  270. });
  271. }
  272. }).catch((err) => {
  273. vant.showNotify({
  274. type: 'danger',
  275. message: `提交失败!${err.message}`,
  276. duration: 1000,
  277. });
  278. this.loading = false;
  279. });
  280. },
  281. onClickLeft() {
  282. uni.navigateBack({
  283. delta: 1
  284. });
  285. }
  286. }
  287. }).use(vant).use(FormMakingV3).mount('#app')
  288. </script>
  289. </body>
  290. </html>