|
|
@@ -72,14 +72,21 @@
|
|
|
show-overflow-tooltip
|
|
|
width="450"
|
|
|
/>
|
|
|
- <el-table-column label="图片" align="center" width="120">
|
|
|
+ <el-table-column label="图片" align="center" width="120">
|
|
|
<template #default="scope">
|
|
|
- <div class="row-el" @click.stop="aa" style="height: 40px;justify-content: center;align-items: center;">
|
|
|
+ <div
|
|
|
+ class="row-el"
|
|
|
+ @click.stop="aa"
|
|
|
+ style="height: 40px;justify-content: center;align-items: center;"
|
|
|
+ >
|
|
|
<image-preview
|
|
|
- v-show="(scope.row.pictures!=undefined && scope.row.pictures.length>0)" :is-p="true" border-radius="5%"
|
|
|
- style="width: 40px;height: 40px;" :src="scope.row.picturesStr" @error="() => true" >
|
|
|
- <!-- <img src="@/assets/images/defvip.png" alt=""/>-->
|
|
|
- </image-preview>
|
|
|
+ v-show="scope.row.pictures != undefined && scope.row.pictures.length > 0"
|
|
|
+ :is-p="true"
|
|
|
+ border-radius="5%"
|
|
|
+ style="width: 40px;height: 40px;"
|
|
|
+ :src="scope.row.picturesStr"
|
|
|
+ @error="() => true"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
@@ -114,24 +121,30 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<!-- 分页 -->
|
|
|
-<!-- <Pagination-->
|
|
|
-<!-- :total="total"-->
|
|
|
-<!-- v-model:page="queryParams.pageNo"-->
|
|
|
-<!-- v-model:limit="queryParams.pageSize"-->
|
|
|
-<!-- @pagination="getList"-->
|
|
|
-<!-- />-->
|
|
|
+ <!-- <Pagination-->
|
|
|
+ <!-- :total="total"-->
|
|
|
+ <!-- v-model:page="queryParams.pageNo"-->
|
|
|
+ <!-- v-model:limit="queryParams.pageSize"-->
|
|
|
+ <!-- @pagination="getList"-->
|
|
|
+ <!-- />-->
|
|
|
</ContentWrap>
|
|
|
|
|
|
- <AddForm ref="addFoodRef" @success="getList" />
|
|
|
+ <AddForm
|
|
|
+ ref="addFoodRef"
|
|
|
+ @success="handleAddSuccess"
|
|
|
+ @visible-change="handleAddFormVisibleChange"
|
|
|
+ @form-activity="handleAddFormActivity"
|
|
|
+ />
|
|
|
<DetailsForm ref="foodDetailsForm" @success="getList" />
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-
|
|
|
import AddForm from '@/views/system/food/canteenManage/AddForm.vue'
|
|
|
import DetailsForm from '@/views/system/food/canteenManage/DetailsForm.vue'
|
|
|
-import {chargeCategoryDel} from '@/api/elderly/fee/chargeCategory'
|
|
|
-import {getListRestaurant, restaurantManagementDelete} from "@/api/system/foods";
|
|
|
+import { chargeCategoryDel } from '@/api/elderly/fee/chargeCategory'
|
|
|
+import { getAiSuggest,getListRestaurant, restaurantManagementDelete } from '@/api/system/foods'
|
|
|
+import { getTenantId } from '@/utils/auth'
|
|
|
+import { ElMessageBox } from 'element-plus'
|
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
const { t } = useI18n() // 国际化
|
|
|
@@ -142,23 +155,144 @@ const addFoodRef = ref()
|
|
|
const foodDetailsForm = ref()
|
|
|
const total = ref(0) // 列表的总页数
|
|
|
|
|
|
+const suggestInterval = ref(5000)
|
|
|
+
|
|
|
const list = ref([]) // 列表的数据
|
|
|
let queryParams = reactive({
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
elderName: '',
|
|
|
approvalStatus: '',
|
|
|
- categoryId: '',
|
|
|
+ categoryId: ''
|
|
|
})
|
|
|
|
|
|
+const aiSuggestTimer = ref<any>(null)
|
|
|
+const isAddFormVisible = ref(false)
|
|
|
+const isAddMode = ref(false)
|
|
|
+const isAiSuggestRunning = ref(false)
|
|
|
+const isAiSuggestStopped = ref(true)
|
|
|
|
|
|
+const clearAiSuggestTimer = () => {
|
|
|
+ if (aiSuggestTimer.value) {
|
|
|
+ clearTimeout(aiSuggestTimer.value)
|
|
|
+ aiSuggestTimer.value = null
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-const deleteItems = async (id) => {
|
|
|
+const startAiSuggestTimer = () => {
|
|
|
+ clearAiSuggestTimer()
|
|
|
+ if (isAiSuggestStopped.value) return
|
|
|
+ if (!isAddFormVisible.value || !isAddMode.value) return
|
|
|
+ aiSuggestTimer.value = setTimeout(() => {
|
|
|
+ triggerAiSuggestFlow()
|
|
|
+ }, suggestInterval.value)
|
|
|
+}
|
|
|
+
|
|
|
+const triggerAiSuggestFlow = async () => {
|
|
|
+ if (!isAddFormVisible.value || !isAddMode.value) return
|
|
|
+ if (isAiSuggestRunning.value) return
|
|
|
+
|
|
|
+ const rawTenantId = getTenantId()
|
|
|
+ const tenantId = Array.isArray(rawTenantId) ? rawTenantId[0] : rawTenantId
|
|
|
+ if (!tenantId) {
|
|
|
+ startAiSuggestTimer()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let needRestartTimer = false
|
|
|
+ isAiSuggestRunning.value = true
|
|
|
try {
|
|
|
- if(id===undefined){
|
|
|
- id=multipleSelection.value[0].id
|
|
|
+ const suggest = await getAiSuggest(tenantId)
|
|
|
+ // const suggest = {
|
|
|
+ // restaurantName: '测试餐厅名称',
|
|
|
+ // restaurantDescription: '测试餐厅描述'
|
|
|
+ // }
|
|
|
+ if (!suggest || (!suggest.restaurantName && !suggest.restaurantDescription)) {
|
|
|
+ needRestartTimer = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isAddFormVisible.value || !isAddMode.value) {
|
|
|
+ clearAiSuggestTimer()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const formData = addFoodRef.value?.getFormData?.()
|
|
|
+ const hasRestaurantName = !!formData?.restaurantName?.toString().trim()
|
|
|
+ const hasRestaurantDescription = !!formData?.restaurantDescription?.toString().trim()
|
|
|
+ if (hasRestaurantName && hasRestaurantDescription) {
|
|
|
+ needRestartTimer = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const suggestContentList = [
|
|
|
+ suggest.restaurantName ? `餐厅名称建议:<br/>${suggest.restaurantName}` : '',
|
|
|
+ suggest.restaurantDescription ? `餐厅描述建议:<br/>${suggest.restaurantDescription}` : ''
|
|
|
+ ].filter(Boolean)
|
|
|
+
|
|
|
+ const confirmMessage = [
|
|
|
+ '检测到您在当前页面停留时间过长,是否遇到了问题,我给出了一些表单内容的建议是否进行采纳填写?',
|
|
|
+ ...suggestContentList
|
|
|
+ ].join('<br/><br/>')
|
|
|
+
|
|
|
+ await ElMessageBox.confirm(confirmMessage, '提示', {
|
|
|
+ confirmButtonText: '是',
|
|
|
+ cancelButtonText: '否',
|
|
|
+ type: 'warning',
|
|
|
+ center: true,
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ closeOnClickModal: false,
|
|
|
+ closeOnPressEscape: false
|
|
|
+ })
|
|
|
+
|
|
|
+ addFoodRef.value?.applyAiSuggest?.({
|
|
|
+ restaurantName: suggest.restaurantName,
|
|
|
+ restaurantDescription: suggest.restaurantDescription
|
|
|
+ })
|
|
|
+
|
|
|
+ clearAiSuggestTimer()
|
|
|
+ } catch (error) {
|
|
|
+ needRestartTimer = true
|
|
|
+ } finally {
|
|
|
+ isAiSuggestRunning.value = false
|
|
|
+ if (needRestartTimer && isAddFormVisible.value && isAddMode.value) {
|
|
|
+ startAiSuggestTimer()
|
|
|
}
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+const handleAddFormActivity = () => {
|
|
|
+ if (!isAddFormVisible.value || !isAddMode.value) return
|
|
|
+ startAiSuggestTimer()
|
|
|
+}
|
|
|
+
|
|
|
+const handleAddFormVisibleChange = (visible: boolean) => {
|
|
|
+ isAddFormVisible.value = visible
|
|
|
+ if (!visible) {
|
|
|
+ isAiSuggestStopped.value = true
|
|
|
+ isAddMode.value = false
|
|
|
+ isAiSuggestRunning.value = false
|
|
|
+ clearAiSuggestTimer()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (isAddMode.value) {
|
|
|
+ isAiSuggestStopped.value = false
|
|
|
+ startAiSuggestTimer()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleAddSuccess = async () => {
|
|
|
+ clearAiSuggestTimer()
|
|
|
+ isAiSuggestRunning.value = false
|
|
|
+ isAddMode.value = false
|
|
|
+ await getList()
|
|
|
+}
|
|
|
+
|
|
|
+const deleteItems = async (id) => {
|
|
|
+ try {
|
|
|
+ if (id === undefined) {
|
|
|
+ id = multipleSelection.value[0].id
|
|
|
+ }
|
|
|
|
|
|
// 取消的二次确认
|
|
|
await message.delConfirm('确定要删除这条餐厅数据吗?')
|
|
|
@@ -172,11 +306,16 @@ const deleteItems = async (id) => {
|
|
|
|
|
|
//添加菜
|
|
|
const addCK = () => {
|
|
|
+ isAddMode.value = true
|
|
|
+ isAiSuggestRunning.value = false
|
|
|
addFoodRef.value.open(undefined)
|
|
|
}
|
|
|
|
|
|
//编辑加菜
|
|
|
const editCK = (item) => {
|
|
|
+ isAddMode.value = false
|
|
|
+ isAiSuggestRunning.value = false
|
|
|
+ clearAiSuggestTimer()
|
|
|
addFoodRef.value.open(item)
|
|
|
}
|
|
|
|
|
|
@@ -231,22 +370,17 @@ const treeRef = ref() // 树的表单
|
|
|
const getList = async () => {
|
|
|
loading.value = true
|
|
|
try {
|
|
|
- // console.log('AAA', queryParams)
|
|
|
- //console.log('AAA', data)
|
|
|
list.value = await getListRestaurant(queryParams)
|
|
|
|
|
|
for (const datum of list.value) {
|
|
|
- let dd=datum.pictures||''
|
|
|
+ let dd = datum.pictures || ''
|
|
|
datum.pictures = JSON.parse(dd)
|
|
|
- let li = datum.pictures||[]
|
|
|
- datum.picturesStr =''
|
|
|
+ let li = datum.pictures || []
|
|
|
+ datum.picturesStr = ''
|
|
|
for (const ddElement of li) {
|
|
|
- datum.picturesStr += `${ddElement.url?ddElement.url:ddElement.fileUrl},`
|
|
|
+ datum.picturesStr += `${ddElement.url ? ddElement.url : ddElement.fileUrl},`
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //console.log('最终值:',list.value)
|
|
|
- // total.value = data.total
|
|
|
} finally {
|
|
|
loading.value = false
|
|
|
}
|
|
|
@@ -316,6 +450,10 @@ onMounted(() => {
|
|
|
getList()
|
|
|
})
|
|
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ clearAiSuggestTimer()
|
|
|
+})
|
|
|
+
|
|
|
// 表头格式
|
|
|
const tableHeaderColor = ({ rowIndex }: any) => {
|
|
|
if (rowIndex === 0) {
|