studoc.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <script setup>
  2. import { ref, reactive } from "vue";
  3. import { Plus, Calendar, Search, Delete } from "@element-plus/icons-vue";
  4. import { ElMessage, ElMessageBox } from "element-plus";
  5. import user from "~/store/user";
  6. import { useRouter } from "vue-router";
  7. const router = useRouter();
  8. const pageNum = ref(1);
  9. const totalNum = ref("");
  10. const searchValue = ref("");
  11. const tableData = ref("");
  12. const InitData = () => {
  13. request({
  14. url: "/dyaw/xlfw_xsda/index",
  15. data: {
  16. page: pageNum.value,
  17. keyword: searchValue.value,
  18. },
  19. })
  20. .then((res) => {
  21. if (res.code == "1") {
  22. tableData.value = res.data.page_data;
  23. pageNum.value = Number(res.data.total_page);
  24. totalNum.value = Number(res.data.total_rows);
  25. }
  26. })
  27. .catch((err) => {
  28. console.log(err);
  29. });
  30. };
  31. InitData();
  32. //多选
  33. const multipleSelection = ref([]);
  34. const handleSelectionChange = (val) => {
  35. multipleSelection.value = val;
  36. };
  37. //批量删除
  38. const batchDel = () => {
  39. if (multipleSelection.value.length == 0) {
  40. ElMessage({
  41. showClose: true,
  42. message: "请至少选择一项~",
  43. type: "error",
  44. });
  45. } else {
  46. let tempArr = [];
  47. multipleSelection.value.forEach((item) => {
  48. tempArr.push(item.dxx_id);
  49. });
  50. request({
  51. url: "/dyaw/xlfw_xsda/delete",
  52. data: {
  53. dxx_id: tempArr.join(),
  54. },
  55. })
  56. .then((res) => {
  57. if (res.code == "1") {
  58. ElMessage({
  59. message: res.msg,
  60. type: "success",
  61. });
  62. InitData();
  63. }
  64. })
  65. .catch((err) => {
  66. console.log(err);
  67. });
  68. }
  69. };
  70. //按钮-搜索
  71. const searchBtn = () => {
  72. InitData();
  73. };
  74. //按钮-全部档案(跳转)
  75. const allFile = () => {
  76. router.push("studocAll");
  77. };
  78. //表格选项-详情(跳转)
  79. const handlDetailClick = (item) => {
  80. router.push({
  81. path: "studocSingle",
  82. query: {
  83. userId: item.user_id,
  84. },
  85. });
  86. };
  87. //表格选项-删除
  88. const handleDel = (item) => {
  89. request({
  90. url: "/dyaw/xlfw_xsda/delete",
  91. data: {
  92. dxx_id: item.dxx_id,
  93. },
  94. })
  95. .then((res) => {
  96. if (res.code == "1") {
  97. ElMessage({
  98. showClose: true,
  99. message: res.msg,
  100. type: "success",
  101. });
  102. InitData();
  103. }
  104. })
  105. .catch((err) => {
  106. console.log(err);
  107. });
  108. };
  109. //分页
  110. const handleCurrentChange = (val) => {
  111. pageNum.value = val;
  112. InitData();
  113. };
  114. </script>
  115. <template>
  116. <div class="studocList">
  117. <div class="allOptions">
  118. <el-button type="danger" :icon="Delete" round @click="batchDel">批量删除</el-button>
  119. <el-input v-model="searchValue" style="width: 10%; margin: 0 5px 0 20px" placeholder="关键词搜索" :prefix-icon="Search"
  120. round />
  121. <el-button type="primary" round @click="searchBtn">搜索</el-button>
  122. <el-button type="primary" round @click="allFile">全部档案</el-button>
  123. </div>
  124. <div class="allTables">
  125. <el-table ref="multipleTableRef" :data="tableData" stripe @selection-change="handleSelectionChange"
  126. style="width: 100%">
  127. <el-table-column type="selection" width="55" />
  128. <el-table-column type="index" width="80" label="序号" />
  129. <el-table-column prop="dxx_user_realname" label="姓名" />
  130. <el-table-column prop="dxx_school_name" label="学校" />
  131. <el-table-column prop="dxx_grade_name" label="年级" />
  132. <el-table-column prop="dxx_class_name" label="班级" />
  133. <el-table-column prop="dxx_zxcs" label="咨询次数" />
  134. <el-table-column prop="dxx_dasl" label="档案数量" />
  135. <el-table-column fixed="right" label="操作">
  136. <template #default="scope">
  137. <el-button link type="primary" size="small" @click="handlDetailClick(scope.row)">详情</el-button>
  138. <el-button link type="primary" size="small" @click="handleDel(scope.row)">删除</el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <div class="pag">
  143. <el-pagination class="pageC" background small layout=" prev, pager, next" :total="totalNum"
  144. @current-change="handleCurrentChange" />
  145. </div>
  146. </div>
  147. </div>
  148. </template>
  149. <style lang="scss" scoped>
  150. .studocList {
  151. background: #fff;
  152. box-sizing: border-box;
  153. padding: 1%;
  154. }
  155. .allOptions {
  156. text-align: right;
  157. margin-bottom: 10px;
  158. }
  159. .allTables {
  160. margin-top: 20px;
  161. }
  162. .pag {
  163. margin: 20px 0;
  164. overflow: hidden;
  165. }
  166. .pageC {
  167. float: right;
  168. }
  169. </style>