123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- <template>
- <div class="chainTransferOutEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" class="chainTransferOutEdit-back" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="chainTransferOutEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">调往对象:{{ (basicInfoData&&basicInfoData.putTenantName) || '--' }}</span>
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <template slot="extra" v-if="$hasPermissions('B_allocLinkageOutPrint')">
- <a-radio-group key="3" v-model="printerType">
- <a-radio value="NEEDLE">针式</a-radio>
- <a-radio value="INK">喷墨</a-radio>
- </a-radio-group>
- <a-button key="2" id="chainTransferOutEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
- <a-button key="1" type="primary" id="chainTransferOutEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
- </template>
- </a-page-header>
- <!-- 选择产品 -->
- <a-card size="small" :bordered="false" class="chainTransferOutEdit-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(1)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="产品编码" prop="productCode">
- <a-input id="chainTransferOutEdit-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="chainTransferOutEdit-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="chainTransferOutEdit-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="产品品牌">
- <a-select
- placeholder="请选择"
- id="chainTransferOutEdit-brandSn"
- allowClear
- v-model="queryParam.brandSn"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption">
- <a-select-option v-for="item in productBrandList" :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="产品分类">
- <a-cascader
- @change="changeProductType"
- change-on-select
- v-model="productType"
- expand-trigger="hover"
- :options="productTypeList"
- :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
- id="chainTransferOutEdit-productType"
- placeholder="请选择产品分类"
- allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="仓库">
- <a-select id="chainTransferOutEdit-warehouseSn" allowClear placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
- <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ 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(1)" :disabled="disabled" id="chainTransferOutEdit-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="chainTransferOutEdit-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.stockSn+record.productSn+record.warehouseSn+record.warehouseLocationSn"
- :columns="columns"
- :customRow="handleClickRow"
- :dataSource="loadData"
- :loading="loading"
- :scroll="{ x: 1680, y: 300 }"
- bordered>
- <!-- 调出数量 -->
- <template slot="outQty" slot-scope="text, record">
- <a-input-number
- id="chainTransferOutEdit-outQty"
- v-model="record.outQty"
- :precision="0"
- :min="1"
- :max="record.currentQty"
- placeholder="请输入"
- style="width: 100%;" />
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="primary" class="button-primary" @click="handleAdd(record)" id="chainTransferOutEdit-add-btn">添加</a-button>
- </template>
- </a-table>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- <!-- 已选产品 -->
- <a-card size="small" :bordered="false" class="chainTransferOutEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="已选产品">
- <!-- 总计 -->
- <a-alert type="info" showIcon 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)) ? '¥'+productTotal.productTotalCost : '--' }}</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="chainTransferOutEdit-productCode" v-model="chooseQueryParam.productCode" placeholder="请输入产品编码" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="9" :sm="24">
- <a-form-item label="产品名称" prop="productName">
- <a-input id="chainTransferOutEdit-productName" v-model="chooseQueryParam.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)" :disabled="chooseDisabled" id="chainTransferOutList-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="chainTransferOutList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- </a-col>
- <a-col :span="7" style="text-align: right;">
- <!-- <a-button size="small" style="margin-left: 8px" id="chainTransferOutEdit-import-btn">导入明细</a-button> -->
- <a-button size="small" type="danger" style="margin-left: 8px" @click.stop="handleDel('', 'all')" id="chainTransferOutEdit-del-all-btn">整单删除</a-button>
- </a-col>
- </a-row>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="chooseTable"
- size="small"
- :rowKey="(record) => record.id"
- :columns="chooseColumns"
- :data="chooseLoadData"
- :scroll="{ x: 1695, y: 300 }"
- bordered>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="chainTransferOutEdit-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="chainTransferOutEdit-submit"
- size="large"
- class="button-primary"
- @click="handleSubmit"
- style="padding: 0 60px;">提交</a-button>
- </div>
- </a-affix>
- </a-spin>
- <!-- 打印 -->
- <div id="print"></div>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import { getOperationalPrecision } from '@/libs/tools.js'
- import { allocLinkageOutDetailSn, allocLinkageOutDetailList, allocLinkageOutDetailSave, allocLinkageOutDetailDel, allocLinkageOutDetailCount, allocLinkageOutSubmit, allocLinkageOutDetailDelAll, allocLinkageOutDetailPrint } from '@/api/allocLinkageOut'
- import { productQuery } from '@/api/allocWarehouse'
- import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
- import { dealerProductTypeList } from '@/api/dealerProductType'
- import { warehouseAllList } from '@/api/warehouse'
- export default {
- components: { STable, VSelect },
- data () {
- return {
- spinning: false,
- queryParam: {
- productCode: '',
- productName: '',
- productOrigCode: '',
- warehouseSn: undefined,
- brandSn: undefined,
- productTypeSn1: undefined,
- productTypeSn2: undefined,
- productTypeSn3: undefined
- },
- productBrandList: [], // 产品品牌 下拉数据
- productTypeList: [], // 产品分类 下拉数据
- productType: [],
- warehouseList: [], // 仓库 下拉数据
- disabled: false, // 查询、重置按钮是否可操作
- loading: false, // 表格加载中
- chooseDisabled: false,
- advanced: false, // 高级搜索 展开/关闭
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '品牌', dataIndex: 'brandName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '成本价(¥)', dataIndex: 'putCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { 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: 'outQty' }, width: 140, align: 'center', fixed: 'right' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
- ],
- loadData: [],
- pageNo: 1, // 分页页码
- pageSize: 10, // 分页 每页多少条
- paginationProps: {
- showSizeChanger: true, // 是否可以改变 pageSize
- total: 0, // 分页总条数
- current: 1,
- onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
- onChange: (current) => this.changePage(current)
- },
- chooseQueryParam: {
- productCode: '',
- productName: ''
- },
- // 表头
- chooseColumns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
- { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '品牌', dataIndex: 'dealerProductEntity.productBrandName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '成本价', dataIndex: 'outCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '调出数量', dataIndex: 'outQty', width: 140, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '成本小计', dataIndex: 'costSubtotal', width: 115, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- chooseLoadData: parameter => {
- this.chooseDisabled = true
- const params = Object.assign(parameter, this.chooseQueryParam, { allocationLinkageOutSn: this.$route.params.sn })
- return allocLinkageOutDetailList(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
- // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
- data.list[i].costSubtotal = getOperationalPrecision(data.list[i].outCost, data.list[i].outQty)
- }
- this.chooseDisabled = false
- this.getDetailCount(params)
- this.localDataSource = data.list
- return data
- })
- },
- basicInfoData: null, // 基本信息
- productTotal: null, // 合计
- localDataSource: [],
- printerType: 'NEEDLE' // 打印机类型
- }
- },
- methods: {
- // 重置
- resetSearchForm () {
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.queryParam.productOrigCode = ''
- this.queryParam.warehouseSn = undefined
- this.queryParam.brandSn = undefined
- this.queryParam.productTypeSn1 = undefined
- this.queryParam.productTypeSn2 = undefined
- this.queryParam.productTypeSn3 = undefined
- this.productType = []
- this.getProductList(1)
- },
- // 已选产品 重置
- chooseResetSearchForm () {
- this.chooseQueryParam.productCode = ''
- this.chooseQueryParam.productName = ''
- this.$refs.chooseTable.refresh(true)
- },
- // 双击快速添加
- handleClickRow (record) {
- return {
- on: {
- dblclick: (event) => {
- this.handleAdd(record)
- }
- }
- }
- },
- // 基本信息
- getDetail () {
- allocLinkageOutDetailSn({ sn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.basicInfoData = res.data
- this.getProductList(1)
- this.getProductBrand()
- this.getProductType()
- } else {
- this.basicInfoData = null
- }
- })
- },
- // 添加/编辑
- handleAdd (row, isEdit) {
- if (!isEdit && !row.outQty) {
- this.$message.warning('请输入调出数量后再添加!')
- return
- }
- const params = {
- id: isEdit ? row.id : undefined,
- allocationLinkageOutSn: this.$route.params.sn,
- outCost: isEdit ? row.outCost : row.putCost,
- outQty: row.outQty,
- productSn: row.productSn,
- productProduceDate: row.productProduceDate,
- productExpiryDate: row.productExpiryDate,
- warehouseSn: row.warehouseSn,
- warehouseLocationSn: row.warehouseLocationSn
- }
- this.spinning = true
- allocLinkageOutDetailSave(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.getProductList()
- this.$refs.chooseTable.refresh()
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- // 删除
- handleDel (row, isAll) {
- const _this = this
- const content = isAll ? '删除后不可恢复,确定要进行整单删除吗?' : '删除后不可恢复,确定要进行删除吗?'
- this.$confirm({
- title: '提示',
- content: content,
- centered: true,
- onOk () {
- if (isAll) { // 整单删除
- _this.spinning = true
- allocLinkageOutDetailDelAll({ sn: _this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.getProductList()
- _this.$refs.chooseTable.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- } else { // 单个删除
- _this.spinning = true
- allocLinkageOutDetailDel({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.getProductList()
- _this.$refs.chooseTable.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- }
- })
- },
- // 提交
- handleSubmit () {
- const _this = this
- _this.spinning = true
- allocLinkageOutSubmit({ sn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- setTimeout(() => {
- _this.handleBack()
- _this.spinning = false
- }, 1000)
- } else {
- _this.spinning = false
- }
- })
- },
- // 导入明细
- handleImport () {
- console.log(333)
- },
- // 返回列表
- handleBack () {
- this.$router.push({ path: '/allocationManagement/chainTransferOut/list', query: { closeLastOldTab: true } })
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 产品列表数据
- getProductList (pageNo) {
- this.disabled = true
- this.loading = true
- this.pageNo = pageNo || this.pageNo
- // 箭冠品牌 sysFlag传1,非箭冠品牌传0。与新增时所选调出产品类型有关
- this.queryParam.sysFlag = this.basicInfoData.allocationType == 'JIANGUAN' ? '1' : '0'
- const params = Object.assign({ pageNo: this.pageNo, pageSize: this.pageSize }, this.queryParam)
- productQuery(params).then(res => {
- this.loading = false
- if (res.status == 200) {
- const data = res.data
- this.paginationProps.total = Number(res.data.count) || 0
- this.paginationProps.current = data.pageNo
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.loadData = data.list
- this.disabled = false
- } else {
- this.paginationProps.total = 0
- this.paginationProps.current = 1
- this.loadData = []
- }
- })
- },
- // 合计
- getDetailCount (params) {
- allocLinkageOutDetailCount(params).then(res => {
- if (res.status == 200) {
- this.productTotal = res.data
- } else {
- this.productTotal = null
- }
- })
- },
- // 产品分类 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] : ''
- },
- // 产品品牌 列表
- getProductBrand () {
- // sysFlag为1查询箭冠产品,为0查询非箭冠产品
- dealerProductBrandQuery({ sysFlag: this.basicInfoData.allocationType == 'JIANGUAN' ? '1' : '0' }).then(res => {
- if (res.status == 200) {
- this.productBrandList = res.data
- } else {
- this.productBrandList = []
- }
- })
- },
- // 产品分类 列表
- getProductType () {
- dealerProductTypeList({ sysFlag: this.basicInfoData.allocationType == 'JIANGUAN' ? '1' : '0' }).then(res => {
- if (res.status == 200) {
- this.productTypeList = res.data
- } else {
- this.productTypeList = []
- }
- })
- },
- // 仓库下拉数据
- getWarehouseList (type) {
- warehouseAllList({}).then(res => {
- if (res.status == 200) {
- this.warehouseList = res.data
- } else {
- this.warehouseList = []
- }
- })
- },
- // 打印预览/快捷打印
- handlePrint (type) {
- const _this = this
- _this.spinning = true
- allocLinkageOutDetailPrint({ sn: this.$route.params.sn, type: this.printerType }).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 {
- this.print(res, type)
- }
- })
- },
- print (data, type) {
- if (!data) {
- return
- }
- const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
- document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
- if (type == 'preview') { // 预览
- window.open(url)
- } else if (type == 'print') { // 打印
- window.frames['printf'].focus()
- window.frames['printf'].print()
- }
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.getDetail()
- vm.getWarehouseList()
- })
- }
- }
- </script>
- <style lang="less">
- .chainTransferOutEdit-wrap{
- .chainTransferOutEdit-back{
- margin-bottom: 15px;
- }
- .chainTransferOutEdit-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>
|