Selaa lähdekoodia

Merge branch 'dev/v1.0.36_tsz' of jianyu/web into feature/v1.0.36

汤世哲 1 vuosi sitten
vanhempi
commit
a0c2e8d5ee

+ 15 - 7
apps/bigmember_pc/src/components/filter-items/CommonCheckboxSelector.vue

@@ -10,8 +10,8 @@
       >
       <el-checkbox-button
         class="j-checkbox-button"
-        v-for="state in options.value"
-        :key="state"
+        v-for="(state, index) in options.value"
+        :key="index"
         :label="setSelectValue(state)"
       >
         {{ field ? setSelectValue(state) : state }}
@@ -26,7 +26,7 @@ const props = defineProps({
   // 是否单选
   sigle: {
     type: Boolean,
-    default: false
+    default: true
   },
   // field: 空代表字符串数组
   // 其他: options是对象数组,field是对象数组的某个字段
@@ -44,7 +44,7 @@ const props = defineProps({
   }
 })
 function setSelectValue(state) {
-  if (props.dataType === '') {
+  if (props.field === '') {
     return state
   } else {
     return state[props.field]
@@ -56,9 +56,17 @@ function onIssueStateChange(value) {
   if (isAllBtn.length > 0) {
     value = ['全部']
   } else {
-    value = value.filter((item) => item !== '全部')
-    if (value.length === 0) {
-      value = ['全部']
+    // 如果是单选,则只取最新一个
+    if (props.sigle) {
+      const nonAllValues = value.filter((item) => item !== '全部')
+      value = nonAllValues.length
+        ? [nonAllValues[nonAllValues.length - 1]]
+        : ['全部']
+    } else {
+      value = value.filter((item) => item !== '全部')
+      if (value.length === 0) {
+        value = ['全部']
+      }
     }
   }
   emit('input', value)

+ 2 - 0
apps/bigmember_pc/src/views/search/nzj/model/base.js

@@ -137,6 +137,7 @@ export default function () {
   }
 
   function doChangeInput(data) {
+    console.log(data)
     let { area, build, civil, electromechanical, project_stage, ownerclass } =
       data
     const areaJudge = checkIfArrayHasOnlyValue(area, '全部')
@@ -200,6 +201,7 @@ export default function () {
   }
 
   function checkIfArrayHasOnlyValue(arr, value) {
+    if (!arr) arr = []
     return arr.length === 1 && arr[0] === value
   }