| | |
| | |
|
| | | <script lang="ts">
|
| | | import { defineComponent, reactive } from "vue";
|
| | | import { CrudLoad, Upsert, Table } from "@cool-vue/crud/types";
|
| | | import { CrudLoad, Upsert, Table, RefreshOp } from "@cool-vue/crud/types";
|
| | | import { useCool } from "/@/cool";
|
| | | import { deepTree } from "/@/cool/utils";
|
| | |
|
| | | export default defineComponent({
|
| | | setup() {
|
| | | const { refs, setRefs, service } = useCool();
|
| | | const { refs, setRefs, service, router } = useCool();
|
| | |
|
| | | // 新增、编辑配置
|
| | | const upsert = reactive<Upsert>({
|
| | |
| | | // crud 加载
|
| | | function onLoad({ ctx, app }: CrudLoad) {
|
| | | // 绑定 service
|
| | | ctx.service(service.device.device).done();
|
| | | console.log(service);
|
| | | ctx.service(service.business.basedeviceinfo).done();
|
| | | app.refresh();
|
| | | }
|
| | | // 刷新监听
|
| | | function onRefresh(_: any, { render }: RefreshOp) {
|
| | | console.log("开始执行刷新");
|
| | | service.business.basedeviceinfo.list().then((list: any[]) => {
|
| | | list.map((e) => {
|
| | | e.permList = e.perms ? e.perms.split(",") : [];
|
| | | });
|
| | | console.log("刷新监听内打印");
|
| | |
|
| | | render(deepTree(list), {
|
| | | total: list.length
|
| | | });
|
| | | });
|
| | | }
|
| | | // 刷新
|
| | | function refresh() {
|
| | | console.log("刷新内打印");
|
| | | refs.value.crud.refresh();
|
| | | }
|
| | |
|
| | | // 跳转
|
| | | function toUrl(url: string) {
|
| | | router.push(url);
|
| | | }
|
| | | return {
|
| | | refs,
|
| | | setRefs,
|
| | | onRefresh,
|
| | | refresh,
|
| | | toUrl,
|
| | | upsert,
|
| | | table,
|
| | | onLoad
|