Browse Source

fix:C端我得店铺页面联调

lazy 3 weeks ago
parent
commit
24c5a7e494

+ 45 - 0
src/api/myStoreEnterprise.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+
+// 获取店铺列表
+export function getStoreList(params) {
+  return request({
+    url: '/shop/c/list',
+    method: 'get',
+    params
+  })
+}
+
+// 查看可选的企业
+export function getAllEnterprise(params) {
+  return request({
+    url: '/company/c/allList',
+    method: 'get',
+    params
+  })
+}
+
+// 新增店铺
+export function addShopStore(data) {
+  return request({
+    url: '/shop/add',
+    method: 'post',
+    data
+  })
+}
+
+// 绑定企业
+export function bindEnterprise(data) {
+  return request({
+    url: '/shop/bindCompany',
+    method: 'put',
+    data
+  })
+}
+
+// 解除绑定的企业
+export function unBindEnterprise(data) {
+  return request({
+    url: `/shop/unbindCompany/${data}`,
+    method: 'put'
+  })
+}

+ 11 - 0
src/store/modules/constantData.js

@@ -32,5 +32,16 @@ export default {
       code: 'debtor',
       name: '债务人'
     }
+  ],
+  // 企业店铺管理--店铺状态
+  shopStatus: [
+    {
+      code: 0,
+      name: '关闭'
+    },
+    {
+      code: 1,
+      name: '正常'
+    }
   ]
 }

+ 4 - 4
src/views/myStoreEnterprise/components/AddStoreDialog.vue

@@ -2,7 +2,7 @@
   <cy-dialog ref="addStoreRef" :title="addSuccess ? '添加店铺' : '店铺准入'">
     <template v-if="!addSuccess">
       <el-form class="rule-form-orange" :model="ruleForm">
-        <el-form-item label="店铺名称" class="one-form-item">
+        <el-form-item label="店铺名称" style="width: 100%;">
           <el-select v-model="ruleForm.storeName" @change="storeNameChange">
             <el-option
               v-for="item in storeList"
@@ -12,7 +12,7 @@
             ></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="店铺ID" class="one-form-item">
+        <el-form-item label="店铺ID" style="width: 100%;">
           <el-input v-model="ruleForm.storeId" disabled></el-input>
         </el-form-item>
       </el-form>
@@ -22,8 +22,8 @@
     </template>
     <div slot="footer" class="dialog-footer">
       <el-button @click="closeDialog">取 消</el-button>
-      <el-button v-if="!addSuccess" @click="handleCertain">确 定</el-button>
-      <el-button v-if="addSuccess" @click="toGoEnterprisePage">确 定</el-button>
+      <el-button v-if="!addSuccess" @click="handleCertain" type="primary">确 定</el-button>
+      <el-button v-if="addSuccess" @click="toGoEnterprisePage" type="primary">确 定</el-button>
     </div>
   </cy-dialog>
 </template>

+ 119 - 0
src/views/myStoreEnterprise/components/BindEnterprise.vue

@@ -0,0 +1,119 @@
+<template>
+  <cy-dialog ref="addStoreRef" title="绑定企业">
+    <el-form class="rule-form-orange" :model="ruleForm">
+      <el-form-item label="企业名称" style="width: 100%" class="form-required">
+        <el-select v-model="ruleForm.enterpriseName" @change="enterpriseNameChange">
+          <el-option
+            v-for="item in allEnterpriseList"
+            :label="item.name"
+            :key="item.name"
+            :value="item.name"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="统一社会信用代码" style="width: 100%">
+        <el-input v-model="ruleForm.socialCreditCode" placeholder="请输入统一信用代码" disabled></el-input>
+      </el-form-item>
+    </el-form>
+    <div slot="footer" class="dialog-footer">
+      <el-button @click="closeDialog">取 消</el-button>
+      <el-button @click="handleCertain" type="primary">确 定</el-button>
+    </div>
+  </cy-dialog>
+</template>
+
+<script>
+import { getAllEnterprise, bindEnterprise } from '@/api/myStoreEnterprise'
+
+export default {
+  props: {
+    name: {
+      type: String,
+      default: ''
+    },
+    status: {
+      type: [String, Number],
+      default: ''
+    },
+    shopId: {
+      type: [String, Number],
+      default: ''
+    }
+  },
+  data() {
+    return {
+      ruleForm: {
+        enterpriseName: '',
+        socialCreditCode: ''
+      },
+      bindParams: {
+        shopId: '',
+        companyId: ''
+      },
+      allEnterpriseList: []
+    }
+  },
+  methods: {
+    initForm() {
+      this.ruleForm.enterpriseName = ''
+      this.ruleForm.socialCreditCode = ''
+    },
+    showAddEnterprise() {
+      this.initForm()
+      this.queryAllEnterprise()
+      this.$refs.addStoreRef.show = true
+    },
+    enterpriseNameChange(val) {
+      const find = this.allEnterpriseList.find(el => el.name === val)
+
+      if (find) {
+        this.ruleForm.socialCreditCode = find.code
+        this.bindParams.companyId = find.id
+      }
+    },
+    closeDialog() {
+      this.$refs.addStoreRef.show = false
+    },
+    async queryAllEnterprise() {
+      const res = await getAllEnterprise({ name: this.name, status: this.status })
+
+      if (res.success && res.data.length) {
+        this.allEnterpriseList = res.data
+      }
+    },
+    async handleCertain() {
+      this.bindParams.shopId = this.shopId
+      if (!this.ruleForm.enterpriseName) {
+        this.$message.warning('请选择要绑定的企业名称')
+        return
+      }
+      if (!this.bindParams.shopId) {
+        this.$message.warning('该企业没关联的店铺')
+        return
+      }
+      if (!this.bindParams.companyId) {
+        this.$message.warning('该企业不存在')
+        return
+      }
+
+      const res = await bindEnterprise({ ...this.bindParams })
+
+      if (res.success) {
+        this.$message.success('企业绑定成功')
+        this.closeDialog()
+        this.$router.go(0)
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.success-tip {
+  width: 100%;
+  height: 300px;
+  line-height: 300px;
+  font-size: #ebeb;
+  padding-left: 100px;
+}
+</style>

+ 89 - 44
src/views/myStoreEnterprise/components/Store.vue

@@ -8,21 +8,21 @@
         <div class="right" style="width: auto;">
           <div>
             <el-input
-              v-model="search.fastSearch"
-              placeholder="请输入店铺/企业名称"
+              v-model="search.shopName"
+              placeholder="请输入店铺名称"
               style="width: 180px !important; margin-right: 10px;"
             ></el-input>
             <el-select
-              v-model="search.transCode"
+              v-model="search.shopStatus"
               placeholder="请选择店铺状态"
               clearable
               style="width: 200px !important;"
             >
               <el-option
-                v-for="item in transCodeList"
-                :key="item"
-                :label="item"
-                :value="item"
+                v-for="item in constant.shopStatus"
+                :key="item.code"
+                :label="item.name"
+                :value="item.code"
               ></el-option>
             </el-select>
           </div>
@@ -38,35 +38,41 @@
         :table-options="tableOptions"
         :data="tableData"
         :count="total"
-        parent-component="LogManage"
       />
     </template>
     <AddStroe ref="addStoreRef" @goEnterprise="changeEnterprise" />
+    <BindEnterprise ref="bindEnterpriseRef" :name="curShopName" :status="curShopStatus" :shop-id="curShopId" />
   </div>
 </template>
 
 <script>
-// import { getAllTransCode, getSmbList } from '@/api/systemManage/smbLogManage/smbLogManage'
+import { mapGetters } from 'vuex'
+import { getStoreList, unBindEnterprise } from '@/api/myStoreEnterprise'
 
 export default {
   name: 'StoreList',
   components: {
-    AddStroe: () => import('./AddStoreDialog.vue')
+    AddStroe: () => import('./AddStoreDialog.vue'),
+    BindEnterprise: () => import('./BindEnterprise.vue')
   },
   data() {
     return {
       search: {
-        transCode: ''
+        shopName: '',
+        shopStatus: ''
       },
       transCodeList: [],
       total: 0,
       loading: false,
-      tableData: [{ enterpriseName: '1688' }],
+      tableData: [],
       tableOptions: {
         sortTable: true,
         maxHeight: 'calc(100vh - 395px)',
         height: 'calc(100vh - 395px)'
       },
+      curShopName: '',
+      curShopStatus: '',
+      curShopId: '',
       columns: [
         {
           label: '序号',
@@ -74,52 +80,57 @@ export default {
         },
         {
           label: '平台',
-          prop: 'platformName',
-          showTooltip: true
+          showTooltip: true,
+          render: (h, row) => {
+            return <div>{ this.getPlatformName(row.platformType) }</div>
+          }
         },
         {
           label: '企业名称',
-          prop: 'enterpriseName',
+          prop: 'companyName',
           showTooltip: true
         },
         {
           label: '统一社会信用代码',
           width: 160,
-          prop: 'socialCreditCode',
+          prop: 'code',
           showTooltip: true
         },
         {
           label: '店铺ID',
           showTooltip: true,
-          prop: 'storeId'
+          prop: 'platformShopId'
         },
         {
           label: '店铺名称',
-          prop: 'storeName',
+          prop: 'shopName',
           showTooltip: true
         },
         {
           label: '店铺状态',
-          prop: 'storeStatus',
-          showTooltip: true
+          prop: 'shopStatus',
+          showTooltip: true,
+          render: (h, row) => {
+            return <div>{ this.getShopStatus(row.shopStatus) }</div>
+          }
         },
         {
           label: '准入状态',
-          prop: 'enterStatus',
+          prop: 'zrStatus',
           showTooltip: true,
           render: (h, row) => {
-            return <div>{ row.success ? '成功' : '失败' }</div>
+            return <div>{ row.zrStatus ? '成功' : '失败' }</div>
           }
         },
         {
           label: '绑定账户名称',
-          prop: 'bindName',
+          prop: 'registrationName',
           width: 160,
           showTooltip: true
         },
         {
           label: '绑定账号',
-          prop: 'bindAccountNo',
+          prop: 'registrationAccount',
           showTooltip: true
         },
         {
@@ -135,7 +146,7 @@ export default {
             const btnList = [
               {
                 msg: '解绑企业',
-                icon: 'iconfont icon-icon-record',
+                icon: 'iconfont icon-a-Group1046',
                 power: '', // viewFinancingLoanInfo
                 rowPower: [],
                 category: 'unBindEnterprise'
@@ -159,7 +170,7 @@ export default {
               return (
                 this.tablePower({ item, row }) && <el-tooltip class='item' effect='dark' content={item.msg} placement='top' >
                   <span class='table-icon-box' v-power={item.power}>
-                    <i class={item.icon} onClick={() => { this.handlerOperate(item.category, row, item.msg) }}></i>
+                    <i class={item.icon} style='font-size: 21px;' onClick={() => { this.handlerOperate(item.category, row, item.msg) }}></i>
                   </span>
                 </el-tooltip>
               )
@@ -171,10 +182,8 @@ export default {
       ]
     }
   },
-  // mounted() {
-  //   this.fetchData()
-  // },
   computed: {
+    ...mapGetters(['constant']),
     tablePower() {
       return ({ item, row }) => {
         const { rowPower, category } = item
@@ -188,6 +197,9 @@ export default {
       }
     }
   },
+  mounted() {
+    this.fetchData()
+  },
   methods: {
     handleAddStore() {
       this.$refs.addStoreRef.showAddStore()
@@ -198,22 +210,21 @@ export default {
       }
     },
     async fetchData() {
-      // const params = {
-      //   page: this.page,
-      //   rows: this.size,
-      //   transCode: this.search.transCode
-      // }
-
-      // this.loading = true
+      const params = {
+        page: this.page,
+        rows: this.size,
+        transCode: this.search.transCode
+      }
 
-      // const res = await getSmbList(params)
+      this.loading = true
 
-      // this.loading = false
+      const res = await getStoreList(params)
 
-      // if (res.success) {
-      //   this.tableData = res.rows || []
-      //   this.total = res.records
-      // }
+      this.loading = false
+      if (res.success) {
+        this.tableData = res.rows || []
+        this.total = res.records
+      }
     },
     async queryAllTransCode() {
       // const res = await getAllTransCode()
@@ -224,12 +235,46 @@ export default {
     },
     handlerOperate(type, row, msg) {
       if (type === 'unBindEnterprise') {
-
+        console.log('unBindEnterprise')
+        this.$confirm('确定要解绑企业嘛?', '解绑企业', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.unbindEnterprise(row.id)
+        }).catch(() => {})
       } else if (type === 'bindEnterprise') {
-
+        this.curShopName = row.shopName
+        this.curShopStatus = row.shopStatus
+        this.curShopId = row.id
+        this.$refs.bindEnterpriseRef.showAddEnterprise()
       } else if (type === 'bindAccount') {
+        console.log('bindAccount')
+      }
+    },
+    async unbindEnterprise(enterpriseId) {
+      const res = await unBindEnterprise(enterpriseId)
 
+      if (res.success) {
+        this.$message.success('解绑企业成功')
+        this.$router.go(0)
+      }
+    },
+    getPlatformName(type) {
+      const map = {
+        'pinduoduo': '拼多多',
+        'kuaishou': '快手',
+        'douyin': '抖音',
+        'meituan': '美团'
+      }
+      return map[type] || ''
+    },
+    getShopStatus(status) {
+      const map = {
+        0: '关闭',
+        1: '正常'
       }
+      return map[status] || ''
     }
   }
 }