vue2-client 1.18.27 → 1.18.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.18.27",
3
+ "version": "1.18.28",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -66,6 +66,7 @@
66
66
  :query-params-json="queryParamsJson"
67
67
  :show-pagination="showPagination"
68
68
  :customDelete="customDelete"
69
+ :autoSave="autoSave"
69
70
  :extraHeight="extraHeight"
70
71
  :serviceName="serviceName"
71
72
  :pageMaxSize="realQueryConfig.queryPagesSize"
@@ -135,6 +136,7 @@
135
136
  :query-params-json="queryParamsJson"
136
137
  :show-pagination="showPagination"
137
138
  :customDelete="customDelete"
139
+ :autoSave="autoSave"
138
140
  :extraHeight="extraHeight"
139
141
  :serviceName="serviceName"
140
142
  :pageMaxSize="realQueryConfig.queryPagesSize"
@@ -208,17 +210,17 @@ import XAddReport from '@vue2-client/base-client/components/common/XAddReport'
208
210
  import XTable from '@vue2-client/base-client/components/common/XTable'
209
211
  import XTree from '@vue2-client/base-client/components/common/XTree'
210
212
  import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
211
- import { Splitpanes, Pane } from 'splitpanes'
213
+ import {Splitpanes, Pane} from 'splitpanes'
212
214
  import 'splitpanes/dist/splitpanes.css'
213
215
  import {
214
216
  getConfigByName,
215
217
  getConfigByLogic,
216
218
  parseConfig, runLogic, getConfigByNameAsync,
217
219
  } from '@vue2-client/services/api/common'
218
- import { mapState } from 'vuex'
220
+ import {mapState} from 'vuex'
219
221
  import XTreePro from '@vue2-client/base-client/components/common/XTree/XTreePro.vue'
220
- import { executeStrFunctionByContext } from '@vue2-client/utils/runEvalFunction'
221
- import { getRealKeyData } from '@vue2-client/utils/util'
222
+ import {executeStrFunctionByContext} from '@vue2-client/utils/runEvalFunction'
223
+ import {getRealKeyData} from '@vue2-client/utils/util'
222
224
  import * as util from '@vue2-client/utils/util'
223
225
  import UserInfoDetailManage from '@vue2-client/pages/userInfoDetailManage/index.vue'
224
226
 
@@ -236,7 +238,7 @@ export default {
236
238
  Splitpanes,
237
239
  Pane
238
240
  },
239
- provide () {
241
+ provide() {
240
242
  return {
241
243
  getSelf: () => this,
242
244
  emitEvent: this.emitEvent.bind(this)
@@ -282,7 +284,7 @@ export default {
282
284
  currUser: {
283
285
  default: () => {
284
286
  console.warn('currUser is not provided.')
285
- return { id: null, name: 'Guest' }
287
+ return {id: null, name: 'Guest'}
286
288
  },
287
289
  },
288
290
 
@@ -302,7 +304,7 @@ export default {
302
304
  }
303
305
  }
304
306
  },
305
- data () {
307
+ data() {
306
308
  return {
307
309
  // 加载状态
308
310
  loading: false,
@@ -417,6 +419,13 @@ export default {
417
419
  return false
418
420
  }
419
421
  },
422
+ // 行编辑模式自动数据切换自动保存
423
+ autoSave: {
424
+ type: Boolean,
425
+ default: () => {
426
+ return false
427
+ }
428
+ },
420
429
  // 行选择模式
421
430
  rowSelectMode: {
422
431
  type: Boolean,
@@ -519,24 +528,24 @@ export default {
519
528
  },
520
529
  watch: {
521
530
  logicParam: {
522
- handler () {
531
+ handler() {
523
532
  this.initConfig()
524
533
  },
525
534
  deep: true
526
535
  },
527
536
  queryParamsJson: {
528
- handler () {
537
+ handler() {
529
538
  this.initConfig()
530
539
  },
531
540
  deep: true
532
541
  },
533
542
  queryParamsName: {
534
- handler () {
543
+ handler() {
535
544
  this.initConfig()
536
545
  }
537
546
  },
538
547
  serviceName: {
539
- handler () {
548
+ handler() {
540
549
  this.initConfig()
541
550
  }
542
551
  }
@@ -546,20 +555,20 @@ export default {
546
555
  getRealKeyData,
547
556
  getConfigByNameAsync,
548
557
  getConfigByName,
549
- storePaneSize (treeSize) {
558
+ storePaneSize(treeSize) {
550
559
  localStorage.setItem('CURD::' + this.xTreeConfigName + '::TreeSize', treeSize[0].size)
551
560
  },
552
- customEvent (func, data) {
561
+ customEvent(func, data) {
553
562
  this.$emit(func, data)
554
563
  },
555
- columnClick (key, value, record) {
564
+ columnClick(key, value, record) {
556
565
  this.$emit('columnClick', key, value, record)
557
566
  },
558
- gotoUserDetail (key, value, record) {
567
+ gotoUserDetail(key, value, record) {
559
568
  this.$refs.userInfo.init(getRealKeyData(record))
560
569
  },
561
570
  // 获取主表的数据内容,去掉主表别名
562
- getPrimaryData (rows) {
571
+ getPrimaryData(rows) {
563
572
  const alias = this.realQueryConfig.tableAliasName // 获取主表的别名
564
573
  const prefix = `${alias}_` // 构建前缀
565
574
  const result = []
@@ -580,7 +589,7 @@ export default {
580
589
  },
581
590
 
582
591
  // 给数据区域添加主表数据,给的数据没有主表别名,放着时添加主表别名
583
- pushPrimaryData (rows) {
592
+ pushPrimaryData(rows) {
584
593
  const alias = this.realQueryConfig.tableAliasName // 获取主表的别名
585
594
  const prefix = `${alias}_` // 构建前缀
586
595
  const result = rows.map(row => {
@@ -595,7 +604,7 @@ export default {
595
604
  },
596
605
 
597
606
  // 设置固定查询条件,主表别名自动带
598
- setFixedQueryForm (data) {
607
+ setFixedQueryForm(data) {
599
608
  const alias = this.realQueryConfig.tableAliasName // 获取主表的别名
600
609
  const prefixedData = {}
601
610
 
@@ -607,10 +616,10 @@ export default {
607
616
  Object.assign(this.fixedQueryForm, prefixedData)
608
617
  },
609
618
 
610
- importExcelOk (data) {
619
+ importExcelOk(data) {
611
620
  this.$emit('importExcelOk', data)
612
621
  },
613
- initConfig () {
622
+ initConfig() {
614
623
  this.loading = true
615
624
  this.loadError = false
616
625
  if (this.queryParamsName) {
@@ -625,7 +634,7 @@ export default {
625
634
  }
626
635
  },
627
636
 
628
- getConfig () {
637
+ getConfig() {
629
638
  getConfigByName(this.queryParamsName, this.serviceName, (res) => {
630
639
  if (!res) {
631
640
  this.loading = false
@@ -635,7 +644,7 @@ export default {
635
644
  this.updateComponents(res)
636
645
  }, this.env === 'dev')
637
646
  },
638
- getConfigBySource () {
647
+ getConfigBySource() {
639
648
  parseConfig(this.queryParamsJson, 'CRUD_FORM', this.serviceName, this.env === 'dev').then(res => {
640
649
  if (!res) {
641
650
  this.loading = false
@@ -645,7 +654,7 @@ export default {
645
654
  this.updateComponents(res, true)
646
655
  })
647
656
  },
648
- getColumnJsonByLogic () {
657
+ getColumnJsonByLogic() {
649
658
  getConfigByLogic(this.logicName, this.logicParam, this.serviceName, (res) => {
650
659
  if (!res) {
651
660
  this.loading = false
@@ -661,7 +670,7 @@ export default {
661
670
  * @param res 参数
662
671
  * @param setQueryParams 是否设置queryParams参数
663
672
  */
664
- updateComponents (res, setQueryParams) {
673
+ updateComponents(res, setQueryParams) {
665
674
  this.realQueryConfig = res
666
675
  // 读取表格展示模式配置
667
676
  this.tableShowMode = res.tableShowMode || 'default'
@@ -693,6 +702,7 @@ export default {
693
702
  buttonState: Object.assign(res.buttonState, this.buttonState),
694
703
  title: this.title || res.title,
695
704
  viewMode: this.viewMode,
705
+ autoSave: this.autoSave,
696
706
  localEditMode: localEditMode,
697
707
  rowSelectMode: this.rowSelectMode,
698
708
  allowSelectRowNum: this.allowSelectRowNum,
@@ -735,7 +745,7 @@ export default {
735
745
  this.loading = false
736
746
  },
737
747
  // 自定义按钮
738
- editButtonStateDataClick (functionName, rows) {
748
+ editButtonStateDataClick(functionName, rows) {
739
749
  console.log('functionName', functionName)
740
750
  console.log('rows', rows)
741
751
  this.$emit(functionName, rows)
@@ -745,7 +755,7 @@ export default {
745
755
  * 提交查询表单事件
746
756
  * @param res 参数
747
757
  */
748
- onSearchSubmit (res) {
758
+ onSearchSubmit(res) {
749
759
  if (res.valid) {
750
760
  // 如果是弹框模式,显示表单加载动画,不立即打开弹框
751
761
  if (this.tableShowMode === 'popup') {
@@ -765,11 +775,11 @@ export default {
765
775
  /**
766
776
  * 关闭表格弹框
767
777
  */
768
- closeTableModal () {
778
+ closeTableModal() {
769
779
  this.tableModalVisible = false
770
780
  },
771
781
 
772
- active (props) {
782
+ active(props) {
773
783
  let num = false
774
784
  for (const key in props) {
775
785
  // eslint-disable-next-line no-prototype-builtins
@@ -789,7 +799,7 @@ export default {
789
799
  /**
790
800
  * 提交新增/修改表单后事件
791
801
  */
792
- onAddOrEditSubmitAfterSubmit (res) {
802
+ onAddOrEditSubmitAfterSubmit(res) {
793
803
  this.refreshTable(res.businessType === '新增')
794
804
  // commit
795
805
  this.$emit('afterSubmit', res)
@@ -799,7 +809,7 @@ export default {
799
809
  * @param res 参数(可能是 Promise)
800
810
  * @param conditionParams 查询条件
801
811
  */
802
- async afterQuery (res, conditionParams) {
812
+ async afterQuery(res, conditionParams) {
803
813
  // 如果是弹框模式且正在查询中
804
814
  if (this.tableShowMode === 'popup' && this.formQueryLoading) {
805
815
  // 兼容 Promise
@@ -827,20 +837,20 @@ export default {
827
837
  * @param actionType 操作类型
828
838
  * @param fun 向上级传递的事件
829
839
  */
830
- action (record, id, actionType, fun = 'action', index) {
840
+ action(record, id, actionType, fun = 'action', index) {
831
841
  this.$emit('innerXFormTableEmit', fun, record, id, actionType, index, this)
832
842
  this.$emit(fun, record, id, actionType, index, this)
833
843
  },
834
- treeOnChecked (checkedKeys, deepNodes, deepKeys) {
844
+ treeOnChecked(checkedKeys, deepNodes, deepKeys) {
835
845
  this.$emit('treeOnChecked', checkedKeys, deepNodes, deepKeys)
836
846
  },
837
- treeBtnFuncClick (index, func) {
847
+ treeBtnFuncClick(index, func) {
838
848
  this.$emit('treeBtnFuncClick', index, func)
839
849
  },
840
850
  /**
841
851
  * 新增按钮事件
842
852
  */
843
- add () {
853
+ add() {
844
854
  if (this.customAdd) {
845
855
  this.$emit('add')
846
856
  } else {
@@ -851,7 +861,7 @@ export default {
851
861
  }
852
862
  }
853
863
  },
854
- addFormInit () {
864
+ addFormInit() {
855
865
  const res = this.realQueryConfig
856
866
  const localEditMode = !this.localEditMode ? res.localEditMode : this.localEditMode
857
867
  this.$refs.xAddForm.init({
@@ -876,7 +886,7 @@ export default {
876
886
  /**
877
887
  * 添加按钮事件
878
888
  */
879
- move () {
889
+ move() {
880
890
  this.moveType = true
881
891
  this.$nextTick(
882
892
  () => {
@@ -891,7 +901,7 @@ export default {
891
901
  * 修改按钮事件
892
902
  * @param modifyModelData 修改表单数据
893
903
  */
894
- edit (modifyModelData) {
904
+ edit(modifyModelData) {
895
905
  if (this.customEdit) {
896
906
  this.$emit('edit')
897
907
  } else {
@@ -919,7 +929,7 @@ export default {
919
929
  /**
920
930
  * 删除按钮事件
921
931
  */
922
- del (keys, callback) {
932
+ del(keys, callback) {
923
933
  if (this.customDelete) {
924
934
  this.$emit('del', keys, callback)
925
935
  }
@@ -928,14 +938,14 @@ export default {
928
938
  * 删除后事件
929
939
  * @param res
930
940
  */
931
- afterDelete (res) {
941
+ afterDelete(res) {
932
942
  this.$emit('afterDelete', res)
933
943
  },
934
944
  /**
935
945
  * 行选择事件
936
946
  * @param row 选中行
937
947
  */
938
- rowChoose (row) {
948
+ rowChoose(row) {
939
949
  this.$emit('rowChoose', row)
940
950
  },
941
951
  /**
@@ -943,13 +953,13 @@ export default {
943
953
  * @param currRow 当前行
944
954
  * @param defaultAppendRowData 默认追加的行数据
945
955
  */
946
- validateTableAndSyncData (currRow, defaultAppendRowData) {
956
+ validateTableAndSyncData(currRow, defaultAppendRowData) {
947
957
  this.$refs.xTable.validateTableAndSyncData(currRow, defaultAppendRowData)
948
958
  },
949
959
  /**
950
960
  * 更多条件是否展示
951
961
  */
952
- toggleAdvanced () {
962
+ toggleAdvanced() {
953
963
  // 只有在非弹出模式下才需要调整表格滚动高度
954
964
  if (this.tableShowMode !== 'popup') {
955
965
  this.$refs.xTable.setScrollYHeight({})
@@ -958,7 +968,7 @@ export default {
958
968
  /**
959
969
  * 查询表单部分显示/隐藏切换
960
970
  */
961
- toggleIsFormShow () {
971
+ toggleIsFormShow() {
962
972
  this.toggleIsFormIcon = this.toggleIsFormIcon === 'vertical-align-top' ? 'vertical-align-bottom' : 'vertical-align-top'
963
973
  this.$refs.xForm.toggleVisible()
964
974
  // 只有在非弹出模式下才需要调整表格滚动高度
@@ -971,7 +981,7 @@ export default {
971
981
  * @param selectedRowKeys 选中列Key集合
972
982
  * @param selectedRows 选中列
973
983
  */
974
- selectRow (selectedRowKeys, selectedRows) {
984
+ selectRow(selectedRowKeys, selectedRows) {
975
985
  this.table_selectedRowKeys = selectedRowKeys
976
986
  this.table_selectedRows = selectedRows
977
987
  this.$emit('selectRow', selectedRowKeys, selectedRows)
@@ -979,14 +989,14 @@ export default {
979
989
  /**
980
990
  * 清除勾选数据
981
991
  */
982
- clearRowKeys () {
992
+ clearRowKeys() {
983
993
  this.$refs.xTable.clearRowKeys()
984
994
  },
985
995
  /**
986
996
  * 刷新表格
987
997
  * @param toFirstPage 是否到第一页
988
998
  */
989
- refreshTable (toFirstPage = true) {
999
+ refreshTable(toFirstPage = true) {
990
1000
  if (this.tableShowMode === 'popup') {
991
1001
  this.formQueryLoading = true
992
1002
  }
@@ -996,7 +1006,7 @@ export default {
996
1006
  * 刷新表格
997
1007
  * @param toFirstPage 是否到第一页
998
1008
  */
999
- refresh (toFirstPage = true) {
1009
+ refresh(toFirstPage = true) {
1000
1010
  if (this.tableShowMode === 'popup') {
1001
1011
  this.formQueryLoading = true
1002
1012
  }
@@ -1005,7 +1015,7 @@ export default {
1005
1015
  /**
1006
1016
  * 主动传递条件查询表格
1007
1017
  */
1008
- queryTable (conditionParams) {
1018
+ queryTable(conditionParams) {
1009
1019
  if (this.tableShowMode === 'popup') {
1010
1020
  this.formQueryLoading = true
1011
1021
  }
@@ -1014,30 +1024,30 @@ export default {
1014
1024
  /**
1015
1025
  * 向外暴露 resetForm 函数
1016
1026
  */
1017
- resetForm () {
1027
+ resetForm() {
1018
1028
  this.$refs.xForm.resetForm()
1019
1029
  },
1020
1030
  /**
1021
1031
  * 获取表格数据
1022
1032
  */
1023
- getTableData () {
1033
+ getTableData() {
1024
1034
  return this.$refs.xTable.getTableData()
1025
1035
  },
1026
1036
  // 在行编辑等情况下,让界面生效
1027
- update () {
1037
+ update() {
1028
1038
  this.getTableData().push(...[])
1029
1039
  },
1030
1040
 
1031
1041
  /**
1032
1042
  * 设置表格数据
1033
1043
  */
1034
- setTableData (data) {
1044
+ setTableData(data) {
1035
1045
  this.$refs.xTable.setTableData(data)
1036
1046
  },
1037
1047
  /**
1038
1048
  * 表单本地提交
1039
1049
  */
1040
- onLocalSubmit (res, callback) {
1050
+ onLocalSubmit(res, callback) {
1041
1051
  const form = res.realForm
1042
1052
  if (res.businessType === '新增') {
1043
1053
  this.$refs.xTable.appendLocalData(form)
@@ -1050,25 +1060,25 @@ export default {
1050
1060
  callback()
1051
1061
  }
1052
1062
  },
1053
- emitFunc (func, ...args) {
1063
+ emitFunc(func, ...args) {
1054
1064
  this.$emit(func, ...args)
1055
1065
  this.$emit('getEmitFuncData', func, ...args)
1056
1066
  },
1057
1067
  // 直接转发事件的函数
1058
- emitEvent (event, ...args) {
1068
+ emitEvent(event, ...args) {
1059
1069
  this.$emit(event, ...args)
1060
1070
  },
1061
1071
  // 添加处理 rowClick 的方法
1062
- handleRowClick (record) {
1072
+ handleRowClick(record) {
1063
1073
  this.$emit('rowClick', record)
1064
1074
  },
1065
- handleRowDblClick (record) {
1075
+ handleRowDblClick(record) {
1066
1076
  this.$emit('rowDblClick', record)
1067
1077
  },
1068
- beforeDataChange (record) {
1078
+ beforeDataChange(record) {
1069
1079
  this.$emit('beforeDataChange', record)
1070
1080
  },
1071
- onExpand (expanded, record) {
1081
+ onExpand(expanded, record) {
1072
1082
  this.$emit('expand', expanded, record)
1073
1083
  }
1074
1084
  },
@@ -1076,7 +1086,7 @@ export default {
1076
1086
  /**
1077
1087
  * 实现doAction方法
1078
1088
  */
1079
- doAction (actionType, args, data) {
1089
+ doAction(actionType, args, data) {
1080
1090
  switch (actionType) {
1081
1091
  case 'refreshTable':
1082
1092
  for (const item in args) {
@@ -1088,7 +1098,7 @@ export default {
1088
1098
  }
1089
1099
  }
1090
1100
  },
1091
- mounted () {
1101
+ mounted() {
1092
1102
  if (!this.isMounted) {
1093
1103
  // 防止多次调用
1094
1104
  // 不知道为啥他会执行两次 mounted 暂时处理方式
@@ -1109,8 +1119,8 @@ export default {
1109
1119
  Object.assign(this.fixedAddForm, data)
1110
1120
  Object.assign(this.fixedQueryForm, data)
1111
1121
  } else {
1112
- Object.assign(this.fixedAddForm, { selected_id: selectedId })
1113
- Object.assign(this.fixedQueryForm, { selected_id: selectedId })
1122
+ Object.assign(this.fixedAddForm, {selected_id: selectedId})
1123
+ Object.assign(this.fixedQueryForm, {selected_id: selectedId})
1114
1124
  }
1115
1125
  }
1116
1126
  }
@@ -1125,6 +1135,7 @@ export default {
1125
1135
  line-height: 32px;
1126
1136
  margin-bottom: 12px;
1127
1137
  }
1138
+
1128
1139
  // 表格行样式类型
1129
1140
  .ant-table-tbody {
1130
1141
  // 成功样式 - 绿色 (#52c41a)
@@ -1155,13 +1166,13 @@ export default {
1155
1166
 
1156
1167
  // 警告样式 - 黄色 (#faad14)
1157
1168
  .ant-table-row-warning {
1158
- background-color: rgba(250, 173, 20, 0.1) ;
1169
+ background-color: rgba(250, 173, 20, 0.1);
1159
1170
 
1160
1171
  &:hover {
1161
- background-color: rgba(250, 173, 20, 0.15) ;
1172
+ background-color: rgba(250, 173, 20, 0.15);
1162
1173
 
1163
1174
  td {
1164
- background-color: transparent ;
1175
+ background-color: transparent;
1165
1176
  }
1166
1177
  }
1167
1178
 
@@ -1175,65 +1186,65 @@ export default {
1175
1186
  }
1176
1187
 
1177
1188
  td {
1178
- background-color: transparent ;
1189
+ background-color: transparent;
1179
1190
  }
1180
1191
  }
1181
1192
 
1182
1193
  // 错误样式 - 红色 (#f5222f)
1183
1194
  .ant-table-row-error {
1184
- background-color: rgba(245, 34, 47, 0.1) ;
1195
+ background-color: rgba(245, 34, 47, 0.1);
1185
1196
 
1186
1197
  &:hover {
1187
- background-color: rgba(245, 34, 47, 0.15) ;
1198
+ background-color: rgba(245, 34, 47, 0.15);
1188
1199
 
1189
1200
  td {
1190
- background-color: transparent ;
1201
+ background-color: transparent;
1191
1202
  }
1192
1203
  }
1193
1204
 
1194
1205
  // 选中状态
1195
1206
  &.ant-table-row-selected {
1196
- background-color: rgba(245, 34, 47, 0.2) ;
1207
+ background-color: rgba(245, 34, 47, 0.2);
1197
1208
 
1198
1209
  td {
1199
- background-color: transparent ;
1210
+ background-color: transparent;
1200
1211
  }
1201
1212
  }
1202
1213
 
1203
1214
  td {
1204
- background-color: transparent ;
1215
+ background-color: transparent;
1205
1216
  }
1206
1217
  }
1207
1218
 
1208
1219
  // 魔法样式 - 紫色
1209
1220
  .ant-table-row-magic {
1210
- background-color: rgba(114, 46, 209, 0.1) ;
1221
+ background-color: rgba(114, 46, 209, 0.1);
1211
1222
 
1212
1223
  &:hover {
1213
- background-color: rgba(114, 46, 209, 0.15) ;
1224
+ background-color: rgba(114, 46, 209, 0.15);
1214
1225
 
1215
1226
  td {
1216
- background-color: transparent ;
1227
+ background-color: transparent;
1217
1228
  }
1218
1229
  }
1219
1230
 
1220
1231
  // 选中状态
1221
1232
  &.ant-table-row-selected {
1222
- background-color: rgba(114, 46, 209, 0.2) ;
1233
+ background-color: rgba(114, 46, 209, 0.2);
1223
1234
 
1224
1235
  td {
1225
- background-color: transparent ;
1236
+ background-color: transparent;
1226
1237
  }
1227
1238
  }
1228
1239
 
1229
1240
  td {
1230
- background-color: transparent ;
1241
+ background-color: transparent;
1231
1242
  }
1232
1243
  }
1233
1244
 
1234
1245
  // 默认选中状态(没有特殊行样式时)
1235
1246
  .ant-table-row-selected:not(.ant-table-row-success):not(.ant-table-row-warning):not(.ant-table-row-error):not(.ant-table-row-magic) {
1236
- background-color: rgba(24, 144, 255, 0.1) ;
1247
+ background-color: rgba(24, 144, 255, 0.1);
1237
1248
  }
1238
1249
  }
1239
1250
  </style>
@@ -519,6 +519,11 @@ export default {
519
519
  return {}
520
520
  }
521
521
  },
522
+ // 行编辑模式自动数据切换自动保存
523
+ autoSave:{
524
+ type: Boolean,
525
+ default: false
526
+ },
522
527
  // 数据只有一页时是否展示分页,true:展示,auto:隐藏
523
528
  showPagination: {
524
529
  type: Boolean,
@@ -687,12 +692,12 @@ export default {
687
692
  })
688
693
  })
689
694
  },
690
- onCancel () {
695
+ onCancel() {
691
696
  }
692
697
  })
693
698
  }
694
699
  },
695
- importExcelOk (data) {
700
+ importExcelOk(data) {
696
701
  this.refresh(true)
697
702
  this.$emit('importExcelOk', data)
698
703
  },
@@ -701,7 +706,7 @@ export default {
701
706
  * @param row 选中行集合
702
707
  * @param attr 表单项属性
703
708
  */
704
- async rowChoose (row, attr, callback, record) {
709
+ async rowChoose(row, attr, callback, record) {
705
710
  // 如果配置了自定义函数
706
711
  if (attr.dataChangeFunc) {
707
712
  await executeStrFunction(attr.dataChangeFunc, [record, this.setForm, {
@@ -716,7 +721,7 @@ export default {
716
721
  callback()
717
722
  }
718
723
  },
719
- setForm (record, obj) {
724
+ setForm(record, obj) {
720
725
  Object.assign(record, obj)
721
726
  this.$forceUpdate()
722
727
  },
@@ -725,7 +730,7 @@ export default {
725
730
  * @param {Number} rowIndex 行索引
726
731
  * @param {String} fieldName 字段名
727
732
  */
728
- focusInput (rowIndex, fieldName) {
733
+ focusInput(rowIndex, fieldName) {
729
734
  this.$nextTick(() => {
730
735
  // 构造 ID:{rowIndex}-{fieldName}input
731
736
  const inputId = `${rowIndex}-${fieldName}input`
@@ -760,16 +765,16 @@ export default {
760
765
  * 处理表单项事件,向外抛出事件供开发者处理
761
766
  * @param {Object} context 增强的上下文数据
762
767
  */
763
- handleFormItemEvent (context) {
764
- const { func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex } = context
768
+ handleFormItemEvent(context) {
769
+ const {func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex} = context
765
770
 
766
771
  // 向外抛出事件,参数顺序:func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex
767
772
  this.$emit('x-form-item-emit-func', func, attr, value, currentRecord, currentIndex, nextRecord, nextIndex)
768
773
  },
769
- handleResize () {
774
+ handleResize() {
770
775
  this.setScrollYHeight({})
771
776
  },
772
- isInAModal () {
777
+ isInAModal() {
773
778
  let parent = this.$parent
774
779
  while (parent) {
775
780
  // 检查组件名称,这里假设a-modal组件的名称为AModal,根据实际情况可能需要调整
@@ -782,7 +787,7 @@ export default {
782
787
  },
783
788
  executeStrFunction,
784
789
  // 切换看板模式和表格模式
785
- changeViewMode () {
790
+ changeViewMode() {
786
791
  this.isTableMode = !this.isTableMode
787
792
  // 看板切换回表格模式 刷新列表
788
793
  this.refresh(true)
@@ -790,7 +795,7 @@ export default {
790
795
  /**
791
796
  * 初始化表格参数
792
797
  */
793
- init (params) {
798
+ init(params) {
794
799
  const {
795
800
  // 查询参数对象, 用于没有对应查询配置文件名时
796
801
  queryParams,
@@ -964,7 +969,7 @@ export default {
964
969
  }
965
970
  },
966
971
  // 操作面板按钮渲染
967
- buttonRendering (button) {
972
+ buttonRendering(button) {
968
973
  if (!this.buttonPermissions) {
969
974
  return true
970
975
  }
@@ -983,7 +988,7 @@ export default {
983
988
  }
984
989
  },
985
990
  // 防止查询多次点击处理
986
- loadTableData (requestParameters) {
991
+ loadTableData(requestParameters) {
987
992
  if (this.queryPromise) {
988
993
  return this.queryPromise
989
994
  }
@@ -996,11 +1001,11 @@ export default {
996
1001
  * 加载表格数据
997
1002
  * @param requestParameters 请求参数
998
1003
  */
999
- async loadTableDataGen (requestParameters) {
1004
+ async loadTableDataGen(requestParameters) {
1000
1005
  let result
1001
1006
  if (this.localEditMode) {
1002
1007
  if (!this.isLocalDataSourceLoadedExternally && requestParameters?.conditionParams && Object.keys(requestParameters?.conditionParams).length > 0) {
1003
- const result = await query(Object.assign(requestParameters, { userId: this.currUser?.id }),
1008
+ const result = await query(Object.assign(requestParameters, {userId: this.currUser?.id}),
1004
1009
  this.serviceName, this.env === 'dev')
1005
1010
  if (result.data) {
1006
1011
  let no = 0
@@ -1018,7 +1023,7 @@ export default {
1018
1023
  })
1019
1024
  })
1020
1025
  } else {
1021
- result = query(Object.assign(requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
1026
+ result = query(Object.assign(requestParameters, {userId: this.currUser?.id}), this.serviceName, this.env === 'dev')
1022
1027
  result.then(res => {
1023
1028
  this.totalCount = res.totalCount || 0
1024
1029
 
@@ -1077,11 +1082,11 @@ export default {
1077
1082
  * @param func 事件默认 action
1078
1083
  * @param index 行下标
1079
1084
  */
1080
- action (record, actionType, func = 'action', index) {
1085
+ action(record, actionType, func = 'action', index) {
1081
1086
  this.$emit('action', record, record[this.getPrimaryKeyName()], actionType, func, index)
1082
1087
  },
1083
1088
  // 看板点击事件
1084
- handleCardEmit (data, eventName) {
1089
+ handleCardEmit(data, eventName) {
1085
1090
  this.action(data, undefined, eventName)
1086
1091
  },
1087
1092
  /**
@@ -1091,7 +1096,7 @@ export default {
1091
1096
  * @param selectedRows 被选择的列集合
1092
1097
  * @param nativeEvent 原生事件
1093
1098
  */
1094
- onSelect (record, selected, selectedRows, nativeEvent) {
1099
+ onSelect(record, selected, selectedRows, nativeEvent) {
1095
1100
  console.log('onSelect', record, selected, selectedRows)
1096
1101
  if (this.selectRowMode === 'listView') {
1097
1102
  const primaryKeyName = this.primaryKey || this.rowKey
@@ -1110,7 +1115,7 @@ export default {
1110
1115
  * @param selectedRows 被选择的列集合
1111
1116
  * @param changeRows 改变的行集合
1112
1117
  */
1113
- onSelectAll (selected, selectedRows, changeRows) {
1118
+ onSelectAll(selected, selectedRows, changeRows) {
1114
1119
  console.log('onSelectAll', selected, selectedRows, changeRows)
1115
1120
  if (this.selectRowMode === 'listView') {
1116
1121
  if (!selected) {
@@ -1127,7 +1132,7 @@ export default {
1127
1132
  * @param currentPageSelectedKeys 被选择的列Key集合
1128
1133
  * @param currentPageSelectedRows 被选择的列集合
1129
1134
  */
1130
- onSelectChange (currentPageSelectedKeys, currentPageSelectedRows) {
1135
+ onSelectChange(currentPageSelectedKeys, currentPageSelectedRows) {
1131
1136
  if (this.selectRowMode === 'listView' && !this.clearSelectRowAfterQuery) {
1132
1137
  const primaryKeyName = this.primaryKey || this.rowKey
1133
1138
  if (primaryKeyName) {
@@ -1187,13 +1192,13 @@ export default {
1187
1192
  /**
1188
1193
  * 清除表格选中项
1189
1194
  */
1190
- clearRowKeys () {
1195
+ clearRowKeys() {
1191
1196
  this.$refs.table.clearSelected()
1192
1197
  },
1193
1198
  /**
1194
1199
  * 为表格附加查询条件
1195
1200
  */
1196
- setQueryForm (form = {}) {
1201
+ setQueryForm(form = {}) {
1197
1202
  this.form = form
1198
1203
  if (this.createdQuery) {
1199
1204
  this.refresh(true)
@@ -1204,7 +1209,7 @@ export default {
1204
1209
  /**
1205
1210
  * 主动传递条件查询表格
1206
1211
  */
1207
- async queryTable (conditionParams) {
1212
+ async queryTable(conditionParams) {
1208
1213
  // 备份一下 form 这个函数传递的 condition 仅临时用一下
1209
1214
  // 如果要实质修改 form 需要在 x-form 中赋值
1210
1215
  const _from = JSON.parse(JSON.stringify(this.form))
@@ -1217,12 +1222,12 @@ export default {
1217
1222
  * 表格重新加载方法
1218
1223
  * 如果参数为 true, 则强制刷新到第一页
1219
1224
  */
1220
- refresh (bool) {
1225
+ refresh(bool) {
1221
1226
  this.$nextTick(() => {
1222
1227
  this.$refs.table.refresh(bool)
1223
1228
  })
1224
1229
  },
1225
- setScrollYHeight ({ extraHeight = this.extraHeight, id = this.uniqueId, type = '' }) {
1230
+ setScrollYHeight({extraHeight = this.extraHeight, id = this.uniqueId, type = ''}) {
1226
1231
  this.$nextTick(() => {
1227
1232
  debounce(() => {
1228
1233
  const curDocument = window?.rawDocument || document
@@ -1278,17 +1283,17 @@ export default {
1278
1283
  /**
1279
1284
  * 获取主键列名称
1280
1285
  */
1281
- getPrimaryKeyName () {
1286
+ getPrimaryKeyName() {
1282
1287
  if (this.primaryKey) {
1283
1288
  return this.primaryKey
1284
1289
  }
1285
1290
  const indexColumn = this.tableColumns.find(i => i?.slotType === 'index')
1286
1291
  return indexColumn ? indexColumn.dataIndex : this.tableColumns[0].dataIndex
1287
1292
  },
1288
- handleExport (type) {
1293
+ handleExport(type) {
1289
1294
  this.$refs.exportExcel.handleExport(type, this.title)
1290
1295
  },
1291
- handlePrint (type) {
1296
+ handlePrint(type) {
1292
1297
  const printData = {
1293
1298
  title: this.title,
1294
1299
  form: this.form,
@@ -1298,7 +1303,7 @@ export default {
1298
1303
  }
1299
1304
  this.$refs.exportExcel.handlePrint(type, printData)
1300
1305
  },
1301
- validateTableAndSyncData (currRow, defaultAppendRowData) {
1306
+ validateTableAndSyncData(currRow, defaultAppendRowData) {
1302
1307
  let isLastRow = false
1303
1308
  if (this.localEditModeDataSource.length === 0) {
1304
1309
  isLastRow = true
@@ -1310,7 +1315,7 @@ export default {
1310
1315
  }
1311
1316
  },
1312
1317
  // 新增业务
1313
- add () {
1318
+ add() {
1314
1319
  if (this.eventState?.customAdd) {
1315
1320
  this.custom('customAdd', {})
1316
1321
  return
@@ -1322,19 +1327,19 @@ export default {
1322
1327
  }
1323
1328
  },
1324
1329
  // 添加业务
1325
- move () {
1330
+ move() {
1326
1331
  this.$emit('move')
1327
1332
  },
1328
1333
  // 通用事件业务
1329
- custom (func) {
1334
+ custom(func) {
1330
1335
  this.$emit('customEvent', func)
1331
1336
  },
1332
1337
  // 编辑业务
1333
- edit (id) {
1338
+ edit(id) {
1334
1339
  this.editLoading = true
1335
1340
  this.getEditData(id).then(modifyModelData => {
1336
1341
  if (this.eventState?.customEdit) {
1337
- this.custom('customEdit', { id, modifyModelData })
1342
+ this.custom('customEdit', {id, modifyModelData})
1338
1343
  return
1339
1344
  }
1340
1345
  this.$emit('edit', modifyModelData)
@@ -1342,7 +1347,7 @@ export default {
1342
1347
  })
1343
1348
  },
1344
1349
  // 行选择业务
1345
- choose () {
1350
+ choose() {
1346
1351
  if (this.isChoose) {
1347
1352
  // 如果配置了自定义函数
1348
1353
  this.$emit('rowChoose', this.selectedRows)
@@ -1351,11 +1356,11 @@ export default {
1351
1356
  }
1352
1357
  },
1353
1358
  // 自定义按钮点击
1354
- editButtonStateDataClick (index) {
1359
+ editButtonStateDataClick(index) {
1355
1360
  this.$emit('editButtonStateDataClick', this.editButtonStateData[index].functionName, this.selectedRows)
1356
1361
  },
1357
1362
  // 获取被编辑的数据
1358
- getEditData (id) {
1363
+ getEditData(id) {
1359
1364
  if (!id) {
1360
1365
  this.selectId = this.selectedRowKeys[0]
1361
1366
  } else {
@@ -1387,11 +1392,11 @@ export default {
1387
1392
  requestParameters.conditionParams[primaryKeyName] = this.selectId
1388
1393
  requestParameters.f_businessid = this.selectId
1389
1394
  return queryWithResource(requestParameters, this.serviceName, this.env === 'dev').then(res => {
1390
- return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
1395
+ return {data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files}
1391
1396
  })
1392
1397
  },
1393
1398
  // 删除业务
1394
- deleteItem () {
1399
+ deleteItem() {
1395
1400
  if (this.viewMode) {
1396
1401
  this.$message.info('预览模式禁止删除')
1397
1402
  return
@@ -1436,24 +1441,24 @@ export default {
1436
1441
  }
1437
1442
  })
1438
1443
  },
1439
- onCancel () {
1444
+ onCancel() {
1440
1445
  }
1441
1446
  })
1442
1447
  },
1443
1448
  // 导入业务
1444
- importData () {
1449
+ importData() {
1445
1450
  this.$refs.importExcel.importExcelHandleOpen()
1446
1451
  },
1447
- afterVisibleChange (val) {
1452
+ afterVisibleChange(val) {
1448
1453
  if (val) {
1449
1454
  this.retrieveSummaryData()
1450
1455
  }
1451
1456
  },
1452
- async retrieveSummaryData () {
1457
+ async retrieveSummaryData() {
1453
1458
  const promises = []
1454
1459
 
1455
1460
  if (this.requestParameters.querySummary) {
1456
- const querySummaryPromise = querySummary(Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
1461
+ const querySummaryPromise = querySummary(Object.assign(this.requestParameters, {userId: this.currUser?.id}), this.serviceName, this.env === 'dev')
1457
1462
  .then(res => {
1458
1463
  if (this.compatible === 'V3') {
1459
1464
  res = res.data
@@ -1475,7 +1480,7 @@ export default {
1475
1480
 
1476
1481
  if (this.showCustomSummary) {
1477
1482
  this.customSummaryArray.forEach(item => {
1478
- const runLogicPromise = runLogic(item.source, Object.assign(this.requestParameters, { userId: this.currUser?.id }), this.serviceName, this.env === 'dev')
1483
+ const runLogicPromise = runLogic(item.source, Object.assign(this.requestParameters, {userId: this.currUser?.id}), this.serviceName, this.env === 'dev')
1479
1484
  .then(res => {
1480
1485
  this.summaryData.forEach(summary => {
1481
1486
  if (item.key === summary.key) {
@@ -1501,7 +1506,7 @@ export default {
1501
1506
  await Promise.all(promises)
1502
1507
  return this.summaryData
1503
1508
  },
1504
- sortSummaryData () {
1509
+ sortSummaryData() {
1505
1510
  const result = this.summaryData
1506
1511
  // 过滤出 result 中实际存在的 title,并按照 fieldsArray 的顺序排序
1507
1512
  this.summaryData = [...result].sort((a, b) => {
@@ -1510,7 +1515,7 @@ export default {
1510
1515
  return indexA - indexB
1511
1516
  })
1512
1517
  },
1513
- showDrawer () {
1518
+ showDrawer() {
1514
1519
  if (this.summaryUpdate) {
1515
1520
  this.summaryData.forEach(item => {
1516
1521
  item.loading = true
@@ -1522,15 +1527,15 @@ export default {
1522
1527
  this.$message.warning('请查询后再来查看')
1523
1528
  }
1524
1529
  },
1525
- onClose () {
1530
+ onClose() {
1526
1531
  this.summaryDrawerVisible = false
1527
1532
  },
1528
1533
  // 获取表格内所有数据
1529
- getTableData () {
1534
+ getTableData() {
1530
1535
  return this.$refs.table.localDataSource
1531
1536
  },
1532
1537
  // 设置表格内数据
1533
- setTableData (data) {
1538
+ setTableData(data) {
1534
1539
  if (this.localEditMode) {
1535
1540
  // 本地编辑模式下,需要修改 localEditModeDataSource
1536
1541
  this.localEditModeDataSource = data.map((item, index) => ({
@@ -1550,24 +1555,24 @@ export default {
1550
1555
  }
1551
1556
  },
1552
1557
  // 获取所有本地数据
1553
- getLocalData () {
1558
+ getLocalData() {
1554
1559
  return this.localEditModeDataSource
1555
1560
  },
1556
1561
  // 获取指定rowKey的value的本地数据
1557
- getDataByRowKeyValue (rowKeyValue) {
1562
+ getDataByRowKeyValue(rowKeyValue) {
1558
1563
  return this.getLocalData().find(item => {
1559
1564
  return item[this.rowKey] === rowKeyValue
1560
1565
  })
1561
1566
  },
1562
1567
  // 修改本地数据
1563
- modifyLocalData (rowKeyValue, data) {
1568
+ modifyLocalData(rowKeyValue, data) {
1564
1569
  const modifyItem = this.getDataByRowKeyValue(rowKeyValue)
1565
1570
  if (modifyItem) {
1566
1571
  Object.assign(modifyItem, data)
1567
1572
  }
1568
1573
  },
1569
1574
  // 追加本地数据
1570
- appendLocalData (item) {
1575
+ appendLocalData(item) {
1571
1576
  if (this.localEditModeDataSource.length === 0) {
1572
1577
  item['序号'] = 1
1573
1578
  } else {
@@ -1575,20 +1580,23 @@ export default {
1575
1580
  }
1576
1581
  this.localEditModeDataSource.push(item)
1577
1582
  },
1578
- handleRowClick (record) {
1583
+ handleRowClick(record) {
1579
1584
  this.$emit('rowClick', record)
1580
1585
  },
1581
- handleRowDblClick (record) {
1586
+ handleRowDblClick(record) {
1582
1587
  this.$emit('rowDblClick', record)
1583
1588
  },
1584
- beforeDataChange (record) {
1589
+ beforeDataChange(record) {
1590
+ if (this.isEditMode && this.autoSave) {
1591
+ this.editRowSave()
1592
+ }
1585
1593
  this.$emit('beforeDataChange', record)
1586
1594
  },
1587
- onExpand (expanded, record) {
1595
+ onExpand(expanded, record) {
1588
1596
  this.$emit('expand', expanded, record)
1589
1597
  },
1590
1598
  // 添加新方法处理表格选中状态
1591
- updateTableSelection (selectedKeys) {
1599
+ updateTableSelection(selectedKeys) {
1592
1600
  console.log('selectedKeys', selectedKeys)
1593
1601
  if (!this.$refs.table) {
1594
1602
  return
@@ -1612,7 +1620,7 @@ export default {
1612
1620
  },
1613
1621
 
1614
1622
  // 实际执行更新选中状态的方法
1615
- doUpdateTableSelection (selectedKeys) {
1623
+ doUpdateTableSelection(selectedKeys) {
1616
1624
  const primaryKeyName = this.primaryKey || this.rowKey
1617
1625
 
1618
1626
  // 更新内部选中状态
@@ -1695,7 +1703,8 @@ export default {
1695
1703
  margin: 0;
1696
1704
  }
1697
1705
  }
1698
- .hiddenFunctionalArea{
1706
+
1707
+ .hiddenFunctionalArea {
1699
1708
  display: none;
1700
1709
  }
1701
1710
  </style>
@@ -1,159 +1,159 @@
1
- <template>
2
- <div>
3
- <div class="filter-bar">
4
- <a-date-picker v-model="upload_date" placeholder="上传日期" @change="selfSearch" />
5
- <a-select
6
- style="width: 200px;"
7
- v-model="fusetype"
8
- :options="fusetypes"
9
- placeholder="分类"
10
- @change="selfSearch"
11
- allow-clear />
12
- <a-button type="primary" @click="selfSearch">查询</a-button>
13
- </div>
14
- <a-list bordered>
15
- <a-list-item v-for="item in files" :key="item.days">
16
- <div class="file-group">
17
- <h4>{{ item.days }}</h4>
18
- <div class="file-items">
19
- <div v-for="file in item.arrays" :key="file.id" class="file-card">
20
- <img :src="getFileUrl(file.f_downloadpath)" class="file-image" v-if="file.f_filetype.includes('jpg') || file.f_filetype.includes('png')" @click="openPreview(file.f_downloadpath)" style="cursor:pointer" />
21
- <p>上传时间: {{ file.f_uploaddate }}</p>
22
- <p>操作员: {{ file.f_username }}</p>
23
- <p>分类: {{ file.fusetype }}</p>
24
- <p>说明: {{ file.fremarks }}</p>
25
- <a :href="getFileUrl(file.f_downloadpath)" target="_blank">预览</a>
26
- <a-button v-if="isDelete === '1'" @click="delet(file.id)">删除</a-button>
27
- </div>
28
- </div>
29
- </div>
30
- </a-list-item>
31
- </a-list>
32
- <ImagePreview :src="previewImg" :visible="previewVisible" @close="previewVisible = false" />
33
- </div>
34
- </template>
35
-
36
- <script>
37
- import { post } from '@vue2-client/services/api'
38
- import { del } from '@vue2-client/services/api/restTools'
39
- import ImagePreview from './ImagePreview.vue'
40
- export default {
41
- props: {
42
- currUserInfo: {
43
- type: Object,
44
- default: () => undefined
45
- }
46
- },
47
- components: { ImagePreview },
48
- data () {
49
- return {
50
- upload_date: null,
51
- fusetype: null,
52
- files: [],
53
- fusetypes: [],
54
- isDelete: '0',
55
- previewVisible: false,
56
- previewImg: ''
57
- }
58
- },
59
- methods: {
60
- async getfusetypes () {
61
- this.fusetypes = [{ label: '全部', value: '' }]
62
- const res = await post('/api/af-revenue/logic/getFileUseType', {})
63
- this.fusetypes.push(...res.map(item => ({ label: item.fusetype, value: item.fusetype })))
64
- },
65
- async getFiles () {
66
- if (!this.currUserInfo) return
67
- this.files = []
68
- let condition = `f_blobid = '${this.currUserInfo.f_userinfo_id}'`
69
- if (this.upload_date) {
70
- condition += ` and CONVERT(VARCHAR(100), f_uploaddate, 23) = '${this.upload_date}'`
71
- }
72
- if (this.fusetype) {
73
- condition += ` and fusetype = '${this.fusetype}'`
74
- }
75
- const res = await post('/api/af-revenue/logic/getAllFiles', { data: { condition } })
76
- this.files = res.days.map(day => ({
77
- days: day.uploadday,
78
- arrays: res.array.filter(file => file.uploadday === day.uploadday)
79
- }))
80
- },
81
- async delet (fileId) {
82
- await del('api/af-revenue/entity/save/t_files', { id: fileId }, { resolveMsg: '删除成功', rejectMsg: '删除失败' })
83
- this.getFiles()
84
- },
85
- selfSearch () {
86
- this.getFiles()
87
- },
88
- openPreview (src) {
89
- this.previewImg = this.getFileUrl(src)
90
- this.previewVisible = true
91
- },
92
- getFileUrl (path) {
93
- if (!path) return ''
94
-
95
- console.log('原始路径:', path)
96
-
97
- // 获取当前域名和端口
98
- const baseUrl = `${window.location.protocol}//${window.location.host}`
99
-
100
- // 如果是本地文件路径,转换为新的转发路径
101
- if (path.match(/^[A-Za-z]:[\/\\]/)) {
102
- // 提取文件名
103
- const fileName = path.split(/[/\\]/).pop()
104
- const newUrl = `${baseUrl}/rs/image/file/${fileName}`
105
- console.log('转换后路径:', newUrl)
106
- return newUrl
107
- }
108
- // 如果已经是HTTP路径,直接返回
109
- if (path.startsWith('http')) {
110
- console.log('HTTP路径,直接返回:', path)
111
- return path
112
- }
113
- // 如果是相对路径,添加域名前缀
114
- if (path.startsWith('/resource/')) {
115
- const newUrl = `${baseUrl}${path}`
116
- console.log('相对路径转换:', newUrl)
117
- return newUrl
118
- }
119
- console.log('其他路径,直接返回:', path)
120
- return path
121
- }
122
- },
123
- mounted () {
124
- if (this.$login.r.includes('上传附件删除')) {
125
- this.isDelete = '1'
126
- }
127
- this.getFiles()
128
- this.getfusetypes()
129
- }
130
- }
131
- </script>
132
-
133
- <style scoped>
134
- .filter-bar {
135
- display: flex;
136
- gap: 10px;
137
- margin-bottom: 15px;
138
- }
139
- .file-group {
140
- margin-bottom: 15px;
141
- }
142
- .file-items {
143
- display: flex;
144
- flex-wrap: wrap;
145
- gap: 10px;
146
- }
147
- .file-card {
148
- border: 1px solid #ddd;
149
- padding: 10px;
150
- border-radius: 5px;
151
- width: 200px;
152
- }
153
- .file-image {
154
- width: 100%; /* 让图片填充整个容器 */
155
- height: 150px; /* 调整高度 */
156
- object-fit: cover; /* 保持图片比例,填充整个区域 */
157
- border-radius: 5px; /* 圆角边框 */
158
- }
159
- </style>
1
+ <template>
2
+ <div>
3
+ <div class="filter-bar">
4
+ <a-date-picker v-model="upload_date" placeholder="上传日期" @change="selfSearch" />
5
+ <a-select
6
+ style="width: 200px;"
7
+ v-model="fusetype"
8
+ :options="fusetypes"
9
+ placeholder="分类"
10
+ @change="selfSearch"
11
+ allow-clear />
12
+ <a-button type="primary" @click="selfSearch">查询</a-button>
13
+ </div>
14
+ <a-list bordered>
15
+ <a-list-item v-for="item in files" :key="item.days">
16
+ <div class="file-group">
17
+ <h4>{{ item.days }}</h4>
18
+ <div class="file-items">
19
+ <div v-for="file in item.arrays" :key="file.id" class="file-card">
20
+ <img :src="getFileUrl(file.f_downloadpath)" class="file-image" v-if="file.f_filetype.includes('jpg') || file.f_filetype.includes('png')" @click="openPreview(file.f_downloadpath)" style="cursor:pointer" />
21
+ <p>上传时间: {{ file.f_uploaddate }}</p>
22
+ <p>操作员: {{ file.f_username }}</p>
23
+ <p>分类: {{ file.fusetype }}</p>
24
+ <p>说明: {{ file.fremarks }}</p>
25
+ <a :href="getFileUrl(file.f_downloadpath)" target="_blank">预览</a>
26
+ <a-button v-if="isDelete === '1'" @click="delet(file.id)">删除</a-button>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </a-list-item>
31
+ </a-list>
32
+ <ImagePreview :src="previewImg" :visible="previewVisible" @close="previewVisible = false" />
33
+ </div>
34
+ </template>
35
+
36
+ <script>
37
+ import { post } from '@vue2-client/services/api'
38
+ import { del } from '@vue2-client/services/api/restTools'
39
+ import ImagePreview from './ImagePreview.vue'
40
+ export default {
41
+ props: {
42
+ currUserInfo: {
43
+ type: Object,
44
+ default: () => undefined
45
+ }
46
+ },
47
+ components: { ImagePreview },
48
+ data () {
49
+ return {
50
+ upload_date: null,
51
+ fusetype: null,
52
+ files: [],
53
+ fusetypes: [],
54
+ isDelete: '0',
55
+ previewVisible: false,
56
+ previewImg: ''
57
+ }
58
+ },
59
+ methods: {
60
+ async getfusetypes () {
61
+ this.fusetypes = [{ label: '全部', value: '' }]
62
+ const res = await post('/api/af-revenue/logic/getFileUseType', {})
63
+ this.fusetypes.push(...res.map(item => ({ label: item.fusetype, value: item.fusetype })))
64
+ },
65
+ async getFiles () {
66
+ if (!this.currUserInfo) return
67
+ this.files = []
68
+ let condition = `f_blobid = '${this.currUserInfo.f_userinfo_id}'`
69
+ if (this.upload_date) {
70
+ condition += ` and CONVERT(VARCHAR(100), f_uploaddate, 23) = '${this.upload_date}'`
71
+ }
72
+ if (this.fusetype) {
73
+ condition += ` and fusetype = '${this.fusetype}'`
74
+ }
75
+ const res = await post('/api/af-revenue/logic/getAllFiles', { data: { condition } })
76
+ this.files = res.days.map(day => ({
77
+ days: day.uploadday,
78
+ arrays: res.array.filter(file => file.uploadday === day.uploadday)
79
+ }))
80
+ },
81
+ async delet (fileId) {
82
+ await del('api/af-revenue/entity/save/t_files', { id: fileId }, { resolveMsg: '删除成功', rejectMsg: '删除失败' })
83
+ this.getFiles()
84
+ },
85
+ selfSearch () {
86
+ this.getFiles()
87
+ },
88
+ openPreview (src) {
89
+ this.previewImg = this.getFileUrl(src)
90
+ this.previewVisible = true
91
+ },
92
+ getFileUrl (path) {
93
+ if (!path) return ''
94
+
95
+ console.log('原始路径:', path)
96
+
97
+ // 获取当前域名和端口
98
+ const baseUrl = `${window.location.protocol}//${window.location.host}`
99
+
100
+ // 如果是本地文件路径,转换为新的转发路径
101
+ if (path.match(/^[A-Za-z]:[\/\\]/)) {
102
+ // 提取文件名
103
+ const fileName = path.split(/[/\\]/).pop()
104
+ const newUrl = `${baseUrl}/rs/image/file/${fileName}`
105
+ console.log('转换后路径:', newUrl)
106
+ return newUrl
107
+ }
108
+ // 如果已经是HTTP路径,直接返回
109
+ if (path.startsWith('http')) {
110
+ console.log('HTTP路径,直接返回:', path)
111
+ return path
112
+ }
113
+ // 如果是相对路径,添加域名前缀
114
+ if (path.startsWith('/resource/')) {
115
+ const newUrl = `${baseUrl}${path}`
116
+ console.log('相对路径转换:', newUrl)
117
+ return newUrl
118
+ }
119
+ console.log('其他路径,直接返回:', path)
120
+ return path
121
+ }
122
+ },
123
+ mounted () {
124
+ if (this.$login.r.includes('上传附件删除')) {
125
+ this.isDelete = '1'
126
+ }
127
+ this.getFiles()
128
+ this.getfusetypes()
129
+ }
130
+ }
131
+ </script>
132
+
133
+ <style scoped>
134
+ .filter-bar {
135
+ display: flex;
136
+ gap: 10px;
137
+ margin-bottom: 15px;
138
+ }
139
+ .file-group {
140
+ margin-bottom: 15px;
141
+ }
142
+ .file-items {
143
+ display: flex;
144
+ flex-wrap: wrap;
145
+ gap: 10px;
146
+ }
147
+ .file-card {
148
+ border: 1px solid #ddd;
149
+ padding: 10px;
150
+ border-radius: 5px;
151
+ width: 200px;
152
+ }
153
+ .file-image {
154
+ width: 100%; /* 让图片填充整个容器 */
155
+ height: 150px; /* 调整高度 */
156
+ object-fit: cover; /* 保持图片比例,填充整个区域 */
157
+ border-radius: 5px; /* 圆角边框 */
158
+ }
159
+ </style>