index.vue 10 KB

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