ChangeStore.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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" style="max-height: 375px;overflow: auto;margin-top: 30px;">
  4. <el-form-item label="上级渠道" prop="parentId">
  5. <el-select v-model="form.parentId" placeholder="请选择上级渠道" style="width: 60%;" filterable clearable :filter-method="dataFilter">
  6. <el-option v-for="(item) in channelList" :key="item.channelId" :label="item.name" :value="item.channelId">
  7. <div>
  8. <span style="float: left;">{{item.name}} </span>
  9. <span style="float: right;">{{item.mobile}}</span>
  10. </div>
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. </el-form>
  15. <div style="width: 100%;text-align: center;">谨慎操作,点击确定后转换,转换完成请到门店列表查看</div>
  16. <div slot="footer" class="dialog-footer">
  17. <el-button @click="close">取 消</el-button>
  18. <el-button type="primary" :disabled="loading" @click="saveClick">确 定</el-button>
  19. </div>
  20. </el-dialog>
  21. </template>
  22. <script>
  23. import { listAllChannel, channelTransform } from "@/api/admin/channel";
  24. export default {
  25. props: {
  26. dialogVisible: {
  27. type: Boolean,
  28. default: false
  29. },
  30. editId: [Number, String] // 编辑用
  31. },
  32. data() {
  33. return {
  34. loading: false,
  35. // 上级渠道列表
  36. channelList: [],
  37. channelCopyList: [],
  38. // 表单参数
  39. form: {
  40. parentId: null,
  41. },
  42. // 表单校验
  43. rules: {
  44. parentId: [
  45. { required: true, message: "请选择门店所属上级渠道", trigger: "change" }
  46. ],
  47. },
  48. };
  49. },
  50. mounted() {
  51. this.getChannelList()
  52. },
  53. methods: {
  54. // 获取上级渠道下拉列表
  55. getChannelList() {
  56. listAllChannel().then(response => {
  57. this.channelList = response.data || [];
  58. this.channelCopyList = response.data || [];
  59. });
  60. },
  61. dataFilter(val) {
  62. if (val) { //val存在
  63. this.channelList = this.channelCopyList.filter((item) => {
  64. if (!!~item.mobile.indexOf(val) || !!~item.mobile.toUpperCase().indexOf(val.toUpperCase())
  65. || !!~item.name.indexOf(val) || !!~item.name.indexOf(val)) {
  66. return true
  67. }
  68. })
  69. } else { //val为空时,还原数组
  70. this.channelList = this.channelCopyList;
  71. }
  72. },
  73. saveClick() {
  74. this.loading = true
  75. const subForm = this.$refs["form"]
  76. subForm.validate(valid => {
  77. if (valid) {
  78. this.submitForm(this.form);
  79. } else {
  80. this.loading = false;
  81. // 提示第一个error
  82. this.getFormErrorMessage(subForm);
  83. return false;
  84. }
  85. });
  86. },
  87. /**
  88. * 保存
  89. */
  90. submitForm(params) {
  91. if (this.editId) {
  92. params.channelId = this.editId;
  93. }
  94. channelTransform(params).then(response => {
  95. this.loading = false
  96. this.$message.success('转换门店成功')
  97. this.$emit('saveSuccess')
  98. this.close()
  99. }).catch(() => {
  100. this.loading = false
  101. });
  102. },
  103. /**
  104. * 关闭窗口
  105. */
  106. close() {
  107. this.$emit("close");
  108. this.form = {};
  109. }
  110. }
  111. };
  112. </script>
  113. <style scoped lang="scss">
  114. .tag {
  115. margin-right: 15px;
  116. width: 90px;
  117. text-align: center;
  118. cursor: pointer;
  119. }
  120. .tag-select {
  121. background-color: #409eff !important;
  122. border-color: #409eff !important;
  123. color: #fff !important;
  124. }
  125. .cover-content-item {
  126. width: 220px;
  127. float: left;
  128. position: relative;
  129. .cover-img {
  130. width: 200px;
  131. height: 100px;
  132. }
  133. .cover-mark {
  134. position: absolute;
  135. top: 0px;
  136. right: 28px;
  137. z-index: 1;
  138. color: red;
  139. cursor: pointer;
  140. visibility: hidden;
  141. }
  142. .select {
  143. visibility: visible !important;
  144. }
  145. }
  146. .dialog-footer {
  147. text-align: center;
  148. }
  149. </style>
  150. <style lang="scss">
  151. .ygp-form-items {
  152. .el-form-item {
  153. padding: 0 5px;
  154. }
  155. .el-form-item__label {
  156. line-height: 1.2;
  157. padding-bottom: 8px;
  158. word-break: break-all;
  159. word-wrap: break-word;
  160. color: #333;
  161. }
  162. .el-form-item__error {
  163. position: relative;
  164. top: auto;
  165. left: auto;
  166. }
  167. .el-form-item.is-desc_text {
  168. .el-form-item__label {
  169. display: none;
  170. }
  171. }
  172. }
  173. </style>