Explorar o código

📦五年计划页面

快乐的梦鱼 hai 2 semanas
pai
achega
cd80d62df0

+ 56 - 1
src/api/inheritor/InheritorContent.ts

@@ -1,4 +1,4 @@
-import { DataModel } from '@imengyu/js-request-transform';
+import { DataModel, transformArrayDataModel } from '@imengyu/js-request-transform';
 import { AppServerRequestModule } from '../RequestModules';
 import dayjs from 'dayjs';
 
@@ -423,6 +423,42 @@ export class SeminarExpandInfo extends DataModel<SeminarExpandInfo> {
   modelId = 17;
   lonlat = [] as (number|string)[];
 }
+export class PlanInfo extends DataModel<PlanInfo> {
+  constructor() {
+    super(PlanInfo, "五年计划");
+    this.setNameMapperCase('Camel', 'Snake');
+    this._convertTable = {
+      progress: { clientSide: 'number', serverSide: 'undefined' },
+    };
+    this._convertKeyType = (key, direction) => {
+      if (key.endsWith('Text') || key.endsWith('_text')) {
+        return {
+          clientSide: 'string',
+          serverSide: 'undefined',
+        };
+      }
+    };
+    this._afterSolveServer = (self) => {
+    };
+    this._afterSolveClient = (data) => {
+    };
+  }
+
+  id = 0 as number;
+  ichId = 0 as number;
+  name = '' as string;
+  investment = 0 as number;
+  desc = '' as string;
+  target = '' as string;
+  unit = 0 as number;
+  department = 0 as number;
+  userId = 0 as number;
+  progress = 0 as number;
+  createdAt = '' as string;
+  updatedAt = '' as string;
+  ichName = '' as string;
+  progressText = '' as string;
+}
 
 export class InheritorContentApi extends AppServerRequestModule<DataModel> {
 
@@ -435,6 +471,22 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
       model_id: new newDataModel().modelId,
     }, '基础表信息', undefined, newDataModel)).data as T;
   }
+  /**
+   * 项目五年计划
+   * @param ichId 项目ID:传承人只返回绑定项目的计划
+   * @param progress 审核进度:-1=不通过,0=待审核,1=已通过
+   * @returns 
+   */
+  async getPlanList(ichId: number, progress?: number) {
+    return transformArrayDataModel<PlanInfo>(
+      PlanInfo,
+      (await this.post('/ich/inheritor/plans', {
+        ich_id: ichId,
+        progress,
+      }, '获取计划列表')).data2.data,
+      "data2"
+    );
+  }
   async saveBaseInfo<T extends DataModel>(dataModel: T) {
     return (await this.post('/ich/inheritor/saveBase', dataModel.toServerSide(), '基础内容表采集(非遗,传承人,传习所)'));
   }
@@ -446,6 +498,9 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
   async saveExpandInfo<T extends DataModel>(dataModel: T) {
     return (await this.post('/ich/inheritor/saveExpand', dataModel.toServerSide(), '扩展内容表采集(非遗,传承人,传习所)'));
   }
+  async savePlanInfo(dataModel: PlanInfo) {
+    return (await this.post('/ich/inheritor/savePlans', dataModel.toServerSide(), '保存项目五年计划'));
+  }
 
   async getIchInfo() {
     return await this.getBaseInfo(IchInfo);

+ 1 - 4
src/components/NavBar.vue

@@ -32,8 +32,6 @@
   >
     <div></div>
     <div class="group">
-      <!-- <div class="link-placeholder" /> -->
-      <RouterLink to="/">首页</RouterLink>
     </div>
     <div class="group center">
       <div class="headerlogos">
@@ -45,7 +43,6 @@
       </div>
     </div>
     <div class="group">
-      <RouterLink to="/inheritor">我的</RouterLink>
     </div>
     
     <a-dropdown v-if="authStore.isLogged" :trigger="['click']">
@@ -207,7 +204,7 @@ nav.main {
 }
 
 .mobile-menu {
-  display: none;
+  //display: none;
   position: fixed;
   left: 25px;
   top: 20px;

+ 65 - 0
src/pages/admin.vue

@@ -0,0 +1,65 @@
+<template>
+  <!-- 管理员管理首页 -->
+  <div class="about main-background main-background-type0">
+    <div class="nav-placeholder">
+    </div>
+    <!-- 表单 -->
+    <section class="main-section ">
+      <div class="content">
+        <div class="title">
+          <h2>管理列表</h2>
+        </div>
+       
+        <a-tabs v-model:activeKey="activeKey" centered>
+          <a-tab-pane key="1" tab="传承人">
+            <EmptyToRecord title="传承人" :model="inheritorData?.works" :showEdited="false" @edit="router.push({ name: 'FormWork' })">
+              <div class="d-flex justify-content-end">
+                <a-button type="primary" @click="router.push({ name: 'FormWork' })">+ 新增</a-button>
+              </div>
+              <a-list item-layout="horizontal" :data-source="inheritorData?.works || []">
+                <template #renderItem="{ item }">
+                  <a-list-item>
+                    <a-list-item-meta
+                      :title="item.title"
+                      :description="item.desc"
+                    >
+                      <template #avatar>
+                        <a-avatar :src="item.image" />
+                      </template>
+                    </a-list-item-meta>
+                    <template #actions>
+                      <a key="list-loadmore-edit" @click="router.push({ name: 'FormWork', query: { id: item.id } })">编辑</a>
+                    </template>
+                  </a-list-item>
+                </template>
+              </a-list>
+            </EmptyToRecord>
+          </a-tab-pane>
+        </a-tabs>
+      </div>
+    </section>
+  </div>
+</template>
+
+
+<script setup lang="ts">
+import { onMounted, ref, watch } from 'vue';
+import { useRoute, useRouter } from 'vue-router';
+import type { IchInfo, InheritorInfo, PlanInfo, SeminarInfo } from '@/api/inheritor/InheritorContent';
+import EmptyToRecord from '@/components/parts/EmptyToRecord.vue';
+
+const router = useRouter();
+const route = useRoute();
+const activeKey = ref(route.query.tab as string || '1');
+const ichData = ref<IchInfo>();
+const inheritorData = ref<InheritorInfo>();
+const seminarData = ref<SeminarInfo>();
+const planData = ref<PlanInfo[]>([]);
+
+watch(activeKey, (newValue) => {
+  router.replace({ query: { tab: newValue } });
+})
+onMounted(() => {
+
+})
+</script>

+ 54 - 0
src/pages/forms/plans.vue

@@ -0,0 +1,54 @@
+<template>
+  <!-- 五年计划 -->
+  <Form 
+    :formModel="formModel"
+    :formOptions="formOptions"
+    :load="loadData"
+  />
+</template>
+
+<script setup lang="ts">
+import { ref, type Ref } from 'vue';
+import { useRoute } from 'vue-router';
+import Form from './form.vue';
+import InheritorContent, { PlanInfo } from '@/api/inheritor/InheritorContent';
+import type { IDynamicFormOptions } from '@imengyu/vue-dynamic-form';
+
+const formModel = ref(new PlanInfo()) as Ref<PlanInfo>;
+const formOptions = ref<IDynamicFormOptions>({
+  formLabelCol: { span: 6 },
+  formWrapperCol: { span: 24 },
+  formAdditionaProps: {
+    layout: 'vertical',
+    scrollToFirstError: true,
+  },
+  formNestNameGenerateType: 'array',
+  formItems: [
+      { label: '预算项目名称', name: 'name', type: 'text', additionalProps: { placeholder: '请输入预算项目名称' } },
+      { label: '经费投入(万元)', name: 'investment', type: 'number', additionalProps: { placeholder: '请输入经费投入(万元)', min: 0, precision: 2 } },
+      { label: '依据说明', name: 'desc', type: 'text-area', additionalProps: { placeholder: '请输入依据说明' } },
+      { label: '预期目标', name: 'target', type: 'text-area', additionalProps: { placeholder: '请输入预期目标' } },
+      { label: '保护单位自筹资金', name: 'unit', type: 'number', additionalProps: { placeholder: '请输入保护单位自筹资金', min: 0, precision: 2 } },
+      { label: '地方(部门)投入资金', name: 'department', type: 'number', additionalProps: { placeholder: '请输入地方(部门)投入资金', min: 0, precision: 2 } }
+  ],
+  formRules: {
+    name: [{ required: true, message: '请输入预算项目名称' }],
+    investment: [{ required: true, message: '请输入经费投入(万元)' }, { type: 'number', min: 0, message: '经费投入不能为负数' }],
+    desc: [{ required: true, message: '请输入依据说明' }],
+    target: [{ required: true, message: '请输入预期目标' }],
+    unit: [{ required: true, message: '请输入保护单位自筹资金' }, { type: 'number', min: 0, message: '保护单位自筹资金不能为负数' }],
+    department: [{ required: true, message: '请输入地方(部门)投入资金' }, { type: 'number', min: 0, message: '地方(部门)投入资金不能为负数' }]
+  }
+});
+
+const route = useRoute();
+
+async function loadData() {
+  const id = parseFloat(route.query.id as string);
+  if (id) {
+    const ichId = (await InheritorContent.getIchInfo()).id;
+    formModel.value = (await InheritorContent.getPlanList(ichId)).find((item) => item.id === id) || new PlanInfo();
+  }
+}
+
+</script>

+ 1 - 1
src/pages/forms/works.vue

@@ -103,7 +103,7 @@ const formOptions = ref<IDynamicFormOptions>({
 const route = useRoute();
 
 async function loadData() {
-  const id = parseFloat(route.params.id as string);
+  const id = parseFloat(route.query.id as string);
   if (id) {
     const works = await InheritorContent.getInheritorInfo();
     formModel.value = works.works.find((item) => item.id === id) || new InheritorWorkInfo();

+ 42 - 5
src/pages/inheritor.vue

@@ -75,6 +75,9 @@
           </a-tab-pane>
           <a-tab-pane key="3" tab="作品">
             <EmptyToRecord title="作品" :model="inheritorData?.works" :showEdited="false" @edit="router.push({ name: 'FormWork' })">
+              <div class="d-flex justify-content-end">
+                <a-button type="primary" @click="router.push({ name: 'FormWork' })">+ 新增</a-button>
+              </div>
               <a-list item-layout="horizontal" :data-source="inheritorData?.works || []">
                 <template #renderItem="{ item }">
                   <a-list-item>
@@ -86,6 +89,9 @@
                         <a-avatar :src="item.image" />
                       </template>
                     </a-list-item-meta>
+                    <template #actions>
+                      <a key="list-loadmore-edit" @click="router.push({ name: 'FormWork', query: { id: item.id } })">编辑</a>
+                    </template>
                   </a-list-item>
                 </template>
               </a-list>
@@ -128,6 +134,29 @@
               </a-descriptions>
             </EmptyToRecord>
           </a-tab-pane>
+          <a-tab-pane key="5" tab="五年计划">
+            <EmptyToRecord title="五年计划" :model="planData" :showEdited="false" @edit="router.push({ name: 'FormPlan' })">
+              <div class="d-flex justify-content-end">
+                <a-button type="primary" @click="router.push({ name: 'FormPlan' })">+ 新增</a-button>
+              </div>
+              <a-list item-layout="horizontal" :data-source="planData">
+                <template #renderItem="{ item }">
+                  <a-list-item>
+                    <a-list-item-meta
+                      :title="item.name"
+                      :description="item.desc"
+                    />
+                    <template #actions>
+                      <a-badge v-if="item.progress === -1" status="error" text="不通过" />
+                      <a-badge v-else-if="item.progress === 0" status="processing" text="待审核" />
+                      <a-badge v-else-if="item.progress === 1" status="success" text="已通过" />
+                      <a key="list-loadmore-edit" @click="router.push({ name: 'FormPlan', query: { id: item.id } })">编辑</a>
+                    </template>
+                  </a-list-item>
+                </template>
+              </a-list>
+            </EmptyToRecord>
+          </a-tab-pane>
         </a-tabs>
       </div>
     </section>
@@ -135,9 +164,9 @@
 </template>
 
 <script setup lang="ts">
-import { onMounted, ref } from 'vue';
-import { useRouter } from 'vue-router';
-import type { IchInfo, InheritorInfo, SeminarInfo } from '@/api/inheritor/InheritorContent';
+import { onMounted, ref, watch } from 'vue';
+import { useRoute, useRouter } from 'vue-router';
+import type { IchInfo, InheritorInfo, PlanInfo, SeminarInfo } from '@/api/inheritor/InheritorContent';
 import InheritorContent from '@/api/inheritor/InheritorContent';
 import ImageGrid from '@/components/content/ImageGrid.vue';
 import SimplePointedMap from '@/components/content/SimplePointedMap.vue';
@@ -145,15 +174,23 @@ import SimpleRichHtml from '@/components/display/SimpleRichHtml.vue';
 import ShowValueOrNull from '@/components/dynamicf/Display/ShowValueOrNull.vue';
 import EmptyToRecord from '@/components/parts/EmptyToRecord.vue';
 
-const activeKey = ref('1');
+const router = useRouter();
+const route = useRoute();
+const activeKey = ref(route.query.tab as string || '1');
 const ichData = ref<IchInfo>();
 const inheritorData = ref<InheritorInfo>();
 const seminarData = ref<SeminarInfo>();
-const router = useRouter();
+const planData = ref<PlanInfo[]>([]);
 
+watch(activeKey, (newValue) => {
+  router.replace({ query: { tab: newValue } });
+})
 onMounted(() => {
   InheritorContent.getIchInfo().then(data => {
     ichData.value = data;
+    InheritorContent.getPlanList(ichData.value.id).then(data => {
+      planData.value = data;
+    });
   });
   InheritorContent.getInheritorInfo().then(data => {
     inheritorData.value = data;

+ 5 - 0
src/router/index.ts

@@ -31,6 +31,11 @@ const router = createRouter({
       component: () => import('@/pages/forms/works.vue'),
     }, 
     {
+      path: '/forms/plan',
+      name: 'FormPlan',
+      component: () => import('@/pages/forms/plans.vue'),
+    },
+    {
       path: '/login',
       name: 'Login',
       component: () => import('@/pages/login.vue'),