sohelp-eleplus 1.1.24 → 1.1.25

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * axios实例
3
3
  */
4
- import { ElMessageBox } from 'element-plus/es';
4
+ import { ElMessageBox } from "element-plus/es";
5
5
 
6
6
  export const SohelpHttp = {
7
7
  /**
@@ -12,7 +12,7 @@ export const SohelpHttp = {
12
12
  },
13
13
 
14
14
  /**
15
- * 下载文件
15
+ * 通过Get请求,下载文件
16
16
  * @param _url
17
17
  * @param param
18
18
  * @param fileName
@@ -20,9 +20,9 @@ export const SohelpHttp = {
20
20
  * @param config
21
21
  * @returns {Promise<never>}
22
22
  */
23
- download: async function (_url, param, fileName, onProgress, config = {}) {
23
+ download: async function(_url, param, fileName, onProgress, config = {}) {
24
24
  if (window.$axios == null) {
25
- console.error('请在配置main.js中配置window.$axios实例!!');
25
+ console.error("请在配置main.js中配置window.$axios实例!!");
26
26
  return;
27
27
  }
28
28
  try {
@@ -33,10 +33,10 @@ export const SohelpHttp = {
33
33
  const response = await window.$axios
34
34
  .get(_url, {
35
35
  params: param || {},
36
- responseType: 'blob',
36
+ responseType: "blob",
37
37
  ...config,
38
38
  onDownloadProgress: (evt) => {
39
- if (typeof onProgress === 'function') {
39
+ if (typeof onProgress === "function") {
40
40
  const total = evt?.total || 0;
41
41
  const loaded = evt?.loaded || 0;
42
42
  onProgress(loaded, total);
@@ -47,7 +47,7 @@ export const SohelpHttp = {
47
47
  return Promise.reject(e.message);
48
48
  });
49
49
 
50
- if (response.type === 'application/json') {
50
+ if (response.type === "application/json") {
51
51
  try {
52
52
  const text = await response.text();
53
53
  const res = JSON.parse(text);
@@ -55,7 +55,7 @@ export const SohelpHttp = {
55
55
  return res.data;
56
56
  } else {
57
57
  if (res?.meta?.error) {
58
- console.log('SohelpHttp.download:', res.meta.error);
58
+ console.log("SohelpHttp.download:", res.meta.error);
59
59
  }
60
60
  return Promise.reject(new Error(res.meta.message));
61
61
  }
@@ -65,12 +65,12 @@ export const SohelpHttp = {
65
65
  return;
66
66
  }
67
67
  // 创建一个链接元素用于下载
68
- const url = _url + '?' + new URLSearchParams(param).toString();
68
+ const url = _url + "?" + new URLSearchParams(param).toString();
69
69
  // const url = window.URL.createObjectURL(response.data);
70
- const link = document.createElement('a');
70
+ const link = document.createElement("a");
71
71
  link.href = url;
72
- link.target = '_blank';
73
- link.setAttribute('download', fileName); // 设置下载的文件名
72
+ link.target = "_blank";
73
+ link.setAttribute("download", fileName); // 设置下载的文件名
74
74
  document.body.appendChild(link);
75
75
 
76
76
  // 触发下载
@@ -82,22 +82,22 @@ export const SohelpHttp = {
82
82
  return Promise.reject(error);
83
83
  }
84
84
  },
85
- get: function (url, param, callback) {
85
+ get: function(url, param, callback) {
86
86
  if (window.$axios == null) {
87
- console.error('请在配置main.js中配置window.$axios实例!!');
87
+ console.error("请在配置main.js中配置window.$axios实例!!");
88
88
  return;
89
89
  }
90
90
  for (const key in param) {
91
- if (typeof param[key] === 'object' && param[key] !== null) {
91
+ if (typeof param[key] === "object" && param[key] !== null) {
92
92
  param[key] = JSON.stringify(param[key]); // 转换为 JSON 字符串
93
93
  }
94
94
  }
95
95
  let promise = window.$axios.get(url, { params: param });
96
96
  return promise.then((r) => {
97
97
  if (!r.meta.success && r.meta.error) {
98
- console.error('(GET请求URL):', url, '(请求参数):', param, '(返回结果):', r.meta.error);
98
+ console.error("(GET请求URL):", url, "(请求参数):", param, "(返回结果):", r.meta.error);
99
99
  }
100
- if (typeof callback === 'function') {
100
+ if (typeof callback === "function") {
101
101
  callback.call(this, r);
102
102
  }
103
103
  return Promise.resolve(r);
@@ -112,17 +112,17 @@ export const SohelpHttp = {
112
112
  * @param {Function} [error] 错误回调函数(目前未使用)
113
113
  * @returns {Promise<any>} 返回Promise对象
114
114
  */
115
- post: function (url, param, callback, error) {
115
+ post: function(url, param, callback, error) {
116
116
  if (window.$axios == null) {
117
- console.error('请在配置main.js中配置window.$axios实例!');
117
+ console.error("请在配置main.js中配置window.$axios实例!");
118
118
  return;
119
119
  }
120
120
  let promise = window.$axios.post(url, param);
121
121
  return promise.then((r) => {
122
122
  if (!r.meta.success && r.meta.error) {
123
- console.error('(GET请求URL):', url, '(请求参数):', param, '(返回结果):', r.meta.error);
123
+ console.error("(GET请求URL):", url, "(请求参数):", param, "(返回结果):", r.meta.error);
124
124
  }
125
- if (typeof callback === 'function') {
125
+ if (typeof callback === "function") {
126
126
  callback.call(this, r);
127
127
  }
128
128
  return Promise.resolve(r);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sohelp-eleplus",
3
- "version": "1.1.24",
3
+ "version": "1.1.25",
4
4
  "description": "SohelpEleplus Extension Components",
5
5
  "public": true,
6
6
  "main": "index.js",
@@ -57,6 +57,17 @@ const getId = () => {
57
57
  return 'sohelp-grid-' + uuid();
58
58
  }
59
59
 
60
+ /** 对齐方式映射 */
61
+ const getAlign = (align) => {
62
+ const alignMap = {
63
+ 'left': 'flex-start',
64
+ 'center': 'center',
65
+ 'right': 'flex-end',
66
+ '': 'flex-start'
67
+ };
68
+ return alignMap[align] || 'flex-start';
69
+ }
70
+
60
71
  const loadReport = () => {
61
72
  SohelpHttp.get("/engine/web/report/list", { refid: props.refid }).then(res => {
62
73
  if (res.meta.success) {
@@ -653,12 +664,13 @@ const getOperationButtonsByType = computed(() => {
653
664
  */
654
665
  const operationHandler = ({ button, row, $grid }) => {
655
666
 
667
+
656
668
  //操作栏事件执行
657
669
  $grid.reload = reload;
658
670
  $grid.refresh = refresh;
659
- if (item.handler && typeof item.handler === "string") {
671
+ if (button.handler && typeof button.handler === "string") {
660
672
  try {
661
- const func = new Function("$row", "$grid", `return (async () => { ${item.handler} })()`);
673
+ const func = new Function("$row", "$grid", `return (async () => { ${button.handler} })()`);
662
674
  (async () => {
663
675
  const context = {
664
676
  $message: EleMessage,
@@ -680,22 +692,22 @@ const operationHandler = ({ button, row, $grid }) => {
680
692
  } catch (e) {
681
693
  EleMessage.error(`操作栏事件出错:${e.message}`);
682
694
  }
683
- } else if (item.refid) {
684
- if (item.openType === "tab") {
685
- window.$SohelpModule.openTab(item.refid, { id: row.id }, item.params || {});
686
- } else if (item.openType === "drawer") {
687
- window.$SohelpModule.openDrawer(item.refid, { id: row.id }, item.params || {});
695
+ } else if (button.refid) {
696
+ if (button.openType === "tab") {
697
+ window.$SohelpModule.openTab(button.refid, { id: row.id }, button.params || {});
698
+ } else if (button.openType === "drawer") {
699
+ window.$SohelpModule.openDrawer(button.refid, { id: row.id }, button.params || {});
688
700
  } else {
689
- window.$SohelpModule.openModal(item.refid, { id: row.id }, item.params || {});
701
+ window.$SohelpModule.openModal(button.refid, { id: row.id }, button.params || {});
690
702
  }
691
703
  } else {
692
- switch (item.code) {
704
+ switch (button.code) {
693
705
  case "row.delete":
694
706
  $grid?.remove(row)
695
707
  break;
696
708
  case "crud.edit":
697
709
  visibleEntityForm.value = true;
698
- toolbarButtonParams.value = item.params || {};
710
+ toolbarButtonParams.value = button.params || {};
699
711
  if (!toolbarButtonParams.value["title"]) {
700
712
  toolbarButtonParams.value["title"] = t("grid.toolbar.edit");
701
713
  }
@@ -716,7 +728,7 @@ const operationHandler = ({ button, row, $grid }) => {
716
728
  break;
717
729
  case "crud.view":
718
730
  visibleEntityForm.value = true;
719
- toolbarButtonParams.value = item.params || {};
731
+ toolbarButtonParams.value = button.params || {};
720
732
  if (!toolbarButtonParams.value["title"]) {
721
733
  toolbarButtonParams.value["title"] = t("grid.toolbar.view");
722
734
  }
@@ -752,9 +764,10 @@ const operationHandler = ({ button, row, $grid }) => {
752
764
  break;
753
765
  }
754
766
  }
755
- emit("operationButtonClick", { item, row, $grid });
767
+ emit("operationButtonClick", { button, row, $grid });
756
768
  };
757
769
 
770
+
758
771
  /**
759
772
  * 获取表格数据
760
773
  */
@@ -1647,7 +1660,7 @@ v-for="field in Object.values(propertiesMap).filter(item => item.query)" :key="f
1647
1660
  <sohelp-power @change="changePower" v-if="sohelpConfig?.filter?.config?.visibleDataRange"/>
1648
1661
  </div>
1649
1662
 
1650
- <div class="search-box" v-if="sohelpConfig?.filter?.config?.visibleKeywords">
1663
+ <div class="search-box" v-if="sohelpConfig?.filter?.config?.visibleKeywords && sohelpConfig?.filter?.keywords.length>0 ">
1651
1664
  <!-- 关键字 -->
1652
1665
  <ele-tooltip :content="getKeywordsPlaceholder" placement="top" :offset="3">
1653
1666
  <sohelp-input
@@ -1686,16 +1699,16 @@ v-for="item in sortList" :key="item.title" :header="item.title"
1686
1699
  </ele-card>
1687
1700
  </div>
1688
1701
  </sohelp-drop-card>
1689
- <el-button
1690
- :icon="Filter" size="small" @click="showFilter()"
1691
- plain
1702
+ <el-button :icon="Filter" size="small"
1703
+ @click="showFilter()"
1704
+ plain
1692
1705
  :type="(sohelpConfig?.filter?.config?.visibleFilter && sohelpConfig?.filter?.config?.filterPosition !== 'NONE')?'primary':''"
1693
1706
  v-if="sohelpConfig?.filter?.config?._visibleFilter"/>
1694
- <ele-tooltip :content="'批量导入数据'" placement="top" :offset="3">
1695
- <el-button size="small" plain :icon="ElementPlusIcons.Upload" @click="openImport" v-permission="importAuthority"/>
1707
+ <ele-tooltip :content="'批量导入数据'" placement="top" :offset="3" v-permission="importAuthority">
1708
+ <el-button size="small" plain :icon="ElementPlusIcons.Upload" @click="openImport" />
1696
1709
  </ele-tooltip>
1697
- <ele-tooltip :content="'批量导出数据'" placement="top" :offset="3">
1698
- <el-dropdown @command="exportData" v-permission="exportAuthority">
1710
+ <ele-tooltip :content="'批量导出数据'" placement="top" :offset="3" v-permission="exportAuthority">
1711
+ <el-dropdown @command="exportData" >
1699
1712
  <el-button size="small" plain :icon="ElementPlusIcons.Download"/>
1700
1713
  <template #dropdown>
1701
1714
  <el-dropdown-menu>
@@ -1726,103 +1739,105 @@ v-for="item in sortList" :key="item.title" :header="item.title"
1726
1739
  #[`default_${name}`]="{ row, column, rowIndex }"
1727
1740
  :key="name"
1728
1741
  >
1742
+ <div style=" display: flex; justify-content: right;" :style="{ justifyContent: getAlign(propertiesMap[name].align)}">
1743
+
1744
+ <!-- 字典 -->
1745
+ <sohelp-dict
1746
+ type="text"
1747
+ v-model="row[name]"
1748
+ v-if="column.type === 'SohelpDict'"
1749
+ v-bind="column.editRender"
1750
+ />
1751
+ <!-- 图片 -->
1752
+ <sohelp-image-upload
1753
+ v-else-if="column.type === 'SohelpImageUpload'"
1754
+ v-model="row[name]"
1755
+ v-bind="column.editRender"
1756
+ :data="getCellValue(rowIndex,name)"
1757
+ :readonly="!column.editRender.edit"
1758
+ />
1759
+ <!-- 附件 -->
1760
+ <sohelp-file-upload
1761
+ v-else-if="column.type === 'SohelpFileUpload'"
1762
+ v-model="row[name]"
1763
+ v-bind="column.editRender"
1764
+ :data="getCellValue(rowIndex,name)"
1765
+ :readonly="!column.editRender.edit"
1766
+ />
1729
1767
 
1768
+ <!-- 下拉选择表格 -->
1769
+ <div v-else-if="column.type === 'SohelpTableSelect' || column.type === 'ORG' || column.type ==='USER'">
1770
+ <span>{{ getTableSelectLabel(row[name], rowIndex, name, column) }}</span>
1771
+ </div>
1730
1772
 
1731
- <sohelp-dict
1732
- type="text"
1733
- v-model="row[name]"
1734
- v-if="column.type === 'SohelpDict'"
1735
- v-bind="column.editRender"
1736
- />
1737
-
1738
- <!-- 图片 -->
1739
- <sohelp-image-upload
1740
- v-else-if="column.type === 'SohelpImageUpload'"
1741
- v-model="row[name]"
1742
- v-bind="column.editRender"
1743
- :data="getCellValue(rowIndex,name)"
1744
- :readonly="!column.editRender.edit"/>
1745
- <!-- 附件 -->
1746
- <sohelp-file-upload
1747
- v-else-if="column.type === 'SohelpFileUpload'"
1748
- v-model="row[name]"
1749
- v-bind="column.editRender"
1750
- :data="getCellValue(rowIndex,name)"
1751
- :readonly="!column.editRender.edit"/>
1752
-
1753
- <!-- 下拉选择表格 -->
1754
- <div v-else-if="column.type === 'SohelpTableSelect' || column.type === 'ORG' || column.type ==='USER'">
1755
- <span>{{ getTableSelectLabel(row[name], rowIndex, name, column) }}</span>
1756
- </div>
1757
-
1758
- <!-- 评分 -->
1759
- <sohelp-rate
1760
- v-else-if="column.type==='SohelpRate'"
1761
- v-model="row[name]"
1762
- v-bind="column.editRender"
1763
- :disabled="!column.editRender.edit"
1764
- show-score
1765
- score-template="{value} 分"
1766
- style="width: 100%;"
1767
- />
1768
-
1769
- <!-- 进度 -->
1770
- <sohelp-process
1771
- v-else-if="column.type==='SohelpProcess'"
1772
- v-model="row[name]"
1773
- v-bind="column.editRender"
1774
- style="width: 100%"
1775
- :readonly="!column.editRender.edit"
1776
- />
1777
-
1778
-
1779
- <!-- 下拉用户选择 -->
1780
- <div v-else-if="column.type === 'SohelpUserSelect'">
1781
- {{ gridData[rowIndex][name]?.["user_name"] }}
1782
- </div>
1783
-
1784
- <!-- 下拉组织选择 -->
1785
- <div v-else-if="column.type === 'SohelpOrgTreeSelect'">
1786
- {{ gridData[rowIndex][name]?.["org_name"] }}
1787
- </div>
1773
+ <!-- 评分 -->
1774
+ <sohelp-rate
1775
+ v-else-if="column.type==='SohelpRate'"
1776
+ v-model="row[name]"
1777
+ v-bind="column.editRender"
1778
+ :disabled="!column.editRender.edit"
1779
+ show-score
1780
+ score-template="{value} 分"
1781
+ style="min-width: 150px"
1782
+ />
1788
1783
 
1789
- <!-- 开关 -->
1790
- <div v-else-if="column.type==='SohelpSwitch' || column.type === 'SohelpCheckbox'">
1791
- <span v-if="!column.editRender.edit">
1792
- {{ !!row[name] ? "V" : "" }}
1793
- </span>
1794
- <sohelp-switch
1784
+ <!-- 进度 -->
1785
+ <sohelp-process
1786
+ v-else-if="column.type==='SohelpProcess'"
1795
1787
  v-model="row[name]"
1796
1788
  v-bind="column.editRender"
1797
- style="width: 100%;"
1798
- v-else
1799
- :activeValue="1"
1800
- :inactiveValue="0"
1789
+ style="width: 100%"
1790
+ :readonly="!column.editRender.edit"
1801
1791
  />
1802
- </div>
1803
1792
 
1804
- <!-- 文本域 -->
1805
- <p
1806
- style="margin: 0;"
1807
- class="textarea-reference"
1808
- @click="showTextareaModal(column, name, row)"
1809
- v-bind="column.editRender"
1810
- v-else-if="column.type === 'SohelpTextarea'"
1811
- >{{ row[name] }}
1812
- </p>
1813
-
1814
- <!-- 外键关联 -->
1815
- <div v-else-if="column.type === 'RELATION' || column.type === 'SohelpTableSelect'">
1816
- {{ gridData[rowIndex][name]?.[column?.editRender?.labelField] || "" }}
1817
- </div>
1818
1793
 
1819
- <!-- 富文本 -->
1820
- <div v-else-if="column.type === 'SohelpRichText'" v-html="row[name]"></div>
1794
+ <!-- 下拉用户选择 -->
1795
+ <div v-else-if="column.type === 'SohelpUserSelect'">
1796
+ {{ gridData[rowIndex][name]?.["user_name"] }}
1797
+ </div>
1798
+
1799
+ <!-- 下拉组织选择 -->
1800
+ <div v-else-if="column.type === 'SohelpOrgTreeSelect'">
1801
+ {{ gridData[rowIndex][name]?.["org_name"] }}
1802
+ </div>
1803
+
1804
+ <!-- 开关 -->
1805
+ <div v-else-if="column.type==='SohelpSwitch' || column.type === 'SohelpCheckbox'">
1806
+ <span v-if="!column.editRender.edit">
1807
+ {{ !!row[name] ? "V" : "" }}
1808
+ </span>
1809
+ <sohelp-switch
1810
+ v-model="row[name]"
1811
+ v-bind="column.editRender"
1812
+ style="width: 100%;"
1813
+ v-else
1814
+ :activeValue="1"
1815
+ :inactiveValue="0"
1816
+ />
1817
+ </div>
1821
1818
 
1822
- <div v-else>
1823
- {{ row[name] }}
1824
- </div>
1819
+ <!-- 文本域 -->
1820
+ <p
1821
+ style="margin: 0;"
1822
+ class="textarea-reference"
1823
+ @click="showTextareaModal(column, name, row)"
1824
+ v-bind="column.editRender"
1825
+ v-else-if="column.type === 'SohelpTextarea'"
1826
+ >{{ row[name] }}
1827
+ </p>
1828
+
1829
+ <!-- 外键关联 -->
1830
+ <div v-else-if="column.type === 'RELATION' || column.type === 'SohelpTableSelect'">
1831
+ {{ gridData[rowIndex][name]?.[column?.editRender?.labelField] || "" }}
1832
+ </div>
1825
1833
 
1834
+ <!-- 富文本 -->
1835
+ <div v-else-if="column.type === 'SohelpRichText'" v-html="row[name]"></div>
1836
+
1837
+ <div v-else>
1838
+ {{ row[name] }}
1839
+ </div>
1840
+ </div>
1826
1841
  </template>
1827
1842
 
1828
1843
  <!-- 可编辑状态 -->
@@ -40,7 +40,7 @@ export default {
40
40
  editConfig: {
41
41
  trigger: 'click',
42
42
  mode: 'cell',
43
- autoClear: false,
43
+ autoClear: true,
44
44
  autoFocus: true,
45
45
  showInsertStatus: true,
46
46
  showUpdateStatus: true
@@ -185,7 +185,7 @@ const filterFieldsByProperties = (_data) => {
185
185
  };
186
186
 
187
187
  let validProperties = Object.fromEntries(
188
- data.properties.filter((item) => item.name && !item.hidden)?.map((item) => [item.name, item.label])
188
+ data.properties?.filter((item) => item.name && !item.hidden)?.map((item) => [item.name, item.label])
189
189
  );
190
190
 
191
191
  data.list = filterArray(data.list).filter((item) => {
@@ -196,7 +196,7 @@ const filterFieldsByProperties = (_data) => {
196
196
 
197
197
  //过滤掉不在列表中的sort属性
198
198
  data.filter.sort = filterArray(data.filter.sort.filter((item) => data.list.some((f) => f === item)));
199
- data.properties = data.properties.filter((item) => item.name && !item.hidden);
199
+ data.properties = data.properties?.filter((item) => item.name && !item.hidden);
200
200
 
201
201
  data.filter.field = data.filter.field.filter((item) => {
202
202
  return item.name in validProperties;
@@ -346,7 +346,7 @@ export function useSohelpGridConfig() {
346
346
  var batchButtonsIndex = -1;
347
347
  const DefaultGridOptions = reactive(deepClone(_DefaultGridOptions));
348
348
  /**获取列表配置*/
349
- const config = isGridConfig ? await moduleCache.getGrid(_refid) : await moduleCache.getEntityGrid(_refid);
349
+ const config = await moduleCache.getGrid(_refid);
350
350
 
351
351
  if (!config) {
352
352
  throw new Error(_refid + ' : 没有发现网格列表配置!');