purchaseReturnDeatil.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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">
  8. <a-icon type="left" />
  9. 返回列表
  10. </a>
  11. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailsData&&detailsData.sparePartsReturnNo }}</span>
  12. <span style="margin: 0 10px;color: #666;">供应商:{{ detailsData && detailsData.supplier && detailsData.supplier.supplierName }}</span>
  13. <a-button type="link" size="small" class="button-default" @click="showDetail=!showDetail">
  14. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  15. </a-button>
  16. </template>
  17. </a-page-header>
  18. <a-card size="small" :bordered="false" class="salesReturnEdit-cont" v-show="showDetail">
  19. <div slot="title">
  20. <span>基础信息</span>
  21. <div style="cursor:pointer;color: #00aaff;float:right;" @click.stop="handleEditBase" >
  22. <a-icon type="edit" /> 编辑基础信息
  23. </div>
  24. </div>
  25. <a-descriptions size="small" :column="4" style="margin-bottom: 10px;">
  26. <a-descriptions-item label="采购退货单号">{{ (detailsData && detailsData.sparePartsReturnNo) || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="供应商名称">{{ (detailsData && detailsData.supplier && detailsData.supplier.supplierName) || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="退货原因">{{ (detailsData && detailsData.returnReasonDictValue) || '--' }}</a-descriptions-item>
  29. <a-descriptions-item label="退货仓库">{{ detailsData&&detailsData.warehouseName || '--' }}</a-descriptions-item>
  30. <a-descriptions-item label="是否抓单">{{ detailsData&&detailsData.grabFlag =='0'?'否':'是' }}</a-descriptions-item>
  31. <a-descriptions-item label="补充说明">{{ (detailsData && detailsData.explainInfo) || '--' }}</a-descriptions-item>
  32. <a-descriptions-item label="附件" :span="2">
  33. <span v-if="detailsData && detailsData.attachmentList && detailsData.attachmentList.length > 0">
  34. <a
  35. target="_blank"
  36. style="color: #00aaff;text-decoration: underline;margin-right: 15px;"
  37. :href="item.filePath"
  38. v-for="item in detailsData.attachmentList"
  39. :key="item.id"
  40. >
  41. {{ item.fileName }}
  42. </a>
  43. </span>
  44. <span v-else>--</span>
  45. </a-descriptions-item>
  46. </a-descriptions>
  47. </a-card>
  48. <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
  49. <queryPart
  50. ref="partQuery"
  51. :newLoading="isInster"
  52. :addMoreLoading="addMoreLoading"
  53. @add="saveProduct"
  54. @bachAdd="saveMoreProduct"></queryPart>
  55. </a-card>
  56. <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
  57. <a-alert style="margin-bottom: 10px;" type="info">
  58. <div slot="message" class="total-bar">
  59. <div v-if="statisticsObj">
  60. <span>申请退货数量:{{ statisticsObj && (statisticsObj.qty || statisticsObj.qty == 0) ? statisticsObj.qty : '--' }};</span>
  61. <span v-if="$hasPermissions('B_purchaseReturnEdit_costPrice')">退货金额:{{ statisticsObj && statisticsObj.totalCost || statisticsObj.totalCost == 0 ? statisticsObj.totalCost : '--' }};</span>
  62. </div>
  63. </div>
  64. </a-alert>
  65. <div class="table-page-search-wrapper" style="display:flex;align-items: center;justify-content: space-between;">
  66. <div style="flex-grow:1;">
  67. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  68. <a-row :gutter="15">
  69. <a-col :md="6" :sm="24">
  70. <a-form-item label="入库单号"><a-input v-model.trim="productForm.sparePartsNo" allowClear placeholder="请输入入库单号" /></a-form-item>
  71. </a-col>
  72. <a-col :md="6" :sm="24">
  73. <a-form-item label="产品编码"><a-input v-model.trim="productForm.productCode" allowClear placeholder="请输入产品编码" /></a-form-item>
  74. </a-col>
  75. <a-col :md="6" :sm="24">
  76. <a-form-item label="产品名称"><a-input v-model.trim="productForm.productName" allowClear placeholder="请输入产品名称" /></a-form-item>
  77. </a-col>
  78. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  79. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  80. <a-button style="margin-left: 5px" @click="resetSearchForm">重置</a-button>
  81. </a-col>
  82. </a-row>
  83. </a-form>
  84. </div>
  85. </div>
  86. <!-- 已选配件列表 -->
  87. <s-table
  88. class="sTable"
  89. ref="table"
  90. size="small"
  91. :rowKey="(record) => record.id"
  92. :columns="columns"
  93. :data="loadData"
  94. :defaultLoadData="false"
  95. :scroll="{ y: 300 }"
  96. bordered>
  97. <!--申请退货数量 -->
  98. <template slot="qty" slot-scope="text, record">
  99. <a-input-number
  100. id="salesReturn-qty"
  101. size="small"
  102. v-model="record.qty"
  103. :precision="0"
  104. :min="1"
  105. :max="record.qty"
  106. placeholder="请输入"
  107. style="width: 100%;"
  108. @blur="e => onCellBlur(e.target.value, record)"
  109. />
  110. </template>
  111. <!-- 操作 -->
  112. <template slot="action" slot-scope="text, record">
  113. <a-button
  114. size="small"
  115. type="link"
  116. :loading="delLoading"
  117. class="button-error"
  118. @click="handleDel(record)"
  119. id="salesReturn-Del">删除</a-button>
  120. </template>
  121. </s-table>
  122. </a-card>
  123. </a-spin>
  124. <div class="affix-cont">
  125. <a-button
  126. size="large"
  127. style="padding: 0 60px;"
  128. :disabled="spinning"
  129. type="primary"
  130. class="button-primary"
  131. @click="beforeSubmit"
  132. id="salesReturn-handleSubmit">提交</a-button>
  133. </div>
  134. <!-- 选择审核人员 -->
  135. <chooseDepartUserModal ref="chooseDepart" :openModal="openDepartUserModal" @close="openDepartUserModal = false" @submit="handleSubmit"></chooseDepartUserModal>
  136. <!-- 编辑基础信息弹窗 -->
  137. <add-modal v-drag :openModal="openModal" :itemSn="sparePartsReturnSn" @ok="getBasicsData" @close="openModal = false" />
  138. </div>
  139. </template>
  140. <script>
  141. import { commonMixin } from '@/utils/mixin'
  142. import { STable, VSelect } from '@/components'
  143. import queryPart from './queryPart.vue'
  144. import addModal from './addModal.vue'
  145. import chooseDepartUserModal from './chooseDepartUserModal.vue'
  146. import {
  147. sparePartsReturnQueryPage,
  148. queryPageCount,
  149. sparePartsReturnDetailDelete,
  150. sparePartsReturnDetailSave,
  151. sparePartsReturnSubmit,
  152. sparePartsReturnInfo,
  153. sparePartsReturnDetailSaveBatch
  154. } from '@/api/sparePartsReturn'
  155. export default {
  156. name: 'PurchaseReturnEdit',
  157. mixins: [commonMixin],
  158. components: {
  159. STable,
  160. VSelect,
  161. queryPart,
  162. addModal,
  163. chooseDepartUserModal
  164. },
  165. data () {
  166. return {
  167. spinning: false,
  168. isInster: false, // 是否正在添加产品
  169. openDepartUserModal: false, // 审核人员弹窗
  170. delLoading: false,
  171. showDetail: false,
  172. productForm: {
  173. productName: '',
  174. productCode: '',
  175. sparePartsNo: '',
  176. orderBy: 'sprd.CREATE_DATE DESC'
  177. },
  178. sparePartsReturnSn: null,
  179. sparePartsReturnNo: null,
  180. chooseList: [],
  181. // 加载数据方法 必须为 Promise 对象
  182. loadData: parameter => {
  183. this.productForm.sparePartsReturnSn = this.sparePartsReturnSn
  184. return sparePartsReturnQueryPage(Object.assign(parameter, this.productForm)).then(res => {
  185. let data
  186. if (res.status == 200) {
  187. data = res.data
  188. const no = (data.pageNo - 1) * data.pageSize
  189. for (var i = 0; i < data.list.length; i++) {
  190. data.list[i].no = no + i + 1
  191. }
  192. }
  193. this.chooseList = data.list
  194. return data
  195. })
  196. },
  197. openModal: false, // 修改信息弹窗
  198. statisticsObj: null, // 统计明细
  199. detailsData: null, // 基础信息数据
  200. addMoreLoading: false, // 批量添加动画
  201. grabFlag: undefined
  202. }
  203. },
  204. computed: {
  205. columns () {
  206. const _this = this
  207. const arr = [
  208. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  209. {
  210. title: '入库单号',
  211. dataIndex: 'sparePartsNo',
  212. width: '18%',
  213. align: 'center',
  214. customRender: function (text) {
  215. return text || '--'
  216. }
  217. },
  218. {
  219. title: '产品编码',
  220. dataIndex: 'product.code',
  221. width: '18%',
  222. align: 'center',
  223. customRender: function (text) {
  224. return text || '--'
  225. }
  226. },
  227. {
  228. title: '产品名称',
  229. dataIndex: 'product.name',
  230. width: '25%',
  231. align: 'left',
  232. customRender: function (text) {
  233. return text || '--'
  234. },
  235. ellipsis: true
  236. },
  237. {
  238. title: '单位',
  239. dataIndex: 'product.unit',
  240. align: 'center',
  241. width: '6%',
  242. customRender: function (text) {
  243. return text || '--'
  244. }
  245. },
  246. {
  247. title: '批次号',
  248. dataIndex: 'stockBatchNo',
  249. align: 'center',
  250. width: '10%',
  251. customRender: function (text) {
  252. return text || '--'
  253. }
  254. },
  255. { title: '申请退货数量', align: 'center', width: '13%', scopedSlots: { customRender: 'qty' } },
  256. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  257. ]
  258. if (this.$hasPermissions('B_purchaseReturnEdit_costPrice')) {
  259. arr.splice(6, 0, {
  260. title: '退货单价',
  261. dataIndex: 'cost',
  262. width: '8%',
  263. align: 'right',
  264. customRender: function (text) {
  265. return text || text == 0 ? _this.toThousands(text, 2) : '--'
  266. }
  267. })
  268. arr.splice(8, 0, {
  269. title: '退款金额',
  270. dataIndex: 'totalCost',
  271. width: '8%',
  272. align: 'right',
  273. customRender: function (text) {
  274. return text || text == 0 ? _this.toThousands(text, 2) : '--'
  275. }
  276. })
  277. }
  278. return arr
  279. }
  280. },
  281. methods: {
  282. // 编辑基础信息
  283. handleEditBase () {
  284. this.openModal = true
  285. },
  286. // 返回
  287. handleBack () {
  288. this.$router.push({ path: `/purchasingManagement/purchaseReturn/list`, query: { closeLastOldTab: true } })
  289. },
  290. // 删除所选产品
  291. handleDel (row) {
  292. const _this = this
  293. this.$confirm({
  294. title: '提示',
  295. content: '确认要删除吗?',
  296. centered: true,
  297. closable: true,
  298. onOk () {
  299. _this.delLoading = true
  300. _this.spinning = true
  301. sparePartsReturnDetailDelete({ detailSn: row.sparePartsReturnDetailSn })
  302. .then(res => {
  303. if (res.status == 200) {
  304. _this.resetTable(false)
  305. _this.getStatisticsData()
  306. _this.getChooseList()
  307. _this.$refs.partQuery.refreshLength()
  308. }
  309. _this.$message.info(res.message)
  310. _this.delLoading = false
  311. _this.spinning = false
  312. })
  313. .catch(err => {
  314. _this.delLoading = false
  315. })
  316. }
  317. })
  318. },
  319. resetTable (flag) {
  320. this.$refs.table.refresh(flag)
  321. },
  322. // 重置
  323. resetSearchForm (flag) {
  324. this.productForm.productName = ''
  325. this.productForm.productCode = ''
  326. this.productForm.sparePartsNo = ''
  327. this.$refs.table.refresh(!!flag)
  328. },
  329. // 已选产品 blur
  330. onCellBlur (val, record) {
  331. if (val * 1 > record.putQty * 1) {
  332. this.$message.warning('申请退货数量不能大于入库数量!')
  333. this.$refs.table.refresh(true)
  334. return
  335. }
  336. const ajax_data = {
  337. sparePartsReturnSn: this.sparePartsReturnSn,
  338. sparePartsReturnNo: this.sparePartsReturnNo,
  339. sparePartsDetailSn: record.sparePartsDetailSn,
  340. productSn: record.productSn,
  341. sparePartsReturnDetailSn: record.sparePartsReturnDetailSn,
  342. stockDetailSn: record.stockDetailSn,
  343. productCode: record.productCode,
  344. putQty: record.putQty, // 入库数量
  345. returnedQty: record.returnedQty, // 已退数量
  346. qty: val, // 申退数量
  347. cost: record.cost, // 成本
  348. stockBatchNo: record.stockBatchNo, // 批次号
  349. warehouseSn: record.warehouseSn, // 仓库sn
  350. warehouseLocationSn: record.warehouseLocationSn, // 仓位sn
  351. sparePartsNo: record.sparePartsNo,
  352. sparePartsSn: record.sparePartsSn
  353. }
  354. this.saveEdit(ajax_data)
  355. },
  356. // 添加或修改产品
  357. saveProduct (row) {
  358. if (this.isInster) {
  359. // 防止多次添加产品
  360. return
  361. }
  362. this.isInster = true
  363. const paramsData = {
  364. sparePartsReturnSn: this.sparePartsReturnSn,
  365. sparePartsReturnNo: this.sparePartsReturnNo,
  366. sparePartsDetailSn: row.sparePartsDetailSn,
  367. productSn: row.productSn,
  368. stockDetailSn: row.stockDetailSn,
  369. productCode: row.productCode,
  370. putQty: row.productQty, // 入库数量
  371. returnedQty: row.returnedQty, // 已退数量
  372. qty: row.qty, // 申退数量
  373. cost: row.productCost, // 成本
  374. stockBatchNo: row.sparePartsBatchNo, // 批次号
  375. warehouseSn: row.warehouseSn, // 仓库sn
  376. warehouseLocationSn: row.warehouseLocationSn, // 仓位sn
  377. sparePartsNo: row.sparePartsNo,
  378. sparePartsSn: row.sparePartsSn
  379. }
  380. this.saveEdit(paramsData)
  381. },
  382. saveMoreProduct (data) {
  383. if (this.addMoreLoading) {
  384. // 防止多次添加产品
  385. return
  386. }
  387. this.addMoreLoading = true
  388. var ajax_data = []
  389. data.forEach(item => {
  390. const obj = {
  391. sparePartsReturnSn: this.sparePartsReturnSn,
  392. sparePartsReturnNo: this.sparePartsReturnNo,
  393. sparePartsDetailSn: item.sparePartsDetailSn,
  394. productSn: item.productSn,
  395. stockDetailSn: item.stockDetailSn,
  396. productCode: item.productCode,
  397. putQty: item.productQty, // 入库数量
  398. returnedQty: item.returnedQty, // 已退数量
  399. qty: item.qty, // 申退数量
  400. cost: item.productCost, // 成本
  401. stockBatchNo: item.sparePartsBatchNo, // 批次号
  402. warehouseSn: item.warehouseSn, // 仓库sn
  403. warehouseLocationSn: item.warehouseLocationSn, // 仓位sn
  404. sparePartsNo: item.sparePartsNo,
  405. sparePartsSn: item.sparePartsSn
  406. }
  407. ajax_data.push(obj)
  408. })
  409. this.saveMore(ajax_data)
  410. },
  411. saveEdit (params) {
  412. this.spinning = true
  413. sparePartsReturnDetailSave(params).then(res => {
  414. if (res.status == 200) {
  415. this.getStatisticsData()
  416. this.$refs.table.refresh(true)
  417. this.getChooseList()
  418. }
  419. this.isInster = false
  420. this.spinning = false
  421. this.addMoreLoading = false
  422. }).catch(err => {
  423. this.isInster = false
  424. })
  425. },
  426. saveMore (params) {
  427. this.spinning = true
  428. sparePartsReturnDetailSaveBatch(params)
  429. .then(res => {
  430. if (res.status == 200) {
  431. this.getStatisticsData()
  432. this.getChooseList()
  433. this.$refs.table.refresh(true)
  434. this.$refs.partQuery.refreshLength()
  435. }
  436. this.isInster = false
  437. this.spinning = false
  438. this.addMoreLoading = false
  439. })
  440. .catch(err => {
  441. this.isInster = false
  442. this.addMoreLoading = false
  443. this.spinning = false
  444. })
  445. },
  446. beforeSubmit () {
  447. if (this.chooseList.length > 0) {
  448. this.openDepartUserModal = true
  449. } else {
  450. this.$message.warning('请先添加要退货的产品!')
  451. }
  452. },
  453. // 提交采购退货
  454. handleSubmit (data) {
  455. this.spinning = true
  456. sparePartsReturnSubmit({ sparePartsReturnSn: this.sparePartsReturnSn, ...data }).then(res => {
  457. if (res.status == 200) {
  458. this.handleBack()
  459. this.$message.success(res.message)
  460. }
  461. this.spinning = false
  462. })
  463. },
  464. pageInit () {
  465. this.supplierSn = this.$route.query.sn
  466. this.sparePartsReturnSn = this.$route.query.returnSn
  467. this.sparePartsReturnNo = this.$route.query.no
  468. this.getStatisticsData()
  469. this.getBasicsData()
  470. this.resetSearchForm(true)
  471. },
  472. getChooseList () {
  473. this.$refs.partQuery.pageInit(this.supplierSn, this.sparePartsReturnSn, this.detailsData ? this.detailsData.warehouseSn : undefined, this.detailsData.grabFlag)
  474. },
  475. // 获取页面统计数据
  476. getStatisticsData () {
  477. this.getBasicsData()
  478. queryPageCount({ sparePartsReturnSn: this.sparePartsReturnSn }).then(res => {
  479. if (res.status == 200) {
  480. if (res.data) {
  481. res.data.totalCost = res.data && (res.data.totalCost || res.data.totalCost == 0) ? this.toThousands(res.data.totalCost, 2) : '--'
  482. this.statisticsObj = res.data
  483. } else {
  484. this.statisticsObj = null
  485. }
  486. } else {
  487. this.statisticsObj = null
  488. }
  489. })
  490. },
  491. // 获取基础信息
  492. getBasicsData () {
  493. sparePartsReturnInfo({ sn: this.sparePartsReturnSn }).then(res => {
  494. if (res.status == 200) {
  495. this.detailsData = res.data
  496. } else {
  497. this.detailsData = null
  498. }
  499. const _this = this
  500. this.$nextTick(() => {
  501. _this.getChooseList()
  502. })
  503. })
  504. }
  505. },
  506. mounted () {
  507. if (!this.$store.state.app.isNewTab) {
  508. // 页签刷新时调用
  509. this.pageInit()
  510. }
  511. },
  512. activated () {
  513. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  514. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  515. this.pageInit()
  516. }
  517. },
  518. beforeRouteEnter (to, from, next) {
  519. next(vm => {})
  520. }
  521. }
  522. </script>
  523. <style lang="less">
  524. .salesReturnEdit-wrap {
  525. position: relative;
  526. height: 100%;
  527. padding-bottom: 51px;
  528. box-sizing: border-box;
  529. > .ant-spin-nested-loading {
  530. overflow-y: scroll;
  531. height: 100%;
  532. }
  533. .salesReturnEdit-cont {
  534. margin-top: 6px;
  535. .ant-divider-horizontal {
  536. margin: 10px 0 24px;
  537. }
  538. .total-bar {
  539. display: flex;
  540. align-items: center;
  541. justify-content: space-between;
  542. > div {
  543. &:last-child {
  544. display: flex;
  545. align-items: center;
  546. justify-content: space-between;
  547. > div {
  548. padding: 0 10px;
  549. }
  550. }
  551. }
  552. }
  553. }
  554. }
  555. </style>