|  | @@ -5,17 +5,19 @@
 | 
	
		
			
				|  |  |      </el-tabs>
 | 
	
		
			
				|  |  |      <div style="display: flex; justify-content: space-between;">
 | 
	
		
			
				|  |  |        <div style="display: flex; color: orange; align-items: center;">
 | 
	
		
			
				|  |  | -        <Icon :size="20" icon="ep:warning" class="mr-3px" />
 | 
	
		
			
				|  |  | -        图片规格: 
 | 
	
		
			
				|  |  | -        <span class="m-l-10px">{{ tabList[tab].size }}</span>
 | 
	
		
			
				|  |  | +        <div v-if="tab !== 9">
 | 
	
		
			
				|  |  | +          <Icon :size="20" icon="ep:warning" class="mr-3px" />
 | 
	
		
			
				|  |  | +          图片规格: 
 | 
	
		
			
				|  |  | +          <span class="m-l-10px">{{ tabList[tab].size }}</span>
 | 
	
		
			
				|  |  | +        </div>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |        <div>
 | 
	
		
			
				|  |  |          <el-button @click="getList"><Icon icon="ep:refresh" class="mr-5px" /> 刷 新</el-button>
 | 
	
		
			
				|  |  | -        <el-button type="primary" @click="handleAdd"><Icon icon="ep:plus" class="mr-5px" />新 增</el-button>
 | 
	
		
			
				|  |  | +        <el-button type="primary" @click="handleAdd"><Icon icon="ep:plus" class="mr-5px" v-hasPermi="['menduner:system:web-content:create']" />新 增</el-button>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |      </div>
 | 
	
		
			
				|  |  | -    <el-table v-loading="loading" :data="info[tabList[tab].key]" :stripe="true">
 | 
	
		
			
				|  |  | -      <!-- <el-table-column label="排序" align="center" prop="sort" /> -->
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <el-table v-if="tab !== 9" v-loading="loading" :data="info[tabList[tab].key]" :stripe="true">
 | 
	
		
			
				|  |  |        <el-table-column label="标题" align="center" prop="title" />
 | 
	
		
			
				|  |  |        <el-table-column label="图片" align="center" prop="img">
 | 
	
		
			
				|  |  |          <template #default="scope">
 | 
	
	
		
			
				|  | @@ -24,7 +26,6 @@
 | 
	
		
			
				|  |  |        </el-table-column>
 | 
	
		
			
				|  |  |        <el-table-column label="点击跳转链接" align="center" prop="link">
 | 
	
		
			
				|  |  |          <template #default="scope">
 | 
	
		
			
				|  |  | -          <!-- <el-link v-if="scope.row.link" :href="scope.row.link" type="primary" target="_blank">点击查看</el-link> -->
 | 
	
		
			
				|  |  |            {{ scope.row.link }}
 | 
	
		
			
				|  |  |          </template>
 | 
	
		
			
				|  |  |        </el-table-column>
 | 
	
	
		
			
				|  | @@ -35,8 +36,19 @@
 | 
	
		
			
				|  |  |        </el-table-column>
 | 
	
		
			
				|  |  |        <el-table-column label="操作" align="center" fixed="right" min-width="220">
 | 
	
		
			
				|  |  |          <template #default="scope">
 | 
	
		
			
				|  |  | -          <el-button link type="primary" @click="handleEdit(scope.row.mark)">编辑</el-button>
 | 
	
		
			
				|  |  | -          <el-button link type="danger" @click="handleDelete(scope.row.mark)">删除</el-button>
 | 
	
		
			
				|  |  | +          <el-button link type="primary" v-hasPermi="['menduner:system:web-content:update']" @click="handleEdit(scope.row.mark)">编辑</el-button>
 | 
	
		
			
				|  |  | +          <el-button link type="danger" v-hasPermi="['menduner:system:web-content:delete']" @click="handleDelete(scope.row.mark)">删除</el-button>
 | 
	
		
			
				|  |  | +        </template>
 | 
	
		
			
				|  |  | +      </el-table-column>
 | 
	
		
			
				|  |  | +    </el-table>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <el-table v-else v-loading="loading" :data="preferredGroup(info)" :stripe="true">
 | 
	
		
			
				|  |  | +      <el-table-column label="企业ID" align="center" prop="enterpriseId" />
 | 
	
		
			
				|  |  | +      <el-table-column label="企业名称" align="center" prop="title" />
 | 
	
		
			
				|  |  | +      <el-table-column label="操作" align="center" fixed="right" min-width="220">
 | 
	
		
			
				|  |  | +        <template #default="scope">
 | 
	
		
			
				|  |  | +          <el-button link type="primary" v-hasPermi="['menduner:system:web-content:update']" @click="handleEditPreferredGroup(scope.row.enterpriseId)">编辑</el-button>
 | 
	
		
			
				|  |  | +          <el-button link type="danger" v-hasPermi="['menduner:system:web-content:delete']" @click="handleDeletePreferredGroup(scope.row.enterpriseId)">删除</el-button>
 | 
	
		
			
				|  |  |          </template>
 | 
	
		
			
				|  |  |        </el-table-column>
 | 
	
		
			
				|  |  |      </el-table>
 | 
	
	
		
			
				|  | @@ -45,11 +57,16 @@
 | 
	
		
			
				|  |  |    <!-- 表单弹窗:添加/修改 -->
 | 
	
		
			
				|  |  |    <WebContentForm ref="formRef" @success="getList" />
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  <!-- 优选集团 -->
 | 
	
		
			
				|  |  | +  <PreferredGroup ref="preferredGroupRef" @success="getList" />
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <script setup lang="ts">
 | 
	
		
			
				|  |  |  import { WebContentApi } from '@/api/menduner/system/web'
 | 
	
		
			
				|  |  |  import WebContentForm from './WebContentForm.vue'
 | 
	
		
			
				|  |  | +import PreferredGroup from './PreferredGroup.vue'
 | 
	
		
			
				|  |  | +import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /** 页面内容 列表 */
 | 
	
		
			
				|  |  |  defineOptions({ name: 'WebContent' })
 | 
	
	
		
			
				|  | @@ -59,7 +76,7 @@ const { t } = useI18n() // 国际化
 | 
	
		
			
				|  |  |  const loading = ref(false)
 | 
	
		
			
				|  |  |  const tab = ref(0)
 | 
	
		
			
				|  |  |  let info = reactive({})
 | 
	
		
			
				|  |  | -const tabList = [
 | 
	
		
			
				|  |  | +const tabList = ref([
 | 
	
		
			
				|  |  |    { label: 'PC首页顶部广告图', value: 0, key: 'pcTop', size: '宽1429px*高80px' },
 | 
	
		
			
				|  |  |    { label: 'PC首页左侧广告图', value: 1, key: 'pcLeft', size: '宽869px*高1512px' },
 | 
	
		
			
				|  |  |    { label: 'PC首页弹窗广告图', value: 2, key: 'pcAdvertisement', size: '宽900px*高530px' },
 | 
	
	
		
			
				|  | @@ -69,8 +86,17 @@ const tabList = [
 | 
	
		
			
				|  |  |    { label: 'PC登录页背景图', value: 6, key: 'pcLoginBackground', size: '宽1920px*高940px' },
 | 
	
		
			
				|  |  |    { label: '小程序首页轮播图', value: 7, key: 'appHomeCarousel', size: '宽750px*高350px' },
 | 
	
		
			
				|  |  |    { label: '小程序首页弹窗广告图', value: 8, key: 'appAdvertisement', size: '宽331px*高442px' },
 | 
	
		
			
				|  |  | -  // { label: '小程序首页功能模块', value: 9, key: 'appHomeColumn', size: '宽72px*高72px' },
 | 
	
		
			
				|  |  | -]
 | 
	
		
			
				|  |  | +  // { label: '小程序首页功能模块', value: 10, key: 'appHomeColumn', size: '宽72px*高72px' },
 | 
	
		
			
				|  |  | +])
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 只有我们自己用的admin账号显示
 | 
	
		
			
				|  |  | +const { wsCache } = useCache()
 | 
	
		
			
				|  |  | +let userInfo = wsCache.get(CACHE_KEY.USER)
 | 
	
		
			
				|  |  | +if (userInfo && userInfo.user.nickname === 'admin') {
 | 
	
		
			
				|  |  | +  const obj = tabList.value.find(e => e.value === 9)
 | 
	
		
			
				|  |  | +  if (!obj) tabList.value.push({ label: '优选集团内容', value: 9, key: 'appPreferredGroup' })
 | 
	
		
			
				|  |  | +  else tabList.value = tabList.value.filter(e => e.value !== 9)
 | 
	
		
			
				|  |  | +} 
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /** 查询列表 */
 | 
	
		
			
				|  |  |  const getList = async () => {
 | 
	
	
		
			
				|  | @@ -83,29 +109,57 @@ const getList = async () => {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +// 优选集团
 | 
	
		
			
				|  |  | +const preferredGroup = computed(() => (data) => {
 | 
	
		
			
				|  |  | +  const list = []
 | 
	
		
			
				|  |  | +  for (let i in data.appPreferredGroup) {
 | 
	
		
			
				|  |  | +    list.push({ title: data.appPreferredGroup[i].title, enterpriseId: i, data: data.appPreferredGroup[i] })
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  return list
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const tabClick = (val) => {
 | 
	
		
			
				|  |  |    tab.value = val.paneName
 | 
	
		
			
				|  |  |    getList()
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const handleAdd = () => {
 | 
	
		
			
				|  |  | -  formRef.value.open('add', tabList[tab.value].key, tabList[tab.value].label)
 | 
	
		
			
				|  |  | +  if (tab.value === 9) return preferredGroupRef.value.open(tabList.value[tab.value].key) // 优选集团
 | 
	
		
			
				|  |  | +  formRef.value.open('add', tabList.value[tab.value].key, tabList.value[tab.value].label)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const formRef = ref()
 | 
	
		
			
				|  |  |  const handleEdit = (mark: string) => {
 | 
	
		
			
				|  |  | -  formRef.value.open('edit', tabList[tab.value].key, tabList[tab.value].label, mark)
 | 
	
		
			
				|  |  | +  formRef.value.open('edit', tabList.value[tab.value].key, tabList.value[tab.value].label, mark)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /** 删除按钮操作 */
 | 
	
		
			
				|  |  |  const handleDelete = async (mark: string) => {
 | 
	
		
			
				|  |  | -  const index = info[tabList[tab.value].key].findIndex((item) => item.mark === mark)
 | 
	
		
			
				|  |  | +  const index = info[tabList.value[tab.value].key].findIndex((item) => item.mark === mark)
 | 
	
		
			
				|  |  |    if (index === -1) return message.warning('图片不存在')
 | 
	
		
			
				|  |  |    try {
 | 
	
		
			
				|  |  |      // 删除的二次确认
 | 
	
		
			
				|  |  |      await message.delConfirm()
 | 
	
		
			
				|  |  |      // 发起删除
 | 
	
		
			
				|  |  | -    info[tabList[tab.value].key].splice(index, 1)
 | 
	
		
			
				|  |  | +    info[tabList.value[tab.value].key].splice(index, 1)
 | 
	
		
			
				|  |  | +    await WebContentApi.updateWebContent(info)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    message.success(t('common.delSuccess'))
 | 
	
		
			
				|  |  | +    // 刷新列表
 | 
	
		
			
				|  |  | +    await getList()
 | 
	
		
			
				|  |  | +  } catch {}
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 优选集团
 | 
	
		
			
				|  |  | +const preferredGroupRef = ref()
 | 
	
		
			
				|  |  | +const handleDeletePreferredGroup = async (id) => {
 | 
	
		
			
				|  |  | +  if (!info[tabList.value[tab.value].key][id]) return message.warning('数据不存在')
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    // 删除的二次确认
 | 
	
		
			
				|  |  | +    await message.delConfirm()
 | 
	
		
			
				|  |  | +    // 发起删除
 | 
	
		
			
				|  |  | +    delete info[tabList.value[tab.value].key][id]
 | 
	
		
			
				|  |  |      await WebContentApi.updateWebContent(info)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      message.success(t('common.delSuccess'))
 | 
	
	
		
			
				|  | @@ -113,6 +167,9 @@ const handleDelete = async (mark: string) => {
 | 
	
		
			
				|  |  |      await getList()
 | 
	
		
			
				|  |  |    } catch {}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +const handleEditPreferredGroup = (id) => {
 | 
	
		
			
				|  |  | +  preferredGroupRef.value.open(tabList.value[tab.value].key, id)
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /** 初始化 **/
 | 
	
		
			
				|  |  |  onMounted(() => {
 |