mixin.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * @Author: chenzy13 chenzy13@yusys.com.cn
  3. * @Date: 2024-07-10 11:30:26
  4. * @LastEditors: zhanglin3
  5. * @LastEditTime: 2024-09-18 11:18:02
  6. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  7. */
  8. /**
  9. * 表单字段格式化
  10. * created by kongqf 2019/02/23
  11. */
  12. import { type } from '@yufp/xy-utils';
  13. import formatterFn from '@/utils/formatter';
  14. import { logInfo, checkCtrl } from '@/utils/util.js';
  15. import router from '@/router';
  16. import { DATE_FORMAT, DATE_TIME_FORMAT, OP_ADD, OP_EDIT, OP_DETAIL } from '@/config/constant/app.data.common.js';
  17. // import { deleHistoryRecord } from '@/utils/routeback';
  18. const formFormaterStr = {
  19. OP_ADD,
  20. OP_EDIT,
  21. OP_DETAIL,
  22. DATE_FORMAT,
  23. DATE_TIME_FORMAT,
  24. VALUE_FORMAT: 'yyyy-MM-dd',
  25. VALUE_FORMAT_YMDHMS: 'yyyy-MM-dd HH:mm:ss',
  26. VALUE_FORMAT_YMDHM: 'yyyy-MM-dd HH:mm',
  27. };
  28. const _isObject = function (o) {
  29. return type(o) === 'object';
  30. };
  31. const _getParamValue = function (ps) {
  32. if (ps.length == 3 && _isObject(ps[0]) && _isObject(ps[1])) {
  33. return ps[2];
  34. }
  35. return ps[0];
  36. };
  37. /**
  38. * 默认mixin配置
  39. */
  40. export default {
  41. data() {
  42. return formFormaterStr;
  43. },
  44. };
  45. // 注册混入的时候没有使用默认的所以这里要添加data不然找不到相关时间变量设置
  46. export const vueMixinButton = {
  47. data() {
  48. return {
  49. ...formFormaterStr,
  50. // 当前页面路径存储
  51. parentRoutPath: '/',
  52. };
  53. },
  54. created() {
  55. // 保存当前路径
  56. this.parentRoutPath = (this.$route || {}).path;
  57. },
  58. methods: {
  59. // 格式化
  60. ...formatterFn,
  61. buttonLogs(btnObj, buttonName) {
  62. const zhCn = {
  63. button: '按钮',
  64. path: '路径:',
  65. buttonOperate: '按钮操作:',
  66. };
  67. const lang = zhCn;
  68. const tab = this.$route || router.history.current;
  69. if (!tab || !tab.meta.id) {
  70. // toto confirm q确认框无法获取当前页面路由
  71. return;
  72. }
  73. buttonName = buttonName || (!btnObj.$slots.default ? '' : btnObj.$el.innerText.trim());
  74. const log = {
  75. logCtg: '2',
  76. oprObj: lang.button,
  77. oprCtnt: `${lang.buttonOperate}${buttonName}${lang.button},${lang.path}${tab.meta.routeUrl}`,
  78. funcModlName: tab.meta.title,
  79. };
  80. logInfo(log);
  81. },
  82. checkCtrl(ctrlCode) {
  83. // 检查是否有控制点权限,有权限返回false,无权限返回true
  84. return !checkCtrl(ctrlCode);
  85. },
  86. },
  87. // 路由离开前回调处理返回逻辑
  88. // beforeRouteLeave(to, from, next) {
  89. // const curRoute = this.$route;
  90. // const flag = this.$store.state.tagsView.closeFlag;
  91. // // 页签关闭 标识时,添加处理返回跳转逻辑
  92. // if (flag && curRoute.query && curRoute.query.hisId) {
  93. // let path = deleHistoryRecord(curRoute.query.hisId);
  94. // if (path) {
  95. // path = path.split(':')[1];
  96. // this.$store.commit('tagsView/SET_CLOSE_FLAG', false);
  97. // next(path); // 继续导航
  98. // }
  99. // }
  100. // next();
  101. // },
  102. };