DataManage.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div class="data-manage">
  3. <div class="part-box">
  4. <Form ref="FilterForm" label-position="left" :label-width="80" inline>
  5. <FormItem label="工作">
  6. <WorkSelect
  7. v-model.trim="filter.workId"
  8. placeholder="请选择工作"
  9. style="width:200px;"
  10. ></WorkSelect>
  11. </FormItem>
  12. <FormItem label="科目">
  13. <SubjectSelect
  14. v-model.trim="filter.subjectId"
  15. :work-id="filter.workId"
  16. placeholder="请选择科目"
  17. style="width:200px;"
  18. ></SubjectSelect>
  19. </FormItem>
  20. <FormItem label="用户">
  21. <CollectUserSelect
  22. v-model.trim="filter.userId"
  23. placeholder="请选择用户"
  24. style="width:200px;"
  25. ></CollectUserSelect>
  26. </FormItem>
  27. <FormItem label="年级名称">
  28. <Input
  29. v-model.trim="filter.name"
  30. placeholder="年级名称模糊查询"
  31. clearable
  32. ></Input>
  33. </FormItem>
  34. <FormItem label="年级状态">
  35. <Select v-model="filter.status" style="width: 150px;" clearable>
  36. <Option v-for="(val, key) in ABLE_TYPE" :key="key" :value="key">{{
  37. val
  38. }}</Option>
  39. </Select>
  40. </FormItem>
  41. <FormItem :label-width="0">
  42. <Button type="primary" icon="ios-search" @click="toPage(1)"
  43. >查询</Button
  44. >
  45. </FormItem>
  46. </Form>
  47. </div>
  48. <div class="part-box">
  49. <div class="part-title">
  50. <div class="part-title-infos">
  51. <Button type="primary" icon="md-add" @click="toAdd">新增</Button>
  52. </div>
  53. </div>
  54. <Table
  55. ref="TableList"
  56. :columns="columes"
  57. :data="grades"
  58. disabled-hover
  59. border
  60. ></Table>
  61. <div class="part-page">
  62. <Page
  63. size="small"
  64. :current="current"
  65. :total="total"
  66. :page-size="size"
  67. @on-change="toPage"
  68. ></Page>
  69. </div>
  70. </div>
  71. <!-- modify-data -->
  72. <modify-data
  73. :instance="curCourse"
  74. @modified="getList"
  75. ref="ModifyData"
  76. ></modify-data>
  77. </div>
  78. </template>
  79. <script>
  80. import { ABLE_TYPE } from "@/constants/enumerate";
  81. import { courseList, deleteCourse, updateCourseStatus } from "../api";
  82. import ModifyData from "../components/ModifyData";
  83. import WorkSelect from "@/components/WorkSelect";
  84. import SubjectSelect from "@/components/SubjectSelect";
  85. import CollectUserSelect from "@/components/CollectUserSelect";
  86. export default {
  87. name: "data-manage",
  88. components: { ModifyData, WorkSelect, SubjectSelect, CollectUserSelect },
  89. data() {
  90. return {
  91. filter: {
  92. name: "",
  93. status: "",
  94. userId: "",
  95. workId: "",
  96. subjectId: ""
  97. },
  98. current: 1,
  99. size: this.GLOBAL.pageSize,
  100. total: 0,
  101. grades: [],
  102. curCourse: {},
  103. ABLE_TYPE,
  104. columes: [
  105. {
  106. title: "序号",
  107. type: "index",
  108. width: 100,
  109. align: "center"
  110. },
  111. {
  112. title: "年级名称",
  113. key: "name",
  114. minWidth: 200
  115. },
  116. {
  117. title: "状态",
  118. key: "status",
  119. minWidth: 200,
  120. render: (h, param) => {
  121. return h("span", ABLE_TYPE[param.row.status]);
  122. }
  123. },
  124. {
  125. title: "操作",
  126. key: "action",
  127. width: 160,
  128. align: "center",
  129. render: (h, param) => {
  130. const actions = [
  131. {
  132. name: "编辑",
  133. action: () => {
  134. this.toEdit(param.row);
  135. }
  136. },
  137. {
  138. name: "删除",
  139. type: "error",
  140. action: () => {
  141. this.toDelete(param.row);
  142. }
  143. },
  144. {
  145. name: param.row.status === "ENABLE" ? "禁用" : "启用",
  146. type: param.row.status === "ENABLE" ? "error" : "primary",
  147. action: () => {
  148. this.toAble(param.row);
  149. }
  150. }
  151. ];
  152. return h("div", this.$tableAction(h, actions));
  153. }
  154. }
  155. ]
  156. };
  157. },
  158. created() {
  159. // this.getList();
  160. },
  161. methods: {
  162. async getList() {
  163. const datas = {
  164. ...this.filter,
  165. current: this.current,
  166. size: this.size
  167. };
  168. const data = await courseList(datas);
  169. this.grades = data.list.map(item => {
  170. return {
  171. id: item.id,
  172. name: item.name,
  173. status: item.status,
  174. createTime: item.createTime
  175. };
  176. });
  177. this.total = data.totalCount;
  178. },
  179. toPage(page) {
  180. this.current = page;
  181. this.getList();
  182. },
  183. toAdd() {
  184. this.curCourse = {};
  185. this.$refs.ModifyData.open();
  186. },
  187. toEdit(row) {
  188. this.curCourse = row;
  189. this.$refs.ModifyData.open();
  190. },
  191. async toAble(row) {
  192. const status = row.status === "ENABLE" ? "DISABLE" : "ENABLE";
  193. await updateCourseStatus({ id: row.id, status });
  194. this.$Message.success("修改成功!");
  195. row.status = status;
  196. },
  197. toDelete(row) {
  198. this.$Modal.confirm({
  199. title: "删除警告",
  200. content: "确定要删除当前学校吗?",
  201. onOk: () => {
  202. this.toDel(row.id);
  203. }
  204. });
  205. },
  206. async toDel(id) {
  207. await deleteCourse(id);
  208. this.$Message.success("删除成功!");
  209. // 解决最后一项删除后的问题
  210. this.deletePageLastItem();
  211. }
  212. }
  213. };
  214. </script>