123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <template>
- <div class="purchaseReturnEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" class="purchaseReturnEdit-back" >
-
- <template slot="subTitle">
- <a id="purchaseReturnEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">供应商名称:{{ $route.params.name || '--' }}</span>
- </template>
-
- <template slot="extra" v-if="$hasPermissions('B_purchaseReturnPrint')">
- <Print :disabled="dataSource.length==0" @handlePrint="handlePrint"></Print>
- </template>
- </a-page-header>
-
- <a-card size="small" :bordered="false" class="purchaseReturnEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1" header="选择产品">
-
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="采购单号" prop="purchaseBillNo">
- <a-input id="purchaseReturnEdit-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" placeholder="请输入采购单号" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品编码" prop="productCode">
- <a-input id="purchaseReturnEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品名称" prop="productName">
- <a-input id="purchaseReturnEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseReturnList-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="purchaseReturnList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
-
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- :pageSize="10"
- :scroll="{ y: 149 }"
- bordered>
-
- <template slot="refundableQtyTitle">
- <a-tooltip placement="top">
- <template slot="title">
- <span>同一个采购单,可多次退货,所以可退数量=采购数量-已退货数量</span>
- </template>
- 可退数量<a-icon type="question-circle" :style="{ marginLeft: '3px' }" />
- </a-tooltip>
- </template>
-
- <template slot="returnQty" slot-scope="text, record">
- <a-input-number
- size="small"
- id="purchaseReturnEdit-returnQty"
- v-model="record.returnQty"
- :precision="0"
- :min="1"
- :max="record.refundableQty"
- placeholder="请输入"
- style="width: 100%;" />
- </template>
-
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="primary"
- class="button-primary"
- :disabled="record.refundableQty==0"
- @click="handleAdd(record)"
- id="purchaseReturnEdit-add-btn">添加</a-button>
- </template>
- </s-table>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
-
- <a-card size="small" :bordered="false" class="purchaseReturnEdit-cont">
- <a-collapse :activeKey="['1']">
- <a-collapse-panel key="1">
- <template slot="header">
- 已选产品
- <a-button
- size="small"
- type="primary"
- class="import-btn"
- id="purchaseReturnEdit-delAll-btn"
- @click.stop="handleDel('', 'all')"
- style="margin-left: 10px;">整单删除</a-button>
- </template>
-
- <s-table
- class="sTable"
- ref="chooseTable"
- size="small"
- :rowKey="(record) => record.id"
- :columns="chooseColumns"
- :data="chooseLoadData"
- :defaultLoadData="false"
- :pageSize="10"
- :scroll="{ y: 149 }"
- bordered>
-
- <template slot="qty" slot-scope="text, record">
- <a-input-number
- size="small"
- id="purchaseReturnEdit-qty"
- v-model="record.qty"
- :precision="0"
- :min="1"
- :max="record.refundableQty"
- placeholder="请输入"
- @blur="e => qtyBlur(e.target.value, record)"
- style="width: 100%;" />
- </template>
-
- <template slot="remarks" slot-scope="text, record">
- <a-input
- size="small"
- id="purchaseReturnEdit-remarks"
- v-model="record.remarks"
- :maxLength="30"
- placeholder="退货原因(最多30个字符)"
- @blur="e => remarksBlur(e.target.value, record)"
- style="width: 100%;" />
- </template>
-
- <template slot="action" slot-scope="text, record">
- <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="purchaseReturnEdit-del-btn">删除</a-button>
- </template>
- </s-table>
- </a-collapse-panel>
- </a-collapse>
- </a-card>
- </a-spin>
- <div class="affix-cont">
- <a-button
- type="primary"
- id="purchaseReturnEdit-submit"
- size="large"
- :disabled="spinning"
- class="button-primary"
- @click="handleSubmit"
- style="padding: 0 60px;">提交</a-button>
- </div>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import Print from '@/views/common/print.vue'
- import { hdPrint } from '@/libs/JGPrint'
- import {
- purchaseReturnPurchaseBillDetailList,
- purchaseReturnDetailList,
- purchaseReturnDetailSave,
- purchaseReturnDetailDel,
- purchaseReturnSubmit,
- purchaseReturnDelAll,
- purchaseReturnDetailPrint,
- purchaseReturnDetailExport } from '@/api/purchaseReturn'
- export default {
- components: { STable, VSelect, Print },
- data () {
- return {
- spinning: false,
- queryParam: {
- purchaseBillNo: '',
- productCode: '',
- productName: ''
- },
- dataSource: [],
- disabled: false,
- advanced: false,
-
- columns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '采购单号', dataIndex: 'purchaseBillNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '13%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '采购总数', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { slots: { title: 'refundableQtyTitle' }, dataIndex: 'refundableQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '库存数量', dataIndex: 'stock.currentStockQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '缺货数量', dataIndex: 'cancelQty', width: '7%', align: 'center' },
- { title: '退货数量', scopedSlots: { customRender: 'returnQty' }, width: '8%', align: 'center' },
- { title: '采购价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }
- ],
-
- loadData: parameter => {
- this.disabled = true
- return purchaseReturnPurchaseBillDetailList(Object.assign(parameter, this.queryParam)).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.disabled = false
- return data
- })
- },
-
- chooseColumns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '采购单号', dataIndex: 'purchaseBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '采购总数', dataIndex: 'purchaseBillQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '退货数量', scopedSlots: { customRender: 'qty' }, width: '10%', align: 'center' },
- { title: '采购价', dataIndex: 'cost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '退货原因', scopedSlots: { customRender: 'remarks' }, width: '15%', align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
- ],
-
- chooseLoadData: parameter => {
- return purchaseReturnDetailList(Object.assign(parameter, { purchaseReturnSn: this.$route.params.sn, orderBy: 'qpls_purchase_return_bill_detail.CREATE_DATE desc' })).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].remarksBackups = data.list[i].remarks
- data.list[i].refundableQty = data.list[i].purchaseBillRefundableQty + data.list[i].qty
- }
- this.dataSource = data.list
- return data
- })
- }
- }
- },
- methods: {
-
- handlePrint (type, printerType) {
- const _this = this
- _this.spinning = true
- let url = purchaseReturnDetailPrint
- const params = { sn: this.$route.params.sn }
- if (type == 'export') {
- url = purchaseReturnDetailExport
- }
-
- hdPrint(printerType, type, url, params, '采购退货单', function () {
- _this.spinning = false
- })
- },
-
- resetSearchForm () {
- this.queryParam.purchaseBillNo = ''
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.$refs.table.refresh(true)
- },
-
- handleAdd (row, isEdit) {
-
- if (!isEdit && !row.returnQty) {
- this.$message.warning('请输入退货数量')
- return
- }
- const params = {
- id: isEdit ? row.id : undefined,
- purchaseReturnSn: this.$route.params.sn,
- purchaseBillSn: row.purchaseBillSn,
- purchaseBillNo: row.purchaseBillNo,
- purchaseBillDetailSn: row.purchaseBillDetailSn,
- qty: isEdit ? row.qty : row.returnQty,
- productSn: row.productSn,
- cost: row.price,
- remarks: row.remarks,
- promotionFlag: row.promotionFlag
- }
- if (isEdit) {
-
- if (!row.qty) {
- row.qty = row.qtyBackups
- return
- }
- }
- this.spinning = true
- purchaseReturnDetailSave(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.table.refresh()
- this.$refs.chooseTable.refresh()
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
-
- handleClickRow (record) {
- return {
- on: {
- dblclick: (event) => {
- this.handleAdd(record)
- }
- }
- }
- },
-
- handleImport () {},
-
- handleDel (row, isAll) {
- const _this = this
- const content = isAll ? '删除后不可恢复,确定要进行整单删除吗?' : '删除后不可恢复,确定要进行删除吗?'
- this.$confirm({
- title: '提示',
- content: content,
- centered: true,
- onOk () {
- if (isAll) {
- _this.spinning = true
- purchaseReturnDelAll({ purchaseReturnSn: _this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.$refs.chooseTable.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- } else {
- _this.spinning = true
- purchaseReturnDetailDel({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.$refs.chooseTable.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- }
- })
- },
-
- handleSubmit () {
- const _this = this
- _this.spinning = true
- purchaseReturnSubmit({ 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
- }
- })
- },
-
- handleBack () {
- this.$router.push({ path: '/purchasingManagement/purchaseReturn/list' })
- },
-
- qtyBlur (val, record) {
-
- if (val != record.qtyBackups) {
- this.handleAdd(record, 'edit')
- }
- },
-
- remarksBlur (val, record) {
- if (val && (val != record.remarksBackups)) {
- this.handleAdd(record, 'edit')
- }
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) {
- this.$refs.chooseTable.refresh(true)
- this.resetSearchForm()
- }
- },
- activated () {
-
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.$refs.chooseTable.refresh(true)
- this.resetSearchForm()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .purchaseReturnEdit-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 51px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: scroll;
- height: 100%;
- }
- .purchaseReturnEdit-back, .purchaseReturnEdit-cont{
- margin-bottom: 10px;
- }
- }
- </style>
|