| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <template>
- <div class="notice_changShang">
- <div v-if="isFather">
- <div style="color: #80808059; border: 1px solid"></div>
- <button @click="announce()">发布公告</button>
- <div class="tableD">
- <div class="table_template">
- <table class="table">
- <thead>
- <tr :style="tableHeadStyle">
- <td
- v-for="(item, index) in tableHeaderD"
- :key="index"
- :style="tableHeadStyle"
- >
- {{ item }}
- </td>
- </tr>
- </thead>
- <tbody>
- <tr
- v-for="(obj, index) in tableData"
- :key="index"
- :class="{ table_gray: !discolor && index % 2 === 1 }"
- >
- <td class="titleStyle" @click="goDetailPage(obj)">{{ obj.title || "-" }}</td>
- <td>重要通知</td>
- <td>
- <!--{{-->
- <!--(obj.addtime || "")-->
- <!--.replace("T", " ")-->
- <!--.slice(0, -4)-->
- <!--.replace(RegExp("-", "g"), "/")-->
- <!--}}-->
- {{obj.addtime.substr(0,10)}}
- </td>
- <td v-if="operation" :style="trStyle" class="operationStyle">
- <div class="operationBox">
- <span
- style="cursor: pointer"
- v-for="(operationObj, i) in operation"
- :key="i"
- @click="operationObj.function(obj, index)"
- >{{ operationObj.name }}
- </span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <div class="pageD">
- <TablePage
- :totalPage="totalPage"
- :currentPage="currentPage"
- @change_page="changePage"
- @jump_page="jumpPage"
- />
- <p>共{{ totalPage }}页,共{{ sum }}条数据</p>
- </div>
- </div>
- <router-view :key="this.$route.path"></router-view>
- </div>
- </template>
- <script>
- import TablePage from "../../components/TablePage";
- import { env_url , php_url } from "../../config/env";
- import axiosPhp from "axios";
- export default {
- components: {
- TablePage,
- },
- data() {
- return {
- unifiedUrl:'/lexus_php/api/',
- tableHeaderD: ["标题", "信息类型", "创建时间", "操作"],
- operation: [
- {
- name: "编辑",
- function: (obj) => {
- this.edit(obj);
- },
- },
- {
- name: "删除",
- function: (obj) => {
- this.delNotice(obj.id)
- },
- },
- ],
- // 表格配置
- sum: 0, // 一共有多少条数据
- pageSize: 20, // 每页展示的数据
- discolor: false, // flase是隔行变色
- currentPage: 1,
- tableData: [],
- tableFileData: [],
- tableHeadStyle: {
- background: "#848484",
- height: "36px",
- color: "white",
- },
- trStyle: {
- minwidth: "150px",
- overflow: "hidden",
- },
- onlineUrl: env_url, //'http://8.140.188.129:8080'线上 //http://8.136.230.133:8080 //测试
- userId: localStorage.getItem("userId") || "",
- };
- },
- computed: {
- // 表格总页数
- totalPage() {
- return Math.ceil(this.sum / this.pageSize);
- },
- isFather: function () {
- return this.$route.path === '/changShang';
- },
- },
- methods: {
- goDetailPage(param){
- this.$router.push({
- path: "/changShang/itemDetail",
- query: {
- id:param.id
- },
- });
- },
- // 获取某一页面的数据,展示在表格
- changePage: function (page) {
- this.currentPage = page;
- this.getDataList()
- },
- // 点击上一页,下一页,首页,尾页
- jumpPage: function (item) {
- switch (item) {
- case 1:
- this.currentPage = 1;
- break;
- case 2:
- this.currentPage = this.currentPage - 1;
- break;
- case 3:
- this.currentPage = this.currentPage + 1;
- break;
- case 4:
- this.currentPage = this.totalPage;
- break;
- }
- this.getDataList()
- },
- //编辑
- edit: function (config) {
- console.log(config,'father')
- if(typeof (config.area) === 'string'){
- config.area = (config.area).split(',');
- }
- this.$router.push({
- path: "/changShang/editPage",
- query: config,
- });
- },
- getDataList: function () {
- axiosPhp({
- method: "post",
- url: php_url + this.unifiedUrl + "notice_list.php",
- data: {
- Page: this.currentPage,
- Rows: this.pageSize,
- },
- })
- .then((res) => {
- if (res.data.code === 200) {
- this.sum = res.data.count;
- this.tableData = res.data.data;
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- delNotice: function (id) {
- axiosPhp({
- method: "post",
- url: php_url + this.unifiedUrl + "notice_del.php",
- data: {
- ids:id
- },
- })
- .then((res) => {
- if (res.data.code === 200) {
- alert(res.data.msg);
- this.getDataList();
- }
- })
- .catch((err) => {
- alert(err)
- });
- },
- /* 发布公告 */
- announce: function () {
- this.$router.push({
- path: "/changShang/editPage",
- query: {
- title:'',
- content:``,
- id:'',
- files:[],
- area:['全区']
- },
- });
- },
- },
- watch: {
- // 如果路由发生变化,再次执行该方法
- "$route": "getDataList"
- },
- created() {
- },
- mounted() {
- this.getDataList()
- }
- };
- </script>
- <style scoped lang="less">
- .titleStyle {
- color: #0000ff;
- cursor: pointer;
- }
- /* 查看详情样式 */
- .table_template {
- text-align: center;
- .table {
- background-color: #fff;
- border-collapse: collapse;
- border: none;
- width: 100%;
- td {
- border: 1px solid #ccc;
- height: 36px;
- width: 25%;
- }
- span {
- &:hover {
- cursor: pointer;
- }
- }
- }
- }
- .table_gray {
- background-color: #f5f5f5;
- }
- .operationStyle span {
- color: #0000ff;
- }
- .operationBox {
- width: 100%;
- display: flex;
- justify-content: space-around;
- }
- .HeadLeft {
- border: 1px solid #ccc;
- }
- .pageD {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- margin-top: 10px;
- }
- .pageD p {
- margin-left: 16px;
- }
- .reportStyle {
- text-decoration: underline;
- cursor: pointer;
- }
- .showItemOperationStyle {
- display: none;
- }
- .noJump {
- color: rgb(173, 162, 162);
- cursor: text !important;
- text-decoration: underline;
- }
- .canJump {
- text-decoration: underline;
- }
- .notice_changShang button:nth-of-type(1) {
- position: relative;
- float: right;
- margin: 8px 8px;
- padding: 8px 16px;
- width: 100px;
- height: 35px;
- border-radius: 5px;
- }
- </style>
|