from.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div v-if="FromData">
  3. <Modal
  4. v-model="modals"
  5. scrollable
  6. footer-hide
  7. closable
  8. :title="FromData.title"
  9. :z-index="1"
  10. width="700"
  11. @on-cancel="cancel"
  12. >
  13. <template>
  14. <div class="radio acea-row row-middle" v-if="FromData.action === '/marketing/coupon/save.html'">
  15. <div class="name ivu-form-item-content">优惠券类型</div>
  16. <Radio-group v-model="type" @on-change="couponsType">
  17. <Radio :label="0">通用券</Radio>
  18. <Radio :label="1">品类券</Radio>
  19. <Radio :label="2">商品券</Radio>
  20. </Radio-group>
  21. </div>
  22. </template>
  23. <form-create
  24. :option="config"
  25. :rule="Array.from(FromData.rules)"
  26. @submit="onSubmit"
  27. class="formBox"
  28. ref="fc"
  29. handleIcon="false"
  30. ></form-create>
  31. </Modal>
  32. </div>
  33. </template>
  34. <script>
  35. import formCreate from '@form-create/iview';
  36. import request from '@/libs/request';
  37. import { mapState } from 'vuex';
  38. export default {
  39. name: 'edit',
  40. components: {
  41. formCreate: formCreate.$form(),
  42. },
  43. computed: {
  44. ...mapState('userLevel', ['taskId', 'levelId']),
  45. },
  46. props: {
  47. FromData: {
  48. type: Object,
  49. default: null,
  50. },
  51. update: {
  52. type: Boolean,
  53. default: true,
  54. },
  55. },
  56. data() {
  57. return {
  58. modals: false,
  59. type: 0,
  60. loading: false,
  61. config: {
  62. global: {
  63. upload: {
  64. props: {
  65. onSuccess(res, file) {
  66. if (res.status === 200) {
  67. file.url = res.data.src;
  68. } else {
  69. this.Message.error(res.msg);
  70. }
  71. },
  72. },
  73. },
  74. },
  75. },
  76. };
  77. },
  78. methods: {
  79. couponsType() {
  80. this.$parent.addType(this.type);
  81. },
  82. // 提交表单 group
  83. onSubmit(formData) {
  84. let datas = {};
  85. datas = formData;
  86. if (this.loading) return;
  87. this.loading = true;
  88. request({
  89. url: this.FromData.action,
  90. method: this.FromData.method,
  91. data: datas,
  92. })
  93. .then((res) => {
  94. if (this.update) this.$parent.getList();
  95. this.$Message.success(res.msg);
  96. this.modals = false;
  97. setTimeout(() => {
  98. this.$emit('submitFail');
  99. this.loading = false;
  100. }, 1000);
  101. })
  102. .catch((res) => {
  103. this.loading = false;
  104. this.$Message.error(res.msg);
  105. });
  106. },
  107. // 关闭按钮
  108. cancel() {
  109. this.type = 0;
  110. // this.$emit('onCancel')
  111. },
  112. },
  113. };
  114. </script>
  115. <style scoped lang="stylus">
  116. .v-transfer-dom >>> .ivu-modal-content-drag {
  117. z-index: 2 !important;
  118. }
  119. .radio {
  120. margin-bottom: 14px;
  121. }
  122. .radio >>> .name {
  123. width: 125px;
  124. text-align: right;
  125. padding-right: 12px;
  126. }
  127. </style>