|
@@ -4,20 +4,31 @@
|
|
* @Author: Cheney
|
|
* @Author: Cheney
|
|
*/
|
|
*/
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
|
|
+import { useResponse } from '/@/utils/useResponse';
|
|
|
|
+import * as api from '../api';
|
|
|
|
+import { Close, Finished } from '@element-plus/icons-vue';
|
|
|
|
|
|
|
|
|
|
-const { rowData } = defineProps<{
|
|
|
|
- rowData: object;
|
|
|
|
-}>();
|
|
|
|
|
|
+const props = defineProps({
|
|
|
|
+ rowData: Object
|
|
|
|
+});
|
|
|
|
+const { rowData } = props;
|
|
|
|
|
|
const dialogVisible = defineModel({ default: false });
|
|
const dialogVisible = defineModel({ default: false });
|
|
|
|
|
|
|
|
+const noticeDialog = <Ref>useTemplateRef('noticeDialog');
|
|
|
|
+
|
|
const staffSelect = ref('');
|
|
const staffSelect = ref('');
|
|
const staffOptions: any = ref([]);
|
|
const staffOptions: any = ref([]);
|
|
const staffTags: any = ref([]);
|
|
const staffTags: any = ref([]);
|
|
const staffLoading = ref(false);
|
|
const staffLoading = ref(false);
|
|
const currentRow: any = ref(null);
|
|
const currentRow: any = ref(null);
|
|
|
|
|
|
|
|
+onBeforeMount(() => {
|
|
|
|
+ fetchStaffsOptions();
|
|
|
|
+ fetchExistingStaff();
|
|
|
|
+});
|
|
|
|
+
|
|
function handleClose(done: any) {
|
|
function handleClose(done: any) {
|
|
staffSelect.value = '';
|
|
staffSelect.value = '';
|
|
staffTags.value = [];
|
|
staffTags.value = [];
|
|
@@ -40,47 +51,52 @@ function isOptionDisabled(id: any) {
|
|
}
|
|
}
|
|
|
|
|
|
function removeTag(tag: any) {
|
|
function removeTag(tag: any) {
|
|
|
|
+ console.log('tag=> ', tag);
|
|
staffTags.value = staffTags.value.filter((t: any) => t.id !== tag.id);
|
|
staffTags.value = staffTags.value.filter((t: any) => t.id !== tag.id);
|
|
|
|
+ staffSelect.value = '';
|
|
}
|
|
}
|
|
|
|
|
|
-async function fetchExistingStaff(row: any) {
|
|
|
|
- const query = {
|
|
|
|
- id: row.value.id ? row.value.id : row.value.rowid
|
|
|
|
- };
|
|
|
|
- // const resp = await api.getExistingStaffs(query);
|
|
|
|
- // staffTags.value = resp.data;
|
|
|
|
|
|
+async function fetchStaffsOptions() {
|
|
|
|
+ const res = await useResponse(api.getStaffsOptions);
|
|
|
|
+ staffOptions.value = res.data;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+async function fetchExistingStaff() {
|
|
|
|
+ const resp = await useResponse(api.getExistingStaffs, {
|
|
|
|
+ id: rowData?.id ? rowData?.id : rowData?.rowid
|
|
|
|
+ });
|
|
|
|
+ staffTags.value = resp.data;
|
|
}
|
|
}
|
|
|
|
|
|
async function addStaffs() {
|
|
async function addStaffs() {
|
|
- staffLoading.value = true;
|
|
|
|
const body = {
|
|
const body = {
|
|
- id: currentRow.id,
|
|
|
|
- user_ids: staffTags.map((tag: any) => tag.id)
|
|
|
|
|
|
+ id: rowData?.id,
|
|
|
|
+ user_ids: staffTags.value.map((tag: any) => tag.id)
|
|
};
|
|
};
|
|
try {
|
|
try {
|
|
- // const resp = await api.postStaffs(body);
|
|
|
|
- // if (resp.code === 2000) {
|
|
|
|
- // ElMessage.error('编辑成功!');
|
|
|
|
- // await fetchExistingStaff(currentRow);
|
|
|
|
- // }
|
|
|
|
|
|
+ const resp = await useResponse(api.postStaffs, body, staffLoading)
|
|
|
|
+ if (resp.code === 2000) {
|
|
|
|
+ ElMessage.success('编辑成功!');
|
|
|
|
+ fetchExistingStaff();
|
|
|
|
+ }
|
|
} catch (error) {
|
|
} catch (error) {
|
|
ElMessage.error('编辑失败!');
|
|
ElMessage.error('编辑失败!');
|
|
} finally {
|
|
} finally {
|
|
staffSelect.value = '';
|
|
staffSelect.value = '';
|
|
- staffLoading.value = false;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function cancelDialog() {
|
|
function cancelDialog() {
|
|
- handleClose(() => {
|
|
|
|
- dialogVisible.value = false;
|
|
|
|
- });
|
|
|
|
|
|
+ staffSelect.value = '';
|
|
|
|
+ staffTags.value = [];
|
|
|
|
+ noticeDialog.value.visible = false;
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<el-dialog
|
|
<el-dialog
|
|
|
|
+ ref="noticeDialog"
|
|
v-model="dialogVisible"
|
|
v-model="dialogVisible"
|
|
:before-close="handleClose"
|
|
:before-close="handleClose"
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
@@ -103,29 +119,34 @@ function cancelDialog() {
|
|
</el-select>
|
|
</el-select>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
- <el-row :gutter="20">
|
|
|
|
|
|
+ <el-row :gutter="20" class="mb-4">
|
|
<el-col :span="2">
|
|
<el-col :span="2">
|
|
-
|
|
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="20" class="ml-2.5">
|
|
<el-col :span="20" class="ml-2.5">
|
|
<i class="bi bi-info-circle"></i>
|
|
<i class="bi bi-info-circle"></i>
|
|
<span class="ml-1" style="color: #909399">仅可添加已绑定邮箱的用户</span>
|
|
<span class="ml-1" style="color: #909399">仅可添加已绑定邮箱的用户</span>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
- <el-divider style="margin: 12px 0 20px 0"></el-divider>
|
|
|
|
- <div class="flex flex-wrap gap-1.5">
|
|
|
|
|
|
+ <div class="flex flex-wrap gap-1.5 min-h-6">
|
|
<el-tag
|
|
<el-tag
|
|
v-for="tag in staffTags"
|
|
v-for="tag in staffTags"
|
|
:key="tag.id"
|
|
:key="tag.id"
|
|
closable
|
|
closable
|
|
|
|
+ round
|
|
|
|
+ effect="plain"
|
|
@close="removeTag(tag)">
|
|
@close="removeTag(tag)">
|
|
{{ tag.username }}
|
|
{{ tag.username }}
|
|
</el-tag>
|
|
</el-tag>
|
|
</div>
|
|
</div>
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
|
- <el-button @click="cancelDialog">取 消</el-button>
|
|
|
|
- <el-button :loading="staffLoading" type="primary" @click="addStaffs">确 定</el-button>
|
|
|
|
- </span>
|
|
|
|
|
|
+
|
|
|
|
+ <el-divider style="margin: 12px 0 20px 0"></el-divider>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <el-button :icon="Close" @click="cancelDialog">取 消</el-button>
|
|
|
|
+ <el-button :icon="Finished" :loading="staffLoading" type="primary" @click="addStaffs">确 定</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ <!--<span slot="footer" class="dialog-footer">-->
|
|
|
|
+ <!-- -->
|
|
|
|
+ <!--</span>-->
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|