payInterfaceConfigForm.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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="payTypeId">
  8. <!-- <a-input v-model="model.payTypeId" placeholder="请输入关联支付方式" ></a-input>-->
  9. <a-select
  10. v-model="model.payTypeId"
  11. placeholder="请选择支付方式"
  12. :allowClear="true"
  13. >
  14. <a-select-option :value="item.id" v-for="(item,index) in payTypeList" :key="index">{{ item.name }}</a-select-option>
  15. </a-select>
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :span="24">
  19. <a-form-model-item label="商户号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="merchantNo">
  20. <a-input v-model="model.merchantNo" placeholder="请输入商户号" ></a-input>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :span="24">
  24. <a-form-model-item label="终端号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="terminalNo">
  25. <a-input v-model="model.terminalNo" placeholder="请输入终端号" ></a-input>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :span="24">
  29. <a-form-model-item label="TOKEN令牌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="token">
  30. <a-input v-model="model.token" placeholder="请输入TOKEN令牌" ></a-input>
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :span="24">
  34. <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
  35. <a-select v-model="model.status" style="width: 100%">
  36. <a-select-option value="0">关闭</a-select-option>
  37. <a-select-option value="1">启用</a-select-option>
  38. </a-select>
  39. </a-form-model-item>
  40. </a-col>
  41. </a-row>
  42. </a-form-model>
  43. </j-form-container>
  44. </a-spin>
  45. </template>
  46. <script>
  47. import { httpAction, getAction } from '@/api/manage'
  48. import { validateDuplicateValue } from '@/utils/util'
  49. export default {
  50. name: 'payInterfaceConfigForm',
  51. components: {
  52. },
  53. props: {
  54. //表单禁用
  55. disabled: {
  56. type: Boolean,
  57. default: false,
  58. required: false
  59. }
  60. },
  61. data () {
  62. return {
  63. model:{
  64. },
  65. labelCol: {
  66. xs: { span: 24 },
  67. sm: { span: 5 },
  68. },
  69. wrapperCol: {
  70. xs: { span: 24 },
  71. sm: { span: 16 },
  72. },
  73. confirmLoading: false,
  74. validatorRules: {
  75. status: [
  76. { required: true, message: '请选择是否启用!'},
  77. ],
  78. payTypeId: [
  79. { required: true, message: '请输入关联支付方式!'},
  80. ],
  81. merchantNo: [
  82. { required: true, message: '请输入商户号!'},
  83. ],
  84. terminalNo: [
  85. { required: true, message: '请输入终端号!'},
  86. ],
  87. token: [
  88. { required: true, message: '请输入TOKEN令牌!'},
  89. ],
  90. },
  91. url: {
  92. add: "/business/busPayInterfaceConfig/add",
  93. edit: "/business/busPayInterfaceConfig/edit",
  94. queryById: "/business/busPayInterfaceConfig/queryById",
  95. query_payType: "/business/busRoomPayType/queryList",
  96. },
  97. payTypeList:[]
  98. }
  99. },
  100. computed: {
  101. formDisabled(){
  102. return this.disabled
  103. },
  104. },
  105. created () {
  106. //备份model原始值
  107. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  108. getAction(this.url.query_payType,{}).then((res)=>{
  109. if(res.success){
  110. this.payTypeList = res.result
  111. }else{
  112. }
  113. })
  114. },
  115. methods: {
  116. add () {
  117. this.edit(this.modelDefault);
  118. },
  119. edit (record) {
  120. this.model = Object.assign({}, record);
  121. this.visible = true;
  122. if(!this.model.id){
  123. this.model.status = "1";
  124. }else{
  125. this.model.status = record.status.toString();
  126. }
  127. },
  128. submitForm () {
  129. const that = this;
  130. // 触发表单验证
  131. this.$refs.form.validate(valid => {
  132. if (valid) {
  133. that.confirmLoading = true;
  134. let httpurl = '';
  135. let method = '';
  136. if(!this.model.id){
  137. httpurl+=this.url.add;
  138. method = 'post';
  139. var info = JSON.parse(localStorage.getItem("storeInfo"));
  140. this.model.hotelId = info.id;
  141. }else{
  142. httpurl+=this.url.edit;
  143. method = 'put';
  144. }
  145. httpAction(httpurl,this.model,method).then((res)=>{
  146. if(res.success){
  147. that.$message.success(res.message);
  148. that.$emit('ok');
  149. }else{
  150. that.$message.warning(res.message);
  151. }
  152. }).finally(() => {
  153. that.confirmLoading = false;
  154. })
  155. }
  156. })
  157. },
  158. }
  159. }
  160. </script>