From df6b3c1440805b0adb1a0772929de560f83fdfcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9=E7=8E=AE?= Date: Mon, 28 Jun 2021 16:03:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/organization.js | 12 ------ src/components/FormMixin/index.js | 34 +++++++++++++++ src/components/table/index.vue | 20 +++++++-- .../jobmanagement/JobManagement.vue | 16 +++---- .../view/organization/jobmanagement/form.vue | 43 +++++++------------ 5 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 src/components/FormMixin/index.js diff --git a/src/api/organization.js b/src/api/organization.js index db07227..a7ba9d7 100644 --- a/src/api/organization.js +++ b/src/api/organization.js @@ -1,17 +1,5 @@ import { delReq, getReq, postReq, putReq } from '@/utils'; -// export function delMenuApi(id) { -// return delReq(`/api/v1/menus/${id}`); -// } - -// export function getMenuDataApi() { -// return getReq('/api/v1/menus'); -// } - -// export function addMenuApi(data) { -// return postReq('/api/v1/menus', data); -// } - function addJobsApi(data) { return postReq('/api/v1/jobs', data); } diff --git a/src/components/FormMixin/index.js b/src/components/FormMixin/index.js new file mode 100644 index 0000000..cb43e98 --- /dev/null +++ b/src/components/FormMixin/index.js @@ -0,0 +1,34 @@ +export default { + data() { + return { + type: 0, + form: {}, + }; + }, + computed: { + isAdd() { + return this.type === 0; + }, + isEdit() { + return this.type === 1; + }, + isView() { + return this.type === 2; + }, + }, + methods: { + async submit() { + await this.$refs.DrawerForm.validate(); + if (this.isAdd) { + return this?.add(); + } + if (this.isEdit) { + return this?.edit(); + } + }, + setData(data, type) { + this.form = data; + this.type = type; + }, + }, +}; diff --git a/src/components/table/index.vue b/src/components/table/index.vue index 3092465..5ad8709 100644 --- a/src/components/table/index.vue +++ b/src/components/table/index.vue @@ -30,13 +30,12 @@
- +
@@ -78,6 +77,7 @@ export default { pageSize: 10, }; return { + title: '新增', data: [], queryForm: { ...this.initQuery, @@ -147,7 +147,19 @@ export default { } this.submitLoading = false; }, - showAdd() { + show({ type, title } = {}) { + if (type === 0) { + this.title = '新增'; + } + if (type === 1) { + this.title = '编辑'; + } + if (type === 2) { + this.title = '查看'; + } + if (title) { + this.title = title; + } this.addVisible = true; }, }, diff --git a/src/pages/system/view/organization/jobmanagement/JobManagement.vue b/src/pages/system/view/organization/jobmanagement/JobManagement.vue index 55c4e51..4bd4e93 100644 --- a/src/pages/system/view/organization/jobmanagement/JobManagement.vue +++ b/src/pages/system/view/organization/jobmanagement/JobManagement.vue @@ -1,21 +1,21 @@