BusMarketMemberGroupForm.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model
  5. ref="form"
  6. :model="model"
  7. :rules="validatorRules"
  8. slot="detail"
  9. >
  10. <a-row>
  11. <!-- <a-col :span="24">
  12. <a-form-model-item label="关联租户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenantId">
  13. <a-input v-model="model.tenantId" placeholder="请输入关联租户" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="关联酒店" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hotelId">
  18. <a-input v-model="model.hotelId" placeholder="请输入关联酒店" ></a-input>
  19. </a-form-model-item>
  20. </a-col> -->
  21. <a-col :span="24">
  22. <a-form-model-item
  23. label="名称"
  24. :labelCol="labelCol"
  25. :wrapperCol="wrapperCol"
  26. prop="name"
  27. >
  28. <a-input v-model="model.name" placeholder="请输入名称"></a-input>
  29. </a-form-model-item>
  30. </a-col>
  31. </a-row>
  32. </a-form-model>
  33. </j-form-container>
  34. </a-spin>
  35. </template>
  36. <script>
  37. import { httpAction, getAction } from "@/api/manage";
  38. import { validateDuplicateValue } from "@/utils/util";
  39. export default {
  40. name: "BusMarketMemberGroupForm",
  41. components: {},
  42. props: {
  43. //表单禁用
  44. disabled: {
  45. type: Boolean,
  46. default: false,
  47. required: false,
  48. },
  49. },
  50. data() {
  51. return {
  52. model: {},
  53. labelCol: {
  54. xs: { span: 24 },
  55. sm: { span: 5 },
  56. },
  57. wrapperCol: {
  58. xs: { span: 24 },
  59. sm: { span: 16 },
  60. },
  61. confirmLoading: false,
  62. validatorRules: {
  63. tenantId: [{ required: true, message: "请输入关联租户!" }],
  64. hotelId: [{ required: true, message: "请输入关联酒店!" }],
  65. name: [{ required: true, message: "请输入名称!" }],
  66. },
  67. url: {
  68. add: "/business/busMarketMemberGroup/add",
  69. edit: "/business/busMarketMemberGroup/edit",
  70. queryById: "/business/busMarketMemberGroup/queryById",
  71. },
  72. };
  73. },
  74. computed: {
  75. formDisabled() {
  76. return this.disabled;
  77. },
  78. },
  79. created() {
  80. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  81. if (_info) {
  82. this.model.hotelId = _info.id;
  83. }
  84. //备份model原始值
  85. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  86. },
  87. methods: {
  88. add() {
  89. this.edit(this.modelDefault);
  90. },
  91. edit(record) {
  92. this.model = Object.assign({}, record);
  93. this.visible = true;
  94. },
  95. submitForm() {
  96. const that = this;
  97. // 触发表单验证
  98. this.$refs.form.validate((valid) => {
  99. if (valid) {
  100. that.confirmLoading = true;
  101. let httpurl = "";
  102. let method = "";
  103. if (!this.model.id) {
  104. httpurl += this.url.add;
  105. method = "post";
  106. } else {
  107. httpurl += this.url.edit;
  108. method = "put";
  109. }
  110. httpAction(httpurl, this.model, method)
  111. .then((res) => {
  112. if (res.success) {
  113. that.$message.success(res.message);
  114. that.$emit("ok");
  115. } else {
  116. that.$message.warning(res.message);
  117. }
  118. })
  119. .finally(() => {
  120. that.confirmLoading = false;
  121. });
  122. }
  123. });
  124. },
  125. },
  126. };
  127. </script>