AdminStoreDiscountCreate.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="AdminDiscountCreate"
  3. :style="localOptions.style">
  4. <div class="flex justify-end">
  5. <q-btn flat
  6. color="grey"
  7. @click="$router.go(-1)">
  8. بازگشت
  9. >
  10. </q-btn>
  11. </div>
  12. <entity-create v-if="mounted"
  13. ref="entityCreate"
  14. v-model:value="inputs"
  15. title="ایجاد تخفیف"
  16. :api="api"
  17. :entity-id-key="entityIdKey"
  18. :entity-param-key="entityParamKey"
  19. :show-route-name="showRouteName"
  20. :show-close-button="false"
  21. :show-edit-button="false"
  22. :show-expand-button="false"
  23. :show-save-button="false"
  24. :show-reload-button="false" />
  25. </div>
  26. </template>
  27. <script>
  28. import { shallowRef } from 'vue'
  29. import { EntityCreate } from 'quasar-crud'
  30. import { mixinWidget } from 'src/mixin/Mixins.js'
  31. import { APIGateway } from 'src/api/APIGateway.js'
  32. import BtnControl from 'components/Control/btn.vue'
  33. const BtnControlComp = shallowRef(BtnControl)
  34. export default {
  35. name: 'AdminDiscountCreate',
  36. components: { EntityCreate },
  37. mixins: [mixinWidget],
  38. data: () => {
  39. return {
  40. mounted: false,
  41. entityLoading: false,
  42. api: APIGateway.discount.APIAdresses.base,
  43. entityIdKey: 'id',
  44. entityParamKey: 'id',
  45. showRouteName: 'Admin.Store.Discount.Show',
  46. inputs: [
  47. { type: 'input', name: 'code', responseKey: 'code', label: 'کد', placeholder: ' ', col: 'col-md-4 col-12' },
  48. { type: 'input', name: 'percent', responseKey: 'percent', label: 'درصد', placeholder: ' ', col: 'col-md-4 col-12' },
  49. { type: 'dateTime', name: 'expire_time', responseKey: 'expire_time', outsideLabel: 'تاریخ انقضا', col: 'col-md-4 col-12' },
  50. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ایجاد تخفیف', placeholder: ' ', atClick: () => {}, col: 'col-md-6' }
  51. ]
  52. }
  53. },
  54. mounted() {
  55. this.setActionBtn()
  56. this.mounted = true
  57. },
  58. methods: {
  59. setActionBtn () {
  60. this.inputs.forEach((item, index) => {
  61. if (item.name === 'btn') {
  62. this.inputs[index].atClick = this.onSubmit
  63. }
  64. })
  65. },
  66. onSubmit () {
  67. this.create()
  68. },
  69. create() {
  70. this.entityLoading = true
  71. this.$refs.entityCreate.createEntity()
  72. .then(() => {
  73. this.entityLoading = false
  74. })
  75. .catch(() => {
  76. this.entityLoading = false
  77. })
  78. }
  79. }
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .AdminDiscountCreate {
  84. .title {
  85. font-style: normal;
  86. font-weight: 700;
  87. font-size: 24px;
  88. line-height: 140%;
  89. color: #424242;
  90. margin-bottom: 27px;
  91. position: relative;
  92. .back-action {
  93. position: absolute;
  94. right: 0;
  95. top: 0;
  96. }
  97. }
  98. :deep(.form) {
  99. padding: 24px;
  100. }
  101. }
  102. </style>