123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <template>
- <div class="salesReturnEdit-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-page-header :ghost="false" :backIcon="false" class="salesReturnEdit-back" >
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="salesReturnEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- <span style="margin: 0 15px;color: #666;">客户名称:{{ ordeDetail&&ordeDetail.buyerName || '--' }}</span>
- </template>
- </a-page-header>
- <a-card size="small" :bordered="false" class="salesReturnEdit-cont" v-show="ordeDetail&&ordeDetail.salesReturnBillSource=='SALES'">
- <!-- 查询配件列表 -->
- <queryPart ref="partQuery" :newLoading="isInster" @add="saveProduct"></queryPart>
- </a-card>
- <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
- <!-- alert -->
- <a-alert style="margin-bottom: 10px;" type="info">
- <div slot="message" class="total-bar">
- <div style="position: relative;width: 100%;">
- <div>
- <span v-if="$hasPermissions('B_isShowPrice')">退货总金额:{{ ordeDetail&&(ordeDetail.totalAmount || ordeDetail.totalAmount==0) ? ordeDetail.totalAmount : '--' }}元;</span>
- <span>退货总数量:{{ ordeDetail&&(ordeDetail.totalQty || ordeDetail.totalQty==0) ? ordeDetail.totalQty : '--' }};</span>
- </div>
- <div style="position: absolute;right: 0;top: -3px;">
- <a-button size="small" type="primary" class="button-info" id="salesReturnEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
- </div>
- </div>
- </div>
- </a-alert>
- <!-- 已选配件列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- :scroll="{ y: 300 }"
- bordered>
- <!-- 本次退货数量 -->
- <template slot="qty" slot-scope="text, record">
- <a-input-number
- id="salesReturn-qty"
- size="small"
- v-model="record.qty"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record, 'qty')"
- style="width: 100%;" />
- </template>
- <!-- 退货单价 -->
- <template slot="price" slot-scope="text, record">
- <a-input-number
- id="salesReturn-price"
- size="small"
- v-model="record.price"
- :precision="2"
- :min="0"
- :max="999999"
- placeholder="请输入"
- @blur="e => onCellBlur(e.target.value, record, 'price')"
- style="width: 100%;" />
- </template>
- <!-- 退货原因 -->
- <template slot="remark" slot-scope="text, record">
- <a-input size="small" placeholder="30个字符内" :maxLength="30" v-model="record.remark" @blur="updateRemark(record)"></a-input>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="primary"
- :loading="delLoading"
- class="button-error"
- @click="handleDel(record)"
- id="salesReturn-Del">删除</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()"
- id="salesReturn-handleSubmit">提交</a-button>
- </div>
- <!-- 导入产品 -->
- <importGuideModal :openModal="openGuideModal" :params="{salesReturnBillSn: $route.params.sn, grabFlag: ordeDetail.grabFlag}" @close="closeGuideModel" @ok="hanldeOk" />
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import ImportGuideModal from './importGuideModal.vue'
- import queryPart from './queryPart.vue'
- import EditableCell from '@/views/common/editInput.js'
- import { salesReturnDetail, salesReturnSubmit, salesReturnBatchInsert } from '@/api/salesReturn'
- import {
- salesReturnDetailList,
- salesReturnDetailDel,
- salesReturnDetailInsert,
- salesReturnDetailUpdateQty,
- salesReturnDetailUpdateReason
- } from '@/api/salesReturnDetail'
- export default {
- name: 'SalesReturnEdit',
- components: {
- STable,
- VSelect,
- queryPart,
- EditableCell,
- ImportGuideModal
- },
- data () {
- return {
- spinning: false,
- orderId: null,
- orderSn: null,
- buyerSn: null,
- disabled: false,
- isInster: false, // 是否正在添加产品
- ordeDetail: { discountAmount: 0 },
- delLoading: false,
- // 已选产品
- dataSource: [],
- productForm: {
- salesReturnBillSn: ''
- },
- chooseLoadData: [],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- // 查询总计
- this.productForm.salesReturnBillSn = this.$route.params.sn
- return salesReturnDetailList(Object.assign(parameter, this.productForm)).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
- data.list[i].priceBackups = data.list[i].price
- }
- this.disabled = false
- this.chooseLoadData = data.list
- }
- return data
- })
- },
- openGuideModal: false // 导入产品引导
- }
- },
- computed: {
- columns () {
- const arr = [
- { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
- { title: '产品编码', dataIndex: 'productEntity.code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productEntity.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '退货数量', dataIndex: 'qty', align: 'center', width: '8%', scopedSlots: { customRender: 'qty' } },
- // { title: '退货单价', dataIndex: 'price', align: 'center', width: '8%', scopedSlots: { customRender: 'price' } },
- { title: '单位', dataIndex: 'productEntity.unit', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
- // { title: '退货小计', align: 'center', dataIndex: 'totalAmount', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '退货原因', dataIndex: 'remark', align: 'center', width: '13%', scopedSlots: { customRender: 'remark' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
- ]
- if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
- arr.splice(4, 0, { title: '退货单价', dataIndex: 'price', align: 'center', width: '8%', scopedSlots: { customRender: 'price' } })
- arr.splice(6, 0, { title: '退货小计', align: 'center', dataIndex: 'totalAmount', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 返回
- handleBack () {
- this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
- },
- // 已选产品 blur
- onCellBlur (val, record, type) {
- let valBackups
- if (type) {
- if (type == 'qty') {
- valBackups = record.qtyBackups
- } else if (type == 'price') {
- valBackups = record.priceBackups
- }
- }
- // 光标移出,值发生改变再调用编辑接口
- if (val && val != valBackups) {
- this.spinning = true
- salesReturnDetailUpdateQty({
- salesReturnDetailSn: record.salesReturnDetailSn,
- qty: record.qty,
- price: record.price
- }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm(true)
- this.$message.success(res.message)
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- } else {
- if (type == 'qty') {
- record.qty = valBackups
- } else if (type == 'price') {
- record.price = valBackups
- }
- }
- },
- // 修改退货原因
- updateRemark (row) {
- this.spinning = true
- salesReturnDetailUpdateReason({
- salesReturnDetailSn: row.salesReturnDetailSn,
- remark: row.remark
- }).then(res => {
- if (res.status == 200) {
- this.resetSearchForm(true)
- this.$message.success(res.message)
- }
- this.spinning = false
- })
- },
- // 重置列表
- resetForm () {
- this.$refs.table.refresh(true)
- },
- // 获取单据详细
- getOrderDetail () {
- salesReturnDetail({ sn: this.orderSn }).then(res => {
- this.ordeDetail = res.data || null
- })
- },
- // 删除产品
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确认要删除吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.delLoading = true
- _this.spinning = true
- salesReturnDetailDel({ salesReturnDetailSn: row.salesReturnDetailSn }).then(res => {
- if (res.status == 200) {
- _this.resetSearchForm(true)
- }
- _this.$message.info(res.message)
- _this.delLoading = false
- _this.spinning = false
- })
- }
- })
- },
- // 重置
- resetSearchForm (flag) {
- this.$refs.table.refresh(!!flag)
- this.getOrderDetail()
- },
- // 添加或修改产品
- saveProduct (row) {
- console.log(row)
- // 防止多次添加产品
- if (this.isInster) {
- return
- }
- this.isInster = true
- const params = {
- 'salesReturnBillSn': this.orderSn,
- 'salesReturnBillNo': this.ordeDetail.salesReturnBillNo,
- 'price': row.productPrice,
- 'cost': row.lastStockCost,
- 'productSn': row.productSn,
- 'qty': row.qty
- }
- this.spinning = true
- salesReturnDetailInsert(params).then(res => {
- if (res.status == 200) {
- this.resetSearchForm(true)
- this.$message.success(res.message)
- }
- this.isInster = false
- this.spinning = false
- })
- },
- // 提交销售单
- handleSubmit () {
- this.spinning = true
- salesReturnSubmit({ salesReturnBillSn: this.orderSn }).then(res => {
- if (res.status == 200) {
- this.handleBack()
- this.$message.success(res.message)
- }
- this.spinning = false
- })
- },
- closeGuideModel () {
- this.openGuideModal = false
- },
- // 导入产品
- hanldeOk (obj) {
- salesReturnBatchInsert(obj).then(res => {
- if (res.status == 200) {
- this.$refs.table.refresh(true)
- this.getOrderDetail()
- }
- })
- },
- pageInit () {
- this.orderSn = this.$route.params.sn
- this.buyerSn = this.$route.params.buyerSn
- this.resetSearchForm(true)
- this.$refs.partQuery.pageInit(this.buyerSn, 0)
- }
- },
- 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">
- .salesReturnEdit-wrap{
- position: relative;
- height: 100%;
- padding-bottom: 51px;
- box-sizing: border-box;
- >.ant-spin-nested-loading{
- overflow-y: scroll;
- height: 100%;
- }
- .salesReturnEdit-cont{
- margin-top: 10px;
- .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>
|