wyg
2024-06-14 a57dc2fae73d6e0dd315a120ca43ee685a6c7b7c
提交 | 用户 | 时间
a57dc2 1 <template>
W 2   <div class="app-container">
3     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
4       <el-form-item label="表单名称" prop="formName">
5         <el-input
6           v-model="queryParams.formName"
7           placeholder="请输入表单名称"
8           clearable
9           size="small"
10           @keyup.enter.native="handleQuery"
11         />
12       </el-form-item>
13       <el-form-item>
14         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
15         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
16       </el-form-item>
17     </el-form>
18
19     <el-row :gutter="10" class="mb8">
20       <el-col :span="1.5">
21         <el-button
22           type="primary"
23           plain
24           icon="el-icon-plus"
25           size="mini"
26           @click="handleAdd"
27           v-hasPermi="['workflow:form:add']"
28         >新增</el-button>
29       </el-col>
30       <el-col :span="1.5">
31         <el-button
32           type="success"
33           plain
34           icon="el-icon-edit"
35           size="mini"
36           :disabled="single"
37           @click="handleUpdate"
38           v-hasPermi="['workflow:form:edit']"
39         >修改</el-button>
40       </el-col>
41       <el-col :span="1.5">
42         <el-button
43           type="danger"
44           plain
45           icon="el-icon-delete"
46           size="mini"
47           :disabled="multiple"
48           @click="handleDelete"
49           v-hasPermi="['workflow:form:remove']"
50         >删除</el-button>
51       </el-col>
52       <el-col :span="1.5">
53         <el-button
54           type="warning"
55           plain
56           icon="el-icon-download"
57           size="mini"
58           @click="handleExport"
59           v-hasPermi="['workflow:form:export']"
60         >导出</el-button>
61       </el-col>
62       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
63     </el-row>
64
65     <el-table v-loading="loading" :data="formList" @selection-change="handleSelectionChange">
66       <el-table-column type="selection" width="55" align="center" />
67       <el-table-column label="表单主键" align="center" prop="formId" />
68       <el-table-column label="表单名称" align="center" prop="formName" />
69       <el-table-column label="备注" align="center" prop="remark" />
70       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
71         <template slot-scope="scope">
72           <el-button
73             size="mini"
74             type="text"
75             icon="el-icon-view"
76             @click="handleDetail(scope.row)"
77           >详情</el-button>
78           <el-button
79             size="mini"
80             type="text"
81             icon="el-icon-edit"
82             @click="handleUpdate(scope.row)"
83             v-hasPermi="['workflow:form:edit']"
84           >修改</el-button>
85           <el-button
86             size="mini"
87             type="text"
88             icon="el-icon-delete"
89             @click="handleDelete(scope.row)"
90             v-hasPermi="['workflow:form:remove']"
91           >删除</el-button>
92         </template>
93       </el-table-column>
94     </el-table>
95
96     <pagination
97       v-show="total>0"
98       :total="total"
99       :page.sync="queryParams.pageNum"
100       :limit.sync="queryParams.pageSize"
101       @pagination="getList"
102     />
103
104     <!-- 添加或修改流程表单对话框 -->
105     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
106       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
107         <el-form-item label="表单名称" prop="formName">
108           <el-input v-model="form.formName" placeholder="请输入表单名称" />
109         </el-form-item>
110         <el-form-item label="表单内容">
111           <editor v-model="form.content" :min-height="192"/>
112         </el-form-item>
113         <el-form-item label="备注" prop="remark">
114           <el-input v-model="form.remark" placeholder="请输入备注" />
115         </el-form-item>
116       </el-form>
117       <div slot="footer" class="dialog-footer">
118         <el-button type="primary" @click="submitForm">确 定</el-button>
119         <el-button @click="cancel">取 消</el-button>
120       </div>
121     </el-dialog>
122
123     <!--表单配置详情-->
124     <el-dialog :title="formTitle" :visible.sync="formConfOpen" width="60%" append-to-body>
125       <div class="test-form">
126         <parser :key="new Date().getTime()"  :form-conf="formConf" />
127       </div>
128     </el-dialog>
129   </div>
130 </template>
131
132 <script>
133 import { listForm, getForm, delForm, addForm, updateForm } from "@/api/workflow/form";
134 import Editor from '@/components/Editor';
135 import Parser from '@/utils/generator/parser'
136 export default {
137   name: "Form",
138   components: {
139     Editor,
140     Parser
141   },
142   data() {
143     return {
144       // 遮罩层
145       loading: true,
146       // 选中数组
147       ids: [],
148       // 非单个禁用
149       single: true,
150       // 非多个禁用
151       multiple: true,
152       // 显示搜索条件
153       showSearch: true,
154       // 总条数
155       total: 0,
156       // 流程表单表格数据
157       formList: [],
158       // 弹出层标题
159       title: "",
160       formConf: {}, // 默认表单数据
161       formConfOpen: false,
162       formTitle: "",
163       // 是否显示弹出层
164       open: false,
165       // 查询参数
166       queryParams: {
167         pageNum: 1,
168         pageSize: 10,
169         formName: null,
170         content: null,
171       },
172       // 表单参数
173       form: {},
174       // 表单校验
175       rules: {
176       }
177     };
178   },
179   created() {
180     this.getList();
181   },
182   activated() {
183     this.getList();
184   },
185   methods: {
186     /** 查询流程表单列表 */
187     getList() {
188       this.loading = true;
189       listForm(this.queryParams).then(response => {
190         this.formList = response.rows;
191         this.total = response.total;
192         this.loading = false;
193       });
194     },
195     // 取消按钮
196     cancel() {
197       this.open = false;
198       this.reset();
199     },
200     // 表单重置
201     reset() {
202       this.form = {
203         formId: null,
204         formName: null,
205         content: null,
206         createTime: null,
207         updateTime: null,
208         createBy: null,
209         updateBy: null,
210         remark: null
211       };
212       this.resetForm("form");
213     },
214     /** 搜索按钮操作 */
215     handleQuery() {
216       this.queryParams.pageNum = 1;
217       this.getList();
218     },
219     /** 重置按钮操作 */
220     resetQuery() {
221       this.resetForm("queryForm");
222       this.handleQuery();
223     },
224     // 多选框选中数据
225     handleSelectionChange(selection) {
226       this.ids = selection.map(item => item.formId)
227       this.single = selection.length!==1
228       this.multiple = !selection.length
229     },
230     /** 表单配置信息 */
231     handleDetail(row){
232       this.formConfOpen = true;
233       this.formTitle = "流程表单配置详细";
234       this.formConf = JSON.parse(row.content)
235     },
236     /** 新增按钮操作 */
237     handleAdd() {
238       // this.reset();
239       // this.open = true;
240       // this.title = "添加流程表单";
241       this.$router.push({ path: '/tool/build/index', query: {formId: null }})
242     },
243     /** 修改按钮操作 */
244     handleUpdate(row) {
245       // this.reset();
246       // const formId = row.formId || this.ids
247       // getForm(formId).then(response => {
248       //   this.form = response.data;
249       //   this.open = true;
250       //   this.title = "修改流程表单";
251       // });
252       this.$router.push({ path: '/tool/build/index', query: {formId: row.formId }})
253     },
254     /** 提交按钮 */
255     submitForm() {
256       this.$refs["form"].validate(valid => {
257         if (valid) {
258           if (this.form.formId != null) {
259             updateForm(this.form).then(response => {
260               this.$modal.msgSuccess("修改成功");
261               this.open = false;
262               this.getList();
263             });
264           } else {
265             addForm(this.form).then(response => {
266               this.$modal.msgSuccess("新增成功");
267               this.open = false;
268               this.getList();
269             });
270           }
271         }
272       });
273     },
274     /** 删除按钮操作 */
275     handleDelete(row) {
276       const formIds = row.formId || this.ids;
277       this.$confirm('是否确认删除流程表单编号为"' + formIds + '"的数据项?', "警告", {
278         confirmButtonText: "确定",
279         cancelButtonText: "取消",
280         type: "warning"
281       }).then(function() {
282         return delForm(formIds);
283       }).then(() => {
284         this.getList();
285         this.$modal.msgSuccess("删除成功");
286       })
287     },
288     /** 导出按钮操作 */
289     handleExport() {
290       let _this = this
291       this.$confirm('是否确认导出所有流程表单数据项?', "警告", {
292         confirmButtonText: "确定",
293         cancelButtonText: "取消",
294         type: "warning"
295       }).then(function() {
296         _this.download('/workflow/form/export', {
297         ..._this.queryParams
298       }, `form_${new Date().getTime()}.xlsx`)
299       })
300     }
301   }
302 };
303 </script>
304
305 <style lang="scss" scoped>
306 .test-form {
307   margin: 15px auto;
308   width: 800px;
309   padding: 15px;
310 }
311 </style>