SaveOrUpdate.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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
  13. class="block-title"
  14. style="line-height: 2.5;margin:20px"
  15. >生成地址</span
  16. >
  17. </el-col>
  18. <el-col :span="10">
  19. <el-button
  20. type="danger"
  21. plain
  22. class="float-right mg-l-r-10 close-btn"
  23. @click="close"
  24. >关闭
  25. </el-button>
  26. <el-button
  27. class="float-right mg-l-r-10 confirm-btn pd-2"
  28. @click="generateAddress"
  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" @click="generateAddress('ruleForm')">提交</el-button
  56. >
  57. <el-button @click="resetForm('ruleForm')">重置</el-button>
  58. </el-form-item>
  59. </el-form>
  60. </el-drawer>
  61. </div>
  62. </template>
  63. <style scope>
  64. .upload__text {
  65. font-size: 12px;
  66. font-family: MiSans, MiSans-Normal;
  67. font-weight: Normal;
  68. text-align: LEFT;
  69. color: #888888;
  70. line-height: 12px;
  71. position: absolute;
  72. bottom: 30px;
  73. left: 23px;
  74. }
  75. .avatar-uploader .el-upload {
  76. background: #f7f7f7;
  77. border-radius: 10px;
  78. cursor: pointer;
  79. position: relative;
  80. overflow: hidden;
  81. }
  82. .avatar-uploader .el-upload:hover {
  83. border-color: #409eff;
  84. }
  85. .avatar-uploader-icon {
  86. font-size: 28px;
  87. color: #8c939d;
  88. width: 156px;
  89. height: 156px;
  90. line-height: 156px;
  91. text-align: center;
  92. }
  93. .el-upload-dragger {
  94. width: 156px;
  95. height: 156px;
  96. }
  97. .avatar {
  98. width: 156px;
  99. height: 156px;
  100. }
  101. </style>
  102. <script>
  103. import { pageAddress, batchAddress } from "@/api/adress";
  104. export const baseUrl = process.env.VUE_APP_BASEURL;
  105. export default {
  106. data() {
  107. return {
  108. url: process.env.VUE_APP_BASEURL,
  109. addressModal: false,
  110. isSave: false,
  111. ruleForm: {
  112. password: undefined,
  113. groupName: undefined,
  114. numWallet: undefined,
  115. },
  116. rules: {},
  117. };
  118. },
  119. methods: {
  120. resetForm() {
  121. this.ruleForm.groupName = undefined;
  122. this.ruleForm.password = undefined;
  123. this.ruleForm.numWallet = undefined;
  124. },
  125. resetField() {
  126. this.$refs["ruleForm"].clearValidate();
  127. },
  128. close() {
  129. this.addressModal = false;
  130. this.resetForm();
  131. },
  132. generateAddress() {
  133. this.$refs["ruleForm"].validate((valid) => {
  134. if (valid) {
  135. batchAddress(JSON.stringify(this.ruleForm), {
  136. headers: {
  137. "content-type": "application/json",
  138. },
  139. }).then((res) => {
  140. this.$message.success("生成成功");
  141. this.addressModal = false;
  142. this.resetForm();
  143. this.$parent.getAddresses();
  144. });
  145. } else {
  146. this.$message.error("请填写必填字段!");
  147. }
  148. });
  149. },
  150. },
  151. created() {},
  152. };
  153. </script>