law-incident-unit-statistics-form.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. >
  10. <a-row>
  11. <a-col :span="12">
  12. <a-form-model-item label="统计日期">
  13. <a-range-picker v-model="form.timeRange" :time-range.sync="form.timeRange" />
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="12">
  17. <a-form-model-item label="统计单位">
  18. <sd-group-picker v-model="form.Org" :read-only="false" :single="true" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="12">
  22. <a-form-model-item label="案件类型">
  23. <a-checkbox-group v-model="form.caseType" :options="caseTypeOptions" />
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="8">
  27. <div class="reportbuttonContent">
  28. <a-button @click="resetForm">重置</a-button>
  29. <a-button
  30. style="margin: 0 5px 10px;"
  31. type="primary"
  32. :loading="isLoading"
  33. @click="submitForm"
  34. >查询</a-button
  35. >
  36. <a-button type="primary" :loading="isLoading" @click="exportForm">导出</a-button>
  37. </div>
  38. </a-col>
  39. </a-row>
  40. </a-form-model>
  41. </a-card>
  42. <a-card class="reporttablecardxm">
  43. <span class="header_sd-header_common"
  44. ><span :class="['toptitle', $style.toptitle]">案发单位统计</span></span
  45. >
  46. <div>
  47. <sd-data-table
  48. ref="exportTable"
  49. :key="tableKey"
  50. data-url="api/xcoa-mobile/v1/law-statistics/case-dept"
  51. :process-req="processReq"
  52. :process-res="processRes"
  53. row-key="index"
  54. :columns="columns"
  55. ></sd-data-table>
  56. </div>
  57. </a-card>
  58. </div>
  59. </template>
  60. <script>
  61. import { message } from '@/common/one-ui'
  62. import download from '@/common/services/download'
  63. import axios from '@/common/services/axios-instance'
  64. import moment from 'moment'
  65. import LawService from '../law-service'
  66. import components from './_import-components/law-incident-unit-statistics-form-import'
  67. export default {
  68. name: 'LawIncidentUnitStatisticsForm',
  69. metaInfo: {
  70. title: '案发单位统计',
  71. },
  72. components: {
  73. ...components,
  74. },
  75. data() {
  76. return {
  77. isFirst: true,
  78. isLoading: false,
  79. tableKey: 0,
  80. formItemLayout: {
  81. labelCol: { span: 6 },
  82. wrapperCol: { span: 14 },
  83. },
  84. form: {
  85. timeRange: [],
  86. Org: [],
  87. caseType: [],
  88. },
  89. caseTypeOptions: [],
  90. columns: [
  91. {
  92. title: '单位名称',
  93. dataIndex: 'deptName',
  94. },
  95. {
  96. title: '累计案件数量',
  97. dataIndex: 'count',
  98. },
  99. {
  100. title: '累计案件金额(元)',
  101. dataIndex: 'caseAmount',
  102. },
  103. {
  104. title: '累计结案数量',
  105. dataIndex: 'finishNum',
  106. },
  107. {
  108. title: '累计结案金额(元)',
  109. dataIndex: 'finishAmount',
  110. },
  111. {
  112. title: '累计减损金额(元)',
  113. dataIndex: 'loseAmount',
  114. },
  115. ],
  116. }
  117. },
  118. created() {
  119. // 获取案件类型
  120. // const params = {
  121. // buttonExpressions: [],
  122. // columns: 'id,name,code,sortNum,status,valueDesc',
  123. // expressions: [
  124. // {
  125. // dataType: 'str',
  126. // name: 'keyId',
  127. // op: 'eq',
  128. // stringValue: '272818597314232320',
  129. // },
  130. // ],
  131. // formId: 'weAppDictValue',
  132. // maxResults: 10,
  133. // startPosition: 0,
  134. // }
  135. LawService.getdict('272818597314232320').then((res) => {
  136. const dict = [
  137. {
  138. label: '全部',
  139. value: 'all',
  140. onChange: this.typeChange,
  141. },
  142. ]
  143. res.data.forEach((d) => {
  144. dict.push({
  145. label: d.label,
  146. value: d.value,
  147. disabled: false,
  148. })
  149. })
  150. this.caseTypeOptions = [...dict]
  151. })
  152. // 设置统计日期默认值
  153. this.form.timeRange = [moment().startOf('year'), moment().endOf('day')]
  154. },
  155. methods: {
  156. // 复选框变化时
  157. typeChange(e) {
  158. this.caseTypeOptions.forEach((item) => {
  159. if (item.value !== 'all') {
  160. item.disabled = e.target.checked
  161. }
  162. })
  163. if (e.target.checked) {
  164. this.caseTypeOptions.forEach((item) => {
  165. if (item.value !== 'all' && !this.form.caseType.includes(item.value)) {
  166. this.form.caseType.push(item.value)
  167. }
  168. })
  169. } else {
  170. this.$nextTick().then(() => {
  171. this.form.caseType = []
  172. })
  173. }
  174. },
  175. submitForm() {
  176. this.isLoading = true
  177. this.isFirst = false
  178. this.tableKey++
  179. },
  180. processReq(req) {
  181. req.data = {
  182. startDate: this.form.timeRange[0] ? moment(this.form.timeRange[0]).valueOf() : undefined,
  183. endDate: this.form.timeRange[1] ? moment(this.form.timeRange[1]).valueOf() : undefined,
  184. unitIds: this.form.Org[0]?.code,
  185. caseTypes: this.form.caseType.length > 0 ? this.form.caseType.join(',') : undefined,
  186. }
  187. return req
  188. },
  189. processRes(res) {
  190. res.forEach((item, index) => (item.index = index + 1))
  191. this.isLoading = false
  192. if (this.isFirst) {
  193. res.data = []
  194. res.totalSize = 0
  195. return res
  196. }
  197. res.data = [...res]
  198. res.totalSize = res.data.length
  199. return res
  200. },
  201. resetForm() {
  202. this.tableKey++
  203. this.isFirst = true
  204. this.form = {
  205. timeRange: [],
  206. Org: [],
  207. caseType: [],
  208. }
  209. },
  210. exportForm() {
  211. if (this.$refs.exportTable.data.length === 0) {
  212. return message.warning('未查询到可导出数据', 1)
  213. }
  214. // 获取画布信息
  215. axios({
  216. method: 'post',
  217. url: 'api/xcoa-mobile/v1/law-statistics/export-case-dept',
  218. data: {
  219. startDate: this.form.timeRange[0] ? moment(this.form.timeRange[0]).valueOf() : undefined,
  220. endDate: this.form.timeRange[1] ? moment(this.form.timeRange[1]).valueOf() : undefined,
  221. unitIds: this.form.Org[0]?.code,
  222. caseTypes: this.form.caseType.length > 0 ? this.form.caseType.join(',') : undefined,
  223. },
  224. responseType: 'blob',
  225. }).then((res) => {
  226. const url = URL.createObjectURL(res.data)
  227. download(url, '案发单位统计' + moment(new Date()).format('YYYY-MM-DD HH:mm:ss') + '.xls')
  228. })
  229. },
  230. },
  231. }
  232. </script>
  233. <style module lang="scss">
  234. @use '@/common/design' as *;
  235. .emptyecharts {
  236. width: 600px;
  237. height: 400px;
  238. margin: auto auto;
  239. text-align: center;
  240. &::after {
  241. content: '无数据';
  242. padding-top: 150px;
  243. display: block;
  244. }
  245. }
  246. .echarts {
  247. width: 100%;
  248. height: 400px;
  249. margin: auto auto;
  250. text-align: center;
  251. }
  252. .toptitle {
  253. color: #404040;
  254. font-weight: bold;
  255. font-size: 22px;
  256. margin-left: calc(50% - 150px);
  257. }
  258. .search-wrap {
  259. margin-bottom: $padding-lg;
  260. :global(.ant-advanced-search-form) {
  261. padding: 0;
  262. background: transparent;
  263. border: none;
  264. }
  265. :global .ant-divider-horizontal {
  266. margin: 10px 0;
  267. }
  268. }
  269. .searchdiv {
  270. height: 100%;
  271. :global(.sd-has-table.ant-card) {
  272. min-height: calc(100vh - 270px);
  273. }
  274. :global(.reporttablecardxm) {
  275. :global(.ant-table-body) {
  276. height: auto !important;
  277. overflow: auto;
  278. min-height: auto !important;
  279. }
  280. }
  281. :global(.ant-table-placeholder) {
  282. height: auto !important;
  283. }
  284. }
  285. </style>