CzRger 1 年之前
父节点
当前提交
0b01828ce5

+ 38 - 0
src/api/modules/weekly.ts

@@ -0,0 +1,38 @@
+import { handle } from '../index'
+
+const suffix = 'api'
+
+//  周报管理 > 列表
+export const getWeekReportList = (params: any) => handle({
+  url: `/${suffix}/week/report/list`,
+  method: 'post',
+  params
+})
+//  周报管理 > 新增
+export const addWeekReportSave = (params: any) => handle({
+  url: `/${suffix}/week/report/save`,
+  method: 'post',
+  params
+})
+//  周报管理 > 编辑
+export const editWeekReportEdit = (params: any) => handle({
+  url: `/${suffix}/week/report/edit`,
+  method: 'put',
+  params
+})
+//  周报管理 > 详情
+export const getWeekReport = (id: any) => handle({
+  url: `/${suffix}/week/report/${id}`,
+  method: 'get',
+})
+//  周报管理 > 查询周报提交情况
+export const getWeekReportSearch = (id: any) => handle({
+  url: `/${suffix}/week/report/search`,
+  method: 'get',
+})
+//  周报管理 > 删除
+export const delWeekReportDelete = (params: any) => handle({
+  url: `/${suffix}/week/report/delete`,
+  method: 'delete',
+  params
+})

+ 22 - 0
src/store/modules/app.ts

@@ -2,6 +2,8 @@ import {getUserInfo} from "@/api/modules/account";
 import {getSignTime} from "@/api/modules/sign";
 import {ElMessage} from "element-plus";
 import {getSeatDutyPersonSearch} from "@/api/modules/seat";
+import * as Handle from "@/views/staging/common/handle";
+import {YMD} from '@/utils/util'
 
 const state = {
 	apiProxy: {
@@ -20,6 +22,26 @@ const getters = {
 	},
 	isWeeklyDay: (state) => {
 		return new Date(state.timestamp).getDay() === 5
+	},
+	yearWeeks: (state) => {
+		const arr: any = []
+		// const firstDate = new Date('2023-11-29')
+		// const wholeFirstDate = Handle.getFirstDateOfWeek(firstDate, state.weekStart)
+		// let start = JSON.parse(JSON.stringify(wholeFirstDate))
+		// let num = 1
+		// while (!(new Date(start).getTime() > new Date(state.tempToday).getTime())) {
+		// 	const end = new Date(start).getTime() + Handle.oneDayTime * 6
+		// 	arr.push({
+		// 		date: [new Date(start), new Date(end)],
+		// 		str: `第${num}周`,
+		// 		selectValue: `第${num}周(${YMD(start)}~${YMD(end)})`,
+		// 		isToday: (new Date(start).getTime() <= new Date(state.tempToday).getTime()) && (new Date(end + Handle.oneDayTime).getTime() > new Date(state.tempToday).getTime()),
+		// 		week: num
+		// 	})
+		// 	start = end + Handle.oneDayTime
+		// 	num++
+		// }
+		return arr
 	}
 }
 

+ 1 - 0
src/views/staging/zby/center/statistic.vue

@@ -479,6 +479,7 @@ export default defineComponent({
     }
     onMounted(() => {
       initStatic()
+      console.log(store.getters['app/yearWeeks'])
     })
     return {
       ...toRefs(state),

+ 107 - 27
src/views/system/weekly-manage/detail.vue

@@ -1,11 +1,13 @@
 <template>
   <CusDialog
-      title="周报"
+      title="日志"
       :show="show"
       @close="$emit('update:show', false)"
       @submit="onSubmit"
       height="560px"
       :closeConfirm="!isViewCpt"
+      :loading="loading"
+      :showSubmit="!isViewCpt"
   >
     <div class="__normal-form">
       <CusForm labelWidth="100px" ref="ref_form" :formView="isViewCpt">
@@ -13,31 +15,35 @@
             :span="24"
             required
             label="周报标题:"
-            v-model:param="cusDetail.p1"/>
+            v-model:param="cusDetail.title"/>
         <CusFormColumn
             :span="24"
             required
-            label="值班时间:"
-            link="datetime"
-            type="datetimerange"
-            v-model:param="cusDetail.p1"/>
+            label="周期日期:"
+            link="date"
+            :disabled="true"
+            v-model:param="cusDetail.dutyTime"/>
         <CusFormColumn
             :span="24"
             required
-            label="值班员:"
-            v-model:param="cusDetail.p1"/>
+            label="提交人员:"
+            :disabled="true"
+            v-model:param="cusDetail.submitter"/>
         <CusFormColumn
             :span="24"
             required
-            label="周报总结:"
+            label="日志记录:"
             type="textarea"
-            :rows="8"
-            v-model:param="cusDetail.p2"/>
+            :rows="4"
+            show-word-limit
+            :maxlength="100"
+            v-model:param="cusDetail.dutyRecord"/>
         <CusFormColumn
             :span="24"
             label="上传文件:"
             link="upload"
-            v-model:param="cusDetail.fileList"/>
+            v-model:param="fileList"
+            :delRule="(file) => true"/>
       </CusForm>
     </div>
   </CusDialog>
@@ -58,6 +64,8 @@ import {
 } from 'vue'
 import {useStore} from 'vuex'
 import {useRouter, useRoute} from 'vue-router'
+import {ElMessage, ElMessageBox} from "element-plus";
+import {addDailyReportSave, editDailyReportEdit, getDailyReport, getDailyReportSearch} from "@/api/modules/daily";
 
 export default defineComponent({
   name: '',
@@ -72,25 +80,48 @@ export default defineComponent({
     const route = useRoute();
     const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
     const state = reactive({
-      cusDetail: {
-        p1: null,
-        p2: null,
-        p3: null,
-        fileList: [
-          { "url": "http://8.140.240.182:18085/profile/upload/2023/10/23/6b7bf3b4-592a-4e2f-ba92-11923671ce3b.doc", "name": "迁移案例.doc"},],
-        }
+      loading: false,
+      cusDetail: <any>{},
+      fileList: <any>[]
     })
     watch(() => props.show, (n) => {
       if (n) {
-        state.cusDetail = {
-          p1: null,
-          p2: null,
-          p3: null,
-          fileList: [],
-        }
+        state.loading = false
+        state.fileList = []
         if (props.transfer.method !== 'add') {
-          state.cusDetail.p1 = props.transfer.detail.p1
-          state.cusDetail.fileList = props.transfer.detail.fileList
+          state.loading = true
+          that.$api.getDailyReport(props.transfer.detail.id).then((res) => {
+            if (res.code === 200 && res.data?.id) {
+              setFormByInfo(res.data)
+            } else {
+              ElMessage.error(res.message)
+              emit('update:show', false)
+            }
+            state.loading = false
+          }).catch(() => {
+            ElMessage.error('请求失败')
+          })
+        } else {
+          state.loading = true
+          that.$api.getDailyReportSearch().then((res) => {
+            if (res.code === 200) {
+              if (res.data?.id) {
+                setFormByInfo(res.data)
+              } else {
+                const diff = new Date(store.state.app.timestamp).getHours() < 12 ? (1000 * 60 * 60 * 24) : 0
+                state.cusDetail = {
+                  dutyTime: that.$util.YMD(new Date(store.state.app.timestamp).getTime() - diff),
+                  submitter: store.state.app.userInfo.displayName,
+                }
+              }
+              state.loading = false
+            } else {
+              ElMessage.error(res.message)
+              emit('update:show', false)
+            }
+          }).catch(() => {
+            ElMessage.error('请求失败')
+          })
         }
         nextTick(() => {
           ref_form.value.reset()
@@ -101,7 +132,56 @@ export default defineComponent({
     const isViewCpt = computed(() => {
       return props.transfer.method === 'view'
     })
+    const setFormByInfo = (data) => {
+      state.cusDetail = data
+      if (state.cusDetail.fileUrl) {
+        const urlArr = state.cusDetail.fileUrl.split(',')
+        const nameArr = state.cusDetail.fileName.split(',')
+        state.fileList = urlArr.map((v, i) => {
+          return {
+            name: nameArr?.[i] || v,
+            url: v
+          }
+        })
+      }
+    }
     const onSubmit = () => {
+      ref_form.value.submit().then(() => {
+        ElMessageBox.confirm("是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          state.loading = true
+          const params: any = state.cusDetail
+          if (state.fileList?.length > 0) {
+            params.fileName = state.fileList.map(v => v.name).join(',')
+            params.fileUrl = state.fileList.map(v => v.url).join(',')
+          } else {
+            params.fileName = ''
+            params.fileUrl = ''
+          }
+          const apiHandle = params.id ? that.$api.editDailyReportEdit(params) : that.$api.addDailyReportSave(params)
+          apiHandle.then(res => {
+            if (res.code === 200) {
+              ElMessage.success(res.message)
+              emit('update:show', false)
+              emit('refresh')
+            } else {
+              ElMessage.error(res.message)
+            }
+            state.loading = false
+          }).catch(() => {
+            state.loading = false
+          })
+        }).catch(() => {})
+      }).catch((e) => {
+        ElMessage({
+          message: e[0].message,
+          grouping: true,
+          type: 'warning',
+        })
+      })
     }
     return {
       ...toRefs(state),

+ 66 - 62
src/views/system/weekly-manage/index.vue

@@ -10,24 +10,25 @@
           <CusForm labelWidth="100px" @handleEnter="onSearch">
             <CusFormColumn
                 label="席位编号:"
-                v-model:param="queryForm.shipId"/>
+                v-model:param="queryForm.seatSerialNumber"/>
             <CusFormColumn
                 label="单位:"
-                link="dept"
-                v-model:param="queryForm.shipId"/>
+                link="select"
+                v-model:param="queryForm.unitId"
+                :options="$store.state.dictionary.deptList"/>
             <CusFormColumn
                 label="提交人员:"
-                v-model:param="queryForm.shipId"/>
+                v-model:param="queryForm.submitter"/>
             <CusFormColumn
-                label="周报时间:"
-                link="datetime"
-                type="datetimerange"
-                v-model:param="queryForm.shipId"/>
+                label="日志日期:"
+                link="date"
+                type="daterange"
+                v-model:param="queryForm.dutyDate"/>
             <CusFormColumn
                 label="提交时间:"
                 link="datetime"
                 type="datetimerange"
-                v-model:param="queryForm.shipId"/>
+                v-model:param="queryForm.submitDate"/>
             <CusSearchButtons
                 @handleReset="handleReset"
                 @handleSearch="onSearch"
@@ -49,7 +50,6 @@
               :page="queryPage.pageNum"
               :pageSize="queryPage.pageSize"
               @handlePage="handlePage"
-              @handleSort="handleSort"
           >
             <template #do-column-value="{ scope }">
               <div class="__cus-table_do">
@@ -59,7 +59,7 @@
                 <div class="__cus-table_do-blue __hover" @click="onEdit(scope.row)">
                   <SvgIcon name="edit" size="16"/>编辑
                 </div>
-                <div class="__cus-table_do-red __hover">
+                <div class="__cus-table_do-red __hover" @click="onDel(scope.row)">
                   <SvgIcon name="del" size="16"/>删除
                 </div>
               </div>
@@ -68,7 +68,7 @@
         </template>
       </CusContent>
     </div>
-    <DetailCom v-model:show="showDetail" :transfer="transfer"/>
+    <DetailCom v-model:show="showDetail" :transfer="transfer" @refresh="handleSearch()"/>
   </div>
 </template>
 
@@ -88,6 +88,8 @@ import {
 import {useStore} from 'vuex'
 import {useRouter, useRoute} from 'vue-router'
 import DetailCom from './detail.vue'
+import {ElMessage, ElMessageBox} from 'element-plus'
+import {delDailyReportDelete, getDailyReportList} from "@/api/modules/daily";
 
 export default defineComponent({
   name: '',
@@ -116,16 +118,14 @@ export default defineComponent({
       queryForm: <any>{},
       //  查询表单参数备份
       back_queryForm: {},
-      //  查询表格排序
-      querySort: {},
       //  表格表头
       tableHead: [
-        {value: "p1", label: "周报标题", show: true},
-        {value: "p1", label: "席位编号", show: true},
-        {value: "p1", label: "单位", show: true},
-        {value: "p1", label: "提交人员", show: true},
-        {value: "p1", label: "周报时间", show: true},
-        {value: "p1", label: "提交时间", show: true},
+        {value: "title", label: "日志标题", show: true},
+        {value: "seatSerialNumber", label: "席位编号", show: true},
+        {value: "unitName", label: "单位", show: true},
+        {value: "submitter", label: "提交人员", show: true},
+        {value: "dutyTime", label: "日志日期", show: true},
+        {value: "submitTime", label: "提交时间", show: true},
         {value: "do", label: "操作", show: true, popover: true, width: 260},
       ],
       showDetail: false,
@@ -134,6 +134,7 @@ export default defineComponent({
     const ref_cusTable = ref()
     //  获取字典
     const initDictionary = () => {
+      store.dispatch('dictionary/LOAD_DEPT')
     }
     //  查询分页参数改变处理方法
     const handlePage = ({page, pageSize}: any) => {
@@ -141,11 +142,6 @@ export default defineComponent({
       state.queryPage.pageSize = pageSize
       handleSearch(page, pageSize)
     }
-    //  查询排序参数改变处理方法
-    const handleSort = ({key, value}: any) => {
-      state.querySort = key ? {key: value} : {}
-      handleSearch()
-    }
     //  重置查询表单方法
     const handleReset = () => {
       state.queryForm = {}
@@ -154,50 +150,38 @@ export default defineComponent({
     }
     //  查询方法
     const handleSearch = (page = 1, pageSize = 10) => {
-      //  添加分页参数
       const queryParams: any = {
         pageNum: page,
         pageSize: pageSize,
-        sort: {},
-        text: ''
-      }
-      //  添加排序参数
-      for (const [k, v] of Object.entries(state.querySort)) {
-        that.$util.isValue(v) ? (queryParams.sort[k] = v) : null;
       }
       //  添加表单参数
       for (const [k, v] of Object.entries(state.back_queryForm)) {
-        that.$util.isValue(v) ? (queryParams[k] = v) : null;
+        if (that.$util.isValue(v)) {
+          if (k === 'unitId') {
+            queryParams['unitName'] = store.state.dictionary.deptMap.get(v).organizationName
+          } else if (k === 'dutyDate') {
+            queryParams['beginDutyTime'] = v[0]
+            queryParams['endDutyTime'] = v[1]
+          } else if (k === 'submitDate') {
+            queryParams['beginTime'] = v[0]
+            queryParams['endTime'] = v[1]
+          } else {
+            queryParams[k] = v
+          }
+        }
       }
-      //  添加复合查询参数
       state.loading = true
-
-      // mock
-      const arr: any = []
-      for (let i = 0; i < 77; i++) {
-        arr.push({
-          p1: '阿三顶顶顶顶顶顶顶顶顶顶顶顶顶' + i,
-          fileList: [
-            { "url": "http://8.140.240.182:18085/profile/upload/2023/10/23/6b7bf3b4-592a-4e2f-ba92-11923671ce3b.doc", "name": "迁移案例.doc"},
-          ],
-        })
-      }
-      state.queryResult.tableData = arr
-      state.queryResult.total = arr.length
-      state.loading = false
-      // that.$api.patrolBoatList(that.$util.formatGetParam(queryParams)).then((res: { code: number; rows: never[]; total: number; }) => {
-      //   if (res.code === 200) {
-      //     state.queryResult.tableData = res.rows
-      //     state.queryResult.total = res.total
-      //   }
-      //   setTimeout(() => {
-      //     state.loading = false
-      //   }, 1000)
-      // }).catch(() => {
-      //   setTimeout(() => {
-      //     state.loading = false
-      //   }, 1000)
-      // })
+      that.$api.getDailyReportList(queryParams).then((res: any) => {
+        if (res.code === 200) {
+          state.queryResult.tableData = res.rows
+          state.queryResult.total = res.total
+        } else {
+          ElMessage.error(res.message)
+        }
+        state.loading = false
+      }).catch(() => {
+        state.loading = false
+      })
     }
     //  点击查询按钮后
     const onSearch = () => {
@@ -226,6 +210,26 @@ export default defineComponent({
       }
       state.showDetail = true
     }
+    const onDel = (val) => {
+      ElMessageBox.confirm(`是否删除${val.title}?`, "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        state.loading = true
+        that.$api.delDailyReportDelete({id: val.id}).then(res => {
+          if (res.code === 200) {
+            ElMessage.success(res.message)
+            handleSearch()
+          } else {
+            ElMessage.error(res.message)
+            state.loading = false
+          }
+        }).catch(() => {
+          state.loading = false
+        })
+      }).catch(() => {})
+    }
     onMounted(() => {
       state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
       initDictionary()
@@ -236,12 +240,12 @@ export default defineComponent({
       ...toRefs(state),
       handleSearch,
       handlePage,
-      handleSort,
       handleReset,
       onSearch,
       onAdd,
       onEdit,
       onView,
+      onDel
     }
   },
 })