ol-base-components 2.7.5 → 2.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.prettierrc CHANGED
@@ -7,7 +7,7 @@
7
7
  "bracketSpacing": true,
8
8
  "arrowParens": "avoid",
9
9
  "endOfLine": "crlf",
10
- "vueIndentScriptAndStyle": true,
10
+ "vueIndentScriptAndStyle": false,
11
11
  "htmlWhitespaceSensitivity": "css",
12
12
  "singleAttributePerLine": false
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.7.5",
3
+ "version": "2.7.7",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
package/src/api/api.js CHANGED
@@ -8,7 +8,7 @@ const SwaggerClient = require("swagger-client");
8
8
  const swaggerUrl = process.argv[2] ? `${process.argv[2]}/swagger/v1/swagger.json` : "";
9
9
  const modulesDir = process.argv[3] ? process.argv[3] : "src/api/modules";
10
10
 
11
- let defaultRemark = `/**
11
+ const defaultRemark = `/**
12
12
  * ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
13
13
  * �� 如需修改,请重新运行生成脚本
14
14
  * 📅 生成时间: ${new Date().toLocaleString()}
@@ -17,13 +17,38 @@ const spinnerChars = ["|", "/", "-", "\\"];
17
17
  let spinnerIndex = 0;
18
18
  let dotCount = 0;
19
19
  const maxDots = 3;
20
+
21
+ const lyrics = [
22
+ "下个礼拜你有空吗",
23
+ "下个礼拜你有空吗",
24
+ "下个礼拜我们还在这里等着你",
25
+ "别说你太忙",
26
+ "别说你没空",
27
+ "有我们陪你一起放轻松",
28
+ ];
29
+
30
+ let currentLyricIndex = 0;
31
+ let lyricChangeTime = Date.now();
32
+
20
33
  const spinner = setInterval(() => {
21
34
  const dots = ".".repeat(dotCount);
22
- process.stdout.write(`\r${spinnerChars[spinnerIndex]} 正在玩命加载中${dots}`);
35
+ const spinnerChar = spinnerChars[spinnerIndex];
36
+
37
+ if (Date.now() - lyricChangeTime > 2000) {
38
+ currentLyricIndex = (currentLyricIndex + 1) % lyrics.length;
39
+ lyricChangeTime = Date.now();
40
+ }
41
+
42
+ const currentLyric = lyrics[currentLyricIndex];
43
+ const rhythm = ["♪", "♫", "♬"][Math.floor(Date.now() / 500) % 3];
44
+
45
+ // 一行显示,用空格清除之前的内容
46
+ const displayText = `${rhythm} ${currentLyric} ${spinnerChar} 正在玩命加载中${dots}`;
47
+ process.stdout.write(`\r${displayText}${" ".repeat(50)}`);
48
+
23
49
  spinnerIndex = (spinnerIndex + 1) % spinnerChars.length;
24
50
  dotCount = (dotCount + 1) % (maxDots + 1);
25
51
  }, 300);
26
-
27
52
  // 设置文件为只读权限
28
53
  function setFileReadOnly(filePath) {
29
54
  try {
package/src/api/run.js CHANGED
@@ -8,7 +8,7 @@ const path = require("path");
8
8
  const swaggerUrl = process.argv[2] ? `${process.argv[2]}/swagger/v1/swagger.json` : "";
9
9
  const outputPath = process.argv[3] || "src/api/swagger.js";
10
10
 
11
- let defaultRemark = `/**
11
+ const defaultRemark = `/**
12
12
  * ⚠️ 警告:此文件由脚本自动生成,请勿手动编辑!
13
13
  * �� 如需修改,请重新运行生成脚本
14
14
  * 📅 生成时间: ${new Date().toLocaleString()}
@@ -17,13 +17,38 @@ const spinnerChars = ["|", "/", "-", "\\"];
17
17
  let spinnerIndex = 0;
18
18
  let dotCount = 0;
19
19
  const maxDots = 3;
20
+
21
+ const lyrics = [
22
+ "下个礼拜你有空吗",
23
+ "下个礼拜你有空吗",
24
+ "下个礼拜我们还在这里等着你",
25
+ "别说你太忙",
26
+ "别说你没空",
27
+ "有我们陪你一起放轻松",
28
+ ];
29
+
30
+ let currentLyricIndex = 0;
31
+ let lyricChangeTime = Date.now();
32
+
20
33
  const spinner = setInterval(() => {
21
34
  const dots = ".".repeat(dotCount);
22
- process.stdout.write(`\r${spinnerChars[spinnerIndex]} 正在玩命加载中${dots}`);
35
+ const spinnerChar = spinnerChars[spinnerIndex];
36
+
37
+ if (Date.now() - lyricChangeTime > 2000) {
38
+ currentLyricIndex = (currentLyricIndex + 1) % lyrics.length;
39
+ lyricChangeTime = Date.now();
40
+ }
41
+
42
+ const currentLyric = lyrics[currentLyricIndex];
43
+ const rhythm = ["♪", "♫", "♬"][Math.floor(Date.now() / 500) % 3];
44
+
45
+ // 一行显示,用空格清除之前的内容
46
+ const displayText = `${rhythm} ${currentLyric} ${spinnerChar} 正在玩命加载中${dots}`;
47
+ process.stdout.write(`\r${displayText}${" ".repeat(50)}`);
48
+
23
49
  spinnerIndex = (spinnerIndex + 1) % spinnerChars.length;
24
50
  dotCount = (dotCount + 1) % (maxDots + 1);
25
51
  }, 300);
26
-
27
52
  // 设置文件为只读权限
28
53
  function setFileReadOnly(filePath) {
29
54
  try {
package/src/bin/add.js CHANGED
@@ -112,6 +112,7 @@ try {
112
112
  let editUrl = "";
113
113
  let deleteUrl = "";
114
114
  let detailUrl = "";
115
+ let rowId = "";
115
116
 
116
117
  // 如果有新增/编辑/删除/详情功能,直接使用分页接口地址
117
118
  if (operationsAnswer.operations.length > 0) {
@@ -137,11 +138,11 @@ try {
137
138
  {
138
139
  type: "input",
139
140
  name: "idField",
140
- message: "请输入ID字段名:",
141
+ message: "请输入url后缀ID字段名:",
141
142
  default: "admissionInfoId",
142
143
  validate: input => {
143
144
  if (!input.trim()) {
144
- return "ID字段名不能为空";
145
+ return "url后缀ID字段名不能为空";
145
146
  }
146
147
  return true;
147
148
  },
@@ -164,6 +165,29 @@ try {
164
165
  }
165
166
  }
166
167
 
168
+ //如果有编辑/详情/删除,询问row中的id字段名
169
+ if (
170
+ operationsAnswer.operations.includes("edit") ||
171
+ operationsAnswer.operations.includes("delete") ||
172
+ operationsAnswer.operations.includes("detail")
173
+ ) {
174
+ const rowIdAnswer = await inquirer.prompt([
175
+ {
176
+ type: "input",
177
+ name: "rowId",
178
+ message: "请输入行数据中ID字段的键名(用于编辑/详情/删除操作)",
179
+ default: "id",
180
+ validate: input => {
181
+ if (!input.trim()) {
182
+ return "ID字段的键名不能为空";
183
+ }
184
+ return true;
185
+ },
186
+ },
187
+ ]);
188
+ rowId = rowIdAnswer.rowId;
189
+ }
190
+
167
191
  // 4. 询问所有接口的模块名
168
192
  const moduleAnswer = await inquirer.prompt([
169
193
  {
@@ -213,6 +237,7 @@ try {
213
237
  detailUrl: detailUrl,
214
238
  swaggerModule: moduleAnswer.swaggerModule,
215
239
  idField: idField,
240
+ rowId,
216
241
  };
217
242
 
218
243
  // 生成模板内容
@@ -29,8 +29,6 @@ function generateKeyName(url, method) {
29
29
  return `${method.toLowerCase()}${key}`;
30
30
  }
31
31
  const vue2Template = (moduleName, config = {}) => {
32
- console.log(888, config);
33
-
34
32
  // 生成各种接口的key名称
35
33
  let pageUrlKey = "",
36
34
  exportUrlKey = "",
@@ -51,7 +49,6 @@ const vue2Template = (moduleName, config = {}) => {
51
49
  const generateImports = () => {
52
50
  const imports = [];
53
51
  if (config.pageUrl) imports.push(`${pageUrlKey}`);
54
- if (config.baseUrl) imports.push(`${baseUrlKey}`);
55
52
  if (config.addUrl) imports.push(`${addUrlKey}`);
56
53
  if (config.editUrl) imports.push(`${editUrlKey}`);
57
54
  if (config.detailUrl) imports.push(`${detailUrlKey}`);
@@ -70,14 +67,6 @@ const vue2Template = (moduleName, config = {}) => {
70
67
  }`);
71
68
  }
72
69
 
73
- // if (config.hasEdit) {
74
- // methods.push(`
75
- // editBtnHandler() {
76
- // this.form.type = 2;
77
- // this.dialogVisible = true;
78
- // }`);
79
- // }
80
-
81
70
  if (config.hasEdit) {
82
71
  methods.push(`
83
72
  ${config.hasDetail ? `async ` : ``}editBtnHandler() {
@@ -87,7 +76,7 @@ const vue2Template = (moduleName, config = {}) => {
87
76
  this.form.type = 2;
88
77
  ${
89
78
  config.hasDetail
90
- ? `const { result = {} } = await ${detailUrlKey}(row.${config.idField});
79
+ ? `const { result = {} } = await ${detailUrlKey}(row.${config.rowId});
91
80
  this.form.value = result || {};`
92
81
  : `this.form.value = { ...row };`
93
82
  }
@@ -114,7 +103,7 @@ const vue2Template = (moduleName, config = {}) => {
114
103
  this.$message("新建成功");
115
104
  }else if(form.type === 2){
116
105
  //编辑
117
- const res = await ${editUrlKey}(data['${config.idField}'], data);
106
+ const res = await ${editUrlKey}(data['${config.rowId}'], data);
118
107
  if(res.code !== 200) return;
119
108
  this.$message("编辑成功");
120
109
  this.init();
@@ -135,7 +124,7 @@ const vue2Template = (moduleName, config = {}) => {
135
124
  cancelButtonText: '取消',
136
125
  type: 'warning'
137
126
  }).then(() => {
138
- ${deleteUrlKey}(row.${config.idField}).then(() => {
127
+ ${deleteUrlKey}(row.${config.rowId}).then(() => {
139
128
  this.$message.success('删除成功');
140
129
  this.init();
141
130
  }).catch(() => {
@@ -168,7 +168,7 @@
168
168
  </div>
169
169
  </div>
170
170
  </template>
171
- <!--
171
+ <!--
172
172
  # BaseForm 基础表单组件
173
173
 
174
174
  ## Props 属性
@@ -210,8 +210,7 @@
210
210
  | onCancel | 取消按钮点击事件 | - |
211
211
  | selectChange| 选择器值变化事件 | {obj: 当前项配置, val: 变化后的值} |
212
212
  -->
213
- <script>
214
- import { getData } from "../../index.js";
213
+ <script>
215
214
  import { initForm } from "../../../utils/initData.js";
216
215
 
217
216
  // interface FormItem {
@@ -340,7 +339,7 @@ export default {
340
339
  }
341
340
  },
342
341
  selectChange(obj, val) {
343
- let temp = {
342
+ const temp = {
344
343
  obj: obj,
345
344
  val: val,
346
345
  };
@@ -386,11 +385,10 @@ export default {
386
385
  },
387
386
  };
388
387
  </script>
389
-
390
- <style lang="scss" scoped>
388
+
389
+ <style lang="scss" scoped>
391
390
  .dialog-footer {
392
391
  display: flex;
393
392
  justify-content: flex-end;
394
393
  }
395
394
  </style>
396
-
@@ -1,9 +1,7 @@
1
1
  <template>
2
2
  <div class="formSearch formSearchArrowUp">
3
3
  <div
4
- v-if="
5
- formSearchData.tableSearch && formSearchData.tableSearch.length >= 0
6
- "
4
+ v-if="formSearchData.tableSearch && formSearchData.tableSearch.length >= 0"
7
5
  class="table-header"
8
6
  >
9
7
  <el-form
@@ -20,11 +18,7 @@
20
18
  <!-- 'label-width': '100px', -->
21
19
  <div
22
20
  class="transitionGroup"
23
- :class="[
24
- formSearchData.expendShow
25
- ? 'formSearchBtnArrowDowns'
26
- : 'formSearchBtnArrowUps',
27
- ]"
21
+ :class="[formSearchData.expendShow ? 'formSearchBtnArrowDowns' : 'formSearchBtnArrowUps']"
28
22
  >
29
23
  <el-form-item
30
24
  v-for="item in findTableSearch"
@@ -113,11 +107,7 @@
113
107
  style="width: 100%"
114
108
  :placeholder="item.props.placeholder || '选择日期'"
115
109
  v-bind="item.props || { type: 'date' }"
116
- :default-time="
117
- item.props.type == 'datetimerange'
118
- ? ['00:00:00', '23:59:59']
119
- : ''
120
- "
110
+ :default-time="item.props.type == 'datetimerange' ? ['00:00:00', '23:59:59'] : ''"
121
111
  />
122
112
  <el-input
123
113
  v-else
@@ -138,11 +128,7 @@
138
128
  <el-form-item
139
129
  style="word-break: keep-all; white-space: nowrap; margin-left: 10px"
140
130
  class="fromBtn"
141
- :class="[
142
- formSearchData.expendShow
143
- ? 'formSearchBtnArrowDown'
144
- : 'formSearchBtnArrowUp',
145
- ]"
131
+ :class="[formSearchData.expendShow ? 'formSearchBtnArrowDown' : 'formSearchBtnArrowUp']"
146
132
  >
147
133
  <el-button
148
134
  v-if="formSearchData.reset"
@@ -197,9 +183,7 @@ export default {
197
183
  "el-select-loadmore": {
198
184
  bind(el, binding) {
199
185
  // 获取element-ui定义好的scroll盒子
200
- const SELECTWRAP_DOM = el.querySelector(
201
- ".el-select-dropdown .el-select-dropdown__wrap"
202
- );
186
+ const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
203
187
  SELECTWRAP_DOM.addEventListener("scroll", function () {
204
188
  /**
205
189
  * scrollHeight 获取元素内容高度(只读)
@@ -208,8 +192,7 @@ export default {
208
192
  * 如果元素滚动到底, 下面等式返回true, 没有则返回false:
209
193
  * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
210
194
  */
211
- const condition =
212
- this.scrollHeight - this.scrollTop <= this.clientHeight;
195
+ const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
213
196
  if (condition > 0 && condition < 2) {
214
197
  binding.value();
215
198
  }
@@ -220,9 +203,7 @@ export default {
220
203
  bind(el, binding, vnode) {
221
204
  // console.log(binding.value)
222
205
  const _that = vnode.context; // 当前vue对象
223
- const SELECTWRAP_DOM = el.querySelector(
224
- ".el-select-dropdown .el-select-dropdown__wrap"
225
- );
206
+ const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
226
207
  SELECTWRAP_DOM.addEventListener("scroll", function () {
227
208
  // console.log(SELECTWRAP_DOM.scrollHeight) // 文档内容的实际高度
228
209
  // console.log(SELECTWRAP_DOM.scrollTop) // 滚动条滚动高度
@@ -240,9 +221,7 @@ export default {
240
221
  unbind(el, binding, vnode) {
241
222
  // 解除事件监听
242
223
  const _that = vnode.context; // 当前vue对象
243
- const SELECTWRAP_DOM = el.querySelector(
244
- ".el-select-dropdown .el-select-dropdown__wrap"
245
- );
224
+ const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
246
225
  if (SELECTWRAP_DOM) {
247
226
  SELECTWRAP_DOM.removeEventListener("scroll", function () {
248
227
  binding.value.SELECTWRAP_DOM_index = 0;
@@ -320,11 +299,10 @@ export default {
320
299
  methods: {
321
300
  async init() {
322
301
  const swaggerData = await getData();
323
- const swaggersearchColumns =
324
- swaggerData.paths[this.url].get.parameters || [];
325
- swaggersearchColumns.forEach((item) => {
302
+ const swaggersearchColumns = swaggerData.paths[this.url].get.parameters || [];
303
+ swaggersearchColumns.forEach(item => {
326
304
  let tempItem = this.formSearchData.tableSearch.find(
327
- (e) => e.value.toLowerCase() === item.name.toLowerCase()
305
+ e => e.value.toLowerCase() === item.name.toLowerCase()
328
306
  );
329
307
  if (tempItem) {
330
308
  // 匹配到
@@ -340,7 +318,7 @@ export default {
340
318
  if (item.schema.enum && Array.isArray(item.schema.enum)) {
341
319
  //枚举值
342
320
  pushItem.inputType = "select";
343
- pushItem.children = item.schema.enum.map((e) => ({
321
+ pushItem.children = item.schema.enum.map(e => ({
344
322
  key: e,
345
323
  value: e,
346
324
  }));
@@ -357,13 +335,13 @@ export default {
357
335
  });
358
336
 
359
337
  const tableHasCreatedTime = this.formSearchData.tableSearch.some(
360
- (e) => e.value === "createdTime"
338
+ e => e.value === "createdTime"
361
339
  );
362
340
  if (!tableHasCreatedTime) {
363
341
  // 单独处理创建时间 就是BeginTime,EndTime
364
342
  const requiredNames = ["BeginTime", "EndTime"];
365
- const hseCreatedTime = requiredNames.every((name) =>
366
- swaggersearchColumns.some((item) => item.name === name)
343
+ const hseCreatedTime = requiredNames.every(name =>
344
+ swaggersearchColumns.some(item => item.name === name)
367
345
  );
368
346
  if (hseCreatedTime) {
369
347
  this.formSearchData.tableSearch.push({
@@ -385,10 +363,7 @@ export default {
385
363
  this.formSearchData.tableSearch.length > this.tableSearchSlice
386
364
  ? this.formSearchData.tableSearch.slice(0, this.tableSearchSlice)
387
365
  : this.formSearchData.tableSearch;
388
- console.log(
389
- `\x1b[36m\x1b[4mol插件-搜索框渲染`,
390
- this.formSearchData.tableSearch
391
- );
366
+ console.log(`\x1b[36m\x1b[4mol插件-搜索框渲染`, this.formSearchData.tableSearch);
392
367
  },
393
368
  // 树形下拉
394
369
  getValue(val) {
@@ -405,7 +380,7 @@ export default {
405
380
  }
406
381
  const tempFormSearch = Object.assign({}, this.formSearch);
407
382
  if (this.formSearchData.rules) {
408
- return this.$refs[formName].validate((valid) => {
383
+ return this.$refs[formName].validate(valid => {
409
384
  if (!valid) return false;
410
385
  this.$emit("handleSearch", tempFormSearch, item);
411
386
  });
@@ -421,25 +396,13 @@ export default {
421
396
  this.$refs[formName].resetFields();
422
397
  if (this.formSearchData.reset) {
423
398
  for (const key in this.formSearch) {
424
- if (
425
- Object.prototype.toString.call(this.formSearch[key]) ===
426
- "[object String]"
427
- ) {
399
+ if (Object.prototype.toString.call(this.formSearch[key]) === "[object String]") {
428
400
  this.formSearch[key] = null;
429
- } else if (
430
- Object.prototype.toString.call(this.formSearch[key]) ===
431
- "[object Array]"
432
- ) {
401
+ } else if (Object.prototype.toString.call(this.formSearch[key]) === "[object Array]") {
433
402
  this.formSearch[key] = [];
434
- } else if (
435
- Object.prototype.toString.call(this.formSearch[key]) ===
436
- "[object Object]"
437
- ) {
403
+ } else if (Object.prototype.toString.call(this.formSearch[key]) === "[object Object]") {
438
404
  this.formSearch[key] = {};
439
- } else if (
440
- Object.prototype.toString.call(this.formSearch[key]) ===
441
- "[object Boolean]"
442
- ) {
405
+ } else if (Object.prototype.toString.call(this.formSearch[key]) === "[object Boolean]") {
443
406
  this.formSearch[key] = false;
444
407
  } else {
445
408
  this.formSearch[key] = null;
@@ -458,10 +421,7 @@ export default {
458
421
  handleExpend() {
459
422
  this.expend = !this.expend; // 展开和收起
460
423
  this.findTableSearch = this.expend
461
- ? this.formSearchData.tableSearch.slice(
462
- 0,
463
- this.formSearchData.tableSearch.length
464
- )
424
+ ? this.formSearchData.tableSearch.slice(0, this.formSearchData.tableSearch.length)
465
425
  : this.formSearchData.tableSearch.slice(0, this.tableSearchSlice);
466
426
 
467
427
  this.$emit("btnHandleExpend", this.expend);
@@ -475,13 +435,7 @@ export default {
475
435
  keyInput(item, e) {
476
436
  if (item.inputType === "number") {
477
437
  let key = e.key;
478
- if (
479
- key === "e" ||
480
- key === "E" ||
481
- key === "-" ||
482
- key === "+" ||
483
- key === "."
484
- ) {
438
+ if (key === "e" || key === "E" || key === "-" || key === "+" || key === ".") {
485
439
  e.returnValue = false;
486
440
  return false;
487
441
  }
@@ -26,18 +26,38 @@ const javaTypeToformType = javaType => {
26
26
  }
27
27
  };
28
28
 
29
+ // 弹框接口数据来源判断 优先级:新增接口>编辑接口>详情接口
30
+ const getDialogSwaggerData = (url, swaggerData) => {
31
+ try {
32
+ // 新增 post
33
+ const entity = swaggerData.paths[url].post;
34
+ const schema = entity.requestBody.content["application/json"].schema;
35
+ const properties = schema.properties;
36
+
37
+ return [schema, properties];
38
+ } catch (err) {
39
+ try {
40
+ //编辑 put
41
+ const entity = swaggerData.paths[url].put;
42
+ const schema = entity.requestBody.content["application/json"].schema;
43
+ const properties = schema.properties;
44
+ return [schema, properties];
45
+ } catch (err) {
46
+ // 详情 get
47
+ const entity = swaggerData.paths[url].get;
48
+ const schema = entity.responses[200].content["application/json"].schema;
49
+ const properties = schema.properties;
50
+ return [schema, properties];
51
+ }
52
+ }
53
+ };
54
+
29
55
  export const initForm = options => {
30
56
  const { url, form } = options;
31
57
  getData().then(swaggerData => {
32
58
  // swagger数据可以来源于,新增接口/编辑接口/详情接口(优先级:新增接口>编辑接口>详情接口)
33
- let entity = {},
34
- schema = {},
35
- properties = {};
36
- entity = swaggerData.paths[url].post;
37
- // 添加title
38
- // if (!form.title) form.title = entity.summary;
39
- schema = entity.requestBody.content["application/json"].schema;
40
- properties = schema.properties;
59
+ const [schema, properties] = getDialogSwaggerData(url, swaggerData);
60
+ if (!schema || !properties) return console.log(`\x1b[36m\x1b[4mol插件-弹框数据异常`);
41
61
  // 生成model
42
62
  // 1.循环model,将properties中prop相同的匹配,属性合并,model权限大,properties权限小,且保持响应式
43
63
  form.model.forEach(item => {