Commit ac470ab1 authored by 水落(YangLei)'s avatar 水落(YangLei)

Merge branch 'master' into feature/shuiluo

parents 8df0af8f b9748521
...@@ -50,20 +50,38 @@ export default { ...@@ -50,20 +50,38 @@ export default {
}, },
row: Object, row: Object,
}, },
watch: {
row() {
this.init();
},
},
data() {
return {
buttonsArr: [],
};
},
created() {
this.init();
},
computed: { computed: {
basicBtns() { basicBtns() {
return this.buttons.length > 3 ? this.buttons.slice(0, 3) : this.buttons; return this.buttonsArr.length > 3 ? this.buttonsArr.slice(0, 3) : this.buttonsArr;
}, },
moreBtns() { moreBtns() {
return this.buttons.length > 3 ? this.buttons.slice(3) : []; return this.buttonsArr.length > 3 ? this.buttonsArr.slice(3) : [];
}, },
}, },
methods: { methods: {
getDelUrl(url, row) { getDelUrl(url, row) {
if (isFunction(url)) return url(row); if (isFunction(url)) return url(row);
return url; return url;
}, },
init() {
this.buttons.map((i) => {
i.__hidden__ = i.isHidden && i.isHidden(this.row);
});
this.buttonsArr = this.buttons.filter((i) => !i.__hidden__);
},
}, },
}; };
</script> </script>
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
<script> <script>
import { EMPTY_FUN } from '@/utils'; import { EMPTY_FUN } from '@/utils';
import { delReq } from '@/utils'; import { delReq, getReq, postReq, putReq } from '@/utils';
export default { export default {
props: { props: {
url: String, url: [String, Object],
cb: { cb: {
type: Function, type: Function,
default: EMPTY_FUN, default: EMPTY_FUN,
...@@ -30,9 +30,25 @@ export default { ...@@ -30,9 +30,25 @@ export default {
}, },
methods: { methods: {
async confirm() { async confirm() {
if (this.url) { if (typeof this.url === 'string') {
await delReq(this.url); await delReq(this.url);
} }
if (typeof this.url === 'object') {
switch (this.url.method) {
case 'get':
await getReq(this.url.url, this.url?.data);
break;
case 'post':
await postReq(this.url.url, this.url?.data);
break;
case 'put':
await putReq(this.url.url, this.url?.data);
break;
case 'del':
await delReq(this.url.url, this.url?.data);
break;
}
}
if (this.onOk) { if (this.onOk) {
await this.onOk(); await this.onOk();
} }
......
<template> <template>
<a-drawer <a-drawer
placement="right" placement="right"
:visible="visible" :visible="value"
:drawerStyle="drawerStyle" :drawerStyle="drawerStyle"
:bodyStyle="bodyStyle" :bodyStyle="bodyStyle"
destroyOnClose destroyOnClose
:width="600"
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners"
@close="onClose"
> >
<div class="tw-overflow-y-hidden"> <div class="tw-overflow-y-hidden tw-flex-1">
<div class="tw-overflow-y-auto tw-h-full"> <div class="tw-overflow-y-auto tw-h-full">
<slot /> <slot />
</div> </div>
</div> </div>
<template> <template>
<a-divider /> <a-divider />
<a-space> <a-space class="tw-justify-end">
<slot name="footer">
<a-button @click="cancel">取消</a-button> <a-button @click="cancel">取消</a-button>
<slot name="footer">
<a-button type="primary" @click="ok" :loading="loading">确认</a-button> <a-button type="primary" @click="ok" :loading="loading">确认</a-button>
</slot> </slot>
</a-space> </a-space>
...@@ -29,10 +32,14 @@ export default { ...@@ -29,10 +32,14 @@ export default {
props: { props: {
oncancel: Function, oncancel: Function,
onok: Function, onok: Function,
value: Boolean,
},
model: {
prop: 'value',
event: 'change',
}, },
data() { data() {
return { return {
visiable: false,
loading: false, loading: false,
drawerStyle: { drawerStyle: {
display: 'flex', display: 'flex',
...@@ -48,21 +55,18 @@ export default { ...@@ -48,21 +55,18 @@ export default {
}; };
}, },
methods: { methods: {
show() {
this.visiable = true;
},
hidden() {
this.visiable = false;
},
cancel() { cancel() {
this.oncancel && this.oncancel(); this.oncancel && this.oncancel();
this.visiable = false; this.$emit('change', false);
},
onClose() {
this.cancel();
}, },
async ok() { async ok() {
this.loading = true; this.loading = true;
await (this.onok && this.onok()); await (this.onok && this.onok());
this.loading = false; this.loading = false;
this.visiable = false; this.$emit('change', false);
}, },
}, },
}; };
......
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
<a-button v-if="addBtn" type="primary" key="add" v-bind="addBtn.options" @click="add"> <a-button v-if="addBtn" type="primary" key="add" v-bind="addBtn.options" @click="add">
{{ addBtn.text || '新建' }} {{ addBtn.text || '新建' }}
</a-button> </a-button>
<template v-for="btn of buttons"> <slot name="buttons" />
<a-button :type="btn.primary" :key="btn.text">{{ btn.text }}</a-button>
</template>
</a-space> </a-space>
<div class="tw-mb-2"> <div class="tw-mb-2">
<a-alert <a-alert
...@@ -65,12 +63,13 @@ ...@@ -65,12 +63,13 @@
</div> </div>
<template v-if="!noFooter"> <template v-if="!noFooter">
<a-divider /> <a-divider />
<a-space> <a-space class="tw-justify-end">
<a-button @click="addVisible = false">取消</a-button> <a-button @click="addVisible = false">取消</a-button>
<a-button type="primary" @click="submit" :loading="submitLoading"> 确认 </a-button> <a-button type="primary" @click="submit" :loading="submitLoading"> 确认 </a-button>
</a-space> </a-space>
</template> </template>
</a-drawer> </a-drawer>
<slot name="children"></slot>
</div> </div>
</template> </template>
......
<template> <template>
<my-table url="/api/v1/users" rowKey="userId" :addBtn="addBtn" ref="table"> <my-table url="/api/v1/users" rowKey="userId" ref="table">
<template #drawer>
<Form ref="form" />
</template>
<template #search="{ query }"> <template #search="{ query }">
<my-form-item label="归属部门"> <my-form-item label="归属部门">
<OrganizationTree v-model="query.orgId" /> <OrganizationTree v-model="query.orgId" />
...@@ -11,6 +8,9 @@ ...@@ -11,6 +8,9 @@
<a-input placeholder="Basic usage" v-model="query.loginId" /> <a-input placeholder="Basic usage" v-model="query.loginId" />
</my-form-item> </my-form-item>
</template> </template>
<template #buttons>
<a-button type="primary" @click="onAdd">新增</a-button>
</template>
<a-table-column title="账号" data-index="loginId" /> <a-table-column title="账号" data-index="loginId" />
<a-table-column title="姓名" data-index="userName" /> <a-table-column title="姓名" data-index="userName" />
...@@ -21,36 +21,95 @@ ...@@ -21,36 +21,95 @@
<a-table-column title="是否锁定" data-index="isLockedName" /> <a-table-column title="是否锁定" data-index="isLockedName" />
<a-table-column title="操作"> <a-table-column title="操作">
<template #default="row"> <template #default="row">
<a @click="() => view(row, 1)">编辑</a> <ActionButton :buttons="buttons" :row="row" />
<a-divider type="vertical" />
<PopconfirmDelete :url="`/api/v1/jobs/${row.jobId}`" :cb="refreshTable" />
</template> </template>
</a-table-column> </a-table-column>
<template #children>
<Form ref="form" />
</template>
</my-table> </my-table>
</template> </template>
<script> <script>
import Form from './form.vue'; import Form from './form.vue';
import PopconfirmDelete from '@/components/popconfirm_delete/index.vue'; import ActionButton from '@/components/action_button/index.vue';
import OrganizationTree from '../components/OrganizationTree.vue'; import OrganizationTree from '../components/OrganizationTree.vue';
export default { export default {
components: { Form, PopconfirmDelete, OrganizationTree }, components: { Form, OrganizationTree, ActionButton },
data() { data() {
return { return {
addBtn: { width: 600, onOk: () => this.$refs['form']?.submit() }, buttons: [
span: { xs: 12, md: 8, lg: 6 }, {
label: '编辑',
click: (row) => {},
},
{
type: 'confirm',
url: (row) => `/api/v1/jobs/${row.jobId}`,
after: () => this.refreshTable(),
isHidden: (row) => {
return row.userId === 1;
},
},
{
type: 'confirm',
label: '重置',
title: '确认是否重置?',
url: (row) => {
return {
url: `/api/v1/users/${row.userId}/resetting`,
method: 'put',
};
},
after: () => this.refreshTable(),
},
{
type: 'confirm',
label: '解锁',
title: '确认是否解锁?',
url: (row) => {
return {
url: `/api/v1/users/${row.userId}/unlocking`,
method: 'put',
};
},
after: () => this.refreshTable(),
isHidden: (row) => {
return !row.isLocked;
},
},
{
type: 'confirm',
label: '锁定',
title: '确认是否锁定?',
url: (row) => {
return {
url: `/api/v1/users/${row.userId}/locking`,
method: 'put',
};
},
after: () => this.refreshTable(),
isHidden: (row) => {
return !!row.isLocked;
},
},
],
}; };
}, },
methods: { methods: {
refreshTable() { refreshTable() {
this.$refs['table']?.getData(); this.$refs['table']?.getData();
}, },
view(data, type) { onAdd() {
this.$refs['table']?.show({ type }); this.$refs['form']?.open();
this.$nextTick(() => {
this.$refs['form'].setData({ ...data }, type);
});
}, },
// view(data, type) {
// this.$refs['table']?.show({ type });
// this.$nextTick(() => {
// this.$refs['form'].setData({ ...data }, type);
// });
// },
}, },
}; };
</script> </script>
<template> <template>
<a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm"> <Drawer ref="drawerRef" v-model="visible" title="用户配置">
<!-- <a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm">
<a-form-model-item label="名称" prop="jobName"> <a-form-model-item label="名称" prop="jobName">
<a-input v-model="form.jobName" :disabled="isView" /> <a-input v-model="form.jobName" :disabled="isView" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="描述" prop="jobDescription"> <a-form-model-item label="描述" prop="jobDescription">
<a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" /> <a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" />
</a-form-model-item> </a-form-model-item>
</a-form-model> -->
<a-steps :current="current">
<a-step v-for="item in steps" :key="item.title" :title="item.title" />
</a-steps>
<a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm">
<a-form-model-item label="名称" prop="jobName">
<a-input v-model="form.jobName" :disabled="isView" />
</a-form-model-item>
</a-form-model> </a-form-model>
<template #footer>
<a-button type="primary" @click="prev" v-if="current > 0"> 上一步 </a-button>
<a-button type="primary" @click="next" v-if="current < 2"> 下一步 </a-button>
</template>
</Drawer>
</template> </template>
<script> <script>
import Drawer from '@/components/table/drawer.vue';
import JobsApi from '@/api/organization'; import JobsApi from '@/api/organization';
import FormMixin from '@/components/FormMixin'; import FormMixin from '@/components/FormMixin';
export default { export default {
components: { Drawer },
mixins: [FormMixin], mixins: [FormMixin],
data() { data() {
return { return {
visible: false,
rules: { rules: {
jobName: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }], jobName: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }],
jobDescription: [ jobDescription: [
{ required: true, message: 'Please select Activity zone', trigger: 'change' }, { required: true, message: 'Please select Activity zone', trigger: 'change' },
], ],
}, },
current: 0,
steps: [
{
title: '基本信息',
},
{
title: '证件设置',
},
{
title: '岗位设置',
},
],
}; };
}, },
methods: { methods: {
open() {
this.visible = true;
},
next() {
this.current++;
},
prev() {
this.current--;
},
add() { add() {
return JobsApi.addJobs({ ...this.form }); return JobsApi.addJobs({ ...this.form });
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment