check.vue 9.9 KB

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