PosThaliInGoodsForm.vue 4.6 KB

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