123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <template>
- <cl-crud ref="Crud">
- <cl-row>
- <cl-refresh-btn />
- <cl-add-btn />
- <cl-multi-delete-btn />
- <cl-filter label="数据类型">
- <cl-select :options="options.dataType" prop="dataType" :width="120"></cl-select>
- </cl-filter>
- <cl-flex1 />
- <cl-search-key placeholder="搜索名称、keyName" />
- </cl-row>
- <cl-row>
- <cl-table ref="Table" />
- </cl-row>
- <cl-row>
- <cl-flex1 />
- <cl-pagination />
- </cl-row>
- <cl-upsert ref="Upsert" />
- </cl-crud>
- </template>
- <script lang="ts" name="sys-param" setup>
- import { setFocus, useCrud, useTable, useUpsert } from "@cool-vue/crud";
- import { Document } from "@element-plus/icons-vue";
- import { reactive } from "vue";
- import { useCool } from "/@/cool";
- const { service } = useCool();
- // 选项
- const options = reactive({
- dataType: [
- {
- label: "字符串",
- value: 0,
- type: "info"
- },
- {
- label: "富文本",
- value: 1,
- type: "success"
- },
- {
- label: "文件",
- value: 2
- }
- ]
- });
- // cl-crud
- const Crud = useCrud({ service: service.base.sys.param }, (app) => {
- app.refresh();
- });
- // cl-table
- const Table = useTable({
- columns: [
- {
- type: "selection",
- width: 60
- },
- {
- label: "名称",
- prop: "name",
- minWidth: 150
- },
- {
- label: "keyName",
- prop: "keyName",
- minWidth: 150
- },
- {
- label: "数据类型",
- prop: "dataType",
- minWidth: 150,
- dict: options.dataType
- },
- {
- label: "备注",
- prop: "remark",
- minWidth: 200,
- showOverflowTooltip: true
- },
- {
- label: "操作",
- type: "op"
- }
- ]
- });
- // cl-upsert
- const Upsert = useUpsert({
- dialog: {
- width: "1000px"
- },
- items: [
- {
- prop: "name",
- label: "名称",
- span: 12,
- required: true,
- component: {
- name: "el-input"
- }
- },
- {
- prop: "keyName",
- label: "keyName",
- span: 12,
- required: true,
- component: {
- name: "el-input",
- props: {
- placeholder: "请输入Key"
- }
- }
- },
- {
- prop: "dataType",
- label: "类型",
- value: 0,
- required: true,
- component: {
- name: "el-radio-group",
- options: options.dataType
- }
- },
- {
- prop: "data_0",
- label: "数据",
- hidden({ scope }) {
- return scope.dataType != 0;
- },
- required: true,
- component: {
- name: "el-input",
- props: {
- rows: 12,
- type: "textarea"
- }
- }
- },
- {
- prop: "data_1",
- label: "数据",
- hidden({ scope }) {
- return scope.dataType != 1;
- },
- required: true,
- component: {
- name: "cl-editor",
- props: {
- name: "cl-editor-wang"
- }
- }
- },
- {
- prop: "data_2",
- label: "数据",
- required: true,
- hidden({ scope }) {
- return scope.dataType != 2;
- },
- component: {
- name: "cl-upload",
- props: {
- icon: Document,
- multiple: true,
- type: "file"
- }
- }
- },
- {
- prop: "remark",
- label: "备注",
- component: {
- name: "el-input",
- props: {
- placeholder: "请输入备注",
- rows: 3,
- type: "textarea"
- }
- }
- }
- ],
- onOpened(data) {
- data[`data_${data.dataType}`] = data.data;
- },
- onSubmit(data, { next }) {
- next({
- ...data,
- data: data[`data_${data.dataType}`],
- data_0: undefined,
- data_1: undefined,
- data_2: undefined
- });
- },
- plugins: [setFocus()]
- });
- </script>
|