Forráskód Böngészése

修改技术支持

zs 2 éve
szülő
commit
dde244fb20

+ 8 - 4
src/views/user/scientist/studio/index.vue

@@ -2,7 +2,11 @@
   <div id="index">
     <el-col class="main animate__animated animate__backInRight">
       <el-col :span="24" class="one">
-        <component :is="partsSearch" :is_search="true" :fields="fields" @search="partSearch"> </component>
+        <component :is="partsSearch" :is_search="true" :fields="fields" @search="partSearch">
+          <template #studio_id>
+            <el-option v-for="i in studioList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+          </template>
+        </component>
       </el-col>
       <el-col :span="24" class="two">
         <component
@@ -55,7 +59,7 @@ let fields: Ref<any[]> = ref([
     model: 'studio_id',
     type: 'select',
     format: (i: string) => {
-      let data = studioList.value.find((r) => r.id == i);
+      let data = studioList.value.find((r) => r._id == i);
       if (data) return data.name || data.apply_name;
     },
     isSearch: true,
@@ -126,8 +130,8 @@ const searchStudio = async () => {
 };
 // 查询
 const search = async (e: { skip: number; limit: number }) => {
-  const { skip, limit } = e;
   if (userInfo && userInfo.value.user_id && userInfo.value.status == '1') {
+    const { skip, limit } = e;
     let info = { limit: limit, skip: skip, ...searchForm.value, user_id: userInfo.value.user_id };
     const res: IQueryResult = await scientistsettle.query(info);
     tableData.value = res.data as any[];
@@ -157,7 +161,7 @@ const searchOther = async () => {
   const p1: IQueryResult = await studio.query();
   studioList.value = p1.data as [];
   // 领域
-  const p2 = await sysdictdata.query({ dict_type: 'studio_field' });
+  const p2: IQueryResult = await sysdictdata.query({ dict_type: 'studio_field' });
   fieldList.value = p2.data as [];
 };
 </script>

+ 35 - 5
src/views/user/scientist/studio/info.vue

@@ -1,11 +1,41 @@
 <template>
-  <div id="index">
+  <div id="info">
     <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">
+          <component :is="studioInfo" :info="info"></component>
+        </el-col>
+      </el-col>
     </el-row>
   </div>
 </template>
+<script setup lang="ts">
+import partsSearch from '@/components/c-search.vue';
+import studioInfo from '@/components/common/studio/info.vue';
+import { useRoute } from 'vue-router';
+import type { Ref } from 'vue';
+import { ref, onMounted } from 'vue';
+import { StudioStore } from '@common/src/stores/studio/studios/studio'; // 列表
+import type { IQueryResult } from '@/util/types.util';
+const studio = StudioStore();
+let route = useRoute();
+let info: Ref<{}> = ref({});
+onMounted(async () => {
+  await search();
+});
+const search = async () => {
+  if (route.query && route.query.id) {
+    let id = route.query.id;
+    const res: IQueryResult = await studio.fetch(id);
+    info.value = res.data as {};
+  }
+};
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
 
-<script setup lang="ts"></script>
-
-<style scoped></style>
+<style lang="scss" scoped></style>

+ 138 - 3
src/views/user/support/add.vue

@@ -1,11 +1,146 @@
 <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">
+          <component :is="CForm" :fields="fields" :rules="rules" :form="form" labelWidth="auto" @save="toSave">
+            <template #fields>
+              <el-option v-for="item in fieldList" :key="item.dict_value" :label="item.dict_label" :value="item.dict_value"></el-option>
+            </template>
+            <template #is_use>
+              <el-option v-for="item in isuseList" :key="item.dict_value" :label="item.dict_label" :value="item.dict_value"></el-option>
+            </template>
+            <template #file>
+              <component :is="CFile" model="file" :limit="limit" :url="url" :list="form.file" @change="onChange"></component>
+            </template>
+            <template #content>
+              <component :is="WangEditor" v-model="form.content" url="/files/studioadmin/other/upload"></component>
+            </template>
+          </component>
+        </el-col>
+      </el-col>
     </el-row>
   </div>
 </template>
 
-<script setup lang="ts"></script>
+<script setup lang="ts">
+import store from '@/stores/counter';
+// #region 组件
+import partsSearch from '@/components/c-search.vue';
+import CForm from '@/components/c-form.vue';
+import CFile from '@/components/c-upload.vue';
+import WangEditor from '@/components/wang-editor.vue';
+// #endregion
+import type { Ref } from 'vue';
+import { ref, onMounted, reactive } from 'vue';
+import type { FormRules } from 'element-plus';
+import { ElMessage } from 'element-plus';
+import { useRoute } from 'vue-router';
+// #region 接口
+import { TecholsupportStore } from '@common/src/stores/studio/supplydemand/techolsupport'; //技术支持
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
+import { UserStudioApplyStore } from '@common/src/stores/studio/role/userStudioApply'; //个人账号申请科学家工作室权限表
+import type { IQueryResult } from '@/util/types.util';
+const techolsupport = TecholsupportStore();
+const sysdictdata = DictDataStore();
+const userStudioApply = UserStudioApplyStore();
+let route = useRoute();
+interface dataItem {}
+// 必填项
+const rules = reactive<FormRules>({
+  scientist_name: [{ required: true, message: '请输入科学家姓名', trigger: 'blur' }],
+  phone: [{ required: true, message: '请输入联系方式', trigger: 'blur' }],
+  company_name: [{ required: true, message: '请输入单位名称', trigger: 'blur' }],
+  title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
+  date: [{ required: true, message: '请选择发布时间', trigger: 'change' }],
+  fields: [{ required: true, message: '请选择行业领域', trigger: 'change' }],
+  file: [{ required: true, message: '请上传文件信息', trigger: 'change' }],
+  content: [{ required: true, message: '请输入信息内容', trigger: 'blur' }],
+});
+// 表单
+let fields: Ref<any[]> = ref([
+  { label: '科学家姓名', model: 'scientist_name' },
+  { label: '联系方式', model: 'phone' },
+  { label: '单位名称', model: 'company_name' },
+  { label: '标题', model: 'title' },
+  { label: '发布时间', model: 'date', type: 'date' },
+  { label: '行业领域', model: 'fields', type: 'selectMany' },
+  { label: '文件信息', model: 'file', custom: true },
+  { label: '信息内容', model: 'content', custom: true },
+  { label: '是否启用', model: 'is_use', type: 'select' },
+]);
+let limit: Ref<number> = ref(1);
+let url: Ref<string> = ref('/files/studioadmin/other/upload');
+// 用户信息
+let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string }> = ref({ _id: '', name: '', unit_name: '', nick_name: '' });
+// 个人用户信息
+let userInfo: Ref<{ name: string; _id: String; user_id: String; status: String; company: String }> = ref({
+  _id: '',
+  user_id: '',
+  status: '',
+  name: '',
+  company: '',
+});
+// 表单
+let form: Ref<{ content: string; file: dataItem[] }> = ref({ content: '', file: [] });
+// 行业领域
+let fieldList: Ref<any[]> = ref([]);
+// 是否启用
+let isuseList: Ref<any[]> = ref([]);
+onMounted(async () => {
+  user.value = store.state.user;
+  await searchOther();
+  await searchUser();
+  await search();
+});
+const searchUser = async () => {
+  const res: IQueryResult = await userStudioApply.query({ user_id: user.value._id });
+  let list = res.data as any[];
+  if (res.total > 0) userInfo.value = list[0];
+};
+// 查询
+const search = async () => {
+  let data = { user_id: user.value._id, scientist_name: userInfo.value.name, phone: userInfo.value.phone.phone, company_name: userInfo.value.company };
+  if (route.query && route.query.id) {
+    let id = route.query.id;
+    const res: IQueryResult = await techolsupport.fetch(id);
+    if (res.errcode == 0) {
+      if (res.data) form.value = res.data as {};
+    }
+  } else {
+    form.value = { ...data };
+  }
+};
+// 返回
+const toBack = () => {
+  window.history.go(-1);
+};
+const onChange = (e: { model: string; value: Array<dataItem> }) => {
+  const { model, value } = e;
+  form.value[model] = value;
+};
+// 添加
+const toSave = async (data: { _id: string }) => {
+  let res: IQueryResult;
+  if (data._id) res = await techolsupport.update(data);
+  else res = await techolsupport.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: 'success', message: '维护信息成功' });
+    toBack();
+  } else ElMessage({ type: 'warning', message: `${res.errmsg}` });
+};
+// 查询其他信息
+const searchOther = async () => {
+  // 字典表---审核状态
+  const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_field' });
+  fieldList.value = p1.data as [];
+  // 角色
+  const p2: IQueryResult = await sysdictdata.query({ dict_type: 'sys_yes_no' });
+  isuseList.value = p2.data as [];
+};
+</script>
 
 <style scoped></style>

+ 180 - 4
src/views/user/support/index.vue

@@ -1,11 +1,187 @@
 <template>
   <div id="index">
     <el-row>
-      <el-col :span="24" class="main"> 发布技术支持 </el-col>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col :span="24" class="one">
+          <component :is="partsSearch" :is_search="true" :fields="fields" @search="partSearch">
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
+            </template>
+          </component>
+        </el-col>
+        <el-col :span="24" class="two">
+          <component :is="Btn1" @toAdd="toAdd"></component>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <component
+            :is="CTable"
+            :fields="fields"
+            :opera="opera"
+            :select="false"
+            :selected="selected"
+            @handleSelect="handleSelect"
+            @query="search"
+            :data="tableData"
+            :total="total"
+            @view="toView"
+            @edit="toEdit"
+            @del="toDel"
+          >
+            <template #is_use="{ row, item }">
+              <el-button :type="row[item.model] == 'Y' ? 'primary' : 'danger'" size="mini" @click="toUse(row)">{{
+                row[item.model] == 'Y' ? '是' : '否'
+              }}</el-button>
+            </template>
+          </component>
+        </el-col>
+      </el-col>
     </el-row>
   </div>
 </template>
+<script setup lang="ts">
+import store from '@/stores/counter';
+// #region 组件
+import partsSearch from '@/components/c-search.vue';
+import CTable from '@/components/c-table.vue';
+import Btn1 from '@/components/btn-1.vue';
+// #endregion
+import type { Ref } from 'vue';
+import { ref, onMounted, getCurrentInstance } from 'vue';
+import { ElMessage } from 'element-plus';
+import { useRouter } from 'vue-router';
+// #region 接口
+import { TecholsupportStore } from '@common/src/stores/studio/supplydemand/techolsupport'; //技术支持
+import { DictDataStore } from '@common/src/stores/users/sysdictdata'; // 字典表
+import { UserStudioApplyStore } from '@common/src/stores/studio/role/userStudioApply'; //个人账号申请科学家工作室权限表
+import type { IQueryResult } from '@/util/types.util';
+const techolsupport = TecholsupportStore();
+const sysdictdata = DictDataStore();
+const userStudioApply = UserStudioApplyStore();
+const { proxy } = getCurrentInstance() as any;
+const router = useRouter();
+// #endregion
+// 列表数据
+let tableData: Ref<any[]> = ref([]);
+// 列表
+let fields: Ref<any[]> = ref([
+  { label: '序号', options: { type: 'index' } },
+  { label: '标题', model: 'title', isSearch: true },
+  { label: '发布时间', model: 'date' },
+  { label: '科学家姓名', model: 'scientist_name', isSearch: true },
+  { label: '联系方式', model: 'phone', isSearch: true },
+  { label: '单位名称', model: 'company_name', isSearch: true },
+  { label: '是否启用', model: 'is_use', custom: true },
+  {
+    label: '审核状态',
+    model: 'status',
+    type: 'select',
+    format: (i) => {
+      let data = statusList.value.find((r) => r.dict_value == i);
+      if (data) return data.dict_label;
+    },
+    isSearch: true,
+  },
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '详情', method: 'view' },
+  { label: '修改', method: 'edit', type: 'warning', display: (i) => i.status == '0' },
+  { label: '删除', method: 'del', type: 'danger', confirm: true },
+]);
+// 多选
+let selected: Ref<any[]> = ref([]);
+// 总数
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+// 用户信息
+let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string }> = ref({ _id: '', name: '', unit_name: '', nick_name: '' });
+// 个人用户信息
+let userInfo: Ref<{ _id: String; user_id: String; status: String }> = ref({ _id: '', user_id: '', status: '' });
+// 查询数据
+let searchForm: Ref<{}> = ref({});
+// 状态
+let statusList: Ref<any[]> = ref([]);
+// 是否使用
+let isuseList: Ref<any[]> = ref([]);
 
-<script setup lang="ts"></script>
-
-<style scoped></style>
+onMounted(async () => {
+  user.value = store.state.user;
+  await searchUser();
+  await searchOther();
+  await search({ skip, limit });
+});
+const searchUser = async () => {
+  const res: IQueryResult = await userStudioApply.query({ user_id: user.value._id });
+  let list = res.data as any[];
+  if (res.total > 0) userInfo.value = list[0];
+};
+// 查询
+const search = async (e: { skip: number; limit: number }) => {
+  if (userInfo && userInfo.value.user_id && userInfo.value.status == '1') {
+    const { skip, limit } = e;
+    let info = { limit: limit, skip: skip, ...searchForm.value, user_id: userInfo.value.user_id };
+    const res: IQueryResult = await techolsupport.query(info);
+    tableData.value = res.data as any[];
+    total.value = res.total;
+  } else {
+    ElMessage({ type: 'warning', message: `用户未完成信息填报/信息填报未完成审核,无法查询相关信息` });
+  }
+};
+// 查询
+const partSearch = (form: { [x: string]: any }) => {
+  searchForm.value = form;
+  search({ skip, limit });
+};
+// 添加
+const toAdd = () => {
+  if (userInfo && userInfo.value.user_id && userInfo.value.status == '1') {
+    router.push({ path: '/user/support/add' });
+  } else {
+    ElMessage({ message: '用户未完成信息填报/信息填报未完成审核,无法查询相关信息', type: 'warning' });
+  }
+};
+// 是否启用
+const toUse = async (data: { is_use: string }) => {
+  data.is_use = data.is_use == 'Y' ? 'N' : 'Y';
+  const res: IQueryResult = await techolsupport.update(data);
+  if (res.errcode == 0) {
+    ElMessage({ message: '维护信息成功', type: 'success' });
+    search({ skip, limit });
+  }
+};
+// 查看
+const toView = (data: { _id: string }) => {
+  router.push({ path: '/user/support/info', query: { id: data._id } });
+};
+// 修改
+const toEdit = (data: { _id: string }) => {
+  router.push({ path: '/user/support/add', query: { id: data._id } });
+};
+// 删除
+const toDel = async (data: { _id: string }) => {
+  const res: IQueryResult = await techolsupport.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ message: '删除信息成功', type: 'success' });
+    search({ skip, limit });
+  }
+};
+// 选择
+const handleSelect = () => {};
+// 查询其他信息
+const searchOther = async () => {
+  // 字典表---审核状态
+  const p1: IQueryResult = await sysdictdata.query({ dict_type: 'studio_status' });
+  statusList.value = p1.data as [];
+  // 角色
+  const p2: IQueryResult = await sysdictdata.query({ dict_type: 'sys_yes_no' });
+  isuseList.value = p2.data as [];
+};
+</script>
+<style lang="scss" scoped>
+.main {
+  .thr {
+    margin: 1vw 0 0 0;
+  }
+}
+</style>

+ 35 - 5
src/views/user/support/info.vue

@@ -1,11 +1,41 @@
 <template>
-  <div id="index">
+  <div id="info">
     <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">
+          <component :is="studioInfo" :info="info"></component>
+        </el-col>
+      </el-col>
     </el-row>
   </div>
 </template>
+<script setup lang="ts">
+import partsSearch from '@/components/c-search.vue';
+import studioInfo from '@/components/common/studio/info.vue';
+import { useRoute } from 'vue-router';
+import type { Ref } from 'vue';
+import { ref, onMounted } from 'vue';
+import { TecholsupportStore } from '@common/src/stores/studio/supplydemand/techolsupport'; // 列表
+import type { IQueryResult } from '@/util/types.util';
+const techolsupport = TecholsupportStore();
+let route = useRoute();
+let info: Ref<{}> = ref({});
+onMounted(async () => {
+  await search();
+});
+const search = async () => {
+  if (route.query && route.query.id) {
+    let id = route.query.id;
+    const res: IQueryResult = await techolsupport.fetch(id);
+    info.value = res.data as {};
+  }
+};
+const toBack = () => {
+  window.history.go(-1);
+};
+</script>
 
-<script setup lang="ts"></script>
-
-<style scoped></style>
+<style lang="scss" scoped></style>