32 changed files with 240 additions and 449 deletions
@ -1,58 +1,125 @@ |
|||||||
<template> |
<script lang="tsx" setup> |
||||||
<BasicModal v-bind="$attrs" |
import { reactive, nextTick, ref, h } from 'vue'; |
||||||
defaultFullscreen |
|
||||||
@register="registerModal" |
|
||||||
@ok="handleSubmit" |
|
||||||
> |
|
||||||
<ARow> |
|
||||||
<ACol :span="12"> |
|
||||||
<AMap :sidebarControl="false"/> |
|
||||||
</ACol> |
|
||||||
<ACol :span="12"> |
|
||||||
<BasicTable @register="registerTable"/> |
|
||||||
</ACol> |
|
||||||
</ARow> |
|
||||||
</BasicModal> |
|
||||||
</template> |
|
||||||
<script lang="ts" setup> |
|
||||||
import { reactive } from 'vue'; |
|
||||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||||
import { BasicTable, useTable } from '/@/components/Table'; |
|
||||||
import { Form, Select, Row, Col } from 'ant-design-vue'; |
import { Form, Select, Row, Col } from 'ant-design-vue'; |
||||||
import { AMap } from '/@/components/AMap'; |
import { AMap } from '/@/components/AMap'; |
||||||
import { formMapDataSettingsColumns } from '/@/components/AMap/src/map.data'; |
import { formMapDataSettingsColumns } from '/@/components/AMap/src/map.data'; |
||||||
|
import Sortable from 'sortablejs'; |
||||||
|
import { VxeGridProps } from 'vxe-table'; |
||||||
|
|
||||||
|
const VxeGridEl = ref(); |
||||||
|
const mapSettingsState = reactive({ |
||||||
|
sortable: {} |
||||||
|
}); |
||||||
|
const gridOptions = reactive({ |
||||||
|
data: [ |
||||||
|
{ |
||||||
|
id: 10001, |
||||||
|
name: 'Test1' |
||||||
|
}, |
||||||
|
{ |
||||||
|
id: 10002, |
||||||
|
name: 'Test2' |
||||||
|
}, |
||||||
|
{ |
||||||
|
id: 10003, |
||||||
|
name: 'Test3' |
||||||
|
} |
||||||
|
], |
||||||
|
columns: [ |
||||||
|
{ |
||||||
|
width: '50px', |
||||||
|
align: 'center', |
||||||
|
slots: { |
||||||
|
default ({ row }) { |
||||||
|
return ( |
||||||
|
<span class="drag-btn"> |
||||||
|
<i class="vxe-icon--menu"/> |
||||||
|
</span> |
||||||
|
); |
||||||
|
}, |
||||||
|
header ({ row }) { |
||||||
|
return ( |
||||||
|
<vxe-tooltip content="按住后可以上下拖动排序!"> |
||||||
|
<i class="vxe-icon--question"/> |
||||||
|
</vxe-tooltip> |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
{ field: 'name', title: '名称' } |
||||||
|
], |
||||||
|
rowConfig: { |
||||||
|
useKey: true, |
||||||
|
isHover: true |
||||||
|
}, |
||||||
|
border: true, |
||||||
|
height: 'auto', |
||||||
|
stripe: true |
||||||
|
} as VxeGridProps); |
||||||
const AForm = Form; |
const AForm = Form; |
||||||
const AFormItem = Form.Item; |
const AFormItem = Form.Item; |
||||||
const ASelect = Select; |
const ASelect = Select; |
||||||
const ARow = Row; |
const ARow = Row; |
||||||
const ACol = Col; |
const ACol = Col; |
||||||
|
|
||||||
const [ registerTable, { reload, getDataSource, setProps }] = useTable({ |
|
||||||
title: '地图标记点数据', |
|
||||||
columns: formMapDataSettingsColumns, |
|
||||||
pagination: false, |
|
||||||
dataSource: [{ |
|
||||||
markId: '001', |
|
||||||
markName: '标记点1' |
|
||||||
},{ |
|
||||||
markId: '002', |
|
||||||
markName: '标记点2' |
|
||||||
}], |
|
||||||
striped: false, |
|
||||||
useSearchForm: false, |
|
||||||
showTableSetting: false, |
|
||||||
bordered: true, |
|
||||||
showIndexColumn: false, |
|
||||||
canResize: false |
|
||||||
}); |
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register']); |
const emit = defineEmits(['success', 'register']); |
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async data => { |
const [registerModal, { setModalProps, closeModal }] = useModalInner(data => { |
||||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||||
props.title = '地图标记点数据设置弹出框'; |
props.title = '地图标记点数据设置弹出框'; |
||||||
|
|
||||||
|
nextTick(() => { |
||||||
|
mapSettingsState.sortable = Sortable.create(VxeGridEl.value!.$el.querySelector('.body--wrapper>.vxe-table--body tbody'), { |
||||||
|
handle: '.drag-btn', |
||||||
|
onEnd: ({ newIndex, oldIndex }) => { |
||||||
|
const currRow = gridOptions.data?.splice(oldIndex!, 1)[0]; |
||||||
|
gridOptions.data?.splice(newIndex!, 0, currRow); |
||||||
|
}, |
||||||
|
ghostClass: 'ghostGrid' |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
// 尾部:设置处理后的最终配置数据 |
// 尾部:设置处理后的最终配置数据 |
||||||
setModalProps(props); |
setModalProps(props); |
||||||
}); |
}); |
||||||
|
|
||||||
|
|
||||||
|
function handleSubmit() { |
||||||
|
|
||||||
|
} |
||||||
</script> |
</script> |
||||||
|
<template> |
||||||
|
<BasicModal v-bind="$attrs" |
||||||
|
defaultFullscreen |
||||||
|
@register="registerModal" |
||||||
|
@ok="handleSubmit" |
||||||
|
> |
||||||
|
<ARow> |
||||||
|
<ACol :span="12"> |
||||||
|
<AMap :sidebarControl="false"/> |
||||||
|
</ACol> |
||||||
|
<ACol :span="12"> |
||||||
|
<vxe-grid ref="VxeGridEl" v-bind="gridOptions"/> |
||||||
|
</ACol> |
||||||
|
</ARow> |
||||||
|
</BasicModal> |
||||||
|
</template> |
||||||
|
<style> |
||||||
|
|
||||||
|
.ghostGrid { |
||||||
|
background: white; |
||||||
|
border: 2px solid #67C23A; |
||||||
|
box-sizing: border-box; |
||||||
|
font-size: 0; |
||||||
|
content: ""; |
||||||
|
overflow: hidden; |
||||||
|
padding: 0 !important; |
||||||
|
position: relative; |
||||||
|
outline: none 0; |
||||||
|
height: 100% !important; |
||||||
|
width: 0 !important; |
||||||
|
float: left; |
||||||
|
margin: 0 2px 0 2px; |
||||||
|
} |
||||||
|
|
||||||
|
</style> |
||||||
|
|
||||||
|
@ -1,88 +0,0 @@ |
|||||||
<template> |
|
||||||
<BasicModal v-bind="$attrs" |
|
||||||
width="720px" |
|
||||||
@ok="handleSubmit" |
|
||||||
@register="registerModal" |
|
||||||
> |
|
||||||
<BasicForm @register="registerForm"/> |
|
||||||
</BasicModal> |
|
||||||
</template> |
|
||||||
<script lang="ts" setup> |
|
||||||
/** |
|
||||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
||||||
* 采用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 { formSchema } from './area.data'; |
|
||||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
||||||
import { listArea, addArea, editArea, getArea } from '/@/api/platform/system/controller/area'; |
|
||||||
import { listToTree } from '/@/utils/helper/treeHelper'; |
|
||||||
|
|
||||||
/** 通用变量统一声明区域 */ |
|
||||||
const tag = ref<Nullable<string>>(''); |
|
||||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
||||||
const emit = defineEmits(['success', 'register']); |
|
||||||
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate, clearValidate }] = useForm({ |
|
||||||
labelWidth: 100, |
|
||||||
schemas: formSchema, |
|
||||||
showActionButtonGroup: false, |
|
||||||
baseColProps: { span: 24 } |
|
||||||
}); |
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
|
||||||
// 处理清除脏数据 |
|
||||||
await resetFields(); |
|
||||||
await clearValidate(); |
|
||||||
// 处理设置数据 |
|
||||||
tag.value = data._tag; |
|
||||||
const topArea = { areaId: '0', name: '顶级区域', children: [] }; |
|
||||||
topArea.children = listToTree(await listArea()); |
|
||||||
await updateSchema({ |
|
||||||
field: 'parentId', |
|
||||||
componentProps: { |
|
||||||
treeData: [topArea] |
|
||||||
} |
|
||||||
}); |
|
||||||
const areaId = data.record?.areaId; |
|
||||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
||||||
// 采用tag标签区分操作 |
|
||||||
switch (unref(tag)) { |
|
||||||
case 'add': |
|
||||||
props.title = '新增区域'; |
|
||||||
areaId && (await setFieldsValue({ parentId: areaId })); |
|
||||||
break; |
|
||||||
case 'edit': |
|
||||||
props.title = '编辑区域'; |
|
||||||
await setFieldsValue(await getArea(areaId)); |
|
||||||
break; |
|
||||||
} |
|
||||||
// 尾部:设置处理后的最终配置数据 |
|
||||||
setModalProps(props); |
|
||||||
}); |
|
||||||
|
|
||||||
/** 处理弹出框提交 */ |
|
||||||
async function handleSubmit() { |
|
||||||
try { |
|
||||||
// 提取验证数据 |
|
||||||
const formData = await validate(); |
|
||||||
// 处理提交之前逻辑 |
|
||||||
setModalProps({ confirmLoading: true }); |
|
||||||
// 采用tag标签区分操作 |
|
||||||
switch (unref(tag)) { |
|
||||||
case 'add': |
|
||||||
await addArea(formData); |
|
||||||
break; |
|
||||||
case 'edit': |
|
||||||
await editArea(formData); |
|
||||||
break; |
|
||||||
} |
|
||||||
// 处理提交完成之后逻辑 |
|
||||||
closeModal(); |
|
||||||
emit('success'); |
|
||||||
} finally { |
|
||||||
setModalProps({ confirmLoading: false }); |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
|
@ -1,191 +0,0 @@ |
|||||||
/** |
|
||||||
* @program: kicc-ui |
|
||||||
* @description: 区域模块动态渲染配置 |
|
||||||
* @author: entfrm开发团队-王翔 |
|
||||||
* @create: 2022/4/21 |
|
||||||
*/ |
|
||||||
|
|
||||||
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: '区域名称', |
|
||||||
dataIndex: 'name', |
|
||||||
align: 'left' |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '区域编码', |
|
||||||
dataIndex: 'code' |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '排序', |
|
||||||
dataIndex: 'sort' |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '状态', |
|
||||||
dataIndex: 'status', |
|
||||||
width: 80, |
|
||||||
customRender: ({record}) => { |
|
||||||
const status = record.status; |
|
||||||
// 采用二进制~~取反,只要为null或者0等等一些其他的空元素都会转为0
|
|
||||||
// 第一次取反会运算为-1,在后一次取反会运算为0
|
|
||||||
const enable = ~~status === 0; |
|
||||||
const color = enable ? 'green' : 'red'; |
|
||||||
const text = enable ? '正常' : '停用'; |
|
||||||
return h(Tag, { color: color }, () => text); |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
title: '创建时间', |
|
||||||
dataIndex: 'createTime' |
|
||||||
} |
|
||||||
]; |
|
||||||
|
|
||||||
/** 搜索表单配置 */ |
|
||||||
export const searchFormSchema: FormSchema[] = [ |
|
||||||
{ |
|
||||||
field: 'name', |
|
||||||
label: '区域名称', |
|
||||||
component: 'Input', |
|
||||||
componentProps: { |
|
||||||
placeholder: '请输入区域名称' |
|
||||||
}, |
|
||||||
colProps: {span: 8} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'status', |
|
||||||
label: '状态', |
|
||||||
component: 'Select', |
|
||||||
componentProps: { |
|
||||||
options: [ |
|
||||||
{ label: '正常', value: '0' }, |
|
||||||
{ label: '停用', value: '1' } |
|
||||||
] |
|
||||||
}, |
|
||||||
colProps: { span: 7 } |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'dateRange', |
|
||||||
label: '创建时间', |
|
||||||
component: 'RangePicker', |
|
||||||
componentProps: { |
|
||||||
style: { width:'100%' }, |
|
||||||
valueFormat: 'YYYY-MM-DD', |
|
||||||
placeholder: ['开始日期','结束日期'] |
|
||||||
}, |
|
||||||
colProps: { span: 8 } |
|
||||||
} |
|
||||||
]; |
|
||||||
|
|
||||||
/** 表单配置 */ |
|
||||||
export const formSchema: FormSchema[] = [ |
|
||||||
{ |
|
||||||
field: 'areaId', |
|
||||||
label: 'ID', |
|
||||||
component: 'Input', |
|
||||||
show: false |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'parentId', |
|
||||||
label: '上级区域', |
|
||||||
component: 'TreeSelect', |
|
||||||
defaultValue: '0', |
|
||||||
componentProps: { |
|
||||||
replaceFields: { |
|
||||||
title: 'name', |
|
||||||
key: 'areaId', |
|
||||||
value: 'areaId', |
|
||||||
}, |
|
||||||
getPopupContainer: () => document.body, |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'name', |
|
||||||
label: '区域名称', |
|
||||||
component: 'Input', |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'code', |
|
||||||
label: '区域代码', |
|
||||||
component: 'Input', |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'contacts', |
|
||||||
label: '联系人', |
|
||||||
component: 'Input', |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'phone', |
|
||||||
label: '联系人电话', |
|
||||||
component: 'Input', |
|
||||||
rules: [ |
|
||||||
{ |
|
||||||
pattern: new RegExp('^1[3|4|5|6|7|8|9][0-9]\\d{8}$'), |
|
||||||
message: '请输入正确的手机号码!', |
|
||||||
validateTrigger: 'change' |
|
||||||
} |
|
||||||
], |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'sort', |
|
||||||
label: '区域排序', |
|
||||||
component: 'InputNumber', |
|
||||||
componentProps: { |
|
||||||
style: { width:'100%' }, |
|
||||||
min: 0 |
|
||||||
}, |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'email', |
|
||||||
label: '邮箱', |
|
||||||
component: 'Input', |
|
||||||
rules: [ |
|
||||||
{ |
|
||||||
type: 'email', |
|
||||||
message: '请输入正确的邮箱地址!', |
|
||||||
validateTrigger: 'change' |
|
||||||
} |
|
||||||
], |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
}, |
|
||||||
{ |
|
||||||
field: 'status', |
|
||||||
label: '状态', |
|
||||||
component: 'RadioGroup', |
|
||||||
defaultValue: '0', |
|
||||||
componentProps: { |
|
||||||
options: [ |
|
||||||
{ label: '正常', value: '0' }, |
|
||||||
{ label: '停用', value: '1' } |
|
||||||
] |
|
||||||
}, |
|
||||||
required: true, |
|
||||||
colProps: { |
|
||||||
span: 12 |
|
||||||
} |
|
||||||
} |
|
||||||
]; |
|
@ -1,112 +0,0 @@ |
|||||||
<template> |
|
||||||
<div> |
|
||||||
<BasicTable @register="registerTable"> |
|
||||||
<template #toolbar> |
|
||||||
<a-button v-auth="['area_add']" type="primary" @click="handleAdd()">新增区域</a-button> |
|
||||||
<a-button type="default" @click="expandAll">展开全部</a-button> |
|
||||||
<a-button type="default" @click="collapseAll">折叠全部</a-button> |
|
||||||
</template> |
|
||||||
<template #action="{ record }"> |
|
||||||
<TableAction |
|
||||||
:actions="[ |
|
||||||
{ |
|
||||||
label: '编辑', |
|
||||||
icon: 'fa6-regular:pen-to-square', |
|
||||||
auth: ['area_edit'], |
|
||||||
onClick: handleEdit.bind(null, record) |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '新增', |
|
||||||
icon: 'ant-design:plus-circle-outlined', |
|
||||||
auth: ['area_add'], |
|
||||||
onClick: handleAdd.bind(null, record) |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: '删除', |
|
||||||
icon: 'ant-design:delete-outlined', |
|
||||||
auth: ['area_del'], |
|
||||||
color: 'error', |
|
||||||
popConfirm: { |
|
||||||
title: '是否确认删除', |
|
||||||
confirm: handleDel.bind(null, record) |
|
||||||
} |
|
||||||
} |
|
||||||
]" |
|
||||||
/> |
|
||||||
</template> |
|
||||||
</BasicTable> |
|
||||||
<AreaModal @register="registerModal" @success="handleRefreshTable" /> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
<script lang="ts" setup> |
|
||||||
/** |
|
||||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
||||||
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
|
||||||
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
||||||
* author entfrm开发团队-王翔 |
|
||||||
*/ |
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table' |
|
||||||
import { useModal } from '/@/components/Modal' |
|
||||||
import AreaModal from './AreaModal.vue' |
|
||||||
import { columns, searchFormSchema } from './area.data' |
|
||||||
import { delArea, listArea } from '/@/api/platform/system/controller/area' |
|
||||||
import { useMessage } from '/@/hooks/web/useMessage' |
|
||||||
import { listToTree } from '/@/utils/helper/treeHelper' |
|
||||||
|
|
||||||
/** 通用变量统一声明区域 */ |
|
||||||
const { createMessage } = useMessage() |
|
||||||
const [registerModal, { openModal }] = useModal() |
|
||||||
const [registerTable, { reload, expandAll, collapseAll }] = useTable({ |
|
||||||
title: '区域列表', |
|
||||||
api: listArea, |
|
||||||
rowKey: 'areaId', |
|
||||||
columns, |
|
||||||
formConfig: { |
|
||||||
labelWidth: 120, |
|
||||||
schemas: searchFormSchema, |
|
||||||
autoSubmitOnEnter: true, |
|
||||||
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']] |
|
||||||
}, |
|
||||||
isTreeTable: true, |
|
||||||
pagination: false, |
|
||||||
striped: false, |
|
||||||
useSearchForm: true, |
|
||||||
showTableSetting: true, |
|
||||||
bordered: true, |
|
||||||
showIndexColumn: false, |
|
||||||
searchInfo: { |
|
||||||
parentId: 0 |
|
||||||
}, |
|
||||||
canResize: false, |
|
||||||
actionColumn: { |
|
||||||
width: 250, |
|
||||||
title: '操作', |
|
||||||
dataIndex: 'action', |
|
||||||
slots: { customRender: 'action' }, |
|
||||||
fixed: false |
|
||||||
}, |
|
||||||
afterFetch: result => listToTree(result, { id: 'areaId' }) |
|
||||||
}) |
|
||||||
|
|
||||||
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
|
||||||
function handleAdd(record?: Recordable) { |
|
||||||
openModal(true, { _tag: 'add', record }) |
|
||||||
} |
|
||||||
|
|
||||||
/** 编辑按钮操作,行内编辑 */ |
|
||||||
function handleEdit(record: Recordable) { |
|
||||||
openModal(true, { _tag: 'edit', record }) |
|
||||||
} |
|
||||||
|
|
||||||
/** 删除按钮操作,行内删除 */ |
|
||||||
async function handleDel(record: Recordable) { |
|
||||||
await delArea(record.areaId) |
|
||||||
createMessage.success('删除成功!') |
|
||||||
handleRefreshTable() |
|
||||||
} |
|
||||||
|
|
||||||
/** 处理表格刷新 */ |
|
||||||
function handleRefreshTable() { |
|
||||||
reload() |
|
||||||
} |
|
||||||
</script> |
|
Loading…
Reference in new issue