check.vue 10 KB

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