SaveOrUpdate.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div>
  3. <el-drawer
  4. :wrapperClosable="false"
  5. size="700px"
  6. :visible.sync="addressModal"
  7. :withHeader="false"
  8. :modal-append-to-body="false"
  9. >
  10. <el-row style="padding-top: 20px; border-bottom: 1px solid #f0f0f0">
  11. <el-col :span="13" class="mb-18">
  12. <span class="block-title" style="line-height: 2.5; margin: 20px"
  13. >生成地址</span
  14. >
  15. </el-col>
  16. <el-col :span="10">
  17. <el-button
  18. type="danger"
  19. plain
  20. class="float-right mg-l-r-10 close-btn"
  21. @click="close"
  22. >关闭
  23. </el-button>
  24. <el-button
  25. type="primary"
  26. class="float-right mg-l-r-10 confirm-btn pd-2"
  27. @click="generateAddress"
  28. :disabled="isDisabled"
  29. >确认</el-button
  30. >
  31. </el-col>
  32. </el-row>
  33. <el-form
  34. :model="ruleForm"
  35. status-icon
  36. :rules="rules"
  37. ref="ruleForm"
  38. label-width="100px"
  39. style="margin: 40px 0; width: 600px"
  40. >
  41. <el-form-item label="地址组名称" prop="groupName">
  42. <el-input v-model="ruleForm.groupName" autocomplete="off"></el-input>
  43. </el-form-item>
  44. <el-form-item label="生成数量" prop="numWallet">
  45. <el-input v-model="ruleForm.numWallet" autocomplete="off"></el-input>
  46. </el-form-item>
  47. <el-form-item label="密码" prop="password">
  48. <el-input
  49. type="password"
  50. v-model="ruleForm.password"
  51. autocomplete="off"
  52. ></el-input>
  53. </el-form-item>
  54. <!-- <el-form-item>
  55. <el-button type="primary" :disabled="disabled" @click="generateAddress('ruleForm')"
  56. >提交</el-button
  57. >
  58. <el-button @click="resetForm('ruleForm')">重置</el-button>
  59. </el-form-item> -->
  60. </el-form>
  61. </el-drawer>
  62. </div>
  63. </template>
  64. <style scope>
  65. .upload__text {
  66. font-size: 12px;
  67. font-family: MiSans, MiSans-Normal;
  68. font-weight: Normal;
  69. text-align: LEFT;
  70. color: #888888;
  71. line-height: 12px;
  72. position: absolute;
  73. bottom: 30px;
  74. left: 23px;
  75. }
  76. .avatar-uploader .el-upload {
  77. background: #f7f7f7;
  78. border-radius: 10px;
  79. cursor: pointer;
  80. position: relative;
  81. overflow: hidden;
  82. }
  83. .avatar-uploader .el-upload:hover {
  84. border-color: #409eff;
  85. }
  86. .avatar-uploader-icon {
  87. font-size: 28px;
  88. color: #8c939d;
  89. width: 156px;
  90. height: 156px;
  91. line-height: 156px;
  92. text-align: center;
  93. }
  94. .el-upload-dragger {
  95. width: 156px;
  96. height: 156px;
  97. }
  98. .avatar {
  99. width: 156px;
  100. height: 156px;
  101. }
  102. </style>
  103. <script>
  104. import { pageAddress, batchAddress } from "@/api/adress";
  105. export const baseUrl = process.env.VUE_APP_BASEURL;
  106. export default {
  107. data() {
  108. return {
  109. url: process.env.VUE_APP_BASEURL,
  110. addressModal: false,
  111. isSave: false,
  112. ruleForm: {
  113. password: undefined,
  114. groupName: undefined,
  115. numWallet: undefined,
  116. },
  117. rules: {},
  118. isDisabled: false,
  119. };
  120. },
  121. methods: {
  122. resetForm() {
  123. this.ruleForm.groupName = undefined;
  124. this.ruleForm.password = undefined;
  125. this.ruleForm.numWallet = undefined;
  126. },
  127. resetField() {
  128. this.$refs["ruleForm"].clearValidate();
  129. },
  130. close() {
  131. this.addressModal = false;
  132. this.resetForm();
  133. },
  134. generateAddress() {
  135. this.$refs["ruleForm"].validate((valid) => {
  136. if (valid) {
  137. this.isDisabled = true;
  138. batchAddress(JSON.stringify(this.ruleForm), {
  139. headers: {
  140. "content-type": "application/json",
  141. },
  142. }).then((res) => {
  143. this.$message.success("生成成功");
  144. this.addressModal = false;
  145. this.resetForm();
  146. this.$parent.getAddresses();
  147. this.isDisabled = false;
  148. });
  149. } else {
  150. this.$message.error("请填写必填字段!");
  151. this.isDisabled = false;
  152. }
  153. });
  154. },
  155. },
  156. created() {},
  157. };
  158. </script>