添加代码片段

This commit is contained in:
icssoa 2021-03-29 11:59:09 +08:00
parent db85ae73eb
commit 5b016fe92c

View File

@ -1,9 +1,9 @@
{ {
"cl-crud": { "cl-crud": {
"prefix": "cl-crud", "prefix": "cl-crud-ts",
"body": [ "body": [
"<template>", "<template>",
" <cl-crud ref=\"crud\" @load=\"onLoad\">", " <cl-crud :ref=\"setRefs('crud')\" @load=\"onLoad\">",
" <el-row type=\"flex\" align=\"middle\">", " <el-row type=\"flex\" align=\"middle\">",
" <!-- 刷新按钮 -->", " <!-- 刷新按钮 -->",
" <cl-refresh-btn />", " <cl-refresh-btn />",
@ -18,7 +18,7 @@
"", "",
" <el-row>", " <el-row>",
" <!-- 数据表格 -->", " <!-- 数据表格 -->",
" <cl-table v-bind=\"table\"></cl-table>", " <cl-table :ref=\"setRefs('table')\" v-bind=\"table\"></cl-table>",
" </el-row>", " </el-row>",
"", "",
" <el-row type=\"flex\">", " <el-row type=\"flex\">",
@ -28,31 +28,47 @@
" </el-row>", " </el-row>",
"", "",
" <!-- 新增、编辑 -->", " <!-- 新增、编辑 -->",
" <cl-upsert ref=\"upsert\" v-bind=\"upsert\"></cl-upsert>", " <cl-upsert :ref=\"setRefs('upsert')\" v-bind=\"upsert\"></cl-upsert>",
" </cl-crud>", " </cl-crud>",
"</template>", "</template>",
"", "",
"<script>", "<script lang=\"ts\">",
"export default {", "import { defineComponent, inject, reactive } from \"vue\";",
" data() {", "import { CrudLoad, Upsert, Table } from \"@/crud/types\";",
" return {", "import { useRefs } from \"@/core\";",
"",
"export default defineComponent({",
" setup() {",
" const { refs, setRefs } = useRefs();",
" // 请求服务",
" const service = inject<any>(\"service\");",
"",
" // 新增、编辑配置", " // 新增、编辑配置",
" upsert: {", " const upsert = reactive<Upsert>({",
" items: []", " items: []",
" },", " });",
"",
" // 表格配置", " // 表格配置",
" table: {", " const table = reactive<Table>({",
" columns: []", " columns: []",
" }", " });",
" };", "",
" },", " // crud 加载",
" methods: {", " function onLoad({ ctx, app }: CrudLoad) {",
" onLoad({ ctx, app }) {", " // 绑定 service",
" ctx.service(${1}).done();", " ctx.service(service.xx).done();",
" app.refresh();", " app.refresh();",
" }", " }",
"",
" return {",
" refs,",
" setRefs,",
" upsert,",
" table,",
" onLoad",
" };",
" }", " }",
"};", "});",
"</script>", "</script>",
"" ""
], ],