index.vue 9.54 KB
Newer Older
qzhxx's avatar
qzhxx committed
1
<template>
2 3
  <div class="listPage H100">
    <div class="search-container">
乐宝呗666's avatar
乐宝呗666 committed
4 5 6 7 8 9 10
      <el-form
        :inline="true"
        :model="form"
        ref="form"
        onsubmit="return false;"
      >
        <el-form-item label="分类名称">
11
          <el-input
乐宝呗666's avatar
乐宝呗666 committed
12
            placeholder="请输入分类名称"
13
            v-model="form.nameOrCode"
乐宝呗666's avatar
乐宝呗666 committed
14
            @keyup.enter.native="onSearch"
15 16 17 18 19
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="版权方有效期">
          <el-date-picker
qzhxx's avatar
qzhxx committed
20
            value-format="yyyy-MM-dd"
乐宝呗666's avatar
乐宝呗666 committed
21
            v-model="form.dateRange"
22 23 24 25 26 27 28 29
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <div class="btn-group">
乐宝呗666's avatar
乐宝呗666 committed
30 31 32 33 34 35 36 37
            <el-button
              type="primary"
              class="btn_form_search"
              @click="onSearch"
              >查询</el-button
            >
            <el-button class="btn_form_search" @click="Reset">重置</el-button
            >
38 39 40 41 42
          </div>
        </el-form-item>
      </el-form>
      <div class="page-tip">
        <span class="page-tip-title">页面说明:</span>
乐宝呗666's avatar
乐宝呗666 committed
43 44 45
        <span class="page-tips"
          >可通过创建时间、展板分类名称模糊搜索快速筛选展板分类信息,可对展板分类信息进行修改、删除。可新增视频分类。</span
        >
46 47 48 49 50 51 52 53 54
      </div>
    </div>
    <div class="table-content">
      <div class="btn-group">
        <el-button type="primary" @click="addPermis()">新建展板分类</el-button>
      </div>
      <div class="party-table">
        <el-table
          border
乐宝呗666's avatar
乐宝呗666 committed
55 56
          style="width: 100%; height: 100%"
          height="100%"
57 58 59
          ref="multipleTable"
          :data="tableData"
        >
乐宝呗666's avatar
乐宝呗666 committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
          <el-table-column
            type="index"
            width="120"
            label="序号"
          ><template slot-scope="scope">
              <span>{{ (page._index - 1) * 10 + scope.$index + 1 }}</span>
            </template></el-table-column>
          <el-table-column label="展板分类名称" prop="name"></el-table-column>
          <el-table-column
            label="版权方"
            prop="copyrightOwnerNames"
          ></el-table-column>
          <el-table-column label="创建时间" prop="createTime"></el-table-column>
          <el-table-column label="备注" prop="remarks"></el-table-column>
          <el-table-column label="操作" header-align="center" align="center">
            <template slot-scope="scope" width="220">
              <div class="table-btn-group">
qzhxx's avatar
qzhxx committed
77 78 79 80 81 82 83 84 85 86 87
                <el-tooltip content="修改" placement="top">
                  <el-button circle @click="openEdit(scope.row)">
                    <i class="icon-table icon-edit"></i>
                  </el-button>
                </el-tooltip>
                <el-tooltip content="删除" placement="top">
                  <el-button circle @click="handleDelete(scope.row)">
                    <i class="icon-table icon-del"></i>
                  </el-button>
                </el-tooltip>
              </div>
乐宝呗666's avatar
乐宝呗666 committed
88 89
            </template>
          </el-table-column>
90 91
        </el-table>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
92
      <party-pagination :page="page" @changePage="handleCurrentChange" />
93
    </div>
乐宝呗666's avatar
乐宝呗666 committed
94 95 96 97 98 99 100 101 102
    <!--新增弹框-->
    <el-dialog
      :title="type?'新建版权方':'编辑版权方'"
      custom-class="party-dialog"
      width="468px"
      :visible.sync="FormVisible"
      :before-close="close"
    >
      <div class="dialog-content">
103 104 105 106 107
        <el-form
          :model="classForm"
          ref="classForm"
          label-width="80px"
          label-position="top"
qzhxx's avatar
qzhxx committed
108
          :rules="rule"
109 110 111 112 113 114 115 116 117 118 119 120
          id="ruleo"
          class="party-form"
        >
          <el-form-item label="展板分类名称" prop="name">
            <el-input v-model="classForm.name"></el-input>
          </el-form-item>
          <el-form-item label="备注">
            <el-input type="textarea" v-model="classForm.remarks"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer btn-group">
乐宝呗666's avatar
乐宝呗666 committed
121 122 123 124 125 126 127
        <el-button size="mini" v-show="type" type="primary" @click="permisSave"
          >确定</el-button
        >
        <el-button size="mini" v-show="!type" type="primary" @click="permisEdit"
          >确定</el-button
        >
        <el-button size="mini" @click="close">取 消</el-button>
128
      </div>
乐宝呗666's avatar
乐宝呗666 committed
129
    </el-dialog>
130 131 132
  </div>
</template>
<script>
乐宝呗666's avatar
乐宝呗666 committed
133
import { partyPagination } from "@/components/index";
134
export default {
乐宝呗666's avatar
乐宝呗666 committed
135
  components: { partyPagination },
136 137
  data() {
    return {
乐宝呗666's avatar
乐宝呗666 committed
138 139
      type: true,
      page: { _index: 1, _size: 10, total: 0 },
140 141 142 143
      tableData: [],
      FormVisible: false,
      formLabelWidth: "100px",
      form: {
乐宝呗666's avatar
乐宝呗666 committed
144
        dateRange:[]
145
      },
乐宝呗666's avatar
乐宝呗666 committed
146 147
      classForm: {},
      rule: {
qzhxx's avatar
qzhxx committed
148
        name: [
乐宝呗666's avatar
乐宝呗666 committed
149
          { required: true, message: "请输入展板分类名称", trigger: "blur" },
qzhxx's avatar
qzhxx committed
150 151
        ],
      },
152
      value: "",
乐宝呗666's avatar
乐宝呗666 committed
153
      name: "",
154 155 156 157 158 159 160
    };
  },
  computed: {},
  mounted() {
    this.onSearch();
  },
  methods: {
乐宝呗666's avatar
乐宝呗666 committed
161 162 163
    onSearch() {
      this.page._index = 1;
      this.getTableData();
164 165
    },
    // 获得数据接口
乐宝呗666's avatar
乐宝呗666 committed
166
    getTableData() {
167
      let vm = this;
乐宝呗666's avatar
乐宝呗666 committed
168 169 170 171 172 173 174
      let param = {
        _index: this.page._index,
        _size: this.page._size,
        nameOrCode:this.form.nameOrCode,
        startDate: this.form.dateRange.length ? this.form.dateRange[0] : "",
        endDate: this.form.dateRange.length ? this.form.dateRange[1] : "",
      };
175 176
      vm.$https(
        {
177
          url: "exhibitionBoardCat/getPageList",
178
          method: "post",
乐宝呗666's avatar
乐宝呗666 committed
179
          authType: this.backToken,
180 181 182
        },
        vm.$qs.stringify(param)
      )
乐宝呗666's avatar
乐宝呗666 committed
183
        .then((res) => {
qzhxx's avatar
qzhxx committed
184
          let data = res.data.data;
185 186 187
          vm.page.total = data.total;
          vm.tableData = data.records;
        })
乐宝呗666's avatar
乐宝呗666 committed
188
        .catch(function (err) {
189 190 191 192 193
          console.log(err);
        });
    },
    // 分页
    handleCurrentChange(val) {
乐宝呗666's avatar
乐宝呗666 committed
194 195
      this.page._index = val;
      this.onSearch();
196
    },
qzhxx's avatar
qzhxx committed
197
    // 重置
乐宝呗666's avatar
乐宝呗666 committed
198 199 200
    Reset() {
      this.form = { dateRange:[]};
      this.onSearch();
201 202 203
    },
    // 添加
    addPermis() {
乐宝呗666's avatar
乐宝呗666 committed
204 205 206
      this.FormVisible = true;
      this.type = true;
      this.classForm = {}
207 208 209 210
    },
    // 新建展板分类确认保存
    permisSave() {
      let _this = this;
乐宝呗666's avatar
乐宝呗666 committed
211
      _this.$refs.classForm.validate((valid) => {
212
        if (valid) {
乐宝呗666's avatar
乐宝呗666 committed
213 214 215 216
          const params ={
            name: this.classForm.name,
            remarks: this.classForm.remarks,
          }
217 218
          _this
            .$https(
乐宝呗666's avatar
乐宝呗666 committed
219 220 221 222 223 224
              {
                url: "exhibitionBoardCat/save",
                method: "post",
                authType: this.backToken,
              },
              _this.$qs.stringify(params)
225 226
            )
            .then(
乐宝呗666's avatar
乐宝呗666 committed
227 228 229
              (res) => {
                if (res.data.resultCode === '200') {
                  _this.$message.success("新建成功!");
230 231
                  //跳回用户列表
                  _this.onSearch();
乐宝呗666's avatar
乐宝呗666 committed
232
                  _this.close()
233
                } else {
乐宝呗666's avatar
乐宝呗666 committed
234
                  _this.$message.error(res.data.msg);
235 236
                }
              },
乐宝呗666's avatar
乐宝呗666 committed
237
              (error) => {
238 239
                _this.$message({
                  type: "error",
乐宝呗666's avatar
乐宝呗666 committed
240
                  message: error,
241 242 243 244 245 246
                });
              }
            );
        }
      });
    },
乐宝呗666's avatar
乐宝呗666 committed
247
    // 编辑展板分类确认保存
248 249
    permisEdit() {
      let _this = this;
乐宝呗666's avatar
乐宝呗666 committed
250
      _this.$refs.classForm.validate((valid) => {
251 252 253
        if (valid) {
          _this
            .$https(
乐宝呗666's avatar
乐宝呗666 committed
254 255 256 257 258
              {
                url: "exhibitionBoardCat/update",
                method: "put",
                authType: this.backToken,
              },
259 260 261
              _this.$qs.stringify(_this.classForm)
            )
            .then(
乐宝呗666's avatar
乐宝呗666 committed
262 263 264
              (res) => {
                if (res.data.resultCode === '200') {
                  _this.$message.success("修改成功!");
265 266
                  //跳回用户列表
                  _this.onSearch();
乐宝呗666's avatar
乐宝呗666 committed
267
                  _this.close()
268
                } else {
乐宝呗666's avatar
乐宝呗666 committed
269
                  _this.$message.error(res.data.msg);
270 271
                }
              },
乐宝呗666's avatar
乐宝呗666 committed
272
              (error) => {
273 274
                _this.$message({
                  type: "error",
乐宝呗666's avatar
乐宝呗666 committed
275
                  message: error,
276 277 278 279 280 281
                });
              }
            );
        }
      });
    },
乐宝呗666's avatar
乐宝呗666 committed
282
    // 关闭
283
    close() {
乐宝呗666's avatar
乐宝呗666 committed
284 285 286
      this.FormVisible = false;
      this.classForm = {}
      this.$refs["classForm"].clearValidate();
287 288 289 290
      this.$refs["classForm"].resetFields();
    },
    // 编辑弹框
    openEdit(row) {
乐宝呗666's avatar
乐宝呗666 committed
291 292 293
      this.type = false;
      this.FormVisible = true;
      this.classForm = JSON.parse(JSON.stringify(row));
294 295 296 297 298 299 300
    },
    // 删除
    handleDelete(row) {
      let _this = this;
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
乐宝呗666's avatar
乐宝呗666 committed
301
        type: "warning",
302 303 304 305
      })
        .then(() => {
          _this
            .$https({
乐宝呗666's avatar
乐宝呗666 committed
306 307 308
              method: "delete",
              url: "exhibitionBoardCat/delete/" + row.id,
              authType: this.backToken,
309 310
            })
            .then(
乐宝呗666's avatar
乐宝呗666 committed
311 312
              (res) => {
                this.$message({ type: "success", message: "删除成功!" });
313 314
                _this.onSearch();
              },
乐宝呗666's avatar
乐宝呗666 committed
315 316 317 318 319 320
              (error) => {
                this.$message({
                  type: "error",
                  message: "删除失败!" + error.response.data,
                });
              }
321
            );
乐宝呗666's avatar
乐宝呗666 committed
322 323 324 325
        })
        .catch(() => {});
    },
  },
326 327 328 329
};
</script>

<style lang="less">
乐宝呗666's avatar
乐宝呗666 committed
330
@import "../../../../style/table.less";
331
</style>