|
@@ -6,54 +6,34 @@
|
|
|
<cSearch :is_title="false" :is_back="true" @toBack="toBack"></cSearch>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="two">
|
|
|
- <cForm :span="24" :fields="fields" :form="form" :rules="rules" @save="toSave" label-width="auto">
|
|
|
+ <cForm :span="24" :fields="fields" :form="form" :rules="{}" :isSave="false" label-width="auto" :disabled="true">
|
|
|
<template #administrator>
|
|
|
<el-option v-for="i in userList" :key="i._id" :label="i.name" :value="i._id"></el-option>
|
|
|
</template>
|
|
|
<template #logo>
|
|
|
- <cUpload :model="`${'logo'}`" listType="picture-card" :limit="1" url="/files/ball/team/upload" :list="form.logo" @change="onUpload"></cUpload>
|
|
|
+ <el-image class="image" v-for="i in form.logo" :key="i.uri" :src="i.url" @click="imgView(i.url)"></el-image>
|
|
|
</template>
|
|
|
<template #member>
|
|
|
- <el-col :span="24" class="button">
|
|
|
- <el-button type="primary" @click="toAdd()" size="mini">新增</el-button>
|
|
|
- </el-col>
|
|
|
- <cTable :fields="memberfields" :opera="opera" :list="memberList" :usePage="false" @del="toDel"> </cTable>
|
|
|
+ <cTable :fields="memberfields" :opera="[]" :list="form.member" :usePage="false"> </cTable>
|
|
|
</template>
|
|
|
</cForm>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <cDialog :dialog="dialog" @toClose="toClose">
|
|
|
- <template v-slot:info>
|
|
|
- <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
|
|
|
- <el-col :span="24" class="one">
|
|
|
- <el-checkbox-group v-model="memberList">
|
|
|
- <el-checkbox border v-for="item in personList" :label="item" :key="item._id">
|
|
|
- {{ item.name }}
|
|
|
- </el-checkbox>
|
|
|
- </el-checkbox-group>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24">
|
|
|
- <el-button type="primary" @click="toClose" size="mini">保存</el-button>
|
|
|
- </el-col>
|
|
|
- </el-col>
|
|
|
- </template>
|
|
|
- </cDialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
// 基础
|
|
|
import type { Ref } from 'vue';
|
|
|
-import { ref, reactive, onMounted } from 'vue';
|
|
|
-import type { FormRules } from 'element-plus';
|
|
|
-import { ElMessage } from 'element-plus';
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
import { useRoute } from 'vue-router';
|
|
|
// 接口
|
|
|
import { TeamStore } from '@/stores/team/team';
|
|
|
import { UserStore } from '@/stores/users/user';
|
|
|
import { DictDataStore } from '@/stores/dict/dictData'; // 字典表
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
+import { forOwnRight } from 'lodash';
|
|
|
const teamAxios = TeamStore();
|
|
|
const userAxios = UserStore();
|
|
|
const dictAxios = DictDataStore();
|
|
@@ -62,7 +42,6 @@ const route = useRoute();
|
|
|
const loading: Ref<any> = ref(false);
|
|
|
// 表单
|
|
|
let form: Ref<any> = ref({});
|
|
|
-const rules = reactive<FormRules>({});
|
|
|
let fields: Ref<any[]> = ref([
|
|
|
{ label: '所属管理员', model: 'administrator', type: 'select' },
|
|
|
{ label: '团队名称', model: 'name' },
|
|
@@ -75,10 +54,7 @@ let fields: Ref<any[]> = ref([
|
|
|
]);
|
|
|
// 字典表
|
|
|
const userList: Ref<any> = ref([]);
|
|
|
-const personList: Ref<any> = ref([]);
|
|
|
const genderList: Ref<any> = ref([]);
|
|
|
-// 成员
|
|
|
-const memberList: Ref<any> = ref([]);
|
|
|
|
|
|
const memberfields: Ref<any> = ref([
|
|
|
{ label: '姓名', model: 'name' },
|
|
@@ -86,10 +62,6 @@ const memberfields: Ref<any> = ref([
|
|
|
{ label: '年龄', model: 'age' },
|
|
|
{ label: '手机号', model: 'phone' }
|
|
|
]);
|
|
|
-// 操作
|
|
|
-let opera: Ref<any[]> = ref([{ label: '删除', method: 'del', confirm: true, type: 'danger' }]);
|
|
|
-// 弹框
|
|
|
-const dialog: Ref<any> = ref({ title: '团队成员选择', show: false, type: '1' });
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true;
|
|
@@ -103,7 +75,14 @@ const search = async () => {
|
|
|
let res: IQueryResult = await teamAxios.fetch(id);
|
|
|
if (res.errcode == '0') {
|
|
|
let info: any = res.data as {};
|
|
|
- memberList.value = info.member;
|
|
|
+ let memberList = [];
|
|
|
+ for (const val of info.member) {
|
|
|
+ for (const as of userList.value) {
|
|
|
+ if (val == as._id)
|
|
|
+ memberList.push({ _id: val, name: as.name || '暂无', age: as.age || '暂无', phone: as.phone || '暂无', gender: as.name || '暂无' });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ info.member = memberList;
|
|
|
form.value = info;
|
|
|
}
|
|
|
}
|
|
@@ -115,62 +94,30 @@ const getDict = (e, model) => {
|
|
|
else return '暂无';
|
|
|
}
|
|
|
};
|
|
|
-const onUpload = (e: { model: string; value: Array<[]> }) => {
|
|
|
- const { model, value } = e;
|
|
|
- form.value[model] = value;
|
|
|
-};
|
|
|
-const toAdd = async () => {
|
|
|
- dialog.value = { title: '团队成员选择', show: true, type: '1' };
|
|
|
-};
|
|
|
-// 删除
|
|
|
-const toDel = async (data: any) => {
|
|
|
- let list: any = form.value.member.filter((i: any) => i._id != data._id);
|
|
|
- memberList.value = list;
|
|
|
- form.value.number = list.length.toString();
|
|
|
- ElMessage({ type: `success`, message: `删除信息成功` });
|
|
|
-};
|
|
|
-// 保存
|
|
|
-const toSave = async (data) => {
|
|
|
- let res: IQueryResult;
|
|
|
- data.member = memberList.value;
|
|
|
- if (data._id) res = await teamAxios.update(data);
|
|
|
- else res = await teamAxios.create(data);
|
|
|
- if (res.errcode == 0) {
|
|
|
- ElMessage({ type: `success`, message: `维护信息成功` });
|
|
|
- toBack();
|
|
|
- }
|
|
|
-};
|
|
|
-// 关闭弹框
|
|
|
-const toClose = () => {
|
|
|
- form.value.number = memberList.value.length.toString();
|
|
|
- dialog.value = { show: false };
|
|
|
-};
|
|
|
// 查询其他信息
|
|
|
const searchOther = async () => {
|
|
|
let res: IQueryResult;
|
|
|
// 管理员
|
|
|
- res = await userAxios.query({ status: '1', type: '1' });
|
|
|
+ res = await userAxios.query({ status: '1' });
|
|
|
if (res.errcode == '0') userList.value = res.data;
|
|
|
- // 比赛人员
|
|
|
- res = await userAxios.query({ status: '1', type: '0' });
|
|
|
- if (res.errcode == '0') personList.value = res.data;
|
|
|
// 性别
|
|
|
res = await dictAxios.query({ type: 'gender' });
|
|
|
if (res.errcode == '0') genderList.value = res.data;
|
|
|
};
|
|
|
+// 图片预览
|
|
|
+const imgView = (url: any) => {
|
|
|
+ window.open(url);
|
|
|
+};
|
|
|
// 返回上一页
|
|
|
const toBack = () => {
|
|
|
window.history.go(-1);
|
|
|
};
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
-.button {
|
|
|
- margin: 5px 0;
|
|
|
-}
|
|
|
-.dialog_one {
|
|
|
- text-align: center;
|
|
|
- .one {
|
|
|
- margin: 0 0 20px 0;
|
|
|
- }
|
|
|
+.image {
|
|
|
+ width: 120px;
|
|
|
+ height: 120px;
|
|
|
+ overflow: hidden;
|
|
|
+ border-radius: 5px;
|
|
|
}
|
|
|
</style>
|