index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="学校名称" prop="schoolName">
  5. <el-input
  6. v-model="queryParams.schoolName"
  7. placeholder="请输入学校名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="学校地址" prop="schoolAddress">
  13. <el-input
  14. v-model="queryParams.schoolAddress"
  15. placeholder="请输入学校地址"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="联系人" prop="linkName">
  21. <el-input
  22. v-model="queryParams.linkName"
  23. placeholder="请输入联系人"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="电话" prop="linkPhone">
  29. <el-input
  30. v-model="queryParams.linkPhone"
  31. placeholder="请输入联系人电话"
  32. clearable
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="primary"
  45. plain
  46. icon="el-icon-plus"
  47. size="mini"
  48. @click="handleAdd"
  49. v-hasPermi="['system:school:add']"
  50. >新增</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="success"
  55. plain
  56. icon="el-icon-edit"
  57. size="mini"
  58. :disabled="single"
  59. @click="handleUpdate"
  60. v-hasPermi="['system:school:edit']"
  61. >修改</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="danger"
  66. plain
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['system:school:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="warning"
  77. plain
  78. icon="el-icon-download"
  79. size="mini"
  80. @click="handleExport"
  81. v-hasPermi="['system:school:export']"
  82. >导出</el-button>
  83. </el-col>
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="schoolList" @selection-change="handleSelectionChange">
  87. <el-table-column type="selection" width="55" align="center" />
  88. <el-table-column type="index" label="序号" align="center" />
  89. <el-table-column label="学校名称" align="center" prop="schoolName" />
  90. <el-table-column label="学校地址" align="center" prop="schoolAddress" >
  91. <template v-slot="{row}">
  92. <div class="omit" :title="row.schoolAddress">
  93. {{ row.schoolAddress }}
  94. </div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="联系人" align="center" prop="linkName" />
  98. <el-table-column label="联系人电话" align="center" prop="linkPhone" />
  99. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  100. <template slot-scope="scope">
  101. <el-button
  102. size="mini"
  103. type="text"
  104. icon="el-icon-edit"
  105. @click="handleUpdate(scope.row)"
  106. v-hasPermi="['system:school:edit']"
  107. >修改</el-button>
  108. <el-button
  109. size="mini"
  110. type="text"
  111. icon="el-icon-delete"
  112. @click="handleDelete(scope.row)"
  113. v-hasPermi="['system:school:remove']"
  114. >删除</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <pagination
  119. v-show="total>0"
  120. :total="total"
  121. :page.sync="queryParams.pageNum"
  122. :limit.sync="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. <!-- 添加或修改学校管理对话框 -->
  126. <el-dialog :title="title" :visible.sync="open" width="550px" append-to-body>
  127. <el-form ref="form" :model="form" :rules="rules" :label-width="labelWidth">
  128. <el-form-item label="学校名称" prop="schoolName">
  129. <el-input v-model="form.schoolName" placeholder="请输入学校名称" />
  130. </el-form-item>
  131. <el-form-item label="学校地址" prop="schoolAddress">
  132. <el-input v-model="form.schoolAddress" placeholder="请输入学校地址" />
  133. </el-form-item>
  134. <el-form-item label="联系人" prop="linkName">
  135. <el-input v-model="form.linkName" placeholder="请输入联系人" />
  136. </el-form-item>
  137. <el-form-item label="联系人电话" prop="linkPhone">
  138. <el-input v-model="form.linkPhone" placeholder="请输入联系人电话" />
  139. </el-form-item>
  140. </el-form>
  141. <div slot="footer" class="dialog-footer">
  142. <el-button type="primary" @click="submitForm">确 定</el-button>
  143. <el-button @click="cancel">取 消</el-button>
  144. </div>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import { listSchool, getSchool, delSchool, addSchool, updateSchool } from "@/api/system/school";
  150. export default {
  151. name: "School",
  152. data() {
  153. return {
  154. // 遮罩层
  155. loading: true,
  156. // 选中数组
  157. ids: [],
  158. // 非单个禁用
  159. single: true,
  160. // 非多个禁用
  161. multiple: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 总条数
  165. total: 0,
  166. // 学校管理表格数据
  167. schoolList: [],
  168. // 弹出层标题
  169. title: "",
  170. // 是否显示弹出层
  171. open: false,
  172. // 查询参数
  173. queryParams: {
  174. pageNum: 1,
  175. pageSize: 10,
  176. schoolName: null,
  177. schoolAddress: null,
  178. linkName: null,
  179. linkPhone: null,
  180. },
  181. // 表单参数
  182. form: {},
  183. // 表单校验
  184. rules: {
  185. schoolName: [
  186. { required: true, message: "学校名称不能为空", trigger: "blur" }
  187. ],
  188. schoolAddress: [
  189. { required: true, message: "学校地址不能为空", trigger: "blur" }
  190. ],
  191. linkName: [
  192. { required: true, message: "联系人不能为空", trigger: "blur" }
  193. ],
  194. linkPhone: [
  195. { required: true, message: "联系人电话不能为空", trigger: "blur" },
  196. { pattern: /^1[34578]\d{9}$/, message: "请输入正确的联系人电话", trigger: "blur" }
  197. ],
  198. },
  199. labelWidth: "100px",
  200. };
  201. },
  202. created() {
  203. this.getList();
  204. },
  205. methods: {
  206. /** 查询学校管理列表 */
  207. getList() {
  208. this.loading = true;
  209. listSchool(this.queryParams).then(response => {
  210. this.schoolList = response.rows;
  211. this.total = response.total;
  212. this.loading = false;
  213. });
  214. },
  215. // 取消按钮
  216. cancel() {
  217. this.open = false;
  218. this.reset();
  219. },
  220. // 表单重置
  221. reset() {
  222. this.form = {
  223. id: null,
  224. schoolName: null,
  225. schoolAddress: null,
  226. linkName: null,
  227. linkPhone: null,
  228. delFlag: null,
  229. createBy: null,
  230. createTime: null,
  231. updateBy: null,
  232. updateTime: null
  233. };
  234. this.resetForm("form");
  235. },
  236. /** 搜索按钮操作 */
  237. handleQuery() {
  238. this.queryParams.pageNum = 1;
  239. this.getList();
  240. },
  241. /** 重置按钮操作 */
  242. resetQuery() {
  243. this.resetForm("queryForm");
  244. this.handleQuery();
  245. },
  246. // 多选框选中数据
  247. handleSelectionChange(selection) {
  248. this.ids = selection.map(item => item.id)
  249. this.single = selection.length!==1
  250. this.multiple = !selection.length
  251. },
  252. /** 新增按钮操作 */
  253. handleAdd() {
  254. this.reset();
  255. this.open = true;
  256. this.title = "添加学校管理";
  257. },
  258. /** 修改按钮操作 */
  259. handleUpdate(row) {
  260. this.reset();
  261. const id = row.id || this.ids
  262. getSchool(id).then(response => {
  263. this.form = response.data;
  264. this.open = true;
  265. this.title = "修改学校管理";
  266. });
  267. },
  268. /** 提交按钮 */
  269. submitForm() {
  270. this.$refs["form"].validate(valid => {
  271. if (valid) {
  272. if (this.form.id != null) {
  273. updateSchool(this.form).then(response => {
  274. this.$modal.msgSuccess("修改成功");
  275. this.open = false;
  276. this.getList();
  277. });
  278. } else {
  279. addSchool(this.form).then(response => {
  280. this.$modal.msgSuccess("新增成功");
  281. this.open = false;
  282. this.getList();
  283. });
  284. }
  285. }
  286. });
  287. },
  288. /** 删除按钮操作 */
  289. handleDelete(row) {
  290. const ids = row.id || this.ids;
  291. this.$modal.confirm('是否确认删除学校管理编号为"' + ids + '"的数据项?').then(function() {
  292. return delSchool(ids);
  293. }).then(() => {
  294. this.getList();
  295. this.$modal.msgSuccess("删除成功");
  296. }).catch(() => {});
  297. },
  298. /** 导出按钮操作 */
  299. handleExport() {
  300. this.download('system/school/export', {
  301. ...this.queryParams
  302. }, `school_${new Date().getTime()}.xlsx`)
  303. }
  304. }
  305. };
  306. </script>