浏览代码

yb11.6可添加分类

jwyu 2 年之前
父节点
当前提交
198084073e
共有 2 个文件被更改,包括 60 次插入3 次删除
  1. 8 0
      src/api/hzyb/chart.js
  2. 52 3
      src/views/hzyb/chart/component/collectBox.vue

+ 8 - 0
src/api/hzyb/chart.js

@@ -103,4 +103,12 @@ export const apiMyChartClassifyList=()=>{
  */
 export const apiMyChartRelateClassify=params=>{
     return post('/my_chart/relate_classify',params)
+}
+
+/**
+ * 新增我的图库分类
+ * @param classify_name
+ */
+export const apiMyChartClassifyAdd=params=>{
+    return post('/my_chart_classify/add',params)
 }

+ 52 - 3
src/views/hzyb/chart/component/collectBox.vue

@@ -1,8 +1,9 @@
 <script setup>
-import {apiChartIsCollect,apiChartCollectCancel,apiChartCollect,apiMyChartClassifyList,apiMyChartRelateClassify} from '@/api/hzyb/chart'
+import {apiChartIsCollect,apiChartCollectCancel,apiChartCollect,apiMyChartClassifyList,apiMyChartRelateClassify,apiMyChartClassifyAdd} from '@/api/hzyb/chart'
 import { reactive, ref, watch } from 'vue'
 import { useRoute } from 'vue-router'
-import { Toast, Popup } from 'vant';
+import { Toast, Popup,Dialog } from 'vant'
+const VanDialog = Dialog.Component;
 
 const route=useRoute()
 
@@ -100,8 +101,32 @@ async function getClassify(){
     }
 }
 
+//添加分类
+let showAdd=ref(false)
+let inputClassifyVal=ref('')
+async function handleConfirmAdd(){
+    if(!inputClassifyVal.value){
+        Toast('请输入分类名称')
+        return
+    }
+    const res=await apiMyChartClassifyAdd({
+        classify_name:inputClassifyVal.value
+    })
+    if(res.code===200){
+        Toast.success('新增成功')
+        showAdd.value=false
+        inputClassifyVal.value=''
+    }
+}
+
+
 // 确定转移
 async function handleTrans(){
+    if(transData.list.length===0){
+        showAdd.value=true
+        showTrans.value=false
+        return
+    }
     if(!transData.selectId){
         Toast('请选择分类')
         return
@@ -147,7 +172,8 @@ window.addEventListener('message',e=>{
     >   
         <div class="mobile-trans-box">
             <div class="label">转移图表</div>
-            <div class="list">
+            <div v-if="transData.list.length==0" style="line-height:250px;text-align:center">暂无分类,请先添加分类!</div>
+            <div class="list" v-else>
                 <div 
                     :class="['item',item.my_chart_classify_id==transData.selectId?'active':'']" 
                     v-for="item in transData.list" 
@@ -158,6 +184,19 @@ window.addEventListener('message',e=>{
             <div class="btn" @click="handleTrans">确定</div>
         </div>
     </Popup>
+
+    <!-- 添加分类弹窗 -->
+    <van-dialog 
+        v-model:show="showAdd" 
+        title="添加分类" 
+        show-cancel-button
+        confirm-button-text="确定"
+        @cancel="showAdd=false"
+        @confirm="handleConfirmAdd"
+    >
+        <input class="add-input" v-model="inputClassifyVal" maxlength="10" type="text" placeholder="请输入分类名称">
+        <p style="color:#999;padding-left:10%;margin-bottom:40rpx;font-size:12px">注:字数控制在10个字以内!</p>
+    </van-dialog>
 </template>
 
 <style lang="scss" scoped>
@@ -241,4 +280,14 @@ window.addEventListener('message',e=>{
     }
 }
 
+
+.add-input{
+    display: block;
+    width: 80%;
+    background: #F7F8FA;
+    border-radius: 8px;
+    padding: 20px;
+    margin: 30px auto 10px auto;
+    border: none;
+}
 </style>