ソースを参照

Merge commit '0e62d286872dc9c190eb44846619c549fabd0aec' into gzb

gzb
guozhongbo 1年前
コミット
1ad30ece62
2個のファイルの変更436行の追加4行の削除
  1. 28
    0
      src/api/index.js
  2. 408
    4
      src/views/history/index.vue

+ 28
- 0
src/api/index.js ファイルの表示

@@ -63,3 +63,31 @@ export const user_update = (data) =>
63 63
     method: "post",
64 64
     data
65 65
   });
66
+// 发展历程列表
67
+export const dh_list = (data) =>
68
+  request({
69
+    url: window._config.baseUrl + "dh/list",
70
+    method: "post",
71
+    data
72
+  });
73
+// 发展历程保存
74
+export const dh_save = (data) =>
75
+  request({
76
+    url: window._config.baseUrl + "dh/save",
77
+    method: "post",
78
+    data
79
+  });
80
+// 发展历程更新
81
+export const dh_update = (data) =>
82
+  request({
83
+    url: window._config.baseUrl + "dh/update",
84
+    method: "post",
85
+    data
86
+  });
87
+// 发展历程删除
88
+export const dh_remove = (data) =>
89
+  request({
90
+    url: window._config.baseUrl + "dh/remove",
91
+    method: "post",
92
+    data
93
+  });

+ 408
- 4
src/views/history/index.vue ファイルの表示

@@ -1,14 +1,418 @@
1 1
 <template>
2
-  <div>user</div>
2
+  <div>
3
+    <div class="searchBox">
4
+      <div>
5
+        <DatePicker
6
+          type="year"
7
+          placeholder="请选择年份"
8
+          v-model="historySearch.dhyear"
9
+          style="margin-right: 16px; width: 200px"
10
+          :clearable="false"
11
+        />
12
+        <RadioGroup v-model="historySearch.ltype" @on-change="searchList()">
13
+          <Radio :label="1">中文</Radio>
14
+          <Radio :label="2">英文</Radio>
15
+        </RadioGroup>
16
+        <Button type="primary" style="margin-left: 16px" @click="searchList()"
17
+          >搜索</Button
18
+        >
19
+      </div>
20
+      <div>
21
+        <Button type="primary" @click="toAdd()">添加</Button>
22
+      </div>
23
+    </div>
24
+    <Table border :columns="historyColumns" :data="historySearch.list">
25
+      <template slot-scope="{ row }" slot="ltypeSlot">
26
+        <span>{{ row.ltype === 1 ? "中文" : "英文" }}</span>
27
+      </template>
28
+      <template slot-scope="{ row }" slot="createtimeSlot">
29
+        <span>{{ dateFormat(row.createtime) }}</span>
30
+      </template>
31
+      <template slot-scope="{ row }" slot="actionSlot">
32
+        <div>
33
+          <span
34
+            style="color: #2d8cf0; cursor: pointer"
35
+            @click="toModifyHistory(row)"
36
+            >修改</span
37
+          >
38
+          <span style="margin: 0 10px; color: #2d8cf0">|</span>
39
+          <span
40
+            style="color: #ff001e; cursor: pointer"
41
+            @click="toDelHistory(row.dhid)"
42
+            >删除</span
43
+          >
44
+        </div>
45
+      </template>
46
+    </Table>
47
+    <div class="foot_page" v-if="historySearch.total > 0">
48
+      <Page
49
+        :total="historySearch.total"
50
+        @on-change="changePage"
51
+        :current="historySearch.page"
52
+        show-total
53
+      ></Page>
54
+    </div>
55
+    <Modal
56
+      v-model="userAddForm.show"
57
+      class="modal1"
58
+      :mask-closable="false"
59
+      title="添加用户信息"
60
+    >
61
+      <Form
62
+        :label-width="90"
63
+        label-position="right"
64
+        ref="userAddForm"
65
+        :rules="addFormRules"
66
+        :model="userAddForm"
67
+      >
68
+        <FormItem label="用户姓名" prop="username">
69
+          <Input v-model="userAddForm.username" placeholder="请输入用户姓名" />
70
+        </FormItem>
71
+        <FormItem label="登录账号" prop="loginname">
72
+          <Input v-model="userAddForm.loginname" placeholder="请输入登录账号" />
73
+        </FormItem>
74
+        <FormItem label="登录密码" prop="loginpwd">
75
+          <Input v-model="userAddForm.loginpwd" placeholder="请输入登录密码" />
76
+        </FormItem>
77
+        <FormItem label="手机号" prop="userphone">
78
+          <Input v-model="userAddForm.userphone" placeholder="请输入手机号" />
79
+        </FormItem>
80
+      </Form>
81
+      <div slot="footer" style="text-align: right">
82
+        <Button @click="userAddForm.show = false">取消</Button>
83
+        <Button @click="toSaveAdd()" type="primary">保存</Button>
84
+      </div>
85
+    </Modal>
86
+    <Modal
87
+      v-model="userModifyForm.show"
88
+      class="modal1"
89
+      :mask-closable="false"
90
+      title="修改用户信息"
91
+    >
92
+      <Form
93
+        :label-width="90"
94
+        label-position="right"
95
+        ref="userModifyForm"
96
+        :rules="modifyFormRules"
97
+        :model="userModifyForm"
98
+      >
99
+        <FormItem label="用户姓名" prop="username">
100
+          <Input
101
+            v-model="userModifyForm.username"
102
+            placeholder="请输入用户姓名"
103
+          />
104
+        </FormItem>
105
+        <FormItem label="登录账号" prop="loginname">
106
+          <Input
107
+            v-model="userModifyForm.loginname"
108
+            placeholder="请输入登录账号"
109
+          />
110
+        </FormItem>
111
+        <FormItem label="登录密码" prop="loginpwd">
112
+          <Input
113
+            v-model="userModifyForm.loginpwd"
114
+            placeholder="请输入登录密码"
115
+          />
116
+        </FormItem>
117
+        <FormItem label="手机号" prop="userphone">
118
+          <Input
119
+            v-model="userModifyForm.userphone"
120
+            placeholder="请输入手机号"
121
+          />
122
+        </FormItem>
123
+      </Form>
124
+      <div slot="footer" style="text-align: right">
125
+        <Button @click="userModifyForm.show = false">取消</Button>
126
+        <Button @click="toSaveModifyUser()" type="primary">保存</Button>
127
+      </div>
128
+    </Modal>
129
+  </div>
3 130
 </template>
4 131
 
5 132
 <script>
133
+import { dh_list, dh_save, dh_update, dh_remove } from "@/api";
134
+import { dateFormat } from "@/utils";
6 135
 export default {
7 136
   data() {
8
-    return {};
137
+    // 手机号验证
138
+    const phoneCheck = async (rule, value, callback) => {
139
+      var filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
140
+      if (!value) {
141
+        return;
142
+      }
143
+      let blnTest = filter.test(value);
144
+      if (!blnTest) {
145
+        return callback(new Error("手机号码格式不正确"));
146
+      }
147
+    };
148
+    return {
149
+      dateFormat,
150
+      historySearch: {
151
+        page: 1,
152
+        size: 10,
153
+        dhyear: new Date(),
154
+        ltype: 1,
155
+        total: 0,
156
+        list: []
157
+      },
158
+      historyColumns: [
159
+        {
160
+          title: "序号",
161
+          width: 70,
162
+          render: (h, params) => {
163
+            return h(
164
+              "span",
165
+              params.index +
166
+                (this.historySearch.page - 1) * this.historySearch.size +
167
+                1
168
+            );
169
+          }
170
+        },
171
+        {
172
+          title: "年份",
173
+          key: "dhyear",
174
+          width: 80
175
+        },
176
+        {
177
+          title: "月份",
178
+          key: "dhmonth",
179
+          width: 90
180
+        },
181
+        {
182
+          title: "状态",
183
+          slot: "ltypeSlot",
184
+          width: 90
185
+        },
186
+        {
187
+          title: "内容",
188
+          key: "content"
189
+        },
190
+        {
191
+          title: "创建人",
192
+          key: "createname",
193
+          width: 120
194
+        },
195
+        {
196
+          title: "创建时间",
197
+          slot: "createtimeSlot",
198
+          width: 200
199
+        },
200
+        {
201
+          title: "操作",
202
+          slot: "actionSlot",
203
+          width: 150
204
+        }
205
+      ],
206
+      userAddForm: {
207
+        show: false,
208
+        username: "",
209
+        loginname: "",
210
+        loginpwd: "",
211
+        userphone: null
212
+      },
213
+      addFormRules: {
214
+        username: [
215
+          {
216
+            required: true,
217
+            message: "用户姓名不能为空",
218
+            trigger: "blur"
219
+          }
220
+        ],
221
+        loginname: [
222
+          {
223
+            required: true,
224
+            message: "登录账号不能为空",
225
+            trigger: "blur"
226
+          },
227
+          {
228
+            min: 4,
229
+            max: 18,
230
+            message: "登录账号长度为4~18个字符",
231
+            trigger: "blur"
232
+          }
233
+        ],
234
+        loginpwd: [
235
+          {
236
+            required: true,
237
+            message: "登录密码不能为空",
238
+            trigger: "blur"
239
+          },
240
+          {
241
+            min: 6,
242
+            max: 16,
243
+            message: "登录密码长度为6~16个字符",
244
+            trigger: "blur"
245
+          }
246
+        ],
247
+        userphone: [{ validator: phoneCheck, trigger: "blur" }]
248
+      },
249
+      userModifyForm: {
250
+        show: false,
251
+        dhid: null,
252
+        username: "",
253
+        loginname: "",
254
+        loginpwd: "",
255
+        userphone: null
256
+      },
257
+      modifyFormRules: {
258
+        username: [
259
+          {
260
+            required: true,
261
+            message: "用户姓名不能为空",
262
+            trigger: "blur"
263
+          }
264
+        ],
265
+        loginname: [
266
+          {
267
+            required: true,
268
+            message: "登录账号不能为空",
269
+            trigger: "blur"
270
+          },
271
+          {
272
+            min: 4,
273
+            max: 18,
274
+            message: "登录账号长度为4~18个字符"
275
+          }
276
+        ],
277
+        loginpwd: [
278
+          // {
279
+          //   required: true,
280
+          //   message: "登录密码不能为空",
281
+          //   trigger: "blur",
282
+          // },
283
+          {
284
+            min: 6,
285
+            max: 16,
286
+            message: "登录密码长度为6~16个字符",
287
+            trigger: "blur"
288
+          }
289
+        ],
290
+        userphone: [{ validator: phoneCheck, trigger: "blur" }]
291
+      },
292
+      userInfo: {}
293
+    };
9 294
   },
10
-  methods: {}
295
+  created() {
296
+    this.userInfo = JSON.parse(localStorage.getItem("xhWebAdminUser"));
297
+    this.getHistoryList();
298
+  },
299
+  methods: {
300
+    searchList() {
301
+      this.historySearch.page = 1;
302
+      this.getHistoryList();
303
+    },
304
+    getHistoryList() {
305
+      dh_list({
306
+        page: this.historySearch.page,
307
+        size: this.historySearch.size,
308
+        dhyear: this.historySearch.dhyear.getFullYear(),
309
+        ltype: this.historySearch.ltype
310
+      })
311
+        .then((data) => {
312
+          if (data.code === 0) {
313
+            this.historySearch.total = data.obj.total;
314
+            this.historySearch.list = data.obj.list;
315
+          } else {
316
+            this.historySearch.total = 0;
317
+            this.historySearch.list = [];
318
+            this.$Message.error(data.msg);
319
+          }
320
+        })
321
+        .catch(() => {});
322
+    },
323
+    toDelHistory(dhid) {
324
+      this.$Modal.confirm({
325
+        title: "提示",
326
+        content: "您确定删除选中数据吗?",
327
+        onOk: () => {
328
+          dh_remove({ dhid }).then((res) => {
329
+            if (res.code == 0) {
330
+              this.$Message.success(res.msg);
331
+              this.searchList();
332
+            }
333
+          });
334
+        },
335
+        onCancel: () => {}
336
+      });
337
+    },
338
+    toAdd() {
339
+      this.userAddForm = {
340
+        show: true,
341
+        username: "",
342
+        loginname: "",
343
+        loginpwd: "",
344
+        userphone: null
345
+      };
346
+    },
347
+    toSaveAdd() {
348
+      this.$refs.userAddForm.validate((valid) => {
349
+        if (valid) {
350
+          dh_save({
351
+            username: this.userAddForm.username,
352
+            loginname: this.userAddForm.loginname,
353
+            loginpwd: this.userAddForm.loginpwd,
354
+            createid: this.userInfo.dhid,
355
+            userphone: this.userAddForm.userphone
356
+          }).then((data) => {
357
+            if (data.code === 0) {
358
+              this.userAddForm.show = false;
359
+              this.$Message.success(data.msg);
360
+              this.searchList();
361
+            } else {
362
+              this.$Message.error(data.msg);
363
+            }
364
+          });
365
+        }
366
+      });
367
+    },
368
+    toModifyHistory(user) {
369
+      this.userModifyForm = {
370
+        show: true,
371
+        dhid: user.dhid,
372
+        username: user.username,
373
+        loginname: user.loginname,
374
+        loginpwd: user.loginpwd,
375
+        userphone: user.userphone
376
+      };
377
+    },
378
+    toSaveModifyUser() {
379
+      this.$refs.userModifyForm.validate((valid) => {
380
+        if (valid) {
381
+          dh_update({
382
+            username: this.userModifyForm.username,
383
+            loginname: this.userModifyForm.loginname,
384
+            loginpwd: this.userModifyForm.loginpwd,
385
+            createid: this.userInfo.dhid,
386
+            userphone: this.userModifyForm.userphone,
387
+            dhid: this.userModifyForm.dhid
388
+          }).then((data) => {
389
+            if (data.code === 0) {
390
+              this.userModifyForm.show = false;
391
+              this.$Message.success(data.msg);
392
+              this.searchList();
393
+            } else {
394
+              this.$Message.error(data.msg);
395
+            }
396
+          });
397
+        }
398
+      });
399
+    },
400
+    changePage(page) {
401
+      this.historySearch.page = page;
402
+      this.getHistoryList();
403
+    }
404
+  }
11 405
 };
12 406
 </script>
13 407
 
14
-<style scoped lang="less"></style>
408
+<style scoped lang="less">
409
+.searchBox {
410
+  display: flex;
411
+  justify-content: space-between;
412
+  padding: 16px 0;
413
+}
414
+.foot_page {
415
+  padding: 16px 0;
416
+  text-align: right;
417
+}
418
+</style>

読み込み中…
キャンセル
保存