Browse Source

部门月度计划修改

duy 2 years ago
parent
commit
9f3fa51497

+ 7 - 0
src/api/modules/other.js

@@ -44,4 +44,11 @@ export const getdepartmentList = (form, msg = true) => httpApi({
     method: 'get',
     params: form
 }, msg);
+//获取用户列表
+export const getuserList = (form, msg = true) => httpApi({
+    url: '/api/blade-user/user-list',
+    method: 'get',
+    params: form
+}, msg);
+
 

+ 34 - 0
src/api/modules/program/section.js

@@ -33,4 +33,38 @@ export default {
             data: form
         }, msg);
     },
+    //开启时获取计划
+    async getPlanInOpen(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-control/departmentPlanLog/getPlanInOpen',
+            method: 'get',
+            params: form
+        }, msg);
+    },
+    //暂停时获取计划
+    async getPlanInPause(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-control/departmentPlanLog/getPlanInPause',
+            method: 'get',
+            params: form
+        }, msg);
+    },
+    //修改部门月度计划
+    async updateDepartmentPlan(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-control/departmentMonthPlan/updateDepartmentPlan',
+            method: 'post',
+            data: form
+        }, msg);
+    },
+    //删除部门月度计划
+    async deleteById(form, msg = true) {
+        return httpApi({
+            url: '/api/blade-control/departmentMonthPlan/deleteById',
+            method: 'get',
+            params: form
+        }, msg);
+    },
+
+
 }

+ 82 - 24
src/views/program/section/form.vue

@@ -4,15 +4,14 @@
             <HcNewSwitch :datas="tabTab" :keys="tabKey" @change="tabChange" :round="false"/>
         </template>
         <HcTable :isIndex="false" :column="tableColumn" :datas="tableData" :loading="tableLoading">
-            <template #key9="{row}">
-                <el-select v-model="row.key9" size="small">
-                    <el-option label="选项1" value="选项1"/>
-                    <el-option label="选项2" value="选项2"/>
+            <template #taskUser="{row}">
+                <el-select v-model="row.taskUser" size="small">
+                    <el-option v-for="item in department" :label="item.name" :value="item.id"/>
                 </el-select>
             </template>
-            <template #action="{row,index}">
-                <el-button size="small" type="primary" @click="openPlanModalShow(row)">开启</el-button>
-                <el-button size="small" type="danger" @click="pausePlanModalShow(row)">暂停</el-button>
+            <template #action="{row,index}" >
+                <el-button size="small" type="primary" @click="openPlanModalShow(row)"  :disabled="row.startOrStop==1||row.startOrStop==0">开启</el-button>
+                <el-button size="small" type="danger" @click="pausePlanModalShow(row)" :disabled="row.startOrStop==2||row.startOrStop==0">暂停</el-button>
             </template>
         </HcTable>
         <template #action>
@@ -77,27 +76,25 @@
 import {useRouter,useRoute} from 'vue-router'
 import {onActivated, ref,watch} from "vue";
 import sectionApi from '~api/program/section.js';
-import {getArrValue,getObjValue,formValidate} from "js-fast-way"
-
+import {getArrValue,getObjValue,formValidate, arrIndex} from "js-fast-way"
+import { getuserList} from "~api/other";
 const router = useRouter()
 const useRoutes = useRoute()
 const dataId = ref(useRoutes?.query?.id ?? '')
 const dataType = ref(useRoutes?.query?.type ?? '')
 const planDate=ref(useRoutes?.query?.month ?? '')
 const departmentType=ref(useRoutes?.query?.section ?? '')
+const deptId=ref(useRoutes?.query?.deptId ?? '')
 //缓存页面被激活时
 onActivated(() => {
     dataId.value = useRoutes?.query?.id ?? ''
     dataType.value = useRoutes?.query?.type ?? ''
     planDate.value = useRoutes?.query?.month ?? ''
     departmentType.value = useRoutes?.query?.section ?? ''
+    deptId.value = useRoutes?.query?.deptId ?? ''
+    setTabData(departmentType.value)
     getDepartmentPlan()
-    if(dataType.value!=='add'){
-        // getDepartmentPlan()
-    
-    }else if(dataType.value=='add'){
-  
-    }
+    getDepartmentuserDict()//获取部门人员字典
 
  
 })
@@ -106,6 +103,7 @@ const getDepartmentPlan=async()=>{
     const {error, code, data} = await sectionApi.getDepartmentPlan(
         {
             departmentType:departmentType.value,
+            deptId:deptId.value,
             planDate:planDate.value,
            
         }
@@ -120,20 +118,47 @@ const getDepartmentPlan=async()=>{
         // milestoneData.value=[]
     }
 }
+const department=ref([])
+//获取部门人员列表
+const getDepartmentuserDict=async()=>{
+    const {error, code, data} = await getuserList({deptId:deptId.value})
+    if (!error && code === 200) {
+        department.value = getArrValue(data)
+
+    } else {
+        department.value = []
+
+    }
+}
 
 //类型tab数据和相关处理
-const tabKey = ref('key1')
+const tabKey = ref('1')
 const tabTab = ref([
-    {key: 'key1', name: '市场部月度预算'},
-    {key: 'key2', name: '研发部月度预算'},
-    {key: 'key3', name: '实施部月度预算'},
-    {key: 'key4', name: '维护部月度预算'},
-    {key: 'key5', name: '人事行政(财务)部月度预算'},
+    {key: '1', name: '市场部月度预算'},
+    {key: '2', name: '研发部月度预算'},
+    {key: '3', name: '实施部月度预算'},
+    {key: '4', name: '维护部月度预算'},
+    {key: '5', name: '人事行政(财务)部月度预算'},
 ]);
 const tabChange = ({key}) => {
     tabKey.value = key
 }
-
+//设置tab
+const setTabData=(key)=>{
+    tabKey.value=key
+    if(key=='1'){
+        tabTab.value=[{key: '1', name: '市场部月度预算'}]
+    }else if(key=='2'){
+        console.log(2222222);
+        tabTab.value=[{key: '2', name: '研发部月度预算'},]
+    }else if(key=='3'){
+        tabTab.value=[ {key: '3', name: '实施部月度预算'},]
+    }else if(key=='4'){
+        tabTab.value=[   {key: '4', name: '维护部月度预算'},]
+    }else if(key=='5'){
+        tabTab.value=[{key: '5', name: '人事行政(财务)部月度预算'},]
+    }
+}
 
 //获取数据
 const tableLoading = ref(false)
@@ -165,8 +190,21 @@ const getTableData = () => {
 //开启计划
 const openPlanModal = ref(false)
 const openPlanModalShow = (row) => {
+    getPlanInOpen(row.id)
     openPlanModal.value = true
 }
+//获取开启计划
+const openPlan=ref({})
+const getPlanInOpen=async(id)=>{
+    const {error, code, data} = await sectionApi.getPlanInOpen({id})
+    if (!error && code === 200) {
+        openPlan.value = getObjValue(data)
+
+    } else {
+        openPlan.value = {}
+
+    }
+}
 const openPlanCloseClick = () => {
     openPlanModal.value = false
 }
@@ -185,8 +223,21 @@ const betweenTimeUpdate = ({arr, query}) => {
 //暂停计划
 const pausePlanModal = ref(false)
 const pausePlanModalShow = (row) => {
+    getPlanInPause(row.id)
     pausePlanModal.value = true
 }
+//获取暂停计划
+const pausePlan=ref({})
+const getPlanInPause=async(id)=>{
+    const {error, code, data} = await sectionApi.getPlanInPause({id})
+    if (!error && code === 200) {
+        pausePlan.value = getObjValue(data)
+
+    } else {
+        pausePlan.value = {}
+
+    }
+}
 const pausePlanCloseClick = () => {
     pausePlanModal.value = false
 }
@@ -199,9 +250,16 @@ const pausePlanSaveClick = () => {
 const goBackClick = () => {
     router.back()
 }
-
+const saveLoaing=ref(false)
 //提交保存
-const saveClick = () => {
+const saveClick = async() => {
+    console.log(tableData.value,'tableData');
+    saveLoaing.value=true
+        const {error, code, data,msg} = await sectionApi.updateDepartmentPlan( tableData.value)
+        saveLoaing.value=false
+        if (!error && code === 200) {
+            window.$message.success(msg)
+        } 
 
 }
 </script>

+ 25 - 14
src/views/program/section/index.vue

@@ -2,8 +2,8 @@
     <HcCard>
         <template #header>
             <div class="w-36">
-                <el-select v-model="searchForm.department" block clearable placeholder="选择部门" size="large">
-                    <el-option v-for="item in department" :label="item.name" :value="item.key"/>
+                <el-select v-model="searchForm.departmentType" block clearable placeholder="选择部门" size="large">
+                    <el-option v-for="item in department" :label="item.deptName" :value="item.deptCategory"/>
                 </el-select>
             </div>
             <div class="w-36 ml-4">
@@ -65,8 +65,8 @@
         >
             <el-form ref="formMonthRef" label-position="top" size="large" :model="formMonthModel" :rules="formMonthRules">
                 <el-form-item label="选择部门" prop="section">
-                    <el-select v-model="formMonthModel.section" block placeholder="选择部门">
-                        <el-option v-for="item in department" :label="item.dictName" :value="item.dictValue"/>
+                    <el-select v-model="formMonthModel.section" block placeholder="选择部门" @change="changeDpt">
+                        <el-option v-for="item in department" :label="item.deptName" :value="item.deptCategory"/>
                     </el-select>
                 </el-form-item>
                 <el-form-item label="选择月份" prop="month">
@@ -79,27 +79,27 @@
 </template>
 
 <script setup>
-import {ref,onMounted,onActivated} from "vue";
+import {ref,onMounted,onActivated,watch} from "vue";
 import {useRouter} from 'vue-router'
 import sectionApi from '~api/program/section.js';
 import {useAppStore} from "~src/store";
 import {getArrValue,getObjValue,formValidate} from "js-fast-way"
+import { getdepartmentList} from "~api/other";
 
 const router = useRouter()
 onActivated(()=>{
-    getTableData()
+    getTableData() 
+    getDepartmentDict()//获取部门字典
 
 })
 //选择部门
 const department = ref([
-    {name: '研发部门', key: '1'},
-    {name: '业务部门', key: '2'},
-    {name: '人事部门', key: '3'},
+   
 ])
 
 //搜索表单
 const searchForm = ref({
-    planType: null, startTime: null, endTime: null, department: null, queryValue: '',
+    planType: null, planStartDate: null, planEndDate: null, departmentType: null,
     current: 1, size: 20, total: 0
 })
 
@@ -159,11 +159,11 @@ const rowNameClick = (row) => {
 //新增计划
 const addRowClick = () => {
     monthModal.value = true
-    getDepartmentDict()
+   
 }
 //获取所属部门列表
 const getDepartmentDict=async()=>{
-    const {error, code, data} = await sectionApi.getDepartmentDict()
+    const {error, code, data} = await getdepartmentList({deptType:2})
     if (!error && code === 200) {
         department.value = getArrValue(data)
 
@@ -189,6 +189,15 @@ const formMonthRules = {
 const monthCloseClick = () => {
     monthModal.value = false
 }
+//选择部门
+const deptId=ref('')
+const changeDpt=(val)=>{
+    department.value.forEach((ele)=>{
+        if(ele.deptCategory=val){
+            deptId.value=ele.id
+        }
+    })
+}
 //新增部门月计划
 const addPlan=async(obj)=>{;
     const {error, code, data,msg} = await sectionApi.addDepartmentPlan( {
@@ -200,7 +209,7 @@ const addPlan=async(obj)=>{;
         monthModal.value = false
         router.push({
             name: 'program-section-form',
-            query: {...formMonthModel.value,type:'add'},
+            query: {...formMonthModel.value,type:'add',deptId:deptId.value},
     
         })
     } 
@@ -218,13 +227,15 @@ const monthSaveClick =async() => {
 
 //编辑预算
 const editRowClick = (row) => {
+    changeDpt(row.departmentType)
     router.push({
         name: 'program-section-form',
         query: {
             id: row.id,
             month:row.planDate,
             section:row.departmentType,
-            type:'edit'
+            type:'edit',
+            deptId:deptId.value
         }
     })
 }

+ 3 - 3
src/views/static/components/tab-all.vue

@@ -8,7 +8,7 @@
                     </el-select>
                 </div>
             </el-row>
-              <el-table :data="tableData" border class="mt-4 "  v-if="costcheck==1"  stripe :header-cell-style="headerStyle" style="height: 90%;">
+              <el-table :data="tableData" border class="mt-4 "  v-if="costcheck==1"  stripe :header-cell-style="headerStyle" style="height: 87%;">
                   <el-table-column v-for="item in tableColData"  align="center" 
                   :prop="item.id"
                   :label="item.name"
@@ -33,7 +33,7 @@
               </el-table>
        
        
-            <el-table stripe :data="tableData" border class="mt-4 " v-if="costcheck==2" :header-cell-style="{ background:'rgb(214, 225, 255)', fontSize:'16px',color:'black'}"   style="height: 90%;">
+            <el-table stripe :data="tableData" border class="mt-4 " v-if="costcheck==2" :header-cell-style="{ background:'rgb(214, 225, 255)', fontSize:'16px',color:'black'}"   style="height: 87%;">
                 <el-table-column 
                 v-for="item in tableprojectColData"  
                 :prop="item.id"
@@ -42,7 +42,7 @@
                 
                 ></el-table-column>
             </el-table>
-            <el-table stripe :data="tableData" border class="mt-4 " v-if="costcheck!=='2'&&costcheck!=='1'" :header-cell-style="{ background:'rgb(214, 225, 255)', fontSize:'16px',color:'black'}"   style="height: 90%;">
+            <el-table stripe :data="tableData" border class="mt-4 " v-if="costcheck!=='2'&&costcheck!=='1'" :header-cell-style="{ background:'rgb(214, 225, 255)', fontSize:'16px',color:'black'}"   style="height: 87%;">
                 <el-table-column 
                 v-for="item in otherColData"  
                 :prop="item.id"