|
1 | 1 | {
|
2 | 2 | "cl-crud": {
|
3 |
| - "prefix": "cl-crud", |
| 3 | + "prefix": "cl-crud-ts", |
4 | 4 | "body": [
|
5 | 5 | "<template>",
|
6 |
| - " <cl-crud ref=\"crud\" @load=\"onLoad\">", |
| 6 | + " <cl-crud :ref=\"setRefs('crud')\" @load=\"onLoad\">", |
7 | 7 | " <el-row type=\"flex\" align=\"middle\">",
|
8 | 8 | " <!-- 刷新按钮 -->",
|
9 | 9 | " <cl-refresh-btn />",
|
|
18 | 18 | "",
|
19 | 19 | " <el-row>",
|
20 | 20 | " <!-- 数据表格 -->",
|
21 |
| - " <cl-table v-bind=\"table\"></cl-table>", |
| 21 | + " <cl-table :ref=\"setRefs('table')\" v-bind=\"table\"></cl-table>", |
22 | 22 | " </el-row>",
|
23 | 23 | "",
|
24 | 24 | " <el-row type=\"flex\">",
|
|
28 | 28 | " </el-row>",
|
29 | 29 | "",
|
30 | 30 | " <!-- 新增、编辑 -->",
|
31 |
| - " <cl-upsert ref=\"upsert\" v-bind=\"upsert\"></cl-upsert>", |
| 31 | + " <cl-upsert :ref=\"setRefs('upsert')\" v-bind=\"upsert\"></cl-upsert>", |
32 | 32 | " </cl-crud>",
|
33 | 33 | "</template>",
|
34 | 34 | "",
|
35 |
| - "<script>", |
36 |
| - "export default {", |
37 |
| - " data() {", |
38 |
| - " return {", |
39 |
| - " // 新增、编辑配置", |
40 |
| - " upsert: {", |
41 |
| - " items: []", |
42 |
| - " },", |
43 |
| - " // 表格配置", |
44 |
| - " table: {", |
45 |
| - " columns: []", |
46 |
| - " }", |
47 |
| - " };", |
48 |
| - " },", |
49 |
| - " methods: {", |
50 |
| - " onLoad({ ctx, app }) {", |
51 |
| - " ctx.service(${1}).done();", |
| 35 | + "<script lang=\"ts\">", |
| 36 | + "import { defineComponent, inject, reactive } from \"vue\";", |
| 37 | + "import { CrudLoad, Upsert, Table } from \"@/crud/types\";", |
| 38 | + "import { useRefs } from \"@/core\";", |
| 39 | + "", |
| 40 | + "export default defineComponent({", |
| 41 | + " setup() {", |
| 42 | + " const { refs, setRefs } = useRefs();", |
| 43 | + " // 请求服务", |
| 44 | + " const service = inject<any>(\"service\");", |
| 45 | + "", |
| 46 | + " // 新增、编辑配置", |
| 47 | + " const upsert = reactive<Upsert>({", |
| 48 | + " items: []", |
| 49 | + " });", |
| 50 | + "", |
| 51 | + " // 表格配置", |
| 52 | + " const table = reactive<Table>({", |
| 53 | + " columns: []", |
| 54 | + " });", |
| 55 | + "", |
| 56 | + " // crud 加载", |
| 57 | + " function onLoad({ ctx, app }: CrudLoad) {", |
| 58 | + " // 绑定 service", |
| 59 | + " ctx.service(service.xx).done();", |
52 | 60 | " app.refresh();",
|
53 | 61 | " }",
|
| 62 | + "", |
| 63 | + " return {", |
| 64 | + " refs,", |
| 65 | + " setRefs,", |
| 66 | + " upsert,", |
| 67 | + " table,", |
| 68 | + " onLoad", |
| 69 | + " };", |
54 | 70 | " }",
|
55 |
| - "};", |
| 71 | + "});", |
56 | 72 | "</script>",
|
57 | 73 | ""
|
58 | 74 | ],
|
|
0 commit comments