Browse Source

feat: plan-t

lhl 10 months ago
parent
commit
d6ac78a025
3 changed files with 69 additions and 33 deletions
  1. 6 0
      src/api/plan/index.ts
  2. 54 33
      src/views/Plan/list/index.vue
  3. 9 0
      src/views/Store/list/index.vue

+ 6 - 0
src/api/plan/index.ts

@@ -21,3 +21,9 @@ export const editPlan = (data: any): Promise<IResponse> => {
 export const delPlan = (id: number): Promise<IResponse> => {
   return request.delete({ url: `${REQUEST_BASE}/store/${id}` })
 }
+
+export const recommendPlan = (data: any): Promise<IResponse> => {
+  return request.put({
+    url: `${REQUEST_BASE}/decoration/cases/recommend/${data.id}/${data.recommend}`
+  })
+}

+ 54 - 33
src/views/Plan/list/index.vue

@@ -1,6 +1,6 @@
 <script setup lang="tsx">
 import { reactive, ref, unref } from 'vue'
-import { getPlanList } from '@/api/plan'
+import { getPlanList, recommendPlan } from '@/api/plan'
 import { useTable } from '@/hooks/web/useTable'
 import { useI18n } from '@/hooks/web/useI18n'
 import { Table, TableColumn } from '@/components/Table'
@@ -9,7 +9,7 @@ import { FormSchema } from '@/components/Form'
 import { ContentWrap } from '@/components/ContentWrap'
 import { Dialog } from '@/components/Dialog'
 import { BaseButton } from '@/components/Button'
-import { ElTag } from 'element-plus'
+import { ElMessage, ElTag } from 'element-plus'
 import { TableImage } from '@/components/tableImage'
 // import Write from './components/Write.vue'
 
@@ -124,8 +124,8 @@ const tableColumns = reactive<TableColumn[]>([
     width: 120
   },
   {
-    field: 'status',
-    label: '是否展示',
+    field: 'is_recommend',
+    label: '是否推荐',
     width: 150,
     slots: {
       default: ({ row }: any) => {
@@ -133,9 +133,11 @@ const tableColumns = reactive<TableColumn[]>([
           <>
             <ElTag
               class="mr-5px"
-              type={row.status == 0 ? 'primary' : row.status == 1 ? 'success' : 'danger'}
+              type={
+                row.is_recommend == 0 ? 'warning' : row.is_recommend == 1 ? 'success' : 'danger'
+              }
             >
-              {row.status_chs}
+              {row.is_recommend == 0 ? '否' : '是'}
             </ElTag>
           </>
         )
@@ -143,34 +145,35 @@ const tableColumns = reactive<TableColumn[]>([
     }
   },
   {
-    field: 'reason',
-    label: '审核意见',
-    width: 120
+    field: 'action',
+    label: t('userDemo.action'),
+    width: 200,
+    fixed: 'right',
+    align: 'center',
+    headerAlign: 'center',
+    slots: {
+      default: (data: any) => {
+        const row = data.row
+        if (row.is_recommend == 1) {
+          return (
+            <>
+              <BaseButton link size="small" type="warning" onClick={() => changeStatus(0, row)}>
+                取消推荐
+              </BaseButton>
+            </>
+          )
+        } else {
+          return (
+            <>
+              <BaseButton link size="small" type="primary" onClick={() => changeStatus(1, row)}>
+                推荐
+              </BaseButton>
+            </>
+          )
+        }
+      }
+    }
   }
-  // {
-  //   field: 'action',
-  //   label: t('userDemo.action'),
-  //   width: 200,
-  //   fixed: 'right',
-  //   align: 'center',
-  //   headerAlign: 'center',
-  //   slots: {
-  //     default: (data: any) => {
-  //       const row = data.row
-  //       return (
-  //         <>
-  //           <BaseButton link size="small" type="primary" onClick={() => action('edit', row)}>
-  //             编辑
-  //           </BaseButton>
-  //           <ElDivider direction="vertical" />
-  //           <BaseButton link size="small" type="danger" onClick={() => delAction(row)}>
-  //             删除
-  //           </BaseButton>
-  //         </>
-  //       )
-  //     }
-  //   }
-  // }
 ])
 
 const searchSchema = reactive<FormSchema[]>([
@@ -271,6 +274,24 @@ const saveLoading = ref(false)
 //     })
 //     .catch(() => {})
 // }
+const changeStatus = async (is_recommend, row) => {
+  const data: any = {
+    id: row.id,
+    recommend: is_recommend
+  }
+  try {
+    await recommendPlan(data)
+    getList()
+    ElMessage({
+      showClose: true,
+      message: '设置成功',
+      type: 'success'
+    })
+  } catch (error) {
+    console.log(error)
+  } finally {
+  }
+}
 const save = async () => {
   // // const write = unref(writeRef)
   // // const formData = await write?.submit()

+ 9 - 0
src/views/Store/list/index.vue

@@ -186,6 +186,15 @@ const searchSchema = reactive<FormSchema[]>([
         }
       ]
     }
+  },
+  {
+    field: 'name',
+    label: '名称',
+    component: 'Input',
+    value: '',
+    componentProps: {
+      placeholder: '请输入门店名称'
+    }
   }
 ])