receiving.vue 18 KB

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