xuwenqiang1992 2 vuotta sitten
vanhempi
commit
ad3103d05f

+ 71 - 4
src/api/store/index.ts

@@ -1,34 +1,101 @@
 // @ts-nocheck
 import request from "@/utils/request";
+
 //生成门店平台授权地址
 export function generateStoreAuthUrl_Douyin(data) {
     return request({
         url: "/store/generateStoreAuthUrl_Douyin",
         method: "post",
-        data: data,
+        params: data,
     });
 }
+
+//禁用启用
+export function voidStoreBrand(data) {
+    return request({
+        url: "/store/voidStoreBrand",
+        method: "post",
+        params: data,
+    });
+}
+
+//修改门店品牌
+export function updateStoreBrand(data) {
+    return request({
+        url: "/store/updateStoreBrand",
+        method: "post",
+        params: data,
+    });
+}
+
 //新增门店品牌
 export function addStoreBrand(data) {
     return request({
         url: "/store/addStoreBrand",
         method: "post",
-        data: data,
+        params: data
+    });
+}
+
+//获取品牌详情
+export function getStoreBrand(data) {
+    return request({
+        url: "/store/getStoreBrand",
+        method: "get",
+        params: data,
+    });
+}
+
+//获取门店品牌列表
+export function queryStoreBrandList(data) {
+    return request({
+        url: "/store/queryStoreBrandList",
+        method: "get",
+        params: data,
+    });
+}
+
+//禁用启用
+export function voidStoreInfo(data) {
+    return request({
+        url: "/store/voidStoreInfo",
+        method: "post",
+        params: data,
+    });
+}
+
+//修改门店
+export function updateStoreInfo(data) {
+    return request({
+        url: "/store/updateStoreInfo",
+        method: "post",
+        params: data,
     });
 }
+
 //新增门店
 export function addStoreInfo(data) {
     return request({
         url: "/store/addStoreInfo",
         method: "post",
-        data: data,
+        params: data,
     });
 }
+
 //获取门店
 export function queryViewStoreInfo(data) {
     return request({
         url: "/store/queryViewStoreInfo",
         method: "get",
-        data: data,
+        params: data,
+    });
+}
+
+//获取门店详情
+export function getViewStoreInfo(data) {
+    return request({
+        url: "/store/getViewStoreInfo",
+        method: "get",
+        params: data,
     });
 }

+ 0 - 2
src/permission.ts

@@ -33,13 +33,11 @@ router.beforeEach(async (to, from, next) => {
       }else {
         try {
           const result = await userStore.getUserInfo();
-          // console.log(result);
           userStore.user.userInfo = result.user
           const accessRoutes = await permissionStore.generateRoutes(result.menus);
           accessRoutes.forEach((route) => {
             router.addRoute(route);
           });
-          // console.log("0000",accessRoutes);
           userStore.user.init = true
           next({ ...to, replace: true });
         } catch (error) {

+ 1 - 1
src/store/modules/permission.ts

@@ -20,7 +20,7 @@ const filterAsyncRoutes = (routerList) => {
   routerList.forEach((e) => {
     // console.log(e.component);
     let e_new = {
-      path: e.route,
+      path: e.route??'test',
       name: e.pathName,
       meta: {
         hidden: e.visible==1?false:true,

+ 135 - 0
src/views/store/storeBrand/compt/childDialog.vue

@@ -0,0 +1,135 @@
+<template>
+  <div class="dialog">
+    <el-dialog
+        v-model="dialogVisible"
+        :title="dialogTitle"
+        width="480"
+        @close="closeDialog()"
+    >
+      <el-form
+          ref="formRef"
+          :model="formData"
+          :rules="rules"
+          label-width="120px"
+      >
+        <el-row>
+          <el-col :span="24">
+            <el-form-item prop="brandName" label="品牌名称">
+              <el-input v-model="formData.brandName"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item prop="startingPrice" label="基础费用">
+              <el-input v-model="formData.startingPrice"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item prop="packagingFee" label="包装费用">
+              <el-input v-model="formData.packagingFee"/>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item prop="brandMemo" label="备注">
+              <el-input v-model="formData.brandMemo"/>
+            </el-form-item>
+          </el-col>
+        </el-row>
+
+      </el-form>
+
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button v-throttle type="primary" @click="handleSubmit">确 定</el-button>
+          <el-button @click="closeDialog()">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+<script setup lang="ts">
+import {getStoreBrand, addStoreBrand, updateStoreBrand} from "@/api/store";
+import type {FormInstance} from 'element-plus'
+
+let dialogVisible = ref(false)
+let dialogTitle = ref("")
+const formRef = ref<FormInstance>()
+const emit = defineEmits(['dialogChange'])
+const formData = reactive({
+  brandName:'',
+  startingPrice:'',
+  packagingFee:'',
+  brandMemo:'',
+  id: ""
+})
+const rules = reactive({
+  brandName: [{required: true, message: "请输入名称", trigger: "blur"}],
+});
+function handleSubmit() {
+  formRef.value.validate((valid: any) => {
+    if (valid) {
+      const itemId = formData.id;
+      if (itemId) {
+        //修改
+        const postData = JSON.stringify(formData)
+        const params = {
+          "storeBrand": postData
+        }
+        updateStoreBrand(params).then((response) => {
+          dialogVisible.value = false
+          if (response.httpCode == 200) {
+            emit('dialogChange');
+            ElMessage.success("操作成功");
+          }
+        })
+      } else {
+        //增加
+        const postData = JSON.stringify(formData)
+        const params = {
+          "storeBrand": postData
+        }
+        addStoreBrand(params).then((response) => {
+          dialogVisible.value = false
+          if (response.httpCode == 200) {
+            emit('dialogChange');
+            ElMessage.success("操作成功");
+          }
+        })
+      }
+    }
+  });
+}
+
+function getItemData(item) {
+  const data = {
+    idStoreBrand: item
+  }
+  getStoreBrand(data).then(response => {
+    if (response.httpCode == 200) {
+      const data = response.data
+      Object.assign(formData, {...data});
+    }
+  })
+}
+
+/**  重置表单 */
+function resetForm() {
+  formRef.value.resetFields();
+  formData.id = ''
+}
+
+/**关闭弹窗 */
+function closeDialog() {
+  dialogVisible.value = false
+  formRef.value.resetFields();
+  formData.id = undefined;
+}
+defineExpose({
+  dialogVisible,
+  dialogTitle,
+  getItemData,
+  resetForm
+})
+</script>
+<style scoped lang="scss">
+
+</style>

+ 164 - 0
src/views/store/storeBrand/index.vue

@@ -0,0 +1,164 @@
+<template>
+  <div class="app-container">
+    <div class="filter-container">
+      <el-input @keyup.enter="handleSearch" class="w200px mr5px" v-model="queryForm.keyWord" placeholder="关键字搜索"/>
+      <el-button type="primary" @click="handleSearch">
+        <i-ep-search/>
+        搜索
+      </el-button>
+      <div class="w100px ml10px" style="display: inline-block;">
+        <el-checkbox style="position: absolute;top: 11px" v-model="disableLock" label="已禁用"
+                     border></el-checkbox>
+      </div>
+      <el-button @click="openDialog()" color="#11a983">
+        <i-ep-plus/>
+        增加门店品牌
+      </el-button>
+      <el-button type="primary" @click="refreshTableInfo">
+        <i-ep-refresh/>
+      </el-button>
+    </div>
+    <div class="table-con">
+      <el-table
+        :max-height="tableHeight"
+        v-loading="loading"
+        :data="tableData"
+        highlight-current-row
+        border
+      >
+        <el-table-column label="操作" width="140">
+          <template #default="{row}">
+            <el-button link @click="openDialog(row.id)" type="primary">
+              <i-ep-edit/>
+              编辑
+            </el-button>
+            <el-button v-if="row.enable==1" link @click="handleDisable(row.id,0)" type="warning">禁用</el-button>
+            <el-button v-if="row.enable==0" type="success" link @click="handleDisable(row.id,1)">启用</el-button>
+          </template>
+        </el-table-column>
+        <el-table-column
+          type="index"
+          label="#"
+          width="50">
+          <template #default="scope">
+            <span>{{ scope.$index + 1 }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="industryCode" width="150" label="客户行业代码"/>
+        <el-table-column prop="industryName" width="350" label="客户行业名称"/>
+        <el-table-column
+          prop="status"
+          label="状态">
+          <template #default="{row}">
+            <el-tag v-if="row.voidFlag==0" type="success">
+              正常
+            </el-tag>
+            <el-tag v-else="row.voidFlag==1" type="danger">
+              停用
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="createTime"
+          label="创建时间"
+          width="155">
+          <template #default="{row}">
+          <span v-if="row.createTime">
+           {{ $filters.getTime(row.createTime)}}
+          </span>
+          </template>
+        </el-table-column>
+      </el-table>
+      <pagination
+        v-if="total > 0"
+        v-model:total="total"
+        v-model:page="queryPage.pageIndex"
+        v-model:limit="queryPage.pageSize"
+        @pagination="getTableData"
+      />
+    </div>
+    <child-dialog ref="childDialog" @dialogChange="dialogChange"></child-dialog>
+  </div>
+</template>
+<script setup lang="ts">
+import {queryStoreBrandList,voidStoreBrand} from "@/api/store";
+import ChildDialog from './compt/childDialog.vue'
+import {useTable} from '@/hooks/useTable'
+
+let disableLock = ref('')
+const childDialog = ref<any>()
+
+//增加编辑
+function openDialog(item?: any) {
+  childDialog.value.dialogVisible = true;
+  if (item) {
+    childDialog.value.dialogTitle = "编辑";
+    nextTick(() => {
+      childDialog.value.getItemData(item)
+    });
+  } else {
+    nextTick(() => {
+      childDialog.value.dialogTitle = "增加";
+      childDialog.value.resetForm()
+    })
+
+
+  }
+}
+
+//禁用删除
+function handleDisable(id, status) {
+  ElMessageBox.confirm("确认操作?", "警告", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  }).then(() => {
+    const postData = {
+      id: id,
+      voidFlag: status
+    }
+    const params = {
+      "industryInfo": JSON.stringify(postData)
+    }
+    voidStoreBrand(params).then((response) => {
+      if (response.httpCode == 200) {
+        ElMessage.success("操作成功");
+        getTableData();
+      }
+
+    })
+  })
+}
+
+//修改成功后传递事件
+function dialogChange() {
+  getTableData()
+}
+
+const queryForm = reactive({
+  keyWord: '',
+  voidFlag: 0
+})
+watch(
+  () => disableLock.value,
+  (disableLock) => {
+    if (disableLock) {
+      queryForm.enable = 0
+      getTableData()
+    } else {
+      queryForm.enable = 1
+      getTableData()
+    }
+  }
+);
+const {
+  tableData,
+  queryPage,
+  total,
+  loading,
+  getTableData,
+  tableHeight,
+  handleSearch,//搜索
+  refreshTableInfo,//刷新
+} = useTable(queryStoreBrandList, queryForm);
+</script>