|
@@ -1,11 +1,323 @@
|
|
|
<template>
|
|
|
- <div id="index">
|
|
|
+ <div id="add">
|
|
|
<el-row>
|
|
|
- <el-col :span="24" class="main"> test </el-col>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <component :is="partsSearch" :is_back="true" @toBack="toBack"></component>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <el-form :model="form" :rules="rules" ref="ruleFormRef" label-width="140px">
|
|
|
+ <el-col :span="24" class="form_1">
|
|
|
+ <el-col :span="24" class="title">一、工作室建设信息</el-col>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <el-form-item label="单位名称" prop="company_name">
|
|
|
+ <el-input v-model="form.company_name" placeholder="请输入单位名称" disabled></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="单位所在地" prop="address">
|
|
|
+ <el-input v-model="form.address" placeholder="请输入单位所在地"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="单位性质" prop="nature">
|
|
|
+ <el-select v-model="form.nature" filterable clearable placeholder="请选择单位性质" style="width: 100%">
|
|
|
+ <el-option v-for="i in natureList" :key="i._id" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="拟解决技术难题或战略发展问题" prop="development">
|
|
|
+ <el-input
|
|
|
+ v-model="form.development"
|
|
|
+ placeholder="请输入拟解决技术难题或战略发展问题"
|
|
|
+ type="textarea"
|
|
|
+ maxlength="500"
|
|
|
+ show-word-limit
|
|
|
+ :autosize="{ minRows: 6, maxRows: 6 }"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="所属领域" prop="fields">
|
|
|
+ <el-select v-model="form.fields" multiple clearable filterable placeholder="请选择所属领域" style="width: 100%">
|
|
|
+ <el-option v-for="i in fieldList" :key="i._id" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="建设目标" prop="target">
|
|
|
+ <el-input v-model="form.target" placeholder="请输入建设目标"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="联系人" prop="contact">
|
|
|
+ <el-input v-model="form.contact" placeholder="请输入联系人"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="联系电话" prop="phone">
|
|
|
+ <el-input v-model="form.phone" placeholder="请输入联系电话"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="form_1">
|
|
|
+ <el-col :span="24" class="title">二、科学家入驻要求</el-col>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <el-form-item label="专业技术职称" prop="zc">
|
|
|
+ <el-select v-model="form.zc" filterable clearable placeholder="请选择专业技术职称" style="width: 100%">
|
|
|
+ <el-option v-for="i in zcList" :key="i._id" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="专业领域" prop="zy_fields">
|
|
|
+ <el-select v-model="form.zy_fields" multiple clearable filterable placeholder="请选择专业领域" style="width: 100%">
|
|
|
+ <el-option v-for="i in fieldList" :key="i._id" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="研究方向" prop="direction">
|
|
|
+ <el-button style="margin: 0 0 0.5vw 0" type="primary" size="small" @click.stop="addDriection()">添加</el-button>
|
|
|
+ <el-table :data="form.direction" border size="small">
|
|
|
+ <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
|
|
|
+ <el-table-column prop="name" label="名称" align="center">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-model="scope.row.name" placeholder="请输入研究方向名称"></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" width="100">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-button size="small" type="danger" @click="delDriection(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="其他要求" prop="other">
|
|
|
+ <el-input
|
|
|
+ v-model="form.other"
|
|
|
+ placeholder="请输入其他要求"
|
|
|
+ type="textarea"
|
|
|
+ maxlength="500"
|
|
|
+ show-word-limit
|
|
|
+ :autosize="{ minRows: 6, maxRows: 6 }"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="form_1">
|
|
|
+ <el-col :span="24" class="title">三、是否公开<span>(公开:平台用户可在系统首页进行搜索查看;不公开:系统首页不展示此条数据;)</span></el-col>
|
|
|
+ <el-col :span="24" class="info">
|
|
|
+ <el-form-item label="是否公开" prop="is_use">
|
|
|
+ <el-select v-model="form.is_use" filterable clearable placeholder="请选择是否公开" style="width: 100%">
|
|
|
+ <el-option v-for="i in isuseList" :key="i._id" :label="i.dict_label" :value="i.dict_value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-button type="primary" size="small" @click="toSave(ruleFormRef)">提交发布</el-button>
|
|
|
+ <el-button type="danger" size="small" @click="reSave(ruleFormRef)">信息重置</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts"></script>
|
|
|
+<script setup lang="ts">
|
|
|
+import store from '@/stores/counter';
|
|
|
+import moment from 'moment';
|
|
|
+// #region 组件
|
|
|
+import partsSearch from '@/components/c-search.vue';
|
|
|
+// #endregion
|
|
|
+import type { Ref } from 'vue';
|
|
|
+import { ref, onMounted, reactive } from 'vue';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+import type { FormInstance, FormRules } from 'element-plus';
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
+// #region 接口
|
|
|
+import { BuilddesireStore } from '@common/src/stores/studio/studios/builddesire'; // 发布工作室建设意愿
|
|
|
+import { UnitStudioApplyStore } from '@common/src/stores/studio/role/unitStudioApply'; // 依托单位申请科学家工作室权限表
|
|
|
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
|
|
|
+import type { IQueryResult } from '@/util/types.util';
|
|
|
+const builddesire = BuilddesireStore();
|
|
|
+const unitStudioApply = UnitStudioApplyStore();
|
|
|
+const sysdictdata = DictDataStore();
|
|
|
+const ruleFormRef = ref<FormInstance>();
|
|
|
+let route = useRoute();
|
|
|
+// 必填项
|
|
|
+const rules = reactive<FormRules>({
|
|
|
+ company_name: [{ required: true, message: '请输入单位名称', trigger: 'blur' }],
|
|
|
+ address: [{ required: true, message: '请输入单位所在地', trigger: 'blur' }],
|
|
|
+ nature: [{ required: true, message: '请选择单位性质', trigger: 'change' }],
|
|
|
+ development: [{ required: true, message: '请输入拟解决技术难题或战略发展问题', trigger: 'blur' }],
|
|
|
+ fields: [{ required: true, message: '请选择所属领域', trigger: 'change' }],
|
|
|
+ target: [{ required: true, message: '请输入建设目标', trigger: 'blur' }],
|
|
|
+ contact: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
|
|
|
+ phone: [{ required: true, message: '请输入联系电话', trigger: 'change' }],
|
|
|
+ zc: [{ required: true, message: '请选择专业技术职称', trigger: 'change' }],
|
|
|
+ zy_fields: [{ required: true, message: '请选择专业领域', trigger: 'change' }],
|
|
|
+ direction: [{ required: false, message: '请选择专业领域', trigger: 'change' }],
|
|
|
+ other: [{ required: false, message: '请选择专业领域', trigger: 'blur' }],
|
|
|
+ is_use: [{ required: true, message: '请选择是否公开', trigger: 'change' }],
|
|
|
+});
|
|
|
+// 用户信息
|
|
|
+let user: Ref<{ _id: string }> = ref({ _id: '' });
|
|
|
+// 依托单位信息
|
|
|
+let unitInfo: Ref<{ _id: String; status: String; company: string; address: string }> = ref({ _id: '', status: '', company: '', address: '' });
|
|
|
+// 表单
|
|
|
+let form: Ref<{
|
|
|
+ _id: string;
|
|
|
+ company_name: string;
|
|
|
+ address: string;
|
|
|
+ nature: string;
|
|
|
+ development: string;
|
|
|
+ fields: Array<[]>;
|
|
|
+ target: string;
|
|
|
+ contact: string;
|
|
|
+ phone: string;
|
|
|
+ zc: string;
|
|
|
+ zy_fields: Array<[]>;
|
|
|
+ contdirectionact: string;
|
|
|
+ direction: Array<[]>;
|
|
|
+ other: string;
|
|
|
+ is_use: string;
|
|
|
+}> = ref({
|
|
|
+ _id: '',
|
|
|
+ company_name: '',
|
|
|
+ address: '',
|
|
|
+ nature: '',
|
|
|
+ development: '',
|
|
|
+ fields: [],
|
|
|
+ target: '',
|
|
|
+ contact: '',
|
|
|
+ phone: '',
|
|
|
+ zc: '',
|
|
|
+ zy_fields: [],
|
|
|
+ contdirectionact: '',
|
|
|
+ direction: [],
|
|
|
+ other: '',
|
|
|
+ is_use: '',
|
|
|
+});
|
|
|
+// 单位性质
|
|
|
+let natureList: Ref<any[]> = ref([]);
|
|
|
+// 领域
|
|
|
+let fieldList: Ref<any[]> = ref([]);
|
|
|
+// 是否启用
|
|
|
+let isuseList: Ref<any[]> = ref([]);
|
|
|
+// 专业技术职称
|
|
|
+let zcList: Ref<any[]> = ref([]);
|
|
|
+onMounted(async () => {
|
|
|
+ user.value = store.state.user as { _id: string };
|
|
|
+ await searchUnit();
|
|
|
+ await searchOther();
|
|
|
+ await search();
|
|
|
+});
|
|
|
+// 依托单位信息
|
|
|
+const searchUnit = async () => {
|
|
|
+ const res: IQueryResult = await unitStudioApply.query({ unit_id: user.value._id });
|
|
|
+ let list = res.data as any[];
|
|
|
+ if (res.total > 0) unitInfo.value = list[0];
|
|
|
+};
|
|
|
+// 查询
|
|
|
+const search = async () => {
|
|
|
+ let data: any = {
|
|
|
+ user_id: user.value._id,
|
|
|
+ company_id: unitInfo.value._id,
|
|
|
+ company_name: unitInfo.value.company,
|
|
|
+ address: unitInfo.value.address,
|
|
|
+ fields: [],
|
|
|
+ zy_fields: [],
|
|
|
+ direction: [],
|
|
|
+ };
|
|
|
+ if (route.query && route.query.id) {
|
|
|
+ let id = route.query.id;
|
|
|
+ const res: IQueryResult = await builddesire.fetch(id);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ if (res.data)
|
|
|
+ form.value = res.data as {
|
|
|
+ _id: '';
|
|
|
+ company_name: '';
|
|
|
+ address: '';
|
|
|
+ nature: '';
|
|
|
+ development: '';
|
|
|
+ fields: [];
|
|
|
+ target: '';
|
|
|
+ contact: '';
|
|
|
+ phone: '';
|
|
|
+ zc: '';
|
|
|
+ zy_fields: [];
|
|
|
+ contdirectionact: '';
|
|
|
+ direction: [];
|
|
|
+ other: '';
|
|
|
+ is_use: '';
|
|
|
+ };
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ form.value = { ...data };
|
|
|
+ }
|
|
|
+};
|
|
|
+// 研究方向添加
|
|
|
+const addDriection = () => {
|
|
|
+ let direction: any = form.value.direction;
|
|
|
+ if (direction.length >= 5) {
|
|
|
+ ElMessage({ message: `研究方向最多添加五个`, type: 'error' });
|
|
|
+ } else {
|
|
|
+ direction.push({ id: moment().valueOf(), name: '' });
|
|
|
+ }
|
|
|
+ form.value.direction = direction;
|
|
|
+};
|
|
|
+// 研究方向删除
|
|
|
+const delDriection = (e: { id: '' }) => {
|
|
|
+ let direction = form.value.direction.filter((i: any) => i.id != e.id);
|
|
|
+ form.value.direction = direction;
|
|
|
+};
|
|
|
+// 返回
|
|
|
+const toBack = () => {
|
|
|
+ window.history.go(-1);
|
|
|
+};
|
|
|
+const toSave = async (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ await formEl.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ let res: IQueryResult;
|
|
|
+ if (form.value._id) res = await builddesire.update(form.value);
|
|
|
+ else res = await builddesire.create(form.value);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ ElMessage({ type: 'success', message: '维护信息成功' });
|
|
|
+ toBack();
|
|
|
+ } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
|
|
|
+ } else {
|
|
|
+ console.log('error submit!', fields);
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+// 取消提交
|
|
|
+const reSave = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ formEl.resetFields();
|
|
|
+};
|
|
|
+// 查询其他信息
|
|
|
+const searchOther = async () => {
|
|
|
+ // 单位性质
|
|
|
+ const p1: IQueryResult = await sysdictdata.query({ dict_type: 's-builddesire-nature' });
|
|
|
+ natureList.value = p1.data as [];
|
|
|
+ // 领域
|
|
|
+ const p2: IQueryResult = await sysdictdata.query({ dict_type: 'studio_field' });
|
|
|
+ fieldList.value = p2.data as [];
|
|
|
+ // 是否启用
|
|
|
+ const p3: IQueryResult = await sysdictdata.query({ dict_type: 's-builddesire-isuse' });
|
|
|
+ isuseList.value = p3.data as [];
|
|
|
+ // 专业技术职称
|
|
|
+ const p4: IQueryResult = await sysdictdata.query({ dict_type: 's-builddesire-zc' });
|
|
|
+ zcList.value = p4.data as [];
|
|
|
+};
|
|
|
+</script>
|
|
|
|
|
|
-<style scoped></style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.main {
|
|
|
+ .two {
|
|
|
+ padding: 0 0 10px 0;
|
|
|
+ .form_1 {
|
|
|
+ .title {
|
|
|
+ margin: 0 0 15px 0;
|
|
|
+ font-size: 20px;
|
|
|
+ font-family: monospace;
|
|
|
+ font-weight: bold;
|
|
|
+ span {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #858585;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .btn {
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|