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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<template>
  <div class="productionLine viewWrap">
    <h2>生产线管理</h2>
    <!-- 数据功能按钮区 -->
    <el-button type="primary" icon="el-icon-plus" style="width: 100px;" @click="handleFormDataAdd">添加</el-button>
 
    <!-- 数据表格区 -->
    <el-table stripe :data="tableData" height="0" style="margin-top: 20px;">
      <el-table-column type="index" label="序号"> </el-table-column>
      <el-table-column prop="name" label="名称"> </el-table-column>
      <el-table-column prop="type" label="型号"> </el-table-column>
      <el-table-column prop="factory" label="厂家"> </el-table-column>
      <el-table-column prop="director" label="技术负责人"> </el-table-column>
      <el-table-column prop="dMobile" label="手机号"> </el-table-column>
      <el-table-column prop="installTime" label="安装时间"> </el-table-column>
      <el-table-column prop="remark" label="备注" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="disabled" label="状态" width="180">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.disabled" active-color="#ff0000" active-text="禁用" inactive-color="#409EFF"
            inactive-text="启用" @change="handleDisabled(scope.row)">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button icon="el-icon-edit" @click.native.prevent="handleFormDataEdit(scope.row)" type="text" size="small">
            编辑
          </el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <!-- 分页组件 -->
    <el-pagination style="margin-top: 20px;" @size-change="onGetTableData" @current-change="onGetTableData"
      :current-page.sync="pageCurr" :page-size.sync="pageSize" :page-sizes="[10, 20, 50, 100]"
      layout="total, sizes, prev, pager, next, jumper" :total="total">
    </el-pagination>
 
    <!-- 表单 -->
    <el-dialog title="生产线信息" :visible.sync="showFromData" width="600px" :before-close="handleFormDataClose">
      <el-form :model="formData" :rules="formRules" ref="formData" label-width="140px">
        <el-form-item label="用户ID" prop="id" style="display: none;">
          <el-input style="width:220px" v-model="formData.id" disabled></el-input>
        </el-form-item>
        <el-form-item label="名称" prop="name">
          <el-input style="width:220px" v-model="formData.name" clearable></el-input>
        </el-form-item>
        <el-form-item label="型号" prop="type">
          <el-input style="width:220px" v-model="formData.type" clearable></el-input>
        </el-form-item>
        <el-form-item label="厂家" prop="factory">
          <el-input style="width:220px" v-model="formData.factory" clearable></el-input>
        </el-form-item>
        <el-form-item label="技术负责人" prop="director">
          <el-input style="width:220px" v-model="formData.director" clearable></el-input>
        </el-form-item>
        <el-form-item label="技术负责人手机号" prop="dMobile">
          <el-input style="width:220px" v-model="formData.dMobile" clearable></el-input>
        </el-form-item>
        <el-form-item label="安装时间" prop="installTime">
          <el-date-picker v-model="formData.installTime" type="date" value-format="yyyy-MM-dd" placeholder="选择日期"
            clearable style="width:220px;">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input style="width:220px" v-model="formData.remark" clearable></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleFormDataClose">取 消</el-button>
        <el-button type="primary" @click="handleFormDataSubmit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<style lang="less" scoped></style>
 
<script>
export default {
  name: "productionLine",
  components: {},
  data() {
    return {
      pageSize: 10,
      pageCurr: 1,
      total: 0,
      tableData: [],
      showFromData: false,
      formData: {
        id: null,
        name: null,
        type: null,
        factory: null,
        director: null,
        dMobile: null,
        installTime: null,
        remark: null,
      },
      formRules: {
        name: [{ required: true, message: "必填项", trigger: "blur" }],
        type: [{ required: true, message: "必填项", trigger: "blur" }],
        factory: [{ required: true, message: "必填项", trigger: "blur" }],
        director: [{ required: true, message: "必填项", trigger: "blur" }],
        dMobile: [{ required: true, message: "必填项", trigger: "blur" }],
        installTime: [{ required: true, message: "必填项", trigger: "blur" }],
      },
    };
  },
  computed: {},
  mounted() {
    this.onGetTableData();
  },
  methods: {
    // 获取表格数据
    onGetTableData: function () {
      var that = this;
      var data = {
        pageSize: this.pageSize,
        pageCurr: this.pageCurr,
      };
      that
        .$axiosAdmin({
          method: "post",
          url: "platform/proLine/some",
          data: JSON.stringify(data),
        })
        .then((res) => {
          if (res.success == true) {
            that.tableData = res.content.obj;
            that.total = res.content.itemTotal;
          } else {
            that.$alert(res.content, "提示", {
              confirmButtonText: "确定",
            });
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 删除确认
    handleDelete(row) {
      this.$confirm(`此操作将删除 ${row.name} , 是否继续?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.onDelete(row);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 执行删除
    onDelete: function (row) {
      var that = this;
      var params = {
        id: row.id,
      };
      that
        .$axiosAdmin({
          method: "get",
          url: "platform/proLine/delete",
          params: params,
        })
        .then((res) => {
          if (res.success == true) {
            that.$message({
              type: "success",
              message: "已成功",
            });
          } else {
            that.$alert(res.content, "提示", {
              confirmButtonText: "确定",
            });
          }
          that.onGetTableData();
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 添加
    handleFormDataAdd: function () {
      this.formData.id = null;
      this.formData.name = null;
      this.formData.type = null;
      this.formData.factory = null;
      this.formData.director = null;
      this.formData.dMobile = null;
      this.formData.installTime = null;
      this.formData.remark = null;
      this.showFromData = true;
    },
    // 关闭
    handleFormDataClose: function () {
      this.formData.id = null;
      this.formData.name = null;
      this.formData.type = null;
      this.formData.factory = null;
      this.formData.director = null;
      this.formData.dMobile = null;
      this.formData.installTime = null;
      this.formData.remark = null;
      this.showFromData = false;
      this.$refs['formData'].resetFields();
    },
    // 编辑
    handleFormDataEdit: function (row) {
      this.formData.id = row.id;
      this.formData.name = row.name;
      this.formData.type = row.type;
      this.formData.factory = row.factory;
      this.formData.director = row.director;
      this.formData.dMobile = row.dMobile;
      this.formData.installTime = row.installTime;
      this.formData.remark = row.remark;
      this.showFromData = true;
    },
    // 提交数据确认
    handleFormDataSubmit: function () {
      this.$confirm(`此操作将保存并更新数据, 是否继续?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.onFormDataSubmit();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 提交数据
    onFormDataSubmit: function () {
      var that = this;
      var url, data;
      if (this.formData.id) {
        url = "platform/proLine/update";
        data = {
          id: this.formData.id,
          name: this.formData.name,
          type: this.formData.type,
          factory: this.formData.factory,
          director: this.formData.director,
          dMobile: this.formData.dMobile,
          installTime: this.formData.installTime,
          remark: this.formData.remark,
        };
      } else {
        url = "platform/proLine/save";
        data = {
          name: this.formData.name,
          type: this.formData.type,
          factory: this.formData.factory,
          director: this.formData.director,
          dMobile: this.formData.dMobile,
          installTime: this.formData.installTime,
          remark: this.formData.remark,
        };
      }
      that
        .$axiosAdmin({
          method: "post",
          url: url,
          data: JSON.stringify(data),
        })
        .then((res) => {
          if (res.success == true) {
            that.$message({
              type: "success",
              message: "已成功",
            });
            that.handleFormDataClose();
            that.onGetTableData();
          } else {
            that.$alert(res.content, "提示", {
              confirmButtonText: "确定",
            });
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 状态变更确认
    handleDisabled(row) {
      this.$confirm(`此操作将变更 ${row.name} 的状态, 是否继续?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.onDisabled(row);
        })
        .catch(() => {
          this.onGetTableData();
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 执行状态变更
    onDisabled: function (row) {
      var that = this;
      var data = {
        id: row.id,
        disabled: row.disabled,
      };
      that
        .$axiosAdmin({
          method: "post",
          url: "platform/proLine/disabled",
          data: JSON.stringify(data),
        })
        .then((res) => {
          if (res.success == true) {
            that.$message({
              type: "success",
              message: "已成功",
            });
          } else {
            that.$alert(res.content, "提示", {
              confirmButtonText: "确定",
            });
          }
          that.onGetTableData();
        })
        .catch((err) => {
          console.log(err);
          that.onGetTableData();
        });
    },
  },
};
</script>