ソースを参照

产品上下线提醒

chenrui 3 年 前
コミット
ce83335e1b

+ 11 - 0
src/api/product.js

@@ -238,3 +238,14 @@ export const productPriceInfo = (params) => {
     method: 'get'
   })
 }
+// 查询最近上下线产品
+export const queryNewProductPage = (params) => {
+  const url = `/product/queryNewProductPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 22 - 0
src/config/router.config.js

@@ -48,6 +48,28 @@ export const asyncRouterMap = [
         },
         hidden: true
       },
+      // 新品列表
+      {
+        path: '/newProduct/:onlineFalg',
+        name: 'newProduct',
+        component: () => import(/* webpackChunkName: "home" */ '@/views/productManagement/newProduct/list'),
+        meta: {
+          title: '新品信息',
+          icon: 'home'
+        },
+        hidden: true
+      },
+      // 产品详情
+      {
+        path: '/viewProduct/:sn',
+        name: 'viewProduct',
+        component: () => import(/* webpackChunkName: "home" */ '@/views/productManagement/newProduct/detail'),
+        meta: {
+          title: '产品详情',
+          icon: 'home'
+        },
+        hidden: true
+      },
       // 销售管理
       {
         path: '/salesManagement',

+ 51 - 2
src/views/Home.vue

@@ -15,19 +15,36 @@
       v-model="openResetPwd">
       <ResetPwd />
     </a-modal>
+    <!-- 新产品上线提醒 -->
+    <a-modal
+      class="newProductTips"
+      :title="'新产品'+(onlineFalg=='1'?'上':'下')+'线提醒'"
+      :width="800"
+      centered
+      :footer="null"
+      :maskClosable="false"
+      :destroyOnClose="true"
+      @cancel="cancelProductTips"
+      v-model="openNewProduct">
+      <newProduct :onlineFalg="onlineFalg" @seeMore="seeMore"></newProduct>
+    </a-modal>
   </div>
 </template>
 
 <script>
 import { mapGetters } from 'vuex'
 import ResetPwd from '@/views/user/ResetPwd.vue'
+import newProduct from '@/views/productManagement/newProduct/modal.vue'
+import { queryNewProductPage } from '@/api/product'
 export default {
   name: 'Home',
-  components: { ResetPwd },
+  components: { ResetPwd, newProduct },
   data () {
     return {
       message: '欢迎登录' + process.env.VUE_APP_PRO_NAME,
-      openResetPwd: false //  重置密码是否显示
+      openResetPwd: false, //  重置密码是否显示
+      openNewProduct: false,
+      onlineFalg: '1' // 上下线标识  1为上线,0为下线
     }
   },
   computed: {
@@ -36,6 +53,34 @@ export default {
   created () {
   },
   methods: {
+    hasNewProduct () {
+      queryNewProductPage({ pageNo: 1, pageSize: 20, onlineFalg: this.onlineFalg }).then(res => {
+        if (res.status == 200) {
+          if (res.data.count > 0) {
+            this.openNewProduct = true
+          } else {
+            if (this.onlineFalg == '1') {
+              this.onlineFalg = '0'
+              this.hasNewProduct()
+            }
+          }
+        }
+      })
+    },
+    // 查看更多产品
+    seeMore () {
+      this.openNewProduct = false
+      this.$router.push({ name: 'newProduct', params: { onlineFalg: this.onlineFalg } })
+    },
+    // 关闭弹框
+    cancelProductTips () {
+      const _this = this
+      this.openNewProduct = false
+      if (this.onlineFalg == '1') {
+        this.onlineFalg = '0'
+        setTimeout(() => { _this.hasNewProduct() }, 100)
+      }
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
@@ -45,6 +90,10 @@ export default {
       } else {
         vm.openResetPwd = true
       }
+      if (from.name == 'login') {
+        // 判断是否有新产品上线
+        vm.hasNewProduct()
+      }
     })
   }
 }

+ 174 - 0
src/views/productManagement/newProduct/detail.vue

@@ -0,0 +1,174 @@
+<template>
+  <div>
+    <a-page-header :ghost="false" :backIcon="false" class="newProductDetail-back">
+      <!-- 自定义的二级文字标题 -->
+      <template slot="subTitle">
+        <a id="newProductDetail-back-btn" href="javascript:;" @click="$router.go(-1)">
+          <a-icon type="left" />
+          返回
+        </a>
+      </template>
+    </a-page-header>
+    <div class="newProductDetail-modal">
+      <!-- 产品详情 -->
+      <h4>{{ (detailsData && detailsData.name) || '--' }}</h4>
+      <div class="productHead">
+        <div class="productInfo">
+          <a-descriptions bordered :column="2" size="small">
+            <a-descriptions-item label="产品品牌:">{{ (detailsData && detailsData.productBrandName) || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="产品编码:">{{ (detailsData && detailsData.code) || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="原厂编码:">{{ (detailsData && detailsData.origCode) || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="商品尺寸:">{{ (detailsData && detailsData.size) || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="重量:">{{ (detailsData && detailsData.weight) || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="计量单位:">{{ (detailsData && detailsData.unit) || '--' }}</a-descriptions-item>
+            <!-- <a-descriptions-item label="适用车型:">{{ productTypeName || '--' }}</a-descriptions-item> -->
+          </a-descriptions>
+          <div class="productDetail">
+            <h4>产品介绍</h4>
+            <div class="productDesc">
+              <div v-if="detailsData && detailsData.description" v-html="detailsData.description"></div>
+              <span v-else>暂无产品介绍</span>
+            </div>
+          </div>
+        </div>
+        <div class="productImg" v-if="detailsData && detailsData.productMsg">
+          <a-carousel arrows>
+            <div slot="prevArrow" slot-scope="props" class="custom-slick-arrow" style="left: 10px;zIndex: 1"><a-icon type="left-circle" /></div>
+            <div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="right: 10px"><a-icon type="right-circle" /></div>
+            <div><img :src="detailsData.productMsg" /></div>
+          </a-carousel>
+          <!-- <div class="sycxImg">
+            <p>适用车型图片</p>
+            <div>
+              <img src="../../../assets/avatar2.jpg" />
+              <div>江陵凯瑞200</div>
+            </div>
+          </div> -->
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import { productSnDetail } from '@/api/product.js'
+export default {
+  name: 'ProductInfoDetail',
+  computed: {
+    productTypeName () {
+      const productTypeName1 = this.detailsData && this.detailsData.productTypeName1 ? this.detailsData.productTypeName1 : ''
+      const productTypeName2 = this.detailsData && this.detailsData.productTypeName2 ? ' > ' + this.detailsData.productTypeName2 : ''
+      const productTypeName3 = this.detailsData && this.detailsData.productTypeName3 ? ' > ' + this.detailsData.productTypeName3 : ''
+      return productTypeName1 + productTypeName2 + productTypeName3
+    }
+  },
+  data () {
+    return {
+      itemId: null,
+      detailsData: null //  详情数据
+    }
+  },
+  methods: {
+    //  获取详情
+    getDetail () {
+      this.detailsData = null
+      productSnDetail({ sn: this.itemId }).then(res => {
+        if (res.status == 200) {
+          this.detailsData = res.data
+        } else {
+          this.detailsData = null
+        }
+      })
+    }
+  },
+  mounted () {
+    this.itemId = this.$route.params.sn
+    this.getDetail()
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.itemId = vm.$route.params.sn
+      vm.getDetail()
+    })
+  }
+}
+</script>
+
+<style lang="less">
+/* For demo */
+.ant-carousel .slick-slide {
+  text-align: center;
+  overflow: hidden;
+  border: 1px solid #eee;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.ant-carousel .custom-slick-arrow {
+  width: 25px;
+  height: 25px;
+  font-size: 25px;
+  color: #fff;
+  opacity: 0.3;
+}
+.ant-carousel .custom-slick-arrow:before {
+  display: none;
+}
+.ant-carousel .custom-slick-arrow:hover {
+  opacity: 0.5;
+}
+.ant-carousel .slick-slide img {
+  width: 100%;
+  max-height: 100%;
+}
+.newProductDetail-back {
+  margin-bottom: 10px;
+}
+.newProductDetail-modal {
+  background-color: #fff;
+  padding: 15px;
+  h4 {
+    font-size: 18px;
+  }
+  .productHead {
+    display: flex;
+    .productImg {
+      width: 240px;
+    }
+    .productInfo {
+      flex-grow: 1;
+      margin-right: 10px;
+    }
+    .sycxImg {
+      margin-top: 10px;
+      p {
+        font-size: 14px;
+        padding: 5px 10px;
+        background-color: #dcf1ff;
+      }
+      img {
+        width: 100px;
+      }
+    }
+  }
+  .productDetail {
+    border: 1px solid #eee;
+    margin-top: 10px;
+    h4 {
+      font-size: 14px;
+      padding: 5px 10px;
+      background-color: #dcf1ff;
+    }
+    .productDesc {
+      padding: 15px;
+    }
+  }
+  .ant-descriptions-item-label.ant-descriptions-item-colon {
+    width: 120px;
+  }
+  .btn-cont {
+    text-align: center;
+    margin: 35px 0 10px;
+  }
+}
+</style>

+ 252 - 0
src/views/productManagement/newProduct/list.vue

@@ -0,0 +1,252 @@
+<template>
+  <a-card size="small" :bordered="false" class="productInfoList-wrap">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 搜索条件 -->
+      <div ref="tableSearch" class="table-page-search-wrapper">
+        <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+          <a-row :gutter="15">
+            <a-col :md="6" :sm="24">
+              <a-form-item label="产品编码">
+                <a-input id="productInfoList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-item label="产品名称">
+                <a-input id="productInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-model-item :label="($route.params.onlineFalg=='1'?'上':'下')+'线时间'">
+                <rangeDate ref="rangeDate" @change="dateChange" />
+              </a-form-model-item>
+            </a-col>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-item label="产品品牌">
+                  <a-select
+                    placeholder="请选择产品品牌"
+                    id="productInfoList-productBrandSn"
+                    allowClear
+                    v-model="queryParam.productBrandSn"
+                    :showSearch="true"
+                    option-filter-prop="children"
+                    :filter-option="filterOption">
+                    <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+                  </a-select>
+                </a-form-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-item label="产品分类">
+                  <a-cascader
+                    @change="changeProductType"
+                    change-on-select
+                    v-model="productType"
+                    expand-trigger="hover"
+                    :options="productTypeList"
+                    :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
+                    id="productInfoList-productType"
+                    placeholder="请选择产品分类"
+                    allowClear />
+                </a-form-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-item label="原厂编码">
+                  <a-input id="productInfoList-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
+                </a-form-item>
+              </a-col>
+            </template>
+            <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
+              <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
+              <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
+              <a @click="advanced=!advanced" style="margin-left: 5px">
+                {{ advanced ? '收起' : '展开' }}
+                <a-icon :type="advanced ? 'up' : 'down'"/>
+              </a>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+      <!-- 列表 -->
+      <s-table
+        class="sTable fixPagination"
+        ref="table"
+        :style="{ height: tableHeight+84.5+'px' }"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :defaultLoadData="false"
+        :scroll="{ x: 1090, y: tableHeight }"
+        bordered>
+        <!-- 上/下线时间 表头 -->
+        <template slot="auditTimeTit">
+          {{ $route.params.onlineFalg=='1'?'上':'下' }}线时间
+        </template>
+        <!-- 上/下线时间 内容 -->
+        <template slot="auditTime" slot-scope="text, record">
+          {{ $route.params.onlineFalg=='1'?record.onlineAuditTime:record.offlineAuditTime }}
+        </template>
+        <!-- 产品分类 -->
+        <template slot="productType" slot-scope="text, record">
+          <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
+          <span v-else>--</span>
+        </template>
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text, record">
+          <a-button
+            size="small"
+            type="link"
+            class="button-success"
+            @click="handleDetail(record)"
+            id="productInfoList-detail-btn">详情</a-button>
+        </template>
+      </s-table>
+    </a-spin>
+  </a-card>
+</template>
+
+<script>
+import { productBrandQuery } from '@/api/productBrand'
+import { productTypeQueryAll } from '@/api/productType'
+import { queryNewProductPage } from '@/api/product'
+import { STable, VSelect } from '@/components'
+import rangeDate from '@/views/common/rangeDate.vue'
+export default {
+  components: { STable, VSelect, rangeDate },
+  data () {
+    return {
+      spinning: false,
+      advanced: true, // 高级搜索 展开/关闭
+      tableHeight: 0,
+      productType: [],
+      queryParam: { //  查询条件
+        beginDate: '',
+        endDate: '',
+        code: '', //  产品编码
+        name: '', //  产品名称
+        origCode: '', //  原厂编码
+        sysFlag: '0',
+        productBrandSn: undefined, //  产品品牌
+        productTypeSn1: '', //  产品一级分类
+        productTypeSn2: '', //  产品二级分类
+        productTypeSn3: '', //  产品三级分类
+        enabledFlag: undefined //  状态
+      },
+      disabled: false, //  查询、重置按钮是否可操作
+      exportLoading: false, // 导出loading
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
+        { slots: { title: 'auditTimeTit' }, scopedSlots: { customRender: 'auditTime' }, width: 140, align: 'center' },
+        { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 140, align: 'center' },
+        { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '原厂编码', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        return queryNewProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: this.$route.params.onlineFalg })).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          this.disabled = false
+          this.spinning = false
+          return data
+        })
+      },
+      openModal: false, //  查看详情  弹框
+      itemId: '', //  当前产品productSn
+      productBrandList: [], //  品牌下拉数据
+      productTypeList: [] //  分类下拉数据
+    }
+  },
+  methods: {
+    //  创建时间  change
+    dateChange (date) {
+      this.queryParam.beginDate = date[0] || ''
+      this.queryParam.endDate = date[1] || ''
+    },
+    //  重置
+    resetSearchForm () {
+      this.$refs.rangeDate.resetDate()
+      this.queryParam.code = ''
+      this.queryParam.name = ''
+      this.queryParam.origCode = ''
+      this.queryParam.productBrandSn = undefined
+      this.queryParam.productTypeSn1 = ''
+      this.queryParam.productTypeSn2 = ''
+      this.queryParam.productTypeSn3 = ''
+      this.queryParam.enabledFlag = undefined
+      this.productType = []
+      this.$refs.table.refresh(true)
+    },
+    filterOption (input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      )
+    },
+    //  详情
+    handleDetail (row) {
+      this.itemId = row.productSn
+      this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
+    },
+    //  产品分类  change
+    changeProductType (val, opt) {
+      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
+    //  产品品牌  列表
+    getProductBrand () {
+      productBrandQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productBrandList = res.data
+        } else {
+          this.productBrandList = []
+        }
+      })
+    },
+    //  产品分类  列表
+    getProductType () {
+      productTypeQueryAll({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    setTableH () {
+      const tableSearchH = this.$refs.tableSearch.offsetHeight
+      this.tableHeight = window.innerHeight - tableSearchH - 215
+    }
+  },
+  mounted () {
+    const _this = this
+    this.$nextTick(() => { // 页面渲染完成后的回调
+      _this.setTableH()
+    })
+  },
+  watch: {
+    advanced (newValue, oldValue) {
+      const _this = this
+      setTimeout(() => {
+        _this.setTableH()
+      }, 400)
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.$refs.table.refresh(true)
+      vm.getProductBrand()
+      vm.getProductType()
+    })
+  }
+}
+</script>

+ 89 - 0
src/views/productManagement/newProduct/modal.vue

@@ -0,0 +1,89 @@
+<template>
+  <div>
+    <a-spin :spinning="spinning" tip="Loading...">
+      <!-- 列表 -->
+      <s-table
+        class="sTable fixPagination"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :scroll="{ y: 400 }"
+        :data="loadData"
+        :defaultLoadData="false"
+        :showPagination="false"
+        bordered>
+      </s-table>
+      <div style="padding-top: 15px;">
+        <a-button @click="viewMore" block type="primary" ghost>查看更多新品</a-button>
+      </div>
+    </a-spin>
+  </div>
+</template>
+
+<script>
+import { STable } from '@/components'
+import { queryNewProductPage } from '@/api/product'
+export default {
+  name: 'NewProduct',
+  components: { STable },
+  props: {
+    onlineFalg: { // 上下线标识  1为上线,0为下线
+      type: [ String, Number ],
+      default: '1'
+    }
+  },
+  data () {
+    return {
+      spinning: false,
+      queryParam: {},
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.spinning = true
+        return queryNewProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: this.onlineFalg })).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          this.spinning = false
+          return data
+        })
+      }
+    }
+  },
+  computed: {
+    columns () {
+      const arr = [
+        { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
+        { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'code', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } }
+      ]
+      if (this.onlineFalg == '1') {
+        arr.push({ title: '上线时间', dataIndex: 'onlineAuditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } })
+      } else if (this.onlineFalg == '0') {
+        arr.push({ title: '下线时间', dataIndex: 'offlineAuditTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } })
+      }
+      return arr
+    }
+  },
+  methods: {
+    viewMore () {
+      this.$emit('seeMore')
+    }
+  },
+  mounted () {
+    this.$refs.table.refresh(true)
+  },
+  watch: {
+    onlineFalg (newValue, oldValue) {
+      const _this = this
+      setTimeout(() => {
+        _this.$refs.table.refresh(true)
+      }, 400)
+    }
+  }
+}
+</script>