22 changed files with 1017 additions and 286 deletions
@ -0,0 +1,57 @@ |
|||||||
|
<template> |
||||||
|
<BasicModal v-bind="$attrs" |
||||||
|
:title="getTitle" |
||||||
|
@register="registerModal" |
||||||
|
@ok="handleSubmit" |
||||||
|
> |
||||||
|
<BasicForm @register="registerForm"/> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script lang="ts" setup> |
||||||
|
import {ref, computed, unref} from 'vue'; |
||||||
|
import {BasicModal, useModalInner} from '/@/components/Modal'; |
||||||
|
import {cardFormSchema} from './boxcard.data'; |
||||||
|
import {BasicForm, useForm} from '/@/components/Form/index'; |
||||||
|
import {set} from '/@/api/platform/system/controller/boxcard'; |
||||||
|
const isUpdate = ref(true); |
||||||
|
// 定义emit |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
/** |
||||||
|
* 表单 |
||||||
|
*/ |
||||||
|
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
||||||
|
labelWidth: 100, |
||||||
|
schemas: cardFormSchema, |
||||||
|
showActionButtonGroup: false, |
||||||
|
actionColOptions: { |
||||||
|
span: 23, |
||||||
|
}, |
||||||
|
}); |
||||||
|
/** |
||||||
|
* 表单参数 |
||||||
|
*/ |
||||||
|
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
||||||
|
resetFields(); |
||||||
|
setModalProps({confirmLoading: false}); |
||||||
|
isUpdate.value = !!data?.isUpdate; |
||||||
|
if (unref(isUpdate)) { |
||||||
|
setFieldsValue({ |
||||||
|
...data.record, |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
//表单标题 |
||||||
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增网卡' : '编辑网卡')); |
||||||
|
async function handleSubmit() { |
||||||
|
try { |
||||||
|
const values = await validate(); |
||||||
|
setModalProps({confirmLoading: true}); |
||||||
|
await set(values);//保存网卡 |
||||||
|
closeModal(); |
||||||
|
emit('success'); |
||||||
|
} finally { |
||||||
|
setModalProps({confirmLoading: false}); |
||||||
|
} |
||||||
|
} |
||||||
|
</script> |
@ -0,0 +1,160 @@ |
|||||||
|
import { BasicColumn } from '/@/components/Table'; |
||||||
|
import { FormSchema } from '/@/components/Table'; |
||||||
|
import {h} from 'vue'; |
||||||
|
import {Tag} from 'ant-design-vue'; |
||||||
|
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: 'ID', |
||||||
|
dataIndex: 'id', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: 'iccid', |
||||||
|
dataIndex: 'iccid', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '卡号', |
||||||
|
dataIndex: 'card', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '网卡厂商', |
||||||
|
dataIndex: 'company', |
||||||
|
width: 120, |
||||||
|
customRender: ({ record }) => { |
||||||
|
const com = record.company; |
||||||
|
switch (com) { |
||||||
|
case '1': return '中国移动'; |
||||||
|
case '2': return '中国联通'; |
||||||
|
case '3': return '中国电信'; |
||||||
|
default: return '未知厂商'; |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '卡是否已使用', |
||||||
|
dataIndex: 'isUsed', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '状态', |
||||||
|
dataIndex: 'status', |
||||||
|
width: 100, |
||||||
|
customRender: ({ record }) => { |
||||||
|
const status = record.status; |
||||||
|
const enable = status === '0'; |
||||||
|
const color = enable ? 'green' : 'red'; |
||||||
|
const text = enable ? '启用' : '禁用'; |
||||||
|
return h(Tag, { color: color }, () => text); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建人', |
||||||
|
dataIndex: 'createByName', |
||||||
|
width: 180, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建时间', |
||||||
|
dataIndex: 'createTime', |
||||||
|
width: 180, |
||||||
|
} |
||||||
|
]; |
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
field: 'iccid', |
||||||
|
label: 'iccid', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入唯一标识iccid', |
||||||
|
}, |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'card', |
||||||
|
label: '卡号', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入卡号', |
||||||
|
}, |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'company', |
||||||
|
label: '网卡厂商', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入网卡厂商', |
||||||
|
}, |
||||||
|
colProps: { span: 4 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'beginTime', |
||||||
|
label: '起始时间', |
||||||
|
component: 'DatePicker', |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'endTime', |
||||||
|
label: '截止时间', |
||||||
|
component: 'DatePicker', |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
]; |
||||||
|
|
||||||
|
export const cardFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
field: 'id', |
||||||
|
label: 'ID', |
||||||
|
component: 'Input', |
||||||
|
show: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'iccid', |
||||||
|
label: 'iccid', |
||||||
|
component: 'Input', |
||||||
|
helpMessage: ['唯一识别号'], |
||||||
|
required: true |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'card', |
||||||
|
label: '卡号', |
||||||
|
component: 'Input', |
||||||
|
required: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'company', |
||||||
|
label: '网卡厂商', |
||||||
|
component: 'Select', |
||||||
|
required: true, |
||||||
|
componentProps: { |
||||||
|
options: [ |
||||||
|
{ label: '中国移动', value: '1' }, |
||||||
|
{ label: '中国联通', value: '2' }, |
||||||
|
{ label: '中国电信', value: '3' }, |
||||||
|
{ label: '未知厂商', value: ''||undefined||null } |
||||||
|
], |
||||||
|
|
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'status', |
||||||
|
label: '状态', |
||||||
|
component: 'RadioButtonGroup', |
||||||
|
defaultValue: '0', |
||||||
|
componentProps: { |
||||||
|
options: [ |
||||||
|
{ label: '启用', value: '0' }, |
||||||
|
{ label: '禁用', value: '1' }, |
||||||
|
], |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '备注', |
||||||
|
field: 'remarks', |
||||||
|
component: 'InputTextArea', |
||||||
|
} |
||||||
|
]; |
@ -0,0 +1,94 @@ |
|||||||
|
<template> |
||||||
|
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #toolbar> |
||||||
|
<a-button type="primary" @click="handleCreate">新增网卡</a-button> |
||||||
|
</template> |
||||||
|
<template #action="{ record }"> |
||||||
|
<TableAction |
||||||
|
:actions="[ |
||||||
|
{ |
||||||
|
icon: 'clarity:note-edit-line', |
||||||
|
onClick: handleEdit.bind(null, record), |
||||||
|
}, |
||||||
|
{ |
||||||
|
icon: 'ant-design:delete-outlined', |
||||||
|
color: 'error', |
||||||
|
popConfirm: { |
||||||
|
title: '是否确认删除', |
||||||
|
confirm: handleDelete.bind(null, record), |
||||||
|
}, |
||||||
|
}, |
||||||
|
]" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
</BasicTable> |
||||||
|
|
||||||
|
<BoxCardModal @register="registerModal" @success="handleSuccess"/> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script lang="ts" setup> |
||||||
|
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
||||||
|
import {useModal} from '/@/components/Modal'; |
||||||
|
import BoxCardModal from './BoxCardModal.vue'; |
||||||
|
import {columns, searchFormSchema} from './boxcard.data'; |
||||||
|
import {useMessage} from '/@/hooks/web/useMessage'; |
||||||
|
import {cardList, remove} from '/@/api/platform/system/controller/boxcard'; |
||||||
|
const {createMessage} = useMessage(); |
||||||
|
const [registerModal, {openModal}] = useModal(); |
||||||
|
const [registerTable, {reload}] = useTable({ |
||||||
|
title: '网卡列表', |
||||||
|
api: cardList, |
||||||
|
columns, |
||||||
|
formConfig: { |
||||||
|
labelWidth: 120, |
||||||
|
schemas: searchFormSchema, |
||||||
|
}, |
||||||
|
pagination: true, |
||||||
|
striped: true, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
bordered: true, |
||||||
|
showIndexColumn: true, |
||||||
|
canResize: false, |
||||||
|
actionColumn: { |
||||||
|
width: 80, |
||||||
|
title: '操作', |
||||||
|
dataIndex: 'action', |
||||||
|
slots: {customRender: 'action'}, |
||||||
|
fixed: undefined, |
||||||
|
}, |
||||||
|
}); |
||||||
|
/** |
||||||
|
* 创建菜单 |
||||||
|
*/ |
||||||
|
function handleCreate() { |
||||||
|
openModal(true, { |
||||||
|
isUpdate: false, |
||||||
|
}); |
||||||
|
} |
||||||
|
/** |
||||||
|
* 编辑菜单 |
||||||
|
*/ |
||||||
|
function handleEdit(record: Recordable) { |
||||||
|
openModal(true, { |
||||||
|
record, |
||||||
|
isUpdate: true, |
||||||
|
}); |
||||||
|
} |
||||||
|
/** |
||||||
|
* 删除菜单 |
||||||
|
*/ |
||||||
|
async function handleDelete(record: Recordable) { |
||||||
|
await remove({ids: record.id}); |
||||||
|
createMessage.success('删除成功!'); |
||||||
|
handleSuccess(); |
||||||
|
} |
||||||
|
/** |
||||||
|
* 成功后重载表格 |
||||||
|
*/ |
||||||
|
function handleSuccess() { |
||||||
|
reload(); |
||||||
|
} |
||||||
|
</script> |
@ -1,52 +1,79 @@ |
|||||||
<template> |
<template> |
||||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> |
<BasicModal v-bind="$attrs" |
||||||
|
width="720px" |
||||||
|
@register="registerModal" |
||||||
|
@ok="handleSubmit" |
||||||
|
> |
||||||
<BasicForm @register="registerForm"/> |
<BasicForm @register="registerForm"/> |
||||||
</BasicModal> |
</BasicModal> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {ref, computed, unref} from 'vue'; |
/** |
||||||
import {BasicModal, useModalInner} from '/@/components/Modal'; |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
import {doctorFormSchema} from './doctor.data'; |
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
import {BasicForm, useForm} from '/@/components/Form'; |
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
import {set} from '/@/api/platform/system/controller/doctor'; |
* author entfrm开发团队-王翔 |
||||||
const isUpdate = ref(true); |
|
||||||
// 定义emit |
|
||||||
const emit = defineEmits(['success', 'register']); |
|
||||||
/** |
|
||||||
* 表单 |
|
||||||
*/ |
*/ |
||||||
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
import { ref, unref } from 'vue'; |
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index'; |
||||||
|
import { doctorFormSchema } from './doctor.data'; |
||||||
|
import {addDoctor, delDoctor,getDoctor,editDoctor} from '/@/api/platform/system/controller/doctor'; |
||||||
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
|
import { isEmpty } from '/@/utils/is'; |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const tag = ref<Nullable<string>>(''); |
||||||
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ |
||||||
labelWidth: 100, |
labelWidth: 100, |
||||||
schemas: doctorFormSchema, |
schemas: doctorFormSchema, |
||||||
showActionButtonGroup: false, |
showActionButtonGroup: false, |
||||||
actionColOptions: { |
baseColProps: { span: 24 } |
||||||
span: 23, |
}); |
||||||
}, |
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||||
}); |
// 处理清除脏数据 |
||||||
/** |
await resetFields(); |
||||||
* 表单参数 |
await clearValidate(); |
||||||
*/ |
// 处理设置数据 |
||||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
tag.value = data._tag; |
||||||
resetFields(); |
const id = data.record?.id; |
||||||
setModalProps({confirmLoading: false}); |
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
isUpdate.value = !!data?.isUpdate; |
// 采用tag标签区分操作 |
||||||
console.log(data.record); |
switch (unref(tag)) { |
||||||
if (unref(isUpdate)) { |
case 'add': |
||||||
setFieldsValue(data.record); |
props.title = '医生'; |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
props.title = '编辑医生'; |
||||||
|
await setFieldsValue(await getDoctor(id)); |
||||||
|
break; |
||||||
} |
} |
||||||
}) |
// 尾部:设置处理后的最终配置数据 |
||||||
//表单标题 |
setModalProps(props); |
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增医生' : '编辑医生')); |
}); |
||||||
async function handleSubmit() { |
|
||||||
|
/** 处理弹出框提交 */ |
||||||
|
async function handleSubmit() { |
||||||
try { |
try { |
||||||
const values = await validate(); |
// 提取验证数据 |
||||||
setModalProps({confirmLoading: true}); |
const formData = await validate(); |
||||||
await set(values);//保存网卡 |
// 处理提交之前逻辑 |
||||||
|
setModalProps({ confirmLoading: true }); |
||||||
|
// 采用tag标签区分操作 |
||||||
|
switch (unref(tag)) { |
||||||
|
case 'add': |
||||||
|
await addDoctor(formData); |
||||||
|
break; |
||||||
|
case 'edit': |
||||||
|
await editDoctor(formData); |
||||||
|
break; |
||||||
|
} |
||||||
|
// 处理提交完成之后逻辑 |
||||||
closeModal(); |
closeModal(); |
||||||
emit('success'); |
emit('success'); |
||||||
} finally { |
} finally { |
||||||
setModalProps({confirmLoading: false}); |
setModalProps({ confirmLoading: false }); |
||||||
|
} |
||||||
} |
} |
||||||
} |
|
||||||
</script> |
</script> |
@ -1,94 +1,136 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div> |
||||||
<BasicTable @register="registerTable"> |
<BasicTable @register="registerTable" |
||||||
|
@selection-change="handleSelectionChange" |
||||||
|
> |
||||||
<template #toolbar> |
<template #toolbar> |
||||||
<a-button type="primary" @click="handleCreate">新增医生</a-button> |
<a-button |
||||||
|
type="primary" |
||||||
|
@click="handleAdd()" |
||||||
|
>新增医生</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.single" |
||||||
|
@click="handleEdit()" |
||||||
|
>修改医生</a-button> |
||||||
|
<a-button type="primary" |
||||||
|
:disabled="state.multiple" |
||||||
|
@click="handleDel()" |
||||||
|
>删除医生</a-button> |
||||||
</template> |
</template> |
||||||
<template #action="{ record }"> |
<template #action="{ record }"> |
||||||
<TableAction |
<TableAction :actions="[ |
||||||
:actions="[ |
|
||||||
{ |
{ |
||||||
icon: 'clarity:note-edit-line', |
label: '编辑', |
||||||
onClick: handleEdit.bind(null, record), |
icon: 'fa6-regular:pen-to-square', |
||||||
|
onClick: handleEdit.bind(null, record) |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
|
label: '删除', |
||||||
icon: 'ant-design:delete-outlined', |
icon: 'ant-design:delete-outlined', |
||||||
color: 'error', |
color: 'error', |
||||||
popConfirm: { |
onClick: handleDel.bind(null, record) |
||||||
title: '是否确认删除', |
}]" |
||||||
confirm: handleDelete.bind(null, record), |
|
||||||
}, |
|
||||||
}, |
|
||||||
]" |
|
||||||
/> |
/> |
||||||
</template> |
</template> |
||||||
</BasicTable> |
</BasicTable> |
||||||
|
<!--弹出窗体区域--> |
||||||
<DoctorModal @register="registerModal" @success="handleSuccess"></DoctorModal> |
<DoctorModal @register="registerModal" @success="handleRefreshTable"/> |
||||||
</div> |
</div> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
/** |
||||||
import {useModal} from '/@/components/Modal'; |
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||||
import DoctorModal from './DoctorModal.vue'; |
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||||
import {columns, searchFormSchema} from './doctor.data' |
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||||
import {useMessage} from '/@/hooks/web/useMessage'; |
* author entfrm开发团队-王翔 |
||||||
import {list, remove} from '/@/api/platform/system/controller/doctor'; |
*/ |
||||||
const {createMessage} = useMessage(); |
import { reactive, toRaw } from 'vue'; |
||||||
const [registerModal, {openModal}] = useModal(); |
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||||
const [registerTable, {reload}] = useTable({ |
import {listDoctor, delDoctor} from '/@/api/platform/system/controller/doctor'; |
||||||
|
import { useModal } from '/@/components/Modal'; |
||||||
|
import { columns, searchFormSchema } from './doctor.data'; |
||||||
|
import { useMessage } from '/@/hooks/web/useMessage'; |
||||||
|
import DoctorModal from './DoctorModal.vue'; |
||||||
|
|
||||||
|
/** 类型规范统一声明定义区域 */ |
||||||
|
interface TableState { |
||||||
|
single: boolean; |
||||||
|
multiple: boolean; |
||||||
|
} |
||||||
|
|
||||||
|
/** 通用变量统一声明区域 */ |
||||||
|
const state = reactive<TableState>({ |
||||||
|
// 非单个禁用 |
||||||
|
single: true, |
||||||
|
// 非多个禁用 |
||||||
|
multiple: true |
||||||
|
}); |
||||||
|
const { createConfirm, createMessage } = useMessage(); |
||||||
|
const [registerModal, { openModal }] = useModal(); |
||||||
|
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||||
title: '医生列表', |
title: '医生列表', |
||||||
api: list, |
api: listDoctor, |
||||||
|
rowKey: 'id', |
||||||
columns, |
columns, |
||||||
formConfig: { |
formConfig: { |
||||||
labelWidth: 120, |
labelWidth: 120, |
||||||
schemas: searchFormSchema, |
schemas: searchFormSchema, |
||||||
|
autoSubmitOnEnter: true, |
||||||
|
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] |
||||||
}, |
}, |
||||||
pagination: true, |
rowSelection: { type: 'checkbox' }, |
||||||
striped: true, |
|
||||||
useSearchForm: true, |
useSearchForm: true, |
||||||
showTableSetting: true, |
showTableSetting: true, |
||||||
bordered: true, |
bordered: true, |
||||||
showIndexColumn: true, |
clickToRowSelect: false, |
||||||
canResize: false, |
showIndexColumn: false, |
||||||
actionColumn: { |
actionColumn: { |
||||||
width: 80, |
width: 220, |
||||||
title: '操作', |
title: '操作', |
||||||
dataIndex: 'action', |
dataIndex: 'action', |
||||||
slots: {customRender: 'action'}, |
slots: { customRender: 'action' }, |
||||||
fixed: undefined, |
fixed: false |
||||||
}, |
}, |
||||||
}); |
handleSearchInfoFn: () => clearSelectedRowKeys() |
||||||
/** |
|
||||||
* 创建菜单 |
|
||||||
*/ |
|
||||||
function handleCreate() { |
|
||||||
openModal(true, { |
|
||||||
isUpdate: false, |
|
||||||
}); |
|
||||||
} |
|
||||||
/** |
|
||||||
* 编辑菜单 |
|
||||||
*/ |
|
||||||
function handleEdit(record: Recordable) { |
|
||||||
openModal(true, { |
|
||||||
record, |
|
||||||
isUpdate: true, |
|
||||||
}); |
}); |
||||||
} |
|
||||||
/** |
/** 处理多选框选中数据 */ |
||||||
* 删除菜单 |
function handleSelectionChange(selection?: Recordable) { |
||||||
*/ |
const rowSelection = toRaw(selection?.keys) || []; |
||||||
async function handleDelete(record: Recordable) { |
state.single = rowSelection.length != 1; |
||||||
await remove({ids: record.id}); |
state.multiple = !rowSelection.length; |
||||||
|
} |
||||||
|
|
||||||
|
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
||||||
|
function handleAdd() { |
||||||
|
openModal(true,{ _tag: 'add' }); |
||||||
|
} |
||||||
|
|
||||||
|
/** 编辑按钮操作,行内编辑 */ |
||||||
|
function handleEdit(record?: Recordable) { |
||||||
|
record = record || { id: getSelectRowKeys() }; |
||||||
|
openModal(true, { _tag: 'edit', record }); |
||||||
|
} |
||||||
|
|
||||||
|
/** 删除按钮操作,行内删除 */ |
||||||
|
async function handleDel(record?: Recordable) { |
||||||
|
const id = record?.id || getSelectRowKeys(); |
||||||
|
createConfirm({ |
||||||
|
iconType: 'warning', |
||||||
|
title: '警告', |
||||||
|
content: `是否确认删除医生编号为${id}医生吗?`, |
||||||
|
onOk: async () => { |
||||||
|
await delDoctor(id); |
||||||
createMessage.success('删除成功!'); |
createMessage.success('删除成功!'); |
||||||
handleSuccess(); |
handleRefreshTable(); |
||||||
} |
} |
||||||
/** |
}); |
||||||
* 成功后重载表格 |
} |
||||||
*/ |
|
||||||
function handleSuccess() { |
/** 处理表格刷新 */ |
||||||
|
function handleRefreshTable() { |
||||||
|
clearSelectedRowKeys(); |
||||||
reload(); |
reload(); |
||||||
} |
} |
||||||
</script> |
</script> |
@ -0,0 +1,67 @@ |
|||||||
|
<template> |
||||||
|
<BasicModal v-bind="$attrs" |
||||||
|
:title="getTitle" |
||||||
|
@register="registerModal" |
||||||
|
@ok="handleSubmit" |
||||||
|
> |
||||||
|
<BasicForm @register="registerForm"/> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script lang="ts" setup> |
||||||
|
import {ref, computed, unref} from 'vue'; |
||||||
|
import {BasicModal, useModalInner} from '/@/components/Modal'; |
||||||
|
import {cardFormSchema} from './boxcard.data'; |
||||||
|
import {BasicForm, useForm} from '/@/components/Form/index'; |
||||||
|
import {set} from '/@/api/platform/system/controller/boxcard'; |
||||||
|
|
||||||
|
const isUpdate = ref(true); |
||||||
|
|
||||||
|
// 定义emit |
||||||
|
const emit = defineEmits(['success', 'register']); |
||||||
|
|
||||||
|
/** |
||||||
|
* 表单 |
||||||
|
*/ |
||||||
|
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
||||||
|
labelWidth: 100, |
||||||
|
schemas: cardFormSchema, |
||||||
|
showActionButtonGroup: false, |
||||||
|
actionColOptions: { |
||||||
|
span: 23, |
||||||
|
}, |
||||||
|
}); |
||||||
|
|
||||||
|
/** |
||||||
|
* 表单参数 |
||||||
|
*/ |
||||||
|
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
||||||
|
resetFields(); |
||||||
|
setModalProps({confirmLoading: false}); |
||||||
|
isUpdate.value = !!data?.isUpdate; |
||||||
|
|
||||||
|
|
||||||
|
if (unref(isUpdate)) { |
||||||
|
setFieldsValue({ |
||||||
|
...data.record, |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
//表单标题 |
||||||
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增网卡' : '编辑网卡')); |
||||||
|
|
||||||
|
async function handleSubmit() { |
||||||
|
try { |
||||||
|
const values = await validate(); |
||||||
|
setModalProps({confirmLoading: true}); |
||||||
|
await set(values);//保存网卡 |
||||||
|
closeModal(); |
||||||
|
emit('success'); |
||||||
|
} finally { |
||||||
|
setModalProps({confirmLoading: false}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
</script> |
@ -0,0 +1,160 @@ |
|||||||
|
import { BasicColumn } from '/@/components/Table'; |
||||||
|
import { FormSchema } from '/@/components/Table'; |
||||||
|
import {h} from 'vue'; |
||||||
|
import {Tag} from 'ant-design-vue'; |
||||||
|
|
||||||
|
|
||||||
|
export const columns: BasicColumn[] = [ |
||||||
|
{ |
||||||
|
title: 'ID', |
||||||
|
dataIndex: 'id', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: 'iccid', |
||||||
|
dataIndex: 'iccid', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '卡号', |
||||||
|
dataIndex: 'card', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '网卡厂商', |
||||||
|
dataIndex: 'company', |
||||||
|
width: 120, |
||||||
|
customRender: ({ record }) => { |
||||||
|
const com = record.company; |
||||||
|
switch (com) { |
||||||
|
case '1': return '中国移动'; |
||||||
|
case '2': return '中国联通'; |
||||||
|
case '3': return '中国电信'; |
||||||
|
default: return '未知厂商'; |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '卡是否已使用', |
||||||
|
dataIndex: 'isUsed', |
||||||
|
width: 120, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '状态', |
||||||
|
dataIndex: 'status', |
||||||
|
width: 100, |
||||||
|
customRender: ({ record }) => { |
||||||
|
const status = record.status; |
||||||
|
const enable = status === '0'; |
||||||
|
const color = enable ? 'green' : 'red'; |
||||||
|
const text = enable ? '启用' : '禁用'; |
||||||
|
return h(Tag, { color: color }, () => text); |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建人', |
||||||
|
dataIndex: 'createByName', |
||||||
|
width: 180, |
||||||
|
}, |
||||||
|
{ |
||||||
|
title: '创建时间', |
||||||
|
dataIndex: 'createTime', |
||||||
|
width: 180, |
||||||
|
} |
||||||
|
]; |
||||||
|
|
||||||
|
export const searchFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
field: 'iccid', |
||||||
|
label: 'iccid', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入唯一标识iccid', |
||||||
|
}, |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'card', |
||||||
|
label: '卡号', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入卡号', |
||||||
|
}, |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'company', |
||||||
|
label: '网卡厂商', |
||||||
|
component: 'Input', |
||||||
|
componentProps: { |
||||||
|
placeholder: '请输入网卡厂商', |
||||||
|
}, |
||||||
|
colProps: { span: 4 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'beginTime', |
||||||
|
label: '起始时间', |
||||||
|
component: 'DatePicker', |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'endTime', |
||||||
|
label: '截止时间', |
||||||
|
component: 'DatePicker', |
||||||
|
colProps: { span: 5 }, |
||||||
|
}, |
||||||
|
]; |
||||||
|
|
||||||
|
export const cardFormSchema: FormSchema[] = [ |
||||||
|
{ |
||||||
|
field: 'id', |
||||||
|
label: 'ID', |
||||||
|
component: 'Input', |
||||||
|
show: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'iccid', |
||||||
|
label: 'iccid', |
||||||
|
component: 'Input', |
||||||
|
helpMessage: ['唯一识别号'], |
||||||
|
required: true |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'card', |
||||||
|
label: '卡号', |
||||||
|
component: 'Input', |
||||||
|
required: false, |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'company', |
||||||
|
label: '网卡厂商', |
||||||
|
component: 'Select', |
||||||
|
required: true, |
||||||
|
componentProps: { |
||||||
|
options: [ |
||||||
|
{ label: '中国移动', value: '1' }, |
||||||
|
{ label: '中国联通', value: '2' }, |
||||||
|
{ label: '中国电信', value: '3' }, |
||||||
|
{ label: '未知厂商', value: ''||undefined||null } |
||||||
|
], |
||||||
|
|
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
field: 'status', |
||||||
|
label: '状态', |
||||||
|
component: 'RadioButtonGroup', |
||||||
|
defaultValue: '0', |
||||||
|
componentProps: { |
||||||
|
options: [ |
||||||
|
{ label: '启用', value: '0' }, |
||||||
|
{ label: '禁用', value: '1' }, |
||||||
|
], |
||||||
|
}, |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: '备注', |
||||||
|
field: 'remarks', |
||||||
|
component: 'InputTextArea', |
||||||
|
} |
||||||
|
]; |
@ -0,0 +1,100 @@ |
|||||||
|
<template> |
||||||
|
<div> |
||||||
|
<BasicTable @register="registerTable"> |
||||||
|
<template #toolbar> |
||||||
|
<a-button type="primary" @click="handleCreate">新增网卡</a-button> |
||||||
|
</template> |
||||||
|
<template #action="{ record }"> |
||||||
|
<TableAction |
||||||
|
:actions="[ |
||||||
|
{ |
||||||
|
icon: 'clarity:note-edit-line', |
||||||
|
onClick: handleEdit.bind(null, record), |
||||||
|
}, |
||||||
|
{ |
||||||
|
icon: 'ant-design:delete-outlined', |
||||||
|
color: 'error', |
||||||
|
popConfirm: { |
||||||
|
title: '是否确认删除', |
||||||
|
confirm: handleDelete.bind(null, record), |
||||||
|
}, |
||||||
|
}, |
||||||
|
]" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
</BasicTable> |
||||||
|
|
||||||
|
<BoxCardModal @register="registerModal" @success="handleSuccess"/> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script lang="ts" setup> |
||||||
|
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
||||||
|
import {useModal} from '/@/components/Modal'; |
||||||
|
import BoxCardModal from './BoxCardModal.vue'; |
||||||
|
import {columns, searchFormSchema} from './boxcard.data'; |
||||||
|
import {useMessage} from '/@/hooks/web/useMessage'; |
||||||
|
import {cardList, remove} from '/@/api/platform/system/controller/boxcard'; |
||||||
|
|
||||||
|
const {createMessage} = useMessage(); |
||||||
|
const [registerModal, {openModal}] = useModal(); |
||||||
|
const [registerTable, {reload}] = useTable({ |
||||||
|
title: '网卡列表', |
||||||
|
api: cardList, |
||||||
|
columns, |
||||||
|
formConfig: { |
||||||
|
labelWidth: 120, |
||||||
|
schemas: searchFormSchema, |
||||||
|
}, |
||||||
|
pagination: true, |
||||||
|
striped: true, |
||||||
|
useSearchForm: true, |
||||||
|
showTableSetting: true, |
||||||
|
bordered: true, |
||||||
|
showIndexColumn: true, |
||||||
|
canResize: false, |
||||||
|
actionColumn: { |
||||||
|
width: 80, |
||||||
|
title: '操作', |
||||||
|
dataIndex: 'action', |
||||||
|
slots: {customRender: 'action'}, |
||||||
|
fixed: undefined, |
||||||
|
}, |
||||||
|
}); |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建菜单 |
||||||
|
*/ |
||||||
|
function handleCreate() { |
||||||
|
openModal(true, { |
||||||
|
isUpdate: false, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑菜单 |
||||||
|
*/ |
||||||
|
function handleEdit(record: Recordable) { |
||||||
|
openModal(true, { |
||||||
|
record, |
||||||
|
isUpdate: true, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除菜单 |
||||||
|
*/ |
||||||
|
async function handleDelete(record: Recordable) { |
||||||
|
await remove({ids: record.id}); |
||||||
|
createMessage.success('删除成功!'); |
||||||
|
handleSuccess(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 成功后重载表格 |
||||||
|
*/ |
||||||
|
function handleSuccess() { |
||||||
|
reload(); |
||||||
|
} |
||||||
|
|
||||||
|
</script> |
Loading…
Reference in new issue