| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 | <template>  <div class="m-container">    <h2>      <div class="squrt"></div>      学员乐保    </h2>    <div class="m-core">      <save-form        :inline="true"        class="searchForm"        ref="searchForm"        :model="searchForm"        @submit="onSearch"        @reset="onReSet"      >        <el-form-item prop="search">          <el-input            placeholder="学员编号/姓名"            clearable            @keyup.enter.native="              (e) => {                e.target.blur();                $refs.searchForm.save();                onSearch();              }            "            v-model.trim="searchForm.search"          ></el-input>        </el-form-item>        <el-form-item prop="specification">          <el-input            placeholder="具体型号"            clearable            @keyup.enter.native="              (e) => {                e.target.blur();                $refs.searchForm.save();                onSearch();              }            "            v-model.trim="searchForm.specification"          ></el-input>        </el-form-item>        <el-form-item prop="goodsCategoryId">          <el-select            v-model.trim="searchForm.goodsCategoryId"            clearable            placeholder="乐器分类"          >            <el-option              v-for="(item, index) in categoryList"              :key="index"              :label="item.label"              :value="item.value"            ></el-option>          </el-select>        </el-form-item>        <el-form-item prop="status">          <el-select            v-model.trim="searchForm.status"            filterable            clearable            placeholder="是否乐保"          >            <el-option value="0" label="否"></el-option>            <el-option value="1" label="是"></el-option>          </el-select>        </el-form-item>        <el-form-item>          <el-button native-type="submit" type="danger">搜索</el-button>        </el-form-item>        <el-form-item>          <el-button type="primary" native-type="reset">重置</el-button>        </el-form-item>      </save-form>      <el-button        @click="operationStudent('create')"        type="primary"        v-permission="'studentInstrument/add'"        >新增乐器</el-button      >      <div class="tableWrap">        <el-table          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"          :data="tableList"        >          <el-table-column label="学员信息" align="center">            <template slot-scope="scope">              <div @click="gotoStudent(scope.row.studentId)">                <p>                  <el-button type="text"                    >{{ scope.row.studentName }}<br />                    ({{ scope.row.studentId }})</el-button                  >                </p>              </div>            </template>          </el-table-column>          <el-table-column label="学员声部" align="center">            <template slot-scope="scope">              <div>                <p>                  {{ scope.row.subjectName }}                </p>              </div>            </template>          </el-table-column>          <el-table-column label="乐器名称" align="center">            <template slot-scope="scope">              <copy-text>{{ scope.row.goodsName }}</copy-text>            </template>          </el-table-column>          <el-table-column label="具体型号" align="center">            <template slot-scope="scope">              <copy-text>{{ scope.row.specification }}</copy-text>            </template>          </el-table-column>          <el-table-column label="乐器分类" align="center">            <template slot-scope="scope">              <copy-text>{{ scope.row.goodsCategoryName }}</copy-text>            </template>          </el-table-column>          <el-table-column label="是否乐保" align="center" prop="teacherName">            <template slot-scope="scope">              {{ scope.row.status ? "是" : "否" }}            </template>          </el-table-column>          <el-table-column            label="乐保有效期"            align="center"            width="350px"            prop="studentNum"          >            <template slot-scope="scope">              <div v-if="scope.row.startTime && scope.row.endTime">                {{ scope.row.startTime }}~{{ scope.row.endTime }}              </div>            </template>          </el-table-column>          <el-table-column label="操作" align="center">            <template slot-scope="scope">              <auth :auths="['studentInstrument/update']">                <el-button                  type="text"                  @click="operationStudent('update', scope.row)"                  >修改</el-button                >              </auth>              <auth :auths="['studentInstrument/del']">                <el-button type="text" @click="removeMusic(scope.row)"                  >删除</el-button                >              </auth>            </template>          </el-table-column>        </el-table>        <pagination          sync          :total.sync="pageInfo.total"          :page.sync="pageInfo.page"          :limit.sync="pageInfo.limit"          :page-sizes="pageInfo.page_size"          @pagination="getList"        />      </div>      <el-dialog        :title="operationStatus == 'create' ? '新增乐器' : '修改乐器'"        width="600px"        :visible.sync="addMusicVisible"        v-if="addMusicVisible"      >        <addMusic          :categoryList="categoryList"          :operationData="operationData"          :operationStatus="operationStatus"          :chioseStudent="true"          ref="addMusic"          @getList="getList"          @close="addMusicVisible = false"        />        <span slot="footer" class="dialog-footer">          <el-button @click="addMusicVisible = false">取 消</el-button>          <el-button type="primary" @click="addMusicSubmit">确 定</el-button>        </span>      </el-dialog>    </div>  </div></template><script>import pagination from "@/components/Pagination/index";import addMusic from "@/views/studentManager/modals/addMusic";import { getInstrument, studentInstrumentDel } from "@/api/buildTeam";import { categoryListTree } from "@/api/businessManager";export default {  components: { pagination, addMusic },  data() {    return {      soundLists: [],      tableList: [],      searchForm: {        specification: "",        goodsCategoryId: "",        studentId: "",      },      pageInfo: {        // 分页规则        limit: 10, // 限制显示条数        page: 1, // 当前页        total: 0, // 总条数        page_size: [10, 20, 40, 50], // 选择限制显示条数      },      operationStatus: "create",      operationData: null,      addMusicVisible: false,      categoryList: [],    };  },  mounted() {    this.getCategory();    this.getList();  },  methods: {    onSearch() {      this.pageInfo.page = 1;      this.getList();    },    onReSet() {      this.$refs["searchForm"].resetFields();      this.getList();    },    async getList() {      try {        const res = await getInstrument({          ...this.searchForm,          rows: this.pageInfo.limit,          page: this.pageInfo.page,        });        this.tableList = res.data.rows;        this.pageInfo.total = res.data.total;      } catch (e) {        console.log(e);      }    },    addMusicSubmit() {      this.$refs.addMusic.addMusicSubmit();    },    operationStudent(type, row) {      if (type == "update") {        this.operationData = row;      } else if (type == "create") {        this.operationData = null;      }      this.operationStatus = type;      this.addMusicVisible = true;    },    removeMusic(row) {      // 删除乐器      this.$confirm(`您确定删除吗?`, "提示", {        confirmButtonText: "确定",        cancelButtonText: "取消",        type: "warning",      }).then(async () => {        try {          let res = await studentInstrumentDel({            id: row.id,            studentId: row.studentId,          });          this.$message.success("删除成功");          this.getList();        } catch {}      });    },    getCategory() {      let params = {        delFlag: 0,        rows: 9999,      };      categoryListTree(params).then((res) => {        let result = res.data;        if (res.code == 200) {          let tempArray = [];          result.rows.forEach((row) => {            tempArray.push({              label: row.name,              value: row.id,            });          });          this.categoryList = tempArray;        }      });    },    gotoStudent(search) {      this.$router.push({        name: "studentList",        params: { search: search },      });    },  },};</script><style lang="scss" scoped>.tableWrap {  margin-top: 20px;}</style>
 |