editFoodClassify.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class='content'>
  3. <view class='wrap'>
  4. <view class='caution'>注意:分类排序决定顾客端显示的顺序</view>
  5. <view class='flex justify-space-between align-item-center' v-for='item in classifyList'>
  6. <view>{{item.classifyName}}({{item.dishesNum?item.dishesNum:0}})</view>
  7. <view class='flex'>
  8. <view class='button' @click='sticky(item)'>置顶</view>
  9. <view v-if='!item.dishesNum' class='button' @click='del(item)'>删除</view>
  10. <view v-else class='unable_button'>删除</view>
  11. <view class='button' @click='edit(item)'>编辑</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="mercharts_footer">
  16. <button @click='submit' class="submit">新增</button>
  17. </view>
  18. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  19. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay>
  20. <view class="slot-content">
  21. <view v-if="status==0">
  22. 确定删除"{{currectData.classifyName}}"分类?
  23. </view>
  24. <view v-else>
  25. <u--input inputAlign='center' v-model="classifyName" placeholder="输入分类名称" border="none"></u--input>
  26. </view>
  27. </view>
  28. </u-modal>
  29. </view>
  30. </template>
  31. <script>
  32. var that
  33. export default {
  34. data() {
  35. return {
  36. currect:{},
  37. currectData:{},
  38. classifyList:[],
  39. status:0,
  40. classifyName:'',
  41. form:{},
  42. isSubmit:false,
  43. }
  44. },
  45. onLoad() {
  46. that = this
  47. },
  48. onShow(){
  49. if(uni.getStorageSync('myCateringdustry')){
  50. this.currect=JSON.parse(uni.getStorageSync('myCateringdustry'))
  51. this.getList()
  52. }
  53. },
  54. methods: {
  55. edit(item){
  56. this.currectData=item
  57. this.status=2
  58. this.isSubmit = true
  59. },
  60. del(item){
  61. this.currectData=item
  62. this.status=0
  63. this.isSubmit = true
  64. },
  65. submit(){
  66. this.status=1
  67. this.isSubmit = true
  68. },
  69. confirmSubmit() {
  70. this.form.foodId=this.currect.id
  71. this.form.classifyName=this.classifyName
  72. this.currectData.classifyName=this.classifyName
  73. uni.showLoading({
  74. title: '加载中',
  75. mask: true
  76. })
  77. var text ='',parameter='',data={}
  78. if(this.status==0){
  79. parameter='delete'
  80. data={
  81. id: this.currectData.id
  82. }
  83. text=`删除成功`
  84. }else if(this.status==1){
  85. parameter='add'
  86. data={
  87. dishClassifyInfo: JSON.stringify(this.form)
  88. }
  89. text=`新增成功`
  90. }else if(this.status==2){
  91. parameter='update'
  92. data={
  93. dishClassifyInfo: JSON.stringify(this.currectData)
  94. }
  95. text=`编辑成功`
  96. }
  97. this.$request.baseRequest('admin.tourism.dishClassifyInfo', parameter, data, failres => {
  98. uni.showToast({
  99. icon: "none",
  100. title: failres.errmsg,
  101. duration: 3000
  102. });
  103. uni.hideLoading()
  104. }).then(res => {
  105. this.isSubmit = false
  106. uni.showToast({
  107. icon: "success",
  108. title: text,
  109. duration: 2000
  110. });
  111. this.getList()
  112. })
  113. },
  114. sticky(item){
  115. this.$request.baseRequest('admin.tourism.dishClassifyInfo', 'top', {
  116. dishClassifyInfo: JSON.stringify(item)
  117. }, failres => {
  118. uni.showToast({
  119. icon: "none",
  120. title: failres.errmsg,
  121. duration: 3000
  122. });
  123. uni.hideLoading()
  124. }).then(res => {
  125. uni.showToast({
  126. icon: "success",
  127. title: '置顶成功',
  128. duration: 2000
  129. });
  130. this.getList()
  131. })
  132. },
  133. getList(){
  134. this.$request.baseRequest('admin.tourism.dishClassifyInfo', 'list', {
  135. foodId:this.currect.id,
  136. page:1,
  137. limit:9999
  138. }, failres => {
  139. uni.showToast({
  140. icon: "none",
  141. title: failres.errmsg,
  142. duration: 3000
  143. });
  144. }).then(res => {
  145. this.classifyList = res.data.items
  146. })
  147. },
  148. }
  149. }
  150. </script>
  151. <style lang='scss' scoped>
  152. .button,.unable_button{
  153. margin:5px;
  154. }
  155. </style>