iam-dm-aging-analysis.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div :class="$style.searchdiv">
  3. <a-spin :spinning="loading">
  4. <a-card :class="$style.searchWrap">
  5. <a-form-model
  6. ref="advancedSearchForm"
  7. class="ant-advanced-search-form"
  8. :model="form"
  9. :rules="rules"
  10. v-bind="formItemLayout"
  11. >
  12. <a-row :gutter="24" :class="$style.antformitem">
  13. <a-col :span="11">
  14. <a-form-model-item label="账套名称" prop="booksName">
  15. <a-select
  16. v-model="form.booksName"
  17. :options="booksOptions"
  18. @change="booksNameChange"
  19. >
  20. </a-select>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :span="11">
  24. <a-form-model-item label="查询期间" prop="searchDate">
  25. <a-range-picker
  26. v-model="form.searchDate"
  27. format="YYYY-MM"
  28. :mode="datemode"
  29. :open="dateopen"
  30. @panelChange="handlePanelChange"
  31. @change="handleChange"
  32. @openChange="openChange"
  33. />
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :span="11">
  37. <a-form-model-item label="账龄段" prop="aging">
  38. <a-select v-model="form.aging" :options="agingOptions"> </a-select>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :span="11">
  42. <a-form-model-item label="币种" prop="currency">
  43. <a-select v-model="form.currency" :options="currencyOptions" show-search>
  44. </a-select>
  45. </a-form-model-item>
  46. </a-col>
  47. </a-row>
  48. <a-row>
  49. <a-col :span="16"> </a-col>
  50. <a-col :class="$style.searchbutton" :span="8">
  51. <div class="reportbuttonContent" style="margin-right:15%">
  52. <a-button @click="handleReset">重置</a-button>
  53. <a-button type="primary" html-type="submit" @click="submitForm">查询</a-button>
  54. <a-button type="primary" @click="exportData">导出</a-button>
  55. </div>
  56. </a-col>
  57. </a-row>
  58. </a-form-model>
  59. </a-card>
  60. <a-card :class="$style.reporttablecardxm">
  61. <div :class="$style.title"
  62. ><span :class="['toptitle', $style.toptitle]">账龄分析</span></div
  63. >
  64. <!-- <sd-data-table
  65. :key="tableKey"
  66. ref="dataTable"
  67. data-url="api/xcoa-mobile/v1/agingAnalysisController/agingAnalysisByMultiSubjects"
  68. :columns="columns"
  69. :row-key="(record, index) => index"
  70. :process-req="processReq"
  71. :process-res="processRes"
  72. :defultpagination-pagesize="10"
  73. @dataLoaded="dataLoaded"
  74. @rowClick="rowClick"
  75. >
  76. </sd-data-table> -->
  77. <a-table
  78. ref="dataTable"
  79. :key="tableKey"
  80. :pagination="isSubmit ? pagination : false"
  81. :columns="columns"
  82. :row-key="(record) => record.id"
  83. :data-source="tableData"
  84. :scroll="{ y: 400 }"
  85. @change="handleTableChange"
  86. >
  87. </a-table>
  88. </a-card>
  89. </a-spin>
  90. </div>
  91. </template>
  92. <script>
  93. import axios from '@/common/services/axios-instance'
  94. import { message, Modal } from '@/common/one-ui'
  95. import download from '@/common/services/download'
  96. import iamDmAnalysisServices from './iam-dm-analysis-services'
  97. import components from './_import-components/iam-dm-aging-analysis-import'
  98. export default {
  99. name: 'IamDmAgingAnalysis',
  100. metaInfo: {
  101. title: '账龄分析',
  102. },
  103. components: {
  104. ...components,
  105. },
  106. data() {
  107. return {
  108. pagination: {
  109. pageSize: 10,
  110. total: 100,
  111. },
  112. loading: false, // 列表加载中
  113. tableData: [], // 列表数据
  114. isSubmit: false, // 是否点了查询
  115. showTable: false, // 是否显示查询结果
  116. tableKey: 0,
  117. booksOptions: [], // 账套名称列表
  118. agingOptions: [
  119. { label: '1年', value: '12' },
  120. { label: '半年度', value: '6' },
  121. { label: '季度', value: '3' },
  122. { label: '月度', value: '1' },
  123. ], // 账龄段
  124. currencyOptions: [], // 币种
  125. data: [],
  126. columns: [],
  127. formItemLayout: {
  128. labelCol: { span: 6 },
  129. wrapperCol: { span: 12 },
  130. },
  131. dateFormat: 'YYYY',
  132. form: {
  133. booksName: '',
  134. searchDate: [],
  135. aging: '',
  136. currency: '',
  137. },
  138. rules: {
  139. booksName: [{ required: true, message: '请选择账套名称', trigger: 'change' }],
  140. searchDate: [{ required: true, message: '请选择查询期间', trigger: 'change' }],
  141. aging: [{ required: true, message: '请选择财龄段', trigger: 'change' }],
  142. currency: [{ required: true, message: '请选择币种', trigger: 'change' }],
  143. },
  144. params: {},
  145. datemode: ['month', 'month'],
  146. dateopen: false,
  147. }
  148. },
  149. mounted() {
  150. // 初始化数据字典信息
  151. this.initDictionaryInfo()
  152. },
  153. methods: {
  154. // 分页选择时,重新加载数据
  155. handleTableChange(pagination, filters, sorter) {
  156. this.params.bookdCode = this.form.booksName
  157. this.params.beginDate = this.form.searchDate[0].format('YYYY-MM')
  158. this.params.endDate = this.form.searchDate[1].format('YYYY-MM')
  159. this.params.currencyCode = this.form.currency
  160. this.params.dateSegmentCount = this.form.aging
  161. this.params.startPosition = pagination.current - 1
  162. // 当前页赋值
  163. const pager = { ...this.pagination }
  164. pager.current = pagination.current
  165. this.pagination = pager
  166. this.params.maxResults = 10
  167. this.loadTableData(this.params)
  168. },
  169. openChange(status) {
  170. this.dateopen = status
  171. },
  172. handleChange(value) {
  173. this.form.searchDate = value
  174. },
  175. handlePanelChange(value, mode) {
  176. this.form.searchDate = value
  177. if (mode[1] === 'date') {
  178. this.dateopen = false
  179. }
  180. },
  181. fnonloadsum() {
  182. if (!this.flag) {
  183. if (document.getElementsByClassName('ant-pagination')) {
  184. document.getElementsByClassName('ant-pagination')[0].style.display = 'none'
  185. }
  186. this.flag = true
  187. } else {
  188. if (document.getElementsByClassName('ant-pagination')) {
  189. document.getElementsByClassName('ant-pagination')[0].style.display = ''
  190. }
  191. }
  192. },
  193. initDictionaryInfo() {
  194. // 获取账套名称
  195. iamDmAnalysisServices.findBookName().then((res) => {
  196. this.booksOptions = res.data.map((item) => {
  197. return {
  198. label: item.BOOK_NAME,
  199. value: item.BOOK_CODE,
  200. }
  201. })
  202. })
  203. },
  204. // 账套名称变化时,获取币种列表
  205. booksNameChange(item) {
  206. // 获取币种列表
  207. iamDmAnalysisServices.findCrrencyCode(item).then((res) => {
  208. this.currencyOptions = res.data.map((item) => {
  209. return {
  210. label: item.CURRENCY_NAME,
  211. value: item.CURRENCY_CODE,
  212. }
  213. })
  214. this.form.currency = 'RMB'
  215. })
  216. },
  217. dataLoaded(eventData) {
  218. this.showTable = true
  219. return eventData
  220. },
  221. // 判断账龄段和查询区间的对应关系
  222. checkAgin() {
  223. // 将年转化为月,再加上月,计算差值
  224. let date1 = this.form.searchDate[0].format('YYYY-MM').split('-')
  225. date1 = parseInt(date1[0]) * 12 + parseInt(date1[1])
  226. let date2 = this.form.searchDate[1].format('YYYY-MM').split('-')
  227. date2 = parseInt(date2[0]) * 12 + parseInt(date2[1])
  228. if (date2 - date1 < parseFloat(this.form.aging) - 1) {
  229. return false
  230. } else {
  231. return true
  232. }
  233. },
  234. submitForm() {
  235. this.$refs.advancedSearchForm.validate((valid, values) => {
  236. if (valid) {
  237. // 判断账龄段和查询区间的对应关系
  238. if (!this.checkAgin()) {
  239. const text = this.agingOptions.find((item) => {
  240. return item.value === this.form.aging
  241. }).label
  242. Modal.warning({
  243. title: '提示',
  244. content: `财龄段为${text}时,查询期间间隔必须大于${this.form.aging}个月`,
  245. })
  246. return false
  247. }
  248. this.isSubmit = true
  249. this.params.bookdCode = this.form.booksName
  250. this.params.beginDate = this.form.searchDate[0].format('YYYY-MM')
  251. this.params.endDate = this.form.searchDate[1].format('YYYY-MM')
  252. this.params.currencyCode = this.form.currency
  253. this.params.dateSegmentCount = this.form.aging
  254. this.params.startPosition = 0
  255. this.params.maxResults = 10
  256. // 重置分页到第1页
  257. const pager = { ...this.pagination }
  258. pager.current = 1
  259. this.pagination = pager
  260. this.loadTableData(this.params)
  261. }
  262. })
  263. },
  264. // 加载列表数据
  265. loadTableData(params) {
  266. // 获取列表数据
  267. this.loading = true
  268. iamDmAnalysisServices.getList(params).then((res) => {
  269. this.pagination.total = res.data.count
  270. this.loading = false
  271. this.columns = [
  272. {
  273. title: '序号',
  274. dataIndex: 'sortNum',
  275. width: '80px',
  276. customRender: (text, record, index) => `${index + 1}`,
  277. },
  278. {
  279. title: '科目编码',
  280. dataIndex: 'ACC_CODE',
  281. },
  282. {
  283. title: '科目名称',
  284. dataIndex: 'ACC_NAME',
  285. },
  286. ]
  287. const tableDataList = []
  288. res.data.dataList.forEach((data, dataIndex) => {
  289. const dataJson = {
  290. id: dataIndex,
  291. ACC_CODE: data.ACC_CODE,
  292. ACC_NAME: data.ACC_NAME,
  293. }
  294. data.agingAnalysis.forEach((item, index) => {
  295. if (dataIndex === 0) {
  296. this.columns.push({
  297. title: item.segmentName,
  298. dataIndex: 'agingAmount' + index,
  299. })
  300. }
  301. dataJson['agingAmount' + index] = item.agingAmount
  302. })
  303. tableDataList.push(dataJson)
  304. })
  305. this.tableData = [...tableDataList]
  306. this.tableKey++
  307. })
  308. },
  309. processReq(req) {
  310. req.data = {
  311. ...req.data,
  312. bookdCode: this.params.bookdCode,
  313. beginDate: this.params.beginDate,
  314. endDate: this.params.endDate,
  315. currencyCode: this.params.currencyCode,
  316. dateSegmentCount: this.params.dateSegmentCount,
  317. pageIndex: req.data.startPosition,
  318. pageSize: req.data.maxResults,
  319. }
  320. return req
  321. },
  322. processRes(res) {
  323. res.total = res.count
  324. return res
  325. },
  326. handleReset() {
  327. // this.isSubmit = false
  328. this.$refs.advancedSearchForm.resetFields()
  329. // 特殊处理,清空字段值
  330. // this.handlesearch()
  331. },
  332. // 导出接口
  333. exportData() {
  334. if (this.tableData.length === 0) {
  335. message.warning('未查询出可导出数据', 1)
  336. return
  337. }
  338. this.loading = true
  339. iamDmAnalysisServices
  340. .exportData(this.params)
  341. .then((data) => {
  342. const url = URL.createObjectURL(data.data)
  343. download(url, '财务账龄分析.xls')
  344. this.loading = false
  345. })
  346. .catch(() => {
  347. message.error('导出失败', 3)
  348. })
  349. },
  350. rowClick(record, { rowIndex, column }) {
  351. let type = '1'
  352. if (this.params.dimension === 'domains') {
  353. type = '2'
  354. }
  355. const param = {
  356. dateStart: this.params.dateStart,
  357. dateEnd: this.params.dateEnd,
  358. dimension: this.params.dimension,
  359. unitIds: "'" + record.UNIT_ID + "'",
  360. auditedUnitNames: "'" + record.AUDITED_UNIT_NAME + "'",
  361. }
  362. if (type === '1') {
  363. param.columnValue = this.convertAttrName(this.sjlxcolumns, column.dataIndex)
  364. } else {
  365. param.columnValue = this.convertAttrName(this.sjycolumns, column.dataIndex)
  366. }
  367. // window.open(`#/sd-webflow/done-pages/${record.instId}`)
  368. const url =
  369. '#/audit-annualplancompletion-project-list?params=' +
  370. encodeURIComponent(JSON.stringify(param)) +
  371. '&type=projectlist'
  372. window.open(url)
  373. },
  374. convertAttrName(columns, name) {
  375. let names = name.split('_')
  376. names = names.map((item, index) => {
  377. if (index === 0) {
  378. if (item.toLowerCase() === 'sum') {
  379. return ''
  380. } else {
  381. return item.toLowerCase()
  382. }
  383. } else {
  384. return item.substr(0, 1) + item.substr(1).toLowerCase()
  385. }
  386. })
  387. return names.join('')
  388. },
  389. },
  390. }
  391. </script>
  392. <style module lang="scss">
  393. @use '@/common/design' as *;
  394. .title {
  395. text-align: center;
  396. .toptitle {
  397. color: #404040;
  398. font-weight: bold;
  399. font-size: 22px;
  400. }
  401. }
  402. .search-wrap {
  403. margin-bottom: $padding-lg;
  404. :global(.ant-advanced-search-form) {
  405. padding: 0;
  406. background: transparent;
  407. border: none;
  408. }
  409. :global .ant-divider-horizontal {
  410. margin: 10px 0;
  411. }
  412. }
  413. .searchdiv {
  414. height: 100%;
  415. background-color: #f0f2f5;
  416. :global(.sd-has-table.ant-card) {
  417. min-height: 50%;
  418. }
  419. .reporttablecardxm {
  420. :global(.ant-table-body) {
  421. height: auto !important;
  422. overflow: auto;
  423. min-height: auto !important;
  424. }
  425. }
  426. :global(.ant-table-placeholder) {
  427. height: 500px !important;
  428. :global(.ant-empty-normal) {
  429. margin-top: 130px;
  430. }
  431. }
  432. }
  433. :global(.statistics) {
  434. :global(.ant-table-wrapper) {
  435. margin-top: 40px;
  436. }
  437. }
  438. </style>