salesReturnCheck.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div>
  3. <a-page-header :ghost="false" :backIcon="false" class="salesReturnCheck-back" >
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="salesReturnCheck-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. <span style="margin: 0 15px;color: #666;">客户名称:{{ ordeDetail&&ordeDetail.buyerName }}</span>
  8. </template>
  9. </a-page-header>
  10. <a-spin :spinning="spinning" tip="Loading...">
  11. <a-card size="small" :bordered="false" class="pages-wrap">
  12. <div>
  13. <a-button type="primary" :loading="loading" class="button-error" @click="backStock">批量返库</a-button>
  14. </div>
  15. <!-- 已选配件列表 -->
  16. <s-table
  17. class="sTable"
  18. ref="table"
  19. size="small"
  20. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onChange, onSelect: onSelectChange, onSelectAll: onSelectAllChange }"
  21. :rowKey="(record) => record.id"
  22. :columns="columns"
  23. :data="loadData"
  24. :scroll="{ x: 1500, y: 300 }"
  25. bordered>
  26. <!-- 返库数量 -->
  27. <template slot="backStockQty" slot-scope="text, record">
  28. <editable-cell
  29. size="small"
  30. :text="record.backStockQty"
  31. :max="record.qty"
  32. :min="0"
  33. :precision="0"
  34. @change="onCellChange(record.id, 'backStockQty', $event)" />
  35. </template>
  36. </s-table>
  37. </a-card>
  38. <a-affix :offset-bottom="0">
  39. <div
  40. style="text-align: center;width: 100%;background-color: #fff;padding: 0 0 40px;box-shadow: 0 0 20px #dcdee2;">
  41. <a-button
  42. size="large"
  43. style="width: 150px;"
  44. type="primary"
  45. class="button-primary"
  46. @click="handleSubmit()"
  47. id="salesReturn-handleSubmit">提交</a-button>
  48. </div>
  49. </a-affix>
  50. </a-spin>
  51. </div>
  52. </template>
  53. <script>
  54. import { STable, VSelect } from '@/components'
  55. import queryPart from './queryPart.vue'
  56. import EditableCell from '@/views/common/editInput.js'
  57. import { salesReturnDetail, salesReturnCheck } from '@/api/salesReturn'
  58. import {
  59. salesReturnDetailList,
  60. updateBackStockQty
  61. } from '@/api/salesReturnDetail'
  62. export default {
  63. name: 'SalesReturnEdit',
  64. components: {
  65. STable,
  66. VSelect,
  67. queryPart,
  68. EditableCell
  69. },
  70. data () {
  71. return {
  72. spinning: false,
  73. orderId: null,
  74. orderSn: null,
  75. buyerSn: null,
  76. disabled: false,
  77. isInster: false, // 是否正在添加产品
  78. ordeDetail: { discountAmount: 0 },
  79. loading: false,
  80. selectedRowKeys: [], // Check here to configure the default column
  81. selectedRows: [],
  82. // 已选产品
  83. dataSource: [],
  84. productForm: {
  85. salesReturnBillSn: ''
  86. },
  87. // 表头
  88. columns: [
  89. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  90. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: 160, customRender: function (text) { return text || '--' } },
  91. { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', width: 200, customRender: function (text) { return text || '--' } },
  92. { title: '退货数量', dataIndex: 'qty', align: 'center', width: 150, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  93. { title: '坏件数量', dataIndex: 'badQty', align: 'center', width: 150, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  94. { title: '返库数量', dataIndex: 'backStockQty', width: 150, align: 'center', scopedSlots: { customRender: 'backStockQty' } },
  95. { title: '单位', dataIndex: 'productEntity.unit', align: 'center', customRender: function (text) { return text || '--' }, width: 100 },
  96. { title: '售价', dataIndex: 'price', align: 'center', width: 150, customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } }
  97. ],
  98. chooseLoadData: [],
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. this.disabled = true
  102. // 查询总计
  103. this.productForm.salesReturnBillSn = this.$route.params.sn
  104. return salesReturnDetailList(Object.assign(parameter, this.productForm)).then(res => {
  105. const data = res.data
  106. const no = (data.pageNo - 1) * data.pageSize
  107. for (var i = 0; i < data.list.length; i++) {
  108. data.list[i].no = no + i + 1
  109. }
  110. this.disabled = false
  111. this.chooseLoadData = data.list
  112. return data
  113. })
  114. }
  115. }
  116. },
  117. methods: {
  118. onChange (selectedRowKeys, selectedRows) {
  119. this.selectedRowKeys = selectedRowKeys
  120. },
  121. onSelectChange (record, selected, selectedRows, nativeEvent) {
  122. const _this = this
  123. if (selected) { // 选择
  124. this.selectedRows.push(record)
  125. } else { // 取消
  126. this.selectedRows.map((item, index) => {
  127. if (item.id == record.id) {
  128. _this.selectedRows.splice(index, 1)
  129. }
  130. })
  131. }
  132. },
  133. // 本页全选/取消全选
  134. onSelectAllChange (selected, selectedRows, changeRows) {
  135. const _this = this
  136. if (selected) { // 选择
  137. this.selectedRows = [...this.selectedRows, ...changeRows]
  138. } else { // 取消
  139. this.selectedRows.map((item, index) => {
  140. this.selectedRows.map((subItem, ind) => {
  141. if (item.id == subItem.id) {
  142. _this.selectedRows.splice(index, 1)
  143. }
  144. })
  145. })
  146. }
  147. },
  148. // 返回
  149. handleBack () {
  150. this.$router.push({ name: 'salesReturnList' })
  151. },
  152. // 批量返库
  153. backStock () {
  154. const _this = this
  155. if (_this.selectedRowKeys.length < 1) {
  156. _this.$message.warning('请在选择产品!')
  157. return
  158. }
  159. this.$confirm({
  160. title: '提示',
  161. content: '确认要批量返库吗?',
  162. centered: true,
  163. onOk () {
  164. const obj = []
  165. _this.selectedRows.map(item => {
  166. obj.push({
  167. salesReturnDetailSn: item.salesReturnDetailSn,
  168. backStockQty: item.qty
  169. })
  170. })
  171. _this.submitCheck(obj)
  172. }
  173. })
  174. },
  175. // 修改返库数量
  176. onCellChange (id, key, value) {
  177. const chooseLoadData = [...this.chooseLoadData]
  178. const row = chooseLoadData.find(item => item.id === id)
  179. if (row) {
  180. row[key] = Number(value)
  181. this.submitCheck([{
  182. salesReturnDetailSn: row.salesReturnDetailSn,
  183. backStockQty: row.backStockQty
  184. }])
  185. }
  186. },
  187. // 品检
  188. submitCheck (data) {
  189. this.loading = true
  190. this.spinning = true
  191. updateBackStockQty(data).then(res => {
  192. if (res.status == 200) {
  193. this.resetSearchForm(true)
  194. this.$message.success(res.message)
  195. }
  196. this.loading = false
  197. this.spinning = false
  198. })
  199. },
  200. // 重置列表
  201. resetForm () {
  202. this.$refs.table.refresh(true)
  203. },
  204. // 获取单据详细
  205. getOrderDetail () {
  206. salesReturnDetail({ sn: this.orderSn }).then(res => {
  207. this.ordeDetail = res.data || null
  208. })
  209. },
  210. // 重置
  211. resetSearchForm (flag) {
  212. this.$refs.table.refresh(!!flag)
  213. this.getOrderDetail()
  214. },
  215. // 提交销售单
  216. handleSubmit () {
  217. this.spinning = true
  218. salesReturnCheck({ salesReturnBillSn: this.orderSn }).then(res => {
  219. if (res.status == 200) {
  220. this.handleBack()
  221. this.$message.success(res.message)
  222. this.spinning = false
  223. } else {
  224. this.spinning = false
  225. }
  226. })
  227. }
  228. },
  229. mounted () {
  230. this.orderSn = this.$route.params.sn
  231. this.buyerSn = this.$route.params.buyerSn
  232. this.getOrderDetail()
  233. },
  234. beforeRouteEnter (to, from, next) {
  235. next(vm => {
  236. console.log('beforeRouteEnter')
  237. })
  238. }
  239. }
  240. </script>
  241. <style lang="less">
  242. .pages-wrap{
  243. margin-top: 15px;
  244. .sTable{
  245. margin-top: 15px;
  246. }
  247. .total-bar{
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. > div{
  252. &:last-child{
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. > div{
  257. padding: 0 10px;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>