123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <div class="data-list">
- <el-table
- :data="dataList"
- style="width: 100%"
- header-row-class-name="headerBg"
- empty-text="没有文档信息"
- >
- <el-table-column prop="id" label="ID" align="center" width="80" />
- <el-table-column
- prop="title"
- label="文档名称"
- align="left"
- min-width="180"
- />
- <el-table-column
- prop="user_name"
- label="创建人"
- align="center"
- width="150"
- />
- <el-table-column
- prop="category.name"
- label="所属分类"
- align="center"
- width="150"
- />
- <el-table-column
- prop="createTime"
- label="创建时间"
- align="center"
- width="150"
- />
- <el-table-column
- prop="status"
- label="文档状态"
- align="center"
- width="150"
- >
- <template #default="scope">
- <div v-if="scope.row.status == 5">启用</div>
- <div v-if="scope.row.status == 6">停用</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" :width="editWidth()">
- <template #default="scope">
- <div class="btns">
- <el-button
- type="primary"
- size="small"
- v-if="allowEdit"
- @click="btnEdit(scope.row.id)"
- ><svg-icon icon-class="edit" />编辑</el-button
- >
- <el-button
- type="danger"
- size="small"
- v-if="allowDelete"
- @click="btnDelete(scope.row.id)"
- ><svg-icon icon-class="delete" />删除</el-button
- >
- </div>
- </template>
- </el-table-column>
- </el-table>
- <div class="page-info">
- <el-pagination
- :currentPage="queryForm.page"
- :page-size="queryForm.pageSize"
- :total="recordCount"
- :page-count="pageTotal"
- background
- layout="prev, pager, next"
- @current-change="ChangePage"
- >
- </el-pagination>
- </div>
- </div>
- </template>
- <script>
- import { searchDocument, deleteDocument } from "@/api/document";
- export default {
- props: {
- queryForm: {
- type: Object,
- default: () => {
- return {
- page: 1,
- pageSize: 10,
- title: "",
- category_id: "",
- status: "",
- };
- },
- },
- allowEdit: {
- type: Boolean,
- default: false,
- },
- allowDelete: {
- type: Boolean,
- default: false,
- },
- },
- watch: {
- queryForm: {
- handler: function (val) {
- this.search();
- },
- // immediate: true,//立即执行
- deep: true,
- },
- },
- data() {
- return {
- dialogVisible: false, //控制产品审核
- currentDataId: 0,
- recordCount: 0,
- pageTotal: 1,
- dataList: [],
- currentData: {},
- };
- },
- mounted() {
- this.search();
- },
- methods: {
- editWidth() {
- if (this.allowDelete && this.allowEdit) {
- return 200;
- }
- if (this.allowDelete || this.allowEdit) {
- return 120;
- }
- return 100;
- },
- onFocusVal(e) {
- let _this = this;
- _this.currentDataId = e.target.dataset.id;
- },
- onChangeVal(e) {
- let _this = this;
- let par = {
- id: _this.currentDataId,
- val: e,
- };
- },
- btnDelete(e) {
- let _this = this;
- let par = {
- id: e,
- };
- _this
- .$confirm("您是否确认删除该记录?", "提示", {
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then((res) => {
- // console.log("AAA")
- deleteDocument(par).then((res) => {
- _this.search();
- });
- })
- .catch(() => {});
- },
- searchData() {
- let _this = this;
- _this.dialogVisible = false;
- _this.search();
- },
- //编辑
- btnEdit(e) {
- let _this = this;
- let a = document.createElement("a");
- a.href = "#/document/create?articleId=" + e; // 使用 hash
- a.target = "_blank";
- a.click();
- // _this.$router.push({path:"/document/create",query:{articleId:e}})
- },
- handleClose() {
- let _this = this;
- _this.currentData = {};
- _this.dialogVisible = false;
- },
- //搜索
- search() {
- let _this = this;
- searchDocument(_this.queryForm).then((res) => {
- if (!res) return;
- /* res.data.dataList.filter(el => el.is_template == 0)
- console.log(res.data.dataList); */
- _this.dataList = res.data.dataList.filter(el => el.is_template == 0);
- _this.recordCount = res.data.totalRecord;
- _this.pageTotal = res.data.pageTotal;
- });
- },
- //修改分页
- ChangePage(e) {
- let _this = this;
- _this.queryForm.page = e;
- _this.search();
- },
- },
- };
- </script>
- <style lang="scss">
- @import "./dataList.scss";
- </style>
|