123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <div>
- <a-page-header :ghost="false" :backIcon="false" class="salesReturnCheck-back" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="salesReturnCheck-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">客户名称:{{ ordeDetail&&ordeDetail.buyerName || '--' }}</span>
- </template>
- </a-page-header>
- <a-spin :spinning="spinning" tip="Loading...">
- <a-card size="small" :bordered="false" class="pages-wrap">
- <div>
- <a-button type="primary" :loading="loading" class="button-error" @click="backStock">批量返库</a-button>
- </div>
- <!-- 已选配件列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onChange, onSelect: onSelectChange, onSelectAll: onSelectAllChange }"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 710, y: 300 }"
- bordered>
- <!-- 返库数量 -->
- <template slot="backStockQty" slot-scope="text, record">
- <a-input-number
- id="salesReturn-backStockQty"
- size="small"
- v-model="record.backStockQty"
- :precision="0"
- :min="0"
- :max="record.qty"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record)"
- style="width: 100%;" />
- </template>
- </s-table>
- </a-card>
- <a-affix :offset-bottom="0">
- <div
- style="text-align: center;width: 100%;background-color: #fff;padding: 0 0 40px;box-shadow: 0 0 20px #dcdee2;">
- <a-button
- size="large"
- style="width: 150px;"
- type="primary"
- class="button-primary"
- @click="handleSubmit()"
- id="salesReturn-handleSubmit">提交</a-button>
- </div>
- </a-affix>
- </a-spin>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import queryPart from './queryPart.vue'
- import { salesReturnDetail, salesReturnCheck } from '@/api/salesReturn'
- import {
- salesReturnDetailList,
- updateBackStockQty
- } from '@/api/salesReturnDetail'
- export default {
- name: 'SalesReturnEdit',
- components: {
- STable,
- VSelect,
- queryPart
- },
- data () {
- return {
- spinning: false,
- orderId: null,
- orderSn: null,
- buyerSn: null,
- disabled: false,
- isInster: false, // 是否正在添加产品
- ordeDetail: { discountAmount: 0 },
- loading: false,
- selectedRowKeys: [], // Check here to configure the default column
- selectedRows: [],
- // 已选产品
- dataSource: [],
- productForm: {
- salesReturnBillSn: ''
- },
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
- { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: 120, customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '退货数量', dataIndex: 'qty', align: 'center', width: 80, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '坏件数量', dataIndex: 'badQty', align: 'center', width: 80, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '返库数量', dataIndex: 'backStockQty', width: 100, align: 'center', scopedSlots: { customRender: 'backStockQty' } },
- { title: '单位', dataIndex: 'productEntity.unit', align: 'center', customRender: function (text) { return text || '--' }, width: 60 },
- { title: '售价', dataIndex: 'price', align: 'center', width: 80, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
- ],
- chooseLoadData: [],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- // 查询总计
- this.productForm.salesReturnBillSn = this.$route.params.sn
- 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].backStockQtyBackups = data.list[i].backStockQty
- }
- this.disabled = false
- this.chooseLoadData = data.list
- return data
- })
- }
- }
- },
- methods: {
- onChange (selectedRowKeys, selectedRows) {
- this.selectedRowKeys = selectedRowKeys
- },
- onSelectChange (record, selected, selectedRows, nativeEvent) {
- const _this = this
- if (selected) { // 选择
- this.selectedRows.push(record)
- } else { // 取消
- const arrId = []
- this.selectedRows.map((item, index) => {
- if (item.id == record.id) {
- arrId.push(index)
- }
- })
- arrId.map((item, index) => {
- _this.selectedRows = _this.selectedRows.slice(item, item + 1)
- })
- }
- },
- // 本页全选/取消全选
- onSelectAllChange (selected, selectedRows, changeRows) {
- const _this = this
- if (selected) { // 选择
- this.selectedRows = [...this.selectedRows, ...changeRows]
- } else { // 取消
- const arrId = []
- this.selectedRows.map((item, index) => {
- this.selectedRows.map((subItem, ind) => {
- if (item.id == subItem.id) {
- arrId.push(index)
- }
- })
- })
- arrId.map((item, index) => {
- _this.selectedRows = _this.selectedRows.slice(item, item + 1)
- })
- }
- },
- // 返回
- handleBack () {
- this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
- },
- // 批量返库
- backStock () {
- const _this = this
- if (_this.selectedRowKeys.length < 1) {
- _this.$message.warning('请在选择产品!')
- return
- }
- this.$confirm({
- title: '提示',
- content: '确认要批量返库吗?',
- centered: true,
- onOk () {
- const obj = []
- _this.selectedRows.map(item => {
- obj.push({
- salesReturnDetailSn: item.salesReturnDetailSn,
- backStockQty: item.qty
- })
- })
- _this.submitCheck(obj)
- }
- })
- },
- // 已选产品 blur
- onCellBlur (val, record) {
- // 光标移出,值发生改变再调用编辑接口
- if (val && val != record.backStockQtyBackups) {
- this.submitCheck([{
- salesReturnDetailSn: record.salesReturnDetailSn,
- backStockQty: record.backStockQty
- }])
- } else {
- record.backStockQty = record.backStockQtyBackups
- }
- },
- // 品检
- submitCheck (data) {
- this.loading = true
- this.spinning = true
- updateBackStockQty(data).then(res => {
- if (res.status == 200) {
- this.resetSearchForm(true)
- this.$message.success(res.message)
- }
- this.loading = false
- this.spinning = false
- })
- },
- // 重置列表
- resetForm () {
- this.$refs.table.refresh(true)
- },
- // 获取单据详细
- getOrderDetail () {
- salesReturnDetail({ sn: this.orderSn }).then(res => {
- this.ordeDetail = res.data || null
- })
- },
- // 重置
- resetSearchForm (flag) {
- this.$refs.table.refresh(!!flag)
- this.getOrderDetail()
- },
- // 提交销售单
- handleSubmit () {
- this.spinning = true
- salesReturnCheck({ salesReturnBillSn: this.orderSn }).then(res => {
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- }
- },
- mounted () {
- this.orderSn = this.$route.params.sn
- this.buyerSn = this.$route.params.buyerSn
- this.getOrderDetail()
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- console.log('beforeRouteEnter')
- })
- }
- }
- </script>
- <style lang="less">
- .pages-wrap{
- margin-top: 10px;
- .sTable{
- 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>
|