receiving.vue 17 KB

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