receiving.vue 18 KB

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