purchaseReturnDeatil.vue 17 KB

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