|
@@ -0,0 +1,239 @@
|
|
|
+<template>
|
|
|
+ <a-modal
|
|
|
+ centered
|
|
|
+ class="chooseImport-modal"
|
|
|
+ :footer="null"
|
|
|
+ :maskClosable="false"
|
|
|
+ title="确认导入"
|
|
|
+ v-model="isShow"
|
|
|
+ @cancel="isShow=false"
|
|
|
+ width="72%">
|
|
|
+ <a-spin :spinning="spinning" tip="Loading...">
|
|
|
+ <div class="chooseImport-con">
|
|
|
+ <p>产品款数与产品数量不符:Y6508N(17/18);Y6509N(15/18)</p>
|
|
|
+ <!-- 列表 -->
|
|
|
+ <s-table
|
|
|
+ class="sTable fixPagination"
|
|
|
+ ref="table"
|
|
|
+ style="height: 500px"
|
|
|
+ size="small"
|
|
|
+ :rowClassName="(record, index) => record.isError==1 ? 'redBg-row':''"
|
|
|
+ :rowKey="(record) => record.id"
|
|
|
+ :columns="columns"
|
|
|
+ :data="loadData"
|
|
|
+ :scroll="{ y:430}"
|
|
|
+ :defaultLoadData="false"
|
|
|
+ bordered>
|
|
|
+ </s-table>
|
|
|
+ <!-- 按钮 -->
|
|
|
+ <div class="btn-con">
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ id="chooseImport-submit"
|
|
|
+ size="large"
|
|
|
+ class="button-primary"
|
|
|
+ @click="handleConfirm"
|
|
|
+ style="padding: 0 40px;">确认导入</a-button>
|
|
|
+ <a-button
|
|
|
+ id="chooseImport-cancel"
|
|
|
+ size="large"
|
|
|
+ class="button-cancel"
|
|
|
+ @click="handleCancel"
|
|
|
+ style="padding: 0 40px;margin-left: 15px;">取消</a-button>
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ id="chooseImport-error"
|
|
|
+ size="large"
|
|
|
+ class="button-error"
|
|
|
+ @click="handleExportError"
|
|
|
+ style="padding: 0 40px;margin-left: 15px;">导出错误项</a-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <common-modal
|
|
|
+ :openModal="openTipsModal"
|
|
|
+ :modalHtml="modalHtml"
|
|
|
+ modalTit="操作提示"
|
|
|
+ okText="确定"
|
|
|
+ :isCancel="false"
|
|
|
+ @ok="operationEnd"
|
|
|
+ @close="openTipsModal=false" />
|
|
|
+ </a-spin>
|
|
|
+ </a-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { commonMixin } from '@/utils/mixin'
|
|
|
+import { STable, Upload } from '@/components'
|
|
|
+import { stockImportList, stockImportFinish, stockImportCancel, stockImportKCExportError } from '@/api/stockImport'
|
|
|
+import { downloadExcel } from '@/libs/JGPrint.js'
|
|
|
+import commonModal from '@/views/common/commonModal.vue'
|
|
|
+export default {
|
|
|
+ name: 'StockImportList',
|
|
|
+ components: { STable, Upload, commonModal },
|
|
|
+ mixins: [commonMixin],
|
|
|
+ props: {
|
|
|
+ openModal: { // 弹框显示状态
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ paramsData: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {
|
|
|
+ return {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ isShow: this.openModal, // 是否打开弹框
|
|
|
+ openTipsModal: false,
|
|
|
+ modalHtml: '',
|
|
|
+ spinning: false,
|
|
|
+ exportLoading: false, // 导出loading
|
|
|
+ // 加载数据方法 必须为 Promise 对象
|
|
|
+ loadData: parameter => {
|
|
|
+ this.spinning = true
|
|
|
+ return stockImportList(Object.assign(parameter, { stockImportSn: this.uploadData && this.uploadData.stockImportSn })).then(res => {
|
|
|
+ let data
|
|
|
+ if (res.status == 200) {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ const ret = data.list.filter(item => item.isError == 1)
|
|
|
+ this.isAllError = ret.length == data.count
|
|
|
+ this.listData = data.list
|
|
|
+ if (this.uploadData && data.list.length == 0) {
|
|
|
+ this.$message.info('没有可导入数据,请检查模板是否为空')
|
|
|
+ this.resetSearchForm()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.spinning = false
|
|
|
+ return data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ isAllError: false, // 是否全部错误
|
|
|
+ listData: [],
|
|
|
+ columns:[
|
|
|
+ { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
|
|
|
+ { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '唯一码', dataIndex: 'warehouseName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '工厂出库单号', dataIndex: 'warehouseLocationName', width: '25%', align: 'center', customRender: function (text) { return text || '--' } },
|
|
|
+ { title: '错误原因', dataIndex: 'errorMsg', width: '30%', align: 'center', customRender: function (text) { return text || '--' } }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ resetSearchForm () {
|
|
|
+ this.$refs.table.clearTable() // 清空列表数据
|
|
|
+ this.uploadData = null // 清空上传数据
|
|
|
+ },
|
|
|
+ // 确认导入
|
|
|
+ handleConfirm () {
|
|
|
+ const _this = this
|
|
|
+ if (this.isAllError) {
|
|
|
+ this.$message.error('没有可导入的数据!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ _this.spinning = true
|
|
|
+ stockImportFinish({ stockImportSn: _this.uploadData && _this.uploadData.stockImportSn }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$message.success(res.message)
|
|
|
+ _this.showSuccessModal(res.data)
|
|
|
+ _this.spinning = false
|
|
|
+ } else {
|
|
|
+ _this.spinning = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showSuccessModal (data) {
|
|
|
+ if (data) {
|
|
|
+ this.openTipsModal = true
|
|
|
+ this.$emit('close')
|
|
|
+ this.modalHtml = `<div><div>库存导入成功</div><div>入库类型:库存导入</div><div>库存批次:${data.stockBatchNo}</div><div>总导入款数:${data.productTotalCategory}</div><div>总入库数量:${data.productTotalQty}</div><div>总入库成本:${data.productTotalCost}</div></div>`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 操作完成
|
|
|
+ operationEnd () {
|
|
|
+ this.$emit('ok')
|
|
|
+ this.openTipsModal = false
|
|
|
+ this.isShow = false
|
|
|
+ this.resetSearchForm()
|
|
|
+ },
|
|
|
+ // 取消导入
|
|
|
+ handleCancel () {
|
|
|
+ const _this = this
|
|
|
+ _this.spinning = true
|
|
|
+ stockImportCancel({ stockImportSn: _this.uploadData && _this.uploadData.stockImportSn }).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$message.success(res.message)
|
|
|
+ _this.spinning = false
|
|
|
+ _this.isShow = false
|
|
|
+ _this.resetSearchForm()
|
|
|
+ } else {
|
|
|
+ _this.spinning = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 导出错误项
|
|
|
+ handleExportError () {
|
|
|
+ const _this = this
|
|
|
+ _this.spinning = true
|
|
|
+ stockImportKCExportError({ stockImportSn: _this.uploadData && _this.uploadData.stockImportSn }).then(res => {
|
|
|
+ _this.spinning = false
|
|
|
+ if (res.type == 'application/json') {
|
|
|
+ var reader = new FileReader()
|
|
|
+ reader.addEventListener('loadend', function () {
|
|
|
+ const obj = JSON.parse(reader.result)
|
|
|
+ _this.$notification.error({
|
|
|
+ message: '提示',
|
|
|
+ description: obj.message
|
|
|
+ })
|
|
|
+ })
|
|
|
+ reader.readAsText(res)
|
|
|
+ } else {
|
|
|
+ downloadExcel(res, '库存导入错误项')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // 父页面传过来的弹框状态
|
|
|
+ openModal (newValue, oldValue) {
|
|
|
+ this.isShow = newValue
|
|
|
+ },
|
|
|
+ // 重定义的弹框状态
|
|
|
+ isShow (newValue, oldValue) {
|
|
|
+ if (!newValue) {
|
|
|
+ this.$emit('close')
|
|
|
+ } else {
|
|
|
+ if (this.paramsData) {
|
|
|
+ this.uploadData = this.paramsData
|
|
|
+ const _this = this
|
|
|
+ this.$nextTick(() => {
|
|
|
+ _this.$refs.table.refresh(true)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+ .chooseImport-modal{
|
|
|
+ .chooseImport-con{
|
|
|
+ /deep/.redBg-row{
|
|
|
+ background-color: #F39494 !important;
|
|
|
+ }
|
|
|
+ .btn-con{
|
|
|
+ text-align: center;
|
|
|
+ margin: 30px 0 20px;
|
|
|
+ .button-cancel,.button-error{
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|