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>
9         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
10         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
11       </el-form-item>
12     </el-form>
13
14     <!-- 操作工具栏 -->
15     <el-row :gutter="10" class="mb8">
16       <el-col :span="1.5">
17         <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
18                    v-hasPermi="['bpm:form:create']">新增</el-button>
19       </el-col>
20       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
21     </el-row>
22
23     <!-- 列表 -->
24     <el-table v-loading="loading" :data="list">
25       <el-table-column label="编号" align="center" prop="id" />
26       <el-table-column label="表单名" align="center" prop="name" />
27       <el-table-column label="开启状态" align="center" prop="status">
28         <template v-slot="scope">
29           <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
30         </template>
31       </el-table-column>
32       <el-table-column label="备注" align="center" prop="remark" />
33       <el-table-column label="创建时间" align="center" prop="createTime" width="180">
34         <template v-slot="scope">
35           <span>{{ parseTime(scope.row.createTime) }}</span>
36         </template>
37       </el-table-column>
38       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
39         <template v-slot="scope">
40           <el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row)"
41                      v-hasPermi="['bpm:form:query']">详情</el-button>
42           <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
43                      v-hasPermi="['bpm:form:update']">修改</el-button>
44           <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
45                      v-hasPermi="['bpm:form:delete']">删除</el-button>
46         </template>
47       </el-table-column>
48     </el-table>
49     <!-- 分页组件 -->
50     <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
51                 @pagination="getList"/>
52
53     <!--表单配置详情-->
54     <el-dialog title="表单详情" :visible.sync="detailOpen" width="50%" append-to-body>
55       <div class="test-form">
56         <parser :key="new Date().getTime()" :form-conf="detailForm" />
57       </div>
58     </el-dialog>
59   </div>
60 </template>
61
62 <script>
63 import {deleteForm, getForm, getFormPage} from "@/api/bpm/form";
64 import Parser from '@/components/parser/Parser'
65 import {decodeFields} from "@/utils/formGenerator";
66
67 export default {
68   name: "BpmForm",
69   components: {
70     Parser
71   },
72   data() {
73     return {
74       // 遮罩层
75       loading: true,
76       // 显示搜索条件
77       showSearch: true,
78       // 总条数
79       total: 0,
80       // 工作流的列表
81       list: [],
82       // 查询参数
83       queryParams: {
84         pageNo: 1,
85         pageSize: 10,
86         name: null,
87       },
88       // 表单详情
89       detailOpen: false,
90       detailForm: {
91         fields: []
92       }
93     };
94   },
95   created() {
96     this.getList();
97   },
98   methods: {
99     /** 查询列表 */
100     getList() {
101       this.loading = true;
102       // 执行查询
103       getFormPage(this.queryParams).then(response => {
104         this.list = response.data.list;
105         this.total = response.data.total;
106         this.loading = false;
107       });
108     },
109     /** 搜索按钮操作 */
110     handleQuery() {
111       this.queryParams.pageNo = 1;
112       this.getList();
113     },
114     /** 重置按钮操作 */
115     resetQuery() {
116       this.resetForm("queryForm");
117       this.handleQuery();
118     },
119     /** 详情按钮操作 */
120     handleDetail(row) {
121       getForm(row.id).then(response => {
122         // 设置值
123         const data = response.data
124         this.detailForm = {
125           ...JSON.parse(data.conf),
126           fields: decodeFields(data.fields)
127         }
128         // 弹窗打开
129         this.detailOpen = true
130       })
131     },
132     /** 新增按钮操作 */
133     handleAdd() {
134       this.$router.push({
135         name: "BpmFormEditor"
136       });
137     },
138     /** 修改按钮操作 */
139     handleUpdate(row) {
140       this.$router.push({
141         name: "BpmFormEditor",
142         query:{
143           formId: row.id
144         }
145       });
146     },
147     /** 删除按钮操作 */
148     handleDelete(row) {
149       const id = row.id;
150       this.$modal.confirm('是否确认删除工作表单的编号为"' + id + '"的数据项?').then(function() {
151         return deleteForm(id);
152       }).then(() => {
153         this.getList();
154         this.$modal.msgSuccess("删除成功");
155       }).catch(() => {});
156     }
157   }
158 };
159 </script>