edit.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div>
  3. <form-design ref="formDesign">
  4. <template v-slot:action>
  5. <el-button type="text" icon="el-icon-check" @click="btnSave"
  6. >保存</el-button
  7. >
  8. </template>
  9. </form-design>
  10. </div>
  11. </template>
  12. <script>
  13. import { getAction, putAction } from '@/api/flowable/manage';
  14. import { Message } from 'element-ui';
  15. import FormDesign from './FormDesign';
  16. export default {
  17. name: 'FlowableFormEdit',
  18. components: { FormDesign },
  19. data() {
  20. return {
  21. formKey: undefined,
  22. formData: {
  23. formKey: undefined,
  24. formName: '',
  25. formJson: ''
  26. }
  27. };
  28. },
  29. created() {
  30. if (this.$route.query && this.$route.query.formKey) {
  31. this.formKey = this.$route.query.formKey;
  32. }
  33. this.getFormData();
  34. },
  35. methods: {
  36. getFormData() {
  37. if (!this.formKey) {
  38. Message.error('formKey is null');
  39. return;
  40. }
  41. getAction('/flowable/form/queryById', { id: this.formKey }).then(
  42. (res) => {
  43. let { data } = res.data;
  44. this.formData = data;
  45. let json = this.formData?.formJson;
  46. setTimeout(
  47. () =>
  48. this.$refs.formDesign.setJSON(
  49. json ? JSON.parse(json) : undefined
  50. ),
  51. 100
  52. );
  53. }
  54. );
  55. },
  56. btnSave() {
  57. this.formData.formJson = JSON.stringify(
  58. this.$refs.formDesign.getJSON()
  59. );
  60. console.log(this.formData, 88888888);
  61. putAction('/flowable/form/update', this.formData).then(({ data }) => {
  62. Message.success(data.message);
  63. });
  64. }
  65. }
  66. };
  67. </script>