123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <template>
- <div class="salesReturnList-wrap">
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <div style="width:80%">
- <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="5" :sm="24">
- <a-form-item label="入库单号">
- <a-input id="salesReturnList-productCode" v-model.trim="queryParam.sparePartsNo" allowClear placeholder="请输入入库单号"/>
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="财务审核时间">
- <rangeDate ref="rangeDate" :value="warehousingDate" @change="dateChange" />
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="产品编码">
- <a-input id="salesReturnList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-item label="产品名称">
- <a-input id="salesReturnList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-button type="primary" @click="$refs.chooseTable.refresh(true)" id="salesReturnList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" id="salesReturnList-reset">重置</a-button>
- </a-col>
- <a-col :md="12" :sm="24" style="margin-bottom: 10px;display: flex;align-items: center;">
- <a-button type="primary" style="margin-right: 5px" @click="handleBatchAdd" :loading="addMoreLoading">批量添加</a-button>
- <span v-if="selNums&&selNums!=0" style="margin:0 10px;">已选中{{ selNums }}项</span>
- <a-checkbox @change="onChange" :checked="isChecked">
- 显示最大可退数量为0的产品
- </a-checkbox>
- </a-col>
- </a-row>
- </a-form>
- </div>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="chooseTable"
- size="small"
- :rowKey="(record,i) => i"
- :row-selection="{ columnWidth: 40,getCheckboxProps: record => ({ props: { disabled: record.currentStockQty == 0 || record.isCheckedFlag} }) }"
- @rowSelection="rowSelectionFun"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- :scroll="{ y: 300 }"
- bordered>
- <!-- 申请退货数量 -->
- <template slot="qty" slot-scope="text, record">
- <div @dblclick.stop>
- <a-input-number
- size="small"
- v-model="record.qty"
- :precision="0"
- :min="1"
- :disabled="record.currentStockQty == 0"
- :max="record.currentStockQty"
- style="width: 100%;"
- placeholder="请输入"/>
- </div>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- class="button-info"
- :loading="newLoading"
- v-if="record.currentStockQty != 0 && !record.isCheckedFlag"
- @click="handleAdd(record)"
- >添加</a-button>
- <span v-else>--</span>
- </template>
- </s-table>
- </div>
- </template>
- <script>
- import { queryDetailStockPage } from '@/api/spareParts'
- import { queryDetailSnListBySn } from '@/api/sparePartsReturn'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import { toFixedDecimal } from '@/libs/tools.js'
- export default {
- name: 'QueryPart',
- components: { STable, VSelect, rangeDate },
- props: {
- newLoading: Boolean,
- isShowPrice: {
- type: Boolean,
- default: true
- },
- // 是否显示仓库实收数量
- showReceiveQty: {
- type: Boolean,
- default: false
- },
- addMoreLoading: {
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- buyerSn: '',
- queryParam: { // 查询条件
- productName: '', // 产品名称
- productCode: '', // 产品编码
- beginDate: '',
- endDate: '',
- sparePartsNo: '',
- isZero: 0
- },
- warehousingDate: [], // 入库时间
- selectArr: null,
- isChecked: false,
- repeatList: null,
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.queryParam.supplierSn = this.buyerSn
- return queryDetailStockPage(Object.assign(parameter, this.queryParam)).then(res => {
- let data
- if (res.status == 200) {
- 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].qty = data.list[i].currentStockQty
- data.list[i].isCheckedFlag = this.repeatList.findIndex(item => { return item == data.list[i].sparePartsDetailSn }) > -1
- }
- }
- return data
- })
- }
- }
- },
- computed: {
- columns () {
- const arr = [
- { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
- { title: '入库单号', dataIndex: 'sparePartsNo', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品编码', dataIndex: 'product.code', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'product.name', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '单位', dataIndex: 'product.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '批次号', dataIndex: 'sparePartsBatchNo', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '入库数量', dataIndex: 'productQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
- { title: '已退数量', dataIndex: 'returnedQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
- { title: '最大可退数量', dataIndex: 'currentStockQty', width: '9%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
- { title: '申请退货数量', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
- ]
- if (this.$hasPermissions('B_isShowCost')) {
- arr.splice(6, 0, { title: '入库单价', dataIndex: 'productCost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? toFixedDecimal(text, 2) : '--') } })
- }
- return arr
- },
- selNums () {
- return this.selectArr && this.selectArr.length || 0
- }
- },
- methods: {
- // 重置
- resetSearchForm () {
- this.queryParam.productName = ''
- this.queryParam.productCode = ''
- this.queryParam.sparePartsNo = ''
- this.warehousingDate = []
- this.$refs.rangeDate.resetDate(this.warehousingDate)
- this.$refs.chooseTable.refresh(true)
- },
- onChange (e) {
- this.isChecked = !this.isChecked
- this.queryParam.isZero = e.target.checked ? 1 : 0
- this.$refs.chooseTable.refresh()
- },
- // 入库时间 change
- dateChange (date) {
- this.queryParam.beginDate = date[0] ? date[0] : ''
- this.queryParam.endDate = date[1] ? date[1] : ''
- },
- pageInit (buyerSn, returnSn) {
- this.buyerSn = buyerSn
- this.getRepeatResult(returnSn)
- this.$refs.chooseTable.refresh()
- // this.$refs.chooseTable.clearSelected()
- },
- // 添加
- handleAdd (row) {
- if (this.selectArr && this.selectArr.length > 0) {
- const pot = this.selectArr.findIndex(item => { return item.sparePartsDetailSn == row.sparePartsDetailSn })
- this.selectArr.splice(pot, 1)
- }
- this.$emit('add', row)
- },
- // 删除后选中长度恢复
- refreshLength (row) {
- this.$refs.chooseTable.clearSelected()
- },
- rowSelectionFun (obj) {
- this.selectArr = obj.selectedRows
- },
- // 批量添加
- handleBatchAdd () {
- if (!this.selectArr) {
- this.$message.warning('请先选择要添加的产品!')
- return
- }
- this.$emit('bachAdd', this.selectArr)
- },
- getRepeatResult (sn) {
- queryDetailSnListBySn({ sn }).then(res => {
- if (res.status == 200) {
- this.repeatList = res.data
- }
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .salesReturnList-wrap{
- .redBg-row{
- background-color: #f5cdc8;
- }
- }
- /deep/.sTable input:disabled{
- color:gray !important;
- -webkit-text-fill-color:gray !important;
- }
- </style>
|