law-casestatistics-form.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div :class="$style.searchdiv">
  3. <a-card :class="$style.searchWrap">
  4. <a-form-model
  5. ref="advancedSearchForm"
  6. layout="horizontal"
  7. :model="form"
  8. v-bind="formItemLayout"
  9. :rules="rules"
  10. >
  11. <a-row>
  12. <a-col :span="8">
  13. <a-form-model-item label="统计日期" prop="timeRange">
  14. <a-range-picker 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="Org">
  19. <sd-group-picker v-model="form.Org" :read-only="false" :single="false" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :span="8">
  23. <div class="reportbuttonContent">
  24. <a-button @click="resetForm">重置</a-button>
  25. <a-button
  26. style="margin: 0 5px 10px"
  27. type="primary"
  28. html-type="submit"
  29. @click="submitForm"
  30. >查询</a-button
  31. >
  32. <a-button type="primary" @click="exportForm">导出</a-button>
  33. </div>
  34. </a-col>
  35. </a-row>
  36. </a-form-model>
  37. </a-card>
  38. <a-card class="reporttablecardxm">
  39. <span class="header_sd-header_common"
  40. ><span :class="['toptitle', $style.toptitle]">案件数额统计</span></span
  41. >
  42. <template v-if="JSON.stringify(chartData.xAxis.data) !== '[]'">
  43. <div><sd-echart :class="$style.echarts" :options="chartData" autoresize /></div>
  44. </template>
  45. <template v-else-if="JSON.stringify(chartData.xAxis.data) === '[]' && !flag">
  46. <div :class="$style.emptyecharts"> </div>
  47. </template>
  48. </a-card>
  49. </div>
  50. </template>
  51. <script>
  52. import 'echarts/lib/chart/line'
  53. import 'echarts/lib/chart/bar'
  54. import 'echarts/lib/component/polar'
  55. import 'echarts/lib/component/legend'
  56. import 'echarts/lib/component/tooltip'
  57. import 'echarts/lib/component/title'
  58. import 'echarts/lib/component/toolbox'
  59. import moment from 'moment'
  60. import lawService from '../law-service'
  61. import components from './_import-components/law-casestatistics-form-import'
  62. export default {
  63. name: 'LawCasestatisticsForm',
  64. metaInfo: {
  65. title: '案件数额统计',
  66. },
  67. components: {
  68. ...components,
  69. },
  70. data() {
  71. return {
  72. rules: {
  73. // timeRange: [{ required: true, message: '请选择年度', trigger: 'change' }],
  74. // Org: [{ required: true, message: '请选择审计机构', trigger: 'change' }],
  75. },
  76. formItemLayout: {
  77. labelCol: { span: 6 },
  78. wrapperCol: { span: 14 },
  79. },
  80. startYear: null,
  81. endYear: null,
  82. form: {
  83. timeRange: [],
  84. Org: [],
  85. },
  86. // columns: [],
  87. chartData: {
  88. title: {
  89. left: 'center',
  90. text: null,
  91. },
  92. tooltip: {},
  93. legend: {
  94. show: true,
  95. // orient: 'vertical',
  96. // x: 'right',
  97. // y: 'center',
  98. data: [{ name: '案件数量' }, { name: '案件金额' }],
  99. align: 'left',
  100. textStyle: {
  101. color: '#939393',
  102. lineHeight: 18,
  103. },
  104. itemWidth: 10,
  105. },
  106. grid: {},
  107. xAxis: {
  108. type: 'category',
  109. data: [],
  110. },
  111. yAxis: [
  112. {
  113. type: 'value',
  114. name: '案件数量',
  115. show: true,
  116. interVal: 1,
  117. },
  118. {
  119. type: 'value',
  120. name: '案件金额',
  121. min: 0,
  122. interVal: 1000,
  123. show: true,
  124. },
  125. ],
  126. series: [],
  127. toolbox: {
  128. feature: {
  129. // magicType: { show: true, type: ['line', 'bar'] },
  130. restore: { title: '刷新', show: true },
  131. saveAsImage: { show: true, name: '案件数额统计图' },
  132. },
  133. },
  134. },
  135. params: {
  136. startYear: '',
  137. endYear: '',
  138. Org: [],
  139. }, // 查询条件
  140. flag: true,
  141. }
  142. },
  143. created() {},
  144. methods: {
  145. submitForm() {
  146. this.flag = false
  147. // this.$refs.advancedSearchForm.validate((valid, values) => {
  148. // if (valid) {
  149. let unitIds = ''
  150. if (this.form.Org) {
  151. this.form.Org.forEach((o) => {
  152. unitIds = unitIds + o.code + ','
  153. })
  154. }
  155. if (unitIds !== '') unitIds = unitIds.substring(0, unitIds.length - 1)
  156. const params = {}
  157. if (this.form.timeRange) {
  158. if (this.form.timeRange.length > 2) {
  159. params.startDate = moment(this.form.timeRange[0]).format('YYYY-MM-DD')
  160. params.endDate = moment(this.form.timeRange[1]).format('YYYY-MM-DD')
  161. } else {
  162. if (this.form.timeRange[0])
  163. params.startDate = moment(this.form.timeRange[0]).format('YYYY-MM-DD')
  164. if (this.form.timeRange[1])
  165. params.endDate = moment(this.form.timeRange[1]).format('YYYY-MM-DD')
  166. }
  167. }
  168. if (unitIds !== '') params.unitIds = unitIds
  169. const chartDatasd = []
  170. const chartDatasj = []
  171. this.chartData.xAxis.data = []
  172. lawService.getCaseStatistics(params).then((res) => {
  173. res.data.forEach((d) => {
  174. this.chartData.xAxis.data.push(d.caseTypeName)
  175. chartDatasd.push(d.count)
  176. chartDatasj.push(d.caseAmount)
  177. })
  178. this.chartData.series = [
  179. {
  180. name: '案件数量',
  181. data: chartDatasd,
  182. type: 'bar',
  183. barWidth: '40px',
  184. itemStyle: {
  185. color: '#64ede6',
  186. },
  187. },
  188. {
  189. name: '案件金额',
  190. data: chartDatasj,
  191. yAxisIndex: 1,
  192. type: 'line',
  193. lineStyle: {
  194. color: '#3366ff', // 颜色生效
  195. },
  196. },
  197. ]
  198. // this.chartData.legend.data = [{},{}]
  199. })
  200. // }
  201. // })
  202. },
  203. resetForm() {
  204. this.startYear = null
  205. this.endYear = null
  206. this.form = {
  207. timeRange: [],
  208. Org: [],
  209. }
  210. },
  211. exportForm() {
  212. // 获取画布信息
  213. const canvas = document.getElementsByTagName('canvas')
  214. if (canvas && canvas.length > 0) {
  215. // 创建标签
  216. const tempA = document.createElement('a')
  217. // 设置下载名称
  218. tempA.download = '案件数额统计图' + '.png'
  219. // 设置地址以及文件类型
  220. tempA.href = canvas[0].toDataURL('image/png')
  221. document.body.appendChild(tempA)
  222. // 触发下载事件
  223. tempA.click()
  224. // 移除标签
  225. tempA.remove()
  226. }
  227. },
  228. chartClick(evtArgs) {
  229. const seriesId = JSON.parse(evtArgs.seriesId)
  230. const param = {
  231. planYear: evtArgs.name,
  232. unitNames: "'" + seriesId.NAME + "'",
  233. auditType: seriesId.TYPE,
  234. amount: '1',
  235. }
  236. const url =
  237. '#/audit-annualplancompletion-project-list?params=' +
  238. encodeURIComponent(JSON.stringify(param)) +
  239. '&type=projecttrends'
  240. window.open(url)
  241. },
  242. },
  243. }
  244. </script>
  245. <style module lang="scss">
  246. @use '@/common/design' as *;
  247. .emptyecharts {
  248. width: 600px;
  249. height: 400px;
  250. margin: auto auto;
  251. text-align: center;
  252. &::after {
  253. content: '无数据';
  254. padding-top: 150px;
  255. display: block;
  256. }
  257. }
  258. .echarts {
  259. width: 100%;
  260. height: 400px;
  261. margin: auto auto;
  262. text-align: center;
  263. }
  264. .toptitle {
  265. color: #404040;
  266. font-weight: bold;
  267. font-size: 22px;
  268. margin-left: calc(50% - 150px);
  269. }
  270. .search-wrap {
  271. margin-bottom: $padding-lg;
  272. :global(.ant-advanced-search-form) {
  273. padding: 0;
  274. background: transparent;
  275. border: none;
  276. }
  277. :global .ant-divider-horizontal {
  278. margin: 10px 0;
  279. }
  280. }
  281. .searchdiv {
  282. height: 100%;
  283. :global(.sd-has-table.ant-card) {
  284. min-height: calc(100vh - 270px);
  285. }
  286. :global(.reporttablecardxm) {
  287. :global(.ant-table-body) {
  288. height: auto !important;
  289. overflow: auto;
  290. min-height: auto !important;
  291. }
  292. }
  293. :global(.ant-table-placeholder) {
  294. height: auto !important;
  295. }
  296. }
  297. </style>