jobdone-shared-files 1.0.49 → 1.0.50

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/README.md CHANGED
@@ -359,6 +359,7 @@ import OOXX from '../../node_modules/jobdone-shared-files/OOXX.vue';
359
359
  | 5 | `search-placeholder` | `String` | `''` | 自定義搜尋框的提示文字。如未設定,有選擇內容時會將選擇的內容當成提示文字,而未選擇時則顯示placeholder(參數2)的值 |
360
360
  | 6 | `trigger-class` | `String` | `''` | 預覽框與輸入框的樣式CLASS,可用於驗證提示 |
361
361
  | 7 | `list-put` | `String`| `'body'` | 列表Dom放置位置 |
362
+ | 8 | `is-unselected-extend-value` | `Array`| `[]` | 如未設定 `null` `undefined` `0` `''` 辯視為未選擇內容 |
362
363
 
363
364
  ### 清除按鈕參數
364
365
  | # | 參數 Attribute | 型別 Type | 預設值 Default | 選項 Option | 說明 Description |
@@ -27,7 +27,7 @@
27
27
  </div>
28
28
  </li>
29
29
  <template v-if="active">
30
- <li v-for="(opt, idx) in filterList" :key="idx" @click.stop="selectConfirm(opt)" :title="opt.name"
30
+ <li v-for="(opt, idx) in filterList" :key="idx" @click.stop="selectConfirm(opt)" :title="opt?.name"
31
31
  :id="`autocomplete-select-component-opt-item_${idx}`">
32
32
  <button class="autocomplete-select-component-opt-item" type="button"
33
33
  :class="`${idx == keyboardSwitchIndex ? 'active' : ''} ${optClass}`">
@@ -127,8 +127,10 @@ const props = defineProps({
127
127
  type: Boolean,
128
128
  default: false
129
129
  },
130
-
131
-
130
+ isUnselectedExtendValue: {
131
+ type: Array,
132
+ default: []
133
+ }
132
134
  });
133
135
 
134
136
  const emit = defineEmits(['select'])
@@ -138,6 +140,26 @@ const componentContentInput = ref(null)
138
140
  const componentContentList = ref(null)
139
141
  const keywordFilterInput = ref(null)
140
142
 
143
+ const valueIsUnselected = computed(()=>{
144
+ const defaultPlaceholderValue = [null, undefined, 0, '']
145
+ let ary =[]
146
+ for (let index = 0; index < defaultPlaceholderValue.length; index++) {
147
+ const element = defaultPlaceholderValue[index];
148
+ if(!props.isUnselectedExtendValue.includes(element)){
149
+ ary.push(element)
150
+ }
151
+ }
152
+ return ary || []
153
+ })
154
+ const checkValueIsUnselected = (checkValue) => {
155
+ if(valueIsUnselected.value.includes(checkValue)){
156
+ return true
157
+ }
158
+ if((typeof props.selectedData) === 'object' && checkValue !== null && Object.keys(props.selectedData).length === 0){
159
+ return true
160
+ }
161
+ return false
162
+ }
141
163
 
142
164
  // 是否開啟下拉選單
143
165
  const active = ref(false)
@@ -222,7 +244,7 @@ const filterList = computed(() => {
222
244
 
223
245
  // 從選項列表中挖出整個選中的item,因選中的值(可能是某個key)
224
246
  const selectedItem = computed(() => {
225
- if (props.selectedData === null || props.selectedData === undefined || ((typeof props.selectedData) === 'object' && Object.keys(props.selectedData).length === 0)) {
247
+ if (checkValueIsUnselected(props.selectedData)) {
226
248
  return
227
249
  }
228
250
 
@@ -262,7 +284,7 @@ function previewAdjust(itemObj) {
262
284
 
263
285
  // 選中的值的顯示
264
286
  const selectedPreviewText = computed(() => {
265
- if (selectedItem.value === '' || selectedItem.value === null || selectedItem.value === undefined || ((typeof selectedItem.value) === 'object' && Object.keys(selectedItem.value).length === 0)) {
287
+ if (checkValueIsUnselected(selectedItem.value)) {
266
288
  return props.placeholder
267
289
  }
268
290
  return previewAdjust(selectedItem.value)
@@ -276,8 +298,8 @@ function clearSelected() {
276
298
 
277
299
  // 選擇送出
278
300
  function selectConfirm(v) {
279
- if (v === null || v === undefined || ((typeof v) === 'object' && Object.keys(v).length === 0)) {
280
- return
301
+ if (checkValueIsUnselected(v)) {
302
+ return props.resetValue
281
303
  }
282
304
  emit('select', JSON.parse(JSON.stringify(v)))
283
305
  leave()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jobdone-shared-files",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Shared JS and SCSS for Jobdone Enterprise.",
5
5
  "main": "index.js",
6
6
  "scripts": {