companyPayment-detail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <el-dialog
  3. :visible.sync="showDialog"
  4. :title="title"
  5. :modal-append-to-body="false"
  6. style="text-align: left"
  7. @close="closeDialog"
  8. :close-on-click-modal="false"
  9. >
  10. <div class="user-panel" v-loading="loading">
  11. <el-form
  12. ref="form"
  13. :model="formModel"
  14. :rules="ruleValidate"
  15. :label-width="'180px'"
  16. inline
  17. >
  18. <el-form-item label="物业公司" prop="companyId">
  19. <el-select v-model="formModel.companyId" filterable>
  20. <el-option
  21. v-for="result in companyList"
  22. :key="result.id"
  23. :label="result.name"
  24. :value="result.id"
  25. ></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="账户名称" prop="name">
  29. <el-input
  30. v-model="formModel.name"
  31. placeholder="请输入账户名称"
  32. style="width: 500px"
  33. ></el-input>
  34. </el-form-item>
  35. <el-form-item label="微信mchId" prop="mchId">
  36. <el-input
  37. v-model="formModel.mchId"
  38. placeholder="请输入微信mchId"
  39. style="width: 500px"
  40. ></el-input>
  41. </el-form-item>
  42. <el-form-item label="微信subMchId" prop="subMchId">
  43. <el-input
  44. v-model="formModel.subMchId"
  45. placeholder="请输入微信subMchId"
  46. style="width: 500px"
  47. ></el-input>
  48. </el-form-item>
  49. <el-form-item label="支付宝appAuthToken" prop="appAuthToken">
  50. <el-input
  51. v-model="formModel.appAuthToken"
  52. placeholder="请输入支付宝appAuthToken"
  53. style="width: 500px"
  54. ></el-input>
  55. </el-form-item>
  56. </el-form>
  57. </div>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button @click="closeDialog">取 消</el-button>
  60. <el-button type="primary" @click="handleSubmit" :loading="submitting"
  61. >确 定</el-button
  62. >
  63. </span>
  64. </el-dialog>
  65. </template>
  66. <script>
  67. import Constant from "@/constant";
  68. import companyPaymentApi from "@/api/base/companyPayment";
  69. import companyInfoApi from "@/api/base/companyInfo";
  70. export default {
  71. props: ["businessKey", "title"],
  72. data() {
  73. return {
  74. ruleValidate: {
  75. companyId: [{ required: true, message: "物业公司不能为空", trigger: "blur" }],
  76. name: [{ required: true, message: "账户名称不能为空", trigger: "blur" }],
  77. mchId: [{ required: true, message: "微信mchId不能为空", trigger: "blur" }],
  78. subMchId: [{ required: true, message: "微信subMchId不能为空", trigger: "blur" }],
  79. appAuthToken: [{ required: true, message: "支付宝appAuthToken不能为空", trigger: "blur" }],
  80. },
  81. formModel:{
  82. companyId:"",
  83. name:"",
  84. mchId:"",
  85. subMchId:"",
  86. appAuthToken:"",
  87. },
  88. companyList:[],
  89. showDialog: true,
  90. loading: false,
  91. submitting: false,
  92. }
  93. },
  94. methods: {
  95. closeDialog() {
  96. this.$emit("close", false);
  97. },
  98. handleSubmit() {
  99. var self = this;
  100. this.$refs["form"].validate((valid) => {
  101. if (valid) {
  102. (function () {
  103. var id = self.formModel.id;
  104. alert(JSON.stringify(self.formModel))
  105. if (id == null || id.length == 0) {
  106. return companyPaymentApi.add(self.formModel);
  107. } else {
  108. return companyPaymentApi.update(self.formModel);
  109. }
  110. })().then(function (response) {
  111. var jsonData = response.data;
  112. if (jsonData.result) {
  113. self.$message({
  114. message: "保存成功!",
  115. type: "success",
  116. });
  117. self.$emit("close", true);
  118. } else {
  119. self.$message({
  120. message: jsonData.message + "",
  121. type: "warning",
  122. });
  123. self.$emit("close", false);
  124. }
  125. });
  126. }
  127. });
  128. },
  129. },
  130. mounted: function () {
  131. var self = this;
  132. companyInfoApi.list().then((resp) => {
  133. var jsonData = resp.data;
  134. this.companyList = jsonData.data;
  135. });
  136. (function () {
  137. if (self.businessKey.length == 0) {
  138. return companyPaymentApi.create();
  139. } else {
  140. return companyPaymentApi.edit(self.businessKey);
  141. }
  142. })()
  143. .then((response) => {
  144. var jsonData = response.data;
  145. self.loading = false;
  146. if (jsonData.result) {
  147. self.formModel = jsonData.data;
  148. } else {
  149. self.$message.error(jsonData.message + "");
  150. }
  151. })
  152. .catch((error) => {
  153. self.$message.error(error + "");
  154. });
  155. },
  156. }
  157. </script>
  158. <style scoped>
  159. .user-panel {
  160. margin: 10px auto;
  161. }
  162. </style>