123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842 |
- <template>
- <div class="bulkWarehousingOrderEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 内容 -->
- <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderEdit-cont" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="bulkWarehousingOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span class="head-order-number">单号:{{ (basicInfoData&&basicInfoData.sparePartsPurchaseNo) || '' }}</span>
- <a-button type="primary" ghost @click="isShowBisiceInfo=!isShowBisiceInfo">
- 基础信息
- <a-icon :type="isShowBisiceInfo ? 'up' : 'down'"/>
- </a-button>
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <template slot="extra" v-if="$hasPermissions('B_bulkWarehousingOrder_print')">
- <Print :disabled="chooseLoadDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
- </template>
- </a-page-header>
- <!-- 基础信息 -->
- <div v-show="isShowBisiceInfo" class="bulkWarehousingOrderEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="基础信息" :disabled="true">
- <a-row :gutter="16">
- <a-col class="gutter-row" :span="8">
- 供应商:{{ (basicInfoData&&basicInfoData.supplierName) || '--' }}
- </a-col>
- <a-col class="gutter-row" :span="8">
- 散件入库类型:{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '--' }}
- </a-col>
- <a-col class="gutter-row" :span="8">
- 备注:{{ (basicInfoData&&basicInfoData.remarks) || '--' }}
- </a-col>
- </a-row>
- </a-collapse-panel>
- </a-collapse>
- </div>
- <!-- 选择产品 -->
- <div class="bulkWarehousingOrderEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1">
- <template slot="header">
- 选择产品<span class="sub-title">①输入查询条件--->②查找到需要入库的配件--->③录入成本价、数量、仓库、仓位--->④点击“添加”</span>
- </template>
- <!-- 选择产品 -->
- <div>
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row type="flex" :gutter="12" justify="start">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input id="bulkWarehousingOrderEdit-code" ref="searchProductCode" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input id="bulkWarehousingOrderEdit-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="原厂编码">
- <a-input id="bulkWarehousingOrderEdit-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
- </a-form-model-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-item label="产品分类">
- <ProductType id="bulkWarehousingOrderEdit-productType" @change="changeProductType" v-model="productType"></ProductType>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品品牌">
- <ProductBrand id="bulkWarehousingOrderEdit-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
- </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="bulkWarehousingOrderEdit-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="bulkWarehousingOrderEdit-reset">重置</a-button>
- <a @click="advanced=!advanced" style="margin:0 30px 0 10px" id="bulkWarehousingOrderEdit-advanced">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- @dblclick="handleClickRow"
- :data="loadData"
- :defaultLoadData="false"
- :scroll="{ y: 150 }"
- bordered>
- <!-- 成本价 -->
- <template slot="putCost" slot-scope="text, record">
- <div @dblclick.stop>
- <a-input-number
- size="small"
- :id="'bulkWarehousingOrderEdit-putCost-'+record.id"
- v-model="record.putCost"
- :precision="2"
- :min="0"
- :max="999999"
- placeholder="请输入"
- class="rightPrice"
- style="width: 100%;" />
- </div>
- </template>
- <!-- 数量 -->
- <template slot="putQty" slot-scope="text, record">
- <div @dblclick.stop>
- <a-input-number
- size="small"
- @dblclick.stop
- :id="'bulkWarehousingOrderEdit-putQty-'+record.id"
- v-model="record.putQty"
- :precision="0"
- :min="1"
- :max="999999"
- placeholder="请输入"
- style="width: 100%;" />
- </div>
- </template>
- <!-- 仓库仓位 -->
- <template slot="warehouse" slot-scope="text, record, index">
- <div @dblclick.stop>
- <a-cascader
- size="small"
- @change="e => changeWarehouseCascade(e, record, index, 'dealerProduct')"
- v-model="record.warehouseCascade"
- expand-trigger="hover"
- :allowClear="false"
- :options="warehouseCascadeData"
- :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
- :id="'bulkWarehousingOrderEdit-warehouseCascade-'+record.id"
- placeholder="请选择仓库仓位"
- style="width: 100%;" />
- </div>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="link" class="button-primary" @click="handleAdd(record)" id="bulkWarehousingOrderEdit-add-btn">添加</a-button>
- </template>
- </s-table>
- </div>
- </a-collapse-panel>
- </a-collapse>
- </div>
- <!-- 已选产品 -->
- <div class="bulkWarehousingOrderEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1">
- <template slot="header">
- 已选产品
- </template>
- <!-- 已选产品 -->
- <div>
- <!-- 总计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div slot="message">
- 总款数 <strong>{{ (productTotal&&(productTotal.productTotalCategory || productTotal.productTotalCategory==0)) ? productTotal.productTotalCategory : '--' }}</strong> ,
- 总数量 <strong>{{ (productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0)) ? productTotal.productTotalQty : '--' }}</strong> ,
- 总成本 <strong>{{ (productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0)) ? toThousands(productTotal.productTotalCost,2) : '--' }}</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="5" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input id="chooseTable-code" v-model.trim="queryChooseParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input id="chooseTable-name" v-model.trim="queryChooseParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="5" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="disabled" id="chooseTable-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetChooseSearchForm" :disabled="disabled" id="chooseTable-reset">重置</a-button>
- </a-col>
- <a-col :md="3" :sm="24">
- </a-col>
- <a-col :md="6" :sm="24" style="text-align:right;">
- <a-button
- type="default"
- @click="openGuideModal=true"
- :loading="delLoading"
- id="chooseTable-import">导入产品</a-button>
- <a-button
- type="primary"
- ghost
- :disabled="chooseLoadDataSource.length==0"
- style="margin-left: 10px"
- @click="delBulkOrder"
- :loading="delLoading"
- id="chooseTable-del-all">清空列表</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="chooseTable"
- size="small"
- :rowKey="(record) => record.id"
- :columns="chooseColumns"
- :data="chooseLoadData"
- :defaultLoadData="false"
- :scroll="{ y: 200 }"
- bordered>
- <!-- 成本价 -->
- <template slot="putCost" slot-scope="text, record">
- <a-input-number
- size="small"
- :id="'chooseTable-putCost-'+record.id"
- v-model="record.putCost"
- :precision="2"
- :min="0"
- :max="999999"
- placeholder="请输入"
- class="rightPrice"
- @blur="e => putCostBlur(e.target.value, record)"
- style="width: 100%;" />
- </template>
- <!-- 数量 -->
- <template slot="putQty" slot-scope="text, record">
- <a-input-number
- size="small"
- :id="'chooseTable-putQty-'+record.id"
- v-model="record.putQty"
- :precision="0"
- :min="1"
- :max="999999"
- placeholder="请输入"
- @blur="e => putQtyBlur(e.target.value, record)"
- style="width: 100%;" />
- </template>
- <!-- 仓库仓位 -->
- <template slot="warehouse" slot-scope="text, record, index">
- <a-cascader
- size="small"
- @change="e => changeWarehouseCascade(e, record, index, 'sparePartsPurDetail')"
- v-model="record.warehouseCascade"
- expand-trigger="hover"
- :allowClear="false"
- :options="warehouseCascadeData"
- :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
- :id="'chooseTable-warehouseCascade-'+record.id"
- placeholder="请选择仓库仓位"
- style="width: 100%;" />
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="link" class="button-error" @click="handleDel(record)" :id="'chooseTable-del-'+record.id">删除</a-button>
- </template>
- </s-table>
- </div>
- </a-collapse-panel>
- </a-collapse>
- </div>
- </a-spin>
- <div class="affix-cont">
- <a-button
- type="primary"
- id="bulkWarehousingOrderEdit-submit"
- size="large"
- :disabled="spinning"
- class="button-primary"
- @click="handleSubmit"
- style="padding: 0 60px;">提交</a-button>
- </div>
- <!-- 导入费用明细 -->
- <importGuideModal
- :openModal="openGuideModal"
- :params="{sparePartsPurchaseSn: $route.params.sn}"
- @close="openGuideModal=false"
- @ok="hanldeImprotOk" />
- <!-- 新增产品 -->
- <a-modal
- centered
- class="newProduct-modal"
- :footer="null"
- :maskClosable="false"
- title="新增产品"
- v-model="showNewProduct"
- @cancel="showNewProduct=false"
- :width="800">
- <newProduct
- ref="newProduct"
- :saveing="spinning"
- :paramsData="paramsData"
- pageType="modal"
- @cansel="showNewProduct=false"
- @saveOk="saveProductOk"></newProduct>
- </a-modal>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import { getOperationalPrecision } from '@/libs/tools.js'
- 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, Print, ProductType, ProductBrand, newProduct, importGuideModal },
- mixins: [commonMixin],
- data () {
- const _this = this
- return {
- isShowBisiceInfo: false, // 是否显示基础信息
- advanced: false, // 展开收起
- spinning: false,
- loading: false,
- delLoading: false, // 删除按钮loading
- showNewProduct: false, // 新增产品弹框
- openGuideModal: false, // 导入产品弹框
- queryParam: {
- code: '', // 产品编码
- name: '', // 产品名称
- origCode: '', // 原厂编码
- productBrandSn: undefined, // 产品品牌sn
- productTypeSn1: undefined, // 产品分类1sn
- productTypeSn2: undefined, // 产品分类2sn
- productTypeSn3: undefined // 产品分类3sn
- },
- queryChooseParam: {
- productCode: '', // 产品编码
- productName: '' // 产品名称
- },
- productType: [], // 产品分类默认值
- warehouseCascadeData: [], // 仓库仓位
- disabled: false, // 查询、重置按钮是否可操作
- paramsData: null, // 新增产品临时参数
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'code', width: '14%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'name', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'origCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品品牌', dataIndex: 'productBrandName', width: '10%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '单位', dataIndex: 'unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: '7%', align: 'center' },
- { title: '数量', scopedSlots: { customRender: 'putQty' }, width: '7%', align: 'center' },
- { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '13%', align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- parameter.sortAlias = 'dp'
- const params = Object.assign(parameter, this.queryParam, { supplierSn: this.$route.params.supplierSn })
- return bulkProductList(params).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
- data.list[i].putCost = data.list[i].purchasePrice
- data.list[i].putQty = data.list[i].putQty || 1
- // 默认仓库仓位
- if (this.defaultWarehouseCascade.length > 0) {
- data.list[i].warehouseCascade = this.defaultWarehouseCascade
- data.list[i].warehouseSn = this.defaultWarehouseCascade[0]
- data.list[i].warehouseLocationSn = this.defaultWarehouseCascade[1]
- } else {
- data.list[i].warehouseCascade = undefined
- }
- }
- this.loadDataSource = data.list
- this.disabled = false
- // 如果没有搜索到产品,直接添加产品
- this.isAddNewProduct(data.list)
- return data
- })
- },
- // 表头
- chooseColumns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
- { title: '产品名称', dataIndex: 'productName', width: '14%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品品牌', dataIndex: 'brandName', width: '10%', align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '单位', dataIndex: 'productUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '成本价', scopedSlots: { customRender: 'putCost' }, width: '7%', align: 'center' },
- { title: '数量', scopedSlots: { customRender: 'putQty' }, width: '7%', align: 'center' },
- { title: '成本小计', dataIndex: 'costSubtotal', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
- { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '13%', align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- chooseLoadData: parameter => {
- // 排序
- if (parameter.sortField == 'brandName') {
- parameter.sortField = 'productBrandName'
- parameter.sortAlias = 'dp'
- }
- if (parameter.sortField == 'productName') {
- parameter.sortField = 'productCode'
- parameter.sortAlias = 'sppd'
- }
- const params = Object.assign(parameter, this.queryChooseParam, { sparePartsPurchaseSn: this.$route.params.sn })
- return sparePartsPurDetailList(params).then(res => {
- this.getDetailCount(params)
- 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
- data.list[i].putCostBackups = data.list[i].putCost
- data.list[i].putQtyBackups = data.list[i].putQty
- // 默认仓库仓位
- const warehouseSn = data.list[i].warehouseSn || undefined
- const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
- if (warehouseSn || warehouseLocationSn) {
- data.list[i].warehouseSnBackups = warehouseSn
- data.list[i].warehouseLocationSnBackups = warehouseLocationSn
- data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
- } else {
- data.list[i].warehouseCascade = undefined
- }
- // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
- data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
- }
- this.chooseLoadDataSource = data.list
- return data
- })
- },
- loadDataSource: [], // 产品列表原始数据
- chooseLoadDataSource: [], // 已选产品列表原始数据
- warehouseList: [], // 仓库 下拉数据
- warehouseLocList: {}, // 仓位 下拉数据
- defaultWarehouseCascade: [], // 默认仓库仓位
- chooseWarehouseList: [], // 已选产品 仓库 下拉数据
- chooseWarehouseLocList: {}, // 已选产品 仓位 下拉数据
- basicInfoData: null, // 基本信息
- productTotal: null // 合计
- }
- },
- methods: {
- // 是否新增产品
- isAddNewProduct (data) {
- const _this = this
- if (data.length == 0) {
- _this.$confirm({
- title: '提示',
- content: '该产品信息不存在,是否马上新增?',
- centered: true,
- onOk () {
- _this.paramsData = {
- supplierName: _this.basicInfoData.supplierName,
- code: _this.queryParam.code,
- name: _this.queryParam.name,
- origCode: _this.queryParam.origCode,
- putCost: 0,
- putQty: 1,
- warehouse: []
- }
- _this.showNewProduct = true
- _this.$nextTick(() => {
- _this.$refs.newProduct.pageInit()
- })
- }
- })
- } else {
- // 新添加的产品自动添加到已选产品中
- if (data.length == 1 && this.showNewProduct) {
- data[0].putCost = this.paramsData.putCost
- data[0].putQty = this.paramsData.putQty
- data[0].warehouseSn = this.paramsData.warehouse[0] || ''
- data[0].warehouseLocationSn = this.paramsData.warehouse[1] || ''
- this.handleAdd(data[0])
- }
- }
- },
- // 添加产品成功
- saveProductOk (data) {
- this.paramsData = data
- this.queryParam.code = data.code
- this.$refs.table.refresh(true)
- this.spinning = false
- },
- // 重置产品列表
- resetSearchForm () {
- this.queryParam.name = ''
- this.queryParam.code = ''
- this.queryParam.origCode = ''
- this.queryParam.productBrandSn = undefined
- this.queryParam.productTypeSn1 = ''
- this.queryParam.productTypeSn2 = ''
- this.queryParam.productTypeSn3 = ''
- this.productType = []
- this.$refs.table.refresh(true)
- },
- // 重置已选产品列表
- resetChooseSearchForm () {
- this.queryChooseParam.productName = ''
- this.queryChooseParam.productCode = ''
- this.$refs.chooseTable.refresh(true)
- },
- // 打印预览/快捷打印
- handlePrint (type, printerType) {
- const _this = this
- _this.spinning = true
- const url = sparePartsPurDetailPrint
- const params = { sn: this.$route.params.sn, type: printerType }
- // 打印或导出
- hdPrint(printerType, type, url, params, '散件入库', function () {
- _this.spinning = false
- })
- },
- // 双击快速添加
- handleClickRow (record) {
- this.handleAdd(record)
- },
- // 基本信息
- getDetail () {
- sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
- if (res.status == 200) {
- this.basicInfoData = res.data
- } else {
- this.basicInfoData = null
- }
- })
- },
- // 添加/编辑
- handleAdd (row, isEdit) {
- const _this = this
- if (!isEdit && !(row.putCost || row.putCost == 0)) {
- _this.$message.warning('请输入成本价后再添加!')
- return
- }
- if (!isEdit && !row.putQty) {
- _this.$message.warning('请输入数量后再添加!')
- return
- }
- if (!isEdit && !row.warehouseSn) {
- _this.$message.warning('请选择仓库后再添加!')
- return
- }
- if (!isEdit && !row.warehouseLocationSn) {
- _this.$message.warning('请选择仓位后再添加!')
- return
- }
- if (!isEdit && row.enabledFlag == 0) {
- _this.$message.warning('产品已禁用,不能添加!')
- return
- }
- // if (!isEdit && row.enabledFlag == '0') {
- // _this.$confirm({
- // title: '提示',
- // content: '该产品已禁用,确认继续添加吗?',
- // centered: true,
- // onOk () {
- // _this.saveFormData(row, isEdit)
- // }
- // })
- // return
- // }
- _this.saveFormData(row, isEdit)
- },
- // 保存
- saveFormData (row, isEdit) {
- const params = {
- id: isEdit ? row.id : undefined,
- sparePartsPurchaseSn: this.$route.params.sn,
- putCost: row.putCost,
- putQty: row.putQty,
- productCode: isEdit ? row.productCode : row.code,
- productOrigCode: (isEdit ? row.productOrigCode : row.origCode) || undefined,
- productSn: row.productSn,
- productTypeSn1: row.productTypeSn1,
- productTypeSn2: row.productTypeSn2,
- productTypeSn3: row.productTypeSn3,
- brandSn: isEdit ? row.brandSn : row.productBrandSn,
- warehouseLocationSn: row.warehouseLocationSn,
- warehouseSn: row.warehouseSn
- }
- if (isEdit) { // 编辑
- // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
- if (!(row.putCost || row.putCost == 0)) {
- row.putCost = row.putCostBackups
- return
- }
- if (!row.putQty) {
- row.putQty = row.putQtyBackups
- return
- }
- }
- this.spinning = true
- sparePartsPurDetailSave(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.chooseTable.refresh()
- this.spinning = false
- } else {
- this.spinning = false
- }
- this.paramsData = null
- this.showNewProduct = false
- })
- },
- // 提交
- handleSubmit () {
- const _this = this
- _this.spinning = true
- sparePartsPurSubmit({ id: this.$route.params.id }).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- setTimeout(() => {
- _this.handleBack()
- _this.spinning = false
- }, 1000)
- } else {
- _this.spinning = false
- }
- })
- },
- // 删除
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '删除后不可恢复,确定要进行删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.spinning = true
- sparePartsPurDetailDel({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.chooseTable.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 清空列表
- 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 () {
- this.$router.push({ name: 'bulkWarehousingOrderList' })
- },
- // 合计
- getDetailCount (params) {
- sparePartsPurDetailCount(params).then(res => {
- if (res.status == 200) {
- this.productTotal = res.data
- } else {
- this.productTotal = null
- }
- })
- },
- // 选择仓库仓位
- changeWarehouseCascade (val, opt, ind, type) {
- let loadData
- if (type == 'dealerProduct') { // 全部产品
- loadData = this.loadDataSource[ind]
- } else if (type == 'sparePartsPurDetail') { // 已选产品
- loadData = this.chooseLoadDataSource[ind]
- }
- // 如果仓库无仓位
- if (val.length < 2) {
- this.$message.warning('当前仓库无仓位,请选择其他仓库')
- const warehouseSnBackups = loadData.warehouseSnBackups || undefined
- const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
- loadData.warehouseSn = warehouseSnBackups
- loadData.warehouseLocationSn = warehouseLocationSnBackups
- if (warehouseSnBackups || warehouseLocationSnBackups) {
- loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
- } else {
- loadData.warehouseCascade = undefined
- }
- } else {
- loadData.warehouseSn = val[0] ? val[0] : ''
- loadData.warehouseLocationSn = val[1] ? val[1] : ''
- if (type == 'sparePartsPurDetail') { // 已选产品
- loadData = this.chooseLoadDataSource[ind]
- this.handleAdd(loadData, 'edit')
- }
- }
- },
- // 已选产品 成本价 blur
- putCostBlur (val, record) {
- // 光标移出,值发生改变再调用编辑接口
- if (val != record.putCostBackups || !val) {
- this.handleAdd(record, 'edit')
- }
- },
- // 已选产品 数量 blur
- putQtyBlur (val, record) {
- if (val != record.putQtyBackups) {
- this.handleAdd(record, 'edit')
- }
- },
- // 产品分类 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] : ''
- },
- // 仓库仓位 级联 列表
- getWarehouseCascade () {
- const _this = this
- warehouseCascadeList({}).then(res => {
- if (res.status == 200) {
- res.data.filter(item => {
- // 过滤默认仓库
- if (item.defaultFlag == 1 && item.wasteFlag == 0) { // defaultFlag为1,且不是废品仓
- _this.defaultWarehouseCascade[0] = item.warehouseSn
- // 过滤默认仓位
- item.warehouseLocationList.filter(subItem => {
- if (subItem.defaultFlag == 1 && subItem.wasteFlag == 0) {
- _this.defaultWarehouseCascade[1] = subItem.warehouseLocationSn
- // _this.$refs.table.refresh(true)
- // _this.$refs.chooseTable.refresh(true)
- }
- })
- }
- })
- res.data.map(item => {
- item.sn = item.warehouseSn
- if (item.warehouseLocationList) {
- item.warehouseLocationList.map(subItem => {
- subItem.sn = subItem.warehouseLocationSn
- })
- }
- })
- this.warehouseCascadeData = res.data
- } else {
- this.warehouseCascadeData = []
- }
- })
- },
- // 确认导入明细
- 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.$refs.searchProductCode.focus()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.initPage()
- }
- },
- activated () {
- // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.initPage()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .bulkWarehousingOrderEdit-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 51px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: auto;
- height: 100%;
- }
- .bulkWarehousingOrderEdit-cont{
- margin-bottom: 10px;
- .sub-title{
- font-size: 12px;
- color: #808695;
- margin-left: 10px;
- }
- }
- .rightPrice.ant-input-number-sm input{
- text-align: right;
- }
- .ant-collapse .ant-collapse-item-disabled > .ant-collapse-header{
- color:#333;
- }
- }
- </style>
|