index.ts 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import axios from "axios";
  2. import { module } from "/@/cool";
  3. import { PropRules } from "../dict";
  4. import type { PropRule } from "../types";
  5. // 统一请求
  6. export async function request(options: any): Promise<any> {
  7. const { host } = module.config("helper");
  8. return new Promise((resolve, reject) => {
  9. axios({
  10. ...options,
  11. url: host + options.url
  12. })
  13. .then((res) => {
  14. const { code, data, message } = res.data;
  15. if (code == 1000) {
  16. resolve(data);
  17. } else {
  18. reject({ message });
  19. }
  20. })
  21. .catch(reject);
  22. });
  23. }
  24. // 获取匹配规则
  25. export async function getRules() {
  26. const res = await request({
  27. url: "/app/base/comm/param",
  28. params: {
  29. key: "epsFieldType"
  30. }
  31. });
  32. let eps: { components: PropRule[] };
  33. eval(`
  34. ${res}
  35. eps = EPS
  36. `);
  37. const arr = eps!.components.map((e) => {
  38. return {
  39. ...e,
  40. ...e.render
  41. };
  42. });
  43. PropRules.unshift(...arr);
  44. }