checking.vue 14 KB

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