index.vue 6.74 KB
<!-- 员工群发 - 列表 -->
<template>
  <div>
    <!-- class="order-detail" -->
    <d2-container>
      <!-- <div class="offline-account"> -->
      <div class="header" slot="header" style="padding: 10px 20px">
        <d2-search
          ref="showSearch"
          class="show-search"
          :search-form="searchForm"
          :label-width="labelWidth"
          :form-data="showFormData"
        />
        <div class="up-btns">
          <el-button @click="handleSearch" size="small" type="primary">
            查询
          </el-button>
          <el-button size="small" @click="handleReset"> 重置 </el-button>
        </div>
      </div>
      <div class="d2-container-content">
        <div class="content-panel">
          <div class="content-item item-first" @click="handleAdd">
            <div class="first-add">
              <i class="el-icon-plus avatar-uploader-desc-icon"></i>
            </div>
            <div class="first-desc">新增产品词条</div>
          </div>
          <div class="content-item" v-for="item in productList" :key="item.id">
            <div class="content-title">
              {{ item.headings }}
            </div>
            <div class="content-time">
              创建时间:{{ item.createdDate | formatTime }}
            </div>
            <div class="content-footer">
              <a class="edit-btn" @click="handleEdit(item)">编辑</a>
              <a class="del-btn" @click="handleDel(item)">删除</a>
            </div>
          </div>
        </div>
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          :total="total"
          layout="sizes,total,->,prev,pager,next,jumper"
        />
      </div>
    </d2-container>
    <add-drawer
      @close="close"
      :form="form"
      :dialogVisible="dialogVisible"
      v-if="dialogVisible"
    ></add-drawer>
  </div>
</template>

<script>
import { Util, deepClone } from "@/common/util"
import { contentTypeList, sendStatusList } from "@/common/constants.js"
import { productPage, productDetail, productDelete } from "@api/contentManager"
import AddDrawer from "../components/AddDrawer/index"
export default {
  name: "productEntry",
  components: {
    AddDrawer
  },
  data() {
    return {
      currentPage: 1,
      pageSize: 10,
      total: 0,
      dialogVisible: false,
      labelWidth: "100px",
      searchForm: {
        headings: ""
      },
      form: {},
      productList: [
        {
          id: 1
        },
        {
          id: 12
        },
        {
          id: 13
        },
        {
          id: 14
        },
        {
          id: 15
        },
        {
          id: 16
        }
      ],
      searchFormSearch: {},
      showFormData: [
        {
          label: "产品名称",
          name: "headings",
          type: "input",
          maxlength: "20",
          isClear: true
        }
      ],
      baseData: {
        contentTypeList: deepClone(contentTypeList),
        sendStatusList: deepClone(sendStatusList)
      },

      infos: [],
      recordInfo: null,
      addVisible: false
    }
  },
  mounted() {
    this.getList()
  },
  filters: {
    formatTime(time) {
      return Util.dateFormate(time, "YYYY-MM-DD HH:mm:ss")
    }
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.currentPage = val
      this.getList()
    },
    getList() {
      productPage({
        pageSize: this.pageSize,
        currentPage: this.currentPage,
        headings: this.searchForm.headings
      }).then((res) => {
        const { list, total } = res || {}
        this.productList = list
        this.total = total
      })
    },
    close() {
      this.dialogVisible = false
      this.handleSearch()
    },
    handleEdit(row) {
      productDetail({ id: row.id }).then((res) => {
        this.form = res || {}
      })
      this.dialogVisible = true
    },
    handleAdd() {
      this.form = {
        pictureList: [],
        content: "",
        audio: ""
      }
      this.dialogVisible = true
    },
    handleSearch() {
      this.getList()
    },
    handleReset() {
      this.searchForm = {
        headings: ""
      }
      this.handleSearch()
    },

    // 删除
    handleDel(row) {
      this.$confirm("删除后不可恢复,是否确定删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        closeOnClickModal: false
      })
        .then(() => {
          productDelete({ id: row.id }).then((res) => {
            this.notice.okTips()
            this.getList()
          })
        })
        .catch((err) => {
          console.log(err)
        })
    },

    goStatisticsPage(row) {
      this.$router.push({
        name: "statisticsPage",
        query: {
          id: row.id,
          title: row.title
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}
.d2-container-content {
  height: calc(100vh - 300px);
  .content-panel {
    height: calc(100% - 20px);
  }
}
.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}
.content-panel {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 将容器分成四个相等的部分 */
  grid-gap: 30px;
  grid-template-rows: repeat(3, 124px); /* 两行,每行100px */
  .content-item {
    overflow: hidden;
    width: 100%;
    height: 124px;
    border-radius: 4px;
    opacity: 1;
    border: 1px solid #0000001a;
    background: #ffffff;
    box-shadow: 0 0 8px 0 #0000000d;
    padding: 16px;
    box-sizing: border-box;
    .content-title {
      color: #333333;
      font-size: 16px;
      font-weight: 600;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      width: 100%;
    }
    .content-time {
      color: #999999;
      font-size: 12px;
      margin: 6px 0;
    }
    .content-footer {
      border-top: 1px solid #0000001a;
      height: 60px;
      line-height: 60px;
      a {
        font-size: 14px;
        color: #666666;
        cursor: pointer;
        &.edit-btn {
          color: #185efe;
          font-size: 14px;
          margin-right: 10px;
        }
      }
    }
    &.item-first {
      text-align: center;
      border: 1px solid #00000026;
      background: #0000000a;
      cursor: pointer;
      .first-add {
        i {
          font-size: 16px;
          margin-top: 20px;
        }
      }
      .first-desc {
        color: #666666;
        font-size: 14px;
        line-height: 32px;
      }
    }
  }
}
</style>