otherList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div style="width:100%">
  3. <Toptitle title="产值表">
  4. <Button type="primary" ghost style="margin-right: 10px" @click='exportData()'>导出</Button>
  5. </Toptitle>
  6. <div style="height:90%;overflow:auto">
  7. <Topsearch :list="list" @searchData="searchVal"> </Topsearch>
  8. <div class="table_content" >
  9. <div v-for="(item, index) in tableData" :key="index" class="table_style" >
  10. <div class="table_title">{{item.title}}</div>
  11. <Table
  12. :data="item.data"
  13. :columns="tableColumns"
  14. border
  15. max-height='614'
  16. show-summary
  17. :summary-method="handleSummary"
  18. >
  19. </Table>
  20. </div>
  21. </div>
  22. </div>
  23. <!-- <div class="pageSlotStyle">
  24. <Page
  25. :page-size-opts="[10, 20, 30, 50, 100, 1000]"
  26. @on-page-size-change="changeSize"
  27. @on-change="changePage"
  28. :current="pageIndex"
  29. show-total
  30. :total="total"
  31. show-sizer
  32. :page-size="pageSize"
  33. />
  34. </div> -->
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. searchState:false,
  42. proxyData:{},
  43. total:0,
  44. pageSize:10,
  45. pageIndex:1,
  46. tableData: [],
  47. tableColumns:[
  48. {title:'日期',align:'center',width:'120',key:'end_time'},
  49. {title:'项目名称',align:'center',width:'100',key:'residential_name',ellipsis:true,tooltip:true},
  50. {title:'图号',align:'center',width:'80',key:'url_number',ellipsis:true,tooltip:true},
  51. {title:'平方',align:'center',width:'100',key:'area',ellipsis:true,tooltip:true},
  52. {title:'人数',align:'center',width:'80',key:'count'},
  53. ],
  54. list: [
  55. {
  56. title: "班组",
  57. name: "Select",
  58. isTooltip:true,
  59. showChooseAll:true,
  60. value: "",
  61. multiple: true,
  62. filterable: true,
  63. placeholder: "请选择",
  64. serverName: "employee",
  65. optionName: "label",
  66. optionValue: "value",
  67. option: [],
  68. },
  69. {
  70. title:'日期',
  71. isDate:true,
  72. name:"Date",
  73. type:'date',
  74. start_value:`${(new Date()).toLocaleDateString().split('/')[0]}-${(new Date()).toLocaleDateString().split('/')[1]}-1`,
  75. end_value:['1','3','5','7','8','10','12'].indexOf((new Date()).toLocaleDateString().split('/')[1])>=0?`${(new Date()).toLocaleDateString().split('/')[0]}-${(new Date()).toLocaleDateString().split('/')[1]}-31`:['4','6','9','11'].indexOf((new Date()).toLocaleDateString().split('/')[1])>=0?`${(new Date()).toLocaleDateString().split('/')[0]}-${(new Date()).toLocaleDateString().split('/')[1]}-30`:`${(new Date()).toLocaleDateString().split('/')[0]}-${(new Date()).toLocaleDateString().split('/')[1]}-${((new Date()).toLocaleDateString().split('/')[0])%4==0?29:28}`,
  76. start_server: "start_time",
  77. end_server:'end_time',
  78. start_placeholder:'年/月',
  79. end_placeholder:'年/月'
  80. },
  81. {
  82. title: "项目名称",
  83. name: "Select",
  84. isTooltip:true,
  85. showChooseAll:true,
  86. value: "",
  87. multiple: true,
  88. filterable: true,
  89. placeholder: "请选择",
  90. serverName: "residential_name",
  91. optionName: "label",
  92. optionValue: "value",
  93. option: [],
  94. },
  95. {
  96. title: "图号",
  97. name: "Select",
  98. isTooltip:true,
  99. showChooseAll:true,
  100. value: "",
  101. multiple: true,
  102. filterable: true,
  103. placeholder: "请选择",
  104. serverName: "url_number",
  105. optionName: "label",
  106. optionValue: "value",
  107. option: [],
  108. },
  109. ],
  110. };
  111. },
  112. // computed:{
  113. // pageSize(){
  114. // return 10;
  115. // },
  116. // pageIndex(){
  117. // return 1;
  118. // }
  119. // },
  120. mounted() {
  121. this.axios.post('/api/team_list').then(res=>{
  122. this.proxyData.employee = res.data.data;
  123. let employee = [];
  124. res.data.data.forEach(v=>{
  125. let obj ={};
  126. obj.label = v;
  127. obj.value=v;
  128. employee.push(obj);
  129. })
  130. this.list[0].option = employee;
  131. let residential_name = [];
  132. res.data.residential_name.forEach(v=>{
  133. let obj = {};
  134. obj.label = v;
  135. obj.value = v;
  136. residential_name.push(obj)
  137. })
  138. this.list[2].option = residential_name;
  139. let url_number = [];
  140. res.data.url_number.forEach(v=>{
  141. let obj = {};
  142. obj.label = v;
  143. obj.value = v;
  144. url_number.push(obj)
  145. })
  146. this.list[3].option = url_number;
  147. })
  148. },
  149. methods: {
  150. handleSummary ({ columns, data }) {
  151. const sums = {};
  152. columns.forEach((column, index) => {
  153. const key = column.key;
  154. if (index === 0) {
  155. sums[key] = {
  156. key,
  157. value: '合计'
  158. };
  159. return;
  160. }
  161. const values = data.map(item => Number(item[key]));
  162. if (key === 'area') {
  163. const v = values.reduce((prev, curr) => {
  164. const value = Number(curr);
  165. if (!isNaN(value)) {
  166. return prev + curr;
  167. } else {
  168. return prev;
  169. }
  170. }, 0);
  171. sums[key] = {
  172. key,
  173. value:v.toFixed(2)
  174. };
  175. } else {
  176. sums[key] = {
  177. key,
  178. value: ''
  179. };
  180. }
  181. });
  182. return sums;
  183. },
  184. searchVal(row){
  185. if(this.searchState){
  186. return
  187. }else{
  188. this.searchState = true;
  189. this.search(row);
  190. }
  191. },
  192. // changeSize(e){
  193. // console.log(1)
  194. // this.pageSize = e;
  195. // this.search(this.proxyData);
  196. // },
  197. // changePage(e){
  198. // this.pageIndex = e;
  199. // this.search(this.proxyData);
  200. // },
  201. // init(row) {
  202. // if(row){
  203. // this.proxyData = JSON.parse(JSON.stringify(row))
  204. // row.start_time=row.start_time?Date.parse(row.start_time).toString().slice(0,10):'';
  205. // row.end_time = row.end_time?Date.parse(row.end_time).toString().slice(0,10):'';
  206. // }
  207. // this.axios.post("/api/outputs_value_list", { ...row,page_size:this.pageSize,page_index:this.pageIndex }).then((res) => {
  208. // res.data.data.forEach(element => {
  209. // if(element.data.length<this.pageSize){
  210. // for(let i=0;i<this.pageSize;i++){
  211. // if(element.data.length<this.pageSize){
  212. // element.data.push({});
  213. // }else{
  214. // break;
  215. // }
  216. // }
  217. // }
  218. // });
  219. // this.tableData = res.data.data;
  220. // this.total=0;
  221. // this.tableData.forEach(v=>{
  222. // if(v.total>this.total){
  223. // this.total = v.total
  224. // }
  225. // })
  226. // });
  227. // },
  228. async exportData(){
  229. const res = await this.axios.post('/api/output_value_export',{...this.proxyData})
  230. if(res.code == 200){
  231. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`
  232. location.href = url
  233. }
  234. },
  235. async search(row){
  236. if(row){
  237. console.log(row)
  238. row.start_time=row.start_time.indexOf('-')>=0?Date.parse(row.start_time).toString().slice(0,10):row.start_time;
  239. row.end_time = row.end_time.indexOf('-')>=0?Date.parse(row.end_time).toString().slice(0,10):row.end_time;
  240. this.proxyData = JSON.parse(JSON.stringify(row))
  241. if(this.proxyData.employee.length==0){
  242. this.proxyData.employee = [];
  243. row.employee =[];
  244. this.list[0].option.forEach(v=>{
  245. this.proxyData.employee.push(v.value);
  246. row.employee.push(v.value);
  247. })}
  248. }
  249. this.tableData = [];
  250. // this.total = 0;
  251. row.employee.forEach(async (v)=>{
  252. await this.axios.post("/api/outputs_value_list",{start_time:row.start_time,end_time:row.end_time,employee:v,url_number:row.url_number,residential_name:row.residential_name}).then(res=>{
  253. // if(res.data.total>this.total){
  254. // this.total = res.data.total;
  255. // }
  256. this.$nextTick(()=>{
  257. if(res.data.data.length<12){
  258. for(let i=0;i<12;i++){
  259. if(res.data.data.length<12){
  260. res.data.data.push({});
  261. }else{
  262. break;
  263. }
  264. }
  265. }
  266. })
  267. this.tableData.push(res.data);
  268. this.searchState = false;
  269. // this.tableData.sort(this.sort);
  270. })
  271. })
  272. // this.tableData.forEach(v=>{
  273. // if(v.length<this.total){
  274. // for(let i=0;i<this.total;i++){
  275. // if(v.length<this.total){
  276. // v.push({});
  277. // }else{
  278. // break;
  279. // }
  280. // }
  281. // }
  282. // })
  283. // this.$forceUpdate();
  284. },
  285. sort(a,b){
  286. return a.index-b.index
  287. },
  288. },
  289. };
  290. </script>
  291. <style lang="scss" scoped>
  292. .table_content{
  293. vertical-align: top;
  294. overflow-y: hidden;
  295. overflow-x: auto;
  296. white-space: nowrap;
  297. height: 710px;
  298. width:100%;
  299. .table_title{
  300. text-align: center;
  301. font-size: 18px;
  302. font-weight: bold;
  303. border-top:#dcdee2 solid 2px;
  304. border-left:#dcdee2 solid 2px;
  305. border-right: #dcdee2 solid 2px;;
  306. }
  307. .table_style{
  308. display: inline-block;
  309. width:492px;
  310. }
  311. }
  312. .pageSlotStyle {
  313. text-align: center;
  314. margin-top: 10px;
  315. }
  316. </style>