form.blade.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. @extends('layouts.base')
  2. @section('添加会员分组')
  3. @section('content')
  4. <link href="{{static_url('yunshop/css/total.css')}}" media="all" rel="stylesheet" type="text/css" />
  5. <style>
  6. .vue-title {
  7. display: flex;
  8. margin: 5px 0;
  9. line-height: 32px;
  10. font-size: 16px;
  11. color: #333;
  12. font-weight: 600;
  13. }
  14. .vue-title-left {
  15. width: 4px;
  16. height: 18px;
  17. margin-top: 6px;
  18. background: #29ba9c;
  19. display: inline-block;
  20. margin-right: 10px;
  21. }
  22. .vue-title-content {
  23. font-size: 14px;
  24. flex: 1;
  25. }
  26. </style>
  27. <div class="all">
  28. <div id="app">
  29. <div class="total-head">
  30. <div class="vue-title">
  31. <div class="vue-title-left"></div>
  32. <div class="vue-title-content">会员分组设置</div>
  33. </div>
  34. <el-form label-width="200px">
  35. <el-form-item :required="true" label="分组名称" placeholder="请输入分组名称">
  36. <el-input clearable v-model="form.groupName" v-focus style="width: 600px;"></el-input>
  37. </el-form-item>
  38. </el-form>
  39. </div>
  40. <div class="fixed total-floo">
  41. <div class="fixed_box">
  42. <el-form>
  43. <el-form-item>
  44. <el-button @click="submit" type="primary">提交</el-button>
  45. <el-button @click="returnList">返回列表</el-button>
  46. </el-form-item>
  47. </el-form>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <script>
  53. var vm = new Vue({
  54. el: "#app",
  55. delimiters: ['[[', ']]'],
  56. data() {
  57. return {
  58. form: {
  59. groupName: ''
  60. },
  61. isid: false,
  62. id: null,
  63. isCount: 1,
  64. uniacid: 0
  65. }
  66. },
  67. created() {
  68. let i = window.location.href.indexOf('id=');
  69. if (i !== -1) {
  70. this.isid = true
  71. let id = Number(window.location.href.slice(i + 3));
  72. this.id = id
  73. this.postUpdateGroup(id);
  74. }
  75. },
  76. // 自定义组件
  77. directives: {
  78. // 注册一个局部的自定义指令 v-focus
  79. focus: {
  80. // 指令的定义
  81. inserted: function(el) {
  82. // 聚焦元素
  83. el.querySelector('input').focus()
  84. }
  85. }
  86. },
  87. methods: {
  88. //回退
  89. hisGo(i) {
  90. // console.log(i);
  91. history.go(i)
  92. },
  93. //获取更新当前数据
  94. postUpdateGroup(id) {
  95. this.$http.post("{!!yzWebFullUrl('member.member-group.update')!!}", {
  96. group_id: id,
  97. group: this.isCount > 1 ? {
  98. group_name: this.form.groupName
  99. } : ""
  100. }).then(res => {
  101. console.log(res);
  102. if (this.isCount == 1) {
  103. let {
  104. groupModel: model
  105. } = res.body.data
  106. // 分组数据
  107. this.form.groupName = model.group_name;
  108. } else {
  109. if (res.data.result == 1) {
  110. this.$message.success(res.data.msg);
  111. window.history.back(-1)
  112. } else {
  113. this.$message.error(res.data.msg);
  114. }
  115. }
  116. })
  117. },
  118. //添加数据
  119. postAddgroup() {
  120. this.$http.post("{!!yzWebFullUrl('member.member-group.store')!!}", {
  121. group: {
  122. group_name: this.form.groupName
  123. }
  124. }).then(res => {
  125. console.log(res);
  126. if (res.data.result === 1) {
  127. this.$message.success("添加分组成功")
  128. window.history.back(-1)
  129. } else {
  130. this.$message.error("添加分组失败")
  131. }
  132. // console.log(res);
  133. })
  134. },
  135. //提交
  136. submit() {
  137. if (this.isid) {
  138. this.isCount++
  139. //提交修改
  140. // this.postSetUpdateGroup(this.id);
  141. this.postUpdateGroup(this.id)
  142. } else {
  143. //提交添加
  144. this.postAddgroup();
  145. }
  146. },
  147. //跳转
  148. returnList() {
  149. window.history.back(-1)
  150. // window.location.href="http://127.0.0.2/web/index.php?c=site&a=entry&m=yun_shop&do=8113&route=member.member-group.index";
  151. }
  152. }
  153. })
  154. </script>@endsection