AddCreate.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <el-dialog title="编辑门店名称" :visible.sync="dialogVisible" width="750px" :append-to-body="true" :before-close="close" :destroy-on-close="true" :close-on-click-modal="false">
  3. <el-form ref="form" :model="form" :rules="rules" label-width="120px" style="max-height: 375px;overflow: auto;">
  4. <el-form-item label="门店名称" prop="name" style="width: 60%;margin: 40px 0">
  5. <el-input v-model="form.name" placeholder="例如xxxx店, 对用户可见" />
  6. </el-form-item>
  7. <el-form-item label="是否不进行分佣:">
  8. <el-switch v-model="form.commFlag" :active-value="1" :inactive-value="0" />
  9. <div class="tip">开启后,购买线上票不分佣(渠道,门店,推广员)</div>
  10. </el-form-item>
  11. </el-form>
  12. <div slot="footer" class="dialog-footer">
  13. <el-button @click="close">取 消</el-button>
  14. <el-button type="primary" :disabled="loading" @click="saveClick">确 定</el-button>
  15. </div>
  16. </el-dialog>
  17. </template>
  18. <script>
  19. import { updateSaleSite, getSaleSiteDetail } from "@/api/admin/salesite";
  20. export default {
  21. props: {
  22. dialogVisible: {
  23. type: Boolean,
  24. default: false
  25. },
  26. editId: [Number, String] // 编辑用
  27. },
  28. data() {
  29. return {
  30. loading: false,
  31. // 表单参数
  32. form: {
  33. name: "",
  34. commFlag: 0,
  35. },
  36. // 表单校验
  37. rules: {
  38. name: [
  39. { required: true, message: "请输入门店名称", trigger: "blur" }
  40. ],
  41. },
  42. //招商推广宣传图
  43. picture: []
  44. };
  45. },
  46. created() {
  47. // 是编辑
  48. if (this.editId) {
  49. this.getDetail();
  50. }
  51. },
  52. methods: {
  53. getDetail() {
  54. this.loading = true;
  55. getSaleSiteDetail(this.editId).then(res => {
  56. this.form.name = res.data.name
  57. this.form.commFlag = res.data.commFlag
  58. this.loading = false
  59. }).catch(() => {
  60. this.loading = false;
  61. });
  62. },
  63. //确定修改
  64. saveClick() {
  65. this.loading = true
  66. this.$refs.form.validate(valid => {
  67. if (valid) {
  68. this.submitForm(this.form);
  69. } else {
  70. this.loading = false;
  71. this.$message.error('门店名称不能为空')
  72. return false;
  73. }
  74. });
  75. },
  76. //保存
  77. submitForm(params) {
  78. if (this.editId) {
  79. params.channelId = this.editId;
  80. }
  81. updateSaleSite(params).then(response => {
  82. this.loading = false
  83. this.$message.success('编辑成功')
  84. this.$emit('saveSuccess')
  85. this.close()
  86. }).catch(() => {
  87. this.loading = false
  88. });
  89. },
  90. //关闭
  91. close() {
  92. this.$emit("close");
  93. }
  94. }
  95. };
  96. </script>
  97. <style scoped lang="scss">
  98. .tip {
  99. font-size: 12px;
  100. color: #999;
  101. }
  102. .tag {
  103. margin-right: 15px;
  104. width: 90px;
  105. text-align: center;
  106. cursor: pointer;
  107. }
  108. .tag-select {
  109. background-color: #409eff !important;
  110. border-color: #409eff !important;
  111. color: #fff !important;
  112. }
  113. .cover-content-item {
  114. width: 220px;
  115. float: left;
  116. position: relative;
  117. .cover-img {
  118. width: 200px;
  119. height: 100px;
  120. }
  121. .cover-mark {
  122. position: absolute;
  123. top: 0px;
  124. right: 28px;
  125. z-index: 1;
  126. color: red;
  127. cursor: pointer;
  128. visibility: hidden;
  129. }
  130. .select {
  131. visibility: visible !important;
  132. }
  133. }
  134. .dialog-footer {
  135. text-align: center;
  136. }
  137. </style>
  138. <style lang="scss">
  139. .ygp-form-items {
  140. .el-form-item {
  141. padding: 0 5px;
  142. }
  143. .el-form-item__label {
  144. line-height: 1.2;
  145. padding-bottom: 8px;
  146. word-break: break-all;
  147. word-wrap: break-word;
  148. color: #333;
  149. }
  150. .el-form-item__error {
  151. position: relative;
  152. top: auto;
  153. left: auto;
  154. }
  155. .el-form-item.is-desc_text {
  156. .el-form-item__label {
  157. display: none;
  158. }
  159. }
  160. }
  161. </style>