123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <template>
- <div class="productInfoList-wrap">
- <!-- 搜索条件 -->
- <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" v-if="grabFlag == 1">
- <a-form-item label="审核时间">
- <rangeDate ref="rangeDate" @change="dateChange" />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品编码">
- <a-input id="productInfoList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="产品名称">
- <a-input id="productInfoList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-item>
- </a-col>
- <template v-if="advanced && grabFlag == 1">
- <a-col :md="6" :sm="24">
- <a-form-item label="销售单号">
- <a-input id="productInfoList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
- <a @click="advanced=!advanced" style="margin:0 15px 0 8px" v-if="grabFlag == 1">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </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="price" slot-scope="text, record">
- <span v-if="grabFlag==1">{{ text }}</span>
- <div v-else>
- <a-input-number
- size="small"
- v-model="record.salePrice"
- :precision="2"
- :min="0"
- :max="999999"
- placeholder="请输入"
- style="width: 100%;" />
- </div>
- </template>
- <span slot="customTitle">
- 操作
- <!-- <a-popover>
- <template slot="content">
- 双击列表配件可快速选中添加
- </template>
- <a-icon type="question-circle" theme="twoTone" />
- </a-popover> -->
- </span>
- <!-- 本次退货数量 -->
- <template slot="returnQty" slot-scope="text, record">
- <a-input-number
- size="small"
- v-model="record.returnQty"
- :precision="0"
- :min="0"
- :max="record.qty-record.hasReturnQty"
- placeholder="请输入"
- style="width: 100%;"
- v-if="(grabFlag==1)&&(record.qty!=record.hasReturnQty)||grabFlag==0"
- />
- <span v-else>--</span>
- </template>
- <!-- 废品数量 -->
- <template slot="celQty" slot-scope="text, record">
- <a-input-number
- size="small"
- v-model="record.celQty"
- :precision="0"
- :min="0"
- :max="record.returnQty"
- placeholder="请输入"
- style="width: 100%;"
- v-if="(grabFlag==1)&&(record.qty!=record.hasReturnQty)||grabFlag==0"/>
- <span v-else>--</span>
- </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"
- :allowClear="false"
- :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
- placeholder="请选择仓库仓位"
- style="width: 100%;"
- v-if="(grabFlag==1)&&(record.qty!=record.hasReturnQty)||grabFlag==0"/>
- <span v-else>--</span>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="primary"
- class="button-info"
- :loading="newLoading"
- :disabled="(grabFlag==1)&&(record.qty==record.hasReturnQty)"
- @click="handleAdd(record)"
- >添加</a-button>
- </template>
- </s-table>
- </div>
- </template>
- <script>
- import { salesReturnProductList } from '@/api/salesReturn'
- import { stockList } from '@/api/stock'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- export default {
- name: 'QueryPart',
- components: { STable, VSelect, rangeDate },
- props: {
- // buyerSn: {
- // type: [Number, String],
- // default: ''
- // },
- warehouseCascadeData: {
- type: Array,
- default: function () {
- return []
- }
- },
- newLoading: Boolean,
- grabFlag: [Number, String]
- // priceType: [Number, String]
- },
- data () {
- return {
- advanced: false, // 高级搜索 展开/关闭
- queryParam: { // 查询条件
- beginDate: '',
- endDate: '',
- salesBillNo: '', // 销售单号
- productName: '', // 产品名称
- productCode: '' // 产品编码
- },
- buyerSn: '',
- priceType: '',
- disabled: false, // 查询、重置按钮是否可操作
- columns: [],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- // 抓单时
- if (this.grabFlag == 1) {
- this.queryParam.buyerSn = this.buyerSn
- }
- const fun = [stockList, salesReturnProductList]
- if (this.grabFlag == 0) {
- this.queryParam.salePriceType = this.priceType
- }
- return fun[this.grabFlag](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
- // 不抓单
- if (this.grabFlag == 0) {
- data.list[i].putCost = data.list[i].lastStockCost
- const warehouse = this.warehouseCascadeData[0].warehouseLocationList[0]
- data.list[i].warehouseCascade = [warehouse.warehouseSn, warehouse.warehouseLocationSn]
- data.list[i].returnQty = 1
- data.list[i].celQty = 0
- } else {
- // 抓单
- data.list[i].returnQty = data.list[i].qty - data.list[i].hasReturnQty
- data.list[i].celQty = 0
- const warehouseSn = data.list[i].warehouseSn || undefined
- const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
- if (warehouseSn || warehouseLocationSn) {
- data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
- } else {
- data.list[i].warehouseCascade = undefined
- }
- }
- }
- this.listData = data.list || []
- this.disabled = false
- }
- return data
- })
- },
- listData: []
- }
- },
- mounted () {
- // 抓单
- if (this.grabFlag == 1) {
- this.columns = [
- { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
- { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
- { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '销售单号', dataIndex: 'salesBillNo', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '销售审核时间', dataIndex: 'auditDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '售价', dataIndex: 'price', align: 'center', width: '5%', scopedSlots: { customRender: 'price' } },
- { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '销售数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '已退数量', dataIndex: 'hasReturnQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '本次退货数量', align: 'center', width: '7%', scopedSlots: { customRender: 'returnQty' } },
- { title: '废品数量', align: 'center', width: '6%', scopedSlots: { customRender: 'celQty' } },
- { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '10%', align: 'center' },
- { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }]
- } else {
- this.columns = [
- { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: '22%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
- { title: '产品名称', dataIndex: 'productName', width: '22%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '售价', dataIndex: 'salePrice', width: '10%', align: 'center', scopedSlots: { customRender: 'price' } },
- { title: '单位', dataIndex: 'productUnit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '10%', align: 'center' },
- { title: '本次退货数量', align: 'center', width: '7%', scopedSlots: { customRender: 'returnQty' } },
- { title: '废品数量', align: 'center', width: '6%', scopedSlots: { customRender: 'celQty' } },
- { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }]
- }
- },
- methods: {
- // 时间 change
- dateChange (date) {
- this.queryParam.beginDate = date[0]
- this.queryParam.endDate = date[1]
- },
- // 双击列表选择配件
- handleClickRow (record) {
- const _this = this
- return {
- on: {
- dblclick: (event) => {
- if ((_this.grabFlag == 1) && (record.qty == record.hasReturnQty)) {
- _this.$message.info('该产品暂时不能添加')
- } else {
- event.stopPropagation()
- _this.$emit('add', record)
- }
- }
- }
- }
- },
- // 修改仓库仓位
- changeWarehouseCascade (val, opt, ind) {
- console.log(val, opt, ind)
- const loadData = this.listData[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] : ''
- }
- },
- // 重置
- resetSearchForm () {
- this.$refs.rangeDate && this.$refs.rangeDate.resetDate()
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.queryParam.salesBillNo = ''
- this.queryParam.productName = ''
- this.queryParam.productCode = ''
- this.$refs.table.refresh(true)
- },
- pageInit (buyerSn, priceType) {
- console.log(buyerSn, priceType)
- this.buyerSn = buyerSn
- this.priceType = priceType
- this.refreshData()
- },
- refreshData () {
- this.$refs.table.refresh(true)
- },
- // 选择配件
- handleAdd (row) {
- this.$emit('add', row, 'new')
- }
- }
- }
- </script>
|