This commit is contained in:
commit
c8ee2b85cc
|
@ -303,7 +303,7 @@ export default {
|
|||
})
|
||||
},
|
||||
beforeAvatarUpload(file) {
|
||||
const isJPG = file.type === 'image/jpeg'
|
||||
/*const isJPG = file.type === 'image/jpeg'
|
||||
const isLt2M = file.size / 1024 / 1024 < 2
|
||||
|
||||
if (!isJPG) {
|
||||
|
@ -312,7 +312,7 @@ export default {
|
|||
if (!isLt2M) {
|
||||
this.$message.error('上传头像图片大小不能超过 2MB!')
|
||||
}
|
||||
return isJPG && isLt2M
|
||||
return isJPG && isLt2M*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,144 @@
|
|||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="filter-container">
|
||||
<el-button class="filter-item" type="primary" icon="el-icon-circle-plus" @click="onAdd">添加</el-button>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
|
||||
<el-table-column align="center" fixed label="ID" width="80" prop="city_id" />
|
||||
<el-table-column align="center" fixed label="城市" width="220" prop="city_name" />
|
||||
<el-table-column align="center" width="220" label="操作">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" size="small" icon="el-icon-edit" @click="onEdit(scope.row)">编辑</el-button>
|
||||
<el-button type="danger" size="small" icon="el-icon-delete" @click="onDel(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getShortcutContent" />
|
||||
|
||||
<el-dialog title="添加城市" :visible.sync="dialogCreate">
|
||||
<el-form label-width="120px" :model="anchors">
|
||||
<el-form-item label="城市">
|
||||
<el-input v-model="anchors.city_name" type="text" placeholder="请输入城市" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button v-loading="loading" type="primary" @click="onSave">保 存</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="编辑城市" :visible.sync="dialogEdit">
|
||||
<el-form label-width="120px" :model="anchors">
|
||||
<el-form-item label="城市">
|
||||
<el-input v-model="anchors.city_name" type="text" placeholder="请输入城市" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button v-loading="loading" type="primary" @click="onSave">保 存</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
<script>
|
||||
import Pagination from '@/components/PaginationFixed'
|
||||
|
||||
export default {
|
||||
name: 'GetQa',
|
||||
components: { Pagination },
|
||||
data() {
|
||||
return {
|
||||
statusArr: { 0: '禁用', 1: '启用' },
|
||||
list: [],
|
||||
total: 0,
|
||||
loading: false,
|
||||
listLoading: true,
|
||||
listQuery: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
status: null,
|
||||
city_name: '',
|
||||
title: '',
|
||||
content: ''
|
||||
},
|
||||
dialogCreate: false,
|
||||
dialogEdit: false,
|
||||
item: {},
|
||||
anchors: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.listQuery.status = this.$route.query.status || null
|
||||
this.listQuery.content = this.$route.query.content || null
|
||||
this.getQaCityList()
|
||||
},
|
||||
methods: {
|
||||
getQaCityList() {
|
||||
this.listLoading = true
|
||||
this.$axios.get('/admin/qacity/getQaCityList', { params: this.listQuery }).then(response => {
|
||||
this.list = response.data.data
|
||||
this.total = response.data.total
|
||||
this.listLoading = false
|
||||
}).catch(() => {
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
onAdd() {
|
||||
this.anchors = { sort: 0 } // 初始化时默认排序值为0
|
||||
this.dialogCreate = true
|
||||
},
|
||||
onEdit(item) {
|
||||
this.anchors = { ...item }
|
||||
this.dialogEdit = true
|
||||
},
|
||||
onSave() {
|
||||
if (this.loading) return
|
||||
this.loading = true
|
||||
const api = this.dialogCreate ? '/admin/qacity/addQaCity' : '/admin/qacity/editQaCity'
|
||||
this.$axios.post(api, this.anchors).then(() => {
|
||||
this.dialogCreate = false
|
||||
this.dialogEdit = false
|
||||
this.loading = false
|
||||
this.getQaCityList()
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
onDel(item) {
|
||||
this.$axios.post('/admin/qacity/delQaCity', { city_id: item.city_id }).then(() => {
|
||||
this.getQaCityList()
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
updateSort(item) {
|
||||
this.$axios.post('/admin/qacity/editQaCity', { id: item.id, sort: item.sort }).then(() => {
|
||||
this.getQaCityList()
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
updateStatus(item) {
|
||||
this.$axios.post('/admin/qacity/editQaCity', { id: item.id, status: item.status }).then(() => {
|
||||
this.getQaCityList()
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-container {
|
||||
position: relative;
|
||||
padding-bottom: 60px; /* 分页条的高度 */
|
||||
}
|
||||
|
||||
.filter-container,
|
||||
.el-table {
|
||||
padding-bottom: 52px; /* 分页条的高度,以避免内容重叠 */
|
||||
}
|
||||
|
||||
.search {
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
|
||||
<el-table-column align="center" fixed label="ID" width="80" prop="id" />
|
||||
<el-table-column align="center" fixed label="城市" width="80" prop="city_name" />
|
||||
<el-table-column align="center" fixed label="城市" width="80" prop="qaCitys.city_name" />
|
||||
<el-table-column align="center" fixed label="标题" width="280" prop="title" />
|
||||
<el-table-column align="center" fixed label="内容" width="380" prop="content" />
|
||||
<el-table-column align="center" label="状态" width="100">
|
||||
|
@ -33,7 +33,17 @@
|
|||
<el-dialog title="添加QA" :visible.sync="dialogCreate">
|
||||
<el-form label-width="120px" :model="anchors">
|
||||
<el-form-item label="城市">
|
||||
<el-input v-model="anchors.city_name" type="text" placeholder="请输入城市" />
|
||||
<el-select v-model="anchors.city_id" placeholder="请选择">
|
||||
<el-form-item style="display: inline-flex;text-align: left;width: 770px;">
|
||||
<el-option
|
||||
v-for="item in getQaCitys"
|
||||
:key="item.city_id"
|
||||
style="display: inline-flex;word-break: break-all;"
|
||||
:label="item.city_name"
|
||||
:value="item.city_id"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="旅游路线">
|
||||
<el-input v-model="anchors.title" type="text" placeholder="请输入旅游路线" />
|
||||
|
@ -41,6 +51,14 @@
|
|||
<el-form-item label="QA内容">
|
||||
<el-input v-model="anchors.content" :rows="6" style="height: 120px" type="textarea" placeholder="QA内容" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="上传行程">
|
||||
<el-input v-model="anchors.title" type="text" placeholder="请输入旅游路线" />
|
||||
<span style="color: #C03639">(只接受压缩包)</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="上传图片">
|
||||
<el-input v-model="anchors.title" type="text" placeholder="请输入旅游路线" />
|
||||
<span style="color: #C03639">(只接受压缩包)</span>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="状态">
|
||||
<el-switch v-model="anchors.status" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949" />
|
||||
</el-form-item>
|
||||
|
@ -75,7 +93,17 @@
|
|||
<el-dialog title="编辑内容" :visible.sync="dialogEdit">
|
||||
<el-form label-width="120px" :model="anchors">
|
||||
<el-form-item label="城市">
|
||||
<el-input v-model="anchors.city_name" type="text" placeholder="请输入城市" />
|
||||
<el-select v-model="anchors.city_id" placeholder="请选择">
|
||||
<el-form-item style="display: inline-flex;text-align: left;width: 770px;">
|
||||
<el-option
|
||||
v-for="item in getQaCitys"
|
||||
:key="item.city_id"
|
||||
style="width: 250px;display: inline-flex;word-break: break-all;"
|
||||
:label="item.city_name"
|
||||
:value="item.city_id"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="旅游路线">
|
||||
<el-input v-model="anchors.title" type="text" placeholder="请输入旅游路线" />
|
||||
|
@ -142,13 +170,15 @@ export default {
|
|||
item: {},
|
||||
imageUrl:'',
|
||||
imageUrls:'',
|
||||
anchors: {}
|
||||
anchors: {},
|
||||
getQaCitys: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.listQuery.status = this.$route.query.status || null
|
||||
this.listQuery.content = this.$route.query.content || null
|
||||
this.getQa()
|
||||
this.getQaCity()
|
||||
},
|
||||
methods: {
|
||||
getQa() {
|
||||
|
@ -169,7 +199,7 @@ export default {
|
|||
this.imageUrls = URL.createObjectURL(file.raw)
|
||||
},
|
||||
onAdd() {
|
||||
this.anchors = { sort: 0 } // 初始化时默认排序值为0
|
||||
this.anchors = {} // 初始化时默认排序值为0
|
||||
this.dialogCreate = true
|
||||
},
|
||||
onEdit(item) {
|
||||
|
@ -195,6 +225,13 @@ export default {
|
|||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
getQaCity(){
|
||||
this.$axios.post('/admin/qacity/getQaCity').then(response => {
|
||||
this.getQaCitys = response.data
|
||||
this.getQa()
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
updateSort(item) {
|
||||
this.$axios.post('/admin/qa/editQa', { id: item.id, sort: item.sort }).then(() => {
|
||||
this.getQa()
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\model\QaCitys;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
|
||||
class QaCityController extends base
|
||||
{
|
||||
/**
|
||||
* cms list
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getQaCityList(Request $request)
|
||||
{
|
||||
$list = QaCitys::paginate($request->get('limit',10));
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
public function getQaCity(Request $request)
|
||||
{
|
||||
$list = QaCitys::order('city_id desc')->select();
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
public function addQaCity(Request $request)
|
||||
{
|
||||
$post = $request->post();
|
||||
if (empty($post['city_name'])) return $this->error(2001, 'city_name data cannot be empty!');
|
||||
|
||||
try {
|
||||
$data = QaCitys::create($post);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error(2002, $e->getMessage());
|
||||
}
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
public function editQaCity(Request $request)
|
||||
{
|
||||
$post = $request->post();
|
||||
if (empty($post['city_id'])) return $this->error(2001, 'id data cannot be empty!');
|
||||
$city_id = $post['city_id'];
|
||||
unset($post['city_id']);
|
||||
|
||||
try {
|
||||
$data = QaCitys::where('city_id',$city_id)->update($post);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error(2002, $e->getMessage());
|
||||
}
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
public function delQaCity(Request $request)
|
||||
{
|
||||
$city_id = $request->post('city_id');
|
||||
if (empty($city_id)) return $this->error(2001, 'city_id data cannot be empty!');
|
||||
try {
|
||||
$data = QaCitys::where('city_id',$city_id)->delete();
|
||||
} catch (\Exception $e) {
|
||||
return $this->error(2002, $e->getMessage());
|
||||
}
|
||||
return $this->success($data);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|||
|
||||
use app\model\QaCitys;
|
||||
use app\model\Qas;
|
||||
use support\Log;
|
||||
use support\Request;
|
||||
|
||||
class QaController extends base
|
||||
|
@ -11,9 +12,17 @@ class QaController extends base
|
|||
public function getQaList(Request $request)
|
||||
{
|
||||
$city_id = $request->get('city_id');
|
||||
if (empty($city_id)) return $this->error(2001, 'city_id data cannot be empty!');
|
||||
$keyword = $request->get('keyword');
|
||||
|
||||
$list = Qas::where(['status'=>1,'city_id'=>$city_id])->fieldRaw('title,content')->select();
|
||||
$list = Qas::order('id decs');
|
||||
|
||||
if (!empty($city_id)){
|
||||
$list = $list->where(['status' => 1, 'city_id' => $city_id]);
|
||||
}
|
||||
if (!empty($keyword)){
|
||||
$list = $list->whereRaw("title LIKE ? OR content LIKE ?", ['%'.$keyword.'%', '%'.$keyword.'%']);
|
||||
}
|
||||
$list = $list->paginate($request->get('limit',10));
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
@ -29,7 +38,7 @@ class QaController extends base
|
|||
$title = $request->get('title');
|
||||
$status = $request->get('status');
|
||||
|
||||
$list = Qas::order('create_time desc');
|
||||
$list = Qas::with('qaCitys')->order('create_time desc');
|
||||
|
||||
if (!empty($title)){
|
||||
$list = $list->where('title','like','%'.$title.'%');
|
||||
|
@ -47,7 +56,7 @@ class QaController extends base
|
|||
$id = $request->get('id');
|
||||
if (empty($id)) return $this->error(2001, 'id data cannot be empty!');
|
||||
|
||||
$data = Qas::where('status',1)->fieldRaw('id,city_name,title,content')->find();
|
||||
$data = Qas::where('status',1)->find();
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
@ -55,7 +64,7 @@ class QaController extends base
|
|||
public function addQa(Request $request)
|
||||
{
|
||||
$post = $request->post();
|
||||
if (empty($post['city_name'])) return $this->error(2001, 'city_name data cannot be empty!');
|
||||
if (empty($post['city_id'])) return $this->error(2001, 'city_id data cannot be empty!');
|
||||
if (empty($post['title'])) return $this->error(2001, 'title data cannot be empty!');
|
||||
if (empty($post['content'])) return $this->error(2001, 'content data cannot be empty!');
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ class adminAuth implements MiddlewareInterface
|
|||
if($path) {
|
||||
//白名单
|
||||
$url = [
|
||||
'/admin/login'
|
||||
'/admin/login',
|
||||
'admin/index/avatar'
|
||||
];
|
||||
if(in_array($path, $url)) {
|
||||
return $next($request);
|
||||
|
|
|
@ -5,4 +5,9 @@ namespace app\model;
|
|||
class Qas extends base
|
||||
{
|
||||
|
||||
public function qaCitys()
|
||||
{
|
||||
return $this->hasOne(QaCitys::class,'city_id','city_id');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue