fangyuan
2022-12-16 9ff66017debadfc89bc0c1b796684a4d1dbe2bc3
src/views/systemSetting/device/loudspeaker/index.vue
@@ -23,10 +23,7 @@
    <main>
      <div class="main-content">
        <div class="main-title">
          <el-button
            class="el-icon-plus"
            type="primary"
            @click="dialogCreate = true"
          <el-button class="el-icon-plus button-addition" type="primary" @click="handleAdd"
            >添加</el-button
          >
        </div>
@@ -72,7 +69,7 @@
          </el-table-column>
          <el-table-column prop="operation" label="操作" min-width="20">
            <template slot-scope="scope">
              <div class="btn">
              <div class="operation">
                <span @click="handleEdit(scope.row)">编辑</span>
                <span class="line">|</span>
                <span @click="handleDelete(scope.row)">删除</span>
@@ -106,10 +103,9 @@
        title="添加音柱"
        :visible.sync="dialogCreate"
        width="60%"
        v-if="dialogCreate"
        :before-close="handleClose"
      >
        <MyForm :info="loudspeakerInfo" :closeDialog="null"></MyForm>
        <MyForm :info="loudspeakerInfo" @closeDialog="handleCallBack"></MyForm>
      </el-dialog>
    </footer>
  </div>
@@ -146,14 +142,7 @@
      pageSize: 10,
      currentPage: 1,
      renderFlag: false,
      loudspeakerInfo: {
        id: 0,
        name: "",
        code: "",
        power: "",
        frequencyResponse: "",
        fullRangeSpeaker: "",
      },
      loudspeakerInfo: {},
    };
  },
  created() {
@@ -164,16 +153,42 @@
      "getLoudspeakerList",
      "saveLoudspeaker",
      "updateLoudspeaker",
      "deleteLoudspeaker",
    ]),
    handleAdd() {
      this.loudspeakerInfo = {
        id: 0,
        name: "",
        code: "",
        power: "",
        frequencyResponse: "",
        fullRangeSpeaker: "",
      };
      this.dialogCreate = true;
    },
    handleEdit(row) {
      this.loudspeakerInfo = row;
      this.dialogCreate = true;
    },
    handleDelete(row) {},
    handleDelete(row) {
      this.$confirm("确认删除?").then((_) => {
        this.deleteLoudspeaker(row.id).then((res) => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.setTableData();
        });
      });
    },
    formatSate(row, column) {
      return row.state == 1 ? "在线" : "离线";
    },
    handleCallBack(e) {
      this.currentPage = 1;
      this.dialogCreate = false;
      this.setTableData();
    },
    // 设置表格斑马纹
    tableRowClassName({ row, rowIndex }) {
      if ((rowIndex + 1) % 2 == 0) {
@@ -197,11 +212,12 @@
        pageSize,
        state: context,
      }).then((res) => {
          this.list = res.records;
          this.totalNum = res.total;
        this.list = res.records;
        this.totalNum = res.total;
      });
    },
    handleStateChange(e) {
      this.currentPage = 1;
      this.setTableData();
    },
    // 当前页改变触发事件