lilei %!s(int64=2) %!d(string=hai) anos
pai
achega
df9882a6d0

+ 53 - 0
src/api/product.js

@@ -22,6 +22,59 @@ export const productPricedList = (params) => {
     method: 'post'
   })
 }
+// 定价批量审核 
+export const batchAuditPrice = (params) => {
+  const url = `/product/pricing/batchAudit`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 导出产品定价
+export const productExportPricing = (params) => {
+  return axios({
+    url: '/product/pricing/exportExcel',
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}
+// 产品定价 下载模板
+export const productPriceTplDownload = params => {
+  return axios.request({
+    url: `/product/productPrice/importTemplate`,
+    method: 'post',
+    responseType: 'blob'
+  })
+}
+// 产品定价 入库导入数据
+export const productPriceInsertImport = params => {
+  return axios({
+    url: '/product/productPrice/insertImport',
+    data: params,
+    method: 'post'
+  })
+}
+// 产品定价  批量插入
+export const productPriceImport = params => {
+  return axios({
+    url: '/product/productPrice/import',
+    data: params,
+    method: 'post'
+  })
+}
+//  产品定价 导入产品 导出错误项
+export const productPriceFailExcel = (params) => {
+  const url = `/product/productPrice/exportImportError`
+  return axios.request({
+    url: url,
+    method: 'post',
+    data: params,
+    responseType: 'blob'
+  })
+}
+
 //  产品 保存
 export const productSave = (params) => {
   return axios({

+ 196 - 0
src/views/productManagement/productPricing/chooseImportModal.vue

@@ -0,0 +1,196 @@
+<template>
+  <a-modal
+    centered
+    class="chooseImport-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="导入"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="900">
+    <div class="chooseImport-con">
+      <!-- 可导入数据 -->
+      <p class="">可导入数据{{ loadData.length }}条</p>
+      <a-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.allocateSn"
+        :columns="nowColumns"
+        :dataSource="loadData"
+        :loading="loading"
+        :scroll="{ y: 200 }"
+        :pagination="false"
+        bordered>
+      </a-table>
+      <a-divider />
+      <!-- 不可导入数据 -->
+      <p class="red">不可导入数据{{ unLoadData.length }}条</p>
+      <a-table
+        class="unTable"
+        ref="unTable"
+        size="small"
+        :rowKey="(record) => record.errorDesc"
+        :columns="nowUnColumns"
+        :dataSource="unLoadData"
+        :loading="loading"
+        :scroll="{ y: 200 }"
+        :pagination="false"
+        bordered>
+      </a-table>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="chooseImport-submit"
+          size="large"
+          :class="loadData.length==0?'button-grey':'button-primary'"
+          @click="handleSubmit"
+          style="padding: 0 40px;">确认导入</a-button>
+        <a-button
+          id="chooseImport-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 40px;margin-left: 15px;">取消</a-button>
+        <a-button
+          type="primary"
+          id="chooseImport-error"
+          size="large"
+          class="button-error"
+          @click="handleError"
+          style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { hdExportExcel } from '@/libs/exportExcel'
+import { productPriceImport, productPriceFailExcel } from '@/api/product'
+export default {
+  name: 'ChooseImportModal',
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    paramsData: {
+      type: Object,
+      default: () => {
+        return {}
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      nowColumns: [
+        { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
+        { title: '产品名称', dataIndex: 'name', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'code', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '特约价', dataIndex: 'specialPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '终端价', dataIndex: 'terminalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '车主价', dataIndex: 'carOwnersPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '变更原因', dataIndex: 'changeReason', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      loadData: [],
+      nowUnColumns: [
+        { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
+        { title: '产品名称', dataIndex: 'name', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '特约价', dataIndex: 'specialPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '终端价', dataIndex: 'terminalPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '车主价', dataIndex: 'carOwnersPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '备注', dataIndex: 'errorDesc', width: '22%', align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      unLoadData: [],
+      loading: false
+    }
+  },
+  methods: {
+    getData () {
+      const _this = this
+      this.loading = true
+      const params = {
+        path: this.paramsData.path
+      }
+      productPriceImport(params).then(res => {
+        this.loading = false
+        if (res.status == 200) {
+          if (res.data.rightList && res.data.rightList.length > 0) {
+            res.data.rightList.map((item, index) => {
+              item.no = index + 1
+            })
+          }
+          if (res.data.errorList && res.data.errorList.length > 0) {
+            res.data.errorList.map((item, index) => {
+              item.no = index + 1
+            })
+          }
+          _this.loadData = res.data.rightList || []
+          _this.unLoadData = res.data.errorList || []
+        }
+      })
+    },
+    // 确认导入
+    handleSubmit () {
+      if (this.loadData.length == 0) {
+        this.$message.warning('无可导入产品!')
+      } else {
+        this.$emit('ok', this.loadData)
+        this.isShow = false
+      }
+    },
+    // 导出
+    handleError () {
+      const _this = this
+      if (_this.unLoadData.length < 1) {
+        _this.$message.info('暂无可导出的错误项~')
+        return
+      }
+      _this.spinning = true
+      hdExportExcel(productPriceFailExcel, _this.unLoadData, '产品定价错误项', function () {
+        _this.spinning = false
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.loadData = []
+        this.unLoadData = []
+      } else {
+        this.getData()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .chooseImport-modal{
+    .chooseImport-con{
+      .red{
+        color: #f30;
+      }
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel,.button-error{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 1 - 1
src/views/productManagement/productPricing/editModal.vue

@@ -160,7 +160,7 @@ export default {
           this.form.afterSpecialPrice = res.data.afterSpecialPrice || ''
           this.form.afterTerminalPrice = res.data.afterTerminalPrice || ''
           this.form.afterCarOwnersPrice = res.data.afterCarOwnersPrice || ''
-          this.form.changeReason = res.data.id ? '价格修改' : '首次定价'
+          this.form.changeReason = res.data.id && res.data.changeReason ? '价格修改' : '首次定价'
         } else {
           this.detailData = null
           this.$refs.ruleForm.resetFields()

+ 195 - 0
src/views/productManagement/productPricing/importGuideModal.vue

@@ -0,0 +1,195 @@
+<template>
+  <a-modal
+    centered
+    class="importGuide-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="导入"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="750">
+    <div class="importGuide-con">
+      <div class="explain-con">
+        <div class="explain-item">
+          <div class="explain-tit">
+            <span>1</span>准备导入
+          </div>
+          <ul>
+            <li>1) 导入的Excel文件中必须包含名为“产品编码”的列,且名称必须相同</li>
+            <li>2) “产品编码”必须是列表中已存在的产品</li>
+            <li>3) 省级价、市级价、特约价、终端价、车主价均可为空,为空表示不对原有价格做改变</li>
+          </ul>
+          <a-button type="link" icon="download" style="padding: 0 0 0 23px;" @click="handleExport">下载导入模板</a-button>
+        </div>
+        <div class="explain-item">
+          <div class="explain-tit">
+            <span>2</span>上传数据文件
+          </div>
+          <p>目前支持的文件类型*.xls,*.xlsx.</p>
+          <div style="overflow: hidden;padding-left: 23px;">
+            <Upload
+              id="importGuide-attachList"
+              ref="importUpload"
+              :maxNums="1"
+              fileType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
+              uploadType="import"
+              :action="attachAction"
+              :uploadParams="uploadParams"
+              upText="添加文件"
+              @change="changeImport"></Upload>
+          </div>
+        </div>
+      </div>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="importGuide-nextStep"
+          size="large"
+          class="button-primary"
+          @click="handlerNextStep"
+          style="padding: 0 60px;">下一步</a-button>
+        <a-button
+          id="importGuide-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 60px;margin-left: 15px;">取消</a-button>
+      </div>
+    </div>
+    <!-- 导入 -->
+    <chooseImportModal :openModal="openImportModal" :paramsData="paramsData" @close="handleClose" @ok="hanldeOk" />
+  </a-modal>
+</template>
+
+<script>
+import ChooseImportModal from './chooseImportModal.vue'
+import { Upload } from '@/components'
+import { hdExportExcel } from '@/libs/exportExcel'
+import { productPriceTplDownload } from '@/api/product'
+export default {
+  name: 'ImportGuideModal',
+  components: { ChooseImportModal, Upload },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    params: {
+      type: Object,
+      default: null
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      openImportModal: false, //  导入
+      attachAction: process.env.VUE_APP_API_BASE_URL + '/upload',
+      paramsData: null,
+      uploadParams: {
+        savePathType: 'local'
+      }
+    }
+  },
+  methods: {
+    // 下一步
+    handlerNextStep () {
+      if (this.paramsData) {
+        this.openImportModal = true
+      } else {
+        this.$message.warning('添加文件后再进行下一步操作!')
+      }
+    },
+    // 上传文件  change
+    changeImport (file) {
+      if (file) {
+        this.paramsData = {
+          path: file
+        }
+      }
+    },
+    // 导入
+    hanldeOk (obj) {
+      if (obj && obj.length > 0) {
+        this.$emit('ok', obj)
+        this.isShow = false
+      }
+    },
+    // 关闭
+    handleClose () {
+      this.openImportModal = false
+      this.isShow = false
+    },
+    //  导出
+    handleExport () {
+      const _this = this
+      this.spinning = true
+      hdExportExcel(productPriceTplDownload, {}, '产品定价导入模板', function () {
+        _this.spinning = false
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.paramsData = null
+        this.$refs.importUpload.setFileList('')
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .importGuide-modal{
+    .importGuide-con{
+      .explain-con{
+        .explain-item{
+          margin-bottom: 10px;
+          .explain-tit{
+            font-weight: bold;
+            span{
+              display: inline-block;
+              width: 18px;
+              height: 18px;
+              line-height: 16px;
+              text-align: center;
+              margin-right: 5px;
+              border-radius: 50%;
+              border: 1px solid rgba(0, 0, 0, 0.3);
+            }
+          }
+          p{
+            margin: 8px 0;
+            padding-left: 23px;
+          }
+          ul{
+            list-style: none;
+            padding: 0;
+            padding-left: 23px;
+            margin: 0;
+            li{
+              line-height: 26px;
+            }
+          }
+        }
+        #importGuide-attachList{
+          width: 100%;
+        }
+      }
+      .btn-con{
+        margin: 10px 0 20px;
+        text-align: center;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 18 - 6
src/views/productManagement/productPricing/list.vue

@@ -70,7 +70,7 @@
           @click="handleBatchAudit"
           style="margin: 0 15px 0 0;">批量审核</a-button>
         <span>已选{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys?rowSelectionInfo.selectedRowKeys.length:0 }}项</span>
-        <a-button style="margin: 0 0 0 15px;" id="productPricingList-add" type="primary" class="button-error">定价导入</a-button>
+        <a-button style="margin: 0 0 0 15px;" id="productPricingList-add" @click="openGuideModal=true" type="primary" class="button-error">定价导入</a-button>
       </div>
       <!-- 列表 -->
       <s-table
@@ -78,7 +78,7 @@
         ref="table"
         :style="{ height: tableHeight+84.5+'px' }"
         size="small"
-        :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.pricingState=='WAIT_PRICING_AUDIT' } })}"
+        :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.pricingState!='WAIT_PRICING_AUDIT' } })}"
         @rowSelection="rowSelectionFun"
         :rowKey="(record) => record.id"
         :columns="columns"
@@ -125,6 +125,8 @@
     <product-pricing-edit-modal :openModal="openModal" :itemSn="itemSn" @close="closeModal" @ok="$refs.table.refresh()" />
     <!-- 审核价格 -->
     <product-pricing-audit-modal :openModal="openAuditModal" :itemSn="itemSn" @close="closeAuditModal" @ok="$refs.table.refresh()" />
+    <!-- 导入产品 -->
+    <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="hanldeOk" />
   </a-card>
 </template>
 
@@ -136,16 +138,18 @@ import productPricingEditModal from './editModal.vue'
 import productPricingAuditModal from './auditModal.vue'
 import { productBrandQuery } from '@/api/productBrand'
 import { productTypeQuery } from '@/api/productType'
-import { productPricingList } from '@/api/product'
+import { productPricingList, productExportPricing, batchAuditPrice, productPriceInsertImport } from '@/api/product'
 import ProductBrand from '@/views/common/productBrand.js'
+import ImportGuideModal from './importGuideModal.vue'
 export default {
   name: 'ProductPricingList',
   mixins: [commonMixin],
-  components: { STable, VSelect, productPricingEditModal, productPricingAuditModal, ProductBrand },
+  components: { STable, VSelect, productPricingEditModal, productPricingAuditModal, ProductBrand, ImportGuideModal },
   data () {
     return {
       spinning: false,
       advanced: true, // 高级搜索 展开/关闭
+      openGuideModal: false,
       tableHeight: 0,
       queryParam: { //  查询条件
         name: '', //  产品名称
@@ -274,7 +278,7 @@ export default {
         centered: true,
         onOk () {
           _this.spinning = true
-          productBatchAudit(obj).then(res => {
+          batchAuditPrice(obj).then(res => {
             if (res.status == 200) {
               _this.$refs.table.clearSelected() // 清空表格选中项
               _this.$message.success(res.message)
@@ -287,12 +291,20 @@ export default {
         }
       })
     },
+    // 导入产品
+    hanldeOk (obj) {
+      productPriceInsertImport(obj).then(res => {
+        if (res.status == 200) {
+          this.$refs.table.refresh(true)
+        }
+      })
+    },
     //  导出
     handleExport () {
       const _this = this
       const params = this.queryParam
       this.spinning = true
-      exportExcel(productExport, params, '产品价格导出', function () {
+      exportExcel(productExportPricing, params, '产品价格导出', function () {
         _this.spinning = false
       })
     },