huangxw 10 tháng trước cách đây
mục cha
commit
4e4b3fcb63

+ 11 - 0
src/api/cdt/menus/index.ts

@@ -118,3 +118,14 @@ export const getTestPackageItems = (query?: any): any => {
         params: query
     });
 };
+/**
+ * 企业id查企业详情
+ * @param id
+ * @returns {*}
+ */
+export const getEnterpriseDetail = (id?: string): any => {
+    return request({
+        url: `/dgtmedicine/member//getMemberInfoById/${id}`,
+        method: 'get'
+    });
+};

+ 60 - 58
src/views/cdt/menus/index.vue

@@ -35,70 +35,72 @@
                     </div>
                 </div>
             </div>
-            <div class="flex1 ov-hd pd-16">
+            <div class="flex1 ov-hd pd-16 d-flex flex-cln">
                 <searchTabs v-model="queryParams.publicFlag" @change="handleQuery" :list="tabs" key-label="name" key-value="type" key-count="num"></searchTabs>
                 <div class="pd-8"></div>
-                <vxe-table :loading="loading" border :data="list" min-height="0" max-height="100%">
-                    <!-- 序号 -->
-                    <vxe-column type="seq" fixed="left" width="60" title="序号" align="center" />
-                    <vxe-column title="套餐名称" fixed="left" align="center" field="name" min-width="100" :formatter="colNoData" />
-                    <vxe-column title="适用对象" field="applyType" min-width="100">
-                        <template #default="{ row }">
-                            <view class="d-flex flex-cln">
-                                <template v-for="(item, index) in row?.priceDetail" :key="index">
-                                    <view>
-                                        {{ item?.memberLevelName }}-{{ NP.times(item?.memberDiscount, 10) }}折
-                                        <span class="c-333 f-w-5">({{ item?.price }})</span>
-                                    </view>
-                                </template>
-                            </view>
-                        </template>
-                    </vxe-column>
-                    <vxe-column title="检测项目" min-width="140">
-                        <template #default="{ row }">
-                            <view v-if="row?.items">
-                                {{ row?.items }}
-                                <el-button @click="queryRowItems(row)" type="primary" text>点击查看详情{{ '>' }}</el-button>
-                            </view>
-                            <view v-else>-</view>
-                        </template>
-                    </vxe-column>
-                    <vxe-column title="检测周期" width="100">
-                        <template #default="{ row }">{{ row?.period }}天</template>
-                    </vxe-column>
-                    <vxe-column title="上架数量" field="totalCount" width="80" :formatter="colNoData"></vxe-column>
-                    <vxe-column title="销量" field="orderedCount" width="80" :formatter="colNoData"></vxe-column>
-                    <vxe-column title="套餐状态" align="center" width="90" fixed="right">
-                        <template #default="{ row }">
-                            <span v-if="+row?.status === 0" class="c-danger">未上架</span>
-                            <span v-else-if="+row?.status === 1" class="c-primary">在售</span>
-                            <span v-else-if="+row?.status === 2" class="c-999">已下架</span>
-                        </template>
-                    </vxe-column>
-                    <vxe-column title="操作" fixed="right" width="260">
-                        <template #default="{ row }">
-                            <template v-if="+row?.status === 0">
-                                <el-button @click="putaway(row)" text type="primary">上架</el-button>
-                                <span></span>
-                                <el-button @click="router.push({ path: 'menus-form', query: { id: row?.id } })" text type="primary">编辑</el-button>
+                <div class="flex1 ov-hd">
+                    <vxe-table :loading="loading" border :data="list" min-height="0" max-height="100%">
+                        <!-- 序号 -->
+                        <vxe-column type="seq" fixed="left" width="60" title="序号" align="center" />
+                        <vxe-column title="套餐名称" fixed="left" align="center" field="name" min-width="100" :formatter="colNoData" />
+                        <vxe-column title="适用对象" field="applyType" min-width="100">
+                            <template #default="{ row }">
+                                <view class="d-flex flex-cln">
+                                    <template v-for="(item, index) in row?.priceDetail" :key="index">
+                                        <view>
+                                            {{ item?.memberLevelName }}-{{ NP.times(item?.memberDiscount, 10) }}折
+                                            <span class="c-333 f-w-5">({{ item?.price }})</span>
+                                        </view>
+                                    </template>
+                                </view>
                             </template>
-                            <template v-if="+row?.status === 1">
-                                <el-button @click="soldOut(row)" text type="danger">下架</el-button>
-                                <span></span>
-                                <el-button text type="primary">分享</el-button>
+                        </vxe-column>
+                        <vxe-column title="检测项目" min-width="140">
+                            <template #default="{ row }">
+                                <view v-if="row?.items">
+                                    {{ row?.items }}
+                                    <el-button @click="queryRowItems(row)" type="primary" text>点击查看详情{{ '>' }}</el-button>
+                                </view>
+                                <view v-else>-</view>
                             </template>
-                            <template v-if="+row?.status === 2">
-                                <el-button @click="putaway(row)" text type="primary">上架</el-button>
+                        </vxe-column>
+                        <vxe-column title="检测周期" width="100">
+                            <template #default="{ row }">{{ row?.period }}天</template>
+                        </vxe-column>
+                        <vxe-column title="上架数量" field="totalCount" width="80" :formatter="colNoData"></vxe-column>
+                        <vxe-column title="销量" field="orderedCount" width="80" :formatter="colNoData"></vxe-column>
+                        <vxe-column title="套餐状态" align="center" width="90" fixed="right">
+                            <template #default="{ row }">
+                                <span v-if="+row?.status === 0" class="c-danger">未上架</span>
+                                <span v-else-if="+row?.status === 1" class="c-primary">在售</span>
+                                <span v-else-if="+row?.status === 2" class="c-999">已下架</span>
+                            </template>
+                        </vxe-column>
+                        <vxe-column title="操作" fixed="right" width="260">
+                            <template #default="{ row }">
+                                <template v-if="+row?.status === 0">
+                                    <el-button @click="putaway(row)" text type="primary">上架</el-button>
+                                    <span></span>
+                                    <el-button @click="router.push({ path: 'menus-form', query: { id: row?.id } })" text type="primary">编辑</el-button>
+                                </template>
+                                <template v-if="+row?.status === 1">
+                                    <el-button @click="soldOut(row)" text type="danger">下架</el-button>
+                                    <span></span>
+                                    <el-button text type="primary">分享</el-button>
+                                </template>
+                                <template v-if="+row?.status === 2">
+                                    <el-button @click="putaway(row)" text type="primary">上架</el-button>
+                                    <span></span>
+                                    <el-button text style="color: #999;" disabled>分享</el-button>
+                                </template>
                                 <span></span>
-                                <el-button text style="color: #999;" disabled>分享</el-button>
+                                <el-button @click="copyItem(row)" text type="primary">复制</el-button>
+                                <span></span>
+                                <el-button @click="router.push({ path: 'menus-detail', query: { id: row?.id } })" text type="primary">详情</el-button>
                             </template>
-                            <span></span>
-                            <el-button @click="copyItem(row)" text type="primary">复制</el-button>
-                            <span></span>
-                            <el-button @click="router.push({ path: 'menus-detail', query: { id: row?.id } })" text type="primary">详情</el-button>
-                        </template>
-                    </vxe-column>
-                </vxe-table>
+                        </vxe-column>
+                    </vxe-table>
+                </div>
             </div>
             <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
         </div>

+ 30 - 8
src/views/models/SearchSelect.vue

@@ -1,19 +1,22 @@
 <template>
     <el-select ref="selectDropRef" :multiple-limit="limit" @change="changeSelect" multiple v-model="value" filterable popper-class="custom-dropdown" remote reserve-keyword :remote-method="remoteMethod" remote-show-suffix clearable placeholder="请选择适用企业">
         <div class="optionBox" infinite-scroll-delay="500" infinite-scroll-distance="20" v-infinite-scroll="load">
-            <el-option v-for="item in options" :key="item.value" filterable :label="item.cpyName" :value="item.cpyid"></el-option>
+            <template v-if="optionsV.length">
+                <el-option v-for="item in optionsV" :key="item.value" :label="item.cpyName" :value="item.cpyid"></el-option>
+            </template>
+            <template v-for="item in options" :key="item.cpyid">
+                <el-option v-if="!isOptionsV(item.cpyid)" :label="item.cpyName" :value="item.cpyid"></el-option>
+            </template>
         </div>
     </el-select>
 </template>
 <script setup lang="ts">
-import { getEnterpriseList } from '@/api/cdt/menus'
+import { getEnterpriseDetail, getEnterpriseList } from '@/api/cdt/menus'
+import { propTypes } from '@/utils/propTypes';
 // 防抖
 import { debounce } from 'lodash';
 const props = defineProps({
-    modelValue: {
-        type: String,
-        default: ''
-    },
+    modelValue: propTypes.any.def([]),
     params: {
         type: Object,
         default: () => ({})
@@ -24,8 +27,9 @@ const props = defineProps({
     }
 })
 const emit = defineEmits(['change', 'update:modelValue', 'changeItem'])
-const value = ref('')
+const value = ref<string[]>([])
 const options = ref([])
+const optionsV = ref([])
 const total = ref(0)
 const selectDropRef = ref(null)
 const queryParams = ref({
@@ -64,10 +68,27 @@ const changeSelect = (val: string[]) => {
     emit('change', val)
     emit('changeItem', itemInfo)
 }
+// 判断是否在optionsV
+const isOptionsV = (val: string) => {
+    return optionsV.value.some((item) => item.cpyid === val)
+}
+// 获取当前id对应的企业信息
 const selectSearch = debounce(() => {
     getList()
 }, 500)
-
+// 根据values获取下拉框的options
+const getOptions = async (values: string[]) => {
+    if (!values.length) {
+        return
+    }
+    values.forEach(async (item) => {
+        if ([...optionsV.value, ...options.value].find((v) => v.cpyid === item)) {
+            return
+        }
+        const res = await getEnterpriseDetail(item)
+        res?.data && optionsV.value.push(res.data)
+    })
+}
 onMounted(() => {
     getList()
     nextTick(() => {
@@ -83,5 +104,6 @@ onMounted(() => {
 })
 watch(() => props.modelValue, (val) => {
     value.value = val
+    getOptions(val)
 }, { immediate: true })
 </script>

+ 10 - 10
src/views/models/searchTabs.vue

@@ -1,13 +1,13 @@
 <template>
-  <div class="ridio-info d-flex f-w-w">
-    <!-- <div class="ridio-item f-12" @click="change('')" :class="{ checked: !activeName }">全部({{ total }})</div> -->
-    <template v-for="item in list" :key="item.value">
-      <div class="ridio-item f-s-12 f-w-5" @click="change(item[keyValue])" :class="{ checked: (item[keyValue] || '') === activeName }">
-        <template v-if="isNum"> {{ item[keyLabel] }}({{ item[keyCount] }}) </template>
-        <template v-else> {{ item[keyLabel] }} </template>
-      </div>
-    </template>
-  </div>
+    <div class="ridio-info d-flex f-w-w">
+        <!-- <div class="ridio-item f-12" @click="change('')" :class="{ checked: !activeName }">全部({{ total }})</div> -->
+        <template v-for="item in list" :key="item.value">
+            <div class="ridio-item f-s-12 f-w-5" @click="change(item[keyValue])" :class="{ checked: (item[keyValue] || '') === activeName }">
+                <template v-if="isNum">{{ item[keyLabel] }}({{ item[keyCount] }})</template>
+                <template v-else>{{ item[keyLabel] }}</template>
+            </div>
+        </template>
+    </div>
 </template>
 <script setup name="searchTabs" lang="ts">
 import { propTypes } from '@/utils/propTypes';
@@ -23,7 +23,7 @@ const props = defineProps({
 });
 const change = (event: any) => {
   console.log(event);
-  
+
   activeName.value = event;
 
   emit('update:modelValue', activeName.value);