XMLWAN пре 4 година
родитељ
комит
d9bc0d8c26
1 измењених фајлова са 211 додато и 0 уклоњено
  1. 211 0
      src/xt_pages/mode/index.vue

+ 211 - 0
src/xt_pages/mode/index.vue Прегледај датотеку

@@ -0,0 +1,211 @@
1
+<template>
2
+  <div class="main-contain">
3
+    <div class="position">
4
+      <bread-crumb :crumbs="crumbs"></bread-crumb>
5
+
6
+      <el-button
7
+        size="small"
8
+        icon="el-icon-circle-plus-outline"
9
+        type="primary"
10
+        @click="addMode"
11
+        >新增</el-button
12
+      >
13
+    </div>
14
+    <div class="app-container">
15
+      <el-row>
16
+        <el-col :span="24">
17
+          <el-table
18
+            :data="tableData"
19
+            :row-style="{ color: '#303133' }"
20
+            :header-cell-style="{
21
+              backgroundColor: 'rgb(245, 247, 250)',
22
+              color: '#606266'
23
+            }"
24
+            border
25
+          >
26
+            <el-table-column label="型号名称" align="center">
27
+              <template slot-scope="scope">
28
+                <span>{{ scope.row.device_mode }}</span>
29
+              </template>
30
+            </el-table-column>
31
+            <el-table-column label="操作" align="center">
32
+              <template slot-scope="scope">
33
+                <el-tooltip
34
+                  class="item"
35
+                  effect="dark"
36
+                  content="编辑"
37
+                  placement="top"
38
+                >
39
+                  <el-button
40
+                    type="primary"
41
+                    icon="el-icon-edit-outline"
42
+                    size="small"
43
+                    @click="EditMode(scope.row.id)"
44
+                  ></el-button>
45
+                </el-tooltip>
46
+                <el-tooltip
47
+                  class="item"
48
+                  effect="dark"
49
+                  content="删除"
50
+                  placement="top"
51
+                >
52
+                  <el-button
53
+                    type="danger"
54
+                    icon="el-icon-delete"
55
+                    size="small"
56
+                    @click="DeleteMode(scope.row.id, scope.$index)"
57
+                  ></el-button>
58
+                </el-tooltip>
59
+              </template>
60
+            </el-table-column>
61
+          </el-table>
62
+        </el-col>
63
+      </el-row>
64
+
65
+      <el-dialog
66
+        title="添加设备型号"
67
+        :visible.sync="dialogVisible"
68
+        width="30%"
69
+        center
70
+      >
71
+        <el-form :model="form" ref="form" :rules="ModeRules">
72
+          <el-form-item label="设备型号:" required prop="device_mode">
73
+            <el-input style="width:200px" v-model="form.device_mode"></el-input>
74
+          </el-form-item>
75
+        </el-form>
76
+        <span slot="footer" class="dialog-footer">
77
+          <el-button @click="dialogVisible = false">取 消</el-button>
78
+          <el-button type="primary" @click="SaveMode('form')">保存</el-button>
79
+        </span>
80
+      </el-dialog>
81
+
82
+      <el-dialog
83
+        title="编辑设备型号"
84
+        :visible.sync="editDialogVisible"
85
+        width="30%"
86
+        center
87
+      >
88
+        <el-form :model="form" ref="form" :rules="ModeRules">
89
+          <el-form-item label="设备型号:">
90
+            <el-input style="width:200px" v-model="form.device_mode"></el-input>
91
+          </el-form-item>
92
+        </el-form>
93
+        <span slot="footer" class="dialog-footer">
94
+          <el-button @click="editDialogVisible = false">取 消</el-button>
95
+          <el-button type="primary" @click="UpdateMode('form')">保存</el-button>
96
+        </span>
97
+      </el-dialog>
98
+    </div>
99
+  </div>
100
+</template>
101
+
102
+<script>
103
+// eslint-disable-next-line no-unused-vars
104
+import BreadCrumb from "@/xt_pages/components/bread-crumb";
105
+import {
106
+  SaveMode,
107
+  getAllMode,
108
+  EditMode,
109
+  UpdateMode,
110
+  DeleteMode
111
+} from "@/api/manage";
112
+export default {
113
+  name: "index.vue",
114
+  data() {
115
+    return {
116
+      crumbs: [
117
+        { path: false, name: "设备管理" },
118
+        { path: "/device/mode", name: "型号管理" }
119
+      ],
120
+      dialogVisible: false,
121
+      editDialogVisible: false,
122
+      tableData: [],
123
+      form: {
124
+        id: "",
125
+        device_mode: ""
126
+      },
127
+      ModeRules: {
128
+        device_mode: [{ required: true, message: "请填写设备型号" }]
129
+      }
130
+    };
131
+  },
132
+  methods: {
133
+    addMode() {
134
+      this.dialogVisible = true;
135
+    },
136
+    SaveMode(formName) {
137
+      this.$refs[formName].validate(valid => {
138
+        if (valid) {
139
+          // eslint-disable-next-line no-undef
140
+          SaveMode(this.form).then(response => {
141
+            // eslint-disable-next-line no-empty
142
+            if (response.data.state === 1) {
143
+              var mode = response.data.data.mode;
144
+              this.form.device_mode = "";
145
+              this.dialogVisible = false;
146
+              this.getAllMode();
147
+            }
148
+          });
149
+        }
150
+      });
151
+    },
152
+    getAllMode() {
153
+      getAllMode().then(response => {
154
+        if (response.data.state === 1) {
155
+          var mode = response.data.data.mode;
156
+          this.tableData = mode;
157
+          console.log(mode);
158
+        }
159
+      });
160
+    },
161
+    EditMode(id) {
162
+      this.editDialogVisible = true;
163
+      EditMode(id).then(response => {
164
+        if (response.data.state === 1) {
165
+          var mode = response.data.data.mode;
166
+          this.form.id = mode.id;
167
+          this.form.device_mode = mode.device_mode;
168
+        }
169
+      });
170
+    },
171
+    UpdateMode(formName) {
172
+      this.$refs[formName].validate(valid => {
173
+        if (valid) {
174
+          UpdateMode(this.form.id, this.form).then(response => {
175
+            if (response.data.state === 1) {
176
+              var mode = response.data.data.mode;
177
+              this.editDialogVisible = false;
178
+              this.getAllMode();
179
+            }
180
+          });
181
+        }
182
+      });
183
+    },
184
+    DeleteMode(id, index) {
185
+      this.$confirm(
186
+        "确认要删除所选信息吗? <br>删除后,信息将无法恢复",
187
+        "删除提示",
188
+        {
189
+          dangerouslyUseHTMLString: true,
190
+          confirmButtonText: "确定",
191
+          cancelButtonText: "取消",
192
+          type: "warning"
193
+        }
194
+      ).then(() => {
195
+        DeleteMode(id, index).then(response => {
196
+          if (response.data.state === 1) {
197
+            var msg = response.data.data.msg;
198
+            this.tableData.splice(index, 1);
199
+          }
200
+        });
201
+      });
202
+    }
203
+  },
204
+
205
+  created() {
206
+    this.getAllMode();
207
+  }
208
+};
209
+</script>
210
+
211
+<style scoped></style>