Ver código fonte

下线导入

chenrui 2 anos atrás
pai
commit
3a93ecc680

BIN
public/templ/批量下线导入模板.xlsx


+ 30 - 0
src/api/product.js

@@ -439,3 +439,33 @@ export const priceChangeEnabled = (params) => {
     method: 'post'
   })
 }
+
+/*
+* 批量导入下线产品
+*/
+// 批量导入下线产品
+export const offlineImport = (params) => {
+  return axios({
+    url: '/product/offline/import',
+    data: params,
+    method: 'post'
+  })
+}
+// 导出错误项产品
+export const exportErrorOffline = (params) => {
+  return axios({
+    url: '/product/offline/exportError',
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}
+
+// 批量保存产品
+export const importSaveBatch = (params) => {
+  return axios({
+    url: '/product/offline/importSaveBatch',
+    data: params,
+    method: 'post'
+  })
+}

+ 22 - 6
src/views/productManagement/productInfo/importGuideModal.vue

@@ -18,8 +18,17 @@
             <li>1) 请先下载导入模板,模板中已标示出必填项</li>
             <li>2) 产品编码具有唯一性,{{ guideType=='1'?'系统中已存在的无法导入':'下线导入,必须是系统中已存在的产品编码' }}</li>
             <li v-if="guideType=='1'">3) 产品品牌、产品分类、单位、包装数单位,必须是系统中已经存在的值,否则无法导入</li>
+            <li v-if="guideType=='2'"><a :href="filePath" style="margin: 5px 0 0 15px;display: block;">
+              <a-icon type="download" style="padding-right: 5px;" />下载导入模板
+            </a></li>
           </ul>
-          <a-button type="link" icon="download" style="padding: 0 0 0 23px;" :loading="exportLoading" @click="handleExport">下载导入模板</a-button>
+          <a-button
+            v-if="guideType=='1'"
+            type="link"
+            icon="download"
+            style="padding: 0 0 0 23px;"
+            :loading="exportLoading"
+            @click="handleExport">下载导入模板</a-button>
         </div>
         <div class="explain-item">
           <div class="explain-tit">
@@ -96,16 +105,22 @@ export default {
         savePathType: 'local'
       },
       exportLoading: false,
-      openOfflineImportModal: true
+      openOfflineImportModal: false,
+      filePath: location.protocol + '//' + location.host + '/templ/批量下线导入模板.xlsx'
     }
   },
   methods: {
     // 下一步
     handlerNextStep () {
-      if (this.paramsData) {
-        this.openImportModal = true
+      const _this = this
+      if (_this.paramsData) {
+        if (_this.guideType == 1) {
+          _this.openImportModal = true
+        } else {
+          _this.openOfflineImportModal = true
+        }
       } else {
-        this.$message.warning('添加文件后再进行下一步操作!')
+        _this.$message.warning('添加文件后再进行下一步操作!')
       }
     },
     // 上传文件  change
@@ -118,7 +133,7 @@ export default {
     },
     // 导入
     hanldeOk (obj) {
-      if (obj && obj.length > 0) {
+      if (obj) {
         this.$emit('ok', obj)
         this.isShow = false
       }
@@ -126,6 +141,7 @@ export default {
     // 关闭
     handleClose () {
       this.openImportModal = false
+      this.openOfflineImportModal = false
       this.isShow = false
     },
     // 下载模板

+ 17 - 8
src/views/productManagement/productInfo/list.vue

@@ -102,7 +102,6 @@
           @click="handleBatchDownline"
           style="margin: 0 10px;">批量下线</a-button>
         <!-- <a-button
-
           v-if="$hasPermissions('B_productInfo_batchImport')"
           type="primary"
           class="button-error"
@@ -224,7 +223,7 @@ import productTypeAll from '@/views/common/productTypeAll.js'
 import { exportExcel } from '@/libs/JGPrint.js'
 import rangeDate from '@/views/common/rangeDate.vue'
 import importGuideModal from './importGuideModal.vue'
-import { productList, productAudit, productBatchAudit, productDel, productOnline, productBatchOnline, productExport, saveBatchImportProduct } from '@/api/product'
+import { productList, productAudit, productBatchAudit, productDel, productOnline, productBatchOnline, productExport, saveBatchImportProduct, importSaveBatch } from '@/api/product'
 export default {
   name: 'ProductInfoList',
   mixins: [commonMixin],
@@ -320,13 +319,23 @@ export default {
     },
     // 批量导入产品
     hanldeOk (obj) {
+      debugger
       this.spinning = true
-      saveBatchImportProduct(obj).then(res => {
-        if (res.status == 200) {
-          this.resetSearchForm()
-        }
-        this.spinning = false
-      })
+      if (obj && obj.type && obj.type == 'offline') { // 下线导入
+        importSaveBatch(obj).then(res => {
+          if (res.status == 200) {
+            this.resetSearchForm()
+          }
+          this.spinning = false
+        })
+      } else {
+        saveBatchImportProduct(obj).then(res => {
+          if (res.status == 200) {
+            this.resetSearchForm()
+          }
+          this.spinning = false
+        })
+      }
     },
     // 审核
     handleAudit (row) {

+ 73 - 49
src/views/productManagement/productInfo/offlineImportModal.vue

@@ -11,47 +11,44 @@
     <div class="chooseImport-con">
       <!-- 可导入数据 -->
       <p style="font-weight:bold;">可导入数据{{ loadData.length }}条,确认要批量下线吗?</p>
-      <a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol">
-          <a-form-model-item label="下线选项">
-           <a-select
-               label-in-value
-               @change="handleChange"
-             >
-               <a-select-option value="1">
-                 淘汰
-               </a-select-option>
-               <a-select-option value="2">
-                通用
-               </a-select-option>
-             </a-select>
-          </a-form-model-item>
-          <a-form-model-item label="通用编码">
-           <a-table
-             class="sTable"
-             ref="table"
-             size="small"
-             :rowKey="(record) => record.allocateSn"
-             :columns="nowColumns"
-             :dataSource="loadData"
-             :loading="loading"
-             :scroll="{ y: 200}"
-             :pagination="false"
-             bordered>
-             <template slot="currency" slot-scope="text, record">
-                <a-input placeholder="请输入通用编码" />
-             </template>
-           </a-table>
-          </a-form-model-item>
-          <a-form-model-item label="下线备注">
-           <a-textarea 
-                 v-model="value"
-                 placeholder="请输入下线备注(最多60个字符)"
-                 :maxLength="60"
-                 :auto-size="{ minRows: 2, maxRows: 5 }"
-               />
-          </a-form-model-item>
-        </a-form-model>
-      
+      <a-form-model :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
+        <a-form-model-item label="下线选项" prop="offlineReasonType">
+          <v-select
+            code="OFFLINE_REASON_TYPE"
+            id="productInfoOffline-offlineReasonType"
+            v-model="form.offlineReasonType"
+            allowClear
+            placeholder="请选择下线选项"
+          ></v-select>
+        </a-form-model-item>
+        <a-form-model-item label="通用编码" :required="form.offlineReasonType=='通用'">
+          <a-table
+            class="sTable"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.allocateSn"
+            :columns="nowColumns"
+            :dataSource="loadData"
+            :loading="loading"
+            :scroll="{ y: 200}"
+            :pagination="false"
+            bordered>
+            <template slot="currency" slot-scope="text, record">
+              <productCodeList ref="productCodeList" mode="multiple" @change="e => productCodeChange(e, record)" />
+            </template>
+          </a-table>
+        </a-form-model-item>
+        <a-form-model-item label="下线备注">
+          <a-textarea
+            v-model="form.offlineRemark"
+            placeholder="请输入下线备注(最多60个字符)"
+            :maxLength="60"
+            :auto-size="{ minRows: 2, maxRows: 5 }"
+            allowClear
+          />
+        </a-form-model-item>
+      </a-form-model>
+
       <a-divider />
       <!-- 不可导入数据 -->
       <p class="red">不可导入数据{{ unLoadData.length }}条</p>
@@ -95,12 +92,15 @@
 </template>
 
 <script>
+import { VSelect } from '@/components'
 import { commonMixin } from '@/utils/mixin'
 import { hdExportExcel } from '@/libs/exportExcel'
-import { batchImportProduct, exportErrorProduct } from '@/api/product'
+import { offlineImport, exportErrorOffline } from '@/api/product'
+import productCodeList from '@/views/common/productCodeList.vue'
 export default {
   name: 'SalesChooseImportModal',
   mixins: [commonMixin],
+  components: { VSelect, productCodeList },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -115,15 +115,19 @@ export default {
   },
   data () {
     return {
-       labelCol: { span: 2 },
-       wrapperCol: { span: 22 },
+      labelCol: { span: 2 },
+      wrapperCol: { span: 22 },
       isShow: this.openModal, //  是否打开弹框
       nowColumns: [
         { title: '序号', dataIndex: 'no', width: '3%', align: 'center' },
         { title: '产品编码', dataIndex: 'code', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '通用编码',scopedSlots: { customRender: 'currency' },  width: '5%', align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '通用编码', scopedSlots: { customRender: 'currency' }, width: '5%', align: 'center' }
       ],
       loadData: [],
+      form: {
+        offlineReasonType: undefined,
+        offlineRemark: ''
+      },
       nowUnColumns: [
         { title: '序号', dataIndex: 'no', width: '3%', align: 'center' },
         { title: '产品编码', dataIndex: 'code', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
@@ -131,22 +135,36 @@ export default {
         { title: '备注', dataIndex: 'errorMsg', width: '5%', align: 'center', customRender: function (text) { return text || '--' } }
       ],
       unLoadData: [],
-      loading: false
+      loading: false,
+      rules: {
+        offlineReasonType: [
+          { required: true, message: '请选择下线选项', trigger: 'change' }
+        ]
+      }
     }
   },
   methods: {
+    productCodeChange (val, row) {
+      row.commonSn = []
+      if (val.length > 0) {
+        val.map(item => {
+          row.commonSn.push({ code: item.row && item.row.code ? item.row.code : undefined, productSn: item.key || undefined })
+        })
+      }
+    },
     getData () {
       const _this = this
       this.loading = true
       const params = {
         path: this.paramsData.path
       }
-      batchImportProduct(params).then(res => {
+      offlineImport(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
+              item.commonSn = []
             })
           }
           if (res.data.errorList && res.data.errorList.length > 0) {
@@ -164,7 +182,9 @@ export default {
       if (this.loadData.length == 0) {
         this.$message.warning('无可导入产品!')
       } else {
-        this.$emit('ok', this.loadData)
+        this.form.type = 'offline'
+        this.form.offlineProductList = this.loadData
+        this.$emit('ok', this.form)
         this.isShow = false
       }
     },
@@ -176,7 +196,7 @@ export default {
         return
       }
       _this.spinning = true
-      hdExportExcel(exportErrorProduct, _this.unLoadData, '导出产品错误项', function () {
+      hdExportExcel(exportErrorOffline, _this.unLoadData, '导出产品错误项', function () {
         _this.spinning = false
       })
     }
@@ -192,6 +212,10 @@ export default {
         this.$emit('close')
         this.loadData = []
         this.unLoadData = []
+        this.form = {
+          offlineReasonType: '',
+          offlineRemark: ''
+        }
       } else {
         this.getData()
       }