index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div id="schoolManagement">
  3. <search-box
  4. ref="search_box"
  5. :formList="formList"
  6. @search="search"
  7. @init="init"
  8. />
  9. <table-list
  10. :tableSets="tableSet"
  11. :tableData="tableData"
  12. :navText="navText"
  13. @addClick="addClick"
  14. :loading="loading"
  15. @editInfo="editInfo"
  16. >
  17. <template slot="btn" slot-scope="props">
  18. <el-button type="text" @click="addClick(props.scope.row, 0)"
  19. >修改</el-button
  20. >
  21. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  22. </template>
  23. </table-list>
  24. <pagination
  25. :total="total"
  26. :pageSize="pageSize"
  27. :currentPage="currentPage"
  28. @handleSizeChange="handleSizeChange"
  29. @handleCurrentChange="handleCurrentChange"
  30. />
  31. <el-dialog
  32. :visible.sync="dialogBox"
  33. width="560px"
  34. :show-close="false"
  35. :destroy-on-close="true"
  36. :before-close="closeBefore"
  37. :fullscreen="fullscreen"
  38. >
  39. <div slot="title" class="hearders">
  40. <div class="leftTitle">
  41. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  42. </div>
  43. <div class="rightBoxs">
  44. <img
  45. src="@/assets/images/Max@2x.png"
  46. alt=""
  47. @click="fullscreen = !fullscreen"
  48. />
  49. <img src="@/assets/images/Close@2x.png" alt="" @click="closeBefore" />
  50. </div>
  51. </div>
  52. <el-row class="contentBox" :span="24">
  53. <el-form
  54. label-position="right"
  55. label-width="120px"
  56. :model="poppleData"
  57. :rules="rules"
  58. ref="poppleData"
  59. >
  60. <el-form-item label="学校名称" prop="schoolName">
  61. <el-input v-model="poppleData.schoolName"></el-input>
  62. </el-form-item>
  63. <el-form-item label="学校等级" prop="dictCode">
  64. <el-select
  65. v-model="poppleData.dictCode"
  66. placeholder="请选择学校等级"
  67. >
  68. <el-option
  69. v-for="item in optionsList"
  70. :key="item.value"
  71. :label="item.label"
  72. :value="item.value"
  73. >
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="是否启用" prop="status">
  78. <el-radio-group v-model="poppleData.status">
  79. <el-radio :label="1">启用</el-radio>
  80. <el-radio :label="0">停用</el-radio>
  81. </el-radio-group>
  82. </el-form-item>
  83. <el-form-item label="学校联系人">
  84. <el-input v-model="poppleData.contact"></el-input>
  85. </el-form-item>
  86. <el-form-item label="联系方式">
  87. <el-input v-model="poppleData.phone"></el-input>
  88. </el-form-item>
  89. <el-form-item label="优势专业">
  90. <el-input v-model="poppleData.advantageSpecialty"></el-input>
  91. </el-form-item>
  92. <el-form-item label="地点">
  93. <el-input v-model="poppleData.address"></el-input>
  94. </el-form-item>
  95. <el-form-item label="简介">
  96. <el-input
  97. type="textarea"
  98. :rows="2"
  99. placeholder="请输入简介"
  100. v-model="poppleData.introduction"
  101. ></el-input>
  102. </el-form-item>
  103. </el-form>
  104. </el-row>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button @click="closeBefore">关闭</el-button>
  107. <el-button @click="submitForm('poppleData')" type="primary"
  108. >确定</el-button
  109. >
  110. </div>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import searchBox from "@/components/searchBox";
  116. import tableList from "@/components/tableList";
  117. import pagination from "@/components/pagination";
  118. export default {
  119. components: { searchBox, tableList, pagination },
  120. data() {
  121. return {
  122. loading: false, //当前表单加载是否加载动画
  123. navText: {
  124. title: "查出学校共有",
  125. index: 0,
  126. ch: "所",
  127. num: true,
  128. choice: true,
  129. addHide: false,
  130. backFatherBtn: {
  131. status: false,
  132. title: "未定义",
  133. },
  134. },
  135. //搜索
  136. formList: [
  137. {
  138. label:"学校名称",
  139. prop:"schoolName",
  140. placeholder: "请输入学校名称",
  141. scope:"selects",
  142. options:[],
  143. },
  144. {
  145. label: "学校联系人",
  146. prop: "contact",
  147. placeholder: "请输入学校联系人",
  148. },
  149. {
  150. label: "联系方式",
  151. prop: "phone",
  152. placeholder: "请输入联系方式",
  153. },
  154. {
  155. label: "学校等级",
  156. prop: "dictCode",
  157. placeholder: "请选择学校等级",
  158. scope: "select",
  159. options: [],
  160. },
  161. {
  162. label: "学校状态",
  163. prop: "status",
  164. placeholder: "请选择学校状态",
  165. scope: "select",
  166. options: [
  167. {
  168. label: "启用",
  169. value: 1,
  170. },
  171. {
  172. label: "关闭",
  173. value: 0,
  174. },
  175. ],
  176. },
  177. ],
  178. // 表单
  179. tableSet: [
  180. {
  181. label: "学校名称",
  182. prop: "schoolName",
  183. hidden: true,
  184. },
  185. {
  186. label: "学校联系人",
  187. prop: "contact",
  188. hidden: true,
  189. },
  190. {
  191. label: "联系方式",
  192. prop: "phone",
  193. hidden: true,
  194. },
  195. {
  196. label: "学校等级",
  197. prop: "dictLabel",
  198. hidden: true,
  199. },
  200. {
  201. label: "优势专业",
  202. prop: "advantageSpecialty",
  203. hidden: true,
  204. },
  205. {
  206. label: "地址",
  207. prop: "address",
  208. hidden: true,
  209. },
  210. {
  211. label: "用户数",
  212. prop: "userNum",
  213. hidden: true,
  214. scope: "isNums",
  215. },
  216. {
  217. label: "启用状态",
  218. prop: "status",
  219. hidden: true,
  220. scope: "status",
  221. },
  222. {
  223. label: "简介",
  224. prop: "introduction",
  225. hidden: true,
  226. },
  227. ],
  228. poppleData: {},
  229. tableData: [], //表单数据
  230. total: 0, //一共多少条+
  231. pageSize: 10, //每页多少条数据
  232. currentPage: 1, //当前页码
  233. fullscreen: false,
  234. dialogBox: false,
  235. optionsList: [],
  236. statusPop: 0,
  237. rules: {
  238. schoolName: [
  239. { required: true, message: "请输入学校名称", trigger: "blur" },
  240. ],
  241. dictCode: [
  242. { required: true, message: "请选择学校等级", trigger: "change" },
  243. ],
  244. status: [
  245. { required: true, message: "请选择是否启用", trigger: "change" },
  246. ],
  247. },
  248. };
  249. },
  250. mounted() {
  251. this.search();
  252. this.getSchoolType();
  253. },
  254. methods: {
  255. editInfo(options) {
  256. this.$router.push({
  257. name: "/personalManagement",
  258. params: {
  259. schoolName: options.schoolName,
  260. },
  261. });
  262. console.log(options);
  263. },
  264. getSchoolType() {
  265. this.$api.obtaindictdata({ dictTypeId: 11 }).then((res) => {
  266. var listsT = [];
  267. res.rows.forEach((item, index) => {
  268. var ac = {
  269. value: item.dictCode,
  270. label: item.dictLabel,
  271. };
  272. listsT.push(ac);
  273. });
  274. this.formList.forEach((item, index) => {
  275. if (item.prop === "dictCode") {
  276. item.options = listsT;
  277. this.optionsList = listsT;
  278. }
  279. });
  280. });
  281. },
  282. submitForm(formName) {
  283. var self = this;
  284. this.$refs[formName].validate((valid) => {
  285. if (valid) {
  286. self.rulesTableSumbit();
  287. } else {
  288. return false;
  289. }
  290. });
  291. },
  292. search(v, os) {
  293. this.loading = true;
  294. if (os) {
  295. this.currentPage = 1;
  296. }
  297. if(v === undefined){
  298. v = {}
  299. }
  300. var data = {
  301. schoolName: v.schoolName,
  302. contact: v.contact,
  303. phone: v.phone,
  304. dictCode: v.dictCode,
  305. status: v.status === undefined ? "0,1" : v.status,
  306. pageSize: this.pageSize,
  307. pageNum: this.currentPage,
  308. };
  309. this.$api.inquireuserschoolList(data).then((res) => {
  310. this.tableData = res.rows;
  311. this.total = res.total;
  312. this.navText.index = res.total;
  313. });
  314. this.loading = false;
  315. },
  316. init() {
  317. this.search();
  318. },
  319. rulesTableSumbit() {
  320. var data = {
  321. address: this.poppleData.address,
  322. advantageSpecialty: this.poppleData.advantageSpecialty,
  323. contact: this.poppleData.contact,
  324. dictCode: this.poppleData.dictCode,
  325. introduction: this.poppleData.introduction,
  326. phone: this.poppleData.phone,
  327. schoolCity: this.poppleData.schoolCity,
  328. schoolName: this.poppleData.schoolName,
  329. status: this.poppleData.status,
  330. };
  331. if (this.statusPop === 1) {
  332. this.$api.adduserschool(data).then((res) => {
  333. if (res.code === 200) {
  334. this.$message.success("新增成功");
  335. this.search();
  336. this.dialogBox = false;
  337. }
  338. });
  339. } else {
  340. data.id = this.poppleData.id;
  341. this.$api.edituserschool(data).then((res) => {
  342. if (res.code === 200) {
  343. this.$message.success("修改成功");
  344. this.search();
  345. this.dialogBox = false;
  346. }
  347. });
  348. }
  349. },
  350. del(options) {
  351. var self = this;
  352. this.$confirm("此操作将删除该学校, 是否继续?", "提示", {
  353. confirmButtonText: "确定",
  354. cancelButtonText: "取消",
  355. type: "warning",
  356. })
  357. .then(() => {
  358. self.$api
  359. .edituserschool({
  360. id: options.id,
  361. status: -1,
  362. schoolName: options.schoolName,
  363. })
  364. .then((res) => {
  365. if (res.code === 200) {
  366. self.$message.success("删除成功");
  367. self.search();
  368. }
  369. });
  370. })
  371. .catch(() => {});
  372. },
  373. closeBefore() {
  374. this.dialogBox = false;
  375. this.fullscreen = false;
  376. this.poppleData = {};
  377. },
  378. addClick(v, int) {
  379. if (v === undefined) {
  380. this.statusPop = 1;
  381. this.poppleData = {};
  382. } else {
  383. this.statusPop = int;
  384. this.$api.obtainuserschool(v.id).then((res) => {
  385. this.poppleData = res.data;
  386. });
  387. }
  388. this.$nextTick(() => {
  389. this.$refs.poppleData.clearValidate();
  390. });
  391. this.dialogBox = true;
  392. },
  393. handleSizeChange(v) {
  394. this.pageSize = v;
  395. this.currentPage = 1;
  396. this.search(this.$refs.search_box.formData);
  397. },
  398. handleCurrentChange(v) {
  399. this.currentPage = v;
  400. this.search(this.$refs.search_box.formData);
  401. },
  402. },
  403. };
  404. </script>
  405. <style lang="less" scoped>
  406. /deep/.el-button {
  407. border-radius: 8px;
  408. }
  409. /deep/.el-dialog {
  410. border-radius: 8px;
  411. .el-dialog__header {
  412. padding: 0;
  413. .hearders {
  414. height: 40px;
  415. display: flex;
  416. align-items: center;
  417. justify-content: space-between;
  418. padding: 0px 18px 0px 20px;
  419. border-bottom: 1px solid #e2e2e2;
  420. .leftTitle {
  421. font-size: 14px;
  422. font-weight: bold;
  423. color: #2f4378;
  424. }
  425. .rightBoxs {
  426. display: flex;
  427. align-items: center;
  428. img {
  429. width: 14px;
  430. height: 14px;
  431. margin-left: 13px;
  432. cursor: pointer;
  433. }
  434. }
  435. }
  436. }
  437. .el-dialog__body {
  438. padding: 0;
  439. .contentBox {
  440. padding: 20px 20px 5px;
  441. .el-col {
  442. padding: 0px 20px;
  443. margin-bottom: 30px;
  444. header {
  445. margin-bottom: 6px;
  446. color: #2f4378;
  447. font-size: 14px;
  448. }
  449. }
  450. }
  451. }
  452. .el-dialog__footer {
  453. padding: 0;
  454. .dialog-footer {
  455. padding: 0px 40px;
  456. height: 70px;
  457. border-top: 1px solid #e2e2e2;
  458. display: flex;
  459. align-items: center;
  460. justify-content: flex-end;
  461. }
  462. }
  463. }
  464. .imgBox {
  465. width: 100%;
  466. // height: 210px;
  467. border: 1px solid #e2e2e2;
  468. border-radius: 8px;
  469. padding: 8px 8px 3px;
  470. display: flex;
  471. flex-direction: column;
  472. align-items: center;
  473. .imgLabel {
  474. flex: 1;
  475. width: 100%;
  476. border: 1px dotted #e2e2e2;
  477. color: #999;
  478. font-size: 14px;
  479. cursor: pointer;
  480. border-radius: 8px;
  481. .msPhoto {
  482. display: flex;
  483. justify-content: center;
  484. align-items: center;
  485. max-width: 100%;
  486. max-height: 270px;
  487. img {
  488. max-width: 100%;
  489. max-height: 270px;
  490. }
  491. }
  492. .imgbbx {
  493. display: flex;
  494. flex-direction: column;
  495. align-items: center;
  496. justify-content: center;
  497. width: 100%;
  498. height: 100%;
  499. i {
  500. font-weight: bold;
  501. margin: 14px 0;
  502. font-size: 24px;
  503. }
  504. }
  505. }
  506. p {
  507. margin: 5px 0px;
  508. }
  509. }
  510. .avatar-uploader .el-upload {
  511. border: 1px dashed #d9d9d9;
  512. border-radius: 6px;
  513. cursor: pointer;
  514. position: relative;
  515. overflow: hidden;
  516. }
  517. .avatar-uploader .el-upload:hover {
  518. border-color: #409eff;
  519. }
  520. .avatar-uploader-icon {
  521. font-size: 28px;
  522. color: #8c939d;
  523. width: 178px;
  524. height: 178px;
  525. line-height: 178px;
  526. text-align: center;
  527. }
  528. .avatar {
  529. width: 178px;
  530. height: 178px;
  531. display: block;
  532. }
  533. </style>