Kaynağa Gözat

散件导入模板

lilei 2 yıl önce
ebeveyn
işleme
c776d736a1

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1657598097048
+  "version": 1657616634181
 }

+ 24 - 0
src/api/sparePartsPur.js

@@ -50,6 +50,13 @@ export const sparePartsPurDel = (params) => {
     method: 'get'
   })
 }
+// 整单删除
+export const sparePartsPurDeleteAll = (params) => {
+  return axios({
+    url: `/sparePartsPur/detail/deleteAll/${params.sn}`,
+    method: 'get'
+  })
+}
 //  散件采购(入库) 导出
 export const sparePartsPurExport = (params) => {
   return axios({
@@ -123,3 +130,20 @@ export const sparePartsPurDetailPrint = params => {
   }
   return axios.request(data)
 }
+// 散件入库导入确认
+export const sparePartsPurDetailInsertBatch = (params) => {
+  return axios({
+    url: '/sparePartsPur/detail/insertBatch',
+    data: params,
+    method: 'post'
+  })
+}
+// 导出错误项
+export const sparePartsPurExportErrorLine = (params) => {
+  return axios({
+    url: '/sparePartsPur/detail/exportErrorLine',
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}

+ 237 - 0
src/views/bulkManagement/bulkWarehousingOrder/chooseImportModal.vue

@@ -0,0 +1,237 @@
+<template>
+  <a-modal
+    centered
+    wrapClassName="chooseImport-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="确认导入"
+    v-model="isShow"
+    @cancel="isShow=false"
+    width="80%">
+    <div class="chooseImport-con">
+      <!-- 可导入数据 -->
+      <div style="display:flex;justify-content: space-between;align-items: center;padding:10px 0;">
+        <div style="display:flex;align-items: center;">
+          可导入数据{{ loadData.length }}条
+          <div v-if="disableProduct.length">
+            ,其中<span style="color: red;">{{ disableProduct.length }}个禁用产品</span>,请确认已禁用的产品是否导入?
+            <a-radio-group v-model="importDisabled">
+              <a-radio :value="1">
+                导入
+              </a-radio>
+              <a-radio :value="0">
+                不导入
+              </a-radio>
+            </a-radio-group>
+          </div>
+        </div>
+        <div v-if="disableProduct.length">
+          <a-checkbox v-model="showDisable">
+            仅显示已禁用产品
+          </a-checkbox>
+        </div>
+      </div>
+      <a-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.productCode"
+        :rowClassName="(record, index) => record.productEnableFlag == 0 ? 'redBg-row':''"
+        :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.productCode"
+        :columns="nowUnColumns"
+        :dataSource="unLoadData"
+        :loading="loading"
+        :scroll="{ y: 200 }"
+        :pagination="false"
+        bordered>
+        <template slot="errorMsg" slot-scope="text,record">
+          <a-popover placement="topRight">
+            <template slot="content">
+              <p v-for="d in record.errorMsgList">{{ d }}</p>
+            </template>
+            <a-button type="link">
+              查看
+            </a-button>
+          </a-popover>
+        </template>
+      </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 { sparePartsPurExportErrorLine } from '@/api/sparePartsPur.js'
+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: '8%', align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '成本价', dataIndex: 'putCost', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '数量', dataIndex: 'putQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '仓库', dataIndex: 'warehouseName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '仓位', dataIndex: 'warehouseLocationName', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '单位', dataIndex: 'productUnit', align: 'center', width: '15%', customRender: function (text) { return text || '--' } }
+      ],
+      nowUnColumns: [
+        { title: '序号', dataIndex: 'no', width: '9%', align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '数量', dataIndex: 'putQty', width: '20%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '错误说明', scopedSlots: { customRender: 'errorMsg' }, width: '10%', align: 'center' }
+      ],
+      unLoadData: [],
+      loading: false,
+      importDisabled: undefined,
+      showDisable: false,
+      rightData: []
+    }
+  },
+  computed: {
+    // 启用产品
+    enableProduct () {
+      return this.rightData.filter(item => item.productEnableFlag == 1)
+    },
+    // 禁用产品
+    disableProduct () {
+      return this.rightData.filter(item => item.productEnableFlag == 0)
+    },
+    loadData () {
+      return this.showDisable ? this.rightData.filter(item => item.productEnableFlag == 0) : this.rightData
+    }
+  },
+  methods: {
+    getData () {
+      const paramsData = JSON.parse(JSON.stringify(this.paramsData))
+      this.rightData = paramsData.okList || []
+      this.rightData.map((item, index) => {
+        item.no = index + 1
+        item.sparePartsPurchaseSn = paramsData.sparePartsPurchaseSn
+      })
+      this.unLoadData = paramsData.errorList || []
+      this.unLoadData.map((item, index) => {
+        item.no = index + 1
+        item.sparePartsPurchaseSn = paramsData.sparePartsPurchaseSn
+      })
+    },
+    // 确认导入
+    handleSubmit () {
+      if (this.loadData.length == 0) {
+        this.$message.warning('无可导入的产品!')
+      } else {
+        if (this.importDisabled != undefined && this.disableProduct.length > 0) {
+          this.$emit('ok', this.importDisabled == 1 ? this.rightData : this.enableProduct)
+          this.isShow = false
+        } else {
+          this.$message.warning('请先确认已禁用的产品是否导入!')
+        }
+      }
+    },
+    // 导出
+    handleError () {
+      const _this = this
+      if (_this.paramsData.errorList.length < 1) {
+        _this.$message.info('暂无可导出错误项~')
+        return
+      }
+      _this.spinning = true
+      hdExportExcel(sparePartsPurExportErrorLine, _this.paramsData.errorList, '散件入库导出错误项', function () {
+        _this.spinning = false
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.rightData = []
+        this.unLoadData = []
+        this.importDisabled = undefined
+        this.showDisable = false
+      } else {
+        this.getData()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .chooseImport-modal{
+    .chooseImport-con{
+      .red{
+        color: #f30;
+      }
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel,.button-error{
+          font-size: 12px;
+        }
+      }
+    }
+   .redBg-row{
+      background-color: #f5cdc8;
+    }
+  }
+</style>

+ 96 - 17
src/views/bulkManagement/bulkWarehousingOrder/edit.vue

@@ -162,6 +162,40 @@
                   总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
                 </div>
               </a-alert>
+              <div class="table-page-search-wrapper">
+                <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
+                  <a-row :gutter="15">
+                    <a-col :md="4" :sm="24">
+                      <a-form-model-item label="产品编码">
+                        <a-input id="bulkWarehousingOrderEdit-code" v-model.trim="queryChooseParam.code" allowClear placeholder="请输入产品编码"/>
+                      </a-form-model-item>
+                    </a-col>
+                    <a-col :md="4" :sm="24">
+                      <a-form-model-item label="产品名称">
+                        <a-input id="bulkWarehousingOrderEdit-name" v-model.trim="queryChooseParam.name" allowClear placeholder="请输入产品名称"/>
+                      </a-form-model-item>
+                    </a-col>
+                    <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
+                      <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderEdit-choose-refresh">查询</a-button>
+                      <a-button style="margin-left: 8px" @click="resetChooseSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-choose-reset">重置</a-button>
+                    </a-col>
+                    <a-col :md="4" :sm="24">
+                    </a-col>
+                    <a-col :md="8" :sm="24" style="text-align:right;">
+                      <a-button
+                        type="default"
+                        @click="openGuideModal=true"
+                        :loading="delLoading"
+                        id="bulkWarehousingOrderEdit-del-all">导入产品</a-button>
+                      <a-button
+                        type="link"
+                        @click="delBulkOrder"
+                        :loading="delLoading"
+                        id="bulkWarehousingOrderEdit-del-all">整单删除</a-button>
+                    </a-col>
+                  </a-row>
+                </a-form>
+              </div>
               <!-- 列表 -->
               <s-table
                 class="sTable"
@@ -233,8 +267,13 @@
         @click="handleSubmit"
         style="padding: 0 60px;">提交</a-button>
     </div>
-    <!-- 选择基本信息弹框 -->
-    <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
+    <!-- 导入弹框 -->
+    <!-- 导入费用明细 -->
+    <importGuideModal
+      :openModal="openGuideModal"
+      :params="{sparePartsPurchaseSn: $route.params.sn}"
+      @close="openGuideModal=false"
+      @ok="hanldeImprotOk" />
     <!-- 新增产品 -->
     <a-modal
       centered
@@ -259,27 +298,38 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
-import basicInfoModal from './basicInfoModal.vue'
 import { getOperationalPrecision } from '@/libs/tools.js'
-import { sparePartsPurDetail, sparePartsPurDetailList, sparePartsPurDetailCount, sparePartsPurDetailSave, sparePartsPurDetailDel, sparePartsPurSubmit, sparePartsPurDetailPrint } from '@/api/sparePartsPur'
+import {
+  sparePartsPurDetail,
+  sparePartsPurDetailList,
+  sparePartsPurDetailCount,
+  sparePartsPurDetailSave,
+  sparePartsPurDetailDel,
+  sparePartsPurSubmit,
+  sparePartsPurDetailPrint,
+  sparePartsPurDeleteAll,
+  sparePartsPurDetailInsertBatch } from '@/api/sparePartsPur'
 import { bulkProductList } from '@/api/dealerProduct'
 import { warehouseCascadeList } from '@/api/warehouse'
 import ProductType from '../../common/productType.js'
 import ProductBrand from '../../common/productBrand.js'
 import Print from '@/views/common/print.vue'
+import importGuideModal from './importGuideModal.vue'
 import newProduct from '@/views/productManagement/productInfo/edit.vue'
 import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'BulkWarehousingEdit',
-  components: { STable, VSelect, basicInfoModal, Print, ProductType, ProductBrand, newProduct },
+  components: { STable, VSelect, Print, ProductType, ProductBrand, newProduct, importGuideModal },
   mixins: [commonMixin],
   data () {
     return {
       advanced: false,
       spinning: false,
       loading: false,
+      delLoading: false,
       chooseLoading: false,
       showNewProduct: false,
+      openGuideModal: false,
       queryParam: {
         code: '', //  产品编码
         name: '', //  产品名称
@@ -289,6 +339,10 @@ export default {
         productTypeSn2: undefined,
         productTypeSn3: undefined
       },
+      queryChooseParam: {
+        code: '', //  产品编码
+        name: '' //  产品名称
+      },
       productType: [],
       warehouseCascadeData: [], //  仓库仓位
       disabled: false, //  查询、重置按钮是否可操作
@@ -385,7 +439,6 @@ export default {
       },
       loadDataSource: [],
       chooseLoadDataSource: [],
-      openModal: false, // 选择基本信息弹框是否显示
       warehouseList: [], //  仓库  下拉数据
       warehouseLocList: {}, //  仓位  下拉数据
       defaultWarehouseCascade: [], //  默认仓库仓位
@@ -437,7 +490,7 @@ export default {
       this.queryParam.code = data.code
       this.$refs.table.refresh(true)
     },
-    //  重置
+    //  重置产品列表
     resetSearchForm () {
       this.queryParam.name = ''
       this.queryParam.code = ''
@@ -449,6 +502,12 @@ export default {
       this.productType = []
       this.$refs.table.refresh(true)
     },
+    //  重置已选产品列表
+    resetChooseSearchForm () {
+      this.queryChooseParam.name = ''
+      this.queryChooseParam.code = ''
+      this.$refs.chooseTable.refresh(true)
+    },
     // 打印预览/快捷打印
     handlePrint (type, printerType) {
       const _this = this
@@ -577,6 +636,7 @@ export default {
         title: '提示',
         content: '删除后不可恢复,确定要进行删除吗?',
         centered: true,
+        closable: true,
         onOk () {
           _this.spinning = true
           sparePartsPurDetailDel({ id: row.id }).then(res => {
@@ -591,15 +651,25 @@ export default {
         }
       })
     },
-    //  编辑基本信息
-    handleEditInfo () {
-      this.openModal = true
-    },
-    //  基本信息  保存
-    handleOk () {},
-    //  导入明细
-    handleImport () {
-      console.log(333)
+    // 整单删除
+    delBulkOrder () {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '删除后不可恢复,确认删除所有已选产品吗?',
+        centered: true,
+        closable: true,
+        onOk () {
+          _this.spinning = true
+          sparePartsPurDeleteAll({ sn: _this.$route.params.sn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.chooseTable.refresh()
+            }
+            _this.spinning = false
+          })
+        }
+      })
     },
     //  返回列表
     handleBack () {
@@ -694,12 +764,21 @@ export default {
         }
       })
     },
+    // 确认导入明细
+    hanldeImprotOk (obj) {
+      this.spinning = true
+      sparePartsPurDetailInsertBatch(obj).then(res => {
+        if (res.status == 200) {
+          this.resetChooseSearchForm()
+        }
+        this.spinning = false
+      })
+    },
     initPage () {
       this.getWarehouseCascade()
       this.getDetail()
       this.resetSearchForm()
       this.$refs.chooseTable.refresh(true)
-      this.openModal = false
       this.$refs.searchProductCode.focus()
     }
   },

+ 201 - 0
src/views/bulkManagement/bulkWarehousingOrder/importGuideModal.vue

@@ -0,0 +1,201 @@
+<template>
+  <a-modal
+    centered
+    class="importGuide-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="导入产品"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="800">
+    <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>
+          </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="attach"
+              :action="attachAction"
+              :uploadParams="uploadParams"
+              upText="选择导入文件"
+              @remove="resetSearchForm"
+              @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'
+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 + '/sparePartsPur/detail/import',
+      paramsData: null,
+      uploadParams: {
+        savePathType: 'local',
+        sparePartsPurchaseSn: this.params.sparePartsPurchaseSn
+      }
+    }
+  },
+  methods: {
+    // 清空数据
+    resetSearchForm () {
+      this.$refs.importUpload.setFileList() //  清空导入文件
+      this.paramsData = null //  清空上传数据
+    },
+    // 下一步
+    handlerNextStep () {
+      if (this.paramsData) {
+        this.openImportModal = true
+      } else {
+        this.$message.warning('添加文件后再进行下一步操作!')
+      }
+    },
+    // 上传文件  change
+    changeImport (file) {
+      // console.log(file, JSON.parse(file))
+      if (file && JSON.parse(file).length > 0) {
+        this.paramsData = Object.assign({}, JSON.parse(file)[0] || null, this.params)
+      } else {
+        this.paramsData = null
+      }
+    },
+    // 导入
+    hanldeOk (obj) {
+      if (obj && obj.length > 0) {
+        this.$emit('ok', obj)
+        this.isShow = false
+      }
+    },
+    // 关闭
+    handleClose () {
+      this.openImportModal = false
+      this.isShow = false
+    },
+    // 下载模板
+    handleExport () {
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/template/SalesDetailImport.xlsx'
+      link.setAttribute('download', '散件入库产品导入模板' + '.xlsx')
+      document.body.appendChild(link)
+      link.click()
+      document.body.removeChild(link)
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.resetSearchForm()
+      }
+    }
+  }
+}
+</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>