123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589 |
- <template>
- <div class="salesReturnEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" class="salesReturnEdit-back" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="salesReturnEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">客户名称:{{ (ordeDetail&&ordeDetail.buyerName) || '--' }}</span>
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
- <a-radio-group key="4" v-model="printerType">
- <a-radio value="NEEDLE">针式</a-radio>
- <a-radio value="INK">喷墨</a-radio>
- </a-radio-group>
- <a-button key="3" id="salesReturnEdit-preview-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('preview')">打印预览</a-button>
- <a-button key="2" type="primary" id="salesReturnEdit-print-btn" :disabled="chooseLoadData.length==0" @click="handlePrint('print')">快捷打印</a-button>
- <a-button
- key="1"
- type="primary"
- class="button-warning"
- id="salesReturnEdit-export-btn"
- :disabled="chooseLoadData.length==0"
- @click="handlePrint('export')">导出Excel</a-button>
- </template>
- </a-page-header>
- <a-card size="small" :bordered="false" class="pages-wrap">
- <!-- 查询配件列表 -->
- <queryPart :buyerSn="$route.params.buyerSn" :priceType="ordeDetail&&ordeDetail.priceType||''" grabFlag="0" :newLoading="isInster" @add="saveProduct"></queryPart>
- </a-card>
- <a-card size="small" :bordered="false" class="pages-wrap">
- <!-- alert -->
- <a-alert style="margin-bottom: 10px;" type="info">
- <div slot="message" class="total-bar">
- <div v-if="countData">
- <span>退货总金额:{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? countData.totalAmount : '--' }}元;</span>
- <span>总款数:{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : '--' }};</span>
- <span>总数量:{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : '--' }};</span>
- <span>废品总数量:{{ countData&&(countData.totalCelQty || countData.totalCelQty==0) ? countData.totalCelQty : '--' }};</span>
- </div>
- <div v-if="ordeDetail">
- <div>
- 折扣金额:
- <a-input-number id="discount" v-model="ordeDetail.discountAmount" :min="0" :precision="2" :max="999999"/>
- <a-button type="primary" @click="salesReturnDiscount" class="button-info">打折</a-button>
- </div>
- <div>
- 折扣:<strong>{{ ordeDetail&&(ordeDetail.discountRate || ordeDetail.discountRate==0) ? ordeDetail.discountRate+'%' : '--' }}</strong>;
- 折后总售价:<strong>{{ ordeDetail&&(ordeDetail.discountedAmount || ordeDetail.discountedAmount==0) ? '¥'+ordeDetail.discountedAmount : '--' }}</strong>;
- </div>
- </div>
- </div>
- </a-alert>
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-row :gutter="15">
- <a-col :span="18">
- <a-form-model layout="inline" :model="productForm" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="8" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input v-model="productForm.productCode" allowClear placeholder="输入产品编码" />
- </a-form-model-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input v-model="productForm.productName" allowClear placeholder="输入产品名称" />
- </a-form-model-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-model-item>
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesReturn-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetForm" id="salesReturn-reset">重置</a-button>
- </a-form-model-item>
- </a-col>
- </a-row>
- </a-form-model>
- </a-col>
- <a-col :span="6">
- <div style="float:right;overflow: hidden;">
- <!-- <a-button id="salesReturn-dru">导入明细</a-button> -->
- <a-button
- size="small"
- type="primary"
- @click="salesReturnDelAll"
- :loading="delLoading"
- style="margin-left: 10px"
- id="salesReturn-del-all">整单删除</a-button>
- </div>
- </a-col>
- </a-row>
- </div>
- <!-- 已选配件列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1620, y: 300 }"
- bordered>
- <!-- 本次退货数量 -->
- <template slot="qty" slot-scope="text, record">
- <a-input-number
- id="salesReturn-qty"
- size="small"
- v-model="record.qty"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record, 'qty')"
- style="width: 100%;" />
- </template>
- <!-- 废品数量 -->
- <template slot="celQty" slot-scope="text, record">
- <a-input-number
- id="salesReturn-celQty"
- size="small"
- v-model="record.celQty"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record, 'celQty')"
- style="width: 100%;" />
- </template>
- <!-- 价格 -->
- <template slot="price" slot-scope="text, record">
- <a-input-number
- id="salesReturn-price"
- size="small"
- v-model="record.price"
- :precision="2"
- :min="0"
- :max="999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record, 'price')"
- style="width: 100%;" />
- </template>
- <!-- 退货金额小计 -->
- <template slot="returnAmount" slot-scope="text, record">
- ¥{{ (record.price * record.qty).toFixed(2) }}
- </template>
- <!-- 仓库仓位 -->
- <template slot="warehouse" slot-scope="text, record, index">
- <a-cascader
- size="small"
- @change="e => changeWarehouseCascade(e, record, index)"
- v-model="record.warehouseCascade"
- expand-trigger="hover"
- :options="warehouseCascadeData"
- :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
- id="bulkWarehousingOrderEdit-warehouseCascade"
- placeholder="请选择仓库仓位"
- style="width: 100%;" />
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="primary"
- :loading="delLoading"
- class="button-error"
- @click="handleDel(record)"
- id="salesReturn-Del">删除</a-button>
- </template>
- </s-table>
- </a-card>
- </a-spin>
- <div class="affix-cont">
- <a-button
- size="large"
- style="padding: 0 60px;"
- type="primary"
- :disabled="spinning"
- class="button-primary"
- @click="handleSubmit()"
- id="salesReturn-handleSubmit">提交</a-button>
- </div>
- <!-- 选择客户弹框 -->
- <choose-custom-modal :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
- <!-- 打印 -->
- <div id="print"></div>
- </div>
- </template>
- <script>
- import moment from 'moment'
- import { STable, VSelect } from '@/components'
- import queryPart from './queryPart.vue'
- import chooseCustomModal from './chooseCustomModal.vue'
- import { warehouseCascadeList } from '@/api/warehouse'
- import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
- export default {
- name: 'SalesDetail',
- components: {
- STable,
- VSelect,
- queryPart,
- chooseCustomModal
- },
- data () {
- return {
- spinning: false,
- orderId: null,
- orderSn: null,
- buyerSn: null,
- disabled: false,
- openModal: false,
- isInster: false, // 是否正在添加产品
- ordeDetail: { discountAmount: 0 },
- delLoading: false,
- warehouseCascadeData: [], // 仓库仓位
- // 已选产品
- dataSource: [],
- productForm: {
- productCode: '',
- productName: ''
- },
- countData: null,
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
- { title: '产品编码', dataIndex: 'dealerProductEntity.code', align: 'center', width: 220, customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', width: 220, customRender: function (text) { return text || '--' } },
- { title: '售价', dataIndex: 'price', align: 'center', width: 100, scopedSlots: { customRender: 'price' } },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', align: 'center', width: 60, customRender: function (text) { return text || '--' } },
- { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: 200, align: 'center' },
- { title: '退货数量', dataIndex: 'qty', align: 'center', width: 100, scopedSlots: { customRender: 'qty' } },
- { title: '废品数量', dataIndex: 'celQty', align: 'center', width: 100, scopedSlots: { customRender: 'celQty' } },
- { title: '退货金额小计', align: 'center', scopedSlots: { customRender: 'returnAmount' }, width: 120 },
- { title: '折后金额小计', dataIndex: 'discountedAmount', align: 'center', width: 120, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
- ],
- chooseLoadData: [],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- // 查询总计
- this.productForm.salesReturnBillSn = this.$route.params.sn
- this.getQueryCount(Object.assign(parameter, this.productForm))
- return salesReturnDetailList(Object.assign(parameter, this.productForm)).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].qtyBackups = data.list[i].qty
- data.list[i].celQtyBackups = data.list[i].celQty
- data.list[i].priceBackups = data.list[i].price
- 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
- }
- }
- this.disabled = false
- this.chooseLoadData = data.list
- return data
- })
- },
- printerType: 'NEEDLE' // 打印机类型
- }
- },
- methods: {
- // 返回
- handleBack () {
- this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
- },
- // 选择客户成功
- chooseCustomOk (data) {},
- handleEditCustom () {
- this.openModal = true
- },
- // 已选产品 blur
- onCellBlur (val, record, type) {
- let valBackups
- if (type == 'qty') {
- valBackups = record.qtyBackups
- } else if (type == 'celQty') {
- valBackups = record.celQtyBackups
- } else if (type == 'price') {
- valBackups = record.priceBackups
- }
- // 光标移出,值发生改变再调用编辑接口
- if (val && val != valBackups) {
- if (Number(record.celQty) > Number(record.qty)) {
- this.$message.info('废品数量不可大于本次退货数量')
- this.reductionVal(record, type, valBackups)
- } else {
- this.saveProduct(record, 'edit')
- }
- } else {
- this.reductionVal(record, type, valBackups)
- }
- },
- reductionVal (record, type, valBackups) {
- if (type == 'qty') {
- record.qty = valBackups
- } else if (type == 'celQty') {
- record.celQty = valBackups
- } else if (type == 'price') {
- record.price = valBackups
- }
- },
- // 仓库仓位 级联 列表
- getWarehouseCascade () {
- warehouseCascadeList({}).then(res => {
- if (res.status == 200) {
- 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 = []
- }
- })
- },
- // 修改仓库仓位
- changeWarehouseCascade (val, opt, ind) {
- let loadData = this.chooseLoadData[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] : ''
- loadData.warehouseSnBackups = val[0] ? val[0] : ''
- loadData.warehouseLocationSnBackups = val[1] ? val[1] : ''
- loadData = this.chooseLoadData[ind]
- this.saveProduct(loadData, 'edit')
- }
- },
- // 重置列表
- resetForm () {
- this.productForm = {
- productName: '',
- productCode: ''
- }
- this.$refs.table.refresh(true)
- },
- // 明细统计
- getQueryCount (params) {
- salesReturnQueryCount(params).then(res => {
- this.countData = res.data || null
- })
- },
- // 获取单据详细
- getOrderDetail () {
- salesReturnDetail({ sn: this.orderSn }).then(res => {
- this.ordeDetail = res.data || null
- })
- },
- // 打折
- salesReturnDiscount () {
- if (this.ordeDetail.discountAmount < 0) {
- return
- }
- this.spinning = true
- salesReturnDiscount({
- discountAmount: this.ordeDetail.discountAmount,
- salesReturnSn: this.ordeDetail.salesReturnSn,
- id: this.ordeDetail.id
- }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- // 整单删除
- salesReturnDelAll () {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认要整单删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.delLoading = true
- _this.spinning = true
- salesReturnDelAll({ sn: _this.ordeDetail.salesReturnSn }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm()
- }
- _this.$message.info(res.message)
- _this.delLoading = false
- _this.spinning = false
- })
- }
- })
- },
- // 删除产品
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认要删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.delLoading = true
- _this.spinning = true
- salesReturnDetailDel({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- }
- _this.$message.info(res.message)
- _this.delLoading = false
- _this.spinning = false
- })
- }
- })
- },
- // 重置
- resetSearchForm (flag) {
- this.$refs.table.refresh(!!flag)
- this.getOrderDetail()
- },
- // 添加或修改产品
- saveProduct (row, type) {
- console.log(row)
- // 防止多次添加产品
- if (this.isInster) {
- return
- }
- this.isInster = true
- const params = {
- 'salesReturnBillSn': this.orderSn,
- 'salesReturnBillNo': this.ordeDetail.salesReturnNo,
- 'salesBillSn': row.salesBillSn,
- 'salesBillNo': row.salesBillNo,
- 'salesBillDetailSn': row.salesBillDetailSn,
- 'price': type == 'edit' ? row.price : row.salePrice,
- 'cost': row.putCost,
- 'productSn': row.productSn,
- 'celQty': row.celQty,
- 'hasReturnQty': row.hasReturnQty,
- 'warehouseLocationSn': row.warehouseLocationSn,
- 'warehouseSn': row.warehouseSn
- }
- // 编辑
- if (type == 'edit') {
- params.id = row.id
- params.qty = row.qty
- } else {
- params.salesQty = row.qty
- }
- this.spinning = true
- salesReturnSaveProduct(params).then(res => {
- this.resetSearchForm(true)
- this.isInster = false
- this.spinning = false
- })
- },
- // 提交销售单
- handleSubmit () {
- this.spinning = true
- salesReturnSubmit({ sn: this.orderSn }).then(res => {
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- // 打印预览/快捷打印
- handlePrint (type) {
- const _this = this
- _this.spinning = true
- let url = salesReturnDetailPrint
- let params = { sn: this.$route.params.sn, type: this.printerType }
- if (type == 'export') { // 导出
- url = salesDetailExport
- params = { sn: this.$route.params.sn }
- }
- url(params).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 {
- if (type == 'export') { // 导出
- this.download(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()
- }
- },
- download (data) {
- if (!data) { return }
- const url = window.URL.createObjectURL(new Blob([data]))
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = url
- const a = moment().format('YYYYMMDDHHmmss')
- const fname = '销售退货' + a
- link.setAttribute('download', fname + '.xlsx')
- document.body.appendChild(link)
- link.click()
- }
- },
- mounted () {
- this.orderId = this.$route.params.id
- this.orderSn = this.$route.params.sn
- this.buyerSn = this.$route.params.buyerSn
- this.getOrderDetail()
- this.getWarehouseCascade()
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .salesReturnEdit-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 51px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: scroll;
- height: 100%;
- }
- .pages-wrap{
- margin-top: 10px;
- .total-bar{
- display: flex;
- align-items: center;
- justify-content: space-between;
- > div{
- &:last-child{
- display: flex;
- align-items: center;
- justify-content: space-between;
- > div{
- padding: 0 10px;
- }
- }
- }
- }
- }
- }
- </style>
|