Blame view

src/views/TestPaper/TestPaperClass.vue 7.79 KB
b89c8760   wangming   项目初始化
1
  <template>
1de913cf   ren   sdf
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
    <div class="app-container">
      <div class="seetingsDiv" style="">
        <el-button type="primary" @click="dialogClassIVIsible=true">添加分类
        </el-button>
      </div>
      <el-table :data="testpaperlist" id="QuestionTable" border row-key="id"
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
        style="width: 100%;border-radius: 5px;box-shadow: 0 0 10px #efefef;margin-top: 10px;" :stripe='true'>
        <el-table-column prop="date" label="ID" width="80">
          <template slot-scope="scope">
            <span>{{ scope.row.id }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="date" label="分类名称" width="150" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.ParentId==0">{{ scope.row.ClassTitle }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="date" label="下级分类">
          <template slot-scope="scope">
            <span v-if="scope.row.ParentId!=0">{{ scope.row.ClassTitle }}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" width="100" align="center">
          <template slot-scope="scope">
            <el-dropdown @command="(e)=>{handleCommand(e,scope.row)}">
              <span class="el-dropdown-link">
                操作<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item command="update">编辑</el-dropdown-item>
                  <el-dropdown-item command="add" v-if="scope.row.ParentId==0">添加下级</el-dropdown-item>
                  <el-dropdown-item command="del">删除</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <!--  <el-pagination background @current-change="currentchange"
        style="position:static;bottom: 3px;text-align: center;margin-top: 5px;" :page-size="this.parameter.pageSize"
        layout="total,prev, pager, next" :total="Count">
      </el-pagination> -->
      <el-dialog title="分类维护" :visible.sync="dialogClassIVIsible" @close="closeClassDialog" width="400px"
        :close-on-click-modal="false">
        <el-form ref="TestPaperClassInfo" :model="TestPaperClassInfo" label-width="70px">
          <el-form-item label="上级分类" v-if="TestPaperClassInfo.ParentId && TestPaperClassInfo.Parent">
            <el-input :disabled="true" v-model="TestPaperClassInfo.Parent"></el-input>
          </el-form-item>
          <el-form-item label="分类名称">
            <el-input v-model="TestPaperClassInfo.ClassTitle" placeholder="请输入分类名称"></el-input>
          </el-form-item>
        </el-form>
e011bf15   周超   我先走一步
56
        <el-button @click="CreateTestPaperClassHealder" style="margin: 10px 0 0 0 ;float:right" type="primary" :disabled="loading">确定
1de913cf   ren   sdf
57
58
59
60
        </el-button>
        <div style="clear: both;"></div>
      </el-dialog>
    </div>
b89c8760   wangming   项目初始化
61
62
63
  </template>
  
  <script>
1de913cf   ren   sdf
64
65
66
67
68
69
70
71
72
73
74
75
76
    import {
      getTestPaperClassList,
      GetTestPaperClassById,
      UpdateTestPaperClass,
      DeleteTestPaperClass,
      CreateTestPaperClass
    } from '@/api/TestPaper'
    import {
      parseTime
    } from '@/utils/index.js'
    export default {
      data() {
        return {
e011bf15   周超   我先走一步
77
          loading:false,
1de913cf   ren   sdf
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
          parameter: {
            pageIndex: 1,
            pageSize: 20,
            sort: "id",
            sortOrder: 1,
            keyword: ""
          },
          Count: 0,
          testpaperlist: [],
          dialogClassIVIsible: false,
          TestPaperClassInfo: {
            id: 0,
            ParentId: 0,
            Parent: '',
            ClassTitle: "",
            Addtime: "",
            UpdateTime: "",
            State: 1
          },
        }
      },
      computed: {
b89c8760   wangming   项目初始化
100
  
1de913cf   ren   sdf
101
102
103
104
105
106
107
108
109
110
111
112
113
      },
      created() {
  this.getTestPaperClassListHeadler();
      },
      mounted() {
        // let ContentAreaHight = window.innerHeight - document.getElementById("QuestionTable").offsetTop;
        // let lineNumber = ContentAreaHight - 50 - 40;
        // // this.parameter.pageSize = Math.floor(lineNumber / 49)
        // this.parameter.pageSize = 100;
        // this.getTestPaperClassListHeadler();
      },
      methods: {
        CreateTestPaperClassHealder() {
e011bf15   周超   我先走一步
114
          this.loading = true;
1de913cf   ren   sdf
115
116
117
118
119
120
121
122
          if (this.TestPaperClassInfo.id == 0) {
            this.TestPaperClassInfo.Addtime = parseTime(new Date(), "");
            this.TestPaperClassInfo.Addtime = parseTime(new Date(), "");
            CreateTestPaperClass(this.TestPaperClassInfo).then(res => {
              this.$confirm(res.data.message, '消息')
              this.TestPaperClassInfo = {};
               this.dialogClassIVIsible=false
              this.getTestPaperClassListHeadler();
b89c8760   wangming   项目初始化
123
  
e011bf15   周超   我先走一步
124
125
126
            setTimeout(()=>{
                this.loading = false;
              },1000);
1de913cf   ren   sdf
127
128
129
130
131
132
133
            })
          } else {
            UpdateTestPaperClass(this.TestPaperClassInfo).then(res => {
              this.$confirm(res.data.message, '消息')
              this.dialogClassIVIsible=false
               this.TestPaperClassInfo = {};
              this.getTestPaperClassListHeadler();
e011bf15   周超   我先走一步
134
135
136
              setTimeout(()=>{
                this.loading = false;
              },1000);
1de913cf   ren   sdf
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
            });
          }
        },
        getTestPaperClassListHeadler() {
          let _this = this;
          this.testpaperlist=[]
          getTestPaperClassList(this.parameter).then(res => {
            var gettree = function(titem) {
              titem.children = []
              let childrenList = res.data.data.filter(u => u.ParentId == titem.id);
              if (childrenList.length == 0) {
                titem.children = undefined;
              }
              res.data.data.filter(u => u.ParentId == titem.id).forEach((item, i) => {
                gettree(item);
                titem.children.push(item);
                titem.children=titem.children.sort((a,b)=>{
                  return a.id-b.id
                })
              })
            }
            res.data.data.filter(u => u.ParentId == 0).forEach((item, i) => {
              gettree(item);
              _this.testpaperlist.push(item)
            })
          });
        },
        closeClassDialog() {
          this.TestPaperClassInfo = {
            id: 0,
            ParentId: 0,
            Parent: '',
            ClassTitle: "",
            Addtime: "",
            UpdateTime: "",
            State: 1
          };
          // this.getTestPaperClassListHeadler();
  
        },
        currentchange(page) {
          this.parameter.pageIndex = page;
          this.getTestPaperClassListHeadler();
        },
        //表格右边的操作按钮
        handleCommand(value, val) {
  
          let that = this;
          if (value == "update") {
            // alert("编辑操作"+val)
            this.dialogClassIVIsible = true;
            GetTestPaperClassById(val.id).then(res => {
              that.TestPaperClassInfo = res.data.data;
            });
          }
          if (value == "del") {
            this.$confirm('确定删除该分类?', '消息', {
              confirmButtonText: '确认',
              cancelButtonText: '取消',
              callback: (action) => {
                if (action == "confirm") {
                  DeleteTestPaperClass(val.id).then(res => {
                    if (res.data.code == 200) {
                      this.$confirm(res.data.message, '消息')
                      this.getTestPaperClassListHeadler();
                    }
                  });
                }
              },
            })
  
          }
          if (value == 'add') {
            this.TestPaperClassInfo.ParentId = val.id
            this.TestPaperClassInfo.Parent = val.ClassTitle
            this.dialogClassIVIsible = true
          }
        },
      }
    }
b89c8760   wangming   项目初始化
217
218
  </script>
  
d1837e7a   wangming   测试
219
  <style scoped>
1de913cf   ren   sdf
220
221
222
223
    .seetingsDiv {
      width: 100%;
      height: 60px;
      background: #efefef;
1de913cf   ren   sdf
224
225
226
227
228
229
230
231
232
      border-radius: 5px;
      box-shadow: 0 0 5px #cdcdcd;
    }
  
    .seetingsDiv button {
      background-color: #304156;
      border: 0px;
      margin-left: 10px;
      box-shadow: 0 0 5px #cdcdcd;
d1837e7a   wangming   测试
233
      float: left;
1de913cf   ren   sdf
234
235
236
      margin-top: 12px;
      margin-right: 10px;
    }
b89c8760   wangming   项目初始化
237
  </style>