salesReturnCheck.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="salesReturnCheck-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesReturnCheck-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesReturnCheck-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="salesReturnCheck-cont">
  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. :style="{ height: tableHeight+84.5+'px' }"
  20. size="small"
  21. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onChange, onSelect: onSelectChange, onSelectAll: onSelectAllChange }"
  22. :rowKey="(record) => record.id"
  23. :columns="columns"
  24. :data="loadData"
  25. :scroll="{ y: tableHeight }"
  26. :defaultLoadData="false"
  27. bordered>
  28. <!-- 返库数量 -->
  29. <template slot="backStockQty" slot-scope="text, record">
  30. <a-input-number
  31. id="salesReturn-backStockQty"
  32. size="small"
  33. v-model="record.backStockQty"
  34. :precision="0"
  35. :min="0"
  36. :max="record.qty"
  37. placeholder="请输入"
  38. @blur="e => onCellBlur(e.target.value, record)"
  39. style="width: 100%;" />
  40. </template>
  41. </s-table>
  42. </a-card>
  43. </a-spin>
  44. <div class="affix-cont">
  45. <a-button
  46. size="large"
  47. style="padding: 0 60px;"
  48. :disabled="spinning"
  49. type="primary"
  50. class="button-primary"
  51. @click="handleSubmit()"
  52. id="salesReturn-handleSubmit">提交</a-button>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import { STable, VSelect } from '@/components'
  58. import queryPart from './queryPart.vue'
  59. import { salesReturnDetail, salesReturnCheck } from '@/api/salesReturn'
  60. import {
  61. salesReturnDetailList,
  62. updateBackStockQty
  63. } from '@/api/salesReturnDetail'
  64. export default {
  65. name: 'SalesReturnEdit',
  66. components: {
  67. STable,
  68. VSelect,
  69. queryPart
  70. },
  71. data () {
  72. return {
  73. spinning: false,
  74. tableHeight: 0, // 表格高度
  75. orderId: null,
  76. orderSn: null,
  77. buyerSn: null,
  78. disabled: false,
  79. isInster: false, // 是否正在添加产品
  80. ordeDetail: { discountAmount: 0 },
  81. loading: false,
  82. selectedRowKeys: [], // Check here to configure the default column
  83. selectedRows: [],
  84. // 已选产品
  85. dataSource: [],
  86. productForm: {
  87. salesReturnBillSn: ''
  88. },
  89. chooseLoadData: [],
  90. // 加载数据方法 必须为 Promise 对象
  91. loadData: parameter => {
  92. this.disabled = true
  93. // 查询总计
  94. this.productForm.salesReturnBillSn = this.$route.params.sn
  95. return salesReturnDetailList(Object.assign(parameter, this.productForm)).then(res => {
  96. const data = res.data
  97. const no = (data.pageNo - 1) * data.pageSize
  98. for (var i = 0; i < data.list.length; i++) {
  99. data.list[i].no = no + i + 1
  100. data.list[i].backStockQtyBackups = data.list[i].backStockQty
  101. }
  102. this.disabled = false
  103. this.chooseLoadData = data.list
  104. return data
  105. })
  106. }
  107. }
  108. },
  109. computed: {
  110. columns () {
  111. const arr = [
  112. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  113. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: '23%', customRender: function (text) { return text || '--' } },
  114. { title: '产品名称', dataIndex: 'productEntity.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  115. { title: '退货数量', dataIndex: 'qty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  116. { title: '坏件数量', dataIndex: 'badQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  117. { title: '返库数量', dataIndex: 'backStockQty', width: '10%', align: 'center', scopedSlots: { customRender: 'backStockQty' } },
  118. { title: '单位', dataIndex: 'productEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } }
  119. // { title: '售价', dataIndex: 'price', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  120. ]
  121. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  122. arr.splice(7, 0, { title: '售价', dataIndex: 'price', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  123. }
  124. return arr
  125. }
  126. },
  127. methods: {
  128. onChange (selectedRowKeys, selectedRows) {
  129. this.selectedRowKeys = selectedRowKeys
  130. },
  131. onSelectChange (record, selected, selectedRows, nativeEvent) {
  132. if (selected) { // 选择
  133. this.selectedRows.push(record)
  134. } else { // 取消
  135. this.selectedRows = selectedRows
  136. }
  137. },
  138. // 本页全选/取消全选
  139. onSelectAllChange (selected, selectedRows, changeRows) {
  140. const _this = this
  141. if (selected) { // 选择
  142. this.selectedRows = [...this.selectedRows, ...changeRows]
  143. } else { // 取消
  144. const arrId = []
  145. this.selectedRows.map((item, index) => {
  146. this.selectedRows.map((subItem, ind) => {
  147. if (item.id == subItem.id) {
  148. arrId.push(index)
  149. }
  150. })
  151. })
  152. arrId.map((item, index) => {
  153. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  154. })
  155. }
  156. },
  157. // 返回
  158. handleBack () {
  159. this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
  160. },
  161. // 批量返库
  162. backStock () {
  163. const _this = this
  164. if (_this.selectedRowKeys.length < 1) {
  165. _this.$message.warning('请在选择产品!')
  166. return
  167. }
  168. this.$confirm({
  169. title: '提示',
  170. content: '确认要批量返库吗?',
  171. centered: true,
  172. onOk () {
  173. const obj = []
  174. _this.selectedRows.map(item => {
  175. obj.push({
  176. salesReturnDetailSn: item.salesReturnDetailSn,
  177. backStockQty: item.qty
  178. })
  179. })
  180. _this.submitCheck(obj)
  181. }
  182. })
  183. },
  184. // 已选产品 blur
  185. onCellBlur (val, record) {
  186. // 光标移出,值发生改变再调用编辑接口
  187. if (val && val != record.backStockQtyBackups) {
  188. this.submitCheck([{
  189. salesReturnDetailSn: record.salesReturnDetailSn,
  190. backStockQty: record.backStockQty
  191. }])
  192. } else {
  193. record.backStockQty = record.backStockQtyBackups
  194. }
  195. },
  196. // 品检
  197. submitCheck (data) {
  198. this.loading = true
  199. this.spinning = true
  200. updateBackStockQty(data).then(res => {
  201. if (res.status == 200) {
  202. this.resetSearchForm(true)
  203. this.$message.success(res.message)
  204. }
  205. this.loading = false
  206. this.spinning = false
  207. })
  208. },
  209. // 重置列表
  210. resetForm () {
  211. this.$refs.table.refresh(true)
  212. },
  213. // 获取单据详细
  214. getOrderDetail () {
  215. salesReturnDetail({ sn: this.orderSn }).then(res => {
  216. this.ordeDetail = res.data || null
  217. })
  218. },
  219. // 重置
  220. resetSearchForm (flag) {
  221. this.$refs.table.refresh(!!flag)
  222. this.getOrderDetail()
  223. },
  224. // 提交销售单
  225. handleSubmit () {
  226. this.spinning = true
  227. salesReturnCheck({ salesReturnBillSn: this.orderSn }).then(res => {
  228. if (res.status == 200) {
  229. this.handleBack()
  230. this.$message.success(res.message)
  231. this.spinning = false
  232. } else {
  233. this.spinning = false
  234. }
  235. })
  236. },
  237. pageInit () {
  238. const _this = this
  239. this.$nextTick(() => { // 页面渲染完成后的回调
  240. _this.setTableH()
  241. })
  242. this.orderSn = this.$route.params.sn
  243. this.buyerSn = this.$route.params.buyerSn
  244. this.getOrderDetail()
  245. },
  246. setTableH () {
  247. this.tableHeight = window.innerHeight - 340
  248. }
  249. },
  250. mounted () {
  251. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  252. this.$refs.table.refresh(true)
  253. this.pageInit()
  254. }
  255. },
  256. activated () {
  257. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  258. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  259. this.$refs.table.refresh(true)
  260. this.pageInit()
  261. }
  262. },
  263. beforeRouteEnter (to, from, next) {
  264. next(vm => {})
  265. }
  266. }
  267. </script>
  268. <style lang="less">
  269. .salesReturnCheck-wrap{
  270. position: relative;
  271. height: 100%;
  272. padding-bottom: 51px;
  273. box-sizing: border-box;
  274. >.ant-spin-nested-loading{
  275. overflow-y: scroll;
  276. height: 100%;
  277. }
  278. .salesReturnCheck-cont{
  279. margin-top: 10px;
  280. .sTable{
  281. margin-top: 10px;
  282. }
  283. .total-bar{
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-between;
  287. > div{
  288. &:last-child{
  289. display: flex;
  290. align-items: center;
  291. justify-content: space-between;
  292. > div{
  293. padding: 0 10px;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. </style>