jobsys-explore 4.0.8 → 4.0.10

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "jobsys-explore": patch
3
+ ---
4
+
5
+ option fetch data only once
@@ -0,0 +1,5 @@
1
+ ---
2
+ "jobsys-explore": patch
3
+ ---
4
+
5
+ search watch model value
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # jobsys-explore
2
2
 
3
+ ## 4.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - address
8
+ - add exPros parameter
9
+ - option fetch data only once
10
+ - form expose fetchItem method
11
+ - fixed address modelValue
12
+ - fixed textInValue
13
+ - fixed textInValue
14
+ - add key_cn
15
+ - search watch model value
16
+ - e
17
+
18
+ ## 4.0.9
19
+
20
+ ### Patch Changes
21
+
22
+ - address
23
+ - add exPros parameter
24
+ - option fetch data only once
25
+ - form expose fetchItem method
26
+ - fixed address modelValue
27
+ - fixed textInValue
28
+ - fixed textInValue
29
+ - add key_cn
30
+ - e
31
+
3
32
  ## 4.0.8
4
33
 
5
34
  ### Patch Changes
@@ -13,7 +13,7 @@ export default defineComponent({
13
13
  props: {
14
14
  ...defaultFieldProps,
15
15
 
16
- modelValue: { type: Date, default: () => null },
16
+ modelValue: { type: [Date, String], default: () => null },
17
17
 
18
18
  /**
19
19
  * 标题
@@ -1,4 +1,4 @@
1
- import { defineComponent, nextTick, reactive, ref } from "vue"
1
+ import { defineComponent, nextTick, reactive, ref, watch } from "vue"
2
2
  import { Button, Icon, Popup, Search } from "vant"
3
3
  import { find, isArray, isFunction } from "lodash-es"
4
4
  import { createExpand, createField, createQuick } from "./components"
@@ -74,6 +74,13 @@ export default defineComponent({
74
74
  setup(props, { emit }) {
75
75
  const componentValue = ref(props.modelValue)
76
76
 
77
+ watch(
78
+ () => props.modelValue,
79
+ () => {
80
+ componentValue.value = props.modelValue
81
+ },
82
+ )
83
+
77
84
  const state = reactive({
78
85
  queryForm: {}, // 搜索表单
79
86
  quickColumns: [], //快速检索项
@@ -1,6 +1,6 @@
1
1
  import { cloneDeep, isFunction, isString } from "lodash-es"
2
2
  import { watch } from "vue"
3
- import { useFetch } from "../hooks"
3
+ import { useCache, useFetch } from "../hooks"
4
4
 
5
5
  /**
6
6
  * 通用 field props
@@ -95,6 +95,11 @@ export const defaultOptionsProps = {
95
95
  */
96
96
  url: { type: String, default: null },
97
97
 
98
+ /**
99
+ * 缓存url返回的数据
100
+ */
101
+ urlCache: { type: Boolean, default: true },
102
+
98
103
  /**
99
104
  * 选项获取后的回调
100
105
  */
@@ -118,6 +123,20 @@ export const prepareOptions = (options) => {
118
123
  return options
119
124
  }
120
125
 
126
+ //内部方法,为了useOptionTrait实现单次请求,避免重复请求
127
+ const recordOptionsUrl = {}
128
+ const optionsFetcher = (props) => {
129
+ return new Promise((resolve) => {
130
+ useFetch()
131
+ .get(props.url)
132
+ .then((items) => {
133
+ if (props.afterFetched) {
134
+ items = props.afterFetched(items)
135
+ }
136
+ resolve(items)
137
+ })
138
+ })
139
+ }
121
140
  /**
122
141
  * 初始化选项
123
142
  * @param options
@@ -129,17 +148,18 @@ export const prepareOptions = (options) => {
129
148
  export const useOptionTrait = async (options, props, defaultOptions) => {
130
149
  options.value = prepareOptions(props.options)
131
150
 
132
- const fetchData = () =>
133
- new Promise((resolve) => {
134
- useFetch()
135
- .get(props.url)
136
- .then((items) => {
137
- if (props.afterFetched) {
138
- items = props.afterFetched(items)
139
- }
140
- resolve(items)
141
- })
151
+ const fetchData = async (props) => {
152
+ if (recordOptionsUrl[props.url]) {
153
+ return recordOptionsUrl[props.url]
154
+ }
155
+ recordOptionsUrl[props.url] = optionsFetcher(props)
156
+
157
+ const result = await recordOptionsUrl[props.url]
158
+ recordOptionsUrl[props.url] = null
159
+ return new Promise((resolve) => {
160
+ resolve(result)
142
161
  })
162
+ }
143
163
 
144
164
  watch(
145
165
  () => props.options,
@@ -150,9 +170,16 @@ export const useOptionTrait = async (options, props, defaultOptions) => {
150
170
 
151
171
  if (!options.value.length) {
152
172
  if (props.url) {
153
- fetchData().then((items) => {
154
- options.value = items
155
- })
173
+ if (props.urlCache && useCache(props.url).get()) {
174
+ options.value = useCache(props.url).get()
175
+ } else {
176
+ fetchData(props).then((items) => {
177
+ options.value = items
178
+ if (props.urlCache) {
179
+ useCache(props.url).set(items)
180
+ }
181
+ })
182
+ }
156
183
  } else if (defaultOptions) {
157
184
  options.value = defaultOptions
158
185
  }
package/dist/hooks.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-1d1cffa4.cjs"),r=require("dayjs"),o=require("lodash-es");require("axios");require("vant");function i(){return s.sm2_exports}function c(e,u){return s.sm32(e,u)}function a(e,u,n){return s.sm4_exports.encrypt(e,u,n)}function F(e,u,n){return s.sm4_exports.encrypt(e,u,n)}function m(e,u){return u?r(e,u):r(e)}function t(e,u){return e?(r.isDayjs(e)||(e=r(e)),e.format(u||"YYYY-MM-DD HH:mm")):""}function S(e){return e?(r.isDayjs(e)||(e=r(e)),e.unix()):""}function f(e,u){return e&&o.isString(e)&&(e=parseInt(e)),e<9999999999&&(e*=1e3),t(new Date(e),u)}exports.STATUS=s.STATUS;exports._configStatus=s._configStatus;exports.useCache=s.useCache;exports.useFetch=s.useFetch;exports.useFindLabelsFromPath=s.useFindLabelsFromPath;exports.useFindParentValues=s.useFindParentValues;exports.useFindTextsFromPath=s.useFindTextsFromPath;exports.useFindTextsInValues=s.useFindTextsInValues;exports.useFormFail=s.useFormFail;exports.useFormFormat=s.useFormFormat;exports.useHiddenForm=s.useHiddenForm;exports.useProcessStatus=s.useProcessStatus;exports.useProcessStatusSuccess=s.useProcessStatusSuccess;exports.useTextFromOptionsValue=s.useTextFromOptionsValue;exports.useDateFormat=t;exports.useDateUnix=S;exports.useDayjs=m;exports.useSm2=i;exports.useSm3=c;exports.useSm4Decrypt=F;exports.useSm4Encrypt=a;exports.useTimestampFormat=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-4756607f.cjs"),r=require("dayjs"),o=require("lodash-es");require("axios");require("vant");function i(){return s.sm2_exports}function c(e,u){return s.sm32(e,u)}function a(e,u,n){return s.sm4_exports.encrypt(e,u,n)}function F(e,u,n){return s.sm4_exports.encrypt(e,u,n)}function m(e,u){return u?r(e,u):r(e)}function t(e,u){return e?(r.isDayjs(e)||(e=r(e)),e.format(u||"YYYY-MM-DD HH:mm")):""}function S(e){return e?(r.isDayjs(e)||(e=r(e)),e.unix()):""}function f(e,u){return e&&o.isString(e)&&(e=parseInt(e)),e<9999999999&&(e*=1e3),t(new Date(e),u)}exports.STATUS=s.STATUS;exports._configStatus=s._configStatus;exports.useCache=s.useCache;exports.useFetch=s.useFetch;exports.useFindLabelsFromPath=s.useFindLabelsFromPath;exports.useFindParentValues=s.useFindParentValues;exports.useFindTextsFromPath=s.useFindTextsFromPath;exports.useFindTextsInValues=s.useFindTextsInValues;exports.useFormFail=s.useFormFail;exports.useFormFormat=s.useFormFormat;exports.useHiddenForm=s.useHiddenForm;exports.useProcessStatus=s.useProcessStatus;exports.useProcessStatusSuccess=s.useProcessStatusSuccess;exports.useTextFromOptionsValue=s.useTextFromOptionsValue;exports.useDateFormat=t;exports.useDateUnix=S;exports.useDayjs=m;exports.useSm2=i;exports.useSm3=c;exports.useSm4Decrypt=F;exports.useSm4Encrypt=a;exports.useTimestampFormat=f;
2
2
  //# sourceMappingURL=hooks.cjs.map
package/dist/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
- import { s as o, e as t, f as n } from "./index-6747e8a2.js";
2
- import { S as Y, _, k as g, u as H, i as V, j as b, a as I, h as M, d as U, c as k, l as w, m as A, b as C, g as E } from "./index-6747e8a2.js";
1
+ import { s as o, f as t, g as n } from "./index-438db37d.js";
2
+ import { S as Y, _, u as g, a as H, j as V, k as b, b as I, i as M, e as U, d as k, l as w, m as A, c as C, h as E } from "./index-438db37d.js";
3
3
  import u from "dayjs";
4
4
  import { isString as i } from "lodash-es";
5
5
  import "axios";