|
@@ -6,15 +6,15 @@
|
|
|
<component :is="partsSearch" :is_back="true" @toBack="toBack()"></component>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="two">
|
|
|
- <component :is="CForm" :fields="infoFields" :rules="rules" :form="form" labelWidth="auto" @save="toSave">
|
|
|
+ <component :is="CForm" :fields="infoFields" :rules="rules" :form="form" labelWidth="auto" @save="toSave" @dataChange="dataChange">
|
|
|
<template #type>
|
|
|
<el-option v-for="i in typeList" :key="i.model" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
</template>
|
|
|
<template #user>
|
|
|
<el-select clearable filterable multiple collapse-tags v-model="form.user" placeholder="请选择" style="width: 100%">
|
|
|
- <el-option v-for="item in userList" :key="item.id" :label="item.name || item.company" :value="item.id">
|
|
|
- <span style="float: left">{{ item.name || item.company }}</span>
|
|
|
- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.name ? '科学家' : '依托单位' }}</span>
|
|
|
+ <el-option v-for="(i, index) in userList" :key="index" :label="i.name || i.company" :value="i._id">
|
|
|
+ <span style="float: left">{{ i.name || i.company }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">{{ i.name ? '科学家' : '依托单位' }}</span>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</template>
|
|
@@ -25,49 +25,39 @@
|
|
|
<component :is="WangEditor" v-model="form.content" url="/files/studioadmin/other/upload"></component>
|
|
|
</template>
|
|
|
</component>
|
|
|
- <!-- <data-form :fields="fields" :form="form" :rules="rules" @save="toSave" @dataChange="dataChange" :span="24">
|
|
|
- <template #type>
|
|
|
- <el-option v-for="i in typeList" :key="i.model" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
- </template>
|
|
|
- <template #user>
|
|
|
- <el-select clearable filterable multiple collapse-tags v-model="form.user" placeholder="请选择" style="width: 100%">
|
|
|
- <el-option v-for="item in userList" :key="item.id" :label="item.name || item.company" :value="item.id">
|
|
|
- <span style="float: left">{{ item.name || item.company }}</span>
|
|
|
- <span style="float: right; color: #8492a6; font-size: 13px">{{ item.name ? '科学家' : '依托单位' }}</span>
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </template>
|
|
|
- <template #file="{ item }">
|
|
|
- <c-upload v-model="form[item.model]" url="/files/studioadmin/other/upload" accept="" listType="text" :limit="1"></c-upload>
|
|
|
- </template>
|
|
|
- <template #content>
|
|
|
- <editor v-model="form.content" url="/files/studioadmin/other/upload"></editor>
|
|
|
- </template>
|
|
|
- </data-form> -->
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
+import store from '@/stores/counter';
|
|
|
import partsSearch from '@/components/c-search.vue';
|
|
|
import CForm from '@/components/c-form.vue';
|
|
|
import WangEditor from '@/components/wang-editor.vue';
|
|
|
import CUpload from '@/components/c-upload.vue';
|
|
|
-import { useRoute } from 'vue-router';
|
|
|
import type { Ref } from 'vue';
|
|
|
import { ref, onMounted, reactive } from 'vue';
|
|
|
import type { FormRules } from 'element-plus';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { MessageStore } from '@common/src/stores/studio/other/message'; // 列表 // 列表
|
|
|
import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
|
|
|
+import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply';
|
|
|
+import { UserStudioApplyStore } from '@common/src/stores/studio/role/userStudioApply'; // 列表
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
const message = MessageStore();
|
|
|
const sysdictdata = DictDataStore();
|
|
|
+const unitStudioApply = UnitStudioApplyStore();
|
|
|
+const userStudioApply = UserStudioApplyStore();
|
|
|
interface dataItem {}
|
|
|
-let route = useRoute();
|
|
|
+interface userItem {
|
|
|
+ name: string;
|
|
|
+ company: string;
|
|
|
+ _id: string;
|
|
|
+}
|
|
|
+let user = store.state.user;
|
|
|
// 表单
|
|
|
-let form: Ref<{ content: string; file: dataItem[]; user: dataItem[] }> = ref({ content: '', file: [], user: [] });
|
|
|
+let form: Ref<{ content: string; file: dataItem[]; user: userItem[]; user_id: String }> = ref({ content: '', file: [], user: [], user_id: '' });
|
|
|
// 必填项
|
|
|
const rules = reactive<FormRules>({
|
|
|
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
|
@@ -86,7 +76,7 @@ let infoFields: Ref<any[]> = ref([
|
|
|
]); // 接收人类型
|
|
|
let typeList: Ref<any[]> = ref([]);
|
|
|
// 接收人
|
|
|
-let userList: Ref<any[]> = ref([]);
|
|
|
+let userList: Ref<userItem[]> = ref([]);
|
|
|
|
|
|
let limit: Ref<number> = ref(1);
|
|
|
let url: Ref<string> = ref('/files/studioadmin/other/upload');
|
|
@@ -95,165 +85,79 @@ onMounted(async () => {
|
|
|
await search();
|
|
|
});
|
|
|
const search = async () => {
|
|
|
- let form = { user_id: this.user.id };
|
|
|
- this.$set(this, `form`, form);
|
|
|
+ form.value.user_id = user._id;
|
|
|
};
|
|
|
const onChange = (e: { model: string; value: Array<dataItem> }) => {
|
|
|
const { model, value } = e;
|
|
|
form.value[model] = value;
|
|
|
};
|
|
|
-const dataChange = (model, value) => {
|
|
|
+const dataChange = (e: { model: string; value: string }) => {
|
|
|
+ const { model, value } = e;
|
|
|
if (model == 'type') {
|
|
|
if (value == '3') {
|
|
|
infoFields.value.splice(3, 0, { label: '接收人', model: 'user', custom: true });
|
|
|
searchUser();
|
|
|
} else {
|
|
|
- infoFields.value.filter((i) => i.model != 'user');
|
|
|
+ let name = infoFields.value.filter((i: any) => i.model != 'user');
|
|
|
+ console.log(name);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
// 查詢用戶
|
|
|
- const searchUser=async()=> {
|
|
|
- // 接收人
|
|
|
- let user = [];
|
|
|
- // 企业用户
|
|
|
- let company = await this.cQuery({ status: '1' });
|
|
|
- if (company.errcode == '0' && company.total > 0) {
|
|
|
- for (const val of company.data) {
|
|
|
- user.push({ id: val.id, company: val.company, phone: val.phone });
|
|
|
- }
|
|
|
- }
|
|
|
- // 科学家用户
|
|
|
- let scientist = await this.sQuery({ status: '1' });
|
|
|
- if (scientist.errcode == '0' && scientist.total > 0) {
|
|
|
- for (const val of scientist.data) {
|
|
|
- user.push({ id: val.id, name: val.name, phone: val.phone });
|
|
|
- }
|
|
|
- }
|
|
|
- this.$set(this, `userList`, user);
|
|
|
- },
|
|
|
- // 获取用户
|
|
|
- getUser(e) {
|
|
|
- let user = [];
|
|
|
- for (const val of e) {
|
|
|
- let data = this.userList.find((i) => i.id == val);
|
|
|
- if (data) user.push(data);
|
|
|
- }
|
|
|
- return user;
|
|
|
- },
|
|
|
-// 提交
|
|
|
-const toSave = async (data: { _id: string }) => {
|
|
|
- let res: IQueryResult;
|
|
|
- if (data._id) res = await message.update(data);
|
|
|
- else res = await message.create(data);
|
|
|
+const searchUser = async () => {
|
|
|
+ // 接收人
|
|
|
+ let user = [];
|
|
|
+ // 企业用户
|
|
|
+ let company = await unitStudioApply.query({ status: '1' });
|
|
|
+ if (company.errcode == '0' && company.total > 0) {
|
|
|
+ for (const val of company.data) {
|
|
|
+ user.push({ id: val.id, company: val.company, phone: val.phone });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 科学家用户
|
|
|
+ let scientist = await userStudioApply.query({ status: '1' });
|
|
|
+ if (scientist.errcode == '0' && scientist.total > 0) {
|
|
|
+ for (const val of scientist.data) {
|
|
|
+ user.push({ id: val.id, name: val.name, phone: val.phone });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userList.value = user;
|
|
|
+};
|
|
|
+// 获取用户
|
|
|
+const getUser = (e) => {
|
|
|
+ let user = [];
|
|
|
+ for (const val of e) {
|
|
|
+ let data = userList.value.find((i: any) => i.id == val);
|
|
|
+ if (data) user.push(data);
|
|
|
+ }
|
|
|
+ return user;
|
|
|
+};
|
|
|
+// 创建信息
|
|
|
+const createMess = async (e) => {
|
|
|
+ let res = await message.create(e);
|
|
|
if (res.errcode == 0) {
|
|
|
ElMessage({ type: 'success', message: '维护信息成功' });
|
|
|
toBack();
|
|
|
} else ElMessage({ type: 'warning', message: `${res.errmsg}` });
|
|
|
};
|
|
|
+// 提交
|
|
|
+const toSave = async (data: { _id: string; type: string; user: any }) => {
|
|
|
+ if (data.type == '3') {
|
|
|
+ if (data.user.length > 0) {
|
|
|
+ data.user = getUser(data.user);
|
|
|
+ createMess(data);
|
|
|
+ } else ElMessage({ message: `请选择指定用户`, type: 'error' });
|
|
|
+ } else createMess(data);
|
|
|
+};
|
|
|
const toBack = () => {
|
|
|
window.history.go(-1);
|
|
|
};
|
|
|
// 查询其他信息
|
|
|
const searchOther = async () => {
|
|
|
// 字典表---审核状态
|
|
|
- const p1: IQueryResult = await sysdictdata.query({ dict_type: 'sys_yes_no' });
|
|
|
- isuseList.value = p1.data as [];
|
|
|
+ const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_message_type' });
|
|
|
+ typeList.value = p1.data as [];
|
|
|
};
|
|
|
</script>
|
|
|
-<!-- <script>
|
|
|
-
|
|
|
- methods: {
|
|
|
- ...mapActions(['create']),
|
|
|
- ...sysdictdata({ dQuery: 'query' }),
|
|
|
- search() {
|
|
|
- let form = { user_id: this.user.id };
|
|
|
- this.$set(this, `form`, form);
|
|
|
- },
|
|
|
- // 选择接收人类型
|
|
|
- dataChange({ model, value }) {
|
|
|
- if (model == 'type') {
|
|
|
- if (value == '3') {
|
|
|
- this.fields.splice(3, 0, { label: '接收人', model: 'user', custom: true });
|
|
|
- this.searchUser();
|
|
|
- } else {
|
|
|
- this.fields.filter((i) => i.model != 'user');
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 查詢用戶
|
|
|
- async searchUser() {
|
|
|
- // 接收人
|
|
|
- let user = [];
|
|
|
- // 企业用户
|
|
|
- let company = await this.cQuery({ status: '1' });
|
|
|
- if (company.errcode == '0' && company.total > 0) {
|
|
|
- for (const val of company.data) {
|
|
|
- user.push({ id: val.id, company: val.company, phone: val.phone });
|
|
|
- }
|
|
|
- }
|
|
|
- // 科学家用户
|
|
|
- let scientist = await this.sQuery({ status: '1' });
|
|
|
- if (scientist.errcode == '0' && scientist.total > 0) {
|
|
|
- for (const val of scientist.data) {
|
|
|
- user.push({ id: val.id, name: val.name, phone: val.phone });
|
|
|
- }
|
|
|
- }
|
|
|
- this.$set(this, `userList`, user);
|
|
|
- },
|
|
|
- // 获取用户
|
|
|
- getUser(e) {
|
|
|
- let user = [];
|
|
|
- for (const val of e) {
|
|
|
- let data = this.userList.find((i) => i.id == val);
|
|
|
- if (data) user.push(data);
|
|
|
- }
|
|
|
- return user;
|
|
|
- },
|
|
|
- // 保存信息
|
|
|
- async toSave({ data }) {
|
|
|
- if (data.type == '3') {
|
|
|
- if (data.user.length > 0) {
|
|
|
- data.user = this.getUser(data.user);
|
|
|
- this.createMess(data);
|
|
|
- } else {
|
|
|
- this.$message({ message: `请选择指定用户`, type: 'error' });
|
|
|
- }
|
|
|
- } else this.createMess(data);
|
|
|
- },
|
|
|
- // 创建信息
|
|
|
- async createMess(e) {
|
|
|
- let res = await this.create(e);
|
|
|
- if (this.$checkRes(res, `维护信息完成`, `${res.errmsg}`)) this.toBack();
|
|
|
- },
|
|
|
- // 查询其他信息
|
|
|
- async searchOther() {
|
|
|
- let res;
|
|
|
- // 接收人类型
|
|
|
- res = await this.dQuery({ dict_type: 'studio_message_type' });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `typeList`, res.data);
|
|
|
- }
|
|
|
- },
|
|
|
- // 返回
|
|
|
- toBack() {
|
|
|
- window.history.go('-1');
|
|
|
- },
|
|
|
- },
|
|
|
- computed: {
|
|
|
- ...mapState(['user']),
|
|
|
- },
|
|
|
- metaInfo() {
|
|
|
- return { title: this.$route.meta.title };
|
|
|
- },
|
|
|
- watch: {
|
|
|
- test: {
|
|
|
- deep: true,
|
|
|
- immediate: true,
|
|
|
- handler(val) {},
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
-</script> -->
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
+<style lang="scss" scoped></style>
|