index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 学员乐保
  6. </h2>
  7. <div class="m-core">
  8. <save-form
  9. :inline="true"
  10. class="searchForm"
  11. ref="searchForm"
  12. :model="searchForm"
  13. @submit="onSearch"
  14. @reset="onReSet"
  15. >
  16. <el-form-item prop="search">
  17. <el-input
  18. placeholder="学员编号/姓名"
  19. clearable
  20. @keyup.enter.native="
  21. (e) => {
  22. e.target.blur();
  23. $refs.searchForm.save();
  24. onSearch();
  25. }
  26. "
  27. v-model.trim="searchForm.search"
  28. ></el-input>
  29. </el-form-item>
  30. <el-form-item prop="specification">
  31. <el-input
  32. placeholder="具体型号"
  33. clearable
  34. @keyup.enter.native="
  35. (e) => {
  36. e.target.blur();
  37. $refs.searchForm.save();
  38. onSearch();
  39. }
  40. "
  41. v-model.trim="searchForm.specification"
  42. ></el-input>
  43. </el-form-item>
  44. <el-form-item prop="goodsCategoryId">
  45. <el-select
  46. v-model.trim="searchForm.goodsCategoryId"
  47. clearable
  48. placeholder="乐器分类"
  49. >
  50. <el-option
  51. v-for="(item, index) in categoryList"
  52. :key="index"
  53. :label="item.label"
  54. :value="item.value"
  55. ></el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item prop="status">
  59. <el-select
  60. v-model.trim="searchForm.status"
  61. filterable
  62. clearable
  63. placeholder="是否乐保"
  64. >
  65. <el-option value="0" label="否"></el-option>
  66. <el-option value="1" label="是"></el-option>
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item>
  70. <el-button native-type="submit" type="danger">搜索</el-button>
  71. </el-form-item>
  72. <el-form-item>
  73. <el-button type="primary" native-type="reset">重置</el-button>
  74. </el-form-item>
  75. </save-form>
  76. <el-button
  77. @click="operationStudent('create')"
  78. type="primary"
  79. v-permission="'studentInstrument/add'"
  80. >新增乐器</el-button
  81. >
  82. <div class="tableWrap">
  83. <el-table
  84. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  85. :data="tableList"
  86. >
  87. <el-table-column label="学员信息" align="center">
  88. <template slot-scope="scope">
  89. <div @click="gotoStudent(scope.row.studentId)">
  90. <p>
  91. <el-button type="text"
  92. >{{ scope.row.studentName }}<br />
  93. ({{ scope.row.studentId }})</el-button
  94. >
  95. </p>
  96. </div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="学员声部" align="center">
  100. <template slot-scope="scope">
  101. <div>
  102. <p>
  103. {{ scope.row.subjectName }}
  104. </p>
  105. </div>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="乐器名称" align="center">
  109. <template slot-scope="scope">
  110. <copy-text>{{ scope.row.goodsName }}</copy-text>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="具体型号" align="center">
  114. <template slot-scope="scope">
  115. <copy-text>{{ scope.row.specification }}</copy-text>
  116. </template>
  117. </el-table-column>
  118. <el-table-column label="乐器分类" align="center">
  119. <template slot-scope="scope">
  120. <copy-text>{{ scope.row.goodsCategoryName }}</copy-text>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="是否乐保" align="center" prop="teacherName">
  124. <template slot-scope="scope">
  125. {{ scope.row.status ? "是" : "否" }}
  126. </template>
  127. </el-table-column>
  128. <el-table-column
  129. label="乐保有效期"
  130. align="center"
  131. width="350px"
  132. prop="studentNum"
  133. >
  134. <template slot-scope="scope">
  135. <div v-if="scope.row.startTime && scope.row.endTime">
  136. {{ scope.row.startTime }}~{{ scope.row.endTime }}
  137. </div>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="操作" align="center">
  141. <template slot-scope="scope">
  142. <auth :auths="['studentInstrument/update']">
  143. <el-button
  144. type="text"
  145. @click="operationStudent('update', scope.row)"
  146. >修改</el-button
  147. >
  148. </auth>
  149. <auth :auths="['studentInstrument/del']">
  150. <el-button type="text" @click="removeMusic(scope.row)"
  151. >删除</el-button
  152. >
  153. </auth>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. <pagination
  158. sync
  159. :total.sync="pageInfo.total"
  160. :page.sync="pageInfo.page"
  161. :limit.sync="pageInfo.limit"
  162. :page-sizes="pageInfo.page_size"
  163. @pagination="getList"
  164. />
  165. </div>
  166. <el-dialog
  167. :title="operationStatus == 'create' ? '新增乐器' : '修改乐器'"
  168. width="600px"
  169. :visible.sync="addMusicVisible"
  170. v-if="addMusicVisible"
  171. >
  172. <addMusic
  173. :categoryList="categoryList"
  174. :operationData="operationData"
  175. :operationStatus="operationStatus"
  176. :chioseStudent="true"
  177. ref="addMusic"
  178. @getList="getList"
  179. @close="addMusicVisible = false"
  180. />
  181. <span slot="footer" class="dialog-footer">
  182. <el-button @click="addMusicVisible = false">取 消</el-button>
  183. <el-button type="primary" @click="addMusicSubmit">确 定</el-button>
  184. </span>
  185. </el-dialog>
  186. </div>
  187. </div>
  188. </template>
  189. <script>
  190. import pagination from "@/components/Pagination/index";
  191. import addMusic from "@/views/studentManager/modals/addMusic";
  192. import { getInstrument, studentInstrumentDel } from "@/api/buildTeam";
  193. import { categoryListTree } from "@/api/businessManager";
  194. export default {
  195. components: { pagination, addMusic },
  196. data() {
  197. return {
  198. soundLists: [],
  199. tableList: [],
  200. searchForm: {
  201. specification: "",
  202. goodsCategoryId: "",
  203. studentId: "",
  204. },
  205. pageInfo: {
  206. // 分页规则
  207. limit: 10, // 限制显示条数
  208. page: 1, // 当前页
  209. total: 0, // 总条数
  210. page_size: [10, 20, 40, 50], // 选择限制显示条数
  211. },
  212. operationStatus: "create",
  213. operationData: null,
  214. addMusicVisible: false,
  215. categoryList: [],
  216. };
  217. },
  218. mounted() {
  219. this.getCategory();
  220. this.getList();
  221. },
  222. methods: {
  223. onSearch() {
  224. this.pageInfo.page = 1;
  225. this.getList();
  226. },
  227. onReSet() {
  228. this.$refs["searchForm"].resetFields();
  229. this.getList();
  230. },
  231. async getList() {
  232. try {
  233. const res = await getInstrument({
  234. ...this.searchForm,
  235. rows: this.pageInfo.limit,
  236. page: this.pageInfo.page,
  237. });
  238. this.tableList = res.data.rows;
  239. this.pageInfo.total = res.data.total;
  240. } catch (e) {
  241. console.log(e);
  242. }
  243. },
  244. addMusicSubmit() {
  245. this.$refs.addMusic.addMusicSubmit();
  246. },
  247. operationStudent(type, row) {
  248. if (type == "update") {
  249. this.operationData = row;
  250. } else if (type == "create") {
  251. this.operationData = null;
  252. }
  253. this.operationStatus = type;
  254. this.addMusicVisible = true;
  255. },
  256. removeMusic(row) {
  257. // 删除乐器
  258. this.$confirm(`您确定删除吗?`, "提示", {
  259. confirmButtonText: "确定",
  260. cancelButtonText: "取消",
  261. type: "warning",
  262. }).then(async () => {
  263. try {
  264. let res = await studentInstrumentDel({
  265. id: row.id,
  266. studentId: row.studentId,
  267. });
  268. this.$message.success("删除成功");
  269. this.getList();
  270. } catch {}
  271. });
  272. },
  273. getCategory() {
  274. let params = {
  275. delFlag: 0,
  276. rows: 9999,
  277. };
  278. categoryListTree(params).then((res) => {
  279. let result = res.data;
  280. if (res.code == 200) {
  281. let tempArray = [];
  282. result.rows.forEach((row) => {
  283. tempArray.push({
  284. label: row.name,
  285. value: row.id,
  286. });
  287. });
  288. this.categoryList = tempArray;
  289. }
  290. });
  291. },
  292. gotoStudent(search) {
  293. this.$router.push({
  294. name: "studentList",
  295. params: { search: search },
  296. });
  297. },
  298. },
  299. };
  300. </script>
  301. <style lang="scss" scoped>
  302. .tableWrap {
  303. margin-top: 20px;
  304. }
  305. </style>