index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 小小艺术家训练营
  7. </h2>
  8. <div class="m-core">
  9. <save-form
  10. :inline="true"
  11. :model="searchForm"
  12. @submit="search"
  13. @reset="onReSet"
  14. ref="searchForm"
  15. >
  16. <el-form-item prop="name">
  17. <el-input
  18. v-model.trim="searchForm.name"
  19. clearable
  20. @keyup.enter.native="
  21. (e) => {
  22. e.target.blur();
  23. $refs.searchForm.save();
  24. search();
  25. }
  26. "
  27. placeholder="训练营标题"
  28. ></el-input>
  29. </el-form-item>
  30. <el-form-item prop="state">
  31. <el-select
  32. v-model.trim="searchForm.state"
  33. clearable
  34. filterable
  35. placeholder="训练营状态"
  36. >
  37. <el-option
  38. v-for="(item, index) in campStateList"
  39. :key="index"
  40. :value="item.value"
  41. :label="item.label"
  42. ></el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item prop="applyTime">
  46. <el-date-picker
  47. v-model.trim="searchForm.applyTime"
  48. type="daterange"
  49. value-format="yyyy-MM-dd"
  50. range-separator="至"
  51. start-placeholder="报名开始日期"
  52. end-placeholder="报名结束日期"
  53. :picker-options="{
  54. firstDayOfWeek: 1,
  55. }"
  56. >
  57. </el-date-picker>
  58. </el-form-item>
  59. <el-form-item prop="trainTime">
  60. <el-date-picker
  61. v-model.trim="searchForm.trainTime"
  62. type="daterange"
  63. value-format="yyyy-MM-dd"
  64. range-separator="至"
  65. start-placeholder="训练开始日期"
  66. end-placeholder="训练结束日期"
  67. :picker-options="{
  68. firstDayOfWeek: 1,
  69. }"
  70. >
  71. </el-date-picker>
  72. </el-form-item>
  73. <el-form-item>
  74. <el-button native-type="submit" type="primary">搜索</el-button>
  75. <el-button native-type="reset" type="danger">重置</el-button>
  76. </el-form-item>
  77. </save-form>
  78. <div class="buttunWtap">
  79. <auth auths="tempLittleArtistTrainingCamp/add">
  80. <el-button
  81. type="primary"
  82. style="margin-bottom: 30px; margian-right: 10px"
  83. @click="addCamp"
  84. >新建训练营</el-button
  85. >
  86. </auth>
  87. <auth auths="tempLittleArtistTrainingCamp/queryPageTrainingCampUser">
  88. <el-button type="primary" style="margin-bottom: 30px" @click="getRosterList"
  89. >参与名单</el-button
  90. >
  91. </auth>
  92. </div>
  93. <div class="tableWrap">
  94. <el-table
  95. style="width: 100%"
  96. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  97. :data="tableList"
  98. >
  99. <el-table-column
  100. align="center"
  101. prop="id"
  102. label="训练营编号"
  103. ></el-table-column>
  104. <el-table-column
  105. align="center"
  106. prop="name"
  107. label="训练营标题"
  108. ></el-table-column>
  109. <el-table-column align="center" prop="studentId" label="状态">
  110. <template slot-scope="scope">
  111. <div>
  112. {{ scope.row.state | campStateListFilter }}
  113. </div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column align="center" prop="studentId" label="报名时间段">
  117. <template slot-scope="scope">
  118. <div>
  119. <p>{{ scope.row.applyStartDate | dayjsFormat }}</p>
  120. <p>{{ scope.row.applyEndDate | dayjsFormat }}</p>
  121. </div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column align="center" prop="studentId" label="训练时间段">
  125. <template slot-scope="scope">
  126. <div>
  127. <p>{{ scope.row.trainStartDate | dayjsFormat }}</p>
  128. <p>{{ scope.row.trainEndDate | dayjsFormat }}</p>
  129. </div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column align="center" prop="studentId" label="操作">
  133. <template slot-scope="scope">
  134. <div>
  135. <auth auths="tempLittleArtistTrainingCamp/queryUserTrainingDetail">
  136. <el-button type="text" @click="lookCamp(scope.row)"
  137. >详情</el-button
  138. >
  139. </auth>
  140. <auth
  141. :auths="'tempLittleArtistTrainingCamp/update'"
  142. >
  143. <el-button
  144. type="text"
  145. @click="resetCamp(scope.row)"
  146. v-if="scope.row.state != 'ING' && scope.row.state != 'END'"
  147. >修改</el-button
  148. >
  149. </auth>
  150. <auth
  151. auths="tempLittleArtistTrainingCamp/delete"
  152. v-if="scope.row.state == 'READY'"
  153. >
  154. <el-button type="text" @click="deleteCamp(scope.row)"
  155. >删除</el-button
  156. >
  157. </auth>
  158. </div>
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <pagination
  163. sync
  164. :total.sync="rules.total"
  165. :page.sync="rules.page"
  166. :limit.sync="rules.limit"
  167. :page-sizes="rules.page_size"
  168. @pagination="getList"
  169. />
  170. </div>
  171. </div>
  172. <eidtCamp @getList="getList" ref="eidtCamp" />
  173. <campRosterList ref="campRosterList"/>
  174. </div>
  175. </template>
  176. <script>
  177. import axios from "axios";
  178. import { getToken } from "@/utils/auth";
  179. import pagination from "@/components/Pagination/index";
  180. import load from "@/utils/loading";
  181. import { getTimes } from "@/utils";
  182. import { campStateList } from "@/utils/searchArray";
  183. import { getTrainingCampList,delTrainingCamp } from "./api";
  184. import campRosterList from "./models/campRosterList";
  185. import eidtCamp from "./models/eidtCamp";
  186. //
  187. export default {
  188. components: { pagination, eidtCamp, campRosterList },
  189. data() {
  190. return {
  191. searchForm: {
  192. search: null,
  193. applyTime: [],
  194. trainTime: [],
  195. },
  196. campStateList,
  197. tableList: [],
  198. organList: [],
  199. rules: {
  200. // 分页规则
  201. limit: 10, // 限制显示条数
  202. page: 1, // 当前页
  203. total: 0, // 总条数
  204. page_size: [10, 20, 40, 50], // 选择限制显示条数
  205. },
  206. };
  207. },
  208. //生命周期 - 创建完成(可以访问当前this实例)
  209. created() {},
  210. //生命周期 - 挂载完成(可以访问DOM元素)
  211. mounted() {
  212. // 获取分部
  213. this.init();
  214. },
  215. methods: {
  216. init() {
  217. this.getList();
  218. },
  219. async getList() {
  220. let { applyTime, trainTime, ...rest } = this.searchForm;
  221. let params = {
  222. ...rest,
  223. page: this.rules.page,
  224. rows: this.rules.limit,
  225. ...getTimes(applyTime, ["applyStartDate", "applyEndDate"]),
  226. ...getTimes(trainTime, ["trainStartDate", "trainEndDate"]),
  227. };
  228. try {
  229. const res = await getTrainingCampList({ ...params });
  230. this.tableList = res.data.rows;
  231. this.rules.total = res.data.total;
  232. } catch (e) {
  233. console.log(e);
  234. }
  235. },
  236. search() {
  237. this.rules.page = 1;
  238. this.getList();
  239. },
  240. onReSet() {},
  241. lookCamp(row) {
  242. console.log(row)
  243. this.$router.push({path:'/operateManager/aristCampDetail',query:{id:row.id,imGroupIds:row.imGroupIds,name:row.name}})
  244. },
  245. resetCamp(row) {
  246. this.$refs.eidtCamp.openDioag(row);
  247. },
  248. deleteCamp(row) {
  249. this.$confirm("确定删除?", "提示", {
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消",
  252. type: "warning",
  253. })
  254. .then(() => {
  255. delTrainingCamp(row.id).then((res) => {
  256. if (res.code === 200) {
  257. this.$message.success("删除成功");
  258. this.getList();
  259. // this.routeOrderStatus = false;
  260. }
  261. });
  262. })
  263. .catch();
  264. },
  265. addCamp() {
  266. this.$refs.eidtCamp.openDioag();
  267. },
  268. getRosterList(){
  269. this.$refs.campRosterList.openDioag();
  270. }
  271. },
  272. };
  273. </script>
  274. <style lang='scss' scoped>
  275. </style>