receiving.vue 14 KB

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