|
@@ -1,17 +1,90 @@
|
|
|
-import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, uiContext, UserPageQuery } from '@fast-crud/fast-crud';
|
|
|
+import { AddReq, compute,useCrud , CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, uiContext, UserPageQuery, } from '@fast-crud/fast-crud';
|
|
|
import dayjs from 'dayjs';
|
|
|
import * as api from './api';
|
|
|
import { uploadFile } from './api';
|
|
|
import { auth } from '/@/utils/authFunction';
|
|
|
-// import { commonCrudConfig } from '/@/utils/commonCrud';
|
|
|
import {request} from '/@/utils/service';
|
|
|
import {getBaseURL} from '/@/utils/baseUrl';
|
|
|
import Cookies from 'js-cookie';
|
|
|
import { successMessage } from '/@/utils/message';
|
|
|
import { dictionary } from '/@/utils/dictionary';
|
|
|
import { APIResponseData } from '../columns/types';
|
|
|
-import { computed, h } from 'vue';
|
|
|
+import { computed, h,defineComponent, ref, onMounted, watch } from 'vue';
|
|
|
+import { ElTable, ElTableColumn, ElLoading } from 'element-plus';
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+const BorrowRecords = 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.getBorrowRecords(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="application_no" label="借用编号" />
|
|
|
+ <ElTableColumn prop="borrower_name" label="借用人" />
|
|
|
+ <ElTableColumn prop="record_type_label" label="状态" />
|
|
|
+ <ElTableColumn prop="borrower_type" label="借用类型" />
|
|
|
+
|
|
|
+ </ElTable>
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ console.error("BorrowRecords setup error:", e);
|
|
|
+ return () => <div>组件加载失败</div>;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const MaintenanceHistory = 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.getMaintenanceHistory(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="damage_no" label="维修编号" />
|
|
|
+ <ElTableColumn prop="device_name" label="设备名称" />
|
|
|
+ <ElTableColumn prop="damage_reason" label="损坏原因" />
|
|
|
+ <ElTableColumn prop="estimated_loss" label="损失价格" />
|
|
|
+ </ElTable>
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ console.error("MaintenanceHistory setup error:", e);
|
|
|
+ return () => <div>组件加载失败</div>;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
|
const pageRequest = async (query: UserPageQuery) => {
|
|
|
return await api.GetList(query);
|
|
@@ -27,10 +100,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
return await api.AddObj(form);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- const ui = uiContext.get();
|
|
|
-
|
|
|
return {
|
|
|
crudOptions: {
|
|
|
request: {
|
|
@@ -62,27 +131,24 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
show: auth('user:Create')
|
|
|
},
|
|
|
batchimport:{
|
|
|
- text: "批量导入",//按钮文字
|
|
|
- title: "导入",//鼠标停留显示的信息
|
|
|
+ text: "批量导入",
|
|
|
+ title: "导入",
|
|
|
// show: auth('user:batchimport'),
|
|
|
},
|
|
|
export: {
|
|
|
- text: "导出",//按钮文字
|
|
|
- title: "导出",//鼠标停留显示的信息
|
|
|
+ text: "导出",
|
|
|
+ title: "导出",
|
|
|
show: auth('user:Export'),
|
|
|
-
|
|
|
},
|
|
|
downloadtemplate: {
|
|
|
- text: "下载模板",//按钮文字
|
|
|
- title: "下载模板",//鼠标停留显示的信息
|
|
|
+ text: "下载模板",
|
|
|
+ title: "下载模板",
|
|
|
// show: auth('user:Export'),
|
|
|
-
|
|
|
},
|
|
|
batchdelete: {
|
|
|
- text: "批量删除",//按钮文字
|
|
|
- title: "批量删除",//鼠标停留显示的信息
|
|
|
+ text: "批量删除",
|
|
|
+ title: "批量删除",
|
|
|
// show: auth('user:Export'),
|
|
|
-
|
|
|
},
|
|
|
}
|
|
|
},
|
|
@@ -590,52 +656,16 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
console.log("form[key]:::",form[key]);
|
|
|
form[key] = Array.isArray(form[key]) ? form[key][0] : form[key];
|
|
|
}
|
|
|
- // form: {
|
|
|
- // // component: { placeholder: '请上传图片' },
|
|
|
- // component: {
|
|
|
- // limit: 1,
|
|
|
- // uploader: {
|
|
|
- // type: "form"
|
|
|
- // }
|
|
|
- // },
|
|
|
- // rules: createUploaderRules([{ required: true, message: "此项必传", trigger: "change" }]),
|
|
|
- // change:()=>{
|
|
|
-
|
|
|
- // },
|
|
|
- // helper: "上传设备图片",
|
|
|
- // },
|
|
|
-
|
|
|
|
|
|
},
|
|
|
- // maintenancename: {
|
|
|
- // title: '维修名称',
|
|
|
- // type: 'input',
|
|
|
- // search: { show: false },
|
|
|
- // column: { show:false,minWidth: 100 },
|
|
|
- // form: {
|
|
|
- // component: { placeholder: '请输入设备购入价格' },
|
|
|
- // rules: [{ required: true, message: '请输入设备购入价格' }],
|
|
|
- // },
|
|
|
- // },
|
|
|
- jieyong: {
|
|
|
- title: '借用',
|
|
|
- search: { show: false },
|
|
|
- type: 'input',
|
|
|
- column: { minWidth: 120 },
|
|
|
- form: {
|
|
|
- component: { placeholder: '请输入借用' }
|
|
|
- },
|
|
|
- viewForm:{
|
|
|
- component: { placeholder: '' },
|
|
|
- rules: [{ required: true, message: '' }],
|
|
|
- }
|
|
|
- },
|
|
|
- weixiu: {
|
|
|
- title: '维修',
|
|
|
+
|
|
|
+ id: {
|
|
|
+ title: 'deviceid',
|
|
|
search: { show: false },
|
|
|
type: 'input',
|
|
|
- column: { minWidth: 120 },
|
|
|
+ column: { show:false,minWidth: 120 },
|
|
|
form: {
|
|
|
+ show:true,
|
|
|
component: { placeholder: '请输入维修' }
|
|
|
},
|
|
|
viewForm:{
|
|
@@ -643,37 +673,9 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
rules: [{ required: true, message: '' }],
|
|
|
}
|
|
|
},
|
|
|
- baoyang: {
|
|
|
- title: '保养',
|
|
|
- search: { show: false },
|
|
|
- type: 'input',
|
|
|
- column: { minWidth: 120 },
|
|
|
- form: {
|
|
|
- component: { placeholder: '请输入保养' }
|
|
|
- },
|
|
|
- viewForm:{
|
|
|
- component: { placeholder: '' },
|
|
|
- rules: [{ required: true, message: '' }],
|
|
|
- }
|
|
|
- },
|
|
|
- tongji: {
|
|
|
- title: '统计',
|
|
|
- search: { show: false },
|
|
|
- type: 'input',
|
|
|
- column: { minWidth: 120 },
|
|
|
- form: {
|
|
|
- component: { placeholder: '请输入统计' }
|
|
|
- },
|
|
|
- viewForm:{
|
|
|
- component: { placeholder: '' },
|
|
|
- rules: [{ required: true, message: '' }],
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
|
|
|
},
|
|
|
- form: {
|
|
|
+ viewForm: {
|
|
|
wrapper: {
|
|
|
buttons: {
|
|
|
ok:{
|
|
@@ -683,45 +685,60 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
},
|
|
|
row: { gutter: 20 },
|
|
|
group: {
|
|
|
- groupType: "tabs", //collapse, tabs
|
|
|
- accordion: false,
|
|
|
+ groupType: "tabs",
|
|
|
groups: {
|
|
|
base: {
|
|
|
slots: {
|
|
|
- label: (scope) => {
|
|
|
- return (
|
|
|
- <span style={{ color: scope.hasError ? "red" : "green" }}>
|
|
|
- <fs-icon icon={"ion:checkmark-circle"} />
|
|
|
- 基础信息
|
|
|
- </span>
|
|
|
- );
|
|
|
+ label: (scope) => {
|
|
|
+ return (
|
|
|
+ <span style={{ color: scope.hasError ? "red" : "green" }}>
|
|
|
+ <fs-icon icon={"ion:checkmark-circle"} />
|
|
|
+ 基础信息
|
|
|
+ </span>
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
icon: "el-icon-goods",
|
|
|
columns: ["code","category_name", "name", "status","borrowed_quantity","brand","specification","serial_number","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","tenant_id","category","quantity","tags","image"]
|
|
|
},
|
|
|
borrow: {
|
|
|
+ show:true,
|
|
|
label: "借用记录",
|
|
|
icon: "el-icon-price-tag",
|
|
|
- columns: ["jieyong",]
|
|
|
+ columns: ["id"],
|
|
|
+ slots: {
|
|
|
+ default: (scope) => {
|
|
|
+ const currentRow = crudExpose.getFormData();
|
|
|
+ console.log("currentRow::",currentRow);
|
|
|
+ return <BorrowRecords form={currentRow || {}}/>;
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
maintenance: {
|
|
|
+ show:true,
|
|
|
label: "维修记录",
|
|
|
- collapsed: true, //默认折叠
|
|
|
+ // collapsed: true,
|
|
|
icon: "el-icon-warning-outline",
|
|
|
- columns: ["weixiu"]
|
|
|
+ columns: ["id"],
|
|
|
+ slots: {
|
|
|
+ default: (scope) => {
|
|
|
+ const currentRowwx = crudExpose.getFormData();
|
|
|
+ console.log("currentRowwx::",currentRowwx);
|
|
|
+ return <MaintenanceHistory form={currentRowwx || {}} />
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
maintain: {
|
|
|
label: "保养记录",
|
|
|
- collapsed: true, //默认折叠
|
|
|
+ collapsed: true,
|
|
|
icon: "el-icon-warning-outline",
|
|
|
- columns: ["baoyang"]
|
|
|
+ columns: []
|
|
|
},
|
|
|
datastatis: {
|
|
|
label: "数据统计",
|
|
|
- collapsed: true, //默认折叠
|
|
|
+ collapsed: true,
|
|
|
icon: "el-icon-warning-outline",
|
|
|
- columns: ["tongji"]
|
|
|
+ columns: []
|
|
|
},
|
|
|
|
|
|
|