shuilvForm.vue 3.0 KB

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