123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <template>
- <div class="waitDispatch-wrap">
- <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" v-if="salesBillSn">
- <!-- 查询配件列表 -->
- <queryPart
- ref="partQuery"
- :salesBillSn="salesBillSn"
- :detailData="detailData"
- :newLoading="isInster"
- @oneDispatch="oneDispatch"
- @cancelProduct="cancelProduct"
- @addProduct="insterProduct"></queryPart>
- </a-card>
- <a-card :bordered="false" class="waitDispatch-cont">
- <div slot="title">
- <div class="p-title">
- 待下推产品
- </div>
- </div>
- <div class="table-operator">
- <a-button
- type="primary"
- @click="delSalerDetailAll"
- :loading="delLoading"
- id="waitDispatch-del-all">批量移除</a-button>
- </div>
- <!-- 总计 -->
- <a-alert type="info" v-if="totalData">
- <div slot="message" class="total-bar">
- <div>
- 本次下推款数:<strong>¥{{ totalData&&totalData.totalAmount || 0 }}</strong>;
- 本次下推数量:<strong>{{ totalData&&totalData.totalCategory || 0 }}</strong>;
- </div>
- <div>
- </div>
- </div>
- </a-alert>
- <!-- 已选配件列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :showPagination="false"
- :scroll="{ x:1000, 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">
- <editable-cell
- size="small"
- :text="record.qty"
- :max="999999"
- :min="1"
- :precision="0"
- @change="onCellChange(record.id, 'qty', $event)" />
- </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-affix :offset-bottom="0">
- <div
- style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
- <a-button
- size="large"
- style="width: 150px;"
- type="primary"
- class="button-primary"
- @click="handleSubmit()"
- id="productInfoList-handleSubmit">下推</a-button>
- </div>
- </a-affix>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import queryPart from './queryPart.vue'
- import { salesDetailBySn } from '@/api/sales'
- import { salesDetailDispatchByOneKey, insertBatchOfWaitDispatch } from '@/api/salesDetail'
- import EditableCell from '@/views/common/editInput.js'
- import { deleteBatch, pushDown, queryCount, waitDispatchDetailAllList, updateQty } from '@/api/waitDispatchDetail'
- export default {
- name: 'SalesDetail',
- components: { STable, VSelect, queryPart, EditableCell },
- data () {
- return {
- salesBillSn: null, // 销售单sn
- disabled: false, // 查询、重置按钮是否可操作
- isInster: false, // 是否正在添加产品
- delLoading: false,
- detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
- dataSource: [],
- productForm: {
- salesBillSn: ''
- },
- selectedRowKeys: [], // Check here to configure the default column
- selectedRows: [],
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
- { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: 300, align: 'center' },
- { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '剩余待下推', dataIndex: 'surplusQty', width: 150, align: 'center' },
- { title: '本次下推数', scopedSlots: { customRender: 'salesNums' }, width: 150, align: 'center' },
- { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.productForm.salesBillSn = this.$route.params.sn
- // 查询统计
- this.getTotalData(Object.assign(parameter, this.productForm))
- 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
- }
- this.disabled = false
- this.dataSource = data
- return data
- })
- },
- totalData: null
- }
- },
- methods: {
- onSelectChange (selectedRowKeys, selectedRows) {
- this.selectedRowKeys = selectedRowKeys
- this.selectedRows = selectedRows
- },
- // 统计查询
- getTotalData (params) {
- queryCount(params).then(res => {
- this.totalData = res.data || null
- })
- },
- // 修改数量
- onCellChange (id, key, value) {
- console.log(id, key, value)
- const dataSource = [...this.dataSource]
- const row = dataSource.find(item => item.id === id)
- if (row) {
- row[key] = Number(value)
- this.dataSource = dataSource
- }
- if (key == 'qty') {
- updateQty({
- salesBillDetailSn: row.salesBillDetailSn,
- qty: row.qty,
- salesBillSn: this.salesBillSn
- }).then(res => {
- this.resetSearchForm(true)
- if (res.status == 200) {
- this.$refs.partQuery.resetCurForm()
- this.$message.success(res.message)
- }
- })
- }
- },
- // 重置
- resetSearchForm (flag) {
- this.$refs.table.refresh(!!flag)
- this.getOrderDetail()
- },
- // 重置列表
- resetForm () {
- this.$refs.table.refresh()
- },
- // 返回
- handleBack () {
- this.$router.push({ name: 'salesQueryList' })
- },
- // 批量删除
- delSalerDetailAll () {
- const _this = this
- if (_this.selectedRowKeys.length < 1) {
- _this.$message.warning('请在选择待下推产品!')
- return
- }
- const obj = []
- _this.selectedRows.map(item => {
- obj.push(item.productSn)
- })
- 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
- deleteBatch({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- _this.$message.success(res.message)
- }
- _this.delLoading = false
- })
- },
- // 添加产品
- insterProduct (row, promotionFlag) {
- console.log(row)
- // 防止多次添加产品
- if (this.isInster) { return }
- const _this = this
- _this.saveNewProduct(row, promotionFlag)
- },
- // 保存添加的产品到销售列表
- saveNewProduct (row, promotionFlag) {
- this.$message.loading('正在添加产品...', 1)
- this.isInster = true
- insertBatchOfWaitDispatch({
- packQty: row.productPackQty,
- productSn: row.productSn,
- showCos: row.lastStockCost,
- price: row.productPrice,
- qty: row.salesNums,
- salesBillSn: this.detailData.salesBillSn,
- salesBillNo: this.detailData.salesBillNo,
- purchaseBillSn: this.detailData.purchaseBillSn,
- purchaseBillNo: this.detailData.purchaseBillNo,
- stockSn: row.stockSn,
- promotableFlag: 0, // 可促销标记 有活动的传1,没活动的传0
- promotionFlag: promotionFlag // 促销标记 正品传0,促销品传1
- }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.$refs.partQuery.resetCurForm()
- this.$message.success('产品添加成功', 2.5)
- }
- this.isInster = false
- })
- },
- // 批量取消产品
- cancelProduct (row) {
- },
- // 一键下推
- oneDispatch () {
- this.isInster = true
- salesDetailDispatchByOneKey({ salesBillSn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.$refs.partQuery.resetCurForm()
- }
- this.isInster = false
- })
- },
- // 销售单详情
- getOrderDetail () {
- salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
- console.log('getOrderDetail')
- if (res.status == 200) {
- this.detailData = res.data
- console.log(this.detailData)
- }
- })
- },
- // 提交下推
- handleSubmit () {
- pushDown({ salesBillSn: this.salesBillSn }).then(res => {
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- }
- })
- }
- },
- mounted () {
- this.getOrderDetail()
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- console.log('beforeRouteEnter')
- vm.salesBillSn = vm.$route.params.sn
- })
- }
- }
- </script>
- <style lang="less">
- .waitDispatch-wrap{
- .waitDispatch-cont{
- margin-top: 15px;
- }
- .sTable{
- margin-top: 15px;
- }
- .p-title{
- 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>
|