receiving.vue 14 KB

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