4b11b49e94f6a87b25c05b49681dac56576ff4a7.svn-base 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <a-card :bordered="false">
  3. <a-tabs defaultActiveKey="1" @change="callback">
  4. <a-tab-pane tab="柱状图" key="1">
  5. <a-row>
  6. <a-col :span="10">
  7. <a-radio-group :value="barType" @change="statisticst">
  8. <a-radio-button value="year">按年统计</a-radio-button>
  9. <a-radio-button value="month">按月统计</a-radio-button>
  10. <a-radio-button value="category">按类别统计</a-radio-button>
  11. <a-radio-button value="cabinet">按柜号统计</a-radio-button>
  12. </a-radio-group>
  13. </a-col>
  14. <a-col :span="14">
  15. <a-form v-if="barType === 'month' && false" layout="inline" style="margin-top: -4px">
  16. <a-form-item label="月份区间">
  17. <a-range-picker
  18. :placeholder="['开始月份', '结束月份']"
  19. format="YYYY-MM"
  20. :value="barValue"
  21. :mode="barDate"
  22. @panelChange="handleBarDate"/>
  23. </a-form-item>
  24. <a-button style="margin-top: 2px" type="primary" icon="search" @click="queryDatebar">查询</a-button>
  25. <a-button style="margin-top: 2px;margin-left: 8px" type="primary" icon="reload" @click="searchReset">重置</a-button>
  26. </a-form>
  27. </a-col>
  28. <bar class="statistic" title="档案统计" :dataSource="countSource" :height="400"/>
  29. </a-row>
  30. </a-tab-pane>
  31. <a-tab-pane tab="饼状图" key="2">
  32. <a-row :gutter="24">
  33. <a-col :span="10">
  34. <a-radio-group :value="pieType" @change="statisticst">
  35. <a-radio-button value="year">按年统计</a-radio-button>
  36. <a-radio-button value="month">按月统计</a-radio-button>
  37. <a-radio-button value="category">按类别统计</a-radio-button>
  38. <a-radio-button value="cabinet">按柜号统计</a-radio-button>
  39. </a-radio-group>
  40. </a-col>
  41. <a-col :span="14">
  42. <a-form v-if="pieType === 'month' && false" layout="inline" style="margin-top: -4px">
  43. <a-row :gutter="24">
  44. <a-form-item label="月份区间">
  45. <a-range-picker
  46. :placeholder="['开始月份', '结束月份']"
  47. format="YYYY-MM"
  48. :value="pieValue"
  49. :mode="pieDate"
  50. @panelChange="handlePieDate"/>
  51. </a-form-item>
  52. <a-button style="margin-top: 2px" type="primary" icon="search" @click="queryDatepie">查询</a-button>
  53. <a-button style="margin-top: 2px;margin-left: 8px" type="primary" icon="reload" @click="searchReset">重置</a-button>
  54. </a-row>
  55. </a-form>
  56. </a-col>
  57. <pie class="statistic" title="档案统计" :dataSource="countSource" :height="450"/>
  58. </a-row>
  59. </a-tab-pane>
  60. </a-tabs>
  61. </a-card>
  62. </template>
  63. <script>
  64. import Bar from '@/components/chart/Bar'
  65. import Pie from '@/components/chart/Pie'
  66. import ACol from 'ant-design-vue/es/grid/Col'
  67. import { getAction } from '@/api/manage'
  68. export default {
  69. name: 'ArchivesStatisticst',
  70. components: {
  71. ACol,
  72. Bar,
  73. Pie
  74. },
  75. data() {
  76. return {
  77. description: '档案统计页面',
  78. // 查询条件
  79. queryParam: {},
  80. // 数据集
  81. countSource: [],
  82. // 柱状图
  83. barType: 'year',
  84. barDate: ['month', 'month'],
  85. barValue: [],
  86. // 饼状图
  87. pieType: 'year',
  88. pieDate: ['month', 'month'],
  89. pieValue: [],
  90. // 统计图类型
  91. tabStatus:"bar",
  92. url: {
  93. getYearCountInfo: "/mock/api/report/getYearCountInfo",
  94. getMonthCountInfo:"/mock/api/report/getMonthCountInfo",
  95. getCntrNoCountInfo:"/mock/api/report/getCntrNoCountInfo",
  96. getCabinetCountInfo:"/mock/api/report/getCabinetCountInfo",
  97. },
  98. }
  99. },
  100. created() {
  101. let url = this.url.getYearCountInfo;
  102. this.loadDate(url,'year',{});
  103. },
  104. methods: {
  105. loadDate(url,type,param) {
  106. getAction(url,param,'get').then((res) => {
  107. if (res.success) {
  108. this.countSource = [];
  109. if(type === 'year'){
  110. this.getYearCountSource(res.result);
  111. }
  112. if(type === 'month'){
  113. this.getMonthCountSource(res.result);
  114. }
  115. if(type === 'category'){
  116. this.getCategoryCountSource(res.result);
  117. }
  118. if(type === 'cabinet'){
  119. this.getCabinetCountSource(res.result);
  120. }
  121. }else{
  122. var that=this;
  123. that.$message.warning(res.message);
  124. }
  125. })
  126. },
  127. getYearCountSource(data){
  128. for (let i = 0; i < data.length; i++) {
  129. if(this.tabStatus === "bar"){
  130. this.countSource.push({
  131. x: `${data[i].year}年`,
  132. y: data[i].yearcount
  133. })
  134. }else{
  135. this.countSource.push({
  136. item: `${data[i].year}年`,
  137. count:data[i].yearcount
  138. })
  139. }
  140. }
  141. },
  142. getMonthCountSource(data){
  143. for (let i = 0; i < data.length; i++) {
  144. if(this.tabStatus === "bar"){
  145. this.countSource.push({
  146. x: data[i].month,
  147. y: data[i].monthcount
  148. })
  149. }else{
  150. this.countSource.push({
  151. item: data[i].month,
  152. count:data[i].monthcount
  153. })
  154. }
  155. }
  156. },
  157. getCategoryCountSource(data){
  158. for (let i = 0; i < data.length; i++) {
  159. if(this.tabStatus ==="bar"){
  160. this.countSource.push({
  161. x: data[i].classifyname,
  162. y: data[i].cntrnocount
  163. })
  164. }else{
  165. this.countSource.push({
  166. item: data[i].classifyname,
  167. count:data[i].cntrnocount
  168. })
  169. }
  170. }
  171. },
  172. getCabinetCountSource(data){
  173. for (let i = 0; i < data.length; i++) {
  174. if(this.tabStatus === "bar"){
  175. this.countSource.push({
  176. x: data[i].cabinetname,
  177. y: data[i].cabinetcocunt
  178. })
  179. }else{
  180. this.countSource.push({
  181. item: data[i].cabinetname,
  182. count:data[i].cabinetcocunt
  183. })
  184. }
  185. }
  186. },
  187. // 选择统计图类别
  188. callback(key) {
  189. if(key === "1"){
  190. this.tabStatus = "bar";
  191. this.queryDatebar();
  192. }else{
  193. this.tabStatus = "pie";
  194. this.queryDatepie();
  195. }
  196. },
  197. // 选择统计类别
  198. statisticst(e) {
  199. if(this.tabStatus === "pie"){
  200. this.pieType = e.target.value;
  201. this.queryDatepie();
  202. }else{
  203. this.barType = e.target.value;
  204. this.queryDatebar();
  205. }
  206. },
  207. // 按月份查询
  208. queryDatebar(){
  209. if(this.barValue.length>0){
  210. this.getUrl(this.barType,{startTime:this.barValue[0]._d,endTime:this.barValue[1]._d});
  211. }else{
  212. this.getUrl(this.barType,{});
  213. }
  214. },
  215. queryDatepie(){
  216. if(this.pieValue.length>0){
  217. this.getUrl(this.pieType,{startTime:this.pieValue[0]._d,endTime:this.pieValue[1]._d});
  218. }else{
  219. this.getUrl(this.pieType,{});
  220. }
  221. },
  222. searchReset(){
  223. console.log(this.tabStatus);
  224. if(this.tabStatus === "pie"){
  225. this.pieValue = [];
  226. }else{
  227. this.barValue = [];
  228. }
  229. this.getUrl(this.barType,{});
  230. },
  231. // 选择请求url
  232. getUrl(type,param){
  233. let url = "";
  234. if(type === 'year'){
  235. url = this.url.getYearCountInfo;
  236. }
  237. if(type === 'month'){
  238. url = this.url.getMonthCountInfo;
  239. }
  240. if(type === 'category'){
  241. url = this.url.getCntrNoCountInfo;
  242. }
  243. if(type === 'cabinet'){
  244. url = this.url.getCabinetCountInfo;
  245. }
  246. this.loadDate(url,type,param);
  247. },
  248. // 选择月份日期
  249. handleBarDate(value, mode) {
  250. this.barValue = value
  251. this.barDate = [
  252. mode[0] === 'date' ? 'month' : mode[0],
  253. mode[1] === 'date' ? 'month' : mode[1]
  254. ]
  255. },
  256. handlePieDate(value, mode) {
  257. this.pieValue = value
  258. this.pieDate = [
  259. mode[0] === 'date' ? 'month' : mode[0],
  260. mode[1] === 'date' ? 'month' : mode[1]
  261. ]
  262. },
  263. }
  264. }
  265. </script>
  266. <style scoped>
  267. .ant-card-body .table-operator {
  268. margin-bottom: 18px;
  269. }
  270. .ant-table-tbody .ant-table-row td {
  271. padding-top: 15px;
  272. padding-bottom: 15px;
  273. }
  274. .anty-row-operator button {
  275. margin: 0 5px
  276. }
  277. .ant-btn-danger {
  278. background-color: #ffffff
  279. }
  280. .ant-modal-cust-warp {
  281. height: 100%
  282. }
  283. .ant-modal-cust-warp .ant-modal-body {
  284. height: calc(100% - 110px) !important;
  285. overflow-y: auto
  286. }
  287. .ant-modal-cust-warp .ant-modal-content {
  288. height: 90% !important;
  289. overflow-y: hidden
  290. }
  291. .statistic {
  292. padding: 0px !important;
  293. margin-top: 50px;
  294. }
  295. .statistic h4 {
  296. margin-bottom: 20px;
  297. text-align: center !important;
  298. font-size: 24px !important;;
  299. }
  300. .statistic #canvas_1 {
  301. width: 100% !important;
  302. }
  303. </style>