|
@@ -0,0 +1,310 @@
|
|
|
+<template>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch">
|
|
|
+ <template #industry>
|
|
|
+ <el-option v-for="i in industryList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #attr>
|
|
|
+ <el-option v-for="i in attrList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ </cSearch>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="two">
|
|
|
+ <cButton :isAdd="false"> </cButton>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="thr">
|
|
|
+ <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel" @changeUse="toChangeUse"> </cTable>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <cDialog :dialog="dialog" @toClose="toClose">
|
|
|
+ <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
|
|
|
+ <cForm :span="24" :fields="formFields" :form="form" :rules="{}" @save="toSave" label-width="auto">
|
|
|
+ <template #status>
|
|
|
+ <el-radio v-for="i in statusList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
|
|
|
+ </template>
|
|
|
+ <template #industry>
|
|
|
+ <el-option v-for="i in industryList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #attr>
|
|
|
+ <el-option v-for="i in attrList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #way>
|
|
|
+ <el-option v-for="i in wayList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #maturity>
|
|
|
+ <el-option v-for="i in maturityList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #tech>
|
|
|
+ <el-option v-for="i in techList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #area>
|
|
|
+ <el-option v-for="i in areaList" :key="i._id" :label="i.label" :value="i.value"></el-option>
|
|
|
+ </template>
|
|
|
+ <template #files>
|
|
|
+ <cUpload model="files" :limit="5" url="/files/zdlyjszy/achieve/upload" :list="form.files" listType="picture-card" @change="onUpload"></cUpload>
|
|
|
+ </template>
|
|
|
+ <template #public_info>
|
|
|
+ <el-checkbox-group v-model="form.publicInfo">
|
|
|
+ <el-checkbox v-for="i in publicInfoList" :key="i.model" :label="i.model">{{ i.label }}</el-checkbox>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </template>
|
|
|
+ </cForm>
|
|
|
+ </el-col>
|
|
|
+ </cDialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, Ref, onMounted, inject } from 'vue';
|
|
|
+// NeedChange
|
|
|
+import { AchieveStore } from '@/stores/core/achieve';
|
|
|
+import { DictDataStore } from '@/stores/system/dictData';
|
|
|
+import type { IQueryResult } from '@/util/types.util';
|
|
|
+import { cloneDeep, get } from 'lodash';
|
|
|
+import baseStore from '@/stores/counter';
|
|
|
+const user = ref(baseStore.state.user);
|
|
|
+onMounted(async () => {
|
|
|
+ loading.value = true;
|
|
|
+ await searchOther();
|
|
|
+ await search({ skip, limit });
|
|
|
+ loading.value = false;
|
|
|
+});
|
|
|
+
|
|
|
+const loading: Ref<any> = ref(false);
|
|
|
+// NeedChange
|
|
|
+const store = AchieveStore();
|
|
|
+const dictDataStore = DictDataStore();
|
|
|
+const $checkRes = inject('$checkRes') as Function;
|
|
|
+
|
|
|
+// #region 字典
|
|
|
+// NeedChange
|
|
|
+const statusList: Ref<any> = ref([]);
|
|
|
+const industryList: Ref<any> = ref([]);
|
|
|
+const attrList: Ref<any> = ref([]);
|
|
|
+const wayList: Ref<any> = ref([]);
|
|
|
+const maturityList: Ref<any> = ref([]);
|
|
|
+const techList: Ref<any> = ref([]);
|
|
|
+const areaList: Ref<any> = ref([]);
|
|
|
+
|
|
|
+const searchOther = async () => {
|
|
|
+ const statusResult: IQueryResult = await dictDataStore.query({ code: 'achieveStatus' });
|
|
|
+ if ($checkRes(statusResult)) {
|
|
|
+ statusList.value = statusResult.data;
|
|
|
+ }
|
|
|
+ const imsResult: IQueryResult = await dictDataStore.query({ code: 'ims' });
|
|
|
+ if ($checkRes(imsResult)) {
|
|
|
+ industryList.value = imsResult.data;
|
|
|
+ }
|
|
|
+ const achievePropsResult: IQueryResult = await dictDataStore.query({ code: 'achieveProps' });
|
|
|
+ if ($checkRes(achievePropsResult)) {
|
|
|
+ attrList.value = achievePropsResult.data;
|
|
|
+ }
|
|
|
+ const outWayResult: IQueryResult = await dictDataStore.query({ code: 'outWay' });
|
|
|
+ if ($checkRes(outWayResult)) {
|
|
|
+ wayList.value = outWayResult.data;
|
|
|
+ }
|
|
|
+ const maturityResult: IQueryResult = await dictDataStore.query({ code: 'maturity' });
|
|
|
+ if ($checkRes(maturityResult)) {
|
|
|
+ maturityList.value = maturityResult.data;
|
|
|
+ }
|
|
|
+ const techResult: IQueryResult = await dictDataStore.query({ code: 'tech' });
|
|
|
+ if ($checkRes(techResult)) {
|
|
|
+ techList.value = techResult.data;
|
|
|
+ }
|
|
|
+ const achieveAreaResult: IQueryResult = await dictDataStore.query({ code: 'achieveArea' });
|
|
|
+ if ($checkRes(achieveAreaResult)) {
|
|
|
+ areaList.value = achieveAreaResult.data;
|
|
|
+ }
|
|
|
+};
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 查询相关
|
|
|
+let list: Ref<any> = ref([]);
|
|
|
+let total: Ref<number> = ref(0);
|
|
|
+let skip = 0;
|
|
|
+let limit = inject('$limit') as number;
|
|
|
+let searchForm: Ref<any> = ref({});
|
|
|
+
|
|
|
+const search = async (e: { skip: number; limit: number }) => {
|
|
|
+ const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
|
|
|
+ const res: IQueryResult = await store.query(info);
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ list.value = res.data;
|
|
|
+ total.value = res.total;
|
|
|
+ }
|
|
|
+};
|
|
|
+const toSearch = (query) => {
|
|
|
+ searchForm.value = query;
|
|
|
+ search({ skip, limit });
|
|
|
+};
|
|
|
+const toChangeUse = async (data) => {
|
|
|
+ const udata = { _id: data._id, status: data.status === '0' ? '1' : '0' };
|
|
|
+ const res = await store.update(udata);
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit });
|
|
|
+ }
|
|
|
+};
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 表格及操作
|
|
|
+// NeedChange
|
|
|
+let fields: Ref<any[]> = ref([
|
|
|
+ { label: '成果名称', model: 'name', isSearch: true },
|
|
|
+ { label: '行业分类', model: 'industry', isSearch: true, type: 'selectMult', format: (i) => getDict(i, 'industry') },
|
|
|
+ { label: '成果属性', model: 'attr', isSearch: true, type: 'select', format: (i) => getDict(i, 'attr') },
|
|
|
+ { label: '出让方式', model: 'way', format: (i) => getDict(i, 'way') },
|
|
|
+ { label: '成熟度', model: 'maturity', format: (i) => getDict(i, 'maturity') },
|
|
|
+ { label: '发布时间', model: 'time' },
|
|
|
+ { label: '交易金额', model: 'money' },
|
|
|
+ { label: '状态', model: 'status', format: (i) => getDict(i, 'status') }
|
|
|
+]);
|
|
|
+// 操作
|
|
|
+let opera: Ref<any[]> = ref([
|
|
|
+ { label: '修改', method: 'edit' },
|
|
|
+ { label: '非公开', method: 'changeUse', type: 'warning', confirm: true, confirmWord: '您确定要非公开该成果?', display: (i) => i.status === '0' },
|
|
|
+ { label: '公开', method: 'changeUse', type: 'success', confirm: true, confirmWord: '您确定要公开该成果?', display: (i) => i.status === '1' },
|
|
|
+ { label: '删除', method: 'del', confirm: true, type: 'danger' }
|
|
|
+]);
|
|
|
+
|
|
|
+const getDict = (data, model) => {
|
|
|
+ let list;
|
|
|
+ switch (model) {
|
|
|
+ case 'status':
|
|
|
+ list = statusList.value;
|
|
|
+ break;
|
|
|
+ case 'industry':
|
|
|
+ list = industryList.value;
|
|
|
+ break;
|
|
|
+ case 'attr':
|
|
|
+ list = attrList.value;
|
|
|
+ break;
|
|
|
+ case 'way':
|
|
|
+ list = wayList.value;
|
|
|
+ break;
|
|
|
+ case 'maturity':
|
|
|
+ list = maturityList.value;
|
|
|
+ break;
|
|
|
+ case 'tech':
|
|
|
+ list = techList.value;
|
|
|
+ break;
|
|
|
+ case 'area':
|
|
|
+ list = areaList.value;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ const res = list.find((f) => f.value == data);
|
|
|
+ return get(res, 'label');
|
|
|
+};
|
|
|
+const toAdd = () => {
|
|
|
+ formFields.value = formFieldsForCreate;
|
|
|
+ // 所属人是自己,需要把自己的id放进去
|
|
|
+ form.value = { ...cloneDeep(defaultForm) };
|
|
|
+ dialog.value.show = true;
|
|
|
+};
|
|
|
+const toEdit = async (data) => {
|
|
|
+ // 需要将data中public_info(object) 转换成 publicInfo(array,Object.keys())
|
|
|
+ formFields.value = formFieldsForUpdate;
|
|
|
+ const res = await store.getOwner({ owner: data.owner });
|
|
|
+ let owner_name;
|
|
|
+ if ($checkRes(res)) {
|
|
|
+ owner_name = get(res, 'data');
|
|
|
+ }
|
|
|
+ form.value = { ...data, publicInfo: Object.keys(data.public_info || {}), owner_name };
|
|
|
+ dialog.value.show = true;
|
|
|
+};
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 常规接口
|
|
|
+const toSave = async () => {
|
|
|
+ const data = cloneDeep(form.value);
|
|
|
+ // 需要将publicInfo(array) 转换成public_info(object), 并删除publicInfo
|
|
|
+ const public_info = {};
|
|
|
+ for (const i of data.publicInfo) {
|
|
|
+ public_info[i] = true;
|
|
|
+ }
|
|
|
+ data.public_info = public_info;
|
|
|
+ delete data.publicInfo;
|
|
|
+ let res: IQueryResult;
|
|
|
+ if (get(data, '_id')) res = await store.update(data);
|
|
|
+ else res = await store.create(data);
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit });
|
|
|
+ toClose();
|
|
|
+ }
|
|
|
+};
|
|
|
+const toDel = async (data) => {
|
|
|
+ const res = await store.del(data._id);
|
|
|
+ if ($checkRes(res, true)) {
|
|
|
+ search({ skip: 0, limit });
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// #endregion
|
|
|
+
|
|
|
+// #region 表单及操作
|
|
|
+// NeedChange
|
|
|
+const defaultForm = { status: '1', files: [], public_info: {}, publicInfo: [] };
|
|
|
+const formFields: Ref<any> = ref();
|
|
|
+const dialog: Ref<any> = ref({ title: '数据信息', show: false, type: '1' });
|
|
|
+const form: Ref<any> = ref({ file: [] });
|
|
|
+const formFieldsForCreate = [
|
|
|
+ { label: '成果名称', model: 'name' },
|
|
|
+ { label: '行业分类', model: 'industry', type: 'select' },
|
|
|
+ { label: '成果属性', model: 'attr', type: 'select' },
|
|
|
+ { label: '出让方式', model: 'way', type: 'select' },
|
|
|
+ { label: '交易金额', model: 'money' },
|
|
|
+ { label: '成熟度', model: 'maturity', type: 'select' },
|
|
|
+ { label: '技术分类', model: 'tech', type: 'select' },
|
|
|
+ { label: '成果地区', model: 'area', type: 'select' },
|
|
|
+ { label: '发布时间', model: 'time', type: 'datetime' },
|
|
|
+ { label: '附件', model: 'files', custom: true },
|
|
|
+ { label: '成果描述', model: 'desc', type: 'textarea' },
|
|
|
+ { label: '状态', model: 'status', type: 'radio' },
|
|
|
+ { label: '公开信息', model: 'public_info', custom: true }
|
|
|
+];
|
|
|
+const formFieldsForUpdate = [
|
|
|
+ { label: '所属人', model: 'owner_name', options: { disabled: true } },
|
|
|
+ { label: '成果名称', model: 'name' },
|
|
|
+ { label: '行业分类', model: 'industry', type: 'select' },
|
|
|
+ { label: '成果属性', model: 'attr', type: 'select' },
|
|
|
+ { label: '出让方式', model: 'way', type: 'select' },
|
|
|
+ { label: '交易金额', model: 'money' },
|
|
|
+ { label: '成熟度', model: 'maturity', type: 'select' },
|
|
|
+ { label: '技术分类', model: 'tech', type: 'select' },
|
|
|
+ { label: '成果地区', model: 'area', type: 'select' },
|
|
|
+ { label: '发布时间', model: 'time', type: 'datetime' },
|
|
|
+ { label: '附件', model: 'files', custom: true },
|
|
|
+ { label: '成果描述', model: 'desc', type: 'textarea' },
|
|
|
+ { label: '状态', model: 'status', type: 'radio' },
|
|
|
+ { label: '公开信息', model: 'public_info', custom: true }
|
|
|
+];
|
|
|
+const publicInfoList = [
|
|
|
+ { label: '所属人', model: 'owner' },
|
|
|
+ { label: '成果名称', model: 'name' },
|
|
|
+ { label: '行业分类', model: 'industry' },
|
|
|
+ { label: '成果属性', model: 'attr' },
|
|
|
+ { label: '出让方式', model: 'way' },
|
|
|
+ { label: '交易金额', model: 'money' },
|
|
|
+ { label: '成熟度', model: 'maturity' },
|
|
|
+ { label: '技术分类', model: 'tech' },
|
|
|
+ { label: '成果地区', model: 'area' },
|
|
|
+ { label: '发布时间', model: 'time' },
|
|
|
+ { label: '附件', model: 'files' },
|
|
|
+ { label: '成果描述', model: 'desc' }
|
|
|
+];
|
|
|
+// 关闭弹框
|
|
|
+const toClose = () => {
|
|
|
+ form.value = {};
|
|
|
+ dialog.value.show = false;
|
|
|
+};
|
|
|
+const onUpload = (e: { model: string; value: Array<[]> }) => {
|
|
|
+ const { model, value } = e;
|
|
|
+ form.value[model] = value;
|
|
|
+};
|
|
|
+// #endregion
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped></style>
|