purchaseReturnDeatil.vue 19 KB

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