base.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="main">
  3. <el-button type="primary" @click="save" style="margin:20px">保存</el-button>
  4. <el-button type="primary" @click="back" style="margin:20px">返回</el-button>
  5. <el-button type="primary" @click="station" style="margin:20px">场站</el-button>
  6. <!-- 表格 -->
  7. <el-table :data="tableData" style="width:98%;margin:20px" max-height="800px">
  8. <el-table-column
  9. v-for="(i,index) in Object.keys(tableData[0]).sort(function(n,m){
  10. return parseInt(n.split('_')[0])-parseInt(m.split('_')[0]);
  11. })"
  12. :key="index"
  13. :prop="i"
  14. :label="i | clu"
  15. width="160"
  16. >
  17. <template slot-scope="scope">
  18. <el-input @input="send(scope.row)" v-if="scope.row.name =='止码' && i != 'name' && i != 'date'" v-model="scope.row[i]" :disabled='routerData.isConfirm == 1'></el-input>
  19. <label v-else>{{scope.row[i]}}</label>
  20. </template>
  21. </el-table-column>
  22. </el-table>
  23. </div>
  24. </template>
  25. <script>
  26. import dateFormat from "../../public/js/dateFormat";
  27. export default {
  28. data() {
  29. return {
  30. tableData: [],
  31. routerData:this.$route.params,
  32. lm: [],
  33. timeValue: [
  34. dateFormat(
  35. "yyyy-MM-dd",
  36. new Date(new Date().setDate(new Date().getDate() - 5))
  37. ),
  38. dateFormat("yyyy-MM-dd", new Date()),
  39. ],
  40. };
  41. },
  42. created() {
  43. this.fetch();
  44. console.log(this.routerData)
  45. },
  46. mounted() {},
  47. methods: {
  48. async fetch() {
  49. const res = await this.$http.get(
  50. `analysisplus/bdzlist?theday=${dateFormat("yyyy-MM-dd", new Date(this.routerData.data.theday))}&wpid=${this.routerData.data.wpid}`
  51. );
  52. for(let i in res.data){
  53. if( res.data[i].date == undefined ){
  54. }else{
  55. res.data[i].date =dateFormat("yyyy-MM-dd", new Date(res.data[i].date));
  56. }
  57. }
  58. this.tableData = res.data;
  59. console.log(res.data);
  60. var name = ['2_dfds','8_fdf','1_fdjkf'];
  61. var aaa = this.px(name);
  62. console.log(aaa);
  63. },
  64. px(name){
  65. return name.sort(function(a,b){
  66. return parseInt(a.split("_")[0])-parseInt(b.split("_")[0])
  67. });
  68. },
  69. send(v){
  70. },
  71. async save(){
  72. var obj = this.tableData[2];
  73. const wpid = this.routerData.data.wpid;
  74. obj.wpid=wpid
  75. console.log(obj)
  76. const res = await this.$http.post(
  77. `analysisplus/bdzupdate`,obj
  78. );
  79. console.log(res)
  80. },
  81. back(){
  82. this.$router.push({ name: "home", params: { beginDate: this.routerData.beginDate,endDate: this.routerData.endDate} });
  83. },
  84. station(){
  85. console.log(this.routerData);
  86. const param = {
  87. theday: this.routerData.data.theday,
  88. wpid: this.routerData.data.wpid
  89. }
  90. this.$router.push({ name: "station", params: { data: param,beginDate:this.routerData.beginDate,endDate:this.routerData.endDate } });
  91. }
  92. },
  93. filters: {
  94. clu(val){
  95. switch (val) {
  96. case 'name':
  97. return '设备名称';
  98. break;
  99. case 'date':
  100. return '日期';
  101. break;
  102. default:
  103. return val.split("_")[1]
  104. break;
  105. }
  106. },
  107. },
  108. };
  109. </script>
  110. <style scoped lang="scss">
  111. body {
  112. margin: 0;
  113. padding: 0;
  114. }
  115. .main {
  116. width: 100%;
  117. }
  118. </style>