Browse Source

事业部也展示集团SKU, SKU管理:品牌根据事业部品牌进行过滤

lxf 2 years ago
parent
commit
b534cedea1

+ 259 - 0
src/views/shengde/product/groupSKU/details.vue

@@ -0,0 +1,259 @@
+<template>
+  <el-card class="box-card">
+    <div class="contents" v-loading="loadingStatus" :element-loading-text="loadingText" element-loading-background="rgba(0, 0, 0, 0.2)">
+      <div class="rightContent">
+        <el-form ref="form" :model="form" label-width="120px">
+          <LabelTemplate :title="titleList[0]" id="id0" />
+          <div ref="id0">
+            <BasicInformation :form="form"></BasicInformation>
+          </div>
+          <div class="interval">
+            <div></div>
+          </div>
+          <LabelTemplate :title="titleList[1]" id="id1" />
+          <div ref="id1">
+            <ProductMaterial :form="form"></ProductMaterial>
+          </div>
+          <div class="interval">
+            <div></div>
+          </div>
+          <LabelTemplate :title="titleList[2]" id="id2" />
+          <div ref="id2">
+            <ProductionLine :form="form" ref="ProductionLine"></ProductionLine>
+          </div>
+          <div class="interval">
+            <div></div>
+          </div>
+          <LabelTemplate :title="titleList[3]" id="id3" />
+          <div ref="id3">
+            <ProductDescription :form="form"></ProductDescription>
+          </div>
+          <br />
+          <div style="width: 100%; text-align: center">
+            <el-button @click="clickCancel" v-db-click>关 闭</el-button>
+          </div>
+          <br />
+        </el-form>
+      </div>
+    </div>
+  </el-card>
+</template>
+
+<script>
+// import { details } from '@/api/product/customProductLibrary'
+import * as API from '@/api/shengde/product/groupSKU'
+import LabelTemplate from '@/components/LabelTemplate'
+import { mapGetters } from 'vuex'
+import BasicInformation from '@/components/ProductDetails/BasicInformation'
+import ProductPrice from '@/components/ProductDetails/ProductPrice'
+import ProductMaterial from '@/components/ProductDetails/ProductMaterial'
+import ProductionLine from '@/components/ProductDetails/ProductionLine'
+import BOMform from '@/components/ProductDetails/BOMform'
+import ProductDescription from '@/components/ProductDetails/ProductDescription'
+
+export default {
+  name: 'ProductDetails',
+  components: { LabelTemplate, BasicInformation, ProductPrice, ProductMaterial, ProductionLine, BOMform, ProductDescription },
+  props: {
+    rowData: Object,
+  },
+  data() {
+    return {
+      filePrefix: process.env.VUE_APP_FILE_PREFIX,
+      loadingStatus: false,
+      loadingText: '',
+      titleList: ['基本信息', '材质特征', '图片介绍'],
+      navGatorIndex: 0,
+      listBoxState: true,
+      scrollBottom: '',
+      form: {
+        id: '',
+        categoryId: '',
+        barCode: '',
+        articleNo: '',
+        code: '',
+        nameChinese: '',
+        price: '',
+        costPrice: '',
+        materialChinese: '',
+        productModelChinese: '',
+        brandName: '',
+        remarks: '',
+        pic: '',
+        colors: [],
+      },
+      att: [],
+    }
+  },
+  created() {},
+  mounted() {
+    window.addEventListener('scroll', this.scrollToTop, true)
+    if (this.rowData && this.rowData.id) {
+      this.getProductDetails()
+    }
+    this.titleClick(0)
+  },
+  beforeDestroy() {
+    window.removeEventListener('scroll', this.scrollToTop, true)
+  },
+  computed: mapGetters(['userInfo']),
+  methods: {
+    titleClick(index) {
+      this.navGatorIndex = index
+      this.$el.querySelector(`#id${index}`).scrollIntoView({
+        behavior: 'smooth', // 平滑过渡
+        block: 'nearest', // 上边框与视窗顶部平齐。默认值
+      })
+      this.listBoxState = false
+      let timeId
+      clearTimeout(timeId)
+      timeId = setTimeout(() => {
+        this.listBoxState = true
+      }, 200)
+    },
+    // 监听页面元素滚动,改变导航栏选中
+    scrollToTop() {
+      if (this.listBoxState) {
+        for (let i = 0; i < this.titleList.length; i++) {
+          if (this.$refs['id' + i].getBoundingClientRect().top >= 0) {
+            if (this.scrollBottom === 0) {
+              this.navGatorIndex = this.titleList.length - 1
+            } else {
+              this.navGatorIndex = i
+            }
+            break
+          }
+        }
+      }
+    },
+    getScroll(event) {
+      // 滚动条距离底部的距离
+      this.scrollBottom = event.target.scrollHeight - event.target.scrollTop - event.target.clientHeight
+    },
+    getProductDetails() {
+      this.loadingText = '获取数据中,请稍后!'
+      this.loadingStatus = true
+      API.groupProductDetail({ id: this.rowData.id, subsidiaryId: this.rowData.subsidiaryId }).then(
+        (res) => {
+          for (let i = 0; i < res.data.data.colors.length; i++) {
+            res.data.data.colors[i].loading = false
+            res.data.data.colors[i].loading1 = false
+          }
+          if (res.data.data.colors && res.data.data.colors.length > 0) {
+            res.data.data.colors = res.data.data.colors.map((item) => {
+              item.nameChinese = item.nameChinese.replace(res.data.data.nameChinese + '  : ', '')
+              item.nameChinese = item.nameChinese.replace(res.data.data.nameChinese + ':', '')
+              if (!(item.mountingsList && item.mountingsList.length > 0)) {
+                item.mountingsList = []
+              }
+              if (!(item.exPackList && item.exPackList.length > 0)) {
+                item.exPackList = []
+              }
+              return {
+                ...item,
+              }
+            })
+          }
+          this.form = res.data.data
+          if (this.form.productionLineId) {
+            this.$refs.ProductionLine.handleChange(this.form.productionLineId)
+          }
+          this.loadingStatus = false
+        },
+        (err) => {
+          this.loadingStatus = false
+          console.log('groupProductDetail: ' + err)
+        }
+      )
+    },
+    clickCancel() {
+      this.$emit('clickCancel', false)
+    },
+  },
+}
+</script>
+
+<style lang="scss" scoped>
+.box-card {
+  max-height: calc(100vh - 30px - 60px - 20px);
+}
+/deep/ .el-card__body {
+  padding: 0 !important;
+}
+// *::-webkit-scrollbar {
+//   /*滚动条整体样式*/
+//   width: 0px; /*高宽分别对应横竖滚动条的尺寸*/
+//   height: 0px;
+// }
+*::-webkit-scrollbar-thumb {
+  /*滚动条里面小方块*/
+  border-radius: 8px;
+  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
+  background: #b4bbc5;
+}
+*::-webkit-scrollbar-track {
+  /*滚动条里面轨道*/
+  box-shadow: inset 0 0 7px rgba(0, 0, 0, 0.2);
+  border-radius: 8px;
+  background: #ffffff;
+}
+.isActive {
+  color: #016fd4;
+}
+.contents {
+  max-height: calc(100vh - 30px - 60px - 20px);
+  // width: 100%;
+  display: flex;
+  margin: 0 auto;
+  margin-bottom: 0;
+  background-color: white;
+  box-shadow: var(--devui-shadow-fullscreen-overlay, 0 10px 20px 0) var(--devui-shadow, rgba(0, 0, 0, 0.08));
+  scrollbar-width: none;
+}
+.leftContent {
+  width: 12%;
+  text-align: center;
+  background-color: white;
+  box-shadow: var(--devui-shadow-fullscreen-overlay, 0 10px 20px 0) var(--devui-shadow, rgba(0, 0, 0, 0.08));
+  scrollbar-width: none;
+}
+.rowContent {
+  display: flex;
+  justify-content: left;
+  margin-left: 15px;
+  align-items: center;
+  line-height: 40px;
+  font-size: 14px;
+  cursor: pointer;
+}
+.rightContent {
+  max-height: calc(100vh - 30px - 60px - 20px);
+  width: 100%;
+  overflow-y: auto;
+  background-color: white;
+  box-shadow: var(--devui-shadow-fullscreen-overlay, 0 10px 20px 0) var(--devui-shadow, rgba(0, 0, 0, 0.08));
+  scrollbar-width: none;
+}
+.circle {
+  margin: 0 5px;
+  height: 13px;
+  width: 13px;
+  background: #016fd4;
+  border-radius: 20px;
+}
+.circle2 {
+  margin: 0 5px;
+  height: 13px;
+  width: 13px;
+  background: #d4d2d2;
+  border-radius: 20px;
+}
+.interval {
+  padding: 20px 0;
+  div {
+    height: 12px;
+    background-color: #f2f2f2;
+    box-shadow: var(--devui-shadow-fullscreen-overlay, 0 10px 40px 0) var(--devui-shadow, rgba(0, 0, 0, 0.08));
+  }
+}
+</style>

+ 7 - 52
src/views/shengde/product/groupSKU/index.vue

@@ -1,24 +1,5 @@
 <template>
   <div>
-    <!-- <el-row>
-      <el-col :span="4">
-        <el-card style="height: calc(100vh - 110px); margin-right: 10px">
-          <el-input v-model="inputCategory" placeholder="请输入产品分类" size="small" clearable></el-input>
-          <div style="margin-top: 15px; height: calc(100vh - 170px)" class="scroll">
-            <el-tree
-              ref="treeCategory"
-              :data="categoryTreeData"
-              :props="defaultProps"
-              node-key="id"
-              default-expand-all
-              :expand-on-click-node="false"
-              :filter-node-method="treeCategory"
-              @node-click="handleNodeClick"
-            ></el-tree>
-          </div>
-        </el-card>
-      </el-col>
-      <el-col :span="20"> -->
     <el-card style="height: calc(100vh - 110px)" class="scroll">
       <el-form :model="queryParams" ref="queryForm" :inline="true">
         <el-form-item label="群组品号" prop="code">
@@ -27,11 +8,11 @@
         <el-form-item label="群组品名" prop="nameChinese">
           <el-input v-model="queryParams.nameChinese" placeholder="请输入群组品名" clearable size="small" @keyup.enter.native="handleQuery" />
         </el-form-item>
-        <el-form-item label="品牌" prop="brandName">
+        <!-- <el-form-item label="品牌" prop="brandName">
           <el-select v-model="queryParams.brandName" placeholder="请选择品牌" size="small" @change="handleQuery">
             <el-option v-for="item in brandName" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
         <el-form-item label="品号" prop="specCode">
           <el-input v-model="queryParams.specCode" placeholder="请输入品号" clearable size="small" @keyup.enter.native="handleQuery" />
         </el-form-item>
@@ -45,7 +26,7 @@
         </el-form-item>
       </el-form>
 
-      <el-row :gutter="10" style="margin-bottom: 10px">
+      <el-row :gutter="10" style="margin-bottom: 10px" v-if="!userInfo.subsidiaryId">
         <el-col :span="5">
           <el-button type="primary" size="small" @click="handleAdd">添加产品</el-button>
         </el-col>
@@ -112,7 +93,7 @@
         <el-table-column label="品牌" prop="brandName" width="100" />
         <el-table-column label="型号" prop="productModelChinese" min-width="150" />
         <el-table-column label="材质" prop="materialChinese" min-width="150" />
-        <el-table-column label="操作" align="center" width="100" fixed="right">
+        <el-table-column label="操作" align="center" width="100" fixed="right" v-if="!userInfo.subsidiaryId">
           <template slot-scope="scope">
             <el-button type="text" @click="handleUpdate(scope.row)" v-db-click>编辑</el-button>
             <el-button type="text" @click="handleDelete(scope.row)" v-db-click>删除</el-button>
@@ -121,8 +102,6 @@
       </el-table>
       <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
     </el-card>
-    <!-- </el-col>
-    </el-row> -->
 
     <!-- 添加或修改产品信息对话框 -->
     <el-dialog v-if="openProduct" :visible.sync="openProduct" width="98%" append-to-body>
@@ -139,10 +118,9 @@
 <script>
 import * as API from '@/api/shengde/product/groupSKU'
 import { del } from '@/api/product/customProductLibrary'
-// import { productCategoryList } from '@/api/product/productCategories'
 import { mapGetters } from 'vuex'
 import Product from './product'
-import ProductDetails from '@/views/shengde/product/management/details'
+import ProductDetails from './details'
 
 export default {
   name: 'groupSKU',
@@ -180,38 +158,17 @@ export default {
       fileData: [],
       rowData: {},
       openDetails: false,
-      brandName: [],
+      // brandName: [],
     }
   },
   created() {
-    this.brandName = this.dictData.filter((item) => item.code === 'brand_name')[0].children
-    // productCategoryList({}).then(
-    //   (res) => {
-    //     this.categoryTreeData = []
-    //     const data = { id: '0', text: '目录类目', pId: '0', pIds: '0', children: [] }
-    //     data.children = this.handleTree(res.data.data, 'id', 'pId')
-    //     this.categoryTreeData.push(data)
-    //   },
-    //   (err) => {
-    //     console.log('productCategoryList:' + err)
-    //     this.loading = false
-    //   }
-    // )
+    // this.brandName = this.dictData.filter((item) => item.code === 'brand_name')[0].children
   },
   mounted() {
     this.getList()
   },
-  // watch: {
-  //   inputCategory(val) {
-  //     this.$refs.treeCategory.filter(val)
-  //   },
-  // },
   computed: mapGetters(['dictData', 'userInfo']),
   methods: {
-    // treeCategory(value, data) {
-    //   if (!value) return true
-    //   return data.text.indexOf(value) !== -1
-    // },
     handleNodeClick(data) {
       this.queryParams.pageNum = 1
       if (data.dictKey) {
@@ -263,8 +220,6 @@ export default {
     /** 重置按钮操作 */
     resetQuery() {
       this.resetForm('queryForm')
-      // this.queryParams.categoryId = ''
-      // this.$refs.treeCategory.setCurrentKey(null)
       this.handleQuery()
     },
     /** 新增按钮操作 */

+ 15 - 42
src/views/shengde/product/management/index.vue

@@ -1,23 +1,6 @@
 <template>
   <div v-loading="loadingStatus" element-loading-text="获取数据中,请稍后" element-loading-background="rgba(0, 0, 0, 0.2)">
     <el-row style="padding-top: 0">
-      <!-- <el-col :span="4">
-        <el-card style="height: calc(100vh - 110px); margin-right: 10px">
-          <el-input v-model="inputCategory" placeholder="请输入产品分类" size="small" clearable></el-input>
-          <div style="margin-top: 15px; height: calc(100vh - 170px)" class="scroll">
-            <el-tree
-              ref="treeCategory"
-              :data="categoryTreeData"
-              :props="defaultProps"
-              node-key="id"
-              default-expand-all
-              :expand-on-click-node="false"
-              :filter-node-method="treeCategory"
-              @node-click="handleNodeClick"
-            ></el-tree>
-          </div>
-        </el-card>
-      </el-col> -->
       <el-col :span="24">
         <el-card style="height: calc(100vh - 110px)" class="scroll">
           <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
@@ -230,6 +213,7 @@ import { mapGetters } from 'vuex'
 import Product from '@/views/AddOrModifiedProduct/Product'
 import ProductOne from '@/views/AddOrModifiedProduct/ProductOne'
 import ProductDetails from '@/views/shengde/product/management/details'
+import { getDetail } from '@/api/shengde/group/subcompany/subcompanyManagement/index.js'
 
 export default {
   name: 'ProductManagement',
@@ -305,8 +289,20 @@ export default {
     }
   },
   created() {
-    this.brandName = this.dictData.filter((item) => item.code === 'brand_name')[0].children
-    // this.getCategory()
+    if (this.userInfo.subsidiaryId) {
+      getDetail({ id: this.userInfo.subsidiaryId }).then((res) => {
+        let brandNameArr = []
+        if (res.data.data.brandName) {
+          brandNameArr = res.data.data.brandName.split(',')
+        }
+        let data = this.dictData.filter((item) => item.code === 'brand_name')
+        if (data && data.length > 0) {
+          this.brandName = data[0].children.filter((item) => {
+            return brandNameArr.some((i) => item.dictKey == i)
+          })
+        }
+      })
+    }
   },
   mounted() {
     if (this.type) {
@@ -314,17 +310,8 @@ export default {
     }
     this.getList()
   },
-  // watch: {
-  //   inputCategory(val) {
-  //     this.$refs.treeCategory.filter(val)
-  //   },
-  // },
   computed: mapGetters(['menuAll', 'token', 'dictData', 'userInfo']),
   methods: {
-    // treeCategory(value, data) {
-    //   if (!value) return true
-    //   return data.text.indexOf(value) !== -1
-    // },
     handleNodeClick(data) {
       this.queryParams.pageNum = 1
       if (data.dictKey) {
@@ -336,20 +323,6 @@ export default {
       }
       this.getList()
     },
-    // getCategory() {
-    //   productCategoryList({}).then(
-    //     (res) => {
-    //       this.categoryTreeData = []
-    //       const data = { id: '0', text: '目录类目', pId: '0', pIds: '0', children: [] }
-    //       data.children = this.handleTree(res.data.data, 'id', 'pId')
-    //       this.categoryTreeData.push(data)
-    //     },
-    //     (err) => {
-    //       console.log('productCategoryList:' + err)
-    //       this.loading = false
-    //     }
-    //   )
-    // },
     /** 查询产品信息列表 */
     getList() {
       if (this.subsidiaryId) {