purchaseReturnDeatil.vue 17 KB

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