houzhongjian
2024-07-11 759b1c71011abd6b58c37d2566f3f3c208c2f1b2
提交 | 用户 | 时间
759b1c 1 <template>
H 2   <div class="app-container">
3     <!-- 搜索工作栏 -->
4     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5       <el-form-item label="名字" prop="name">
6         <el-input v-model="queryParams.name" placeholder="请输入名字" clearable @keyup.enter.native="handleQuery"/>
7       </el-form-item>
8       <el-form-item label="性别" prop="sex">
9         <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable size="small">
10           <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_BOOLEAN_STRING)"
11                      :key="dict.value" :label="dict.label" :value="dict.value"/>
12         </el-select>
13       </el-form-item>
14       <el-form-item label="出生年" prop="birthday">
15         <el-date-picker clearable v-model="queryParams.birthday" type="date" value-format="yyyy-MM-dd" placeholder="选择出生年" />
16       </el-form-item>
17       <el-form-item label="创建时间" prop="createTime">
18         <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
19                         range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
20       </el-form-item>
21       <el-form-item>
22         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
23         <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
24       </el-form-item>
25     </el-form>
26
27     <!-- 操作工具栏 -->
28     <el-row :gutter="10" class="mb8">
29       <el-col :span="1.5">
30         <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
31                    v-hasPermi="['infra:demo01-contact:create']">新增</el-button>
32       </el-col>
33       <el-col :span="1.5">
34         <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
35                    v-hasPermi="['infra:demo01-contact:export']">导出</el-button>
36       </el-col>
37       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
38     </el-row>
39
40     <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
41       <el-table-column label="编号" align="center" prop="id" />
42       <el-table-column label="名字" align="center" prop="name" />
43       <el-table-column label="性别" align="center" prop="sex">
44         <template v-slot="scope">
45           <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.sex" />
46         </template>
47       </el-table-column>
48       <el-table-column label="出生年" align="center" prop="birthday" width="180">
49         <template v-slot="scope">
50           <span>{{ parseTime(scope.row.birthday) }}</span>
51         </template>
52       </el-table-column>
53       <el-table-column label="简介" align="center" prop="description" />
54       <el-table-column label="头像" align="center" prop="avatar" />
55       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
56         <template v-slot="scope">
57           <span>{{ parseTime(scope.row.createTime) }}</span>
58         </template>
59       </el-table-column>
60       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
61         <template v-slot="scope">
62           <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
63                      v-hasPermi="['infra:demo01-contact:update']">修改</el-button>
64           <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
65                      v-hasPermi="['infra:demo01-contact:delete']">删除</el-button>
66         </template>
67       </el-table-column>
68     </el-table>
69     <!-- 分页组件 -->
70     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
71                 @pagination="getList"/>
72     <!-- 对话框(添加 / 修改) -->
73     <Demo01ContactForm ref="formRef" @success="getList" />
74   </div>
75 </template>
76
77 <script>
78 import * as Demo01ContactApi from '@/api/infra/demo01';
79 import Demo01ContactForm from './Demo01ContactForm.vue';
80 export default {
81   name: "Demo01Contact",
82   components: {
83     Demo01ContactForm,
84   },
85   data() {
86     return {
87       // 遮罩层
88       loading: true,
89       // 导出遮罩层
90       exportLoading: false,
91       // 显示搜索条件
92       showSearch: true,
93       // 总条数
94       total: 0,
95       // 示例联系人列表
96       list: [],
97       // 是否展开,默认全部展开
98       isExpandAll: true,
99       // 重新渲染表格状态
100       refreshTable: true,
101       // 选中行
102       currentRow: {},
103       // 查询参数
104       queryParams: {
105         pageNo: 1,
106         pageSize: 10,
107         name: null,
108         sex: null,
109         birthday: null,
110         description: null,
111         avatar: null,
112         createTime: [],
113       },
114     };
115   },
116   created() {
117     this.getList();
118   },
119   methods: {
120     /** 查询列表 */
121     async getList() {
122       try {
123         this.loading = true;
124         const res = await Demo01ContactApi.getDemo01ContactPage(this.queryParams);
125         this.list = res.data.list;
126         this.total = res.data.total;
127       } finally {
128         this.loading = false;
129       }
130     },
131     /** 搜索按钮操作 */
132     handleQuery() {
133       this.queryParams.pageNo = 1;
134       this.getList();
135     },
136     /** 重置按钮操作 */
137     resetQuery() {
138       this.resetForm("queryForm");
139       this.handleQuery();
140     },
141     /** 添加/修改操作 */
142     openForm(id) {
143       this.$refs["formRef"].open(id);
144     },
145     /** 删除按钮操作 */
146     async handleDelete(row) {
147       const id = row.id;
148       await this.$modal.confirm('是否确认删除示例联系人编号为"' + id + '"的数据项?')
149       try {
150         await Demo01ContactApi.deleteDemo01Contact(id);
151         await this.getList();
152         this.$modal.msgSuccess("删除成功");
153       } catch {}
154     },
155     /** 导出按钮操作 */
156     async handleExport() {
157       await this.$modal.confirm('是否确认导出所有示例联系人数据项?');
158       try {
159         this.exportLoading = true;
160         const res = await Demo01ContactApi.exportDemo01ContactExcel(this.queryParams);
161         this.$download.excel(res.data, '示例联系人.xls');
162       } catch {
163       } finally {
164         this.exportLoading = false;
165       }
166     },
167   }
168 };
169 </script>