|
|
|
|
@ -4,36 +4,31 @@
|
|
|
|
|
* user:sa0ChunLuyu
|
|
|
|
|
* date:2024年10月12日 16:29:26
|
|
|
|
|
*/
|
|
|
|
|
import {ref, onMounted} from 'vue';
|
|
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
|
|
import $router from '@/router'
|
|
|
|
|
import {onBeforeRouteUpdate} from "vue-router";
|
|
|
|
|
import {ElMessage, ElMessageBox} from 'element-plus'
|
|
|
|
|
import { onBeforeRouteUpdate } from 'vue-router'
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
import {
|
|
|
|
|
QuestionItemCreateAction,
|
|
|
|
|
QuestionItemUpdateAction,
|
|
|
|
|
QuestionItemDeleteAction,
|
|
|
|
|
QuestionItemListAction,
|
|
|
|
|
QuestionItemItemAction
|
|
|
|
|
QuestionItemComboAction,
|
|
|
|
|
QuestionItemListAction
|
|
|
|
|
} from '@/api/api.js'
|
|
|
|
|
|
|
|
|
|
const default_page_options = {
|
|
|
|
|
search: '',
|
|
|
|
|
page: 1,
|
|
|
|
|
page: 1
|
|
|
|
|
}
|
|
|
|
|
const page_options = ref(JSON.parse(JSON.stringify(default_page_options)))
|
|
|
|
|
onBeforeRouteUpdate((to) => {
|
|
|
|
|
routerChange(to.query)
|
|
|
|
|
})
|
|
|
|
|
const item_list = ref([])
|
|
|
|
|
const QuestionItemItem = async () => {
|
|
|
|
|
const response = await QuestionItemItemAction({})
|
|
|
|
|
const combo_list = ref([])
|
|
|
|
|
const QuestionItemCombo = async () => {
|
|
|
|
|
const response = await QuestionItemComboAction({})
|
|
|
|
|
if (response.status) {
|
|
|
|
|
item_list.value = response.data.list.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
name: item.sex !== 0 ? `${item.name}(${item.sex === 1 ? '男' : '女'})` : item.name
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
combo_list.value = response.data.list
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error(response.msg)
|
|
|
|
|
}
|
|
|
|
|
@ -43,14 +38,7 @@ const last_page = ref(0)
|
|
|
|
|
const QuestionItemList = async () => {
|
|
|
|
|
const response = await QuestionItemListAction(page_options.value)
|
|
|
|
|
if (response.status) {
|
|
|
|
|
table_list.value = response.data.list.data.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
...item,
|
|
|
|
|
jichu: JSON.parse(item.jichu),
|
|
|
|
|
tuijian: JSON.parse(item.tuijian),
|
|
|
|
|
gaoduan: JSON.parse(item.gaoduan),
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
table_list.value = response.data.list.data
|
|
|
|
|
last_page.value = response.data.list.last_page
|
|
|
|
|
} else {
|
|
|
|
|
ElMessage.error(response.msg)
|
|
|
|
|
@ -60,7 +48,7 @@ const QuestionItemList = async () => {
|
|
|
|
|
const routerChange = (query) => {
|
|
|
|
|
page_options.value = {
|
|
|
|
|
search: query.search || default_page_options.search,
|
|
|
|
|
page: Number(query.page) || default_page_options.page,
|
|
|
|
|
page: Number(query.page) || default_page_options.page
|
|
|
|
|
}
|
|
|
|
|
QuestionItemList()
|
|
|
|
|
}
|
|
|
|
|
@ -72,22 +60,13 @@ const searchClick = (page = 1) => {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const itemNameShow = (items) => {
|
|
|
|
|
let names = []
|
|
|
|
|
for (let i in item_list.value) {
|
|
|
|
|
if (items.includes(String(item_list.value[i].item_id))) {
|
|
|
|
|
names.push(item_list.value[i].name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return names.join('、')
|
|
|
|
|
}
|
|
|
|
|
const edit_data_default = {
|
|
|
|
|
id: 0,
|
|
|
|
|
name: '',
|
|
|
|
|
desc: '',
|
|
|
|
|
jichu: [],
|
|
|
|
|
tuijian: [],
|
|
|
|
|
gaoduan: [],
|
|
|
|
|
jichu: '0',
|
|
|
|
|
tuijian: '0',
|
|
|
|
|
gaoduan: '0'
|
|
|
|
|
}
|
|
|
|
|
const edit_data = ref(JSON.parse(JSON.stringify(edit_data_default)))
|
|
|
|
|
const edit_show = ref(false)
|
|
|
|
|
@ -101,10 +80,7 @@ const updateClick = (row) => {
|
|
|
|
|
const editDoneClick = async () => {
|
|
|
|
|
const $func = edit_data.value.id !== 0 ? QuestionItemUpdateAction : QuestionItemCreateAction
|
|
|
|
|
const response = await $func({
|
|
|
|
|
...edit_data.value,
|
|
|
|
|
jichu: JSON.stringify(edit_data.value.jichu),
|
|
|
|
|
tuijian: JSON.stringify(edit_data.value.tuijian),
|
|
|
|
|
gaoduan: JSON.stringify(edit_data.value.gaoduan),
|
|
|
|
|
...edit_data.value
|
|
|
|
|
})
|
|
|
|
|
if (response.status) {
|
|
|
|
|
edit_show.value = false
|
|
|
|
|
@ -115,7 +91,7 @@ const editDoneClick = async () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QuestionItemDelete = async (id) => {
|
|
|
|
|
const response = await QuestionItemDeleteAction({id})
|
|
|
|
|
const response = await QuestionItemDeleteAction({ id })
|
|
|
|
|
if (response.status) {
|
|
|
|
|
await QuestionItemList()
|
|
|
|
|
} else {
|
|
|
|
|
@ -124,67 +100,28 @@ const QuestionItemDelete = async (id) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const deleteClick = (id) => {
|
|
|
|
|
ElMessageBox.confirm(
|
|
|
|
|
'是否确认删除该项目?',
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确认',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
}
|
|
|
|
|
).then(() => {
|
|
|
|
|
QuestionItemDelete(id)
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
ElMessageBox.confirm('是否确认删除该项目?', '提示', {
|
|
|
|
|
confirmButtonText: '确认',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
QuestionItemDelete(id)
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {})
|
|
|
|
|
}
|
|
|
|
|
const edit_item_data = ref({
|
|
|
|
|
active: 'jichu',
|
|
|
|
|
items: []
|
|
|
|
|
})
|
|
|
|
|
const edit_item_show = ref(false)
|
|
|
|
|
const editItemClick = (type) => {
|
|
|
|
|
edit_item_data.value = {
|
|
|
|
|
active: type,
|
|
|
|
|
items: JSON.parse(JSON.stringify(edit_data.value[type]))
|
|
|
|
|
}
|
|
|
|
|
edit_item_show.value = true
|
|
|
|
|
}
|
|
|
|
|
const editItemDoneClick = () => {
|
|
|
|
|
edit_data.value[edit_item_data.value.active] = JSON.parse(JSON.stringify(edit_item_data.value.items))
|
|
|
|
|
edit_item_show.value = false
|
|
|
|
|
}
|
|
|
|
|
const filterMethod = (query, item) => {
|
|
|
|
|
return item.name.toLowerCase().includes(query.toLowerCase()) || item.pinyin.toLowerCase().includes(query.toLowerCase())
|
|
|
|
|
const comboNameShow = (combo_id) => {
|
|
|
|
|
if (Number(combo_id) === 0) return '无关联套餐'
|
|
|
|
|
return combo_list.value.find((i) => i.combo_id == combo_id).name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
routerChange($router.currentRoute.value.query)
|
|
|
|
|
QuestionItemItem()
|
|
|
|
|
QuestionItemCombo()
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-dialog v-model="edit_item_show" title="关联项目管理" width="610px"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
:close-on-press-escape="false"
|
|
|
|
|
:show-close="false">
|
|
|
|
|
<div>
|
|
|
|
|
<el-transfer
|
|
|
|
|
:titles="['可选项目', '已选项目']"
|
|
|
|
|
:props="{key: 'item_id', label: 'name'}"
|
|
|
|
|
v-model="edit_item_data.items"
|
|
|
|
|
filterable
|
|
|
|
|
:filter-method="filterMethod"
|
|
|
|
|
filter-placeholder="搜索"
|
|
|
|
|
:data="item_list"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
<el-button @click="editItemDoneClick()" type="primary">确定</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="edit_show" :title="`${!!edit_data.id ? '编辑' : '新建'}`">
|
|
|
|
|
<div>
|
|
|
|
|
<el-form label-width="150">
|
|
|
|
|
@ -195,24 +132,42 @@ onMounted(() => {
|
|
|
|
|
<el-input v-model="edit_data.desc" placeholder="请输入项目说明"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="基础项目">
|
|
|
|
|
<span style="margin-right: 10px;">{{ edit_data.jichu.length }} 个关联项目</span>
|
|
|
|
|
<el-button type="primary" size="small" @click="editItemClick('jichu')">编辑项目</el-button>
|
|
|
|
|
<el-select filterable v-model="edit_data.jichu" placeholder="请选择">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="(i, k) in [{ combo_id: '0', name: '暂不关联' }, ...combo_list]"
|
|
|
|
|
:key="k"
|
|
|
|
|
:label="i.name"
|
|
|
|
|
:value="i.combo_id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="推荐项目">
|
|
|
|
|
<span style="margin-right: 10px;">{{ edit_data.tuijian.length }} 个关联项目</span>
|
|
|
|
|
<el-button type="primary" size="small" @click="editItemClick('tuijian')">编辑项目</el-button>
|
|
|
|
|
<el-select filterable v-model="edit_data.tuijian" placeholder="请选择">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="(i, k) in [{ combo_id: '0', name: '暂不关联' }, ...combo_list]"
|
|
|
|
|
:key="k"
|
|
|
|
|
:label="i.name"
|
|
|
|
|
:value="i.combo_id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="高端项目">
|
|
|
|
|
<span style="margin-right: 10px;">{{ edit_data.gaoduan.length }} 个关联项目</span>
|
|
|
|
|
<el-button type="primary" size="small" @click="editItemClick('gaoduan')">编辑项目</el-button>
|
|
|
|
|
<el-select filterable v-model="edit_data.gaoduan" placeholder="请选择">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="(i, k) in [{ combo_id: '0', name: '暂不关联' }, ...combo_list]"
|
|
|
|
|
:key="k"
|
|
|
|
|
:label="i.name"
|
|
|
|
|
:value="i.combo_id"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
<el-button @click="edit_show = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="editDoneClick()">确定</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
<el-button @click="edit_show = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" @click="editDoneClick()">确定</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
@ -220,32 +175,41 @@ onMounted(() => {
|
|
|
|
|
<div class="head">
|
|
|
|
|
<el-row>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-input v-model="page_options.search" placeholder="搜索项目名称"/>
|
|
|
|
|
<el-input v-model="page_options.search" placeholder="搜索项目名称" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-button type="primary" @click="searchClick()" style="margin-left: 10px;">查询</el-button>
|
|
|
|
|
<el-button type="success" @click="createClick()" style="margin-left: 10px;">添加</el-button>
|
|
|
|
|
<el-button type="primary" @click="searchClick()" style="margin-left: 10px"
|
|
|
|
|
>查询</el-button
|
|
|
|
|
>
|
|
|
|
|
<el-button type="success" @click="createClick()" style="margin-left: 10px"
|
|
|
|
|
>添加</el-button
|
|
|
|
|
>
|
|
|
|
|
</el-row>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<el-table :data="table_list" style="width: 100%;" row-key="id" :tooltip-options="{
|
|
|
|
|
<el-table
|
|
|
|
|
:data="table_list"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
row-key="id"
|
|
|
|
|
:tooltip-options="{
|
|
|
|
|
popperClass: 'popper_class_wrapper'
|
|
|
|
|
}">
|
|
|
|
|
<el-table-column prop="id" label="ID" width="100"/>
|
|
|
|
|
<el-table-column prop="name" label="项目名称" width="200"/>
|
|
|
|
|
<el-table-column prop="desc" label="项目说明" show-overflow-tooltip/>
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column prop="id" label="ID" width="100" />
|
|
|
|
|
<el-table-column prop="name" label="项目名称" width="200" />
|
|
|
|
|
<el-table-column prop="desc" label="项目说明" show-overflow-tooltip />
|
|
|
|
|
<el-table-column label="基础项目" show-overflow-tooltip>
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ itemNameShow(scope.row.jichu) }}
|
|
|
|
|
{{ comboNameShow(scope.row.jichu) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="推荐项目" show-overflow-tooltip>
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ itemNameShow(scope.row.tuijian) }}
|
|
|
|
|
{{ comboNameShow(scope.row.tuijian) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="高端项目" show-overflow-tooltip>
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ itemNameShow(scope.row.gaoduan) }}
|
|
|
|
|
{{ comboNameShow(scope.row.gaoduan) }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="操作" width="140">
|
|
|
|
|
@ -257,8 +221,15 @@ onMounted(() => {
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<div class="page">
|
|
|
|
|
<el-pagination v-if="last_page > 0" :current-page="page_options.page" mt-2 background layout="prev, pager, next"
|
|
|
|
|
:page-count="last_page" @update:current-page="searchClick"/>
|
|
|
|
|
<el-pagination
|
|
|
|
|
v-if="last_page > 0"
|
|
|
|
|
:current-page="page_options.page"
|
|
|
|
|
mt-2
|
|
|
|
|
background
|
|
|
|
|
layout="prev, pager, next"
|
|
|
|
|
:page-count="last_page"
|
|
|
|
|
@update:current-page="searchClick"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|