123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- <template>
- <div class="waitDispatch-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="waitDispatch-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">客户名称:{{ detailData&&detailData.buyerName || '--' }}</span>
- <!-- <a-button id="waitDispatch-edit-btn" size="small" @click="handleEdit" style="margin-left:10px" key="0">编辑</a-button> -->
- </template>
- <!-- 操作区,位于 title 行的行尾 -->
- <!-- <template slot="extra">
- <a-button key="2" id="waitDispatch-preview-btn">打印预览</a-button>
- <a-button key="1" type="primary" id="waitDispatch-print-btn">快速打印</a-button>
- </template> -->
- </a-page-header>
- <a-card size="small" :bordered="false" class="waitDispatch-cont">
- <!-- 查询配件列表 -->
- <queryPart
- ref="partQuery"
- :newLoading="isInster"
- @oneDispatch="oneDispatch"
- @cancelProduct="cancelProduct"
- @addProduct="insterProduct"></queryPart>
- </a-card>
- <a-card size="small" :bordered="false" class="waitDispatch-cont">
- <div slot="title">
- <div class="p-title">
- 待下推产品
- </div>
- </div>
- <div style="margin: 0 0 10px 0;">
- <a-button
- type="primary"
- class="button-error"
- @click="delSalerDetailAll"
- :loading="delLoading"
- id="waitDispatch-del-all">批量移除</a-button>
- </div>
- <!-- 总计 -->
- <a-alert type="info" style="margin-bottom: 10px;">
- <div slot="message" class="total-bar">
- <div>
- 本次下推款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
- 本次下推数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
- </div>
- <div>
- </div>
- </div>
- </a-alert>
- <!-- 已选配件列表 -->
- <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"
- :showPagination="false"
- :scroll="{ x:650, y: 300 }"
- bordered>
- <!-- 产品编码 -->
- <template slot="productCode" slot-scope="text, record">
- <a-badge count="促" v-if="record.promotionFlag == 1">
- <div style="padding-right: 15px;">{{ text }}</div>
- </a-badge>
- <span v-else>{{ text }}</span>
- </template>
- <!-- 本次下推数 -->
- <template slot="salesNums" slot-scope="text, record">
- <a-input-number
- id="salesReturn-qty"
- size="small"
- v-model="record.qty"
- :precision="0"
- :min="1"
- :max="999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record)"
- 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)"
- >移除</a-button>
- </template>
- </s-table>
- </a-card>
- </a-spin>
- <div class="affix-cont">
- <a-button
- size="large"
- style="padding: 0 60px;"
- :disabled="spinning"
- type="primary"
- class="button-primary"
- @click="handleSubmit()"
- :loading="loading"
- id="productInfoList-handleSubmit">下推</a-button>
- </div>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import queryPart from './queryPart.vue'
- import { salesDetailBySn } from '@/api/sales'
- import { salesDetailDispatchByOneKey, insertBatchOfWaitDispatch, salesDetailUpdateCancelQty } from '@/api/salesDetail'
- import { deleteBatch, pushDown, dispatchDetail, waitDispatchDetailAllList, updateQty } from '@/api/waitDispatchDetail'
- export default {
- name: 'SalesDetail',
- components: { STable, VSelect, queryPart },
- data () {
- return {
- spinning: false,
- salesBillSn: null, // 销售单sn
- disabled: false, // 查询、重置按钮是否可操作
- isInster: false, // 是否正在添加产品
- delLoading: false, // 是否正在移除产品
- loading: false, // 是否下推中
- detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
- dataSource: [],
- productForm: {
- dispatchBillSn: ''
- },
- selectedRowKeys: [], // Check here to configure the default column
- selectedRows: [],
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
- { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: 120, align: 'center' },
- { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '剩余待下推', dataIndex: 'surplusQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '本次下推数', scopedSlots: { customRender: 'salesNums' }, width: 100, align: 'center' },
- { title: '单位', dataIndex: 'productEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.productForm.dispatchBillSn = this.$route.params.dispatchBillSn
- // 查询统计
- this.getTotalData()
- return waitDispatchDetailAllList(Object.assign(parameter, this.productForm)).then(res => {
- const data = res.data
- const no = 0
- for (var i = 0; i < data.length; i++) {
- data[i].no = no + i + 1
- data[i].qtyBackups = data[i].qty
- }
- this.disabled = false
- this.dataSource = data
- return data
- })
- },
- totalData: null
- }
- },
- methods: {
- onChange (selectedRowKeys, selectedRows) {
- this.selectedRowKeys = selectedRowKeys
- },
- onSelectChange (record, selected, selectedRows, nativeEvent) {
- if (selected) { // 选择
- this.selectedRows.push(record)
- } else { // 取消
- this.selectedRows = selectedRows
- }
- },
- // 本页全选/取消全选
- 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)
- })
- }
- },
- // 统计查询
- getTotalData () {
- dispatchDetail({ dispatchBillSn: this.$route.params.dispatchBillSn }).then(res => {
- if (res.status == 200) {
- this.totalData = res.data || null
- } else {
- this.totalData = null
- }
- })
- },
- // 已选产品 blur
- onCellBlur (val, record) {
- const _this = this
- _this.dataSource = record
- if (val && val != record.qtyBackups) {
- _this.spinning = true
- updateQty({
- dispatchBillDetailSn: record.dispatchBillDetailSn,
- qty: record.qty,
- salesBillSn: _this.salesBillSn
- }).then(res => {
- _this.resetSearchForm(true)
- if (res.status == 200) {
- _this.$refs.partQuery.resetCurForm()
- _this.$message.success(res.message)
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- } else {
- record.qty = record.qtyBackups
- }
- },
- // 重置
- resetSearchForm (flag) {
- console.log(flag)
- this.$refs.table.refresh(!!flag)
- this.getOrderDetail()
- },
- // 返回
- handleBack () {
- this.$router.push({ path: '/salesManagement/salesQuery/list', query: { closeLastOldTab: true } })
- },
- // 批量删除
- delSalerDetailAll () {
- const _this = this
- if (_this.selectedRowKeys.length < 1) {
- _this.$message.warning('请在选择待下推产品!')
- return
- }
- const obj = []
- _this.selectedRows.map(item => {
- if (_this.selectedRowKeys.indexOf(item.id) != -1) {
- obj.push(item.dispatchBillDetailSn)
- }
- })
- this.$confirm({
- title: '提示',
- content: '确认要批量删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.deleteFun(obj, 1)
- }
- })
- },
- // 删除产品
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认要删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.deleteFun(row, 0)
- }
- })
- },
- // 移除操作
- deleteFun (row, type) {
- const _this = this
- _this.delLoading = true
- _this.spinning = true
- deleteBatch(type == 0 ? [row.dispatchBillDetailSn] : row).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- _this.$refs.partQuery.resetCurForm()
- if (type == 1) { // 批量操作
- _this.selectedRowKeys = []
- _this.selectedRows = []
- } else if (type == 0) { // 单条
- const ind = _this.selectedRowKeys.findIndex(item => item == row.id)
- _this.selectedRowKeys.splice(ind, 1)
- }
- _this.$message.success(res.message)
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- _this.delLoading = false
- })
- },
- // 添加产品
- insterProduct (list) {
- console.log(list)
- // 防止多次添加产品
- if (this.isInster) { return }
- this.saveNewProduct(list)
- },
- // 保存添加的产品到下推列表
- saveNewProduct (list) {
- this.$message.loading('正在添加产品...', 1)
- this.isInster = true
- this.spinning = true
- insertBatchOfWaitDispatch(list).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.$refs.partQuery.resetCurForm()
- this.$message.success('添加成功', 2.5)
- this.spinning = false
- } else {
- this.spinning = false
- }
- this.isInster = false
- })
- },
- // 批量取消产品
- cancelProduct (list) {
- // 防止多次添加产品
- this.$message.loading('正在批量取消产品...', 1)
- this.isInster = true
- this.spinning = true
- salesDetailUpdateCancelQty(list).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.$refs.partQuery.resetCurForm()
- this.$message.success(res.message, 2.5)
- this.spinning = false
- } else {
- this.spinning = false
- }
- this.isInster = false
- })
- },
- // 一键下推
- oneDispatch () {
- this.isInster = true
- this.spinning = true
- salesDetailDispatchByOneKey({ salesBillSn: this.$route.params.salesBillSn }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.$refs.partQuery.resetCurForm()
- this.spinning = false
- } else {
- this.spinning = false
- }
- this.isInster = false
- })
- },
- // 销售单详情
- getOrderDetail () {
- salesDetailBySn({ salesBillSn: this.$route.params.salesBillSn }).then(res => {
- if (res.status == 200) {
- this.detailData = res.data
- this.$refs.partQuery.pageInit(this.$route.params.salesBillSn, this.detailData)
- }
- })
- },
- // 提交下推
- handleSubmit () {
- this.delLoading = true
- this.isInster = true
- this.loading = true
- this.spinning = true
- pushDown({ dispatchBillSn: this.$route.params.dispatchBillSn }).then(res => {
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- }
- this.delLoading = false
- this.isInster = false
- this.loading = false
- this.spinning = false
- })
- },
- pageInit () {
- this.salesBillSn = this.$route.params.salesBillSn
- this.getOrderDetail()
- if (!this.disabled) {
- this.$refs.table.refresh(true)
- }
- }
- },
- mounted () {
- this.pageInit()
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.pageInit()
- })
- }
- }
- </script>
- <style lang="less">
- .waitDispatch-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 51px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: scroll;
- height: 100%;
- }
- .waitDispatch-cont{
- margin-top: 10px;
- }
- .p-title{
- font-size: 16px;
- font-weight: bold;
- }
- .p-notes{
- span{
- color: #FF9900;
- }
- }
- .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;
- }
- }
- }
- }
- .redBg-row{
- background-color: #f5cdc8;
- }
- }
- </style>
|