123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- import {
- AddReq,
- CreateCrudOptionsProps,
- CreateCrudOptionsRet,
- DelReq,
- dict,
- EditReq,
- FormWrapperContext,
- ScopeContext,
- UserPageQuery,
- UserPageRes,
- utils
- } from '@fast-crud/fast-crud';
- import * as api from './api';
- import { BorrowingReview, Switchspost } from './api';
- import { ElMessage , ElInput, ElDialog, ElButton } from 'element-plus';
- import dayjs from 'dayjs';
- import { h, ref, computed ,inject,defineAsyncComponent} from "vue";
- // import ItemsList from './ItemsList/index.vue';
- export const createCrudOptions = function ({ crudExpose ,context, showRejectDialog, rejectReason, currentFormId,expose }: CreateCrudOptionsProps& {
- showRejectDialog: Ref<boolean>,
- rejectReason: Ref<string>,
- currentFormId: Ref<number | null>
- }): CreateCrudOptionsRet {
- const pageRequest = async (query: UserPageQuery) => {
- try {
- const res = await api.GetList(query);
- console.log("res::::",res)
- return {
- ...res,
- records: res.data,
- total: res.total,
- };
- } catch (error) {
- return {
- code: 2000,
- msg: 'success',
- records: [],
- total: 0,
- };
- }
- };
- const editRequest = async ({ form, row }: EditReq) => {
- form.id = row.id;
- return await api.UpdateObj(form);
- };
- const delRequest = async ({ row }: DelReq) => {
- return await api.DelObj(row.id);
- };
- const addRequest = async ({ form }: AddReq) => {
- return await api.AddObj(form);
- };
- //切换合作商
- const res = Switchspost(1);
- return {
- crudOptions: {
- request: {
- // switchspost,
- pageRequest,
- addRequest,
- editRequest,
- delRequest,
- },
- form: {
- labelWidth: computed(() => {
- return context.labelWidthRef?.value ? context.labelWidthRef.value + "px" : "100px";
- }),
- wrapper: {
- buttons: {
- ok: {
- text: "通过",
- click: async (ctx: FormWrapperContext) => {
- await api.BorrowingReview(ctx.form.id, "approve", "同意借用");
- ElMessage.success("审批通过");
- ctx.close();
- crudExpose.doRefresh();
- }
- },
- reject: {
- text: "拒绝",
- type: "danger",
- click: async (context: FormWrapperContext) => {
- currentFormId.value = context.form.id;
- showRejectDialog.value = true;
- context.close();
- crudExpose.doRefresh();
- }
- },
-
- }
- }
- },
- search:{
- show:true,
- },
- toolbar:{show: false},
- actionbar:{show:false},
- rowHandle:{
- fixed:'right',
- width: 100,
- show: true,
- buttons: {
- view: {
- show: true,
- order:1,
- click: ({ row }) => {
- // eslint-disable-next-line no-console
- // console.log("row:::",row);
- window.dispatchEvent(new CustomEvent('borrow-view', { detail: row }));
- },
- },
- edit: { show: false },
- remove: { show: false },
- // custom: {
- // text: "审批",
- // order: 5,
- // size: "small",
- // show: true,
- // click({row}) {
- // // eslint-disable-next-line no-console
- // // console.log("click", context);
- // // alert(context);
- // try{
- // // approvalDialogRef.value.openApprovalDialog(row);
- // // BorrowingReview(context.row.id,'approve','同意借用');
- // // ElMessage.success('审批通过');
- // }catch(err){
- // // eslint-disable-next-line no-console
- // console.log("error:::::", err);
- // ElMessage.error("系统错误!");
- // }
- // }
- // }
- // customView: {
- // text: '审批',
- // type: 'primary',
- // size: 'small',
- // order: 1,
- // show: true,
- // }
- }
- },
- columns: {
- _index: {
- title: '序号',
- form: { show: false },
- column: {
- align: 'center',
- width: '70px',
- columnSetDisabled: true,
- formatter: (context) => {
- let index = context.index ?? 1;
- let pagination = crudExpose!.crudBinding.value.pagination;
- return ((pagination!.currentPage ?? 1) - 1) * pagination!.pageSize + index + 1;
- },
- },
- },
- application_no: {
- title: '借用单编号',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入借用编号' },
- rules: [{ required: false, message: '请输入借用编号' }],
- },
- },
- borrower_type_label: { title: '借用人角色', column: { minWidth: 100 } },
- borrow_type_label: {
- title: '借用性质',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入借用性质' },
- rules: [{ required: false, message: '请输入借用性质' }],
- },
- },
- "borrower_info.user_code": {
- title: '学号/工号',
- search: { show: true },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入学号/工号' },
- rules: [{ required: false, message: '请输入学号/工号' }],
- },
- },
- "borrower_info.name": {
- title: '借用人',
- search: { show: true },
- type: 'input',
- column: { show:true, minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入借用人' },
- rules: [{ required: false, message: '请输入借用人' }],
- },
- },
- emergency_contact: {
- title: '借用人',
- search: { show: true },
- type: 'input',
- column: { show:false, minWidth: 120 },
- form: {
- show: false,
- component: { placeholder: '请输入借用人' },
- rules: [{ required: false, message: '请输入借用人' }],
- },
- },
- emergency_phone: {
- title: '联系方式',
- search: { show: false },
- type: 'input',
- column: {
- minWidth: 120
- },
- form: {
- show: true,
- component: { placeholder: '请输入联系方式' },
- rules: [{ required: false, message: '请输入联系方式' }],
- }
- },
- team_type_label: {
- title: '个人/团队',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入个人/团队' },
- rules: [{ required: false, message: '请输入个人/团队' }],
- },
- },
- team_members: { title: '团队成员', column: { show:false,minWidth: 120 } },
- team_members_count: { title: '团队人数', column: { show:false,minWidth: 80 }},
- create_datetime: {
- title: '创建时间',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入创建时间' },
- rules: [{ required: false, message: '请输入创建时间' }],
- },
- },
- status_label: { title: '当前状态', column: { minWidth: 80 } },
- actual_start_time: {
- title: '借出时间',
- column: { minWidth: 140, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
- },
- expected_end_time: {
- title: '预计归还',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '请输入预计归还时间' },
- rules: [{ required: false, message: '请输入预计归还时间' }],
- },
- },
- actual_end_time: {
- title: '完结时间',
- column: { minWidth: 140, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
- },
- return_location: { title: '存放仓库', column: { minWidth: 120 } },
- purpose: { title: '借用目的', column: { minWidth: 150 ,show:false} },
- expected_start_time: {
- title: '预计开始',
-
- column: { minWidth: 140,show:true, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
- },
-
-
- approve_time: {
- title: '审批时间',
- column: { show:false,minWidth: 140, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm') : '') },
- from:{show:false}
- },
- approve_remark: { title: '审批备注', column: {show:false, minWidth: 120 } ,from:{show:false}},
- total_items: { title: '设备数量', column: { show:false,minWidth: 80 } },
-
-
- applicant_remark: { title: '申请备注', column: { show:false, minWidth: 120 } },
-
- update_datetime: {
- title: '更新时间',
- column: { show:false,minWidth: 160, formatter: ({ value }: any) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '') },
-
- },
-
- approver_name: {
- title: '当前审批人',
- search: { show: false },
- type: 'input',
- column: { minWidth: 120 },
- form: {
- show: false,
- component: { placeholder: '请输入当前审批人' },
- rules: [{ required: false, message: '请输入当前审批人' }],
- },
- },
- "items[0].device_category_name": {
- title: '设备分类',
- search: { show: false },
- type: 'input',
- column: { show:false,minWidth: 120 },
- form: {
- show: true,
- component: { placeholder: '' },
- // rules: [{ required: false, message: '请输入当前审批人' }],
- },
- },
- // "items[0].quantity": {
- // title: '借用数量',
- // search: { show: false },
- // type: 'input',
- // column: {show:false, minWidth: 120 },
- // form: {
- // show: true,
- // component: { placeholder: '' },
- // // rules: [{ required: false, message: '请输入当前审批人' }],
- // },
- // },
- // items: {
- // title: '设备列表',
- // type: 'input', // 必须是 component 类型
- // form: {
- // show: true, // 确保表单中显示
- // slot: 'ItemsList',
- // }
- // },
-
-
-
-
-
-
-
- },
- },
- };
- };
|