yanghao пре 2 дана
родитељ
комит
cfabe4237d
2 измењених фајлова са 38 додато и 4 уклоњено
  1. 30 2
      src/views/pms/iotrhdailyreport/index.vue
  2. 8 2
      src/views/pms/iotrhdailyreport/rh-form.vue

+ 30 - 2
src/views/pms/iotrhdailyreport/index.vue

@@ -8,10 +8,12 @@ import { resolveDailyReportDeptId } from '@/utils/dailyReportDept'
 import download from '@/utils/download'
 import { rangeShortcuts } from '@/utils/formatTime'
 import { useDebounceFn } from '@vueuse/core'
+import { hasPermission } from '@/directives/permission/hasPermi'
 import UnfilledReportDialog from './UnfilledReportDialog.vue'
 import CountTo from '@/components/count-to1.vue'
 import dayjs from 'dayjs'
 import RhTable from './rh-table.vue'
+import RhForm from './rh-form.vue'
 
 defineOptions({ name: 'IotRhDailyReport' })
 
@@ -266,6 +268,14 @@ const unfilledDialogRef = ref()
 
 const alarmCollapse = ref<string[]>([])
 
+const rhFormVisible = ref(false)
+const rhFormRef = ref<InstanceType<typeof RhForm>>()
+const canModify = computed(() => hasPermission(['pms:iot-rh-daily-report:modify']))
+
+function handleModify(row: any) {
+  rhFormRef.value?.handleOpenForm(row.id, 'edit')
+}
+
 const openUnfilledDialog = () => {
   if (!query.value.createTime || query.value.createTime.length === 0) {
     message.warning('请先选择创建时间范围')
@@ -408,10 +418,21 @@ const openUnfilledDialog = () => {
       :loading="loading"
       :page-no="query.pageNo"
       :page-size="query.pageSize"
-      :show-action="false"
+      :show-action="canModify"
       is-index
       @current-change="handleCurrentChange"
-      @size-change="handleSizeChange" />
+      @size-change="handleSizeChange">
+      <template #action="{ row }">
+        <el-button
+          link
+          type="primary"
+          size="small"
+          v-hasPermi="['pms:iot-rh-daily-report:modify']"
+          @click="handleModify(row)">
+          修改
+        </el-button>
+      </template>
+    </rh-table>
     <div class="p-1 bg-white dark:bg-[#1d1e1f] rounded-lg shadow">
       <el-collapse v-model="alarmCollapse" class="alarm-collapse">
         <el-collapse-item title="告警提示" name="alarm">
@@ -435,6 +456,13 @@ const openUnfilledDialog = () => {
   </div>
 
   <UnfilledReportDialog ref="unfilledDialogRef" :query-params="query" />
+  <RhForm
+    ref="rhFormRef"
+    v-model:visible="rhFormVisible"
+    type="edit"
+    :load-list="loadList"
+    submit-api="update"
+    no-validate-status />
 </template>
 
 <style scoped>

+ 8 - 2
src/views/pms/iotrhdailyreport/rh-form.vue

@@ -9,11 +9,13 @@ interface Props {
   type?: 'edit' | 'approval' | 'readonly'
   loadList: () => void
   noValidateStatus?: boolean
+  submitApi?: 'create' | 'update'
 }
 
 const props = withDefaults(defineProps<Props>(), {
   type: 'edit',
-  noValidateStatus: false
+  noValidateStatus: false,
+  submitApi: 'create'
 })
 
 const emits = defineEmits(['update:visible'])
@@ -343,7 +345,11 @@ const submitForm = async () => {
     FORM_KEYS.forEach((key) => (submitData[key] = form.value[key]))
     submitData.fillOrderCreateTime = form.value.createTime
 
-    await IotRhDailyReportApi.createIotRhDailyReport(submitData)
+    if (props.submitApi === 'update') {
+      await IotRhDailyReportApi.updateIotRhDailyReport(submitData)
+    } else {
+      await IotRhDailyReportApi.createIotRhDailyReport(submitData)
+    }
     message.success(t('common.updateSuccess'))
     emits('update:visible', false)
     props.loadList()