index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--用户数据-->
  5. <el-col :xs="24">
  6. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
  7. <el-form-item label="专业名称" prop="majorName">
  8. <el-input
  9. v-model="queryParams.majorName"
  10. placeholder="请输入专业名称"
  11. clearable
  12. style="width: 240px"
  13. @keyup.enter.native="handleQuery"
  14. />
  15. </el-form-item>
  16. <el-form-item label="创建时间">
  17. <el-date-picker
  18. v-model="dateRange"
  19. style="width: 240px"
  20. value-format="yyyy-MM-dd"
  21. type="daterange"
  22. range-separator="-"
  23. start-placeholder="开始日期"
  24. end-placeholder="结束日期"
  25. ></el-date-picker>
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  29. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="primary"
  36. plain
  37. icon="el-icon-plus"
  38. size="mini"
  39. @click="handleAdd"
  40. v-hasPermi="['sim:major:add']"
  41. >新增</el-button>
  42. </el-col>
  43. <el-col :span="1.5">
  44. <el-button
  45. type="success"
  46. plain
  47. icon="el-icon-edit"
  48. size="mini"
  49. :disabled="single"
  50. @click="handleUpdate"
  51. v-hasPermi="['sim:major:edit']"
  52. >修改</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="danger"
  57. plain
  58. icon="el-icon-delete"
  59. size="mini"
  60. :disabled="multiple"
  61. @click="handleDelete"
  62. v-hasPermi="['sim:major:remove']"
  63. >删除</el-button>
  64. </el-col>
  65. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  66. </el-row>
  67. <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
  68. <el-table-column type="selection" width="50" align="center" />
  69. <el-table-column label="编号" align="center" key="majorId" prop="majorId" v-if="columns[0].visible" />
  70. <el-table-column label="专业名称" align="center" key="majorName" prop="majorName" v-if="columns[1].visible" />
  71. <el-table-column label="备注" align="center" prop="remark" width="160" v-if="columns[2].visible"/>
  72. <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[3].visible" width="160">
  73. <template slot-scope="scope">
  74. <span>{{ parseTime(scope.row.createTime) }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. label="操作"
  79. align="center"
  80. width="160"
  81. class-name="small-padding fixed-width"
  82. >
  83. <template slot-scope="scope">
  84. <el-button
  85. size="mini"
  86. type="text"
  87. icon="el-icon-edit"
  88. @click="handleUpdate(scope.row)"
  89. v-hasPermi="['sim:major:edit']"
  90. >修改</el-button>
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-delete"
  95. @click="handleDelete(scope.row)"
  96. v-hasPermi="['sim:major:remove']"
  97. >删除</el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. <pagination
  102. v-show="total>0"
  103. :total="total"
  104. :page.sync="queryParams.pageNum"
  105. :limit.sync="queryParams.pageSize"
  106. @pagination="getList"
  107. />
  108. </el-col>
  109. </el-row>
  110. <!-- 添加或修改用户配置对话框 -->
  111. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  112. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  113. <el-row>
  114. <el-col :span="24">
  115. <el-form-item label="专业名称" prop="majorName">
  116. <el-input v-model="form.majorName" placeholder="请输入专业名称" maxlength="30" />
  117. </el-form-item>
  118. </el-col>
  119. </el-row>
  120. <el-row>
  121. <el-col :span="24">
  122. <el-form-item label="备注">
  123. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
  124. </el-form-item>
  125. </el-col>
  126. </el-row>
  127. </el-form>
  128. <div slot="footer" class="dialog-footer">
  129. <el-button type="primary" @click="submitForm">确 定</el-button>
  130. <el-button @click="cancel">取 消</el-button>
  131. </div>
  132. </el-dialog>
  133. </div>
  134. </template>
  135. <script>
  136. import { listMajor, getMajor, delMajor, addMajor, updateMajor, resetUserPwd } from "@/api/sim/major";
  137. export default {
  138. name: "Major",
  139. dicts: ['sys_normal_disable', 'sys_user_sex'],
  140. // components: { Treeselect },
  141. data() {
  142. return {
  143. // 遮罩层
  144. loading: true,
  145. // 选中数组
  146. ids: [],
  147. // 非单个禁用
  148. single: true,
  149. // 非多个禁用
  150. multiple: true,
  151. // 显示搜索条件
  152. showSearch: true,
  153. // 总条数
  154. total: 0,
  155. // 用户表格数据
  156. userList: null,
  157. // 弹出层标题
  158. title: "",
  159. // 是否显示弹出层
  160. open: false,
  161. // 日期范围
  162. dateRange: [],
  163. // 表单参数
  164. form: {},
  165. defaultProps: {
  166. children: "children",
  167. label: "label"
  168. },
  169. // 查询参数
  170. queryParams: {
  171. pageNum: 1,
  172. pageSize: 10,
  173. majorName: undefined,
  174. },
  175. // 列信息
  176. columns: [
  177. { key: 0, label: `编号`, visible: true },
  178. { key: 1, label: `专业名称`, visible: true },
  179. { key: 2, label: `备注`, visible: true },
  180. { key: 3, label: `创建时间`, visible: true }
  181. ],
  182. // 表单校验
  183. rules: {
  184. majorName: [
  185. { required: true, message: "专业名称不能为空", trigger: "blur" },
  186. ],
  187. }
  188. };
  189. },
  190. watch: {
  191. },
  192. created() {
  193. this.getList();
  194. // this.getConfigKey("sys.user.initPassword").then(response => {
  195. // this.initPassword = response.msg;
  196. // });
  197. },
  198. methods: {
  199. /** 查询用户列表 */
  200. getList() {
  201. this.loading = true;
  202. listMajor(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  203. this.userList = response.rows;
  204. this.total = response.total;
  205. this.loading = false;
  206. }
  207. );
  208. },
  209. // 筛选节点
  210. filterNode(value, data) {
  211. if (!value) return true;
  212. return data.label.indexOf(value) !== -1;
  213. },
  214. // 用户状态修改
  215. handleStatusChange(row) {
  216. let text = row.status === "0" ? "启用" : "停用";
  217. this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
  218. return changeUserStatus(row.majorId, row.status);
  219. }).then(() => {
  220. this.$modal.msgSuccess(text + "成功");
  221. }).catch(function() {
  222. row.status = row.status === "0" ? "1" : "0";
  223. });
  224. },
  225. // 取消按钮
  226. cancel() {
  227. this.open = false;
  228. this.reset();
  229. },
  230. // 表单重置
  231. reset() {
  232. this.form = {
  233. majorId: undefined,
  234. majorName: undefined,
  235. remark: undefined,
  236. };
  237. this.resetForm("form");
  238. },
  239. /** 搜索按钮操作 */
  240. handleQuery() {
  241. this.queryParams.pageNum = 1;
  242. this.getList();
  243. },
  244. /** 重置按钮操作 */
  245. resetQuery() {
  246. this.dateRange = [];
  247. this.resetForm("queryForm");
  248. this.queryParams.deptId = undefined;
  249. this.$refs.tree.setCurrentKey(null);
  250. },
  251. // 多选框选中数据
  252. handleSelectionChange(selection) {
  253. this.ids = selection.map(item => item.majorId);
  254. this.single = selection.length != 1;
  255. this.multiple = !selection.length;
  256. },
  257. // 更多操作触发
  258. handleCommand(command, row) {
  259. switch (command) {
  260. case "handleResetPwd":
  261. this.handleResetPwd(row);
  262. break;
  263. case "handleAuthRole":
  264. this.handleAuthRole(row);
  265. break;
  266. default:
  267. break;
  268. }
  269. },
  270. /** 新增按钮操作 */
  271. handleAdd() {
  272. this.reset();
  273. // getMajor().then(response => {
  274. // this.postOptions = response.posts;
  275. // this.roleOptions = response.roles;
  276. this.open = true;
  277. this.title = "添加专业";
  278. // this.form.password = this.initPassword;
  279. // });
  280. },
  281. /** 修改按钮操作 */
  282. handleUpdate(row) {
  283. this.reset();
  284. const majorId = row.majorId || this.ids;
  285. getMajor(majorId).then(response => {
  286. this.form = response.data;
  287. // this.postOptions = response.posts;
  288. // this.roleOptions = response.roles;
  289. // this.$set(this.form, "postIds", response.postIds);
  290. // this.$set(this.form, "roleIds", response.roleIds);
  291. this.open = true;
  292. this.title = "修改专业";
  293. // this.form.password = "";
  294. });
  295. },
  296. /** 提交按钮 */
  297. submitForm: function() {
  298. this.$refs["form"].validate(valid => {
  299. if (valid) {
  300. if (this.form.majorId != undefined) {
  301. updateMajor(this.form).then(response => {
  302. this.$modal.msgSuccess("修改成功");
  303. this.open = false;
  304. this.getList();
  305. });
  306. } else {
  307. addMajor(this.form).then(response => {
  308. this.$modal.msgSuccess("新增成功");
  309. this.open = false;
  310. this.getList();
  311. });
  312. }
  313. }
  314. });
  315. },
  316. /** 删除按钮操作 */
  317. handleDelete(row) {
  318. const majorIds = row.majorId || this.ids;
  319. this.$modal.confirm('是否确认删除编号为"' + majorIds + '"的数据项?').then(function() {
  320. return delMajor(majorIds);
  321. }).then(() => {
  322. this.getList();
  323. this.$modal.msgSuccess("删除成功");
  324. }).catch(() => {});
  325. },
  326. }
  327. };
  328. </script>