init.json指南

12003

快速开始

jianghu-init JSON以JSON格式高效地管理页面结构和API接口,从而优化开发流程和提升工作效率。本指南主要介绍jianghu-init JSON的详细教程。

安装

在开始之前,请确保您已经安装了jianghu-init工具。可以通过以下命令进行安装:

  1. npm uninstall -g @jianghujs/jianghu-init
  2. # 最新版本 3.2.5
  3. npm install -g @jianghujs/jianghu-init@latest

👉 jianghu-init 工具安装详解👈

在江湖项目中生成参考示例

  • 首先,进入已有的江湖JS项目目录

👉 创建jianghujs项目 👈

  • 使用以下命令生成参考示例:
  1. cd my-jh-project
  2. jianghu-init json --generateType=example

执行以上命令,当前项目数据库将添加 example_class 和 example_student 数据表、并在项目目录生成以下文件:

  • app\view\init-json\component\exampleStudentOfClass.js
  • app\view\init-json\page\exampleClass.js
  • app\view\component\example\exampleStudentOfClass.html
  • app\view\page\exampleClass.html

方便参考使用

步骤一:数据表生成配置文件

当有一个新的业务数据表之后,可以使用以下命令生成数据表的配置文件,例如,现在有一个名为class的数据表:

  1. CREATE TABLE `class` (
  2. `id` int(11) NOT NULL AUTO_INCREMENT,
  3. `classId` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '班级ID',
  4. `className` varchar(255) DEFAULT NULL,
  5. `operation` varchar(255) COLLATE utf8mb4_bin DEFAULT 'insert' COMMENT '操作; insert, update, jhInsert, jhUpdate, jhDelete jhRestore',
  6. `operationByUserId` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '操作者userId',
  7. `operationByUser` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '操作者用户名',
  8. `operationAt` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '操作时间; E.g: 2021-05-28T10:24:54+08:00 ',
  9. PRIMARY KEY (`id`)
  10. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

要为class数据表生成基础配置文件,可以使用以下命令:

  1. jianghu-init json --generateType=json --pageType=jh-page --table=class --pageId=classManagement

执行命令之后,会在项目的app/view/init-json/page/目录下生成一个名为classManagement.js的配置文件。

步骤二:配置文件生成页面

上一步生成的配置文件,需要通过以下命令生成页面:

  1. jianghu-init json --generateType=page --pageType=page --file=classManagement

执行以上命令,将会生成项目的app/view/page/目录下生成一个名为classManagement.html的页面文件,并自动配置页面对应的数据库表_page和_resouce的数据。

👉 开启dev模式,修改配置文件自动更新页面 👈

👉 配置字符串代码语法高亮 👈

配置协议

结构总览

  1. {
  2. pageType: "jh-page", // 页面类型,可选值为jh-page、jh-mobile-page、jh-component选
  3. pageId: "pageId", // 页面唯一标识
  4. pageName: "班级页面", // 页面标题
  5. template: "jhTemplateV4", // 页面模板,默认为jhTemplateV4,手机端一般设置为jhMobileTemplateV4
  6. version: 'v3', // 版本 空 或者 v2
  7. resourceList: [],// 页面resource { actionId, resourceType, resourceData }
  8. headContent: [], // 页面头部,常用于配置 标题、面包屑条、服务端搜索、场景搜索等
  9. pageContent: [], // 页面内容区域
  10. actionContent: [], // 触发内容集合,一般会放新增、修改等弹框
  11. includeList: [], // 页面引入资源 { type, path }
  12. common: { // vue 原生变量 + uiAction {data, props, watch, methods, computed}
  13. data: {},
  14. computed: {},
  15. watch: {},
  16. methods: {},
  17. doUiAction: {}, // 自定义uiAction { [key]: [method1, method2, doUiAction1]}
  18. },
  19. style: '', // 自定义样式
  20. }
属性 类型 必填 描述
pageType string 页面类型,可选值为jh-page、jh-mobile-page、jh-component、
pageId string 页面唯一标识
template string 模版
version string 版本 (目前支持设定v2、v3)
resourceList array
headContent array 面包屑
pageContent array 页面主体内容
actionContent array 触发内容(抽屉、弹窗、遮罩层等)
includeList array 页面引入资源 { type, path }
common object 变量、方法
style string

HTML标签

在 headContent、pageCotent、actionContent 中,可以使用使用指定的对象结构来配置一个标签,也支持直接使用HTML字符串。

对象结构

  1. pageContent: [
  2. {
  3. tag: 'v-row',
  4. attrs: {
  5. align: "center"
  6. "@click": "doUiAction('updateItem')"
  7. },
  8. quickAttrs: ['no-gutters'],
  9. value: [
  10. { tag: 'v-col', attrs: { cols: 12 }, value: '' },
  11. /*html*/`<v-col cols="12"></v-col>`
  12. ]
  13. }
  14. ]
属性 类型 必填 描述
tag string 标签名称
attr object 标签属性,如class、@click等
quickAttrs array 标签简洁属性,如 v-else small disabled等
value object 标签内的HTML内容

HTML字符串

  1. pageContent: [
  2. `<v-row align="center"><v-col cols="12"></v-col></v-row>`
  3. ]

接口配置

配置江湖resource,定义的resouce将自动更新到数据库中,供前端调用。

  1. resourceList: [
  2. {
  3. resourceHook: { "before": [], "after": [] }, // 无需设置时可省略
  4. actionId: 'balance-updateItem',
  5. desc: '修改班费余额',
  6. resourceType: 'sql',
  7. resourceData: { "table": "class", "operation": "update" }
  8. }
  9. ]

👉 resouce详细配置文档 👈

资源引入

当页面需要引入组件、样式、脚本等资源时,可以通过includeList配置。支持对象结构和HTML字符串。

  1. includeList: [
  2. { type: 'css', path: "/<$ ctx.app.config.appId $>/public/lib/echarts.min.css" },
  3. { type: 'script', path: "/<$ ctx.app.config.appId $>/public/lib/echarts.min.js" },
  4. { type: 'html', path: "component/exampleChart/lineChart.html" },
  5. { type: 'html', path: 'component/courseBatchDrawer.html', includeType: 'auto', attrs: { id: 'courseBatchDrawer' } },
  6. { type: 'vueComponent', name: 'v-chart', component: 'VueCharts' },
  7. `<script src="/<$ ctx.app.config.appId $>/public/lib/echarts.min.js"></script>`
  8. ]
属性 类型 必填 描述
type string 引入类型,可选 css、js、html、vueComponent
path string 引入路径,type为css、js、html时可用
includeType string 引入类型,可选 auto,当值为auto时将自动添加标签内容添加到页面末端。type为css、js、html时可用
attrs object 自定引入标签属性。type为html、includeType为auto时可用
name string 组件名,type为vueComponent时可用
component string 引入组件,type为vueComponent时可用

配置doUiAction

提供补充doUiAction方法的配置入口

  1. pageContent: [
  2. {
  3. tag: 'v-btn',
  4. value: '测试doUiAction1',
  5. attrs: { '@click': 'doUiAction("doSomething")' },
  6. quickAttrs: ['small']
  7. },
  8. `<v-btn @click="doUiAction('doSomething')">测试doUiAction2</v-btn>`
  9. ],
  10. common: {
  11. doUiAction: {
  12. startUpdataBalance: ['async.method1', 'method2'],
  13. doSomething: ['method3(134)', 'doUiAction.startUpdataBalance']
  14. },
  15. methods: {
  16. async method1 (id) {
  17. console.log('method1', id)
  18. },
  19. async method2 () {
  20. console.log('method2')
  21. },
  22. async method3(actionData) {
  23. console.log('method3')
  24. }
  25. }
  26. }
  • 默认方法链使用 await 同步执行,可添加 async. 进行异步修饰 例:
  1. doUiAction: {
  2. startUpdataBalance: ['async.method1', 'method2'],
  3. },
  4. // 实际执行
  5. case 'startUpdataBalance':
  6. this.method1(uiActionData);
  7. await this.method2(uiActionData);
  8. break;
  • 默认方法链使用方法执行,可添加 doUiAction. 进行包含流程 例:
  1. doUiAction: {
  2. doSomething: ['method3(134)', 'doUiAction.startUpdataBalance'],
  3. doSomething2: ['method3(134)', 'async.doUiAction.startUpdataBalance']
  4. },
  5. // 实际执行
  6. case 'doSomething':
  7. await this.method3(uiActionData);
  8. await this.doUiAction('startUpdataBalance', uiActionData);
  9. break;
  10. case 'doSomething2':
  11. await this.method3(uiActionData);
  12. this.doUiAction('startUpdataBalance', uiActionData);
  13. break;

调用链中支持配置方法名、方法名+参数、doUiAction方法名。

配置示例-PC端

基础页面

  1. const content = {
  2. pageType: "jh-page", pageId: "classManagement", pageName: "classManagement页面", template: 'jhTemplateV4', version: 'v3',
  3. resourceList: [
  4. {
  5. actionId: "selectItemList",
  6. resourceType: "sql",
  7. desc: "✅查询列表-classManagement",
  8. resourceData: { table: "class", operation: "select" }
  9. },
  10. // ... insertItem/updateItem/deleteItem
  11. ], // { actionId: '', resourceType: '', resourceData: {}, resourceHook: {}, desc: '' }
  12. headContent: [
  13. { tag: 'jh-page-title', value: "classManagement", attrs: { cols: 12, sm: 6, md:4 }, helpBtn: true, slot: [] },
  14. { tag: 'v-spacer' },
  15. {
  16. tag: 'jh-search',
  17. attrs: { cols: 12, sm: 6, md:8 },
  18. searchBtn: true,
  19. value: [
  20. { tag: "v-text-field", model: "serverSearchWhereLike.className", attrs: {prefix: '前缀'} },
  21. ],
  22. // v3 版本新增特性
  23. data: {
  24. serverSearchWhereLike: { name: '' },
  25. serverSearchWhere: { semester: '', segment: '小学' },
  26. }
  27. }
  28. ],
  29. pageContent: [
  30. {
  31. tag: 'jh-table',
  32. attrs: { },
  33. colAttrs: { clos: 12 },
  34. cardAttrs: { class: 'rounded-lg elevation-0' },
  35. headActionList: [
  36. { tag: 'v-btn', value: '新增', attrs: { color: 'success', class: 'mr-2', '@click': 'doUiAction("startCreateItem")', small: true } },
  37. { tag: 'v-spacer' },
  38. // 默认筛选
  39. {
  40. tag: 'v-col',
  41. attrs: { cols: '12', sm: '6', md: '3', xs: 8, class: 'pa-0' },
  42. value: [
  43. { tag: 'v-text-field', attrs: {prefix: '筛选', 'v-model': 'searchInput', class: 'jh-v-input', ':dense': true, ':filled': true, ':single-line': true} },
  44. ],
  45. }
  46. ],
  47. headers: [
  48. { text: "id", value: "id", width: 80, sortable: true, class: "fixed", cellClass: "fixed" },
  49. { text: "班级ID", value: "classId", width: 80, sortable: true },
  50. { text: "className", value: "className", width: 80, sortable: true },
  51. { text: "操作", value: "operation", width: 80, sortable: true },
  52. { text: "操作者userId", value: "operationByUserId", width: 80, sortable: true },
  53. { text: "操作者用户名", value: "operationByUser", width: 80, sortable: true },
  54. { text: "操作时间", value: "operationAt", width: 80, sortable: true },
  55. { text: "操作", value: "action", type: "action", width: 'window.innerWidth < 500 ? 70 : 120', align: "center", class: "fixed", cellClass: "fixed" },
  56. // width 表达式需要使用字符串包裹
  57. ],
  58. value: [
  59. // vuetify table custom slot
  60. ],
  61. rowActionList: [
  62. { text: '编辑', icon: 'mdi-note-edit-outline', color: 'success', click: 'doUiAction("startUpdateItem", item)' }, // 简写支持 pc 和 移动端折叠
  63. { text: '删除', icon: 'mdi-trash-can-outline', color: 'error', click: 'doUiAction("deleteItem", item)' } // 简写支持 pc 和 移动端折叠
  64. ],
  65. }
  66. ],
  67. actionContent: [
  68. {
  69. tag: 'jh-create-drawer',
  70. key: "create",
  71. attrs: {},
  72. title: '新增',
  73. headSlot: [
  74. { tag: 'v-spacer'}
  75. ],
  76. contentList: [
  77. {
  78. label: "新增",
  79. type: "form",
  80. formItemList: [
  81. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  82. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  83. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  84. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  85. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  86. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  87. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  88. ],
  89. action: [{
  90. tag: "v-btn",
  91. value: "新增",
  92. attrs: {
  93. color: "success",
  94. ':small': true,
  95. '@click': "doUiAction('createItem')"
  96. }
  97. }],
  98. },
  99. ]
  100. },
  101. {
  102. tag: 'jh-update-drawer',
  103. key: "update",
  104. attrs: {},
  105. title: '编辑',
  106. headSlot: [
  107. { tag: 'v-spacer'}
  108. ],
  109. contentList: [
  110. {
  111. label: "编辑",
  112. type: "form",
  113. formItemList: [
  114. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  115. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  116. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  117. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  118. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  119. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  120. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  121. ],
  122. action: [{
  123. tag: "v-btn",
  124. value: "编辑",
  125. attrs: {
  126. color: "success",
  127. ':small': true,
  128. '@click': "doUiAction('updateItem')"
  129. }
  130. }],
  131. },
  132. { label: "操作记录", type: "component", componentPath: "recordHistory", attrs: { table: 'class', pageId: 'classManagement', ':id': 'updateItem.id' } },
  133. ]
  134. },
  135. ],
  136. includeList: [], // { type: < js | css | html | vueComponent >, path: ''}
  137. common: {
  138. data: {
  139. constantObj: {},
  140. validationRules: {
  141. requireRules: [
  142. v => !!v || '必填',
  143. ],
  144. },
  145. serverSearchWhereLike: { className: '' }, // 服务端like查询
  146. serverSearchWhere: { }, // 服务端查询
  147. serverSearchWhereIn: { }, // 服务端 in 查询
  148. filterMap: {}, // 结果筛选条件
  149. },
  150. dataExpression: {
  151. isMobile: 'window.innerWidth < 500'
  152. }, // data 表达式
  153. watch: {},
  154. computed: {
  155. tableDataComputed() {
  156. if(this.filterMap) {
  157. return this.tableData.filter(row => {
  158. for (const key in this.filterMap) {
  159. if (this.filterMap[key] && row[key] !== this.filterMap[key]) {
  160. return false;
  161. }
  162. }
  163. return true;
  164. });
  165. } else {
  166. return this.tableData;
  167. }
  168. },
  169. },
  170. doUiAction: {}, // 额外uiAction { [key]: [action1, action2]}
  171. methods: {}
  172. },
  173. };
  174. module.exports = content;

标题-只有页面标题

  1. headContent: [
  2. { tag: 'jh-page-title', value: "classManagement", attrs: { cols: 12, sm: 6, md:4 }, helpBtn: true, slot: [] }
  3. ]

标题-服务端搜索

  1. headContent: [
  2. { tag: 'jh-page-title', value: "classManagement", attrs: { cols: 12, sm: 6, md:4 }, helpBtn: true, slot: [] },
  3. { tag: 'v-spacer' },
  4. {
  5. tag: 'jh-search',
  6. attrs: { cols: 12, sm: 6, md:8 },
  7. value: [
  8. { tag: "v-text-field", model: "serverSearchWhereLike.className", attrs: {prefix: '前缀'} },
  9. ],
  10. searchBtn: true,
  11. data: {
  12. serverSearchWhereLike: { name: '' },
  13. }
  14. }
  15. ]

标题-场景搜索

  1. headContent: [
  2. { tag: 'jh-page-title', value: "classManagement", attrs: { cols: 12, sm: 6, md:4 }, helpBtn: true, slot: [] },
  3. { tag: 'v-spacer' },
  4. {
  5. tag: 'jh-scene',
  6. attrs: { ':showActionBtn': false, ':mobile': true },
  7. // v3 版本新增特性
  8. data: {
  9. sceneCreateForm: {}, // 默认创建表单
  10. serverSceneSearchWhere: {}, // 可预设变量或忽略
  11. serverSceneSearchWhereIn: {},
  12. serverSceneSearchWhereLike: {},
  13. serverSceneSearchWhereOptions: [],
  14. serverSceneSearchWhereOrOptions: [],
  15. currentSceneId: '全部', // 当前场景默认name
  16. defaultSceneList: [
  17. { name: "全部", where: {} },
  18. { name: "无跟进人", where: { "gender": "male"}, whereIn: { level: ['01', '02'] } },
  19. ],
  20. customSceneList: [
  21. { label: '年级', tag: 'v-select', model: 'form.level', attrs: {":items": 'constantObj.level'} },
  22. { label: '性别', tag: 'v-select', model: 'form.grade', attrs: {":items": 'constantObj.grade'} },
  23. ],
  24. maxSceneDisplay: 2,
  25. }
  26. },
  27. ],

内容-数据表格

  1. pageContent: [
  2. {
  3. tag: 'jh-table',
  4. props: {
  5. serverPagination: true // 开启服务端分页、服务端分页默认 limit 50
  6. },
  7. attrs: {},
  8. colAttrs: { clos: 12 },
  9. cardAttrs: { class: 'rounded-lg elevation-0' },
  10. headActionList: [
  11. { tag: 'v-btn', value: '新增', attrs: { color: 'success', class: 'mr-2', '@click': 'doUiAction("startCreateItem")', small: true } },
  12. { tag: 'v-spacer' }
  13. ],
  14. headers: [
  15. { text: "id", value: "id", width: 80, sortable: true, class: "fixed", cellClass: "fixed" },
  16. { text: "班级ID", value: "classId", width: 80, sortable: true },
  17. { text: "className", value: "className", width: 80, sortable: true },
  18. { text: "操作", value: "operation", width: 80, sortable: true },
  19. { text: "操作", value: "action", type: "action", width: 'window.innerWidth < 500 ? 70 : 120', align: "center", class: "fixed", cellClass: "fixed" },
  20. ],
  21. value: [
  22. // v-table插槽
  23. // { tag: 'template', attrs: {'slot': 'body', 'slot-scope': "item"}, value: "<div>测试插槽</div>" },
  24. // { tag: 'template', attrs: {'slot': 'item.className', 'slot-scope': "{item, index}"}, value: "<div>{{item.className}}</div>" },
  25. ],
  26. rowActionList: [
  27. { text: '编辑', icon: 'mdi-note-edit-outline', color: 'success', click: 'doUiAction("startUpdateItem", item)' }, // 简写支持 pc 和 移动端折叠
  28. { text: '删除', icon: 'mdi-trash-can-outline', color: 'error', click: 'doUiAction("deleteItem", item)' } // 简写支持 pc 和 移动端折叠
  29. ],
  30. }
  31. ]

内容-数据表格(启用列设置)

常用

  1. pageContent: [
  2. {
  3. tag: 'jh-table',
  4. attrs: {}, // v-data-table attrs
  5. colAttrs: {}, // v-data-table 父元素 v-col attrs
  6. cardAttrs: {}, // v-data-table 父元素 v-card attrs
  7. headers: [], // v-data-table headers
  8. value: [],
  9. showTableColumnSettingBtn: true,
  10. headActionList: [], // 表格上方 v-col 插槽
  11. rowActionList: [], // 表格操作列操作按钮列表
  12. }
  13. ],

模式设定

  1. pageContent: [
  2. {
  3. tag: 'jh-table',
  4. attrs: {},
  5. value: [],
  6. showTableColumnSettingBtn: true,
  7. headActionList: [],
  8. rowActionList: [],
  9. }
  10. ],
  11. common: {
  12. data: {
  13. columnSettingGroup: {
  14. '01模式': [
  15. "netName",
  16. "stage",
  17. "followUpDate",
  18. "district",
  19. "memberId",
  20. "followUpBy",
  21. "currentResidence",
  22. "openVisitationStatus",
  23. "totalVisitationCount",
  24. "visitorAssignInfo",
  25. "operationAt",
  26. "action"
  27. ],
  28. '02模式': [
  29. "netName",
  30. "stage",
  31. "duoxingRoomName",
  32. "followUpDate",
  33. "tag",
  34. "projectList",
  35. "followUpBy",
  36. "district",
  37. "memberId",
  38. "currentResidence",
  39. "operationAt",
  40. "action"
  41. ],
  42. '03模式': [
  43. "netName",
  44. "orgId",
  45. "orgName",
  46. "roleId",
  47. "isDefaultOrg"
  48. ],
  49. },
  50. }
  51. }
属性 类型 必填 描述
showTableColumnSettingBtn boolean 是否启用列设置,默认false

弹框-新增编辑表单

  1. actionContent: [
  2. {
  3. tag: 'jh-create-drawer',
  4. key: "create",
  5. attrs: {},
  6. title: '新增',
  7. headSlot: [
  8. { tag: 'v-spacer'}
  9. ],
  10. contentList: [
  11. {
  12. label: "新增",
  13. type: "form",
  14. formItemList: [
  15. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  16. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  17. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  18. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  19. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  20. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  21. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  22. ],
  23. action: [{
  24. tag: "v-btn",
  25. value: "新增",
  26. attrs: {
  27. color: "success",
  28. '@click': "doUiAction('createItem')"
  29. },
  30. quickAttrs: ['small']
  31. }],
  32. },
  33. ]
  34. },
  35. {
  36. tag: 'jh-update-drawer',
  37. key: "update",
  38. props: {
  39. mergeForm: true // prepareFormData 将会合并对象表单
  40. },
  41. attrs: {},
  42. title: '编辑',
  43. headSlot: [
  44. { tag: 'v-spacer'}
  45. ],
  46. contentList: [
  47. {
  48. label: "编辑",
  49. type: "form",
  50. formItemList: [
  51. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  52. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  53. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  54. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  55. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  56. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  57. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  58. ],
  59. action: [{
  60. tag: "v-btn",
  61. value: "编辑",
  62. attrs: {
  63. color: "success",
  64. '@click': "doUiAction('updateItem')"
  65. },
  66. quickAttrs: ['small']
  67. }],
  68. },
  69. { label: "操作记录", type: "component", componentPath: "recordHistory", attrs: { table: 'class', pageId: 'classManagement', ':id': 'updateItem.id' } },
  70. ]
  71. },
  72. ]

弹框-详情

  1. pageContent: [
  2. `<v-btn @click="openTestDetailDrawer">打开测试详情弹框</v-btn>`,
  3. ],
  4. actionContent: [
  5. {
  6. tag: 'jh-drawer',
  7. key: "testDetail",
  8. attrs: {},
  9. title: '测试详情',
  10. contentList: [
  11. {
  12. type: "form",
  13. formItemList: [
  14. { tag: 'span', value: '课程信息', md: 12, attrs: {class: 'title pl-2'}},
  15. { tag: 'div', md: 12, value: [/*html*/ `
  16. <div class="grey lighten-5">
  17. <v-row class="ma-0 pa-2">
  18. <v-col cols="12" md="3" v-for="(item, index) in courseInfoItems" :key="index">
  19. <span>{{item.title}}:{{item.value}}</span>
  20. </v-col>
  21. </v-row>
  22. </div>
  23. `]
  24. }
  25. ]
  26. }
  27. ]
  28. }
  29. ],
  30. "common": {
  31. data: {
  32. courseInfoItems: [
  33. { title: '课程名称', value: 'IT初级课程' }
  34. ]
  35. }
  36. }

弹框-自定义弹框

  1. pageContent: [
  2. `<v-btn @click="openTestCustomDrawer">打开测试自定义弹框</v-btn>`,
  3. ],
  4. actionContent: [
  5. {
  6. tag: 'jh-drawer',
  7. key: "testCustom",
  8. attrs: {},
  9. title: '测试自定义弹框',
  10. contentList: [
  11. `自定义内容`
  12. ]
  13. }
  14. ]

弹框-多标签

  1. pageContent: [
  2. `<v-btn @click="openTestMultiTabDrawer">打开测试多标签弹框</v-btn>`,
  3. ],
  4. actionContent: [
  5. {
  6. tag: 'jh-drawer',
  7. key: "testMultiTab",
  8. attrs: {},
  9. title: '测试多标签',
  10. contentList: [
  11. { label: "操作记录", type: "component", componentPath: "recordHistory" },
  12. { label: "学生列表", type: "component", componentPath: "example/studentOfClass", bind: ['classId'] },
  13. ]
  14. }
  15. ]

弹框-自定义按钮

  1. pageContent: [
  2. `<v-btn @click="viewTestCustomBtn">打开测试自定义按钮弹框</v-btn>`
  3. ],
  4. actionContent: [
  5. {
  6. tag: 'jh-create-drawer',
  7. key: "testCustomBtn",
  8. attrs: {},
  9. title: '测试自定义按钮',
  10. headSlot: [
  11. { tag: 'v-spacer' },
  12. { tag: 'v-btn', value: '自定义按钮', attrs: { color: 'success', class: 'mr-2', '@click': 'doUiAction("123")', small: true } },
  13. ],
  14. contentList: [ /* 内容列表 */ ]
  15. }
  16. ]

弹框-关闭弹框检查

  1. actionContent: [
  2. {
  3. tag: 'jh-create-drawer',
  4. key: "create",
  5. attrs: {},
  6. title: '新增',
  7. isCheckFormBeforeClose: true,
  8. onCheckFormConfirm: 'doUiAction("createItem", { notConfirmed: true })',
  9. headSlot: [
  10. { tag: 'v-spacer'}
  11. ],
  12. contentList: [
  13. {
  14. label: "新增",
  15. type: "form",
  16. formItemList: [
  17. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  18. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  19. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  20. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  21. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  22. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  23. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  24. ],
  25. action: [{
  26. tag: "v-btn",
  27. value: "新增",
  28. attrs: {
  29. color: "success",
  30. ':small': true,
  31. '@click': "doUiAction('createItem')"
  32. }
  33. }],
  34. },
  35. ]
  36. }
  37. ]
属性 类型 必填 描述
key string form标识,如:create、update 等
title string 抽屉标题
props.mergeForm boolean 是否合并提交form
attrs object v-navigation-drawer 属性
isCheckFormBeforeClose boolean 是否打开关闭弹框检查,默认false,注意检查的表单对象与弹框的key需要保持匹配,如 表单对象:createItem,弹框key:create
onCheckFormConfirm string 保存内容方法名称
contentList array 抽屉内容

配置示例-移动端

基础页面

  1. const content = {
  2. pageType: "jh-mobile-page", pageId: "mobile/classManagement", pageName: "classManagement页面", template: "jhMobileTemplateV4", version: 'v2',
  3. resourceList: [
  4. {
  5. actionId: "selectItemList",
  6. resourceType: "sql",
  7. desc: "✅查询列表-classManagement",
  8. resourceData: { table: "class", operation: "select" }
  9. },
  10. // ... insertItem/updateItem/deleteItem
  11. ], // { actionId: '', resourceType: '', resourceData: {}, resourceHook: {}, desc: '' }
  12. headContent: [
  13. { tag: 'jh-page-title', value: "班级管理", helpBtn: true, slot: [] },
  14. {
  15. tag: 'jh-order',
  16. // v3 新特性
  17. data: {
  18. tableDataOrder: [ { column: "createAt", order: "desc" } ],
  19. tableDataOrderList: [
  20. { text: "报名时间↓", value: [ { column: "createAt", order: "desc" } ] },
  21. { text: "成绩分数↓", value: [ { column: "middleSchoolExamScore", order: "desc" } ] },
  22. { text: "更新时间↓", value: [ { column: "operationAt", order: "desc" } ] },
  23. ],
  24. }
  25. },
  26. {
  27. tag: 'jh-search',
  28. searchList: [
  29. { tag: 'v-select', model: "serverSearchWhere.semester", colAttrs: { class: 'pb-0' }, attrs: { prefix: '学期:', color: 'success', ':items': 'constantObj.semester' } },
  30. { tag: 'v-select', model: "serverSearchWhere.segment", colAttrs: { class: 'pb-0' }, attrs: { prefix: '学部:', color: 'success', ':items': 'constantObj.segment' } },
  31. { tag: 'v-text-field', model: "serverSearchWhereLike.name", colAttrs: { class: 'pb-0' }, attrs: { label: '学生名字:', color: 'success' }, quickAttrs: ['clearable'] },
  32. ],
  33. data: {
  34. serverSearchWhere: { semester: '', segment: '小学' },
  35. serverSearchWhereLike: { name: '' },
  36. }
  37. },
  38. { tag: 'v-spacer'},
  39. { tag: 'jh-mode', data: { viewMode: 'simple' } },
  40. ],
  41. pageContent: [
  42. {
  43. tag: 'jh-list',
  44. props: {
  45. limit: 10,
  46. rightArrowText: '',
  47. },
  48. attrs: { cols: 12, class: 'p-0 pb-7', ':style': '`height: calc(100vh - 140px); overflow-y: auto;overscroll-behavior: contain`' },
  49. headers: [
  50. {text: "学生Id", value: "studentId", width: 80, isSimpleMode: true},
  51. {text: "姓名", value: "name", width: 90, isTitle: true, slot: [`
  52. <div v-if="item.isMonitor" class="ml-1">
  53. <v-icon color="warning" small>mdi-shield-star</v-icon>
  54. <span>干部</span>
  55. </div>
  56. `]},
  57. {text: "性别", value: "gender", width: 60, isSimpleMode: true},
  58. {text: "学生状态", value: "studentStatus", width: 80},
  59. {text: "年级", value: "level", width: 70},
  60. {text: "入学-推荐人", value: "recommendBy", width: 100, isDetailMode: true},
  61. {text: "入学-跟进人", value: "followUpByUserName", width: 100, isDetailMode: true},
  62. {text: "跟进阶段", value: "followUpStage", width: 80},
  63. {text: "报名时间", value: "createAt", width: 150},
  64. {text: "操作者", value: "operationByUser", width: 90},
  65. {text: "操作时间", value: "operationAt", width: 150},
  66. {text: '操作', value: 'action', align: 'center', sortable: false, width: 'window.innerWidth < 500 ? 90: 180', class: 'fixed', cellClass: 'fixed'},
  67. ],
  68. rowActionList: [
  69. { text: "编辑", icon: 'mdi-note-edit-outline', color: 'success', click: 'doUiAction("startUpdateItem", item)' }
  70. ],
  71. },
  72. {
  73. tag: 'jh-action',
  74. attrs: { class: 'h-16 w-16 p-2 fixed right-4 bottom-32' },
  75. actionList: [
  76. { tag: 'v-btn', value: '新增', icon: 'mdi-plus', color: 'success', click: "doUiAction('startCreateItem')" },
  77. { tag: 'v-btn', value: '随机分配跟进人', icon: 'mdi-plus', color: 'success', click: "doUiAction('randomFollowUp')", ':disabled': '!tableSelected.length' },
  78. ]
  79. }
  80. ],
  81. actionContent: [
  82. {
  83. tag: 'jh-create-drawer',
  84. key: "create",
  85. attrs: {},
  86. title: '新增',
  87. headSlot: [
  88. { tag: 'v-spacer'}
  89. ],
  90. contentList: [
  91. {
  92. label: "新增",
  93. type: "form",
  94. formItemList: [
  95. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  96. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  97. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  98. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  99. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  100. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  101. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  102. ],
  103. action: [{
  104. tag: "v-btn",
  105. value: "新增",
  106. attrs: {
  107. color: "success",
  108. ':small': true,
  109. '@click': "doUiAction('createItem')"
  110. }
  111. }],
  112. },
  113. ]
  114. },
  115. {
  116. tag: 'jh-update-drawer',
  117. key: "update",
  118. attrs: {},
  119. title: '编辑',
  120. headSlot: [
  121. { tag: 'v-spacer'}
  122. ],
  123. contentList: [
  124. {
  125. label: "编辑",
  126. type: "form",
  127. formItemList: [
  128. { label: "id", model: "id", tag: "v-text-field", rules: "validationRules.requireRules", },
  129. { label: "班级ID", model: "classId", tag: "v-text-field", rules: "validationRules.requireRules", },
  130. { label: "className", model: "className", tag: "v-text-field", rules: "validationRules.requireRules", },
  131. { label: "操作", model: "operation", tag: "v-text-field", rules: "validationRules.requireRules", },
  132. { label: "操作者userId", model: "operationByUserId", tag: "v-text-field", rules: "validationRules.requireRules", },
  133. { label: "操作者用户名", model: "operationByUser", tag: "v-text-field", rules: "validationRules.requireRules", },
  134. { label: "操作时间", model: "operationAt", tag: "v-text-field", rules: "validationRules.requireRules", },
  135. ],
  136. action: [{
  137. tag: "v-btn",
  138. value: "编辑",
  139. attrs: {
  140. color: "success",
  141. ':small': true,
  142. '@click': "doUiAction('updateItem')"
  143. }
  144. }],
  145. },
  146. { label: "操作记录", type: "component", componentPath: "recordHistory", attrs: { table: 'class', pageId: 'classManagement', ':id': 'updateItem.id' } },
  147. ]
  148. },
  149. {
  150. tag: 'jh-detail-drawer',
  151. key: "detail",
  152. attrs: {},
  153. title: "详情",
  154. headSlot: [
  155. ],
  156. card: {
  157. tag: 'div',
  158. colAttrs: { class: 'pa-0' },
  159. value: `
  160. <div class="p-3 border-b" >
  161. <div class="flex justify-between mb-2 items-center">
  162. <div>
  163. <span class="font-weight-bold text-base">{{ detailItem.name }}</span>
  164. </div>
  165. <span :class="'text-sm '">{{ detailItem.followUpStatus }}</span>
  166. </div>
  167. <div class="text-gray-500 flex justify-between">意向就读学部:{{ detailItem.segment }}</div>
  168. <div class="text-gray-500 flex justify-between">报名日期:{{ detailItem.createAt }}</div>
  169. </div>
  170. <div class="pa-0 h-2 bg-gray-100" ></div>
  171. `
  172. },
  173. contentList: [
  174. {
  175. type: 'preview',
  176. md: 12,
  177. formItemList: [
  178. { label: "性别", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.gender }}" },
  179. { label: "身份证件号", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.icNumber }}" },
  180. { label: "家庭住址", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.residentialAddress }}" },
  181. { label: "意向就读学部", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.segment }}" },
  182. { label: "意向就读年级", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.level }}" },
  183. { label: "意向就读方式", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.afterSchoolCareType }}" },
  184. { label: "原就读学校", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.schoolRoll }}" },
  185. { label: "中考分数", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.middleSchoolExamScore }}" },
  186. { label: "中考报名序号", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.middleSchoolExamSequence }}" }
  187. ],
  188. action: [
  189. {
  190. tag: 'v-btn',
  191. value: "编辑",
  192. attrs: {
  193. color: 'primary',
  194. '@click': "doUiAction('startUpdateItem', detailItem); closeDetailDrawer()"
  195. },
  196. quickAttrs: ['small']
  197. }
  198. ]
  199. }
  200. ]
  201. },
  202. ],
  203. includeList: [], // { type: < js | css | html | vueComponent >, path: ''}
  204. common: {
  205. data: {
  206. constantObj: {
  207. },
  208. validationRules: {
  209. requireRules: [
  210. v => !!v || '必填',
  211. ],
  212. },
  213. filterMap: {}, // 结果筛选条件
  214. },
  215. dataExpression: {
  216. isMobile: 'window.innerWidth < 500'
  217. }, // data 表达式
  218. watch: {},
  219. computed: {
  220. tableDataComputed() {
  221. if(this.filterMap) {
  222. return this.tableData.filter(row => {
  223. for (const key in this.filterMap) {
  224. if (this.filterMap[key] && row[key] !== this.filterMap[key]) {
  225. return false;
  226. }
  227. }
  228. return true;
  229. });
  230. } else {
  231. return this.tableData;
  232. }
  233. },
  234. },
  235. doUiAction: {}, // 额外uiAction { [key]: [action1, action2]}
  236. async created() {
  237. await this.doUiAction('getTableData');
  238. },
  239. methods: {}
  240. },
  241. };
  242. module.exports = content;

标题-只有页面标题

  1. headContent: [
  2. { tag: 'jh-page-title', value: "班级管理" },
  3. ],

标题-排序&筛选&模式切换

  1. headContent: [
  2. { tag: 'jh-page-title', value: "班级管理" },
  3. {
  4. tag: 'jh-order',
  5. data: {
  6. tableDataOrder: [ { column: "createAt", order: "desc" } ],
  7. tableDataOrderList: [
  8. { text: "报名时间↓", value: [ { column: "createAt", order: "desc" } ] },
  9. { text: "成绩分数↓", value: [ { column: "middleSchoolExamScore", order: "desc" } ] },
  10. { text: "更新时间↓", value: [ { column: "operationAt", order: "desc" } ] },
  11. ],
  12. }
  13. }, // 固定变量 model: 'tableDataOrder', items: 'tableDataOrderList'
  14. {
  15. tag: 'jh-search',
  16. searchList: [
  17. { tag: 'v-select', model: "serverSearchWhere.semester", colAttrs: { class: 'pb-0' }, attrs: { prefix: '学期:', color: 'success', ':items': 'constantObj.semester' } },
  18. { tag: 'v-select', model: "serverSearchWhere.segment", colAttrs: { class: 'pb-0' }, attrs: { prefix: '学部:', color: 'success', ':items': 'constantObj.segment' } },
  19. { tag: 'v-text-field', model: "serverSearchWhereLike.name", colAttrs: { class: 'pb-0' }, attrs: { label: '学生名字:', color: 'success' }, quickAttrs: ['clearable'] },
  20. ],
  21. data: {
  22. serverSearchWhereLike: { name: '' },
  23. serverSearchWhere: { semester: '', segment: '小学' },
  24. }
  25. },
  26. { tag: 'v-spacer'},
  27. { tag: 'jh-mode', data: { viewMode: 'simple' } },
  28. ],
  29. common: {
  30. data: {
  31. constantObj: {
  32. },
  33. }
  34. }

内容-数据列表

  1. pageContent: [
  2. {
  3. tag: 'jh-list',
  4. props: {
  5. limit: 10, // 服务端搜索limit
  6. },
  7. attrs: { cols: 12, class: 'p-0 pb-7', ':style': '`height: calc(100vh - 140px); overflow-y: auto;overscroll-behavior: contain`' },
  8. headers: [
  9. {text: "学生Id", value: "studentId", width: 80, isSimpleMode: true},
  10. {text: "姓名", value: "name", width: 90, isTitle: true, slot: [`
  11. <div v-if="item.isMonitor" class="ml-1">
  12. <v-icon color="warning" small>mdi-shield-star</v-icon>
  13. <span>干部</span>
  14. </div>
  15. `]},
  16. {text: "性别", value: "gender", width: 60, isSimpleMode: true},
  17. {text: "学生状态", value: "studentStatus", width: 80},
  18. {text: "年级", value: "level", width: 70},
  19. {text: "入学-推荐人", value: "recommendBy", width: 100, isDetailMode: true},
  20. {text: "入学-跟进人", value: "followUpByUserName", width: 100, isDetailMode: true},
  21. {text: "跟进阶段", value: "followUpStage", width: 80},
  22. {text: "报名时间", value: "createAt", width: 150},
  23. {text: "操作者", value: "operationByUser", width: 90},
  24. {text: "操作时间", value: "operationAt", width: 150},
  25. {text: '操作', value: 'action'},
  26. ],
  27. rowActionList: [
  28. ]
  29. }
  30. ],
  31. common: {
  32. async created() {
  33. await this.doUiAction('getTableData');
  34. },
  35. doUiAction: {
  36. startDetailItem: ['startDetailItem']
  37. },
  38. methods: {
  39. }
  40. }

jh-list

属性 类型 必填 描述
props.limit string 分页每页数量
props.rightArrowText string 右边箭头文本
headers array 字段内容
headers.isSimpleMode boolean 是否只在简单模式显示,默认false
headers.isTitle boolean 是否作为行标题
rowActionList array 详情模式下的点击行

内容-数据列表(详情弹框)

  1. pageContent: [
  2. {
  3. tag: 'jh-list',
  4. props: {
  5. limit: 10,
  6. rightArrowText: '',
  7. },
  8. attrs: { cols: 12, class: 'p-0 pb-7', ':style': '`height: calc(100vh - 140px); overflow-y: auto;overscroll-behavior: contain`' },
  9. headers: [
  10. {text: "学生Id", value: "studentId", width: 80, isSimpleMode: true},
  11. {text: "姓名", value: "name", width: 90, isTitle: true, slot: [`
  12. <div v-if="item.isMonitor" class="ml-1">
  13. <v-icon color="warning" small>mdi-shield-star</v-icon>
  14. <span>干部</span>
  15. </div>
  16. `]},
  17. {text: "性别", value: "gender", width: 60, isSimpleMode: true},
  18. {text: "学生状态", value: "studentStatus", width: 80},
  19. {text: "年级", value: "level", width: 70},
  20. {text: "跟进阶段", value: "followUpStage", width: 80},
  21. {text: "报名时间", value: "createAt", width: 150},
  22. {text: '操作', value: 'action', align: 'center', sortable: false, width: 'window.innerWidth < 500 ? 90: 180', class: 'fixed', cellClass: 'fixed'},
  23. ],
  24. rowActionList: [
  25. { text: "编辑", icon: 'mdi-note-edit-outline', color: 'success', click: 'doUiAction("startUpdateItem", item)' }
  26. ],
  27. }
  28. ],
  29. actionContent: [
  30. {
  31. tag: 'jh-detail-drawer',
  32. key: "detail",
  33. attrs: {},
  34. title: "详情",
  35. headSlot: [
  36. ],
  37. card: {
  38. tag: 'div',
  39. colAttrs: { class: 'pa-0' },
  40. value: `
  41. <div class="p-3 border-b" >
  42. <div class="flex justify-between mb-2 items-center">
  43. <div>
  44. <span class="font-weight-bold text-base">{{ detailItem.name }}</span>
  45. </div>
  46. <span :class="'text-sm '">{{ detailItem.followUpStatus }}</span>
  47. </div>
  48. <div class="text-gray-500 flex justify-between">意向就读学部:{{ detailItem.segment }}</div>
  49. <div class="text-gray-500 flex justify-between">报名日期:{{ detailItem.createAt }}</div>
  50. </div>
  51. <div class="pa-0 h-2 bg-gray-100" ></div>
  52. `
  53. },
  54. contentList: [
  55. {
  56. type: 'preview',
  57. md: 12,
  58. formItemList: [
  59. { label: "性别", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.gender }}" },
  60. { label: "身份证件号", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.icNumber }}" },
  61. { label: "家庭住址", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.residentialAddress }}" },
  62. { label: "意向就读学部", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.segment }}" },
  63. { label: "意向就读年级", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.level }}" },
  64. { label: "意向就读方式", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.afterSchoolCareType }}" },
  65. { label: "原就读学校", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.schoolRoll }}" },
  66. { label: "中考分数", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.middleSchoolExamScore }}" },
  67. { label: "中考报名序号", tag: "span", colAttrs: { class: 'border-b pb-2 flex justify-between' }, value: "{{ detailItem.middleSchoolExamSequence }}" }
  68. ],
  69. action: [
  70. {
  71. tag: 'v-btn',
  72. value: "编辑",
  73. attrs: {
  74. color: 'primary',
  75. '@click': "doUiAction('startUpdateItem', detailItem); closeDetailDrawer()"
  76. },
  77. }
  78. ]
  79. }
  80. ]
  81. }
  82. ],
  83. common: {
  84. async created() {
  85. await this.doUiAction('getTableData');
  86. },
  87. }

内容-圆点操作菜单

  1. pageContent: [
  2. {
  3. tag: 'jh-action',
  4. attrs: { class: 'h-16 w-16 p-2 fixed right-4 bottom-32' },
  5. actionList: [
  6. { tag: 'v-btn', value: '新增', icon: 'mdi-plus', color: 'success', click: "doUiAction('startCreateItem')" },
  7. { tag: 'v-btn', value: '随机分配跟进人', icon: 'mdi-plus', color: 'success', click: "doUiAction('randomFollowUp')", ':disabled': '!tableSelected.length' },
  8. ]
  9. }
  10. ]

弹框相关

👉参考PC端弹框相关配置 👈

命令详解

生成样例文件页面

默认生成 example_classexample_student 数据表、配置文件和页面,方便参考使用

  1. jianghu-init json --generateType=example

生成页面配置文件

根据数据表生成页面配置文件

  1. jianghu-init json --generateType=json --pageType=page --table=class --pageId=classManagement

配置渲染html

根据配置文件生成页面

  1. jianghu-init json --generateType=page --pageType=page --file=classManagement

开启Dev模式

开启dev模式,修改配置文件将自动更新页面

  1. jianghu-init json dev

参数说明

参数 描述
generateType 生成类型,可选 example(生成示例文件)、json(数据表生成配置文件)、page(配置文件生成页面)
pageType 页面类型,可选 page、component
table 数据表名,当generateType为json可用
dev 启用开发模式,执行后会自动检测当前项目的json文件更新并自动更新html文件

其他

字符串代码语法高亮

  1. 在VSCode中,可以安装以下插件来实现字符串代码的语法高亮,以提高代码的可读性:

安装以上插件之后,在字符串代码前指定语法名称,即可显示语法高亮效果。

  1. pageContent: [
  2. /*html*/`<v-btn @click="openTestMultiTabDrawer">打开测试多标签弹框</v-btn>`,
  3. ],
  4. style: /*css*/`
  5. .jh-v-input {
  6. width: 100%;
  7. }
  8. `
  1. 你可以调整 VSCode 的配置来更好地支持模板字符串的 HTML 提示。在 VSCode 的设置中,搜索 "editor.quickSuggestions" 并确保在 "strings" 中启用补全建议:
  1. "editor.quickSuggestions": {
  2. "strings": true
  3. }

version v2版本升级指南

  1. 增加服务端搜索 jh-page
    1. {
    2. tag: 'jh-table',
    3. props: {
    4. serverPagination: true, // 需要version: v2
    5. },
    6. attrs: {},
    7. }
  2. doUiAction.getTableData,尽量不要全部覆盖方法链,如需自定义选择相应方法复写
    1. common.doUiAction: {
    2. getTableData: [
    3. 'prepareTableParamsDefault', // 组合搜索条件赋值到:this.tableParams
    4. 'prepareTableParams', // 自定义条件方法
    5. 'getTableData', // 请求
    6. 'formatTableData' // 格式化 tableData
    7. ]
    8. }
  3. formatTableData 方法
    1. // 原版
    2. formatTableData(rows) {
    3. rows.forEach(row => {
    4. row.operationAt = row.operationAt ? dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss') : '';
    5. });
    6. return rows;
    7. }
    8. // v2版本
    9. formatTableData() {
    10. let tableData = this.tableDataFromBackend.map(row => {
    11. row.operationAt = row.operationAt ? dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss') : '';
    12. return row;
    13. });
    14. this.tableData = tableData;
    15. }

version v3版本升级指南

  • 重构 init-json jh组件,把需要设置在 common.data 内的变量放入标签内,方便组件变量管理
  1. jh-order 移动端排序
    1. {
    2. tag: 'jh-order',
    3. data: {
    4. tableDataOrder: [ { column: "createAt", order: "desc" } ],
    5. tableDataOrderList: [
    6. { text: "报名时间↓", value: [ { column: "createAt", order: "desc" } ] },
    7. { text: "成绩分数↓", value: [ { column: "middleSchoolExamScore", order: "desc" } ] },
    8. { text: "更新时间↓", value: [ { column: "operationAt", order: "desc" } ] },
    9. ],
    10. }
    11. },
  2. jh-search 服务端搜索
    1. {
    2. tag: 'jh-search',
    3. searchList: [
    4. { tag: 'v-select', model: "serverSearchWhere.semester", colAttrs: { class: 'pb-0' }, attrs: { prefix: '学期:', color: 'success', ':items': 'constantObj.semester' } },
    5. { tag: 'v-select', model: "serverSearchWhere.segment", colAttrs: { class: 'pb-0' }, attrs: { prefix: '学部:', color: 'success', ':items': 'constantObj.segment' } },
    6. { tag: 'v-text-field', model: "serverSearchWhereLike.name", colAttrs: { class: 'pb-0' }, attrs: { label: '学生名字:', color: 'success' }, quickAttrs: ['clearable'] },
    7. ],
    8. data: {
    9. serverSearchWhereLike: { name: '' },
    10. serverSearchWhere: { semester: '', segment: '小学' },
    11. }
    12. },
  3. jh-mode 模式切换
    1. { tag: 'jh-mode', data: { viewMode: 'simple' } },
  4. jh-scene 场景搜索
    1. {
    2. tag: 'jh-scene',
    3. attrs: {
    4. // ':showActionBtn': false,
    5. ':mobile': true
    6. },
    7. data: {
    8. sceneCreateForm: {},
    9. currentSceneId: '全部',
    10. defaultSceneList: [
    11. { name: "全部", where: {} },
    12. { name: "无跟进人", where: { level: "01", "gender": "male"} },
    13. ],
    14. customSceneList: [
    15. { label: '年级', tag: 'v-select', model: 'form.level', attrs: {":items": 'constantObj.level'} },
    16. { label: '性别', tag: 'v-select', model: 'form.grade', attrs: {":items": 'constantObj.grade'} },
    17. ],
    18. maxSceneDisplay: 2,
    19. }
    20. }