purchaseReturnDeatil.vue 17 KB

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