浏览代码

提交立项页面代码

ljb 11 月之前
父节点
当前提交
50d0030961
共有 2 个文件被更改,包括 215 次插入51 次删除
  1. 2 23
      src/api/projectManage/projectList.js
  2. 213 28
      src/views/project-manage/components/apply-form.vue

+ 2 - 23
src/api/projectManage/projectList.js

@@ -14,7 +14,7 @@ export const getList = (current, size, params) => {
 
 export const add = (row) => {
   return request({
-    url: '/api/kd-scientific/technician/save',
+    url: '/api/kd-scientific/xm/save',
     method: 'post',
     data: row
   })
@@ -23,29 +23,8 @@ export const add = (row) => {
 
 export const update = (row) => {
   return request({
-    url: '/api/kd-scientific/technician/update',
+    url: '/api/kd-scientific/xm/update',
     method: 'post',
     data: row
   })
 }
-
-
-export const remove = (ids) => {
-  return request({
-    url: '/api/kd-scientific/technician/remove',
-    method: 'post',
-    params: {
-      ids,
-    }
-  })
-}
-
-export const getLastMonthData = params => {
-  return request({
-    url: '/kd-scientific/technician/fetchLastMonthData',
-    method: 'get',
-    params: {
-      ...params,
-    }
-  })
-}

+ 213 - 28
src/views/project-manage/components/apply-form.vue

@@ -2,15 +2,15 @@
   <div class="apply-form">
     <h3 class="page-title">科德集团</h3>
 
-    <h3 class="page-title">研发项目立项资料</h3>
+    <h3 class="page-title" style="margin-bottom: 10px;">{{ getDocTile }}</h3>
     <div class="project-basic-info">
-      <div class="info-row">研发项目名称:1234234</div>
-      <div class="info-row">项目负责人:test</div>
-      <div class="info-row">项目申请单位:test</div>
-      <div class="info-row">项目执行期:</div>
+      <div class="info-row">{{ `研发项目名称:${ formData.xmmc || '' }` }}</div>
+      <div class="info-row">{{ `项目负责人:${ getXmfzrName || '' }` }}</div>
+      <div class="info-row">{{ `项目申请单位:${ formData.xmsqdw || '' }` }}</div>
+      <div class="info-row">{{ `项目执行期:${ getXmDateRange || '' }` }}</div>
     </div>
 
-    <h3 class="page-title">研发立项申请表</h3>
+    <h3 class="page-title" style="margin: 24px 0 16px;">研发立项申请表</h3>
     <table>
       <tbody>
         <tr>
@@ -29,7 +29,12 @@
         <tr>
           <td class="doc-label">项目负责人</td>
           <td class="doc-input">
-            <el-input v-model="formData.xmfzr" placeholder="请输入项目负责人" />
+            <avue-select
+              v-model="formData.xmfzr"
+              placeholder="请选择"
+              :dic="fzrList"
+              style="width: 100%"
+            ></avue-select>
           </td>
           <td class="doc-label">研究类型</td>
           <td class="doc-input">
@@ -108,37 +113,51 @@
         <tr>
           <td class="doc-label">项目预算总额(万元)</td>
           <td class="doc-input">
-            {{ "13,400" }}
+            {{ budgetAmount }}
           </td>
           <td class="doc-label">其中</td>
           <td class="doc-input">
-            <!-- <avue-select multiple v-model="formData.yjlx" placeholder="请选择" :dic="dic"></avue-select> -->
+            <div class="year-list">
+              <div class="year-list-item" v-for="year of yearList" :key="year">
+                <div class="year" >{{ year }}</div>
+                <div class="year-input">
+                  <input v-model="formData[year]" type="number" />
+                </div>
+              </div>
+            </div>
           </td>
         </tr>
       </tbody>
     </table>
 
     <avue-form v-model="formData" :option="option" style="margin-top: 30px;"></avue-form>
+    <p class="tip">注:可一次上传多个相关文件(文档、表格、图片等)。 支持格式:DOC, PDF, Excel, PNG, JPG, PPT 等。 请确保文件内容清晰有效。</p>
+
+    <div class="btn-wrap" style="text-align: center;">
+      <el-button type="primary" style="width: 160px;" @click="handleSaveBtn">保存</el-button>
+    </div>
   </div>
 </template>
 
 <script>
 import { getDictionary } from "@/api/system/dictbiz";
+import { getList as getTechnicanRosterList } from "@/api/basicResource/technicianRoster";
+import { add, update } from "@/api/projectManage/projectList";
+import moment from "moment";
 
 export default {
   data() {
     return {
       formData: {},
-      dic: [
-        {
-          label: "选项1",
-          value: 0,
-        },
-        {
-          label: "选项2",
-          value: 1,
-        },
-      ],
+
+      // 项目预算总额
+      budgetAmount: 0,
+
+      yearList: [],
+
+      // 项目负责人列表
+      fzrList: [],
+
       // 研究类型数据字典
       studyTypeList: [],
       // 项目来源列表
@@ -151,21 +170,23 @@ export default {
       economicObjectivesList: [],
 
       option: {
+        submitBtn: false,
         emptyBtn: false,
         submitText: '保存',
+        menuBtn: false,
         column: [
           {
             label: "立项批文",
-            prop: "imgUrl",
+            prop: "lxpw",
             type: "upload",
             multiple: true,
             span: 24,
             propsHttp: {
-              url: "url",
+              url: "link",
               name: "name",
               res: "data",
             },
-            action: '',
+            action: '/api/kd-resource/oss/endpoint/put-file',
             rules: [{
               required: true,
               message: "请上传立项批文"
@@ -173,16 +194,16 @@ export default {
           },
           {
             label: "立项报告",
-            prop: "imgUrl",
+            prop: "lxbg",
             type: "upload",
             multiple: true,
             span: 24,
             propsHttp: {
-              url: "url",
+              url: "link",
               name: "name",
               res: "data",
             },
-            action: '',
+            action: '/api/kd-resource/oss/endpoint/put-file',
             rules: [{
               required: true,
               message: "请上传立项报告"
@@ -190,22 +211,57 @@ export default {
           },
           {
             label: "其他资料",
-            prop: "imgUrl",
+            prop: "qtzl",
             type: "upload",
             multiple: true,
             span: 24,
+            action: '/api/kd-resource/oss/endpoint/put-file',
             propsHttp: {
-              url: "url",
+              url: "link",
               name: "name",
               res: "data",
             },
             action: '',
-            tip: '注:可一次上传多个相关文件(文档、表格、图片等)。 支持格式:DOC, PDF, Excel, PNG, JPG, PPT 等。 请确保文件内容清晰有效。',
           },
         ],
       },
     };
   },
+  watch: {
+    'formData.xmkssj'(newVal) {
+      this.yearList = this.getDateRangeYear(newVal, this.formData.xmjssj);
+      let cMonth = moment(newVal).format('yyyyMM');
+      if (cMonth != this.xmStartDateYearAndMonth) {
+        this.xmStartDateYearAndMonth = cMonth;
+        this.getTechnicanRosterListFunc(cMonth)
+      }
+    },
+    'formData.xmjssj'(newVal) {
+      this.yearList = this.getDateRangeYear(this.formData.xmkssj, newVal);
+    }
+  },
+  computed: {
+    getDocTile() {
+      let tit = '研发项目资料';
+      if (this.formData.xmmc) {
+        return `${this.formData.xmmc}${tit}`;
+      }
+      return tit;
+    },
+    getXmfzrName() {
+      if (this.formData.xmfzr) {
+        let fzrObj = this.fzrList.find(item => item.value == this.formData.xmfzr);
+        return fzrObj ? fzrObj.label : "";
+      }
+      return;
+    },
+    getXmDateRange() {
+      if (this.formData.xmkssj && this.formData.xmjssj) {
+        return `${this.formData.xmkssj}至${this.formData.xmjssj}`;
+      }
+      return `年 月 日至 年 月 日`;
+    },
+  },
   mounted() {
     this.getDictList("study_type", "studyTypeList");
     this.getDictList("project_source", "projectSourceList");
@@ -214,6 +270,19 @@ export default {
     this.getDictList("economic_objectives", "economicObjectivesList");
   },
   methods: {
+    getDateRangeYear(sDate, eDate) {
+      let yearArr = [];
+      if (sDate && eDate) {
+        let sDateYear = moment(sDate).format('yyyy');
+        let dDateYear = moment(eDate).format('yyyy');
+
+        for (let i=sDateYear; i<=dDateYear; i++) {
+          yearArr.push(i);
+        }
+      }
+      
+      return yearArr;
+    },
     getDictList(code, toListKey) {
       getDictionary({ code }).then((res) => {
         this[toListKey] = res.data.data.map((item) => {
@@ -221,6 +290,78 @@ export default {
         });
       });
     },
+    /**
+     * 获取人员花名册
+     */
+    getTechnicanRosterListFunc(yearAndMonth) {
+      getTechnicanRosterList(1, 99999, { yearAndMonth }).then(res => {
+        if (res.data.success) {
+          this.fzrList = res.data.data.records.map(item => {
+            return { label: item.name, value: item.id };
+          });
+        }
+      });
+    },
+    validForm() {
+      let errorText = '';
+      if (!this.formData.xmmc) {
+        errorText = '请输入项目名称';
+      } else if (/技改|技术改造|推广|打样|翻新|产业化|生产线|改造|年产|示范/g.test(this.formData.xmmc)) {
+        errorText = '研发项目名称,不符合统计部门的命名要求';
+      } else if (!this.formData.xmfzr) {
+        errorText = '请选择项目负责人';
+      } else if (!this.formData.xmkssj) {
+        errorText = '请选择项目开始时间';
+      } else if (!this.formData.xmjssj) {
+        errorText = '请选择项目结束时间';
+      } else if (!this.formData.lxpw) {
+        errorText = '请上传立项批文!';
+      } else if (!this.formData.lxbg) {
+        errorText = '请上传立项报告!';
+      } else {
+        let yearAmount = 0;
+        this.yearList.forEach(year => {
+          let account = this.formData[year] || 0;
+          yearAmount += account;
+        });
+        if (yearAmount > this.budgetAmount) {
+          errorText = '所有年份的预算不等于项目预算总额,请重新填写!';
+        }
+      }
+
+      return errorText;
+    },
+    handleSaveBtn() {
+      let errorText = this.validForm();
+      if (errorText) {
+        this.$message.error(errorText+'!');
+        return;
+      }
+
+      let params = { ...this.formData };
+      params.yqcgxs = params.yqcgxs ? params.yqcgxs.join(',') : '';
+      params.xmjsjjmb = params.xmjsjjmb ? params.xmjsjjmb.join(',') : '';
+      params.lxbg = params.lxbg ? params.lxbg.join(',') : '';
+      params.lxpw = params.lxpw ? params.lxpw.join(',') : '';
+      params.qtzl = params.qtzl ? params.qtzl.join(',') : '';
+      params.xmkssj = moment(params.xmkssj).format('yyyy年MM月DD日');
+      params.xmjssj = moment(params.xmjssj).format('yyyy年MM月DD日');
+      let yearAmountList = [];
+      this.yearList.forEach(year => {
+        yearAmountList.push({ year: Number(year), amount: params[year] || 0 });
+        delete params[year];
+      });
+      params.yearAmountList = yearAmountList;
+
+      console.log(params)
+      this.addOrUpdate(params);
+    },
+    addOrUpdate(params) {
+      let func = params.id ? update : add;
+      add(params).then(res => {
+
+      });
+    }
   },
 };
 </script>
@@ -228,7 +369,14 @@ export default {
 <style lang="scss" scoped>
 .page-title {
   text-align: center;
+  font-size: 24px;
+}
+
+.project-basic-info .info-row {
+  line-height: 26px;
+  color: #666;
 }
+
 .apply-form {
   width: 800px;
   margin: 30px auto;
@@ -248,7 +396,44 @@ table {
   text-align: center;
   color: #333;
 }
+
+.el-input__inner {
+  border: none;
+}
 tr td {
   border: 1px solid #333;
 }
+
+.year-list {
+  &-item {
+    display: flex;
+    height: 32px;
+    line-height: 32px;
+    border-bottom: 1px solid #333;
+    &:last-child {
+      border-bottom: 0;
+    }
+    .year {
+      width: 65px;
+      border-right: 1px solid #333;
+    }
+    .year-input {
+      input {
+        width: 100%;
+        height: 30px;
+        border: 0;
+      }
+    }
+  }
+  
+}
+
+.tip {
+  position: relative;
+  top: -20px;
+  color: red;
+  padding-left: 90px;
+  margin-top: 0;
+  font-size: 12px;
+}
 </style>