confirm.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div>
  3. <Toptitle title="包装日期详情">
  4. <Button type="primary" style="margin-right:10px">导出</Button>
  5. <Button @click="$router.go(-1)" type="primary">返回</Button>
  6. </Toptitle>
  7. <Form :label-width='100' class="form_content">
  8. <FormItem label='时间:' style="width:350px">
  9. <span class="form_item">{{func.replaceDateNoHMS($route.query.start_time).replace(/-/g,'.')}}</span>~
  10. <span class="form_item">{{func.replaceDateNoHMS($route.query.end_time*1-86400).replace(/-/g,'.')}}</span>
  11. </FormItem>
  12. <FormItem label='包装班组:' style="width:350px">
  13. <Select v-model="searchData.employee" filterable clearable class="form_item">
  14. <Option v-for="item in employeeList" :key="item.id" :value="item.id" :label="item.nickname"/>
  15. </Select>
  16. </FormItem>
  17. <FormItem label='项目名称:' style="width:350px">
  18. <Select v-model="searchData.project_title" filterable multiple :max-tag-count='1' class="form_item">
  19. <Option v-for="(item,index) in projectList" :key="index" :value="item" :label="item"/>
  20. </Select>
  21. </FormItem>
  22. <FormItem :label-width='40'>
  23. <Button style="primary" type="primary" @click="search">搜索</Button>
  24. </FormItem>
  25. </Form>
  26. <Table :data='tableData' :columns='setTableColumns' border max-height='550' :span-method="handleSpan">
  27. </Table>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. data(){
  33. return{
  34. proxyData:{},
  35. employeeList:[],
  36. projectList:[],
  37. tableSlice:[],
  38. tableData:[
  39. // {time:'123',A:"600",B:'700',C:'800',D:'900',E:'1000',F:'1100',G:"1200",H:'1300',I:"1400",j:'2000',total_price:'5000'}
  40. ],
  41. tableColumns:[
  42. {title:'时间',key:'time',align:'center',minWidth:100}
  43. ],
  44. otherColumns:[],
  45. searchData:{
  46. project_title:'',
  47. employee:''
  48. }
  49. }
  50. },
  51. computed:{
  52. setTableColumns(){
  53. let arr;
  54. arr = [
  55. ...this.tableColumns,...this.otherColumns,
  56. {title:'合计',align:'center',key:"total_price",minWidth:100}
  57. ]
  58. return arr
  59. }
  60. },
  61. mounted(){
  62. this.initData();
  63. },
  64. methods:{
  65. search(){
  66. let obj = {};
  67. obj = JSON.parse(JSON.stringify(this.searchData));
  68. this.proxyData = obj;
  69. this.initData(obj);
  70. },
  71. handleSpan({ row, column, rowIndex, columnIndex }){
  72. if (rowIndex ===this.tableData.length-2 && (columnIndex === 0||columnIndex===this.tableSlice[this.tableSlice.length-1]+1)) {
  73. return {
  74. rowspan: 2,
  75. colspan: 1
  76. };
  77. } else if (rowIndex === this.tableData.length-1 && (columnIndex === 0||columnIndex===this.tableSlice[this.tableSlice.length-1]+1)) {
  78. return {
  79. rowspan: 0,
  80. colspan: 0
  81. };
  82. }
  83. if(rowIndex===this.tableData.length-1){
  84. return this.totalColumns(rowIndex,columnIndex)
  85. }
  86. },
  87. totalColumns(rowIndex,columnIndex){
  88. let arr = [];
  89. if(0<columnIndex<=this.tableSlice[this.tableSlice.length-1]){
  90. arr = [0,0];
  91. this.tableSlice.forEach((v,index)=>{
  92. // if(index!=this.tableSlice.length-1){
  93. if(index==0){
  94. if(columnIndex===v+1){
  95. arr = [v+1,v]
  96. }
  97. }else{
  98. if(index!=this.tableSlice.length-1&&columnIndex===v+1){
  99. arr = [v+1,this.tableSlice[index+1]-v];
  100. }
  101. }
  102. })
  103. }
  104. if(columnIndex===1){
  105. arr = [1,this.tableSlice[0]] }
  106. return arr;
  107. },
  108. initData(row){
  109. this.axios.post('/api/finance_pack_year',{...this.$route.query,state:'',...row}).then(res=>{
  110. this.otherColumns=[];
  111. this.employeeList = res.data.employee;
  112. this.projectList = res.data.order_list;
  113. let data = res.data.header;
  114. let totalData = res.data.price;
  115. totalData.time='合计';
  116. this.tableData = res.data.list;
  117. // let data=[
  118. // {title:'包装一组',children:[{title:'项目A',key:'A'},{title:'项目B',key:'B'},{title:'项目C',key:'C'}],total_price:'1750'},
  119. // {title:'包装二组',children:[{title:'项目D',key:'D'},{title:'项目E',key:'E'},{title:'项目F',key:'F'}],total_price:'1800'},
  120. // {title:'包装三组',children:[{title:'项目G',key:'G'},{title:'项目H',key:'H'},{title:'项目I',key:'I'},{title:'项目j',key:'j'}],total_price:'1900'},
  121. // ];
  122. // let totalData = {time:'合计',A:"600",B:'700',C:'800',D:'900',E:'1000',F:'1100',G:"1200",H:'1300',I:"1400",j:'2000',total_price:'5000'};
  123. let totalSure = {};
  124. let sum = 0;
  125. data.forEach(v=>{
  126. totalSure[v.children[0].key] = v.total_price;
  127. sum+=v.children.length;
  128. this.tableSlice.push(sum)
  129. let obj = {};
  130. obj.title = v.title;
  131. obj.align = 'center';
  132. v.children.forEach(val=>{
  133. val.align='center';
  134. val.minWidth=100;
  135. val.render=(h,params)=>{
  136. const {row,column} = params;
  137. return !row.time?h('span',{},row[val.key]):h('a',{on:{
  138. 'click':()=>{
  139. // let year = this.func.replaceDateNoHMS(this.$route.query.start_time).split('-')[0]*1;
  140. // let month = this.func.replaceDateNoHMS(this.$route.query.start_time).split('-')[1]*1;
  141. let obj = {};
  142. // obj.start_time = (new Date(`${year}/${month}/${row.time*1}`).getTime().toString().slice(0,10))*1;
  143. // obj.end_time = (new Date(`${year}/${month}/${row.time*1}`).getTime().toString().slice(0,10))*1;
  144. obj.day=row.time;
  145. obj.employee = column.id;
  146. obj.order_no = column.order_no;
  147. obj.employee_title = column.employee;
  148. obj.project_title = column.title;
  149. this.$router.push({path:'/cms/PackagingStatistics/urlNumberDetail',query:{...obj,...this.$route.query}})
  150. }
  151. }},row[val.key])
  152. }
  153. });
  154. obj.children = v.children
  155. this.otherColumns.push(obj);
  156. })
  157. this.tableData.push(totalData);
  158. this.tableData.push(totalSure);
  159. });
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .form_content{
  166. display: flex;
  167. flex-wrap: wrap;
  168. margin-top: 20px;
  169. .form_item{
  170. width: 200px;
  171. }
  172. }
  173. </style>