22 changed files with 1017 additions and 286 deletions
@ -0,0 +1,57 @@
@@ -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 @@
@@ -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 @@
@@ -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 @@
@@ -1,52 +1,79 @@
|
||||
<template> |
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> |
||||
<BasicModal v-bind="$attrs" |
||||
width="720px" |
||||
@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 {doctorFormSchema} from './doctor.data'; |
||||
import {BasicForm, useForm} from '/@/components/Form'; |
||||
import {set} from '/@/api/platform/system/controller/doctor'; |
||||
const isUpdate = ref(true); |
||||
// 定义emit |
||||
const emit = defineEmits(['success', 'register']); |
||||
/** |
||||
* 表单 |
||||
*/ |
||||
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
||||
labelWidth: 100, |
||||
schemas: doctorFormSchema, |
||||
showActionButtonGroup: false, |
||||
actionColOptions: { |
||||
span: 23, |
||||
}, |
||||
}); |
||||
/** |
||||
* 表单参数 |
||||
*/ |
||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
||||
resetFields(); |
||||
setModalProps({confirmLoading: false}); |
||||
isUpdate.value = !!data?.isUpdate; |
||||
console.log(data.record); |
||||
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}); |
||||
/** |
||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||
* author entfrm开发团队-王翔 |
||||
*/ |
||||
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, |
||||
schemas: doctorFormSchema, |
||||
showActionButtonGroup: false, |
||||
baseColProps: { span: 24 } |
||||
}); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
||||
// 处理清除脏数据 |
||||
await resetFields(); |
||||
await clearValidate(); |
||||
// 处理设置数据 |
||||
tag.value = data._tag; |
||||
const id = data.record?.id; |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
// 采用tag标签区分操作 |
||||
switch (unref(tag)) { |
||||
case 'add': |
||||
props.title = '医生'; |
||||
break; |
||||
case 'edit': |
||||
props.title = '编辑医生'; |
||||
await setFieldsValue(await getDoctor(id)); |
||||
break; |
||||
} |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
/** 处理弹出框提交 */ |
||||
async function handleSubmit() { |
||||
try { |
||||
// 提取验证数据 |
||||
const formData = await validate(); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
// 采用tag标签区分操作 |
||||
switch (unref(tag)) { |
||||
case 'add': |
||||
await addDoctor(formData); |
||||
break; |
||||
case 'edit': |
||||
await editDoctor(formData); |
||||
break; |
||||
} |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
</script> |
||||
|
@ -1,94 +1,136 @@
@@ -1,94 +1,136 @@
|
||||
<template> |
||||
<div> |
||||
<BasicTable @register="registerTable"> |
||||
<BasicTable @register="registerTable" |
||||
@selection-change="handleSelectionChange" |
||||
> |
||||
<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 #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), |
||||
}, |
||||
}, |
||||
]" |
||||
<TableAction :actions="[ |
||||
{ |
||||
label: '编辑', |
||||
icon: 'fa6-regular:pen-to-square', |
||||
onClick: handleEdit.bind(null, record) |
||||
}, |
||||
{ |
||||
label: '删除', |
||||
icon: 'ant-design:delete-outlined', |
||||
color: 'error', |
||||
onClick: handleDel.bind(null, record) |
||||
}]" |
||||
/> |
||||
</template> |
||||
</BasicTable> |
||||
|
||||
<DoctorModal @register="registerModal" @success="handleSuccess"></DoctorModal> |
||||
<!--弹出窗体区域--> |
||||
<DoctorModal @register="registerModal" @success="handleRefreshTable"/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
||||
import {useModal} from '/@/components/Modal'; |
||||
import DoctorModal from './DoctorModal.vue'; |
||||
import {columns, searchFormSchema} from './doctor.data' |
||||
import {useMessage} from '/@/hooks/web/useMessage'; |
||||
import {list, remove} from '/@/api/platform/system/controller/doctor'; |
||||
const {createMessage} = useMessage(); |
||||
const [registerModal, {openModal}] = useModal(); |
||||
const [registerTable, {reload}] = useTable({ |
||||
title: '医生列表', |
||||
api: list, |
||||
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, |
||||
/** |
||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
||||
* author entfrm开发团队-王翔 |
||||
*/ |
||||
import { reactive, toRaw } from 'vue'; |
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
||||
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 |
||||
}); |
||||
} |
||||
/** |
||||
* 编辑菜单 |
||||
*/ |
||||
function handleEdit(record: Recordable) { |
||||
openModal(true, { |
||||
record, |
||||
isUpdate: true, |
||||
const { createConfirm, createMessage } = useMessage(); |
||||
const [registerModal, { openModal }] = useModal(); |
||||
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ |
||||
title: '医生列表', |
||||
api: listDoctor, |
||||
rowKey: 'id', |
||||
columns, |
||||
formConfig: { |
||||
labelWidth: 120, |
||||
schemas: searchFormSchema, |
||||
autoSubmitOnEnter: true, |
||||
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] |
||||
}, |
||||
rowSelection: { type: 'checkbox' }, |
||||
useSearchForm: true, |
||||
showTableSetting: true, |
||||
bordered: true, |
||||
clickToRowSelect: false, |
||||
showIndexColumn: false, |
||||
actionColumn: { |
||||
width: 220, |
||||
title: '操作', |
||||
dataIndex: 'action', |
||||
slots: { customRender: 'action' }, |
||||
fixed: false |
||||
}, |
||||
handleSearchInfoFn: () => clearSelectedRowKeys() |
||||
}); |
||||
} |
||||
/** |
||||
* 删除菜单 |
||||
*/ |
||||
async function handleDelete(record: Recordable) { |
||||
await remove({ids: record.id}); |
||||
createMessage.success('删除成功!'); |
||||
handleSuccess(); |
||||
} |
||||
/** |
||||
* 成功后重载表格 |
||||
*/ |
||||
function handleSuccess() { |
||||
reload(); |
||||
} |
||||
</script> |
||||
|
||||
/** 处理多选框选中数据 */ |
||||
function handleSelectionChange(selection?: Recordable) { |
||||
const rowSelection = toRaw(selection?.keys) || []; |
||||
state.single = rowSelection.length != 1; |
||||
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('删除成功!'); |
||||
handleRefreshTable(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** 处理表格刷新 */ |
||||
function handleRefreshTable() { |
||||
clearSelectedRowKeys(); |
||||
reload(); |
||||
} |
||||
</script> |
||||
|
@ -0,0 +1,67 @@
@@ -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 @@
@@ -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 @@
@@ -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