当前位置:   article > 正文

ruoyi-nbcio-plus基于vue3的flowable的自定义业务单表例子的升级修改_vue2 size="medium

vue2 size="medium

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统 http://122.227.135.243:9666/

更多nbcio-boot功能请看演示系统 

gitee源代码地址

后端代码: https://gitee.com/nbacheng/nbcio-boot

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://122.227.135.243:9888

1、原先demo的vue2代码如下:

  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="用户账号" prop="userName">
  5. <el-input
  6. v-model="queryParams.userName"
  7. placeholder="请输入用户账号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="用户昵称" prop="nickName">
  13. <el-input
  14. v-model="queryParams.nickName"
  15. placeholder="请输入用户昵称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="用户邮箱" prop="email">
  21. <el-input
  22. v-model="queryParams.email"
  23. placeholder="请输入用户邮箱"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="头像地址" prop="avatar">
  29. <el-input
  30. v-model="queryParams.avatar"
  31. placeholder="请输入头像地址"
  32. clearable
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="primary"
  45. plain
  46. icon="el-icon-plus"
  47. size="mini"
  48. @click="handleAdd"
  49. v-hasPermi="['workflow:demo:add']"
  50. >新增</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="success"
  55. plain
  56. icon="el-icon-edit"
  57. size="mini"
  58. :disabled="single"
  59. @click="handleUpdate"
  60. v-hasPermi="['workflow:demo:edit']"
  61. >修改</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="danger"
  66. plain
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['workflow:demo:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="warning"
  77. plain
  78. icon="el-icon-download"
  79. size="mini"
  80. @click="handleExport"
  81. v-hasPermi="['workflow:demo:export']"
  82. >导出</el-button>
  83. </el-col>
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="demoList" @selection-change="handleSelectionChange">
  87. <el-table-column type="selection" width="30" align="center" />
  88. <el-table-column label="用户ID" align="center" prop="demoId" v-if="true"/>
  89. <el-table-column label="用户账号" align="center" prop="userName" />
  90. <el-table-column label="用户昵称" align="center" prop="nickName" />
  91. <el-table-column label="流程状态" align="center" prop="actStatus" />
  92. <el-table-column label="待处理节点" align="center" prop="taskName" />
  93. <el-table-column label="处理人" align="center" prop="todoUsers" />
  94. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  95. <template slot-scope="scope">
  96. <act-apply-btn @success="getList" :data-id="String(scope.row.demoId)" :serviceName="serviceName" :variables="scope.row"></act-apply-btn>
  97. <!--<act-handle-btn @success="getList" :data-id="scope.row.demoId" :type="0" text="通过"></act-handle-btn>
  98. <act-handle-btn @success="getList" :data-id="scope.row.demoId" :type="1" text="驳回"></act-handle-btn>
  99. <act-handle-btn @success="getList" :data-id="scope.row.demoId" :type="2" text="退回"></act-handle-btn>
  100. <act-cancel-btn @success="getList" :data-id="scope.row.demoId"></act-cancel-btn>-->
  101. <act-historic-detail-btn :data-id="String(scope.row.demoId)"></act-historic-detail-btn>
  102. <a-divider type="vertical" />
  103. <el-button
  104. size="medium"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['workflow:demo:edit']"
  109. >修改</el-button>
  110. <el-button
  111. size="medium"
  112. type="text"
  113. icon="el-icon-delete"
  114. @click="handleDelete(scope.row)"
  115. v-hasPermi="['workflow:demo:remove']"
  116. >删除</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <pagination
  121. v-show="total>0"
  122. :total="total"
  123. :page.sync="queryParams.pageNum"
  124. :limit.sync="queryParams.pageSize"
  125. @pagination="getList"
  126. />
  127. <!-- 添加或修改DEMO对话框 -->
  128. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  129. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  130. <el-form-item label="用户账号" prop="userName">
  131. <el-input v-model="form.userName" placeholder="请输入用户账号" />
  132. </el-form-item>
  133. <el-form-item label="用户昵称" prop="nickName">
  134. <el-input v-model="form.nickName" placeholder="请输入用户昵称" />
  135. </el-form-item>
  136. <el-form-item label="用户邮箱" prop="email">
  137. <el-input v-model="form.email" placeholder="请输入用户邮箱" />
  138. </el-form-item>
  139. <el-form-item label="头像地址" prop="avatar">
  140. <el-input v-model="form.avatar" placeholder="请输入头像地址" />
  141. </el-form-item>
  142. <el-form-item label="备注" prop="remark">
  143. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  144. </el-form-item>
  145. </el-form>
  146. <div slot="footer" class="dialog-footer">
  147. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  148. <el-button @click="cancel">取 消</el-button>
  149. </div>
  150. </el-dialog>
  151. </div>
  152. </template>
  153. <script>
  154. import { listDemo, getDemo, delDemo, addDemo, updateDemo } from "@/api/workflow/demo";
  155. import ActApplyBtn from "@/views/workflow/components/ActApplyBtn";
  156. import ActCancelBtn from "@/views/workflow/components/ActCancelBtn";
  157. import ActHandleBtn from "@/views/workflow/components/ActHandleBtn";
  158. import ActHistoricDetailBtn from "@/views/workflow/components/ActHistoricDetailBtn";
  159. export default {
  160. name: "Demo",
  161. components: {
  162. ActApplyBtn,
  163. ActCancelBtn,
  164. ActHandleBtn,
  165. ActHistoricDetailBtn
  166. },
  167. data() {
  168. return {
  169. // 按钮loading
  170. buttonLoading: false,
  171. // 遮罩层
  172. loading: true,
  173. // 选中数组
  174. ids: [],
  175. // 非单个禁用
  176. single: true,
  177. // 非多个禁用
  178. multiple: true,
  179. // 显示搜索条件
  180. showSearch: true,
  181. // 总条数
  182. total: 0,
  183. // DEMO表格数据
  184. demoList: [],
  185. // 弹出层标题
  186. title: "",
  187. // 是否显示弹出层
  188. open: false,
  189. // 查询参数
  190. queryParams: {
  191. pageNum: 1,
  192. pageSize: 10,
  193. userName: undefined,
  194. nickName: undefined,
  195. email: undefined,
  196. avatar: undefined,
  197. status: undefined,
  198. },
  199. serviceName: 'wfDemoService',
  200. // 表单参数
  201. form: {},
  202. // 表单校验
  203. rules: {
  204. demoId: [
  205. { required: true, message: "DEMO-ID不能为空", trigger: "blur" }
  206. ],
  207. userName: [
  208. { required: true, message: "用户账号不能为空", trigger: "blur" }
  209. ]
  210. }
  211. };
  212. },
  213. created() {
  214. this.getList();
  215. },
  216. methods: {
  217. /** 查询DEMO列表 */
  218. getList() {
  219. this.loading = true;
  220. listDemo(this.queryParams).then(response => {
  221. this.demoList = response.rows;
  222. this.total = response.total;
  223. this.loading = false;
  224. });
  225. },
  226. // 取消按钮
  227. cancel() {
  228. this.open = false;
  229. this.reset();
  230. },
  231. // 表单重置
  232. reset() {
  233. this.form = {
  234. demoId: undefined,
  235. userName: undefined,
  236. nickName: undefined,
  237. email: undefined,
  238. avatar: undefined,
  239. status: undefined,
  240. delFlag: undefined,
  241. createBy: undefined,
  242. createTime: undefined,
  243. updateBy: undefined,
  244. updateTime: undefined,
  245. remark: undefined
  246. };
  247. this.resetForm("form");
  248. },
  249. /** 搜索按钮操作 */
  250. handleQuery() {
  251. this.queryParams.pageNum = 1;
  252. this.getList();
  253. },
  254. /** 重置按钮操作 */
  255. resetQuery() {
  256. this.resetForm("queryForm");
  257. this.handleQuery();
  258. },
  259. // 多选框选中数据
  260. handleSelectionChange(selection) {
  261. this.ids = selection.map(item => item.demoId)
  262. this.single = selection.length!==1
  263. this.multiple = !selection.length
  264. },
  265. /** 新增按钮操作 */
  266. handleAdd() {
  267. this.reset();
  268. this.open = true;
  269. this.title = "添加DEMO";
  270. },
  271. /** 修改按钮操作 */
  272. handleUpdate(row) {
  273. this.loading = true;
  274. this.reset();
  275. const demoId = row.demoId || this.ids
  276. getDemo(demoId).then(response => {
  277. this.loading = false;
  278. this.form = response.data;
  279. this.open = true;
  280. this.title = "修改DEMO";
  281. });
  282. },
  283. /** 提交按钮 */
  284. submitForm() {
  285. this.$refs["form"].validate(valid => {
  286. if (valid) {
  287. this.buttonLoading = true;
  288. if (this.form.demoId != null) {
  289. updateDemo(this.form).then(response => {
  290. this.$modal.msgSuccess("修改成功");
  291. this.open = false;
  292. this.getList();
  293. }).finally(() => {
  294. this.buttonLoading = false;
  295. });
  296. } else {
  297. addDemo(this.form).then(response => {
  298. this.$modal.msgSuccess("新增成功");
  299. this.open = false;
  300. this.getList();
  301. }).finally(() => {
  302. this.buttonLoading = false;
  303. });
  304. }
  305. }
  306. });
  307. },
  308. /** 删除按钮操作 */
  309. handleDelete(row) {
  310. const demoIds = row.demoId || this.ids;
  311. this.$modal.confirm('是否确认删除DEMO编号为"' + demoIds + '"的数据项?').then(() => {
  312. this.loading = true;
  313. return delDemo(demoIds);
  314. }).then(() => {
  315. this.loading = false;
  316. this.getList();
  317. this.$modal.msgSuccess("删除成功");
  318. }).catch(() => {
  319. }).finally(() => {
  320. this.loading = false;
  321. });
  322. },
  323. /** 导出按钮操作 */
  324. handleExport() {
  325. this.download('workflow/demo/export', {
  326. ...this.queryParams
  327. }, `demo_${new Date().getTime()}.xlsx`)
  328. }
  329. }
  330. };
  331. </script>

2、修改后的vue3代码如下:

  1. <template>
  2. <div class="app-container">
  3. <el-form v-model="queryParams" ref="queryFormRef" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="用户账号" prop="userName">
  5. <el-input
  6. v-model="queryParams.userName"
  7. placeholder="请输入用户账号"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="用户昵称" prop="nickName">
  13. <el-input
  14. v-model="queryParams.nickName"
  15. placeholder="请输入用户昵称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="用户邮箱" prop="email">
  21. <el-input
  22. v-model="queryParams.email"
  23. placeholder="请输入用户邮箱"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="头像地址" prop="avatar">
  29. <el-input
  30. v-model="queryParams.avatar"
  31. placeholder="请输入头像地址"
  32. clearable
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="primary"
  45. plain
  46. icon="el-icon-plus"
  47. size="mini"
  48. @click="handleAdd"
  49. v-hasPermi="['workflow:demo:add']"
  50. >新增</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="success"
  55. plain
  56. icon="el-icon-edit"
  57. size="mini"
  58. :disabled="single"
  59. @click="handleUpdate"
  60. v-hasPermi="['workflow:demo:edit']"
  61. >修改</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="danger"
  66. plain
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['workflow:demo:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="warning"
  77. plain
  78. icon="el-icon-download"
  79. size="mini"
  80. @click="handleExport"
  81. v-hasPermi="['workflow:demo:export']"
  82. >导出</el-button>
  83. </el-col>
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="demoList" @selection-change="handleSelectionChange">
  87. <el-table-column type="selection" width="30" align="center" />
  88. <el-table-column label="用户ID" align="center" prop="demoId" v-if="true"/>
  89. <el-table-column label="用户账号" align="center" prop="userName" />
  90. <el-table-column label="用户昵称" align="center" prop="nickName" />
  91. <el-table-column label="流程状态" align="center" prop="actStatus" />
  92. <el-table-column label="待处理节点" align="center" prop="taskName" />
  93. <el-table-column label="处理人" align="center" prop="todoUsers" />
  94. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  95. <template slot-scope="scope">
  96. <act-apply-btn @success="getList" :data-id="String(scope.row.demoId)" :serviceName="serviceName" :variables="scope.row"></act-apply-btn>
  97. <!--<act-handle-btn @success="getList" :data-id="scope.row.demoId" :type="0" text="通过"></act-handle-btn>
  98. <act-handle-btn @success="getList" :data-id="scope.row.demoId" :type="1" text="驳回"></act-handle-btn>
  99. <act-handle-btn @success="getList" :data-id="scope.row.demoId" :type="2" text="退回"></act-handle-btn>
  100. <act-cancel-btn @success="getList" :data-id="scope.row.demoId"></act-cancel-btn>-->
  101. <act-historic-detail-btn :data-id="String(scope.row.demoId)"></act-historic-detail-btn>
  102. <a-divider type="vertical" />
  103. <el-button
  104. size="medium"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['workflow:demo:edit']"
  109. >修改</el-button>
  110. <el-button
  111. size="medium"
  112. type="text"
  113. icon="el-icon-delete"
  114. @click="handleDelete(scope.row)"
  115. v-hasPermi="['workflow:demo:remove']"
  116. >删除</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <pagination
  121. v-show="total>0"
  122. :total="total"
  123. :page.sync="queryParams.pageNum"
  124. :limit.sync="queryParams.pageSize"
  125. @pagination="getList"
  126. />
  127. <!-- 添加或修改DEMO对话框 -->
  128. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  129. <el-form ref="formRef" v-model="form" :rules="rules" label-width="80px">
  130. <el-form-item label="用户账号" prop="userName">
  131. <el-input v-model="form.userName" placeholder="请输入用户账号" />
  132. </el-form-item>
  133. <el-form-item label="用户昵称" prop="nickName">
  134. <el-input v-model="form.nickName" placeholder="请输入用户昵称" />
  135. </el-form-item>
  136. <el-form-item label="用户邮箱" prop="email">
  137. <el-input v-model="form.email" placeholder="请输入用户邮箱" />
  138. </el-form-item>
  139. <el-form-item label="头像地址" prop="avatar">
  140. <el-input v-model="form.avatar" placeholder="请输入头像地址" />
  141. </el-form-item>
  142. <el-form-item label="备注" prop="remark">
  143. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  144. </el-form-item>
  145. </el-form>
  146. <div slot="footer" class="dialog-footer">
  147. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  148. <el-button @click="cancel">取 消</el-button>
  149. </div>
  150. </el-dialog>
  151. </div>
  152. </template>
  153. <script setup name="WDemo" lang="ts">
  154. import { listDemo, getDemo, delDemo, addDemo, updateDemo } from "@/api/workflow/demo";
  155. import ActApplyBtn from "@/views/workflow/components/ActApplyBtn";
  156. import ActCancelBtn from "@/views/workflow/components/ActCancelBtn";
  157. import ActHandleBtn from "@/views/workflow/components/ActHandleBtn";
  158. import ActHistoricDetailBtn from "@/views/workflow/components/ActHistoricDetailBtn";
  159. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  160. const queryFormRef = ref(null)
  161. const formRef = ref(null)
  162. // 按钮loading
  163. const buttonLoading = ref(false)
  164. // 遮罩层
  165. const loading = ref(true)
  166. // 选中数组
  167. const ids = ref<any>([])
  168. // 非单个禁用
  169. const single = ref(true)
  170. // 非多个禁用
  171. const multiple = ref(true)
  172. // 显示搜索条件
  173. const showSearch = ref(true)
  174. // 总条数
  175. const total = ref(0)
  176. // DEMO表格数据
  177. const demoList = ref<any>([])
  178. // 弹出层标题
  179. const title = ref("")
  180. // 是否显示弹出层
  181. const open = ref(false)
  182. // 查询参数
  183. const queryParams = ref ({
  184. pageNum: 1,
  185. pageSize: 10,
  186. userName: undefined,
  187. nickName: undefined,
  188. email: undefined,
  189. avatar: undefined,
  190. status: undefined,
  191. })
  192. const serviceName = ref('wfDemoService')
  193. // 表单参数
  194. const form = ref<any>({})
  195. // 表单校验
  196. const rules = ref({
  197. demoId: [
  198. { required: true, message: "DEMO-ID不能为空", trigger: "blur" }
  199. ],
  200. userName: [
  201. { required: true, message: "用户账号不能为空", trigger: "blur" }
  202. ]
  203. })
  204. /** 查询DEMO列表 */
  205. const getList = () => {
  206. loading.value = true;
  207. listDemo(queryParams.value).then(response => {
  208. demoList.value = response.rows;
  209. total.value = response.total;
  210. loading.value = false;
  211. });
  212. }
  213. // 取消按钮
  214. const cancel = () => {
  215. open.value = false;
  216. reset();
  217. }
  218. // 表单重置
  219. const reset = () => {
  220. form.value = {
  221. demoId: undefined,
  222. userName: undefined,
  223. nickName: undefined,
  224. email: undefined,
  225. avatar: undefined,
  226. status: undefined,
  227. delFlag: undefined,
  228. createBy: undefined,
  229. createTime: undefined,
  230. updateBy: undefined,
  231. updateTime: undefined,
  232. remark: undefined
  233. };
  234. formRef.value?.resetFields();
  235. }
  236. /** 搜索按钮操作 */
  237. const handleQuery = () => {
  238. queryParams.value.pageNum = 1;
  239. getList();
  240. }
  241. /** 重置按钮操作 */
  242. const resetQuery = () => {
  243. queryFormRef.value?.resetFields();
  244. handleQuery();
  245. }
  246. // 多选框选中数据
  247. const handleSelectionChange = (selection) => {
  248. ids.value = selection.map(item => item.demoId)
  249. single.value = selection.length!==1
  250. multiple.value = !selection.length
  251. }
  252. /** 新增按钮操作 */
  253. const handleAdd = () => {
  254. reset();
  255. open.value = true;
  256. title.value = "添加DEMO";
  257. }
  258. /** 修改按钮操作 */
  259. const handleUpdate = (row) => {
  260. loading.value = true;
  261. reset();
  262. const demoId = row.demoId || ids.value
  263. getDemo(demoId).then(response => {
  264. loading.value = false;
  265. form.value = response.data;
  266. open.value = true;
  267. title.value = "修改DEMO";
  268. });
  269. }
  270. /** 提交按钮 */
  271. const submitForm = () => {
  272. formRef.validate(valid => {
  273. if (valid) {
  274. buttonLoading.value = true;
  275. if (form.value.demoId != null) {
  276. updateDemo(form.value).then(response => {
  277. proxy?.$modal.msgSuccess("修改成功");
  278. open.value = false;
  279. getList();
  280. }).finally(() => {
  281. buttonLoading.value = false;
  282. });
  283. } else {
  284. addDemo(form.value).then(response => {
  285. proxy?.$modal.msgSuccess("新增成功");
  286. open.value = false;
  287. getList();
  288. }).finally(() => {
  289. buttonLoading.value = false;
  290. });
  291. }
  292. }
  293. });
  294. }
  295. /** 删除按钮操作 */
  296. const handleDelete = (row) => {
  297. const demoIds = row.demoId || ids.value;
  298. proxy?.$modal.confirm('是否确认删除DEMO编号为"' + demoIds + '"的数据项?').then(() => {
  299. loading.value = true;
  300. return delDemo(demoIds);
  301. }).then(() => {
  302. loading.value = false;
  303. getList();
  304. proxy?.$modal.msgSuccess("删除成功");
  305. }).catch(() => {
  306. }).finally(() => {
  307. loading.value = false;
  308. });
  309. }
  310. /** 导出按钮操作 */
  311. const handleExport = () => {
  312. this.download('workflow/demo/export', {
  313. ...queryParams.value
  314. }, `demo_${new Date().getTime()}.xlsx`)
  315. }
  316. onMounted(() => {
  317. getList();
  318. })
  319. </script>

3、效果图图如下:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/436685
推荐阅读
相关标签
  

闽ICP备14008679号