AddCreate.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="parentId" style="width: 60%;margin: 40px 0">
  5. <el-select
  6. v-model="form.parentId"
  7. placeholder="请选择上级渠道"
  8. style="width: 100%;"
  9. filterable
  10. clearable
  11. :filter-method="dataFilter"
  12. >
  13. <el-option
  14. v-for="(item) in channelList"
  15. :key="item.channelId"
  16. :label="item.name"
  17. :value="item.channelId">
  18. <div>
  19. <span style="float: left;">{{item.name}} </span>
  20. <span style="float: right;">{{item.mobile}}</span>
  21. </div>
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="门店名称" prop="name" style="width: 60%;margin: 40px 0">
  26. <el-input v-model="form.name" placeholder="例如xxxx店, 对用户可见" />
  27. </el-form-item>
  28. <el-form-item label="手机号码" prop="mobile" style="width: 60%;margin: 40px 0">
  29. <el-input
  30. v-model="form.mobile"
  31. placeholder="请输入手机号码"
  32. clearable
  33. size="small"
  34. />
  35. </el-form-item>
  36. <el-form-item label="关闭分佣:">
  37. <el-switch v-model="form.commFlag" :active-value="1" :inactive-value="0" />
  38. <div class="tip">开启后,购买线上票不分佣(渠道,门店,推广员)</div>
  39. </el-form-item>
  40. </el-form>
  41. <div slot="footer" class="dialog-footer">
  42. <el-button @click="close">取 消</el-button>
  43. <el-button type="primary" :disabled="loading" @click="saveClick">确 定</el-button>
  44. </div>
  45. </el-dialog>
  46. </template>
  47. <script>
  48. import { updateSaleSite, getSaleSiteDetail } from "@/api/admin/salesite";
  49. import { listAllChannel } from "@/api/admin/channel";
  50. export default {
  51. props: {
  52. dialogVisible: {
  53. type: Boolean,
  54. default: false
  55. },
  56. editId: [Number, String] // 编辑用
  57. },
  58. data() {
  59. return {
  60. loading: false,
  61. // 表单参数
  62. form: {
  63. name: "",
  64. commFlag: 0,
  65. mobile: "",
  66. parentId: null,
  67. },
  68. // 表单校验
  69. rules: {
  70. name: [
  71. { required: true, message: "请输入门店名称", trigger: "blur" }
  72. ],
  73. },
  74. //招商推广宣传图
  75. picture: [],
  76. // 上级渠道列表
  77. channelList:[],
  78. };
  79. },
  80. mounted() {
  81. this.getChannelList()
  82. },
  83. created() {
  84. // 是编辑
  85. if (this.editId) {
  86. this.getDetail();
  87. }
  88. },
  89. methods: {
  90. // 获取上级渠道下拉列表
  91. getChannelList(){
  92. listAllChannel().then(response => {
  93. this.channelList = response.data || [];
  94. this.channelCopyList = response.data || [];
  95. });
  96. },
  97. dataFilter(val) {
  98. if (val) { //val存在
  99. this.channelList = this.channelCopyList.filter((item) => {
  100. if (!!~item.mobile.indexOf(val) || !!~item.mobile.toUpperCase().indexOf(val.toUpperCase())
  101. || !!~item.name.indexOf(val) || !!~item.name.indexOf(val)) {
  102. return true
  103. }
  104. })
  105. } else { //val为空时,还原数组
  106. this.channelList = this.channelCopyList;
  107. }
  108. },
  109. getDetail() {
  110. this.loading = true;
  111. getSaleSiteDetail(this.editId).then(res => {
  112. this.form.name = res.data.name
  113. this.form.commFlag = res.data.commFlag
  114. this.form.mobile = res.data.mobile
  115. this.form.parentId = res.data.parentId
  116. this.loading = false
  117. }).catch(() => {
  118. this.loading = false;
  119. });
  120. },
  121. //确定修改
  122. saveClick() {
  123. this.loading = true
  124. this.$refs.form.validate(valid => {
  125. if (valid) {
  126. this.submitForm(this.form);
  127. } else {
  128. this.loading = false;
  129. this.$message.error('门店名称不能为空')
  130. return false;
  131. }
  132. });
  133. },
  134. //保存
  135. submitForm(params) {
  136. if (this.editId) {
  137. params.channelId = this.editId;
  138. }
  139. updateSaleSite(params).then(response => {
  140. this.loading = false
  141. this.$message.success('编辑成功')
  142. this.$emit('saveSuccess')
  143. this.close()
  144. }).catch(() => {
  145. this.loading = false
  146. });
  147. },
  148. //关闭
  149. close() {
  150. this.$emit("close");
  151. }
  152. }
  153. };
  154. </script>
  155. <style scoped lang="scss">
  156. .tip {
  157. font-size: 12px;
  158. color: #999;
  159. }
  160. .tag {
  161. margin-right: 15px;
  162. width: 90px;
  163. text-align: center;
  164. cursor: pointer;
  165. }
  166. .tag-select {
  167. background-color: #409eff !important;
  168. border-color: #409eff !important;
  169. color: #fff !important;
  170. }
  171. .cover-content-item {
  172. width: 220px;
  173. float: left;
  174. position: relative;
  175. .cover-img {
  176. width: 200px;
  177. height: 100px;
  178. }
  179. .cover-mark {
  180. position: absolute;
  181. top: 0px;
  182. right: 28px;
  183. z-index: 1;
  184. color: red;
  185. cursor: pointer;
  186. visibility: hidden;
  187. }
  188. .select {
  189. visibility: visible !important;
  190. }
  191. }
  192. .dialog-footer {
  193. text-align: center;
  194. }
  195. </style>
  196. <style lang="scss">
  197. .ygp-form-items {
  198. .el-form-item {
  199. padding: 0 5px;
  200. }
  201. .el-form-item__label {
  202. line-height: 1.2;
  203. padding-bottom: 8px;
  204. word-break: break-all;
  205. word-wrap: break-word;
  206. color: #333;
  207. }
  208. .el-form-item__error {
  209. position: relative;
  210. top: auto;
  211. left: auto;
  212. }
  213. .el-form-item.is-desc_text {
  214. .el-form-item__label {
  215. display: none;
  216. }
  217. }
  218. }
  219. </style>