123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632 |
- <template>
- <div class="warehouseAllocationEdit-wrap">
- <a-page-header :ghost="false" :backIcon="false" class="warehouseAllocationEdit-back" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="warehouseAllocationEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">调出仓库:{{ (warehouse&&warehouse.outWarehouseName) || '--' }}</span>
- <span style="margin: 0 15px;color: #666;">调入仓库:{{ (warehouse&&warehouse.putWarehouseName) || '--' }}</span>
- <!-- <a-button id="warehouseAllocationEdit-edit-btn" size="small" @click="handleEditInfo" style="margin-left:10px" key="0">编辑</a-button> -->
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <template slot="extra">
- <a-button key="2" id="warehouseAllocationEdit-preview-btn">打印预览</a-button>
- <a-button key="1" type="primary" id="warehouseAllocationEdit-print-btn">快速打印</a-button>
- </template>
- </a-page-header>
- <!-- 选择产品 -->
- <a-card size="small" :bordered="false" class="warehouseAllocationEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="选择产品">
- <!-- 筛选条件 -->
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="getProductList">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="产品编码" prop="productCode">
- <a-input id="warehouseAllocationEdit-productCode" v-model="queryParam.productCode" placeholder="请输入产品编码" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品名称" prop="productName">
- <a-input id="warehouseAllocationEdit-productName" v-model="queryParam.productName" placeholder="请输入产品名称" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="原厂编码" prop="productOrigCode">
- <a-input
- id="warehouseAllocationEdit-productOrigCode"
- v-model="queryParam.productOrigCode"
- placeholder="请输入原厂编码"
- allowClear />
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-item label="产品品牌" prop="brandSn">
- <a-select
- placeholder="请选择"
- id="warehouseAllocationEdit-state"
- allowClear
- v-model="queryParam.brandSn"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption">
- <a-select-option
- v-for="item in brandData"
- :key="item.brandSn"
- :value="item.brandSn">{{ item.brandName }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品分类" prop="typeName">
- <a-cascader
- :field-names="{ label: 'productTypeName', value: 'productTypeSn', children: 'children'}"
- :options="typeData"
- id="warehouseAllocationEdit-typeName"
- placeholder="请选择产品分类"
- allowClear
- v-model="typeName" />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="调出仓位" prop="warehouseLocationSn">
- <a-select
- id="warehouseAllocationEdit-warehouseLocationSn"
- placeholder="请选择"
- allowClear
- v-model="queryParam.warehouseLocationSn"
- style="width: 100%;">
- <a-select-option
- v-for="item in warehouseOutLocData"
- :key="item.warehouseLocationSn"
- :value="item.warehouseLocationSn">
- {{ item.name }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24" style="margin-bottom: 24px;">
- <a-button
- type="primary"
- @click="getProductList"
- :disabled="disabled"
- id="warehouseAllocationList-refresh">查询</a-button>
- <a-button
- style="margin-left: 8px"
- @click="resetSearchForm"
- :disabled="disabled"
- id="warehouseAllocationList-reset">重置</a-button>
- <a @click="advanced=!advanced" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'" />
- </a>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 列表 -->
- <a-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :loading="loading"
- :dataSource="loadData"
- :pagination="pagination"
- @change="getProductList"
- :scroll="{ x: 1740, y: 300 }"
- bordered>
- <!-- 产品分类 -->
- <template slot="productType" slot-scope="text, record">
- <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
- <span v-else>--</span>
- </template>
- <!-- 调入仓位 -->
- <template slot="storageQuantity" slot-scope="text, record">
- <a-select
- id="warehouseAllocationEdit-warehouse"
- placeholder="请选择"
- allowClear
- v-model="record.putWarehouseLocationSn"
- style="width: 100%;">
- <a-select-option
- v-for="item in warehousePutLocData"
- :key="item.warehouseLocationSn"
- :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
- </a-select>
- </template>
- <!-- 调出数量 -->
- <template slot="transferOutQuantity" slot-scope="text, record">
- <a-input-number
- id="warehouseAllocationEdit-allocationQty"
- v-model="record.allocationQty"
- :min="0"
- :max="record.currentQty"
- placeholder="请输入" />
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text,record">
- <a-button
- :loading="record.addLoading"
- size="small"
- type="primary"
- class="button-primary"
- @click="handleAdd(record)"
- id="warehouseAllocationEdit-add-btn">添加</a-button>
- </template>
- </a-table>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- <!-- 已选产品 -->
- <a-card size="small" :bordered="false" class="warehouseAllocationEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="已选产品">
- <!-- 总计 -->
- <a-alert type="info" showIcon style="margin-bottom:15px">
- <div slot="message">总成本:¥<strong>{{ productTotalCost }}</strong>,总数量:
- <strong>{{ productTotalQty }}</strong> ,总款数: <strong>{{ productTotalCategory }}</strong>
- </div>
- </a-alert>
- <!-- 筛选条件 -->
- <a-row :gutter="15" justify="space-between">
- <a-col :span="17">
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="9" :sm="24">
- <a-form-item label="产品编码" prop="productCode">
- <a-input
- id="warehouseAllocationEdit-productCode"
- v-model="chooseParam.productCode"
- placeholder="请输入产品编码"
- allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="9" :sm="24">
- <a-form-item label="产品名称" prop="productName">
- <a-input
- id="warehouseAllocationEdit-productName"
- v-model="chooseParam.productName"
- placeholder="请输入产品名称"
- allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24" style="margin-bottom: 24px;">
- <a-button
- type="primary"
- @click="$refs.chooseTable.refresh(true)"
- id="warehouseAllocationList-refresh">查询</a-button>
- <a-button
- style="margin-left: 8px"
- @click="resetChooseSearchForm"
- id="warehouseAllocationList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- </a-col>
- <a-col :span="7">
- <!-- 暂不做 -->
- <div style="float:right;overflow: hidden;">
- <!-- <a-button size="small" type="primary" id="warehouseAllocationEdit-pladd-btn" style="margin-bottom: 8px;">批量添加</a-button> -->
- <a-button size="small" id="warehouseAllocationEdit-import-btn" style="margin-left: 8px">导入明细
- </a-button>
- <a-button
- size="small"
- :loading="delLoading"
- @click="handleDel({},0)"
- type="danger"
- id="warehouseAllocationEdit-del-all-btn"
- style="margin: 0 0 8px 8px;">整单删除</a-button>
- </div>
- </a-col>
- </a-row>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="chooseTable"
- size="small"
- :rowKey="(record) => record.id"
- :columns="chooseColumns"
- :data="chooseLoadData"
- :scroll="{ x: 1600, y: 300 }"
- bordered>
- <!-- 产品分类 -->
- <template slot="productType" slot-scope="text, record">
- <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
- <span v-else>--</span>
- </template>
- <!-- 调入仓位 -->
- <template slot="storageQuantity" slot-scope="text, record">
- <a-select
- @change="handleAdd(record)"
- id="warehouseAllocationEdit-warehouse"
- placeholder="请选择"
- allowClear
- v-model="record.putWarehouseLocationSn"
- style="width: 100%;">
- <a-select-option v-for="item in warehousePutLocData" :key="item.warehouseLocationSn" :value="item.warehouseLocationSn">{{ item.name }}</a-select-option>
- </a-select>
- </template>
- <!-- 调出数量 -->
- <template slot="transferOutQuantity" slot-scope="text, record">
- <a-input-number
- id="warehouseAllocationEdit-allocationQty"
- v-model="record.allocationQty"
- :precision="0"
- :min="0"
- @change="handleAdd(record)"
- :max="record.currentQty"
- placeholder="请输入" />
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="primary"
- class="button-error"
- @click="handleDel(record,1)"
- id="warehouseAllocationEdit-del-btn">删除</a-button>
- </template>
- </s-table>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- <a-affix :offset-bottom="0">
- <div
- style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
- <a-button
- type="primary"
- id="warehouseAllocationEdit-submit"
- size="large"
- class="button-primary"
- :loading="submitLoading"
- @click="handleSubmit"
- style="padding: 0 60px;">提交</a-button>
- </div>
- </a-affix>
- <!-- 选择基本信息弹框 -->
- <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import basicInfoModal from './basicInfoModal.vue'
- import { dealerProductBrandQuery } from '@/api/dealerProductBrand.js'
- import { dealerProductTypeList } from '@/api/dealerProductType.js'
- import { warehouseLocAllList } from '@/api/warehouse.js'
- import { productQuery, allocWarehouseFind, allocWarehouseDetailTotal, allocWarehouseDetailQuery, allocWarehouseDetailSave, allocWarehouseDetailDelete, allocWarehouseSubmit } from '@/api/allocWarehouse.js'
- export default {
- components: { STable, VSelect, basicInfoModal },
- data () {
- return {
- typeName: [], // 分类
- queryParam: {
- warehouseSn: '', // 调出仓库sn
- productCode: '', // 产品编码
- productName: '', // 产品名称
- productOrigCode: '', // 原厂编码
- brandSn: undefined, // 品牌
- warehouseLocationSn: undefined // 调出仓位
- },
- chooseParam: {
- allocationWarehouseSn: this.$route.params.sn, // 单据sn
- productCode: '', // 产品编码
- productName: '' // 产品名称
- },
- productTotalCost: 0, // 总成本
- productTotalQty: 0, // 总数量
- productTotalCategory: 0, // 总款项
- warehouse: null, // 基础信息
- brandData: [], // 产品品牌 下拉数据
- typeData: [], // 产品分类 下拉数据
- warehousePutLocData: [], // 调入仓库仓位 下拉数据
- warehouseOutLocData: [], // 调出仓库仓位 下拉数据
- disabled: false, // 查询、重置按钮是否可操作
- advanced: false, // 高级搜索 展开/关闭
- delLoading: false, // 整单删除loading
- submitLoading: false, // 提交按钮loading
- // 加载数据方法 必须为 Promise 对象
- loadData: [],
- pageNo: 1,
- pageSize: 10,
- pagination: {
- current: 1,
- pageSize: 10,
- pageSizeOptions: ['10', '20', '30', '40'],
- total: 0
- },
- loading: false, // 表格加载圈
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center' },
- { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '品牌', dataIndex: 'brandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
- { title: '调出仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '调入仓位', scopedSlots: { customRender: 'storageQuantity' }, width: 140, align: 'center' },
- { title: '库存数量', dataIndex: 'currentQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '调出数量', scopedSlots: { customRender: 'transferOutQuantity' }, width: 140, align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
- ],
- // 表头
- chooseColumns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: 200, align: 'center' },
- { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '品牌', dataIndex: 'brandName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
- { title: '调出仓位', dataIndex: 'warehouseLocationSn', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '调入仓位', dataIndex: 'putWarehouseLocationSn', width: 140, align: 'center', scopedSlots: { customRender: 'storageQuantity' } },
- { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '调出数量', scopedSlots: { customRender: 'transferOutQuantity' }, width: 140, align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- chooseLoadData: parameter => {
- this.disabled = true
- return allocWarehouseDetailQuery(Object.assign(parameter, this.chooseParam)).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
- }
- this.getProduceTotal()
- this.disabled = false
- return data
- })
- },
- openModal: false // 选择基本信息弹框是否显示
- }
- },
- methods: {
- pageInit () {
- this.queryParam.productCode = '' // 产品编码
- this.queryParam.productName = '' // 产品名称
- this.queryParam.productOrigCode = '' // 原厂编码
- this.queryParam.brandSn = undefined // 品牌
- this.typeName = [] // 分类
- this.queryParam.warehouseLocationSn = undefined // 调出仓位
- this.chooseParam.productCode = ''
- this.chooseParam.productName = ''
- this.pageNo = 1
- this.pageSize = 10
- },
- // 重置
- resetSearchForm () {
- this.queryParam.productCode = '' // 产品编码
- this.queryParam.productName = '' // 产品名称
- this.queryParam.productOrigCode = '' // 原厂编码
- this.queryParam.brandSn = undefined // 品牌
- this.typeName = [] // 分类
- this.queryParam.warehouseLocationSn = undefined // 调出仓位
- this.getProductList()
- },
- // 已选产品重置查询
- resetChooseSearchForm () {
- this.chooseParam.productCode = ''
- this.chooseParam.productName = ''
- this.$refs.chooseTable.refresh(true)
- },
- // 获取产品品牌
- getProductBrand () {
- dealerProductBrandQuery({}).then(res => {
- this.brandData = res.data || []
- })
- },
- // 获取产品分类
- getProductType () {
- dealerProductTypeList({}).then(res => {
- this.typeData = res.data || []
- })
- },
- // 获取仓库仓位
- getWarehouseLoc (sn, type) {
- warehouseLocAllList({ warehouseSn: sn }).then(res => {
- if (type == 'put') {
- this.warehousePutLocData = res.data || []
- } else {
- this.warehouseOutLocData = res.data || []
- }
- })
- },
- // 查询基础信息
- getHouse () {
- allocWarehouseFind({ id: this.$route.params.id }).then(res => {
- if (res.status == 200) {
- this.warehouse = res.data
- this.queryParam.warehouseSn = res.data.outWarehouseSn
- this.getProductList()
- this.getWarehouseLoc(this.warehouse.putWarehouseSn, 'put')
- this.getWarehouseLoc(this.warehouse.outWarehouseSn, 'out')
- } else {
- this.warehouse = null
- }
- })
- },
- // 产品查询
- getProductList (pagination) {
- this.disabled = true
- this.loading = true
- this.pageNo = pagination && pagination.current ? pagination.current : this.pageNo
- this.pageSize = pagination && pagination.pageSize ? pagination.pageSize : this.pageSize
- this.pagination.current = this.pageNo
- const params = Object.assign({ pageNo: this.pageNo, pageSize: this.pageSize }, this.queryParam)
- if (this.typeName.length) {
- params.productTypeSn1 = this.typeName[0]
- params.productTypeSn2 = this.typeName[1] || ''
- params.productTypeSn3 = this.typeName[2] || ''
- }
- console.log(params, '--------------------------------params')
- productQuery(params).then(res => {
- if (res.status == 200) {
- 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].addLoading = false
- }
- this.pagination.total = Number(data.count)
- this.loadData = data.list
- } else {
- this.pagination.total = 0
- this.loadData = []
- }
- this.loading = false
- this.disabled = false
- })
- },
- // 已选产品总计查询
- getProduceTotal () {
- allocWarehouseDetailTotal(this.chooseParam).then(res => {
- if (res.status == 200) {
- this.productTotalCost = res.data.productTotalCost || 0
- this.productTotalQty = res.data.productTotalQty || 0
- this.productTotalCategory = res.data.productTotalCategory || 0
- } else {
- this.productTotalCost = 0
- this.productTotalQty = 0
- this.productTotalCategory = 0
- }
- })
- },
- // 添加
- handleAdd (row) {
- if (!row.putWarehouseLocationSn) {
- return this.$message.error('请选择调入仓位!')
- }
- if (!row.allocationQty) {
- return this.$message.error('请输入调出数量!')
- }
- row.addLoading = true
- const params = Object.assign(row, { allocationWarehouseSn: this.chooseParam.allocationWarehouseSn })
- params.allocationCost = params.putCost
- params.outWarehouseLocationSn = row.warehouseLocationSn
- allocWarehouseDetailSave(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.chooseTable.refresh(true)
- }
- row.addLoading = false
- })
- },
- // 删除 type:0 整单删除 1:单个删除
- handleDel (row, type) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '删除后不可恢复,确定要进行删除吗?',
- centered: true,
- onOk () {
- let params = {}
- if (type == 0) {
- params = {
- allocationWarehouseSn: _this.chooseParam.allocationWarehouseSn
- }
- _this.delLoading = true
- } else {
- params = {
- id: row.id
- }
- }
- allocWarehouseDetailDelete(params).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.chooseTable.refresh()
- }
- _this.delLoading = false
- })
- }
- })
- },
- // 编辑基本信息
- handleEditInfo () {
- this.openModal = true
- },
- // 基本信息 保存
- handleOk () {
- },
- // 提交
- handleSubmit () {
- this.submitLoading = true
- allocWarehouseSubmit({ id: this.$route.params.id }).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.handleBack()
- }
- })
- },
- // 导入明细
- handleImport () {
- console.log(333)
- },
- // 返回列表
- handleBack () {
- this.$router.push({
- path: '/allocationManagement/warehouseAllocation/list'
- })
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.openModal = false
- vm.pageInit()
- vm.getProductBrand()
- vm.getProductType()
- vm.getHouse()
- console.log(vm.id, vm.$route.params, 'vm.id')
- })
- }
- }
- </script>
- <style lang="less">
- .warehouseAllocationEdit-wrap {
- .warehouseAllocationEdit-back {
- margin-bottom: 15px;
- }
- .warehouseAllocationEdit-cont {
- margin-bottom: 15px;
- .sub-title {
- font-size: 12px;
- color: #808695;
- margin-left: 10px;
- }
- .tag-txt {
- font-size: 12px;
- color: #ed1c24;
- }
- .edit-circle-btn {
- margin-left: 15px;
- i {
- vertical-align: text-bottom;
- }
- }
- .import-btn {
- margin-left: 15px;
- }
- }
- }
- </style>
|