audit-statistics-project.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <div :class="$style.searchdiv">
  3. <a-card :class="$style.searchWrap">
  4. <a-form-model
  5. ref="advancedSearchForm"
  6. class="ant-advanced-search-form"
  7. :model="form"
  8. :rules="rules"
  9. v-bind="formItemLayout"
  10. >
  11. <a-row :gutter="24" :class="$style.antformitem">
  12. <a-col :span="8">
  13. <a-form-model-item label="年度" prop="timeRange">
  14. <AuditRangePicker v-model="form.timeRange" :time-range.sync="form.timeRange" />
  15. </a-form-model-item>
  16. </a-col>
  17. <a-col :span="8">
  18. <a-form-model-item label="审计机构" prop="unitNames">
  19. <AuditGroupPicker
  20. ref="unitNames"
  21. v-model="form.unitNames"
  22. :single="false"
  23. :read-only="false"
  24. :root-node="rootNode"
  25. />
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :span="8">
  29. <a-form-model-item label="统计维度" prop="statisticsRange">
  30. <a-radio-group v-model="form.statisticsRange" :class="$style.typeRadio">
  31. <a-radio v-for="mp in statisticsOptions" :key="mp.id" :value="mp.id">
  32. {{ mp.text }}
  33. </a-radio>
  34. </a-radio-group>
  35. </a-form-model-item>
  36. </a-col>
  37. </a-row>
  38. <a-row>
  39. <a-col :span="16"> </a-col>
  40. <a-col :class="$style.searchbutton" :span="8">
  41. <div class="reportbuttonContent" style="margin-right: 15%">
  42. <a-button @click="handleReset">重置</a-button>
  43. <a-button type="primary" html-type="submit" @click="submitForm">查询</a-button>
  44. <a-button :loading="exportLoading" type="primary" @click="exportData">导出</a-button>
  45. </div>
  46. </a-col>
  47. </a-row>
  48. </a-form-model>
  49. </a-card>
  50. <a-card class="reporttablecardxm">
  51. <span class="header_sd-header_common"
  52. ><span :class="['toptitle', $style.toptitle]">审计项目统计</span></span
  53. >
  54. <sd-data-table
  55. v-if="flagcs === 1 || flagcs === 2"
  56. :key="tableKey"
  57. ref="dataTable"
  58. :projectlist="true"
  59. data-url="api/xcoa-mobile/v1/iam-statistics/getAuditProjectList"
  60. :columns="columns"
  61. :row-key="(record, index) => index"
  62. :process-req="processReq"
  63. :defultpagination-pagesize="50"
  64. @dataLoaded="dataLoaded"
  65. @fnonloadsum="fnonloadsum"
  66. @rowClick="rowClick"
  67. >
  68. <template slot="SUM" slot-scope="text, record">
  69. {{ text ? text : '0' }}
  70. <!-- <span v-if="text === '0' || text === 0">{{ text }}</span>
  71. <a v-else @click="rowClick(record, text, aa)">{{ text }}</a> -->
  72. </template>
  73. </sd-data-table>
  74. </a-card>
  75. </div>
  76. </template>
  77. <script>
  78. import moment from 'moment'
  79. import AuditRangePicker from '../../components/picker/audit-range-picker.vue'
  80. import AuditGroupPicker from '../../components/picker/audit-group-picker.vue'
  81. import StatisticsService from './statistics-service'
  82. import components from './_import-components/audit-statistics-project-import'
  83. import axios from '@/common/services/axios-instance'
  84. import { getUserInfo } from '@/common/store-mixin'
  85. import { message } from '@/common/one-ui'
  86. import TableColumnTypes from '@/common/services/table-column-types'
  87. import download from '@/common/services/download'
  88. export default {
  89. name: 'AuditStatisticsProject',
  90. metaInfo: {
  91. title: '项目统计',
  92. },
  93. components: {
  94. ...components,
  95. AuditRangePicker,
  96. AuditGroupPicker,
  97. },
  98. data() {
  99. return {
  100. exportLoading: false,
  101. data: [],
  102. columns: [
  103. {
  104. title: '序号',
  105. dataIndex: 'sortNum',
  106. width: '80px',
  107. sdHidden: false,
  108. },
  109. {
  110. title: '审计机构',
  111. dataIndex: 'UNIT_NAME',
  112. width: '150px',
  113. },
  114. {
  115. title: '被审计单位',
  116. dataIndex: 'AUDITED_UNIT_NAME',
  117. width: '150px',
  118. },
  119. ],
  120. formItemLayout: {
  121. labelCol: { span: 6 },
  122. wrapperCol: { span: 14 },
  123. },
  124. dateFormat: 'YYYY',
  125. form: {
  126. statisticsRange: '1',
  127. unitNames: [],
  128. timeRange: [],
  129. },
  130. rules: {
  131. timeRange: [{ required: true, message: '请选择统计时间', trigger: 'change' }],
  132. unitNames: [{ required: true, message: '请选择审计机构', trigger: 'change' }],
  133. statisticsRange: [{ required: true, message: '请选择统计维度', trigger: 'change' }],
  134. },
  135. statisticsOptions: [
  136. { text: '按审计类型', id: '1' },
  137. { text: '按审计域', id: '2' },
  138. ],
  139. params: {},
  140. radioStyle: {
  141. display: 'block',
  142. height: '30px',
  143. lineHeight: '30px',
  144. width: '100%',
  145. },
  146. sjlxcolumns: [
  147. {
  148. title: '序号',
  149. dataIndex: 'sortNum',
  150. width: '80px',
  151. sdHidden: false,
  152. },
  153. {
  154. title: '审计机构',
  155. dataIndex: 'UNIT_NAME',
  156. width: '150px',
  157. },
  158. {
  159. title: '被审计单位',
  160. dataIndex: 'AUDITED_UNIT_NAME',
  161. width: '150px',
  162. },
  163. ],
  164. sjlxoptions: [],
  165. sjycolumns: [
  166. {
  167. title: '序号',
  168. dataIndex: 'sortNum',
  169. width: '80px',
  170. sdHidden: false,
  171. },
  172. {
  173. title: '审计机构',
  174. dataIndex: 'UNIT_NAME',
  175. width: '150px',
  176. },
  177. {
  178. title: '被审计单位',
  179. dataIndex: 'AUDITED_UNIT_NAME',
  180. width: '150px',
  181. },
  182. ],
  183. sjyoptions: [],
  184. flagcs: 0,
  185. flag: false,
  186. type: '',
  187. tableKey: 0,
  188. rootNode: {},
  189. }
  190. },
  191. created() {
  192. let userInfo = getUserInfo()
  193. const params = {
  194. orgId: userInfo.deptId,
  195. }
  196. axios({
  197. url: 'api/xcoa-mobile/v1/iamorg/getCurrentUserGroup',
  198. method: 'get',
  199. }).then((res) => {
  200. userInfo = res.data
  201. params.orgId = res.data.id
  202. axios({
  203. url: 'api/xcoa-mobile/v1/iamorg/findIamOrgId',
  204. method: 'post',
  205. params,
  206. }).then((res) => {
  207. this.id = res.data
  208. const deptCode = userInfo.id.toString()
  209. const deptName = userInfo.name
  210. this.rootNode = { code: deptCode, name: deptName, id: this.id }
  211. })
  212. })
  213. },
  214. mounted() {
  215. // 初始化数据字典信息
  216. this.initDictionaryInfo()
  217. },
  218. methods: {
  219. fnonloadsum() {
  220. if (!this.flag) {
  221. if (document.getElementsByClassName('ant-pagination').length > 0) {
  222. document.getElementsByClassName('ant-pagination')[0].style.display = 'none'
  223. }
  224. this.flag = true
  225. } else {
  226. if (document.getElementsByClassName('ant-pagination').length > 0) {
  227. document.getElementsByClassName('ant-pagination')[0].style.display = ''
  228. }
  229. }
  230. },
  231. initDictionaryInfo() {
  232. // 涉及审计域
  233. axios({
  234. url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=AUDIT_DOMAIN',
  235. method: 'get',
  236. }).then((res) => {
  237. if (res.status === 200) {
  238. this.sjyoptions = res.data
  239. res.data.forEach((item) => {
  240. const obj = {
  241. title: item.name,
  242. dataIndex: 'SUM_' + item.id,
  243. width: '150px',
  244. scopedSlots: { customRender: 'SUM' },
  245. sdClickable: true,
  246. }
  247. this.sjycolumns.push(obj)
  248. })
  249. this.sjycolumns.push({
  250. title: '项目总数',
  251. dataIndex: 'TOTAL',
  252. width: '100px',
  253. scopedSlots: { customRender: 'SUM' },
  254. sdClickable: true,
  255. })
  256. }
  257. })
  258. // 审计类型
  259. axios({
  260. url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=PRODUCT_IAM_AUDIT_TYPE',
  261. method: 'get',
  262. }).then((res) => {
  263. if (res.status === 200) {
  264. this.sjlxoptions = res.data
  265. res.data.forEach((item) => {
  266. const obj = {
  267. title: item.name,
  268. dataIndex: 'SUM_' + item.id,
  269. width: '150px',
  270. scopedSlots: { customRender: 'SUM' },
  271. sdClickable: true,
  272. }
  273. this.sjlxcolumns.push(obj)
  274. })
  275. this.sjlxcolumns.push({
  276. title: '项目总数',
  277. dataIndex: 'TOTAL',
  278. width: '100px',
  279. scopedSlots: { customRender: 'SUM' },
  280. sdClickable: true,
  281. })
  282. this.flagcs = 1
  283. this.submitForm()
  284. }
  285. })
  286. },
  287. dataLoaded(eventData) {
  288. if (this.flagcs === 2) {
  289. eventData.data.forEach((item, index) => {
  290. item.sortNum = index + 1
  291. item.id = index
  292. })
  293. } else if (this.flagcs === 1) {
  294. eventData.data.splice(0, eventData.total)
  295. eventData.data.splice(eventData.total)
  296. this.flagcs = 2
  297. } else {
  298. eventData.data = []
  299. }
  300. return eventData
  301. },
  302. submitForm() {
  303. if (this.flagcs === 1) {
  304. this.params.dimension = 'type'
  305. this.columns = this.sjlxcolumns
  306. this.tableKey++
  307. } else {
  308. this.$refs.advancedSearchForm.validate((valid, values) => {
  309. if (valid) {
  310. const startYear = moment(this.form.timeRange[0]).format('YYYY')
  311. const endYear = moment(this.form.timeRange[1]).format('YYYY')
  312. const type = this.form.statisticsRange
  313. this.type = type
  314. this.params.dateStart = startYear
  315. this.params.dateEnd = endYear
  316. if (type === '1') {
  317. this.params.dimension = 'type'
  318. this.columns = this.sjlxcolumns
  319. } else if (type === '2') {
  320. this.params.dimension = 'domains'
  321. this.columns = this.sjycolumns
  322. }
  323. this.params.unitNames = this.form.unitNames.map((n) => "'" + n.id + "'").join(',')
  324. this.params.unitIds = this.form.unitNames.map((n) => "'" + n.id + "'").join(',')
  325. this.tableKey++
  326. }
  327. })
  328. }
  329. },
  330. processReq(req) {
  331. req.data = {
  332. ...req.data,
  333. dateStart: this.params.dateStart,
  334. dateEnd: this.params.dateEnd,
  335. dimension: this.params.dimension,
  336. unitIds: this.params.unitNames,
  337. pageIndex: req.data.startPosition,
  338. pageSize: req.data.maxResults,
  339. }
  340. return req
  341. },
  342. handleReset() {
  343. this.$refs.advancedSearchForm.resetFields()
  344. // 特殊处理,清空字段值
  345. // this.handlesearch()
  346. },
  347. // 导出接口
  348. exportData() {
  349. if (this.$refs.dataTable.data.length === 0) {
  350. message.warning('未查询出可导出数据', 1)
  351. return
  352. }
  353. this.exportLoading = true
  354. StatisticsService.exportData(this.params)
  355. .then((data) => {
  356. const url = URL.createObjectURL(data)
  357. download(url, '审计项目统计.xls')
  358. this.exportLoading = false
  359. })
  360. .catch(() => {
  361. message.error('导出失败', 3)
  362. this.exportLoading = false
  363. })
  364. },
  365. rowClick(record, { rowIndex, column }) {
  366. let type = '1'
  367. if (this.params.dimension === 'domains') {
  368. type = '2'
  369. }
  370. const param = {
  371. dateStart: this.params.dateStart,
  372. dateEnd: this.params.dateEnd,
  373. dimension: this.params.dimension,
  374. unitIds: "'" + record.UNIT_ID + "'",
  375. auditedUnitNames: "'" + record.AUDITED_UNIT_NAME + "'",
  376. }
  377. if (type === '1') {
  378. param.columnValue = this.convertAttrName(this.sjlxcolumns, column.dataIndex)
  379. } else {
  380. param.columnValue = this.convertAttrName(this.sjycolumns, column.dataIndex)
  381. }
  382. // window.open(`#/sd-webflow/done-pages/${record.instId}`)
  383. const url =
  384. '#/audit-annualplancompletion-project-list?params=' +
  385. encodeURIComponent(JSON.stringify(param)) +
  386. '&type=projectlist'
  387. window.open(url)
  388. },
  389. convertAttrName(columns, name) {
  390. let names = name.split('_')
  391. names = names.map((item, index) => {
  392. if (index === 0) {
  393. if (item.toLowerCase() === 'sum') {
  394. return ''
  395. } else {
  396. return item.toLowerCase()
  397. }
  398. } else {
  399. return item.substr(0, 1) + item.substr(1).toLowerCase()
  400. }
  401. })
  402. return names.join('')
  403. },
  404. },
  405. }
  406. </script>
  407. <style module lang="scss">
  408. @use '@/common/design' as *;
  409. .toptitle {
  410. margin-left: calc(50% - 150px);
  411. font-size: 22px;
  412. font-weight: bold;
  413. color: #404040;
  414. }
  415. .search-wrap {
  416. margin-bottom: $padding-lg;
  417. :global(.ant-advanced-search-form) {
  418. padding: 0;
  419. background: transparent;
  420. border: none;
  421. }
  422. :global .ant-divider-horizontal {
  423. margin: 10px 0;
  424. }
  425. }
  426. .searchdiv {
  427. height: 100%;
  428. background-color: #f0f2f5;
  429. :global(.sd-has-table.ant-card) {
  430. min-height: 50%;
  431. }
  432. :global(.reporttablecardxm) {
  433. :global(.ant-table-body) {
  434. height: auto !important;
  435. min-height: auto !important;
  436. overflow: auto;
  437. }
  438. }
  439. :global(.ant-table-placeholder) {
  440. height: auto !important;
  441. }
  442. }
  443. :global(.statistics) {
  444. :global(.ant-table-wrapper) {
  445. margin-top: 40px;
  446. }
  447. }
  448. </style>