AdaKing88
2023-08-23 9cad48db6c56c3e2796a9d6da881817ef13b6eca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<template>
  <div class="block">
    <span class="demonstration">时间</span>
    <el-date-picker v-model="value2" type="date" placeholder="Pick a day" :disabled-date="disabledDate"
      :shortcuts="shortcuts" :size="size" />
  </div>
 
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="chanpin" label="产品" />
    <el-table-column prop="leixing" label="类型" />
    <el-table-column prop="reportTime" label="时间">
 
    </el-table-column>
    <el-table-column prop="banci" label="班次" />
    <el-table-column prop="id" label="编号" />
    <el-table-column prop="createDate" label="最新时间" />
    <el-table-column label="操作">
      <template #default="scope">
        <el-button size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">详情</el-button>
      </template>
    </el-table-column>
  </el-table>
  <div class="page">
    <el-pagination background layout="prev, pager, next" :page-count="pageData.total"
      :current-page="pageData.ListData.pageNo" @current-change="handleCurrentChange" />
  </div>
</template>
 
<script>
import { ref, reactive } from "vue";
import { headPage } from "@/api/head";
import { useRouter } from "vue-router";
export default {
  name: "NewsIndex",
  components: {},
  props: {},
  setup() {
    const router = useRouter();
    const value = ref("");
    let tableData = ref([]);
    const formLabelWidth = "140px";
    let pageData = reactive({
      ListData: {
        pageNo: 1,
        pageSize: 15,
      },
      total: 0,
    });
    let value2 = '';
    const shortcuts = [
      {
        text: '今天',
        value: new Date(),
      },
      {
        text: '昨天',
        value: () => {
          const date = new Date()
          date.setTime(date.getTime() - 3600 * 1000 * 24)
          return date
        },
      },
      {
        text: '一周前',
        value: () => {
          const date = new Date()
          date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
          return date
        },
      },
    ]
 
    const disabledDate = (time) => {
      return time.getTime() > Date.now();
    }
    const options = [
      {
        value: "Option1",
        label: "Option1",
      },
      {
        value: "Option2",
        label: "Option2",
      },
      {
        value: "Option3",
        label: "Option3",
      },
      {
        value: "Option4",
        label: "Option4",
      },
      {
        value: "Option5",
        label: "Option5",
      },
    ];
    function handleEdit(index, row) {
      // console.log("xxxxxxxxxxxxxxx", index);
      // console.log("xxxxxxxxxxxxxxx", row);
      // console.log("oooooooooooooooo");
      if (row.leixing == "A0")
        router.push({
          path: "/Bianxk",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A1")
        router.push({
          path: "/JBJtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A6")
        router.push({
          path: "/DBtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A2")
        router.push({
          path: "/HJtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A3")
        router.push({
          path: "/FBtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A4")
        router.push({
          path: "/JGGXtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A5")
        router.push({
          path: "/JGJtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      if (row.leixing == "A7")
        router.push({
          path: "/GXtable",
          query: {
            id: row.id,
            leixing: row.leixing,
          },
        });
      return handleEdit;
    }
    const formInline = reactive({
      region: "",
    });
    const dialogFormVisible = ref(false);
    //确定搜索动作
    const onSubmit = () => { };
    //请求列表方法
    const getListData = async () => {
      const data = await headPage(pageData.ListData);
      // console.log("data manager....", data);
      pageData.total = Math.ceil(data.data.total / pageData.ListData.pageSize);
      tableData.value = data.data.records;
    };
    // 分页器
    const handleCurrentChange = (val) => {
      pageData.ListData.pageNo = val;
      getListData();
    };
    //删除用户
    const handleDelete = (val) => {
      // console.log(val);
    };
    //新增用户
    const addUser = () => { };
    getListData();
    function showState(row, column, cellValue, index) {
      // console.log("row", row);
      // console.log("col", column);
      // console.log("cel", cellValue);
      // console.log("index", index);
      if (cellValue === 0) return "正常";
      else return "异常";
    }
    return {
      value,
      pageData,
      options,
      onSubmit,
      formInline,
      tableData,
      handleCurrentChange,
      handleDelete,
      showState,
      dialogFormVisible,
      formLabelWidth,
      addUser,
      handleEdit,
      disabledDate,
      shortcuts
    };
  },
};
</script>
<style lang="scss" scoped>
.page {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}
 
.header_nox {
  text-align: right;
}
</style>