checking.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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. <span style="margin: 0 10px;color: #666;">
  10. 退货类别:{{ ordeDetail&&ordeDetail.goodFlagDictValue }}
  11. </span>
  12. </template>
  13. </a-page-header>
  14. <a-card size="small" :bordered="false" class="salesReturnCheck-cont">
  15. <a-form layout="inline" style="margin-bottom:10px;" @keyup.enter.native="searchForm">
  16. <a-form-item label="产品编码" prop="productCode">
  17. <a-input id="salesReturnCheck-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  18. </a-form-item>
  19. <a-form-item label="产品名称" prop="productName">
  20. <a-input id="salesReturnCheck-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  21. </a-form-item>
  22. <a-form-item>
  23. <a-button type="primary" @click="searchForm" :disabled="disabled" id="salesReturnCheck-refresh">查询</a-button>
  24. <a-button style="margin-left: 10px" @click="resetSearchForm" :disabled="disabled" id="salesReturnCheck-reset">重置</a-button>
  25. </a-form-item>
  26. </a-form>
  27. <div style="border-top:1px solid #eee;padding-top:10px;">
  28. <a-button type="primary" ghost class="button-info" :loading="loading" @click="plSetQty(1)">批量设置良品数量</a-button>
  29. <a-button type="primary" ghost class="button-info" style="margin-left:5px;" :loading="loading" @click="plSetQty(2)">批量设置返库数量</a-button>
  30. <a-button type="primary" ghost style="margin-left:5px;" :loading="loading" @click="openPlSetReason">批量设置退货原因</a-button>
  31. <span style="margin-left:10px;" v-if="selNums">已选{{ selNums }}项</span>
  32. <div style="float:right;color:#999;margin-top:8px;">说明:红色行表示收货时新增的产品</div>
  33. </div>
  34. <!-- 已选配件列表 -->
  35. <s-table
  36. class="sTable"
  37. ref="table"
  38. :style="{ height: tableHeight+84.5+'px' }"
  39. :rowClassName="(record, index) => record.addFlag == '1' ? (record.addType == 'WAREHOUSE_RECEIVE'?'redBg-row':'orgBg-row'):''"
  40. size="small"
  41. :rowKey="(record) => record.id"
  42. :row-selection="{ columnWidth: 40 }"
  43. @rowSelection="rowSelectionFun"
  44. :columns="columns"
  45. :data="loadData"
  46. :pagination="{pageSizeOptions: ['50','100','200','300','400']}"
  47. :pageSize="50"
  48. :scroll="{ y: tableHeight }"
  49. :defaultLoadData="false"
  50. bordered>
  51. <!-- 良品数量 -->
  52. <template slot="goodQty" slot-scope="text, record">
  53. <a-input-number
  54. id="salesReturn-goodQty"
  55. size="small"
  56. v-model="record.goodQty"
  57. :precision="0"
  58. :min="0"
  59. :max="record.receiveQty"
  60. placeholder="请输入"
  61. @blur="e => updateGoodQty(e.target.value, record)"
  62. style="width: 100%;" />
  63. </template>
  64. <!-- 返库数量 -->
  65. <template slot="backStockQty" slot-scope="text, record">
  66. <a-input-number
  67. id="salesReturn-backStockQty"
  68. size="small"
  69. v-model="record.backStockQty"
  70. :precision="0"
  71. :min="0"
  72. placeholder="请输入"
  73. @blur="e => updateBackStockQty(e.target.value, record)"
  74. style="width: 100%;" />
  75. </template>
  76. <!-- 退货原因 -->
  77. <template slot="returnReason" slot-scope="text, record">
  78. <returnReason v-model="record.returnReasonCode" @change="e => updateReason(e, record, 0)"></returnReason>
  79. </template>
  80. <!-- 备注 -->
  81. <template slot="remarksInfo" slot-scope="text, record">
  82. <a-input
  83. size="small"
  84. v-model.trim="record.returnReasonRemarks"
  85. @blur="e => updateReason(e, record, 1)"
  86. :maxLength="50"
  87. placeholder="请输入备注信息(最多50字符)"/>
  88. </template>
  89. </s-table>
  90. <div class="footer-btn">
  91. <a-button
  92. size="large"
  93. style="padding: 0 60px;"
  94. :disabled="spinning"
  95. type="primary"
  96. class="button-primary"
  97. @click="handleSubmit()"
  98. id="salesReturn-handleSubmit">提交</a-button>
  99. </div>
  100. </a-card>
  101. </a-spin>
  102. <!-- 选中批量操作 -->
  103. <chooseTypeModal :openModal="openTypeModal" :type="actionType" @close="openTypeModal=false" @confirm="plconfirm"></chooseTypeModal>
  104. <!-- 批量设置退货原因 -->
  105. <commonModal modalTit="批量设置退货原因" :openModal="showPlModal" @cancel="showPlModal=false" @ok="setPlReturnReason">
  106. <div style="text-align: left;">
  107. <div style="line-height: 24px;">
  108. <div><span style="color:red;">*</span>退货原因</div>
  109. <div><returnReason size="large" v-model="plReturnReason"></returnReason></div>
  110. </div>
  111. <div style="line-height: 24px;margin-top:10px;">
  112. <a-checkbox :checked="showEditRemarks" @change="e => showEditRemarks=!showEditRemarks">是否设置备注</a-checkbox>
  113. </div>
  114. <div style="line-height: 24px;margin-top:10px;" v-if="showEditRemarks">
  115. <div>备注</div>
  116. <div><a-input size="large" :maxLength="50" placeholder="请输入备注(最多50字符)" v-model="plReturnRemark"></a-input></div>
  117. </div>
  118. </div>
  119. </commonModal>
  120. </div>
  121. </template>
  122. <script>
  123. import { commonMixin } from '@/utils/mixin'
  124. import { STable, VSelect } from '@/components'
  125. import commonModal from '@/views/common/commonModal.vue'
  126. import returnReason from '@/views/common/returnReason'
  127. import { salesReturnDetail, salesReturnCheck } from '@/api/salesReturn'
  128. import { salesReturnDetailList, updateBatchBackStockQty, updateBatchGoodQty, salesReturnDetailSetReason, salesReturnDetailUpdateReason } from '@/api/salesReturnDetail'
  129. import chooseTypeModal from './chooseTypeModal.vue'
  130. export default {
  131. name: 'SalesReturnCheck',
  132. mixins: [commonMixin],
  133. components: {
  134. STable,
  135. VSelect,
  136. chooseTypeModal,
  137. returnReason,
  138. commonModal
  139. },
  140. data () {
  141. return {
  142. spinning: false,
  143. tableHeight: 0, // 表格高度
  144. orderSn: null,
  145. openTypeModal: false,
  146. actionType: '',
  147. disabled: false,
  148. isInster: false, // 是否正在添加产品
  149. ordeDetail: { discountAmount: 0 },
  150. loading: false,
  151. // 已选产品
  152. dataSource: [],
  153. productForm: {
  154. salesReturnBillSn: ''
  155. },
  156. queryParam: {
  157. productCode: '',
  158. productName: ''
  159. },
  160. chooseLoadData: [],
  161. labelCol: { span: 8 },
  162. wrapperCol: { span: 14 },
  163. // 加载数据方法 必须为 Promise 对象
  164. loadData: parameter => {
  165. this.disabled = true
  166. // 查询总计
  167. this.productForm.salesReturnBillSn = this.$route.params.sn
  168. return salesReturnDetailList(Object.assign(parameter, this.productForm, this.queryParam)).then(res => {
  169. let data
  170. if (res.status == 200) {
  171. data = res.data
  172. const no = (data.pageNo - 1) * data.pageSize
  173. for (var i = 0; i < data.list.length; i++) {
  174. data.list[i].no = no + i + 1
  175. data.list[i].goodQty = data.list[i].goodQty || 0
  176. data.list[i].backStockQty = data.list[i].backStockQty || 0
  177. data.list[i].goodQtyBackups = data.list[i].goodQty
  178. data.list[i].backStockQtyBackups = data.list[i].backStockQty
  179. data.list[i].returnReasonBackups = data.list[i].returnReason
  180. data.list[i].bakReamrks = data.list[i].returnReasonRemarks
  181. }
  182. this.disabled = false
  183. this.chooseLoadData = data.list
  184. }
  185. return data
  186. })
  187. },
  188. rowSelectionInfo: null,
  189. plReturnReason: undefined,
  190. plReturnRemark: undefined,
  191. showPlModal: false,
  192. showEditRemarks: false,
  193. returnReasonlist: []
  194. }
  195. },
  196. watch: {
  197. showPlModal (newValue, oldValue) {
  198. if (!newValue) {
  199. this.plReturnReason = undefined
  200. this.plReturnRemark = undefined
  201. this.showEditRemarks = false
  202. }
  203. }
  204. },
  205. computed: {
  206. goodFlag () {
  207. return this.ordeDetail && this.ordeDetail.goodFlag || ''
  208. },
  209. selNums () {
  210. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  211. },
  212. columns () {
  213. const arr = [
  214. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  215. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: '20%', customRender: function (text) { return text || '--' } },
  216. { title: '产品名称', dataIndex: 'productEntity.name', width: '28%', align: 'left', customRender: function (text) { return text || '--' } },
  217. { title: '单位', dataIndex: 'productEntity.unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '申请退货数量', dataIndex: 'initialQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  219. { title: '仓库实收数量', dataIndex: 'receiveQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  220. { title: '坏件数量', dataIndex: 'badQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  221. { title: '良品数量', dataIndex: 'goodQty', width: '10%', align: 'center', scopedSlots: { customRender: 'goodQty' } },
  222. { title: '返库数量', dataIndex: 'backStockQty', width: '10%', align: 'center', scopedSlots: { customRender: 'backStockQty' } },
  223. { title: '退货原因', dataIndex: 'returnReason', width: '20%', align: 'center', scopedSlots: { customRender: 'returnReason' } },
  224. { title: '备注', dataIndex: ' remarksInfo', width: '20%', align: 'center', scopedSlots: { customRender: 'remarksInfo' } }
  225. ]
  226. return arr
  227. }
  228. },
  229. methods: {
  230. // 表格选中项
  231. rowSelectionFun (obj) {
  232. this.rowSelectionInfo = obj || null
  233. },
  234. // 返回
  235. handleBack () {
  236. this.$router.push({ name: 'receiveCheckList' })
  237. },
  238. // 批量设置
  239. plSetQty (type) {
  240. const _this = this
  241. if (!this.selNums) {
  242. _this.$message.warning('请先选择产品!')
  243. return
  244. }
  245. this.actionType = type
  246. this.openTypeModal = true
  247. },
  248. // 批量修改数量
  249. plconfirm (val) {
  250. const _this = this
  251. const obj = []
  252. const hasError = _this.rowSelectionInfo.selectedRows.filter(item => item.backStockQty > 0)
  253. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  254. // 批量设置良品
  255. if (this.actionType == 1) {
  256. const pa = {
  257. salesReturnDetailSn: item.salesReturnDetailSn,
  258. goodQty: val == 1 ? item.receiveQty : 0
  259. }
  260. // 如果批量修改良品数量为0,且返库数量又不是0的情况
  261. if (hasError.length && val == 0) {
  262. pa.backStockQty = 0
  263. }
  264. obj.push(pa)
  265. } else {
  266. // 批量设置返库
  267. obj.push({
  268. salesReturnDetailSn: item.salesReturnDetailSn,
  269. backStockQty: val == 1 ? item.goodQty : 0
  270. })
  271. }
  272. })
  273. console.log(obj)
  274. // 如果批量修改良品数量为0
  275. if (val == 0 && this.actionType == 1 && hasError.length) {
  276. this.$confirm({
  277. title: '提示',
  278. content: '是否将返库数量同样设置为0?',
  279. centered: true,
  280. closable: true,
  281. onOk () {
  282. _this.plSave(obj)
  283. }
  284. })
  285. } else {
  286. _this.plSave(obj)
  287. }
  288. },
  289. plSave (obj) {
  290. const fun = this.actionType == 1 ? updateBatchGoodQty : updateBatchBackStockQty
  291. this.spinning = true
  292. fun(obj).then(res => {
  293. if (res.status == 200) {
  294. this.$refs.table.clearSelected()
  295. this.$refs.table.refresh()
  296. this.$message.success(res.message)
  297. }
  298. this.spinning = false
  299. this.openTypeModal = false
  300. })
  301. },
  302. // 批量设置退货原因
  303. openPlSetReason () {
  304. if (this.selNums) {
  305. this.showPlModal = true
  306. } else {
  307. this.$message.warning('请先选择产品!')
  308. }
  309. },
  310. setPlReturnReason () {
  311. if (!this.plReturnReason) {
  312. this.$message.warning('请选择退货原因!')
  313. } else {
  314. this.spinning = true
  315. const snList = []
  316. const arr = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  317. const rows = this.returnReasonlist.find(item => item.code == this.plReturnReason)
  318. arr.map(item => {
  319. snList.push(item.salesReturnDetailSn)
  320. })
  321. salesReturnDetailSetReason({
  322. salesReturnBillDetailSnList: snList,
  323. salesReturnBillSn: this.orderSn,
  324. returnReason: rows ? rows.dispName : '',
  325. returnReasonCode: this.plReturnReason,
  326. returnReasonRemarks: this.showEditRemarks ? this.plReturnRemark || '' : undefined,
  327. goodFlag: rows.lookupCode
  328. }).then(res => {
  329. if (res.status == 200) {
  330. this.showPlModal = false
  331. this.$refs.table.clearSelected()
  332. this.$refs.table.refresh()
  333. }
  334. this.spinning = false
  335. })
  336. }
  337. },
  338. // 修改退货原因
  339. updateReason (val, record, type) {
  340. const params = {
  341. salesReturnDetailSn: record.salesReturnDetailSn
  342. }
  343. // 退货原因
  344. if (type == 0) {
  345. const rows = this.returnReasonlist.find(item => item.code == val)
  346. params.returnReasonCode = val || ''
  347. params.returnReason = rows ? rows.dispName : ''
  348. params.goodFlag = rows.lookupCode
  349. } else {
  350. // 备注
  351. params.returnReasonRemarks = val.target.value
  352. if (params.returnReasonRemarks == record.bakReamrks) {
  353. return
  354. }
  355. }
  356. this.spinning = true
  357. salesReturnDetailUpdateReason(params).then(res => {
  358. if (res.status == 200) {
  359. this.$refs.table.refresh()
  360. this.$message.success(res.message)
  361. } else {
  362. row.returnReason = row.returnReasonBackups
  363. }
  364. this.spinning = false
  365. })
  366. },
  367. // 修改良品数量
  368. updateGoodQty (val, record) {
  369. if (record.backStockQty > record.goodQty) {
  370. this.$message.info('返库数量不能大于良品数量')
  371. record.goodQty = record.goodQtyBackups
  372. return
  373. }
  374. // 光标移出,值发生改变再调用编辑接口
  375. if (val && val != record.goodQtyBackups) {
  376. this.spinning = true
  377. updateBatchGoodQty([{
  378. salesReturnDetailSn: record.salesReturnDetailSn,
  379. goodQty: record.goodQty
  380. }]).then(res => {
  381. if (res.status == 200) {
  382. this.resetSearchForm(false)
  383. this.$message.success(res.message)
  384. record.goodQtyBackups = record.goodQty
  385. } else {
  386. record.goodQty = record.goodQtyBackups
  387. }
  388. this.spinning = false
  389. })
  390. } else {
  391. record.goodQty = record.goodQtyBackups
  392. }
  393. },
  394. // 修改返库数量
  395. updateBackStockQty (val, record) {
  396. if (record.backStockQty > record.goodQty) {
  397. this.$message.info('返库数量不能大于良品数量')
  398. record.backStockQty = record.backStockQtyBackups
  399. return
  400. }
  401. // 光标移出,值发生改变再调用编辑接口
  402. if (val && val != record.backStockQtyBackups) {
  403. this.spinning = true
  404. updateBatchBackStockQty([{
  405. salesReturnDetailSn: record.salesReturnDetailSn,
  406. backStockQty: record.backStockQty
  407. }]).then(res => {
  408. if (res.status == 200) {
  409. this.resetSearchForm(false)
  410. this.$message.success(res.message)
  411. } else {
  412. record.backStockQty = record.backStockQtyBackups
  413. }
  414. this.spinning = false
  415. })
  416. } else {
  417. record.backStockQty = record.backStockQtyBackups
  418. }
  419. },
  420. // 获取单据详细
  421. getOrderDetail () {
  422. salesReturnDetail({ sn: this.orderSn }).then(res => {
  423. this.ordeDetail = res.data || null
  424. if (res.data) {
  425. this.returnReasonlist = [...this.$store.state.app.goodReturnReason, ...this.$store.state.app.defectiveReturnReason]
  426. }
  427. })
  428. },
  429. // 重置
  430. resetSearchForm (flag) {
  431. if (flag) {
  432. this.rowSelectionInfo = null
  433. this.$refs.table.clearSelected()
  434. this.queryParam = {
  435. productCode: '',
  436. productName: ''
  437. }
  438. }
  439. this.$refs.table.refresh(!!flag)
  440. },
  441. searchForm () {
  442. this.$refs.table.refresh(true)
  443. this.$refs.table.clearSelected()
  444. },
  445. // 提交品检
  446. handleSubmit () {
  447. const _this = this
  448. this.$confirm({
  449. title: '提示',
  450. content: '提交后将无法修改,确认提交吗?',
  451. centered: true,
  452. closable: true,
  453. onOk () {
  454. _this.spinning = true
  455. salesReturnCheck({ salesReturnBillSn: _this.orderSn }).then(res => {
  456. if (res.status == 200) {
  457. _this.handleBack()
  458. _this.$message.success(res.message)
  459. _this.spinning = false
  460. } else {
  461. _this.spinning = false
  462. }
  463. })
  464. }
  465. })
  466. },
  467. pageInit () {
  468. const _this = this
  469. this.$nextTick(() => { // 页面渲染完成后的回调
  470. _this.setTableH()
  471. })
  472. this.orderSn = this.$route.params.sn
  473. this.getOrderDetail()
  474. },
  475. setTableH () {
  476. this.tableHeight = window.innerHeight - 390
  477. }
  478. },
  479. mounted () {
  480. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  481. this.$refs.table.refresh(true)
  482. this.pageInit()
  483. }
  484. },
  485. activated () {
  486. this.$refs.table.refresh()
  487. this.pageInit()
  488. },
  489. beforeRouteEnter (to, from, next) {
  490. next(vm => {})
  491. }
  492. }
  493. </script>
  494. <style lang="less">
  495. .salesReturnCheck-wrap{
  496. position: relative;
  497. height: 100%;
  498. padding-bottom: 51px;
  499. box-sizing: border-box;
  500. >.ant-spin-nested-loading{
  501. height: 100%;
  502. }
  503. .footer-btn{
  504. text-align: center;
  505. }
  506. .salesReturnCheck-cont{
  507. margin-top: 10px;
  508. .sTable{
  509. margin-top: 10px;
  510. }
  511. .total-bar{
  512. display: flex;
  513. align-items: center;
  514. justify-content: space-between;
  515. > div{
  516. &:last-child{
  517. display: flex;
  518. align-items: center;
  519. justify-content: space-between;
  520. > div{
  521. padding: 0 10px;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. .redBg-row{
  528. background-color: #f5beb4;
  529. }
  530. .orgBg-row{
  531. background-color: #fffca2;
  532. }
  533. }
  534. </style>