index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <div class="app-container inghse">
  3. <el-form style="background-color: #fff;padding: 10px;padding-bottom: 0; padding-top: 20px; border-radius: 10px;margin-bottom: 20px;" :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
  4. <el-form-item label="岗位编码" prop="postCode">
  5. <el-input
  6. v-model="queryParams.postCode"
  7. placeholder="请输入岗位编码"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="岗位名称" prop="postName">
  13. <el-input
  14. v-model="queryParams.postName"
  15. placeholder="请输入岗位名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <!-- <el-form-item label="状态" prop="status">
  21. <el-select v-model="queryParams.status" placeholder="岗位状态" clearable>
  22. <el-option
  23. v-for="dict in dict.type.sys_normal_disable"
  24. :key="dict.value"
  25. :label="dict.label"
  26. :value="dict.value"
  27. />
  28. </el-select>
  29. </el-form-item> -->
  30. <el-form-item>
  31. <el-button style="background-color: #03BF8A; border-color: #03BF8A;" type="primary" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-row :gutter="10" class="mb8">
  36. <el-col :span="1.5">
  37. <el-button
  38. type="primary"
  39. plain
  40. size="mini"
  41. @click="handleAdd"
  42. v-hasPermi="['system:post:add']"
  43. >新增</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="success"
  48. plain
  49. size="mini"
  50. :disabled="single"
  51. @click="handleUpdate"
  52. v-hasPermi="['system:post:edit']"
  53. >修改</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="danger"
  58. plain
  59. size="mini"
  60. :disabled="multiple"
  61. @click="handleDelete"
  62. v-hasPermi="['system:post:remove']"
  63. >删除</el-button>
  64. </el-col>
  65. <el-col :span="1.5">
  66. <el-button
  67. type="warning"
  68. plain
  69. size="mini"
  70. @click="handleExport"
  71. v-hasPermi="['system:post:export']"
  72. >导出</el-button>
  73. </el-col>
  74. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  75. </el-row>
  76. <div class="infinite-list" :style="dynamicStyle">
  77. <el-row :gutter="10" style="margin: 0; ">
  78. <el-col :span="6" v-for="(item,index) in postList" :key="index">
  79. <div class="section_11 flex-col" style="position: relative;">
  80. <div class="section_12 flex-row" style="justify-content: space-between;">
  81. <div style="display: flex;width: 82%;">
  82. <div class="text-wrapper_14 flex-col">
  83. <span class="text_25">{{item.postId}}</span>
  84. </div>
  85. <div style="width: 84%; display: flex;">
  86. <el-tooltip class="item" effect="dark" :content="item.postName" placement="top-start">
  87. <span class="text_26" style="height: 40px;">{{item.postName}}</span>
  88. </el-tooltip>
  89. <img
  90. @click="handleUpdate(item)" v-hasPermi="['system:post:edit']"
  91. class="thumbnail_14"
  92. referrerpolicy="no-referrer"
  93. style="cursor: pointer;"
  94. src="../../../assets/images/icon_htgl_rylb_bjs.png"
  95. />
  96. <img
  97. @click="handleDelete(item)" v-hasPermi="['system:post:remove']"
  98. class="thumbnail_14"
  99. referrerpolicy="no-referrer"
  100. style="cursor: pointer;"
  101. src="../../../assets/images/icon_lby_gdtc_del.png"
  102. />
  103. </div>
  104. </div>
  105. <div>
  106. <el-switch v-model="item.status" active-value="0" inactive-value="1" @change="handleStatusChange(item)"></el-switch>
  107. </div>
  108. </div>
  109. <div class="text-wrapper_15 ">
  110. <div style="display: flex">
  111. <p class="paragraph_5">岗位名称:</p>
  112. <el-tooltip class="item" effect="dark" :content="'岗位名称:' + item.postName" placement="left-start">
  113. <p class="paragraph_5">{{item.postName}}</p>
  114. </el-tooltip>
  115. </div>
  116. <div style="display: flex">
  117. <p class="paragraph_5">岗位排序:</p>
  118. <el-tooltip class="item" effect="dark" :content="'岗位排序:' + item.postSort" placement="left-start">
  119. <p class="paragraph_5">{{item.postSort}}</p>
  120. </el-tooltip>
  121. </div>
  122. <div style="display: flex">
  123. <p class="paragraph_5">创建时间:</p>
  124. <el-tooltip class="item" effect="dark" :content="'创建时间:' + item.createTime" placement="left-start">
  125. <p class="paragraph_5">{{item.createTime}}</p>
  126. </el-tooltip>
  127. </div>
  128. </div>
  129. </div>
  130. </el-col>
  131. </el-row>
  132. </div>
  133. <pagination
  134. v-show="total>0"
  135. :total="total"
  136. :page.sync="queryParams.pageNum"
  137. :limit.sync="queryParams.pageSize"
  138. @pagination="getList"
  139. />
  140. <!-- 添加或修改岗位对话框 -->
  141. <el-drawer
  142. :title="title"
  143. :visible.sync="open"
  144. direction="rtl"
  145. custom-class="demo-drawer"
  146. ref="drawer"
  147. :size="330"
  148. :modal="false"
  149. >
  150. <div class="demo-drawer__content">
  151. <!-- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> -->
  152. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  153. <el-form-item label="岗位名称" prop="postName">
  154. <el-input v-model="form.postName" placeholder="请输入岗位名称" />
  155. </el-form-item>
  156. <el-form-item label="岗位编码" prop="postCode">
  157. <el-input v-model="form.postCode" placeholder="请输入编码名称" />
  158. </el-form-item>
  159. <el-form-item label="岗位顺序" prop="postSort">
  160. <el-input-number v-model="form.postSort" controls-position="right" :min="0" />
  161. </el-form-item>
  162. <el-form-item label="岗位状态" prop="status">
  163. <el-radio-group v-model="form.status">
  164. <el-radio
  165. v-for="dict in dict.type.sys_normal_disable"
  166. :key="dict.value"
  167. :label="dict.value"
  168. >{{dict.label}}</el-radio>
  169. </el-radio-group>
  170. </el-form-item>
  171. <el-form-item label="备注" prop="remark">
  172. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  173. </el-form-item>
  174. </el-form>
  175. <div slot="footer" class="dialog-footer" style="padding: 0 20px; float: right;">
  176. <el-button type="primary" @click="submitForm">确 定</el-button>
  177. <el-button @click="cancel">取 消</el-button>
  178. </div>
  179. </div>
  180. </el-drawer>
  181. </div>
  182. </template>
  183. <script>
  184. import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post"
  185. export default {
  186. name: "Post",
  187. dicts: ['sys_normal_disable'],
  188. data() {
  189. return {
  190. // 遮罩层
  191. loading: true,
  192. // 选中数组
  193. ids: [],
  194. // 非单个禁用
  195. single: true,
  196. // 非多个禁用
  197. multiple: true,
  198. // 显示搜索条件
  199. showSearch: true,
  200. // 总条数
  201. total: 0,
  202. // 岗位表格数据
  203. postList: [],
  204. // 弹出层标题
  205. title: "",
  206. // 是否显示弹出层
  207. open: false,
  208. // 查询参数
  209. queryParams: {
  210. pageNum: 1,
  211. pageSize: 8,
  212. postCode: undefined,
  213. postName: undefined,
  214. status: undefined
  215. },
  216. // 表单参数
  217. form: {},
  218. // 表单校验
  219. rules: {
  220. postName: [
  221. { required: true, message: "岗位名称不能为空", trigger: "blur" }
  222. ],
  223. postCode: [
  224. { required: true, message: "岗位编码不能为空", trigger: "blur" }
  225. ],
  226. postSort: [
  227. { required: true, message: "岗位顺序不能为空", trigger: "blur" }
  228. ]
  229. },
  230. tableMaxHeight:200
  231. }
  232. },
  233. created() {
  234. this.getList()
  235. window.onresize = () => {
  236. this.changeTableMaxHeight()
  237. }
  238. this.changeTableMaxHeight()
  239. },
  240. computed: {
  241. dynamicStyle() {
  242. return {
  243. overflow:'auto',
  244. height: this.tableMaxHeight + 'px',
  245. }
  246. }
  247. },
  248. mounted() {
  249. window.onresize = () => {
  250. this.changeTableMaxHeight()
  251. }
  252. this.changeTableMaxHeight()
  253. },
  254. methods: {
  255. /** 查询岗位列表 */
  256. getList() {
  257. this.loading = true
  258. listPost(this.queryParams).then(response => {
  259. this.postList = response.rows
  260. this.total = response.total
  261. this.loading = false
  262. })
  263. },
  264. // 取消按钮
  265. cancel() {
  266. this.open = false
  267. this.reset()
  268. },
  269. handleStatusChange(row) {
  270. let text = row.status === "0" ? "启用" : "停用"
  271. this.$modal.confirm('确认要"' + text + '""' + row.postName + '"角色吗?').then(function() {
  272. return updatePost(row)
  273. }).then(() => {
  274. this.$modal.msgSuccess(text + "成功")
  275. }).catch(function() {
  276. row.status = row.status === "0" ? "1" : "0"
  277. })
  278. },
  279. // 表单重置
  280. reset() {
  281. this.form = {
  282. postId: undefined,
  283. postCode: undefined,
  284. postName: undefined,
  285. postSort: 0,
  286. status: "0",
  287. remark: undefined
  288. }
  289. this.resetForm("form")
  290. },
  291. /** 搜索按钮操作 */
  292. handleQuery() {
  293. this.queryParams.pageNum = 1
  294. this.getList()
  295. },
  296. /** 重置按钮操作 */
  297. resetQuery() {
  298. this.resetForm("queryForm")
  299. this.handleQuery()
  300. },
  301. // 多选框选中数据
  302. handleSelectionChange(selection) {
  303. this.ids = selection.map(item => item.postId)
  304. this.single = selection.length!=1
  305. this.multiple = !selection.length
  306. },
  307. /** 新增按钮操作 */
  308. handleAdd() {
  309. this.reset()
  310. this.open = true
  311. this.title = "添加岗位"
  312. },
  313. /** 修改按钮操作 */
  314. handleUpdate(row) {
  315. this.reset()
  316. const postId = row.postId || this.ids
  317. getPost(postId).then(response => {
  318. this.form = response.data
  319. this.open = true
  320. this.title = "修改岗位"
  321. })
  322. },
  323. /** 提交按钮 */
  324. submitForm: function() {
  325. this.$refs["form"].validate(valid => {
  326. if (valid) {
  327. if (this.form.postId != undefined) {
  328. updatePost(this.form).then(response => {
  329. this.$modal.msgSuccess("修改成功")
  330. this.open = false
  331. this.getList()
  332. })
  333. } else {
  334. addPost(this.form).then(response => {
  335. this.$modal.msgSuccess("新增成功")
  336. this.open = false
  337. this.getList()
  338. })
  339. }
  340. }
  341. })
  342. },
  343. /** 删除按钮操作 */
  344. handleDelete(row) {
  345. const postIds = row.postId || this.ids
  346. this.$modal.confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?').then(function() {
  347. return delPost(postIds)
  348. }).then(() => {
  349. this.getList()
  350. this.$modal.msgSuccess("删除成功")
  351. }).catch(() => {})
  352. },
  353. /** 导出按钮操作 */
  354. handleExport() {
  355. this.download('system/post/export', {
  356. ...this.queryParams
  357. }, `post_${new Date().getTime()}.xlsx`)
  358. },
  359. // 获取屏幕高度
  360. showFilterForm () {
  361. this.filterActive = !this.filterActive
  362. this.changeTableMaxHeight()
  363. },
  364. changeTableMaxHeight () {
  365. let height = document.body.offsetHeight // 网页可视区域高度
  366. // if (this.filterActive) {
  367. // this.tableMaxHeight = height - 320
  368. // } else {
  369. this.tableMaxHeight = height - 250
  370. // }
  371. console.log(height)
  372. }
  373. }
  374. }
  375. </script>