|
@@ -22,7 +22,7 @@ const BorrowRecords = defineComponent({
|
|
|
const records = ref([]);
|
|
|
const loading = ref(false);
|
|
|
const filteredRecords = computed(() =>
|
|
|
- (records.value || []).filter((item: any) => item?.record_type === 0)
|
|
|
+ (records.value || [])/* .filter((item: any) => item?.record_type === 0) */
|
|
|
);
|
|
|
const loadData = async () => {
|
|
|
if (!props.form?.id) return;
|
|
@@ -41,8 +41,9 @@ const BorrowRecords = defineComponent({
|
|
|
<ElTable data={filteredRecords.value} v-loading={loading.value} style="width: 100%">
|
|
|
<ElTableColumn prop="application_no" label="借用编号" />
|
|
|
<ElTableColumn prop="borrower_name" label="借用人" />
|
|
|
+ <ElTableColumn prop="borrower_code" label="学号/工号"/>
|
|
|
<ElTableColumn prop="record_type_label" label="状态" />
|
|
|
- <ElTableColumn prop="borrower_type" label="借用类型" />
|
|
|
+ <ElTableColumn prop="borrow_type_display" label="借用类型" />
|
|
|
|
|
|
</ElTable>
|
|
|
);
|
|
@@ -88,6 +89,100 @@ const BorrowRecords = defineComponent({
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+const MaintenanceRecords = defineComponent({
|
|
|
+ props: { form: Object },
|
|
|
+ setup(props) {
|
|
|
+ try {
|
|
|
+ const records = ref([]);
|
|
|
+ const loading = ref(false);
|
|
|
+ const loadData = async () => {
|
|
|
+ if (!props.form?.id) return;
|
|
|
+ loading.value = true;
|
|
|
+ try {
|
|
|
+ const res = await api.getMaintenanceRecords(props.form.id);
|
|
|
+ records.value = res.data || [];
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ watch(() => props.form?.id, loadData, { immediate: true });
|
|
|
+
|
|
|
+ return () => (
|
|
|
+ <ElTable data={records.value} v-loading={loading.value} style="width: 100%">
|
|
|
+ <ElTableColumn prop="record_no" label="保养编号" />
|
|
|
+ <ElTableColumn prop="plan_name" label="保养计划" />
|
|
|
+ <ElTableColumn prop="planned_date" label="保养日期" />
|
|
|
+ <ElTableColumn prop="maintenance_person" label="保养人员" />
|
|
|
+ <ElTableColumn prop="maintenance_content" label="保养内容" />
|
|
|
+
|
|
|
+ </ElTable>
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ console.error("MaintenanceRecords setup error:", e);
|
|
|
+ return () => <div>组件加载失败</div>;
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const DeviceStatistics = defineComponent({
|
|
|
+ props: { form: Object },
|
|
|
+ setup(props) {
|
|
|
+ try {
|
|
|
+ const statistics = ref<any>({});
|
|
|
+ const loading = ref(false);
|
|
|
+ const loadData = async () => {
|
|
|
+ if (!props.form?.id) return;
|
|
|
+ loading.value = true;
|
|
|
+ try {
|
|
|
+ const res = await api.getDeviceStatistics(props.form.id);
|
|
|
+ statistics.value = res.data || {};
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ watch(() => props.form?.id, loadData, { immediate: true });
|
|
|
+
|
|
|
+ return () => (
|
|
|
+ <div v-loading={loading.value} style={{ padding: '20px' }}>
|
|
|
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '20px' }}>
|
|
|
+ <div style={{ background: '#f5f7fa', padding: '20px', borderRadius: '8px', textAlign: 'center' }}>
|
|
|
+ <div style={{ fontSize: '24px', fontWeight: 'bold', color: '#409eff' }}>{statistics.value.total_borrow_count || 0}</div>
|
|
|
+ <div style={{ color: '#606266', marginTop: '8px' }}>总借用次数</div>
|
|
|
+ </div>
|
|
|
+ <div style={{ background: '#f5f7fa', padding: '20px', borderRadius: '8px', textAlign: 'center' }}>
|
|
|
+ <div style={{ fontSize: '24px', fontWeight: 'bold', color: '#67c23a' }}>{statistics.value.total_maintenance_count || 0}</div>
|
|
|
+ <div style={{ color: '#606266', marginTop: '8px' }}>总保养次数</div>
|
|
|
+ </div>
|
|
|
+ <div style={{ background: '#f5f7fa', padding: '20px', borderRadius: '8px', textAlign: 'center' }}>
|
|
|
+ <div style={{ fontSize: '24px', fontWeight: 'bold', color: '#e6a23c' }}>{statistics.value.total_repair_count || 0}</div>
|
|
|
+ <div style={{ color: '#606266', marginTop: '8px' }}>总维修次数</div>
|
|
|
+ </div>
|
|
|
+ {/* <div style={{ background: '#f5f7fa', padding: '20px', borderRadius: '8px', textAlign: 'center' }}>
|
|
|
+ <div style={{ fontSize: '24px', fontWeight: 'bold', color: '#f56c6c' }}>{statistics.value.availability_rate || '0%'}</div>
|
|
|
+ <div style={{ color: '#606266', marginTop: '8px' }}>设备可用率</div>
|
|
|
+ </div> */}
|
|
|
+ </div>
|
|
|
+ {statistics.value.recent_activities && (
|
|
|
+ <div style={{ marginTop: '30px' }}>
|
|
|
+ <h3 style={{ marginBottom: '20px', color: '#303133' }}>最近活动</h3>
|
|
|
+ <ElTable data={statistics.value.recent_activities} style={{ width: '100%' }}>
|
|
|
+ <ElTableColumn prop="activity_type" label="活动类型" />
|
|
|
+ <ElTableColumn prop="activity_date" label="活动日期" />
|
|
|
+ <ElTableColumn prop="description" label="描述" />
|
|
|
+ </ElTable>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ console.error("DeviceStatistics setup error:", e);
|
|
|
+ return () => <div>组件加载失败</div>;
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
|
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
|
const pageRequest = async (query: UserPageQuery) => {
|
|
@@ -104,14 +199,14 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
return await api.AddObj(form);
|
|
|
};
|
|
|
|
|
|
- const selectedIds = ref([]);
|
|
|
+ const selectedIds = ref<any[]>([]);
|
|
|
|
|
|
- const onSelectionChange = (changed) => {
|
|
|
+ const onSelectionChange = (changed: any[]) => {
|
|
|
console.log("selection", changed);
|
|
|
- selectedIds.value = changed.map((item) => item.id);
|
|
|
+ selectedIds.value = changed.map((item: any) => item.id);
|
|
|
};
|
|
|
|
|
|
- crudExpose.selectedIds = selectedIds;
|
|
|
+ (crudExpose as any).selectedIds = selectedIds;
|
|
|
|
|
|
return {
|
|
|
// selectedIds,
|
|
@@ -764,16 +859,30 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
}
|
|
|
},
|
|
|
maintain: {
|
|
|
+ show: true,
|
|
|
label: "保养记录",
|
|
|
- collapsed: true,
|
|
|
icon: "el-icon-warning-outline",
|
|
|
- columns: []
|
|
|
+ columns: ["id"],
|
|
|
+ slots: {
|
|
|
+ default: (scope) => {
|
|
|
+ const currentRowMaintain = crudExpose.getFormData();
|
|
|
+ console.log("currentRowMaintain::",currentRowMaintain);
|
|
|
+ return <MaintenanceRecords form={currentRowMaintain || {}} />
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
datastatis: {
|
|
|
+ show: true,
|
|
|
label: "数据统计",
|
|
|
- collapsed: true,
|
|
|
- icon: "el-icon-warning-outline",
|
|
|
- columns: []
|
|
|
+ icon: "el-icon-data-analysis",
|
|
|
+ columns: ["id"],
|
|
|
+ slots: {
|
|
|
+ default: (scope) => {
|
|
|
+ const currentRowStats = crudExpose.getFormData();
|
|
|
+ console.log("currentRowStats::",currentRowStats);
|
|
|
+ return <DeviceStatistics form={currentRowStats || {}} />
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
|