receiving.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <div class="salesReturnReceive-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesReturnReceive-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesReturnReceive-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 15px;color: #666;">客户名称:{{ ordeDetail&&ordeDetail.buyerName || '--' }}</span>
  9. <span style="margin: 0 10px;color: #666;">
  10. 退货类别:{{ ordeDetail&&ordeDetail.goodFlagDictValue }}
  11. </span>
  12. </template>
  13. </a-page-header>
  14. <a-card size="small" :bordered="false" class="salesReturnReceive-cont">
  15. <a-form layout="inline" style="margin-bottom:10px;" @keyup.enter.native="searchForm">
  16. <a-form-item label="产品编码" prop="productCode">
  17. <a-input id="salesReturnReceive-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  18. </a-form-item>
  19. <a-form-item label="产品名称" prop="productName">
  20. <a-input id="salesReturnReceive-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  21. </a-form-item>
  22. <a-form-item>
  23. <a-button type="primary" @click="searchForm" :disabled="disabled" id="salesReturnReceive-refresh">查询</a-button>
  24. <a-button style="margin-left: 10px" @click="resetSearchForm" :disabled="disabled" id="salesReturnReceive-reset">重置</a-button>
  25. </a-form-item>
  26. </a-form>
  27. <div style="border-top:1px solid #eee;padding-top:10px;">
  28. <a-button type="primary" :loading="loading" class="button-info" @click="openModal = true">新增产品</a-button>
  29. <a-button
  30. type="primary"
  31. :loading="loading"
  32. @click="openGuideModal=true"
  33. >导入产品</a-button>
  34. <a-button style="margin-left:10px;" type="primary" ghost :loading="loading" @click="handlePlss">批量实收</a-button>
  35. <span style="margin-left:10px;" v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys&&rowSelectionInfo.selectedRowKeys.length">已选{{ rowSelectionInfo.selectedRowKeys.length }}项</span>
  36. <div style="float:right;color:#999;margin-top:8px;">说明:红色行表示收货时新增的产品</div>
  37. </div>
  38. <!-- 已选配件列表 -->
  39. <s-table
  40. class="sTable"
  41. ref="table"
  42. :style="{ height: tableHeight+84.5+'px' }"
  43. :rowClassName="(record, index) => record.addFlag == '1' ? (record.addType == 'WAREHOUSE_RECEIVE'?'redBg-row':'orgBg-row'):''"
  44. size="small"
  45. :rowKey="(record) => record.id"
  46. :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: record.addFlag == '1' }}) }"
  47. @rowSelection="rowSelectionFun"
  48. :columns="columns"
  49. :data="loadData"
  50. :pagination="{pageSizeOptions: ['50','100','200','300','400']}"
  51. :pageSize="50"
  52. :scroll="{ y: tableHeight }"
  53. :defaultLoadData="false"
  54. bordered>
  55. <!-- 申请退货数量 -->
  56. <template slot="initialQty" slot-scope="text, record">
  57. <a-input-number
  58. size="small"
  59. v-if="record.addFlag == '1'&&record.addType == 'WAREHOUSE_RECEIVE'"
  60. v-model="record.initialQty"
  61. :precision="0"
  62. :min="0"
  63. :max="99999999"
  64. @blur="e => onCellBlurInitialQty(e.target.value, record)"
  65. placeholder="请输入"
  66. style="width: 100%;" />
  67. <span v-else>{{ record.initialQty }}</span>
  68. </template>
  69. <!-- 仓库实收数量 -->
  70. <template slot="receiveQty" slot-scope="text, record">
  71. <a-input-number
  72. size="small"
  73. v-model="record.receiveQty"
  74. :precision="0"
  75. :min="0"
  76. :max="99999999"
  77. @blur="e => onCellBlurReceiveQty(e.target.value, record)"
  78. placeholder="请输入"
  79. style="width: 100%;" />
  80. </template>
  81. <!-- 退货原因 -->
  82. <template slot="returnReason" slot-scope="text, record">
  83. <returnReason
  84. v-model="record.returnReasonCode"
  85. :goodFlag="goodFlag"
  86. v-if="record.addFlag == '1'&&record.addType == 'WAREHOUSE_RECEIVE'"
  87. @change="e => onCellBlurReturnReason(e, record, 0)"></returnReason>
  88. <span v-else>{{ record.returnReason }}</span>
  89. </template>
  90. <!-- 备注 -->
  91. <template slot="remarks" slot-scope="text, record">
  92. <div @dblclick.stop>
  93. <a-input :maxLength="50" size="small" v-model="record.returnReasonRemarks" @blur="e => onCellBlurReturnReason(e, record, 1)" placeholder="请输入备注(最多50字符)"/>
  94. </div>
  95. </template>
  96. <!-- 操作 -->
  97. <template slot="action" slot-scope="text, record">
  98. <div>
  99. <a-button
  100. v-if="record.addFlag == '1'&&record.addType == 'WAREHOUSE_RECEIVE'"
  101. size="small"
  102. type="link"
  103. class="button-warning"
  104. @click="handleDel(record)"
  105. >删除</a-button>
  106. </div>
  107. </template>
  108. </s-table>
  109. <div class="footer-btn">
  110. <a-button
  111. size="large"
  112. style="padding: 0 60px;"
  113. :disabled="spinning"
  114. type="primary"
  115. class="button-primary"
  116. @click="handleSubmit()"
  117. id="salesReturn-handleSubmit">提交</a-button>
  118. </div>
  119. </a-card>
  120. </a-spin>
  121. <!-- 添加产品 -->
  122. <chooseProductsModal
  123. ref="chooseProduct"
  124. :goodFlag="goodFlag"
  125. :isShowPrice="false"
  126. :openModal="openModal"
  127. :warehouseSn="ordeDetail?ordeDetail.warehouseSn:''"
  128. :buyerSn="$route.params.buyerSn"
  129. @close="openModal=false"
  130. @addProduct="addProduct"></chooseProductsModal>
  131. <!-- 导入产品 -->
  132. <importGuideModal :goodFlag="goodFlag == 'GOOD_PRODUCT_RETURN' ? 1 : 0" :params="{salesReturnBillSn: $route.params.sn}" :openModal="openGuideModal" @close="openGuideModal=false" @ok="importOk" />
  133. </div>
  134. </template>
  135. <script>
  136. import { commonMixin } from '@/utils/mixin'
  137. import { STable, VSelect } from '@/components'
  138. import chooseProductsModal from './chooseProductsModal.vue'
  139. import returnReason from '@/views/common/returnReason'
  140. import importGuideModal from './importGuideModal.vue'
  141. import { salesReturnDetail, salesReturnReceive, salesReturnDetailBatchByReceive } from '@/api/salesReturn'
  142. import {
  143. salesReturnDetailList, salesReturnDetailReceiveBatch, salesReturnDetailUpdateReceiveQty, salesReturnDetailUpdateReason, insertByReceive, deleteByReceiver
  144. } from '@/api/salesReturnDetail'
  145. export default {
  146. name: 'Receiving',
  147. mixins: [commonMixin],
  148. components: {
  149. STable,
  150. VSelect,
  151. chooseProductsModal,
  152. returnReason,
  153. importGuideModal
  154. },
  155. data () {
  156. return {
  157. openGuideModal: false,
  158. spinning: false,
  159. tableHeight: 0, // 表格高度
  160. orderSn: null,
  161. disabled: false,
  162. openModal: false, // 添加产品
  163. ordeDetail: null,
  164. loading: false,
  165. // 已选产品
  166. dataSource: [],
  167. productForm: {
  168. salesReturnBillSn: ''
  169. },
  170. chooseLoadData: [],
  171. // 加载数据方法 必须为 Promise 对象
  172. loadData: parameter => {
  173. this.disabled = true
  174. // 查询总计
  175. this.productForm.salesReturnBillSn = this.$route.params.sn
  176. return salesReturnDetailList(Object.assign(parameter, this.productForm, this.queryParam)).then(res => {
  177. let data
  178. if (res.status == 200) {
  179. data = res.data
  180. const no = (data.pageNo - 1) * data.pageSize
  181. for (var i = 0; i < data.list.length; i++) {
  182. data.list[i].no = no + i + 1
  183. data.list[i].receiveQtyBackups = data.list[i].receiveQty
  184. data.list[i].initialQtyBackups = data.list[i].initialQty
  185. data.list[i].returnReasonBackups = data.list[i].returnReason
  186. data.list[i].bakReamrks = data.list[i].returnReasonRemarks
  187. }
  188. this.disabled = false
  189. this.chooseLoadData = data.list
  190. }
  191. return data
  192. })
  193. },
  194. rowSelectionInfo: null,
  195. queryParam: {
  196. productCode: '',
  197. productName: ''
  198. },
  199. returnReasonlist: []
  200. }
  201. },
  202. computed: {
  203. goodFlag () {
  204. return this.ordeDetail && this.ordeDetail.goodFlag || ''
  205. },
  206. columns () {
  207. const arr = [
  208. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  209. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: '10%', customRender: function (text) { return text || '--' } },
  210. { title: '产品名称', dataIndex: 'productEntity.name', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  211. { title: '申请退货数量', dataIndex: 'initialQty', align: 'center', width: '8%', scopedSlots: { customRender: 'initialQty' } },
  212. { title: '仓库实收数量', dataIndex: 'receiveQty', align: 'center', width: '8%', scopedSlots: { customRender: 'receiveQty' } },
  213. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  214. // { title: '退货单价', dataIndex: 'price', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  215. { title: '退货原因', dataIndex: 'returnReason', width: '19%', align: 'center', scopedSlots: { customRender: 'returnReason' } },
  216. { title: '备注', dataIndex: 'remarks', width: '19%', align: 'center', scopedSlots: { customRender: 'remarks' } },
  217. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  218. ]
  219. return arr
  220. }
  221. },
  222. methods: {
  223. // 表格选中项
  224. rowSelectionFun (obj) {
  225. this.rowSelectionInfo = obj || null
  226. },
  227. // 返回
  228. handleBack () {
  229. this.$router.push({ name: 'receiveCheckList' })
  230. },
  231. // 确认导入明细
  232. importOk (data) {
  233. this.spinning = true
  234. salesReturnDetailBatchByReceive({ detailList: data, salesReturnBillSn: this.orderSn }).then(res => {
  235. if (res.status == 200) {
  236. this.resetSearchForm()
  237. this.$message.info(res.message)
  238. }
  239. this.spinning = false
  240. })
  241. },
  242. // 添加产品
  243. addProduct (data) {
  244. const params = {
  245. 'salesReturnBillSn': this.orderSn,
  246. 'salesReturnBillNo': this.ordeDetail.salesReturnBillNo,
  247. 'goodFlag': this.goodFlag,
  248. ...data
  249. }
  250. insertByReceive(params).then(res => {
  251. if (res.status == 200) {
  252. this.resetSearchForm(true)
  253. this.$message.info(res.message)
  254. }
  255. this.$refs.chooseProduct.resetLoading()
  256. })
  257. },
  258. // 删除产品
  259. handleDel (row) {
  260. const _this = this
  261. this.$confirm({
  262. title: '提示',
  263. content: '确认要删除吗?',
  264. centered: true,
  265. closable: true,
  266. onOk () {
  267. _this.loading = true
  268. _this.spinning = true
  269. deleteByReceiver({ salesReturnDetailSn: row.salesReturnDetailSn }).then(res => {
  270. if (res.status == 200) {
  271. _this.resetSearchForm(false)
  272. }
  273. _this.$message.info(res.message)
  274. _this.loading = false
  275. _this.spinning = false
  276. })
  277. }
  278. })
  279. },
  280. // 批量实收
  281. handlePlss () {
  282. const _this = this
  283. const snList = []
  284. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  285. snList.push(item.salesReturnDetailSn)
  286. })
  287. if (snList.length == 0) {
  288. _this.$message.warning('请先选择产品!')
  289. return
  290. }
  291. _this.$confirm({
  292. title: '提示',
  293. content: '确认要批量实收吗?',
  294. centered: true,
  295. onOk () {
  296. _this.loading = true
  297. _this.spinning = true
  298. salesReturnDetailReceiveBatch(snList).then(res => {
  299. if (res.status == 200) {
  300. _this.$refs.table.clearSelected()
  301. _this.resetSearchForm(false)
  302. _this.$message.success(res.message)
  303. }
  304. _this.loading = false
  305. _this.spinning = false
  306. })
  307. }
  308. })
  309. },
  310. // 申请退货数量修改
  311. onCellBlurInitialQty (val, record) {
  312. // 光标移出,值发生改变再调用编辑接口
  313. if (val && val != record.initialQtyBackups) {
  314. this.loading = true
  315. this.spinning = true
  316. salesReturnDetailUpdateReceiveQty({
  317. salesReturnDetailSn: record.salesReturnDetailSn,
  318. initialQty: val
  319. }).then(res => {
  320. if (res.status == 200) {
  321. this.resetSearchForm(false)
  322. this.$message.success(res.message)
  323. } else {
  324. record.initialQty = record.initialQtyBackups
  325. }
  326. this.loading = false
  327. this.spinning = false
  328. })
  329. } else {
  330. record.initialQty = record.initialQtyBackups
  331. }
  332. },
  333. // 仓库实收数量修改
  334. onCellBlurReceiveQty (val, record) {
  335. // 光标移出,值发生改变再调用编辑接口
  336. if (val && val != record.receiveQtyBackups) {
  337. this.loading = true
  338. this.spinning = true
  339. salesReturnDetailUpdateReceiveQty({
  340. salesReturnDetailSn: record.salesReturnDetailSn,
  341. receiveQty: val
  342. }).then(res => {
  343. if (res.status == 200) {
  344. this.resetSearchForm(false)
  345. this.$message.success(res.message)
  346. } else {
  347. record.receiveQty = record.receiveQtyBackups
  348. }
  349. this.loading = false
  350. this.spinning = false
  351. })
  352. } else {
  353. record.receiveQty = record.receiveQtyBackups
  354. }
  355. },
  356. // 修改退货原因
  357. onCellBlurReturnReason (val, record, type) {
  358. const params = {
  359. salesReturnDetailSn: record.salesReturnDetailSn,
  360. goodFlag: this.goodFlag
  361. }
  362. // 退货原因
  363. if (type == 0) {
  364. const rows = this.returnReasonlist.find(item => item.code == val)
  365. params.returnReasonCode = val || ''
  366. params.returnReason = rows ? rows.dispName : ''
  367. } else {
  368. // 备注
  369. params.returnReasonRemarks = val.target.value
  370. if (params.returnReasonRemarks == record.bakReamrks) {
  371. return
  372. }
  373. }
  374. this.loading = true
  375. this.spinning = true
  376. salesReturnDetailUpdateReason(params).then(res => {
  377. if (res.status == 200) {
  378. this.resetSearchForm(false)
  379. this.$message.success(res.message)
  380. } else {
  381. record.returnReason = record.returnReasonBackups
  382. }
  383. this.loading = false
  384. this.spinning = false
  385. })
  386. },
  387. // 获取单据详细
  388. getOrderDetail () {
  389. salesReturnDetail({ sn: this.orderSn }).then(res => {
  390. this.ordeDetail = res.data || null
  391. if (res.data) {
  392. this.returnReasonlist = [...this.$store.state.app.goodReturnReason, ...this.$store.state.app.defectiveReturnReason]
  393. }
  394. })
  395. },
  396. // 审核销售单
  397. handleSubmit () {
  398. const _this = this
  399. this.$confirm({
  400. title: '提示',
  401. content: '提交后将进入品检环节,确认提交吗?',
  402. centered: true,
  403. closable: true,
  404. onOk () {
  405. _this.spinning = true
  406. salesReturnReceive({ salesReturnBillSn: _this.orderSn }).then(res => {
  407. if (res.status == 200) {
  408. _this.handleBack()
  409. _this.$message.success(res.message)
  410. _this.spinning = false
  411. } else {
  412. _this.spinning = false
  413. }
  414. })
  415. }
  416. })
  417. },
  418. // 重置
  419. resetSearchForm (flag) {
  420. if (flag) {
  421. this.queryParam.productName = ''
  422. this.queryParam.productCode = ''
  423. this.rowSelectionInfo = null
  424. this.$refs.table.clearSelected()
  425. }
  426. this.$refs.table.refresh(flag)
  427. },
  428. searchForm () {
  429. this.$refs.table.refresh(true)
  430. this.$refs.table.clearSelected()
  431. },
  432. pageInit () {
  433. const _this = this
  434. this.$nextTick(() => { // 页面渲染完成后的回调
  435. _this.setTableH()
  436. })
  437. this.orderSn = this.$route.params.sn
  438. this.getOrderDetail()
  439. },
  440. setTableH () {
  441. this.tableHeight = window.innerHeight - 390
  442. }
  443. },
  444. mounted () {
  445. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  446. this.$refs.table.refresh(true)
  447. this.pageInit()
  448. }
  449. },
  450. activated () {
  451. this.$refs.table.refresh()
  452. this.pageInit()
  453. },
  454. beforeRouteEnter (to, from, next) {
  455. next(vm => {})
  456. }
  457. }
  458. </script>
  459. <style lang="less">
  460. .salesReturnReceive-wrap{
  461. position: relative;
  462. height: 100%;
  463. padding-bottom: 51px;
  464. box-sizing: border-box;
  465. >.ant-spin-nested-loading{
  466. height: 100%;
  467. }
  468. .footer-btn{
  469. text-align: center;
  470. }
  471. .salesReturnReceive-cont{
  472. margin-top: 10px;
  473. .sTable{
  474. margin-top: 10px;
  475. }
  476. .total-bar{
  477. display: flex;
  478. align-items: center;
  479. justify-content: space-between;
  480. > div{
  481. &:last-child{
  482. display: flex;
  483. align-items: center;
  484. justify-content: space-between;
  485. > div{
  486. padding: 0 10px;
  487. }
  488. }
  489. }
  490. }
  491. }
  492. .redBg-row{
  493. background-color: #f5beb4;
  494. }
  495. .orgBg-row{
  496. background-color: #fffca2;
  497. }
  498. }
  499. </style>