parent
b28b9f520b
commit
3a1c2263b0
@ -0,0 +1,16 @@
|
|||||||
|
import ajax from "@/utils/request";
|
||||||
|
|
||||||
|
export const getEsgList = async (params) =>
|
||||||
|
ajax(`/esg/getEsgList`, "POST", params);
|
||||||
|
|
||||||
|
export const getEsg = async (id) =>
|
||||||
|
ajax(`/esg/getEsg`, "GET", { id });
|
||||||
|
|
||||||
|
export const deleteEsg = async (id) =>
|
||||||
|
ajax(`/esg/deleteEsg`, "GET", { id });
|
||||||
|
|
||||||
|
export const updateEsg = async (params) =>
|
||||||
|
ajax(`/esg/updateEsg`, "POST", params);
|
||||||
|
|
||||||
|
export const addEsg = async (params) =>
|
||||||
|
ajax(`/esg/addEsg`, "POST", params);
|
||||||
@ -0,0 +1,137 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, reactive, onMounted, watch } from "vue";
|
||||||
|
|
||||||
|
import ClassicEditor from "ckeditor5-custom-build/build/ckeditor.js";
|
||||||
|
const editor = ClassicEditor;
|
||||||
|
const editorConfig = ref({
|
||||||
|
simpleUpload: {
|
||||||
|
// The URL that the images are uploaded to.
|
||||||
|
uploadUrl: '/adminapi/article/uploadImage',
|
||||||
|
// // Headers sent along with the XMLHttpRequest to the upload server.
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': 'CSFR-Token',
|
||||||
|
'Authorization' : `${sessionStorage.getItem('token')}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
image: {
|
||||||
|
resize: true,
|
||||||
|
toolbar: [
|
||||||
|
"imageTextAlternative",
|
||||||
|
"|",
|
||||||
|
"imageStyle:alignLeft",
|
||||||
|
"imageStyle:alignRight",
|
||||||
|
"|",
|
||||||
|
"imageStyle:alignBlockLeft",
|
||||||
|
"imageStyle:block",
|
||||||
|
"imageStyle:alignBlockRight",
|
||||||
|
],
|
||||||
|
styles: [
|
||||||
|
'full',
|
||||||
|
'alignLeft',
|
||||||
|
'alignRight',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
import { getNews, addNews, updateNews } from "@/api/news";
|
||||||
|
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
editid: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["close"]);
|
||||||
|
|
||||||
|
const formType = ref("insert");
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const formRef = ref(null);
|
||||||
|
const form = ref({
|
||||||
|
id: 0,
|
||||||
|
title: "",
|
||||||
|
content: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (props.editid) {
|
||||||
|
let res = await getNews(props.editid);
|
||||||
|
if (res.code === 200) {
|
||||||
|
form.value = res.data;
|
||||||
|
formType.value = "update";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const rules = reactive({
|
||||||
|
username: [{ required: true, message: "管理員帳號必填", trigger: 'blur' }],
|
||||||
|
})
|
||||||
|
|
||||||
|
const cancelForm = () => {
|
||||||
|
emit("close", false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitForm = (formEl) => {
|
||||||
|
if (!formEl) return
|
||||||
|
formEl.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
let res;
|
||||||
|
let message;
|
||||||
|
if (formType.value === "update") {
|
||||||
|
form.value.id = props.editid;
|
||||||
|
res = await updateNews(form.value);
|
||||||
|
message = "修改成功.";
|
||||||
|
} else {
|
||||||
|
res = await addNews(form.value);
|
||||||
|
message = "新增成功.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.code === 200) {
|
||||||
|
ElMessage({
|
||||||
|
message: message,
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
|
emit("close", true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage({
|
||||||
|
message: "操作失敗.",
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
status-icon
|
||||||
|
:rules="rules"
|
||||||
|
label-width="120px">
|
||||||
|
<el-form-item label="標題" prop="title">
|
||||||
|
<el-input v-model="form.title" />
|
||||||
|
</el-form-item>
|
||||||
|
<div class="">
|
||||||
|
<ckeditor :editor="editor" v-model="form.content" :config="editorConfig"></ckeditor>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<div class="demo-drawer__footer" style="text-align: right;">
|
||||||
|
<el-button @click="cancelForm">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="submitForm(formRef)">{{
|
||||||
|
loading ? '提交中 ...' : '確認'
|
||||||
|
}}</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ck-editor__editable_inline) {
|
||||||
|
height: 400px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,156 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, reactive, onMounted, watch } from "vue";
|
||||||
|
import { useRouter, useRoute } from "vue-router";
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
import ClassicEditor from "ckeditor5-custom-build/build/ckeditor.js";
|
||||||
|
const editor = ClassicEditor;
|
||||||
|
const editorConfig = ref({
|
||||||
|
simpleUpload: {
|
||||||
|
// The URL that the images are uploaded to.
|
||||||
|
uploadUrl: '/adminapi/article/uploadImage',
|
||||||
|
// // Headers sent along with the XMLHttpRequest to the upload server.
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': 'CSFR-Token',
|
||||||
|
'Authorization' : `${sessionStorage.getItem('token')}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
image: {
|
||||||
|
resize: true,
|
||||||
|
toolbar: [
|
||||||
|
"imageTextAlternative",
|
||||||
|
"|",
|
||||||
|
"imageStyle:alignLeft",
|
||||||
|
"imageStyle:alignRight",
|
||||||
|
"|",
|
||||||
|
"imageStyle:alignBlockLeft",
|
||||||
|
"imageStyle:block",
|
||||||
|
"imageStyle:alignBlockRight",
|
||||||
|
],
|
||||||
|
styles: [
|
||||||
|
'full',
|
||||||
|
'alignLeft',
|
||||||
|
'alignRight',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
import { getEsg, addEsg, updateEsg } from "@/api/esg";
|
||||||
|
|
||||||
|
const formType = ref("insert");
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const formRef = ref(null);
|
||||||
|
const form = ref({
|
||||||
|
id: 0,
|
||||||
|
title: "",
|
||||||
|
content: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (route.query.id) {
|
||||||
|
let res = await getEsg(route.query.id);
|
||||||
|
if (res.code === 200) {
|
||||||
|
form.value = res.data;
|
||||||
|
formType.value = "update";
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: "取得資料失敗.",
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
router.push('/news/esg');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const rules = reactive({
|
||||||
|
title: [{ required: true, message: "ESG標題必填", trigger: 'blur' }],
|
||||||
|
})
|
||||||
|
|
||||||
|
const cancelForm = () => {
|
||||||
|
router.push('/news/esg');
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitForm = (formEl) => {
|
||||||
|
if (!formEl) return
|
||||||
|
formEl.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
let res;
|
||||||
|
let message;
|
||||||
|
if (formType.value === "update") {
|
||||||
|
form.value.id = route.query.id;
|
||||||
|
res = await updateEsg(form.value);
|
||||||
|
message = "修改成功.";
|
||||||
|
} else {
|
||||||
|
res = await addEsg(form.value);
|
||||||
|
message = "新增成功.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.code === 200) {
|
||||||
|
ElMessage({
|
||||||
|
message: message,
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
|
router.push('/news/esg');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ElMessage({
|
||||||
|
message: "請檢查輸入資料是否正確.",
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="main">
|
||||||
|
<!-- Breadcrumb: Start -->
|
||||||
|
<div class="breadcrumb-section">
|
||||||
|
<div>
|
||||||
|
<el-breadcrumb separator="/">
|
||||||
|
<el-breadcrumb-item> 最新消息 </el-breadcrumb-item>
|
||||||
|
<el-breadcrumb-item> ESG </el-breadcrumb-item>
|
||||||
|
</el-breadcrumb>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" @click="$router.back()">回產業動態列表</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Breadcrumb: End -->
|
||||||
|
|
||||||
|
<el-card>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
status-icon
|
||||||
|
:rules="rules"
|
||||||
|
label-width="120px">
|
||||||
|
<el-form-item label="標題" prop="title">
|
||||||
|
<el-input v-model="form.title" />
|
||||||
|
</el-form-item>
|
||||||
|
<div class="">
|
||||||
|
<ckeditor :editor="editor" v-model="form.content" :config="editorConfig"></ckeditor>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<div class="demo-drawer__footer" style="text-align: right;">
|
||||||
|
<el-button @click="cancelForm">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="submitForm(formRef)">{{
|
||||||
|
loading ? '提交中 ...' : '確認'
|
||||||
|
}}</el-button>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.ck-editor__editable_inline) {
|
||||||
|
height: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.demo-drawer__footer{
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,176 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, reactive, onMounted, toRefs } from "vue";
|
||||||
|
import { Plus, Edit, Delete, ArrowDown } from "@element-plus/icons-vue";
|
||||||
|
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
import AscForm from "./components/Form.vue";
|
||||||
|
|
||||||
|
import { getEsgList, deleteEsg } from "@/api/esg";
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { page, pageSize } = toRefs(state);
|
||||||
|
const total = ref(0);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const showFormDraw = ref(false);
|
||||||
|
|
||||||
|
const tableData = ref([]);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getTableData();
|
||||||
|
});
|
||||||
|
|
||||||
|
const getTableData = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
let res = await getEsgList(state);
|
||||||
|
if (res.code === 200) {
|
||||||
|
tableData.value = res.data.list;
|
||||||
|
total.value = res.data.total;
|
||||||
|
}
|
||||||
|
loading.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAdd = () => {
|
||||||
|
editid.value = 0;
|
||||||
|
// showFormDraw.value = true;
|
||||||
|
router.push({
|
||||||
|
path: '/news/esg/form',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEdit = (id) => {
|
||||||
|
editid.value = id;
|
||||||
|
// showFormDraw.value = true;
|
||||||
|
router.push({
|
||||||
|
path: '/news/esg/form',
|
||||||
|
query: {
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = (id) => {
|
||||||
|
ElMessageBox.confirm('確認刪除此紀錄?')
|
||||||
|
.then(async () => {
|
||||||
|
let res = await deleteEsg(id);
|
||||||
|
if (res.code === 200) {
|
||||||
|
ElMessage({
|
||||||
|
message: '刪除成功.',
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
|
getTableData();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
ElMessage({
|
||||||
|
message: '刪除失敗.',
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pagination
|
||||||
|
const handleSizeChange = (val) => {
|
||||||
|
state.pageSize = val;
|
||||||
|
getTableData();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCurrentChange = (val) => {
|
||||||
|
state.page = val;
|
||||||
|
getTableData();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrevClick = (val) => {
|
||||||
|
state.page = val;
|
||||||
|
getTableData();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNextClick = (val) => {
|
||||||
|
state.page = val;
|
||||||
|
getTableData();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Drawer
|
||||||
|
|
||||||
|
const editid = ref(0);
|
||||||
|
|
||||||
|
const handleCloseFormDraw = (val) => {
|
||||||
|
|
||||||
|
showFormDraw.value = false;
|
||||||
|
if(val){
|
||||||
|
getTableData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="main">
|
||||||
|
<!-- Breadcrumb: Start -->
|
||||||
|
<div class="breadcrumb-section">
|
||||||
|
<div>
|
||||||
|
<el-breadcrumb separator="/">
|
||||||
|
<el-breadcrumb-item> 最新消息 </el-breadcrumb-item>
|
||||||
|
<el-breadcrumb-item> ESG </el-breadcrumb-item>
|
||||||
|
</el-breadcrumb>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" :icon="Plus" @click="handleAdd">新增ESG</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Breadcrumb: End -->
|
||||||
|
|
||||||
|
<el-card :body-style="{ padding: '0px' }">
|
||||||
|
<div v-loading="loading">
|
||||||
|
<el-table :data="tableData" style="width: 100%">
|
||||||
|
<el-table-column label="#" prop="id" width="50" />
|
||||||
|
<el-table-column label="標題" prop="title" />
|
||||||
|
<el-table-column label="建立時間" prop="create_time" />
|
||||||
|
<el-table-column label="操作" width="105" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-dropdown>
|
||||||
|
<el-button type="danger">
|
||||||
|
操作<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item :icon="Edit" @click="handleEdit(scope.row.id)">編輯</el-dropdown-item>
|
||||||
|
<el-dropdown-item v-if="scope.row.is_main !== 1" :icon="Delete" @click="handleDelete(scope.row.id)">刪除</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="pagination-block">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="page"
|
||||||
|
v-model:page-size="pageSize"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
layout="->,total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="total"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
@prev-click="handlePrevClick"
|
||||||
|
@next-click="handleNextClick"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-drawer ref="drawerRef" v-model="showFormDraw" :destroy-on-close="true" title="新增管理員" direction="rtl" size="70%">
|
||||||
|
<asc-form :editid="editid" @close="handleCloseFormDraw"/>
|
||||||
|
</el-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\adminapi\controller;
|
||||||
|
|
||||||
|
use app\adminapi\BaseController;
|
||||||
|
use support\Request;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
class EsgController extends BaseController
|
||||||
|
{
|
||||||
|
public function getEsgList(Request $request)
|
||||||
|
{
|
||||||
|
$param = $request->post();
|
||||||
|
$page = isset($param['page']) ? $param['page'] : 1;
|
||||||
|
$pageSize = isset($param['pageSize']) ? $param['pageSize'] : 10;
|
||||||
|
$search = isset($param['search']) ? $param['search'] : [];
|
||||||
|
|
||||||
|
$where = [
|
||||||
|
];
|
||||||
|
|
||||||
|
$list = Db::name('esg')
|
||||||
|
->where($where)
|
||||||
|
->order('create_time', 'desc')
|
||||||
|
->page($page, $pageSize)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$total = Db::name('esg')
|
||||||
|
->where($where)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
foreach($list as $key => $val){
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'list' => $list,
|
||||||
|
'total' => $total
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->Success($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addEsg(Request $request){
|
||||||
|
$params = $request->post();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => isset($params['title'])?$params['title']:'',
|
||||||
|
'content' => isset($params['content'])?$params['content']:'',
|
||||||
|
'create_time' => date('Y-m-d H:i:s',time())
|
||||||
|
];
|
||||||
|
|
||||||
|
try{
|
||||||
|
$id = Db::name('esg')->insertGetId($data);
|
||||||
|
|
||||||
|
AdminLog( $this->uid , '新增產業動態 ' . $id);
|
||||||
|
|
||||||
|
return $this->Success('操作成功');
|
||||||
|
}catch(\Exception $e){
|
||||||
|
AdminLog( $this->uid , '新增產業動態失敗');
|
||||||
|
|
||||||
|
return $this->Error('操作失敗:'. $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteEsg(Request $request){
|
||||||
|
$id = $request->get('id');
|
||||||
|
|
||||||
|
try{
|
||||||
|
$admin_name = getNameById('admin','username',$id);
|
||||||
|
|
||||||
|
$result = Db::name('esg')
|
||||||
|
->where('id',$id)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
AdminLog($this->uid, '刪除管理員 '. $admin_name);
|
||||||
|
return $this->Success('操作成功');
|
||||||
|
}catch(\Exception $e){
|
||||||
|
AdminLog($this->uid, '刪除管理員'.$admin_name.'失敗');
|
||||||
|
return $this->Error('操作失敗');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEsg(Request $request){
|
||||||
|
$id = $request->get('id');
|
||||||
|
|
||||||
|
$user = Db::name('esg')
|
||||||
|
->where('id',$id)
|
||||||
|
->find();
|
||||||
|
|
||||||
|
if(!$user){
|
||||||
|
return $this->Error('資料不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($user['password']);
|
||||||
|
|
||||||
|
$result = $user;
|
||||||
|
|
||||||
|
return $this->Success($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateEsg(Request $request){
|
||||||
|
$params = $request->post();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => isset($params['title'])?$params['title']:'',
|
||||||
|
'content' => isset($params['content'])?$params['content']:'',
|
||||||
|
'update_time' => date('Y-m-d H:i:s',time())
|
||||||
|
];
|
||||||
|
|
||||||
|
try{
|
||||||
|
$result = Db::name('esg')
|
||||||
|
->where('id',$params['id'])
|
||||||
|
->update($data);
|
||||||
|
|
||||||
|
AdminLog($this->uid, '修改產業動態 [' . $params['id'] .']');
|
||||||
|
|
||||||
|
return $this->Success('操作成功');
|
||||||
|
}catch(\Exception $e){
|
||||||
|
|
||||||
|
AdminLog($this->uid, '修改產業動態 [' . $params['id'] . '] 失敗');
|
||||||
|
|
||||||
|
return $this->Error('操作失敗:'. $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<script setup>
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
// const cateData = computed(() => cateRes.value.data);
|
||||||
|
|
||||||
|
const productList = computed(() => prodRes.value.data);
|
||||||
|
|
||||||
|
const keyword = computed(() => route.params.keyword);
|
||||||
|
|
||||||
|
watch(()=>route.params.keyword,(nVal)=>{
|
||||||
|
console.log(nVal);
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
// 取得類別資料
|
||||||
|
// const { data: cateRes } = await useMyFetch('/product/getCategory', "GET", { cat_id })
|
||||||
|
|
||||||
|
// 取得產品列表
|
||||||
|
console.log('keyword',keyword);
|
||||||
|
const { data: prodRes } = await useMyFetch('/product/searchProduct', "GET", { keyword })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!-- <div class="toolbar">
|
||||||
|
<div class="tTitle">{{ cateData.parent_name }}</div>
|
||||||
|
</div> -->
|
||||||
|
<div class="content">
|
||||||
|
<div class="block">
|
||||||
|
<div class="bName"> {{ keyword}} {{ $t('searchResult') }}:
|
||||||
|
<span>{{ $t('total') }} {{ productList.length }} {{ $t('num') }}</span>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="bDesc">{{ cateData.description }}</div> -->
|
||||||
|
<div class="cardGroup">
|
||||||
|
<NuxtLinkLocale class="card" v-for="(prod, i) in productList" :key="i"
|
||||||
|
:to="{path: '/products/detail/'+prod.id}">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="imgCnt md">
|
||||||
|
<img :src="prod.imageurl" :alt="prod.name">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<div class="card-title">{{ prod.name }}</div>
|
||||||
|
<div class="card-desc">{{ prod.description }}</div>
|
||||||
|
<div class="moreBtn">more</div>
|
||||||
|
</div>
|
||||||
|
</NuxtLinkLocale>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less">
|
||||||
|
.card-footer{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in new issue