index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div>
  3. <el-form :inline="true" :model="firstForm">
  4. <el-form-item label="年级:">
  5. <el-select
  6. v-model="firstForm.grade"
  7. placeholder="请选择年级"
  8. @change="switchGrade"
  9. >
  10. <el-option
  11. v-for="item in gradeList"
  12. :label="item.grade_name"
  13. :value="item.grade_id"
  14. ></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="班级:">
  18. <el-select
  19. v-model="firstForm.class"
  20. placeholder="请选择班级"
  21. clearable
  22. @change="getListData"
  23. >
  24. <el-option
  25. v-for="item in classList"
  26. :label="item.class_name"
  27. :value="item.class_num"
  28. ></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item class="mr10" label="学生姓名:">
  32. <el-input
  33. v-model="firstForm.xsxm"
  34. placeholder="输入学生姓名"
  35. @change="getListData"
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item class="mr10" label="学籍号:">
  39. <el-input
  40. v-model="firstForm.xsxh"
  41. placeholder="输入学籍号"
  42. @change="getListData"
  43. ></el-input>
  44. </el-form-item>
  45. <el-button type="primary" @change="getListData">搜索</el-button>
  46. </el-form>
  47. <el-button
  48. type="primary"
  49. @click="exportAll"
  50. :disabled="tableData.length === 0"
  51. >导出</el-button
  52. >
  53. <el-table
  54. :data="tableData"
  55. tooltip-effect="dark"
  56. class="mt20"
  57. style="width: 100%"
  58. @selection-change="handleSelectionChange"
  59. >
  60. <el-table-column type="selection" align="center" width="55">
  61. </el-table-column>
  62. <el-table-column label="年级" prop="grade_name" width="100">
  63. </el-table-column>
  64. <el-table-column label="班级" prop="class_name" width="100">
  65. </el-table-column>
  66. <el-table-column label="学生姓名" prop="xdwx_xsxm" width="100">
  67. </el-table-column>
  68. <el-table-column
  69. label="学籍号"
  70. prop="xdwx_xsxh"
  71. align="center"
  72. width="150"
  73. >
  74. </el-table-column>
  75. <el-table-column label="性别" prop="xdwx_xsxb" width="100">
  76. </el-table-column>
  77. <el-table-column label="二维码">
  78. <template slot-scope="scope">
  79. <h3 class="qr-code hand" @click="showQr(scope.row)"></h3>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <footer
  84. class="flex-item-none"
  85. style="display: flex; justify-content: flex-end; margin-top: 30px"
  86. >
  87. <el-pagination
  88. background
  89. layout="total,prev, pager, next"
  90. :page-size="limit"
  91. :total="total"
  92. :current-page.sync="cur_page"
  93. @current-change="handleCurrentChange"
  94. ></el-pagination>
  95. </footer>
  96. <el-dialog title="二维码详情" :visible.sync="dialogVisible" width="300px">
  97. <div class="text-center">
  98. <vue-qr
  99. :size="200"
  100. :margin="0"
  101. :auto-color="true"
  102. :dot-scale="1"
  103. :text="appSrc"
  104. colorDark="white"
  105. colorLight="black"
  106. />
  107. </div>
  108. <div slot="footer" class="text-center">
  109. <el-button type="primary" @click="dialogVisible = false"
  110. >确 定</el-button
  111. >
  112. </div>
  113. </el-dialog>
  114. </div>
  115. </template>
  116. <script>
  117. import { xsewm_list, xsewm_export, grade_search, class_search } from "./api";
  118. import { useUserStore } from "@/stores/user";
  119. const { token } = useUserStore();
  120. import VueQr from "vue-qr";
  121. export default {
  122. name: "index",
  123. components: {
  124. VueQr,
  125. },
  126. data() {
  127. return {
  128. limit: 10,
  129. total: 12,
  130. cur_page: 1,
  131. grade_name: "",
  132. class_name: "",
  133. grade_id: "",
  134. class_id: "",
  135. tableData: [],
  136. gradeList: [],
  137. classList: [],
  138. firstForm: {
  139. grade: "",
  140. class: "",
  141. xsxh: "",
  142. xsxm: "",
  143. },
  144. loading: false,
  145. logoSrc: "",
  146. appSrc: "",
  147. dialogVisible: false,
  148. multipleSelection: [],
  149. };
  150. },
  151. methods: {
  152. handleCurrentChange(val) {
  153. this.cur_page = val;
  154. this.getListData();
  155. },
  156. getListData() {
  157. this.loading = true;
  158. let data = {
  159. page: this.cur_page,
  160. limit: this.limit,
  161. keyword: this.firstForm.xsxm,
  162. grade_id: this.firstForm.grade,
  163. class_id: this.firstForm.class,
  164. xdwx_xsxh: this.firstForm.xsxh,
  165. };
  166. xsewm_list(data).then((res) => {
  167. this.loading = false;
  168. this.tableData = res.data.page_data;
  169. this.cur_page = Number(res.data.page_now);
  170. this.total = Number(res.data.total_rows);
  171. });
  172. },
  173. gradeListData() {
  174. let data = {
  175. page: 1,
  176. limit: 9999,
  177. };
  178. grade_search(data).then((res) => {
  179. if (res.code == 1) {
  180. this.gradeList = res.data.page_data;
  181. let obj = {
  182. grade_id: "",
  183. grade_name: "全部",
  184. };
  185. this.gradeList.unshift(obj);
  186. }
  187. });
  188. },
  189. classListData() {
  190. let data = {
  191. grade_id: this.firstForm.grade,
  192. page: 1,
  193. limit: 9999,
  194. };
  195. class_search(data).then((res) => {
  196. if (res.code == 1) {
  197. this.classList = res.data.page_data;
  198. let obj = {
  199. class_id: "",
  200. class_name: "全部",
  201. };
  202. this.classList.unshift(obj);
  203. }
  204. });
  205. },
  206. exportAll() {
  207. let link = "";
  208. if (this.multipleSelection.length === 0) {
  209. link =
  210. window.globalVariables.api +
  211. "/xddy/dygl_wypj_xsewm/index?api=xls&page=1&limit=10000&token=" +
  212. token;
  213. } else {
  214. link =
  215. window.globalVariables.api +
  216. "/xddy/dygl_wypj_xsewm/index?api=xls&page=1&limit=10000&token=" +
  217. token +
  218. "&xdwx_id=" +
  219. this.multipleSelection.join(",");
  220. }
  221. window.open(link, "_self");
  222. },
  223. clearData() {
  224. this.firstForm.grade = "";
  225. this.firstForm.class = "";
  226. },
  227. showQr(item) {
  228. this.appSrc =
  229. "http://60.188.226.44:8000/app/xddy/#/scanCode?xsxm=" +
  230. item.xdwx_xsxm +
  231. "&xsxh=" +
  232. item.xdwx_xsxh +
  233. "&sm_id=" +
  234. item.sm_id +
  235. "&token=" +
  236. token +
  237. "&xdwx_id=" +
  238. item.xdwx_id;
  239. this.dialogVisible = true;
  240. },
  241. switchGrade() {
  242. this.firstForm.class = "";
  243. this.classListData();
  244. this.getListData();
  245. },
  246. handleSelectionChange(val) {
  247. this.multipleSelection = [];
  248. for (let i in val) {
  249. this.multipleSelection.push(val[i].xdwx_id);
  250. }
  251. },
  252. },
  253. mounted() {
  254. this.gradeListData();
  255. this.getListData();
  256. // this.classListData();
  257. },
  258. };
  259. </script>
  260. <style scoped lang="scss">
  261. .qr-code {
  262. width: 28px;
  263. height: 28px;
  264. background: url("@/assets/images/a-2.png") center no-repeat;
  265. background-size: 28px 28px;
  266. }
  267. </style>