index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="岗位编码" prop="postCode">
  5. <el-input
  6. v-model="queryParams.postCode"
  7. placeholder="请输入岗位编码"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="岗位名称" prop="postName">
  14. <el-input
  15. v-model="queryParams.postName"
  16. placeholder="请输入岗位名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态" prop="status">
  23. <el-select v-model="queryParams.status" placeholder="岗位状态" clearable size="small">
  24. <el-option
  25. v-for="dict in dict.type.sys_normal_disable"
  26. :key="dict.value"
  27. :label="dict.label"
  28. :value="dict.value"
  29. />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  34. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  35. </el-form-item>
  36. </el-form>
  37. <el-row :gutter="10" class="mb8">
  38. <el-col :span="1.5">
  39. <el-button
  40. type="primary"
  41. plain
  42. icon="el-icon-plus"
  43. size="mini"
  44. @click="handleAdd"
  45. v-hasPermi="['system:post:add']"
  46. >新增</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['system:post:edit']"
  57. >修改</el-button>
  58. </el-col>
  59. <el-col :span="1.5">
  60. <el-button
  61. type="danger"
  62. plain
  63. icon="el-icon-delete"
  64. size="mini"
  65. :disabled="multiple"
  66. @click="handleDelete"
  67. v-hasPermi="['system:post:remove']"
  68. >删除</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="warning"
  73. plain
  74. icon="el-icon-download"
  75. size="mini"
  76. :loading="exportLoading"
  77. @click="handleExport"
  78. v-hasPermi="['system:post:export']"
  79. >导出</el-button>
  80. </el-col>
  81. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  82. </el-row>
  83. <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
  84. <el-table-column type="selection" width="55" align="center" />
  85. <el-table-column label="岗位编号" align="center" prop="postId" />
  86. <el-table-column label="岗位编码" align="center" prop="postCode" />
  87. <el-table-column label="岗位名称" align="center" prop="postName" />
  88. <el-table-column label="岗位排序" align="center" prop="postSort" />
  89. <el-table-column label="状态" align="center" prop="status">
  90. <template slot-scope="scope">
  91. <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  95. <template slot-scope="scope">
  96. <span>{{ parseTime(scope.row.createTime) }}</span>
  97. </template>
  98. </el-table-column>
  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:post: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:post: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="500px" append-to-body>
  127. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  128. <el-form-item label="岗位名称" prop="postName">
  129. <el-input v-model="form.postName" placeholder="请输入岗位名称" />
  130. </el-form-item>
  131. <el-form-item label="岗位编码" prop="postCode">
  132. <el-input v-model="form.postCode" placeholder="请输入编码名称" />
  133. </el-form-item>
  134. <el-form-item label="岗位顺序" prop="postSort">
  135. <el-input-number v-model="form.postSort" controls-position="right" :min="0" />
  136. </el-form-item>
  137. <el-form-item label="岗位状态" prop="status">
  138. <el-radio-group v-model="form.status">
  139. <el-radio
  140. v-for="dict in dict.type.sys_normal_disable"
  141. :key="dict.value"
  142. :label="dict.value"
  143. >{{dict.label}}</el-radio>
  144. </el-radio-group>
  145. </el-form-item>
  146. <el-form-item label="备注" prop="remark">
  147. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  148. </el-form-item>
  149. </el-form>
  150. <div slot="footer" class="dialog-footer">
  151. <el-button type="primary" @click="submitForm">确 定</el-button>
  152. <el-button @click="cancel">取 消</el-button>
  153. </div>
  154. </el-dialog>
  155. </div>
  156. </template>
  157. <script>
  158. import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post";
  159. export default {
  160. name: "Post",
  161. dicts: ['sys_normal_disable'],
  162. data() {
  163. return {
  164. // 遮罩层
  165. loading: true,
  166. // 导出遮罩层
  167. exportLoading: false,
  168. // 选中数组
  169. ids: [],
  170. // 非单个禁用
  171. single: true,
  172. // 非多个禁用
  173. multiple: true,
  174. // 显示搜索条件
  175. showSearch: true,
  176. // 总条数
  177. total: 0,
  178. // 岗位表格数据
  179. postList: [],
  180. // 弹出层标题
  181. title: "",
  182. // 是否显示弹出层
  183. open: false,
  184. // 查询参数
  185. queryParams: {
  186. pageNum: 1,
  187. pageSize: 10,
  188. postCode: undefined,
  189. postName: undefined,
  190. status: undefined
  191. },
  192. // 表单参数
  193. form: {},
  194. // 表单校验
  195. rules: {
  196. postName: [
  197. { required: true, message: "岗位名称不能为空", trigger: "blur" }
  198. ],
  199. postCode: [
  200. { required: true, message: "岗位编码不能为空", trigger: "blur" }
  201. ],
  202. postSort: [
  203. { required: true, message: "岗位顺序不能为空", trigger: "blur" }
  204. ]
  205. }
  206. };
  207. },
  208. created() {
  209. this.getList();
  210. },
  211. methods: {
  212. /** 查询岗位列表 */
  213. getList() {
  214. this.loading = true;
  215. listPost(this.queryParams).then(response => {
  216. this.postList = response.rows;
  217. this.total = response.total;
  218. this.loading = false;
  219. });
  220. },
  221. // 取消按钮
  222. cancel() {
  223. this.open = false;
  224. this.reset();
  225. },
  226. // 表单重置
  227. reset() {
  228. this.form = {
  229. postId: undefined,
  230. postCode: undefined,
  231. postName: undefined,
  232. postSort: 0,
  233. status: "0",
  234. remark: undefined
  235. };
  236. this.resetForm("form");
  237. },
  238. /** 搜索按钮操作 */
  239. handleQuery() {
  240. this.queryParams.pageNum = 1;
  241. this.getList();
  242. },
  243. /** 重置按钮操作 */
  244. resetQuery() {
  245. this.resetForm("queryForm");
  246. this.handleQuery();
  247. },
  248. // 多选框选中数据
  249. handleSelectionChange(selection) {
  250. this.ids = selection.map(item => item.postId)
  251. this.single = selection.length!=1
  252. this.multiple = !selection.length
  253. },
  254. /** 新增按钮操作 */
  255. handleAdd() {
  256. this.reset();
  257. this.open = true;
  258. this.title = "添加岗位";
  259. },
  260. /** 修改按钮操作 */
  261. handleUpdate(row) {
  262. this.reset();
  263. const postId = row.postId || this.ids
  264. getPost(postId).then(response => {
  265. this.form = response.data;
  266. this.open = true;
  267. this.title = "修改岗位";
  268. });
  269. },
  270. /** 提交按钮 */
  271. submitForm: function() {
  272. this.$refs["form"].validate(valid => {
  273. if (valid) {
  274. if (this.form.postId != undefined) {
  275. updatePost(this.form).then(response => {
  276. this.msgSuccess("修改成功");
  277. this.open = false;
  278. this.getList();
  279. });
  280. } else {
  281. addPost(this.form).then(response => {
  282. this.msgSuccess("新增成功");
  283. this.open = false;
  284. this.getList();
  285. });
  286. }
  287. }
  288. });
  289. },
  290. /** 删除按钮操作 */
  291. handleDelete(row) {
  292. const postIds = row.postId || this.ids;
  293. this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', "警告", {
  294. confirmButtonText: "确定",
  295. cancelButtonText: "取消",
  296. type: "warning"
  297. }).then(function() {
  298. return delPost(postIds);
  299. }).then(() => {
  300. this.getList();
  301. this.msgSuccess("删除成功");
  302. }).catch(() => {});
  303. },
  304. /** 导出按钮操作 */
  305. handleExport() {
  306. const queryParams = this.queryParams;
  307. this.$confirm('是否确认导出所有岗位数据项?', "警告", {
  308. confirmButtonText: "确定",
  309. cancelButtonText: "取消",
  310. type: "warning"
  311. }).then(() => {
  312. this.exportLoading = true;
  313. return exportPost(queryParams);
  314. }).then(response => {
  315. this.download(response.msg);
  316. this.exportLoading = false;
  317. }).catch(() => {});
  318. }
  319. }
  320. };
  321. </script>