123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <view class='content'>
- <view class='wrap'>
- <view class='caution'>注意:分类排序决定顾客端显示的顺序</view>
- <view class='flex justify-space-between align-item-center' v-for='item in classifyList'>
- <view>{{item.classifyName}}({{item.dishesNum?item.dishesNum:0}})</view>
- <view class='flex'>
- <view class='button' @click='sticky(item)'>置顶</view>
- <view v-if='!item.dishesNum' class='button' @click='del(item)'>删除</view>
- <view v-else class='unable_button'>删除</view>
- <view class='button' @click='edit(item)'>编辑</view>
- </view>
- </view>
- </view>
- <view class="mercharts_footer">
- <button @click='submit' class="submit">新增</button>
- </view>
- <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
- @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay>
- <view class="slot-content">
- <view v-if="status==0">
- 确定删除"{{currectData.classifyName}}"分类?
- </view>
- <view v-else>
- <u--input inputAlign='center' v-model="classifyName" placeholder="输入分类名称" border="none"></u--input>
- </view>
- </view>
- </u-modal>
- </view>
- </template>
- <script>
- var that
- export default {
- data() {
- return {
- currect:{},
- currectData:{},
- classifyList:[],
- status:0,
- classifyName:'',
- form:{},
- isSubmit:false,
- }
- },
- onLoad() {
- that = this
- },
- onShow(){
- if(uni.getStorageSync('myCateringdustry')){
- this.currect=JSON.parse(uni.getStorageSync('myCateringdustry'))
- this.getList()
- }
-
- },
- methods: {
- edit(item){
- this.currectData=item
- this.status=2
- this.isSubmit = true
- },
- del(item){
- this.currectData=item
- this.status=0
- this.isSubmit = true
- },
- submit(){
- this.status=1
- this.isSubmit = true
- },
- confirmSubmit() {
- this.form.foodId=this.currect.id
- this.form.classifyName=this.classifyName
- this.currectData.classifyName=this.classifyName
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- var text ='',parameter='',data={}
- if(this.status==0){
- parameter='delete'
- data={
- id: this.currectData.id
- }
- text=`删除成功`
- }else if(this.status==1){
- parameter='add'
- data={
- dishClassifyInfo: JSON.stringify(this.form)
- }
- text=`新增成功`
- }else if(this.status==2){
- parameter='update'
- data={
- dishClassifyInfo: JSON.stringify(this.currectData)
- }
- text=`编辑成功`
- }
- this.$request.baseRequest('admin.tourism.dishClassifyInfo', parameter, data, failres => {
- uni.showToast({
- icon: "none",
- title: failres.errmsg,
- duration: 3000
- });
-
- uni.hideLoading()
- }).then(res => {
- this.isSubmit = false
- uni.showToast({
- icon: "success",
- title: text,
- duration: 2000
- });
- this.getList()
-
- })
- },
- sticky(item){
- this.$request.baseRequest('admin.tourism.dishClassifyInfo', 'top', {
- dishClassifyInfo: JSON.stringify(item)
- }, failres => {
- uni.showToast({
- icon: "none",
- title: failres.errmsg,
- duration: 3000
- });
-
- uni.hideLoading()
- }).then(res => {
- uni.showToast({
- icon: "success",
- title: '置顶成功',
- duration: 2000
- });
- this.getList()
- })
- },
- getList(){
- this.$request.baseRequest('admin.tourism.dishClassifyInfo', 'list', {
- foodId:this.currect.id,
- page:1,
- limit:9999
- }, failres => {
- uni.showToast({
- icon: "none",
- title: failres.errmsg,
- duration: 3000
- });
- }).then(res => {
- this.classifyList = res.data.items
- })
- },
- }
- }
- </script>
- <style lang='scss' scoped>
- .button,.unable_button{
- margin:5px;
- }
- </style>
|