Browse Source

日志管理

CzRger 1 year ago
parent
commit
477a448c6f
1 changed files with 62 additions and 24 deletions
  1. 62 24
      src/views/system/daily-manage/detail.vue

+ 62 - 24
src/views/system/daily-manage/detail.vue

@@ -6,6 +6,8 @@
       @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} from "@/api/modules/daily";
 
 export default defineComponent({
   name: '',
@@ -72,25 +80,19 @@ 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: {},
+      fileList: []
     })
     watch(() => props.show, (n) => {
       if (n) {
+        state.loading = false
+        state.fileList = []
         state.cusDetail = {
-          p1: null,
-          p2: null,
-          p3: null,
-          fileList: [],
+          dutyTime: that.$util.YMD(new Date(store.state.app.timestamp)),
+          submitter: store.state.app.userInfo.displayName,
         }
         if (props.transfer.method !== 'add') {
-          state.cusDetail.p1 = props.transfer.detail.p1
-          state.cusDetail.fileList = props.transfer.detail.fileList
         }
         nextTick(() => {
           ref_form.value.reset()
@@ -102,6 +104,42 @@ export default defineComponent({
       return props.transfer.method === 'view'
     })
     const onSubmit = () => {
+      ref_form.value.submit().then(() => {
+        ElMessageBox.confirm("是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }).then(() => {
+          state.loading = true
+          const params = 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 = props.transfer.method === 'edit' ? 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),