purchaseReturnDeatil.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div class="salesReturnEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesReturnEdit-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesReturnEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. </a-page-header>
  10. <a-card size="small" :bordered="false" class="outboundOrderDetail-cont">
  11. <a-collapse :activeKey="['1']">
  12. <a-collapse-panel key="1" header="基础信息">
  13. <a-descriptions size="small" :column="4" style="margin-bottom: 10px;">
  14. <a-descriptions-item label="采购退货单号">CT20221229000001</a-descriptions-item>
  15. <a-descriptions-item label="入库单号">SJ221222000001</a-descriptions-item>
  16. <a-descriptions-item label="批次号">SJ221222000001</a-descriptions-item>
  17. <a-descriptions-item label="供应商名称">东莞市绿冠滤清器有限公司</a-descriptions-item>
  18. <a-descriptions-item label="退货原因">2022-12-30 14:22</a-descriptions-item>
  19. <a-descriptions-item label="补充说明">2022-12-30 14:22</a-descriptions-item>
  20. <a-descriptions-item label="附件">2022-12-30 14:22</a-descriptions-item>
  21. </a-descriptions>
  22. </a-collapse-panel>
  23. </a-collapse>
  24. </a-card>
  25. <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
  26. <!-- 查询配件列表 -->
  27. <div>已入库产品信息</div>
  28. <a-divider />
  29. <queryPart ref="partQuery" :newLoading="isInster" @add="saveProduct"></queryPart>
  30. </a-card>
  31. <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
  32. <a-alert style="margin-bottom: 10px;" type="info">
  33. <div slot="message" class="total-bar">
  34. <div>
  35. <span>申请退货数量:{{ ordeDetail&&(ordeDetail.totalInitialQty || ordeDetail.totalInitialQty==0) ? ordeDetail.totalInitialQty : '--' }};</span>
  36. <span v-if="$hasPermissions('B_isShowPrice')">退货金额:{{ ordeDetail&&(ordeDetail.totalAmount || ordeDetail.totalAmount==0) ? ordeDetail.totalAmount : '--' }}元;</span>
  37. </div>
  38. </div>
  39. </a-alert>
  40. <div class="table-page-search-wrapper" style="display:flex;align-items: center;justify-content: space-between;">
  41. <div style="flex-grow:1;">
  42. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  43. <a-row :gutter="15">
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="产品编码">
  46. <a-input v-model.trim="productForm.productCode" allowClear placeholder="请输入产品编码"/>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-item label="产品名称">
  51. <a-input v-model.trim="productForm.productName" allowClear placeholder="请输入产品名称"/>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  55. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled">查询</a-button>
  56. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled">重置</a-button>
  57. </a-col>
  58. </a-row>
  59. </a-form>
  60. </div>
  61. <div>
  62. <span style="margin-right: 10px;" v-if="selNums">已选{{ selNums }}项</span>
  63. <a-button type="default" class="button-info" @click="openPlSetReason">批量设置退货原因</a-button>
  64. <a-button type="primary" class="button-info" id="salesReturnEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
  65. </div>
  66. </div>
  67. <!-- 已选配件列表 -->
  68. <s-table
  69. class="sTable"
  70. ref="table"
  71. size="small"
  72. :rowKey="(record) => record.id"
  73. :columns="columns"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. :scroll="{ y: 300 }"
  77. bordered>
  78. <!-- 本次退货数量 -->
  79. <template slot="qty" slot-scope="text, record">
  80. <a-input-number
  81. id="salesReturn-qty"
  82. size="small"
  83. v-model="record.initialQty"
  84. :precision="0"
  85. :min="0"
  86. :max="999999"
  87. placeholder="请输入"
  88. @blur="e => onCellBlur(e.target.value, record, 'qty')"
  89. style="width: 100%;" />
  90. </template>
  91. <!-- 退货原因 -->
  92. <template slot="returnReason" slot-scope="text, record">
  93. <returnReason v-model="record.returnReason" @blur="updateReason(record)"></returnReason>
  94. </template>
  95. <!-- 操作 -->
  96. <template slot="action" slot-scope="text, record">
  97. <a-button
  98. size="small"
  99. type="link"
  100. :loading="delLoading"
  101. class="button-error"
  102. @click="handleDel(record)"
  103. id="salesReturn-Del">删除</a-button>
  104. </template>
  105. </s-table>
  106. </a-card>
  107. </a-spin>
  108. <div class="affix-cont">
  109. <a-button
  110. size="large"
  111. style="padding: 0 60px;"
  112. :disabled="spinning"
  113. type="primary"
  114. class="button-primary"
  115. @click="beforeSubmit()"
  116. id="salesReturn-handleSubmit">提交</a-button>
  117. </div>
  118. <!-- 选择审核人员 -->
  119. <!-- <chooseDepartUserModal ref="chooseDepart" :openModal="openDepartUserModal" @close="openDepartUserModal=false" @submit="handleSubmit"></chooseDepartUserModal> -->
  120. <!-- 导入产品 -->
  121. <!-- <importGuideModal :openModal="openGuideModal" :params="{salesReturnBillSn: $route.params.sn}" @close="closeGuideModel" @ok="hanldeOk" /> -->
  122. <!-- 批量设置退货原因 -->
  123. <commonModal modalTit="批量设置退货原因" :openModal="showPlModal" @cancel="showPlModal=false" @ok="setPlReturnReason">
  124. <div style="text-align: center;">
  125. <div style="margin-bottom: 15px;font-size: 14px;"><strong>请输入退货原因</strong></div>
  126. <div style="line-height: 24px;">
  127. <div><returnReason size="large" v-model="plReturnReason"></returnReason></div>
  128. </div>
  129. </div>
  130. </commonModal>
  131. </div>
  132. </template>
  133. <script>
  134. import { commonMixin } from '@/utils/mixin'
  135. import { STable, VSelect } from '@/components'
  136. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  137. // import ImportGuideModal from './importGuideModal.vue'
  138. import queryPart from './queryPart.vue'
  139. import commonModal from '@/views/common/commonModal.vue'
  140. import EditableCell from '@/views/common/editInput.js'
  141. // import chooseDepartUserModal from './chooseDepartUserModal.vue'
  142. import returnReason from '@/views/common/returnReason'
  143. import {
  144. salesReturnDetail,
  145. salesReturnSubmit,
  146. salesReturnBatchInsert,
  147. salesReturnPrint,
  148. salesReturnExport
  149. } from '@/api/salesReturn'
  150. import {
  151. salesReturnDetailList,
  152. salesReturnDetailDel,
  153. salesReturnDetailInsert,
  154. salesReturnDetailUpdateQty,
  155. salesReturnDetailUpdateReason,
  156. salesReturnDetailSetReason
  157. } from '@/api/salesReturnDetail'
  158. export default {
  159. name: 'PurchaseReturnDeatil',
  160. mixins: [commonMixin],
  161. components: {
  162. STable,
  163. VSelect,
  164. EditableCell,
  165. returnReason,
  166. commonModal,
  167. queryPart
  168. },
  169. data () {
  170. return {
  171. spinning: false,
  172. orderId: null,
  173. orderSn: null,
  174. buyerSn: null,
  175. disabled: false,
  176. isInster: false, // 是否正在添加产品
  177. openDepartUserModal: false,
  178. ordeDetail: { discountAmount: 0 },
  179. delLoading: false,
  180. // 已选产品
  181. dataSource: [],
  182. productForm: {
  183. salesReturnBillSn: '',
  184. productName: '',
  185. productCode: ''
  186. },
  187. chooseLoadData: [],
  188. // 加载数据方法 必须为 Promise 对象
  189. loadData: parameter => {
  190. this.disabled = true
  191. // 查询总计
  192. this.productForm.salesReturnBillSn = '481487002858102784'
  193. return salesReturnDetailList(Object.assign(parameter, this.productForm)).then(res => {
  194. let data
  195. if (res.status == 200) {
  196. data = res.data
  197. const no = (data.pageNo - 1) * data.pageSize
  198. for (var i = 0; i < data.list.length; i++) {
  199. data.list[i].no = no + i + 1
  200. data.list[i].qtyBackups = data.list[i].initialQty
  201. data.list[i].returnReasonBackups = data.list[i].returnReason
  202. }
  203. this.disabled = false
  204. this.chooseLoadData = data.list
  205. this.total = res.data.count
  206. }
  207. return data
  208. })
  209. },
  210. openGuideModal: false, // 导入产品引导
  211. total: 0,
  212. rowSelectionInfo: null,
  213. plReturnReason: '',
  214. showPlModal: false
  215. }
  216. },
  217. watch: {
  218. showPlModal (newValue, oldValue) {
  219. if (!newValue) {
  220. this.plReturnReason = ''
  221. }
  222. }
  223. },
  224. computed: {
  225. selNums () {
  226. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  227. },
  228. columns () {
  229. const arr = [
  230. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  231. { title: '产品编码', dataIndex: 'productEntity.code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  232. { title: '产品名称', dataIndex: 'productEntity.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  233. { title: '单位', dataIndex: 'productEntity.unit', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  234. { title: '退货单价', dataIndex: 'initialQty', align: 'center', width: '8%', scopedSlots: { customRender: 'qty' } },
  235. { title: '申请退款数量', dataIndex: 'returnReason', align: 'center', width: '13%', scopedSlots: { customRender: 'returnReason' } },
  236. { title: '退款金额', dataIndex: 'returnReason', align: 'center', width: '13%', scopedSlots: { customRender: 'returnReason' } },
  237. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  238. ]
  239. // if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  240. // arr.splice(4, 0, { title: '参考退货单价', dataIndex: 'price', align: 'center', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  241. // arr.splice(7, 0, { title: '参考退货金额', align: 'center', dataIndex: 'totalAmount', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  242. // }
  243. return arr
  244. }
  245. },
  246. methods: {
  247. // 返回
  248. handleBack () {
  249. this.$router.push({ name: 'salesReturnList', query: { closeLastOldTab: true } })
  250. },
  251. // 表格选中项
  252. rowSelectionFun (obj) {
  253. this.rowSelectionInfo = obj || null
  254. },
  255. // 已选产品 blur
  256. onCellBlur (val, record, type) {
  257. const valBackups = record.qtyBackups
  258. // 光标移出,值发生改变再调用编辑接口
  259. if (val && val != valBackups) {
  260. this.spinning = true
  261. salesReturnDetailUpdateQty({
  262. salesReturnDetailSn: record.salesReturnDetailSn,
  263. initialQty: record.initialQty,
  264. price: record.price
  265. }).then(res => {
  266. if (res.status == 200) {
  267. this.resetTable(false)
  268. this.$message.success(res.message)
  269. this.spinning = false
  270. record.qtyBackups = record.initialQty
  271. } else {
  272. this.spinning = false
  273. record.initialQty = valBackups
  274. }
  275. })
  276. } else {
  277. record.initialQty = valBackups
  278. }
  279. },
  280. // 修改退货原因
  281. updateReason (row) {
  282. console.log(row.returnReason)
  283. // 空或没有改变时不保存数据
  284. if (!row.returnReason || row.returnReason == row.returnReasonBackups) {
  285. row.returnReason = row.returnReasonBackups
  286. return
  287. }
  288. this.spinning = true
  289. salesReturnDetailUpdateReason({
  290. salesReturnDetailSn: row.salesReturnDetailSn,
  291. returnReason: row.returnReason
  292. }).then(res => {
  293. if (res.status == 200) {
  294. this.resetTable(false)
  295. this.$message.success(res.message)
  296. } else {
  297. row.returnReason = row.returnReasonBackups
  298. }
  299. this.spinning = 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. arr.map(item => {
  318. snList.push(item.salesReturnDetailSn)
  319. })
  320. salesReturnDetailSetReason({
  321. salesReturnBillDetailSnList: snList,
  322. returnReason: this.plReturnReason
  323. }).then(res => {
  324. if (res.status == 200) {
  325. this.showPlModal = false
  326. this.$refs.table.clearSelected()
  327. this.resetTable(false)
  328. }
  329. this.spinning = false
  330. })
  331. }
  332. },
  333. // 获取单据详细
  334. getOrderDetail () {
  335. salesReturnDetail({ sn: this.orderSn }).then(res => {
  336. this.ordeDetail = res.data || null
  337. })
  338. },
  339. // 删除产品
  340. handleDel (row) {
  341. const _this = this
  342. this.$confirm({
  343. title: '提示',
  344. content: '确认要删除吗?',
  345. centered: true,
  346. closable: true,
  347. onOk () {
  348. _this.delLoading = true
  349. _this.spinning = true
  350. salesReturnDetailDel({ salesReturnDetailSn: row.salesReturnDetailSn }).then(res => {
  351. if (res.status == 200) {
  352. _this.resetTable(false)
  353. }
  354. _this.$message.info(res.message)
  355. _this.delLoading = false
  356. _this.spinning = false
  357. })
  358. }
  359. })
  360. },
  361. resetTable (flag) {
  362. this.$refs.table.refresh(flag)
  363. this.getOrderDetail()
  364. },
  365. // 重置
  366. resetSearchForm (flag) {
  367. this.productForm.productName = ''
  368. this.productForm.productCode = ''
  369. this.$refs.table.refresh(!!flag)
  370. this.getOrderDetail()
  371. },
  372. // 添加或修改产品
  373. saveProduct (row) {
  374. // 防止多次添加产品
  375. if (this.isInster) {
  376. return
  377. }
  378. this.isInster = true
  379. const params = {
  380. 'salesReturnBillSn': this.orderSn,
  381. 'salesReturnBillNo': this.ordeDetail.salesReturnBillNo,
  382. 'price': row.productPrice,
  383. 'cost': row.lastStockCost,
  384. 'returnReason': row.returnReason,
  385. 'productSn': row.productSn,
  386. 'initialQty': row.qty
  387. }
  388. this.spinning = true
  389. salesReturnDetailInsert(params).then(res => {
  390. if (res.status == 200) {
  391. this.resetSearchForm(true)
  392. this.$message.success(res.message)
  393. }
  394. this.isInster = false
  395. this.spinning = false
  396. })
  397. },
  398. beforeSubmit () {
  399. if (this.total) {
  400. const hasKong = this.chooseLoadData.find(item => !item.returnReason)
  401. if (hasKong) {
  402. this.$message.warning('请输入退货原因!')
  403. } else {
  404. this.openDepartUserModal = true
  405. if (this.ordeDetail.billStatus == 'AUDIT_REJECT') {
  406. this.$refs.chooseDepart.getDetail(this.ordeDetail)
  407. }
  408. }
  409. } else {
  410. this.$message.warning('请添加产品!')
  411. }
  412. },
  413. // 提交销售退货
  414. handleSubmit (data) {
  415. this.spinning = true
  416. salesReturnSubmit({ salesReturnBillSn: this.orderSn, ...data }).then(res => {
  417. if (res.status == 200) {
  418. this.handleBack()
  419. this.$message.success(res.message)
  420. }
  421. this.spinning = false
  422. })
  423. },
  424. closeGuideModel () {
  425. this.openGuideModal = false
  426. },
  427. // 导入产品
  428. hanldeOk (obj) {
  429. salesReturnBatchInsert(obj).then(res => {
  430. if (res.status == 200) {
  431. this.resetTable(true)
  432. }
  433. })
  434. },
  435. // 打印预览/快捷打印
  436. handlePrint (type) {
  437. const _this = this
  438. const a = ['WAIT_CUSTOMER_SERVICE_CONFIRM', 'WAIT_FINANCIAL_AUDIT', 'FINANCIAL_REJECT', 'FINISH'].find(item => item == this.ordeDetail.billStatus)
  439. const status = a ? 'SALES_RETURN_AMOUNT' : 'SALES_RETURN_REASON'
  440. const params = { salesReturnBillSn: this.$route.params.sn, priceType: status }
  441. _this.spinning = true
  442. // 导出
  443. if (type == 'export') {
  444. exportExcel(salesReturnExport, params, '销售退货', function () {
  445. _this.spinning = false
  446. })
  447. } else {
  448. // 打印或预览
  449. printFun(salesReturnPrint, params, type, '销售退货', () => {
  450. _this.spinning = false
  451. })
  452. }
  453. },
  454. pageInit () {
  455. this.orderSn = this.$route.params.sn
  456. this.buyerSn = this.$route.params.buyerSn
  457. this.resetSearchForm(true)
  458. this.$refs.partQuery.pageInit(this.buyerSn, 0)
  459. }
  460. },
  461. mounted () {
  462. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  463. this.pageInit()
  464. }
  465. },
  466. activated () {
  467. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  468. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  469. this.pageInit()
  470. }
  471. },
  472. beforeRouteEnter (to, from, next) {
  473. next(vm => {})
  474. }
  475. }
  476. </script>
  477. <style lang="less">
  478. .salesReturnEdit-wrap{
  479. position: relative;
  480. height: 100%;
  481. padding-bottom: 51px;
  482. box-sizing: border-box;
  483. >.ant-spin-nested-loading{
  484. overflow-y: scroll;
  485. height: 100%;
  486. }
  487. .salesReturnEdit-cont{
  488. margin-top: 10px;
  489. .ant-divider-horizontal{
  490. margin:10px 0 24px;
  491. }
  492. .total-bar{
  493. display: flex;
  494. align-items: center;
  495. justify-content: space-between;
  496. > div{
  497. &:last-child{
  498. display: flex;
  499. align-items: center;
  500. justify-content: space-between;
  501. > div{
  502. padding: 0 10px;
  503. }
  504. }
  505. }
  506. }
  507. }
  508. }
  509. </style>