receiving.vue 15 KB

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