edit.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <div class="financialCollectionAddwrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="financialCollectionAddcont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="purchaseOrderEdit-back-btn" href="javascript:;" @click="handleBack(0)"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. </a-page-header>
  10. <a-collapse :activeKey="['1']" class="financialCollectionAddcont" v-if="detailData">
  11. <a-collapse-panel key="1" header="基础信息">
  12. <div slot="extra" style="padding: 0 20px; color: #00aaff;" @click.stop="handleEditBase" >
  13. <a-icon type="edit" /> 编辑基础信息
  14. </div>
  15. <a-descriptions :column="{ xs: 2, sm: 3, md: 3}">
  16. <a-descriptions-item label="创建时间">{{ detailData&&detailData.createDate || '--' }}</a-descriptions-item>
  17. <a-descriptions-item label="申请人">{{ detailData&&detailData.applyPersonName || '--' }}</a-descriptions-item>
  18. <a-descriptions-item label="审核时间">{{ detailData&&detailData.auditDate || '--' }}</a-descriptions-item>
  19. <a-descriptions-item span="2" label="收款事由">{{ detailData&&detailData.bookReason || '--' }}</a-descriptions-item>
  20. <a-descriptions-item label="状态">{{ detailData&&detailData.statusDictValue || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="付款方类型">{{ detailData&&detailData.payerTypeDictValue || '--' }}</a-descriptions-item>
  22. <a-descriptions-item label="付款方">{{ detailData&&detailData.payerName || '--' }}</a-descriptions-item>
  23. <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks||'--' }}</a-descriptions-item>
  24. <a-descriptions-item label="附件" :span="3">
  25. <a target="_blank" style="color: #00aaff;text-decoration: underline;margin-right: 15px;" :href="item.filePath" v-for="item in detailData.attachmentList" :key="item.id">
  26. {{ item.fileName }}
  27. </a>
  28. </a-descriptions-item>
  29. </a-descriptions>
  30. </a-collapse-panel>
  31. </a-collapse>
  32. <!-- 财务明细 -->
  33. <a-card :bordered="false" size="small" class="financialCollectionAddcont" v-if="$route.params.sn">
  34. <div slot="title">
  35. <div style="display: flex;justify-content: space-between;align-items: center;">
  36. <div>财务明细</div>
  37. <div>
  38. <a-button size="small" class="button-error" type="primary" @click="handleEdit">新增收款明细</a-button>
  39. </div>
  40. </div>
  41. </div>
  42. <a-alert type="info" style="margin-bottom:10px" v-if="detailData">
  43. <div slot="message">
  44. 共 {{ total }} 条,
  45. 订单金额合计 {{ toThousands(detailData.orderTotalAmount ||0)}},
  46. 收款金额合计 {{ toThousands(detailData.receiptTotalAmount ||0)}},
  47. 使用授信合计 {{ toThousands(detailData.useTotalAmount||0) }},
  48. 授信还款合计 {{ toThousands(detailData.payTotalAmount||0) }},
  49. 余款抵扣合计 {{ toThousands(detailData.balanceTotalAmount||0) }}
  50. </div>
  51. </a-alert>
  52. <!-- 列表 -->
  53. <s-table
  54. class="sTable fixPagination"
  55. ref="table"
  56. size="small"
  57. :rowKey="(record) => record.id"
  58. :columns="columns"
  59. :data="loadData"
  60. :defaultLoadData="false"
  61. :showPagination="false"
  62. bordered>
  63. <template slot="expandedRowRender" slot-scope="record">
  64. <div style="padding:10px;overflow: hidden;" v-if="record.detailItemUseList.length || record.detailItemPayList.length">
  65. <a-table
  66. style="width:45%;background:#fff;float:left;border-bottom: 1px solid #eee;"
  67. :bordered="false"
  68. :pagination="false"
  69. :columns="useCol"
  70. :data-source="record.detailItemUseList">
  71. </a-table>
  72. <a-table
  73. :bordered="false"
  74. style="width:45%;background:#fff;float:left;border-bottom: 1px solid #eee;margin-left:2%;"
  75. :pagination="false"
  76. :columns="payCol"
  77. :data-source="record.detailItemPayList">
  78. </a-table>
  79. </div>
  80. <div style="padding:10px;text-align:center;" v-else>暂无数据</div>
  81. </template>
  82. <!-- 付款账户(营业执照) -->
  83. <template slot="payerAccountInfo" slot-scope="record">
  84. {{ record.payerAccountInfo || '--' }}
  85. </template>
  86. <template slot="action" slot-scope="text,record">
  87. <a-button
  88. size="small"
  89. type="link"
  90. class="button-info"
  91. @click="handleEdit(record)"
  92. >编辑</a-button>
  93. <a-button
  94. size="small"
  95. type="link"
  96. class="button-error"
  97. @click="handleDel(record)"
  98. >删除</a-button>
  99. </template>
  100. </s-table>
  101. </a-card>
  102. <!-- 关联单据 -->
  103. <a-card :bordered="false" size="small" class="financialCollectionAddcont" v-if="$route.params.sn">
  104. <div slot="title">
  105. <div style="display: flex;justify-content: space-between;align-items: center;">
  106. <div>关联单据</div>
  107. <div>
  108. <a-button size="small" class="button-info" type="primary" @click="showGlSalseModal=true">选择销售单</a-button>
  109. <a-button size="small" class="button-info" type="primary" @click="showGlAllocaModal=true">选择调拨单</a-button>
  110. </div>
  111. </div>
  112. </div>
  113. <a-alert type="info" style="margin-bottom:10px" v-if="detailGlData">
  114. <div slot="message">
  115. 共 {{ detailGlData.total }} 条,
  116. 总售价:¥{{ detailGlData.totalAmount }}
  117. </div>
  118. </a-alert>
  119. <!-- 列表 -->
  120. <s-table
  121. class="sTable fixPagination"
  122. ref="gltable"
  123. size="small"
  124. :rowKey="(record) => record.id"
  125. :columns="glcolumns"
  126. :data="glloadData"
  127. :showPagination="false"
  128. bordered>
  129. <template slot="action" slot-scope="text,record">
  130. <a-button
  131. size="small"
  132. type="link"
  133. class="button-error"
  134. @click="handleGlDel(record)"
  135. >删除</a-button>
  136. </template>
  137. </s-table>
  138. </a-card>
  139. </a-spin>
  140. <div class="affix-cont">
  141. <a-button
  142. type="primary"
  143. class="button-primary"
  144. :disabled="spinning"
  145. id="financialCollectionAddsubmit-btn"
  146. size="large"
  147. @click="beforeSubmit"
  148. style="padding: 0 60px;">提交</a-button>
  149. </div>
  150. <!-- 基础信息 -->
  151. <baseModal
  152. ref="baseModal"
  153. @refashData="refashData"
  154. :show="openBaseModal"
  155. :bookSn="$route.params.sn"
  156. @cancel="openBaseModal=false"></baseModal>
  157. <!-- 明细弹框 -->
  158. <fcDetailModal
  159. ref="fcDetailModal"
  160. @refashData="fcDetailOk"
  161. :show="openFcDetailModal"
  162. :bookSn="$route.params.sn"
  163. :bookNo="detailData?detailData.bookNo:''"
  164. @cancel="openFcDetailModal=false"></fcDetailModal>
  165. <!-- 选择审核人员 -->
  166. <chooseDepartUserModal :openModal="openDepartUserModal" @close="openDepartUserModal=false" @submit="handleSubmit"></chooseDepartUserModal>
  167. <!-- 关联单据 -->
  168. <selectGlSalesModal
  169. ref="selGlSalesModal"
  170. modalTit="选择销售单"
  171. :loading="spinning"
  172. :dealerSn="detailData&&detailData.dealerSn"
  173. :chooseData="glList"
  174. :openModal="showGlSalseModal"
  175. @choose="addGlOrder"
  176. @cancel="showGlSalseModal=false"></selectGlSalesModal>
  177. <selectGlAllocatModal
  178. ref="selGlAllocatModal"
  179. modalTit="选择调拨单"
  180. :loading="spinning"
  181. :dealerSn="detailData&&detailData.dealerSn"
  182. :chooseData="glList"
  183. :openModal="showGlAllocaModal"
  184. @choose="addGlOrder"
  185. @cancel="showGlAllocaModal=false"></selectGlAllocatModal>
  186. </div>
  187. </template>
  188. <script>
  189. import { commonMixin } from '@/utils/mixin'
  190. import { VSelect, STable } from '@/components'
  191. import baseModal from './baseModal.vue'
  192. import fcDetailModal from './fcDetailModal.vue'
  193. import selectGlSalesModal from './selectGlSalesModal'
  194. import selectGlAllocatModal from './selectGlAllocatModal'
  195. import chooseDepartUserModal from '../../expenseManagement/expenseReimbursement/chooseDepartUserModal.vue'
  196. import { financeBookFindBySn, financeBookDetailDelete, financeBookDetailQueryList, financeBookSubmit, querySettleReceiptFinanceBookList, deleteSettleReceiptFinanceBook, saveSettleReceiptFinanceBook } from '@/api/financeBook.js'
  197. export default {
  198. name: 'FinancialCollectionEdit',
  199. mixins: [commonMixin],
  200. components: { VSelect, STable, baseModal, fcDetailModal, chooseDepartUserModal, selectGlSalesModal, selectGlAllocatModal },
  201. data () {
  202. return {
  203. spinning: false,
  204. detailData: null,
  205. openBaseModal: false,
  206. openDepartUserModal: false,
  207. openFcDetailModal: false, // 财务明细弹框
  208. total: 0,
  209. loadData: parameter => {
  210. const params = Object.assign(parameter, { bookSn: this.$route.params.sn })
  211. this.disabled = true
  212. this.spinning = true
  213. return financeBookDetailQueryList(params).then(res => {
  214. let data
  215. if (res.status == 200) {
  216. data = res.data
  217. const no = 0
  218. for (var i = 0; i < data.length; i++) {
  219. data[i].no = no + i + 1
  220. // 计算使用授信和授信还款的合计
  221. data[i].useTotalAmount = this.getTotal(data[i].detailItemUseList)
  222. data[i].payTotalAmount = this.getTotal(data[i].detailItemPayList)
  223. }
  224. this.total = data.length
  225. this.disabled = false
  226. this.spinning = false
  227. }
  228. return data
  229. })
  230. },
  231. columns: [
  232. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  233. { title: '收款日期', dataIndex: 'receiptDate', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  234. { title: '付款方类型', dataIndex: 'payerTypeDictValue', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  235. { title: '付款方', dataIndex: 'payerName', align: 'center', width: '7%', customRender: function (text) { return text || '--' } },
  236. { title: '财务编码', dataIndex: 'dealerEntity.kdMidCustomerFnumber', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  237. { title: '付款账户(营业执照)', scopedSlots: { customRender: 'payerAccountInfo' }, align: 'center', width: '7%' },
  238. { title: '订单金额', dataIndex: 'orderAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  239. { title: '收款金额', dataIndex: 'receiptAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  240. { title: '使用授信', dataIndex: 'useTotalAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  241. { title: '授信还款', dataIndex: 'payTotalAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  242. { title: '余款抵扣', dataIndex: 'balanceAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  243. { title: '跨月打款', dataIndex: 'nextMonthAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  244. { title: '户名', dataIndex: 'bankAccount', align: 'center', width: '7%', customRender: function (text) { return text || '--' } },
  245. { title: '汇入银行', dataIndex: 'bankName', align: 'center', width: '7%', customRender: function (text) { return text || '--' } },
  246. { title: '足额打款', dataIndex: 'fullPaymentFlagDictValue', align: 'center', width: '5%', customRender: function (text) { return (text == 0 || text) ? text : '--' } },
  247. { title: '说明', dataIndex: 'explainInfo', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  248. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  249. ],
  250. useCol: [
  251. { title: '使用授信项目', dataIndex: 'itemName', width: '50%', align: 'center' },
  252. { title: '使用授信金额', dataIndex: 'itemAmount', width: '50%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') }
  253. ],
  254. payCol: [
  255. { title: '授信还款项目', dataIndex: 'itemName', width: '50%', align: 'center' },
  256. { title: '授信还款金额', dataIndex: 'itemAmount', width: '50%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') }
  257. ],
  258. // 关联单据
  259. detailGlData: {
  260. total: 0,
  261. totalAmount: 0
  262. },
  263. glList: [],
  264. showGlSalseModal: false,
  265. showGlAllocaModal: false,
  266. glloadData: parameter => {
  267. const params = Object.assign(parameter, { bookSn: this.$route.params.sn })
  268. return querySettleReceiptFinanceBookList(params).then(res => {
  269. console.log(res)
  270. let data
  271. let totalAmount = 0
  272. if (res.status == 200) {
  273. data = res.data
  274. this.glList = data
  275. for (var i = 0; i < data.length; i++) {
  276. data[i].no = i + 1
  277. const cons = data[i].bizType == 'DISPATCH' ? {
  278. createDate:data[i].dispatchBill.createDate,
  279. buyerName: data[i].dispatchBill.buyerName,
  280. receiverName: data[i].dispatchBill.receiverName,
  281. sendNo: data[i].dispatchBill.sendNo,
  282. totalCategory: data[i].dispatchBill.totalCategory,
  283. totalQty: data[i].dispatchBill.totalQty,
  284. totalAmount: data[i].dispatchBill.totalAmount,
  285. billStatusDictValue: data[i].dispatchBill.billStatusDictValue,
  286. financialStatusDictValue: data[i].dispatchBill.financialStatusDictValue,
  287. dispatchBillSn: data[i].dispatchBill.dispatchBillSn,
  288. salesBillSn: data[i].dispatchBill.salesBillSn
  289. } : {
  290. createDate:data[i].allocateBill.createDate,
  291. buyerName: data[i].allocateBill.targetName,
  292. receiverName: data[i].allocateBill.receiverName,
  293. sendNo: data[i].allocateBill.sendNo,
  294. totalCategory: data[i].allocateBill.totalCategory,
  295. totalQty: data[i].allocateBill.totalQty,
  296. totalAmount: data[i].allocateBill.totalPrice,
  297. billStatusDictValue: data[i].allocateBill.stateDictValue,
  298. allocateNo: data[i].allocateBill.allocateNo,
  299. allocateSn: data[i].allocateBill.allocateSn
  300. }
  301. data[i] = Object.assign(data[i], cons)
  302. totalAmount = totalAmount + Number(data[i].totalAmount)
  303. }
  304. this.detailGlData.total = data.length
  305. this.detailGlData.totalAmount = totalAmount
  306. }
  307. return data
  308. })
  309. },
  310. glcolumns: [
  311. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  312. { title: '单据类型', dataIndex: 'bizTypeDictValue', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  313. { title: '单据创建时间', dataIndex: 'createDate', align: 'center', width: '10%', customRender: function (text) { return text || '--' } },
  314. { title: '单据号', dataIndex: 'bizNo', align: 'center', width: '10%', customRender: function (text) { return text || '--' } },
  315. { title: '客户名称', dataIndex: 'buyerName', align: 'center', width: '13%', customRender: function (text) { return text || '--' } },
  316. { title: '收货客户名称', dataIndex: 'receiverName', align: 'center', width: '13%', customRender: function (text) { return text || '--' } },
  317. { title: '发货编号', dataIndex: 'sendNo', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  318. { title: '产品款数', dataIndex: 'totalCategory', align: 'center', width: '6%', customRender: function (text) { return (text == 0 || text) ? text : '--' } },
  319. { title: '产品数量', dataIndex: 'totalQty', align: 'center', width: '6%', customRender: function (text) { return (text == 0 || text) ? text : '--' } },
  320. { title: '总售价', dataIndex: 'totalAmount', align: 'center', width: '6%', customRender: function (text) { return (text == 0 || text) ? text : '--' } },
  321. { title: '业务状态', dataIndex: 'billStatusDictValue', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
  322. { title: '财务状态', dataIndex: 'financialStatusDictValue', align: 'center', width: '6%', customRender: function (text) { return (text == 0 || text) ? text : '--' } },
  323. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  324. ]
  325. }
  326. },
  327. methods: {
  328. // 新增关联单据
  329. addGlOrder (data) {
  330. this.spinning = true
  331. saveSettleReceiptFinanceBook({
  332. bookSn: this.detailData.bookSn,
  333. bookNo: this.detailData.bookNo,
  334. ...data
  335. }).then(res => {
  336. if (res.status == 200) {
  337. this.$refs.gltable.refresh()
  338. } else {
  339. if (data.bizType == 'DISPATCH') {
  340. this.$refs.selGlSalesModal.handleDel(data)
  341. } else {
  342. this.$refs.selGlAllocatModal.handleDel(data)
  343. }
  344. }
  345. this.spinning = false
  346. })
  347. },
  348. // 删除关联单据
  349. handleGlDel (row) {
  350. this.spinning = true
  351. deleteSettleReceiptFinanceBook({ id: row.id }).then(res => {
  352. if (res.status == 200) {
  353. this.$refs.gltable.refresh()
  354. this.$message.info(res.message)
  355. }
  356. this.spinning = false
  357. })
  358. },
  359. // ---------------
  360. getTotal (data) {
  361. let ret = 0
  362. data.map(item => {
  363. ret = ret + item.itemAmount
  364. })
  365. return ret.toFixed(2)
  366. },
  367. // 编辑基础信息
  368. handleEditBase (event) {
  369. this.openBaseModal = true
  370. this.$refs.baseModal.getDetail()
  371. },
  372. refashData () {
  373. this.getDetail(1)
  374. },
  375. // 财务单基础详情
  376. getDetail (type) {
  377. this.spinning = true
  378. this.disabled = true
  379. financeBookFindBySn({ bookSn: this.$route.params.sn }).then(res => {
  380. if (res.status == 200) {
  381. this.detailData = res.data
  382. if (!type) {
  383. // 刷新明细列表
  384. this.$refs.table.refresh()
  385. } else {
  386. this.spinning = false
  387. this.disabled = false
  388. }
  389. }
  390. })
  391. },
  392. // 新增明细成功
  393. fcDetailOk () {
  394. this.openFcDetailModal = false
  395. this.getDetail(false)
  396. },
  397. // 新增、编辑明细
  398. handleEdit (row) {
  399. this.openFcDetailModal = true
  400. if (row && row.bookDetailSn) {
  401. this.$refs.fcDetailModal.getDetail(row.bookDetailSn, this.detailData)
  402. } else {
  403. this.$refs.fcDetailModal.setDetail(this.detailData)
  404. }
  405. },
  406. // 删除明细
  407. handleDel (row) {
  408. const _this = this
  409. this.$confirm({
  410. title: '提示',
  411. content: '确认要删除吗?',
  412. centered: true,
  413. closable: true,
  414. onOk () {
  415. _this.spinning = true
  416. financeBookDetailDelete({ bookDetailSn: row.bookDetailSn }).then(res => {
  417. if (res.status == 200) {
  418. _this.$message.success(res.message)
  419. _this.getDetail(false)
  420. _this.spinning = false
  421. } else {
  422. _this.spinning = false
  423. }
  424. })
  425. }
  426. })
  427. },
  428. beforeSubmit () {
  429. if (this.total) {
  430. this.openDepartUserModal = true
  431. } else {
  432. this.$message.info('请新增财务明细')
  433. }
  434. },
  435. // 提交信息
  436. handleSubmit (data) {
  437. this.spinning = true
  438. financeBookSubmit({ bookSn: this.$route.params.sn, ...data }).then(res => {
  439. if (res.status == '200') {
  440. this.$message.success(res.message)
  441. this.handleBack()
  442. }
  443. this.spinning = false
  444. })
  445. },
  446. // 返回
  447. handleBack (data) {
  448. this.$router.push({ name: 'financialCollectionList' })
  449. },
  450. pageInit () {
  451. if (this.$route.params.sn) { // 编辑页
  452. this.getDetail(false)
  453. }
  454. }
  455. },
  456. mounted () {
  457. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  458. this.pageInit()
  459. }
  460. },
  461. activated () {
  462. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  463. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  464. this.pageInit()
  465. } else {
  466. // 刷新明细列表
  467. this.$refs.table.refresh()
  468. }
  469. },
  470. beforeRouteEnter (to, from, next) {
  471. next(vm => {})
  472. }
  473. }
  474. </script>
  475. <style lang="less">
  476. .financialCollectionAddwrap{
  477. position: relative;
  478. height: 100%;
  479. padding-bottom: 51px;
  480. box-sizing: border-box;
  481. >.ant-spin-nested-loading{
  482. overflow-y: scroll;
  483. height: 100%;
  484. }
  485. .financialCollectionAddcont{
  486. margin-bottom: 10px;
  487. }
  488. .affix{
  489. .ant-affix{
  490. z-index: 101;
  491. }
  492. }
  493. }
  494. </style>