fenlei.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view>
  3. <view v-for="(item,index) in list" :key="index" class="flex padding justify-between">
  4. <view class="flex align-center">
  5. <view class="text-bold text-xl">{{index+1}}.</view>
  6. <view class="margin-left-xs">{{item.classifyName}}</view>
  7. </view>
  8. <view class="flex align-center">
  9. <view class="btn margin-right-sm" @click="addtype(2,item)">修改</view>
  10. <view class="btn" @click="bindupdata(item)">删除</view>
  11. </view>
  12. </view>
  13. <empty v-if="list.length == 0" content="暂无数据"></empty>
  14. <view class="addguige text-bold" @click="addtype(1)">添加</view>
  15. <!-- 添加规格弹框 -->
  16. <u-popup v-model="show" mode="center" border-radius="14" width="500rpx" height="400rpx">
  17. <view>
  18. <view class="padding" style="margin-bottom: 20rpx;">
  19. <view>商品分类</view>
  20. <view class="flex align-center" style="margin-top: 15rpx;">
  21. <label style="margin-right: 10rpx;">分类名称</label><u-input v-model="typeName" placeholder="请填写分类名称" clearable="false" />
  22. </view>
  23. <view class="flex align-center" style="margin-top: 15rpx;">
  24. <label style="margin-right: 10rpx;">分类排序</label><u-number-box v-model="sort" placeholder="请填写分类排序"></u-number-box>
  25. </view>
  26. </view>
  27. <view class="addguiges" @click="bindAdd()">确定</view>
  28. </view>
  29. </u-popup>
  30. </view>
  31. </template>
  32. <script>
  33. import empty from '@/components/empty.vue'
  34. export default {
  35. components: {
  36. empty
  37. },
  38. data() {
  39. return {
  40. list: [{
  41. id: 1,
  42. name: '清爽夏日',
  43. }, {
  44. id: 2,
  45. name: '牛奶系列',
  46. }, {
  47. id: 3,
  48. name: '鲜榨果汁',
  49. }],
  50. show: false,
  51. typeName: '',
  52. sort:0,
  53. classifyId: '',
  54. shopId: '',
  55. shopName: '',
  56. }
  57. },
  58. onLoad() {
  59. uni.showLoading({
  60. title: '数据加载中...',
  61. mask: false
  62. })
  63. this.shopId = this.$queue.getData("shopId")
  64. this.shopName = this.$queue.getData("shopUserName")
  65. this.getlist()
  66. },
  67. methods: {
  68. addtype(index, item) {
  69. console.log(index, item)
  70. if (index == 1) {
  71. this.show = true
  72. this.typeName = ''
  73. this.classifyId = ''
  74. this.sort = 0
  75. } else if (index == 2) {
  76. this.show = true
  77. this.typeName = item.classifyName
  78. this.classifyId = item.classifyId
  79. if(item.sort){
  80. this.sort = item.sort
  81. }else{
  82. this.sort = 0
  83. }
  84. }
  85. },
  86. //添加商品类型
  87. bindAdd() {
  88. if (!this.typeName) {
  89. uni.showToast({
  90. title: '请填写商品类型',
  91. icon: 'none',
  92. duration: 1000
  93. })
  94. return
  95. }
  96. console.log(this.classifyId)
  97. if (this.classifyId) {
  98. let data = {
  99. classifyId: this.classifyId,
  100. classifyName: this.typeName,
  101. shopId: this.shopId,
  102. shopName: this.shopName,
  103. sort:this.sort,
  104. }
  105. this.$Request.postJson("/admin/goods/updateClassify", data).then(res => {
  106. if (res.code == 0) {
  107. // this.list = res.data
  108. this.show = false
  109. this.typeName = ''
  110. this.classifyId = ''
  111. this.sort = 0
  112. this.getlist()
  113. }
  114. })
  115. } else {
  116. let data = {
  117. classifyName: this.typeName,
  118. shopId: this.shopId,
  119. shopName: this.shopName,
  120. sort:this.sort
  121. }
  122. this.$Request.postJson("/admin/goods/insertClassify", data).then(res => {
  123. if (res.code == 0) {
  124. // this.list = res.data
  125. this.show = false
  126. this.typeName = ''
  127. this.classifyId = ''
  128. this.sort = 0
  129. this.getlist()
  130. }
  131. })
  132. }
  133. },
  134. //获取分类列表
  135. getlist() {
  136. let data = {
  137. shopId: this.shopId
  138. }
  139. this.$Request.getA("/admin/goods/selectAllClassify", data).then(res => {
  140. uni.hideLoading()
  141. if (res.code == 0) {
  142. this.list = res.data
  143. }
  144. })
  145. },
  146. //删除商品类型
  147. bindupdata(e) {
  148. console.log(e)
  149. uni.showModal({
  150. title: '提示',
  151. content: '确定要删除当前类型吗?',
  152. cancelText: "取消", // 取消按钮的文字
  153. confirmText: "确定", // 确认按钮文字
  154. showCancel: true, // 是否显示取消按钮,默认为 true
  155. confirmColor: '#f55850',
  156. cancelColor: '#39B54A',
  157. success: (res) => {
  158. if (res.confirm) {
  159. let data = {
  160. classifyId: e.classifyId
  161. }
  162. this.$Request.getA("/admin/goods/deleteClassify", data).then(res => {
  163. if (res.code == 0) {
  164. uni.showToast({
  165. title: "删除成功",
  166. icon: 'none'
  167. })
  168. this.getlist();
  169. } else {
  170. uni.showModal({
  171. title: '提示',
  172. content: res.msg,
  173. success: function (res) {
  174. if (res.confirm) {
  175. } else if (res.cancel) {
  176. }
  177. }
  178. });
  179. }
  180. });
  181. }
  182. }
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style>
  189. page {
  190. background: #FFFFFF;
  191. }
  192. .btn {
  193. border: 2upx solid #999999;
  194. border-radius: 24px;
  195. color: #333333;
  196. padding: 5rpx 30rpx;
  197. }
  198. .addguige {
  199. width: 90%;
  200. margin: 0 auto;
  201. background: #FCD202;
  202. box-shadow: 0px 10upx 20upx 0px #FFD9B3;
  203. border-radius: 16upx;
  204. text-align: center;
  205. height: 88upx;
  206. line-height: 88upx;
  207. position: fixed;
  208. bottom: 25upx;
  209. left: 0;
  210. right: 0;
  211. }
  212. .addguiges {
  213. width: 90%;
  214. margin: 0 auto;
  215. background: #FCD202;
  216. box-shadow: 0px 10upx 20upx 0px #FFD9B3;
  217. border-radius: 16upx;
  218. text-align: center;
  219. height: 88upx;
  220. line-height: 88upx;
  221. /* position: fixed;
  222. bottom: 25upx;
  223. left: 0;
  224. right: 0; */
  225. }
  226. </style>