123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804 |
- <template>
- <div class="salesEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="salesEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">客户名称:{{ detailData&&detailData.buyerName }}</span>
- <!-- <div style="margin: 0 15px;display:inline-block;color: #666;">
- <span>出库仓库:</span>
- <chooseWarehouse style="width:200px" :allowClear="false" ref="warehouse" v-model="warehouseSn" @change="handleWarehouse"></chooseWarehouse>
- </div> -->
- </template>
- </a-page-header>
- <a-card size="small" :bordered="false" class="salesEdit-cont">
- <div slot="title">
- <div class="p-title">
- 选择产品
- </div>
- </div>
- <!-- 查询配件列表 -->
- <queryPart ref="partQuery" :newLoading="isInster" @add="insterProduct"></queryPart>
- </a-card>
- <a-card size="small" :bordered="false" class="salesEdit-cont">
- <div slot="title">
- <a-row :gutter="15" type="flex">
- <a-col :span="2">
- <div class="p-title">
- 已选产品
- </div>
- </a-col>
- <a-col :span="16" v-if="activeName">
- <div class="p-notes">
- <a-icon style="color: #FF9900;" type="bell" /> 已选产品可参加<span>{{ activeName }}</span>的促销活动,促销产品为指定产品
- </div>
- </a-col>
- </a-row>
- </div>
- <!-- 总计 -->
- <a-alert type="info" style="margin-bottom: 10px;">
- <div slot="message" class="total-bar">
- <div>
- <span v-if="$hasPermissions('B_salesEdit_salesPrice')">总售价:<strong>{{ detailData&&(detailData.totalCommonAmount || detailData.totalCommonAmount==0) ? toThousands(detailData.totalCommonAmount) : '--' }}</strong>;</span>
- 总款数:<strong>{{ detailData&&(detailData.totalCommonCategory || detailData.totalCommonCategory==0) ? detailData.totalCommonCategory : '--' }}</strong>;
- 总数量:<strong>{{ detailData&&(detailData.totalCommonQty || detailData.totalCommonQty==0) ? detailData.totalCommonQty : '--' }}</strong>;
- </div>
- </div>
- </a-alert>
- <!-- 筛选条件 -->
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="4" :sm="24">
- <a-form-item label="出库仓库" prop="warehouseSn">
- <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-form-item label="产品编码" prop="productCode">
- <a-input id="salesEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-form-item label="产品名称" prop="productName">
- <a-input id="salesEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-form-item label="品牌">
- <ProductBrand id="salesEdit-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24">
- <a-form-item label="产品分类">
- <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="productType" id="salesEdit-productType"></productTypeAll>
- </a-form-item>
- </a-col>
- <a-col :md="4" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesEdit-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesEdit-reset">重置</a-button>
- </a-col>
- <a-col :md="24" :sm="24" style="text-align:right;">
- <span>已选{{ selectTotal }}项</span>
- <a-dropdown>
- <a-menu slot="overlay" @click="handleMenuClick">
- <a-menu-item key="0">
- 仓库设置
- </a-menu-item>
- <a-menu-item key="1">
- 删除已选项
- </a-menu-item>
- <a-menu-item key="2">
- 全部删除
- </a-menu-item>
- </a-menu>
- <a-button
- style="margin:0 15px;"
- type="primary"
- ghost> 批量操作 <a-icon type="down" /> </a-button>
- </a-dropdown>
- <a-button
- type="default"
- @click="openGuideModal=true">导入产品</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 已选配件列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :row-selection="{ columnWidth: 40 }"
- @rowSelection="rowSelectionFun"
- :defaultLoadData="false"
- :scroll="{ y: 300 }"
- bordered>
- <!-- 产品编码 -->
- <template slot="productCode" slot-scope="text, record">
- <a-badge count="缺" v-if="Number(record.stockQty||0) < Number(record.unpushedQty||0)">
- <div style="padding-right: 15px;">{{ text }}</div>
- </a-badge>
- <span v-if="!(Number(record.stockQty||0) < Number(record.unpushedQty||0))">{{ text }}</span>
- </template>
- <!-- 产品名称 -->
- <template slot="productName" slot-scope="text, record">
- <div class="ellipsisCon">
- <a-tooltip placement="rightBottom">
- <template slot="title">
- <span>{{ text }}</span>
- </template>
- <span class="ellipsisText">{{ text }}</span>
- </a-tooltip>
- <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.promotableFlag == 1"></a-badge>
- </div>
- </template>
- <!-- 销售数量 -->
- <template slot="salesNums" slot-scope="text, record">
- <a-input-number
- id="salesEdit-qty"
- size="small"
- v-model="record.qty"
- :precision="0"
- :min="1"
- :max="99999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record)"
- style="width: 100%;" />
- </template>
- <!-- 当前库存 -->
- <template slot="stockQty" slot-scope="text, record">
- <div v-if="record.stockQty || record.stockQty==0">
- <p style="margin: 0;" v-if="Number(record.stockQty) < Number(record.unpushedQty)">{{ record.stockQty }}(<span class="redStyle">缺{{ Number(record.unpushedQty||0) - Number(record.stockQty||0) }}</span>)</p>
- <p style="margin: 0;" v-else>{{ record.stockQty }}</p>
- </div>
- <span v-else>--</span>
- </template>
- <!-- 出库仓库 -->
- <template slot="warehouseBox" slot-scope="text, record">
- <chooseWarehouse style="width:100%;" :allowClear="false" ref="warehouseBox" v-model="record.warehouseSn" @change="handleWarehouseBox(record)"></chooseWarehouse>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- :loading="delLoading"
- class="button-error"
- @click="handleDel(record)"
- >删除</a-button>
- <a-button
- size="small"
- type="link"
- :loading="delLoading"
- class="button-warning"
- @click="handleSelCx(record)"
- v-if="record.promotableFlag == 1"
- >选择促销品</a-button>
- </template>
- </s-table>
- </a-card>
- <a-card size="small" :bordered="false" class="salesEdit-cont">
- <div slot="title">
- <div class="p-title">
- 已选促销品
- </div>
- </div>
- <!-- 总计 -->
- <a-alert type="info" style="margin-bottom: 10px;">
- <div slot="message" class="total-bar">
- <div>
- <span>总成本:<strong>{{ detailData&&(detailData.totalPromoCost || detailData.totalPromoCost==0) ? toThousands(detailData.totalPromoCost) : '--' }}</strong>;</span>
- 总款数:<strong>{{ detailData&&(detailData.totalPromoCategory || detailData.totalPromoCategory==0) ? detailData.totalPromoCategory : '--' }}</strong>;
- 总数量:<strong>{{ detailData&&(detailData.totalPromoQty || detailData.totalPromoQty==0) ? detailData.totalPromoQty : '--' }}</strong>;
- </div>
- <div>
- </div>
- </div>
- </a-alert>
- <!-- 已选促销品列表 -->
- <queryPromotable ref="promotable" :delLoading="delLoading" @onCellBlur="onCellBlur" @del="handleDel"></queryPromotable>
- </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()"
- id="productInfoList-handleSubmit">提交</a-button>
- </div>
- <!-- 添加产品 -->
- <ChooseActive
- ref="activeProduct"
- :openModal="newActive"
- @ok="addNewActive"
- :newLoading="isInster"
- @close="closeActive"></ChooseActive>
- <!-- 导入产品 -->
- <importGuideModal :openModal="openGuideModal" :params="{salesBillSn: $route.params.sn}" @close="closeGuideModel" @ok="hanldeOk" />
- <!-- 仓库设置 -->
- <setWarehouse :show="openWarehouseModal" @ok="chooseWarehouseOk" @cancel="openWarehouseModal=false"></setWarehouse>
- <!-- 价格更新弹窗 -->
- <setPriceModal :show="priceUpdateModal" :totalRealAmount="updataData.totalRealAmount" :totalAmount="updataData.totalAmount" @ok="updatePrice" @cancel="priceUpdateModal=false"></setPriceModal>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import queryPart from './queryPart.vue'
- import queryPromotable from './queryPromotable.vue'
- import ChooseActive from './chooseActive.vue'
- import ImportGuideModal from './importGuideModal.vue'
- import setWarehouse from './setWarehouse.vue'
- import setPriceModal from './setPriceModal.vue'
- import chooseWarehouse from '@/views/common/chooseWarehouse'
- import ProductBrand from '@/views/common/productBrand.js'
- import productTypeAll from '@/views/common/productTypeAll.js'
- import { salesModify, salesDetailBySn, salesWriteSubmit, getPromoacActiveList, deleteAll, submitCheck, updateBatch, updateWarehouse } from '@/api/sales'
- import { salesDetailStockList, salesDetailInsert, salesDetailUpdateQty, salesDetailDel, salesDetailBatchDel, addPromoGoods, salesBatchInsert } from '@/api/salesDetail'
- export default {
- name: 'SalesEdit',
- mixins: [commonMixin],
- components: { STable,
- VSelect,
- queryPart,
- queryPromotable,
- ChooseActive,
- ImportGuideModal,
- chooseWarehouse,
- setWarehouse,
- setPriceModal,
- ProductBrand,
- productTypeAll },
- data () {
- return {
- spinning: false,
- salesBillSn: null, // 销售单sn
- disabled: false, // 查询、重置按钮是否可操作
- chooseDisabled: false,
- isInster: false, // 是否正在添加产品
- delLoading: false,
- newActive: false, // 选择促销品
- detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
- dataSource: [],
- productForm: {
- salesBillSn: '',
- promotionFlag: 0
- },
- openWarehouseModal: false, // 打开仓库设置
- warehouseSn: undefined,
- activeName: '', // 促销活动
- nowData: null,
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.productForm.salesBillSn = this.$route.params.sn
- return salesDetailStockList(Object.assign(parameter, this.productForm, 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].qtyBackups = data.list[i].qty
- }
- this.disabled = false
- this.dataSource = data.list
- this.$refs.promotable.getData(this.salesBillSn)
- }
- return data
- })
- },
- openGuideModal: false, // 导入产品引导
- queryParam: {
- warehouseSn: undefined,
- productCode: '',
- productName: '',
- productBrandSn: undefined,
- productTypeSn1: '', // 产品一级分类
- productTypeSn2: '', // 产品二级分类
- productTypeSn3: '' // 产品三级分类
- },
- productType: [],
- rowSelectionInfo: null,
- priceUpdateModal: false, // 价格更新弹窗
- updataData: {
- totalRealAmount: '',
- totalAmount: ''
- }
- }
- },
- computed: {
- selectTotal () {
- return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
- },
- columns () {
- const arr = [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'productEntity.code', scopedSlots: { customRender: 'productCode' }, width: '13%', align: 'center', sorter: true },
- { title: '产品名称', dataIndex: 'productEntity.name', scopedSlots: { customRender: 'productName' }, width: '20%', align: 'left' },
- // { title: '售价', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '销售数量', scopedSlots: { customRender: 'salesNums' }, width: '8%', align: 'center' },
- { title: '库存', dataIndex: 'stockQty', scopedSlots: { customRender: 'stockQty' }, width: '8%', align: 'center' },
- { title: '出库仓库', scopedSlots: { customRender: 'warehouseBox' }, width: '15%', align: 'center' },
- { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- // { title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
- ]
- if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
- arr.splice(3, 0, { title: '售价', dataIndex: 'price', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
- arr.splice(7, 0, { title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
- }
- return arr
- }
- },
- methods: {
- // 设置单个出库仓库
- handleWarehouseBox (row) {
- const snArr = [row.salesBillDetailSn]
- const ajax_data = {
- warehouseSn: row.warehouseSn,
- salesBillDetailSnList: snArr,
- salesBillSn: this.$route.params.sn
- }
- this.setWarehouseInfo(ajax_data)
- },
- chooseWarehouseOk (sn) {
- const _this = this
- const snArr = []
- _this.rowSelectionInfo.selectedRows.forEach(item => {
- snArr.push(item.salesBillDetailSn)
- })
- const ajax_data = {
- warehouseSn: sn,
- salesBillDetailSnList: snArr,
- salesBillSn: _this.$route.params.sn
- }
- _this.setWarehouseInfo(ajax_data)
- },
- setWarehouseInfo (data) {
- const _this = this
- _this.spinning = true
- updateWarehouse(data).then(res => {
- if (res.status == 200) {
- _this.openWarehouseModal = false
- _this.resetSearchForm(true)
- _this.$refs.promotable.resetCurForm()
- _this.$message.success(res.message)
- }
- _this.$refs.table.refresh(true)
- _this.spinning = false
- })
- },
- // 产品分类 change
- changeProductType (val, opt) {
- this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
- this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
- this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
- },
- // 选择仓库
- handleWarehouse (val) {
- this.warehouseSn = val
- const _this = this
- _this.spinning = true
- salesModify({
- id: _this.detailData.id,
- warehouseSn: val
- }).then(res => {
- if (res.status == 200) {
- _this.$refs.partQuery.resetCurForm()
- _this.$refs.table.refresh(true)
- _this.spinning = false
- } else {
- _this.spinning = false
- _this.warehouseSn = _this.$route.params.wSn
- }
- })
- },
- handleMenuClick (e) {
- const _this = this
- if (e.key == 0) { // 仓库设置
- if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
- _this.$message.warning('请先选择要设置的产品!')
- } else {
- _this.openWarehouseModal = true
- }
- } else if (e.key == 1) { // 删除已选项
- this.handleBatchDel()
- } else {
- this.handleBatchDelAll()
- }
- },
- // 表格选中项
- rowSelectionFun (obj) {
- this.rowSelectionInfo = obj || null
- },
- handleBatchDelAll () {
- const _this = this
- if (_this.dataSource.length == 0) {
- _this.$message.warning('暂无可删除的已选产品!')
- return
- }
- this.$confirm({
- title: '提示',
- content: '确认要删除全部已选产品吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- deleteAll({ salesBillSn: _this.productForm.salesBillSn }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- _this.$refs.promotable.resetCurForm()
- _this.$message.success(res.message)
- }
- _this.spinning = false
- })
- }
- })
- },
- // 批量删除已选产品
- handleBatchDel () {
- const _this = this
- if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
- _this.$message.warning('请先选择要删除的产品后再进行批量操作!')
- return
- }
- const obj = []
- _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
- obj.push(item.salesBillDetailSn)
- })
- this.$confirm({
- title: '提示',
- content: '已选产品' + obj.length + '项,确认要批量删除吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- salesDetailBatchDel({
- salesBillSn: _this.salesBillSn,
- salesBillDetailSnList: obj
- }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- _this.$refs.promotable.resetCurForm()
- _this.$message.success(res.message)
- }
- _this.spinning = false
- })
- }
- })
- },
- // 已选产品 blur
- onCellBlur (val, record) {
- const _this = this
- // 光标移出,值发生改变再调用编辑接口
- if (val && val != record.qtyBackups) {
- _this.spinning = true
- salesDetailUpdateQty({
- salesBillDetailSn: record.salesBillDetailSn,
- qty: record.qty,
- salesBillSn: _this.salesBillSn
- }).then(res => {
- _this.resetSearchForm(true)
- _this.$refs.promotable.resetCurForm()
- if (res.status == 200) {
- _this.$message.success(res.message)
- }
- _this.spinning = false
- })
- } else {
- record.qty = record.qtyBackups
- }
- },
- chooseResetSearchForm () {
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.queryParam.warehouseSn = undefined
- this.$refs.table.refresh(true)
- },
- // 重置
- resetSearchForm (flag) {
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.queryParam.warehouseSn = undefined
- this.queryParam.productBrandSn = undefined
- this.queryParam.productTypeSn1 = ''
- this.queryParam.productTypeSn2 = ''
- this.queryParam.productTypeSn3 = ''
- this.productType = []
- this.$refs.table.refresh(!!flag)
- this.getPromoacActiveList()
- this.getOrderDetail(false)
- this.$refs.table.clearSelected() // 清空表格选中项
- },
- // 返回
- handleBack () {
- this.$router.push({ path: '/salesManagement/salesQuery/list', query: { closeLastOldTab: true } })
- },
- // 删除产品
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认要删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.delLoading = true
- _this.spinning = true
- salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- _this.$refs.promotable.resetCurForm()
- _this.$message.success(res.message)
- }
- _this.delLoading = false
- _this.spinning = 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
- this.spinning = true
- salesDetailInsert({
- packQty: row.productPackQty,
- productSn: row.productSn,
- showCost: row.lastStockCost,
- price: row.productPrice,
- origPrice: row.productPrice,
- promotionGiftsAmount: 0,
- usePromotionGiftsAmount: 0,
- qty: row.salesNums,
- salesBillSn: this.detailData.salesBillSn,
- salesBillNo: this.detailData.salesBillNo,
- purchaseBillSn: this.detailData.purchaseBillSn,
- purchaseBillNo: this.detailData.purchaseBillNo,
- stockSn: row.stockSn,
- promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
- promotionFlag: promotionFlag, // 促销标记 正品传0,促销品传1
- warehouseSn: row.warehouseSn
- }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm()
- this.$message.success('产品添加成功', 2.5)
- this.spinning = false
- } else {
- this.spinning = false
- }
- this.isInster = false
- }).catch(err => {
- this.isInster = false
- })
- },
- // 销售单详情
- getOrderDetail (flag) {
- salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
- if (res.status == 200) {
- this.detailData = res.data
- if (flag) {
- this.$refs.partQuery.pageInit(this.detailData && this.detailData.buyerSn || '')
- }
- }
- })
- },
- // 提交销售单
- handleSubmit () {
- // 先不提交,先判断是否有价格更新 (下级创建时判断)
- if (this.detailData && this.detailData.salesBillSource && this.detailData.salesBillSource == 'PURCHASE') {
- submitCheck({ salesBillSn: this.salesBillSn }).then(res => {
- if (res.status == 200) {
- if (res.data.detailList.length > 0) {
- this.updataData = res.data
- const _this = this
- this.$nextTick(() => {
- _this.priceUpdateModal = true
- })
- } else {
- const ajax_data = { salesBillSn: this.salesBillSn }
- this.submitResult(ajax_data)
- }
- }
- })
- } else {
- const ajax_data = { salesBillSn: this.salesBillSn }
- this.submitResult(ajax_data)
- }
- },
- // 提交
- submitResult (data) {
- this.spinning = true
- salesWriteSubmit(data).then(res => {
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- // 选择价格类型 并更新
- updatePrice (type) {
- const _this = this
- if (type == 0) {
- const ajax_data = {
- salesBillSn: _this.salesBillSn,
- productPriceChangeFlag: type
- }
- _this.submitResult(ajax_data)
- } else {
- updateBatch(_this.updataData.detailList).then(res => {
- if (res.status == 200) {
- const ajax_data = {
- salesBillSn: _this.salesBillSn,
- productPriceChangeFlag: type
- }
- _this.submitResult(ajax_data)
- }
- })
- }
- },
- // 获取促销活动
- getPromoacActiveList () {
- const _this = this
- getPromoacActiveList({ salesBillSn: this.salesBillSn }).then(res => {
- if (res.status == 200) {
- _this.activeName = ''
- res.data.map(item => {
- _this.activeName += item.name + '、'
- })
- _this.activeName = _this.activeName.slice(0, _this.activeName.length - 1)
- }
- })
- },
- // 选择促销品
- handleSelCx (row) {
- // this.nowData = row
- this.newActive = true
- this.$refs.activeProduct.getData(row, this.detailData && this.detailData.buyerSn || '', this.salesBillSn)
- },
- // 批量添加促销品
- addNewActive (list) {
- const temp = []
- list.map(item => {
- temp.push(Object.assign(item, {
- salesBillSn: this.detailData.salesBillSn,
- salesBillNo: this.detailData.salesBillNo,
- purchaseBillSn: this.detailData.purchaseBillSn,
- purchaseBillNo: this.detailData.purchaseBillNo
- }))
- })
- this.isInster == true
- this.spinning = true
- addPromoGoods(temp).then(res => {
- if (res.status == 200) {
- this.$refs.promotable.getData(this.salesBillSn)
- this.getOrderDetail(false)
- this.newActive = false
- this.isInster == false
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- closeActive () {
- this.nowData = null
- this.newActive = false
- },
- closeGuideModel () {
- this.openGuideModal = false
- },
- // 导入产品
- hanldeOk (obj) {
- salesBatchInsert(obj).then(res => {
- if (res.status == 200) {
- this.$refs.table.refresh(true)
- this.getOrderDetail(false)
- }
- })
- },
- pageInit () {
- this.getOrderDetail(true)
- this.$refs.table.refresh(true)
- this.salesBillSn = this.$route.params.sn
- this.warehouseSn = this.$route.params.sn ? this.$route.params.wSn : ''
- // 获取促销活动
- this.getPromoacActiveList()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- }
- },
- activated () {
- // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.pageInit()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .salesEdit-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 51px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: scroll;
- height: 100%;
- }
- .salesEdit-cont{
- margin-top: 10px;
- }
- .p-title{
- font-weight: bold;
- font-size: 14px;
- }
- .p-notes{
- font-size: 14px;
- span{
- color: #FF9900;
- }
- }
- .redStyle{
- font-weight: bold;
- color: red;
- }
- .ellipsisCon{
- display: flex;
- justify-content: space-between;
- align-items: center;
- .ellipsisText{
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- display: box;
- display: -webkit-box;
- -webkit-line-clamp: 1;
- -webkit-box-orient: vertical;
- }
- }
- .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>
|