postManage.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. var _this, dataObj=[], _Tok = null;
  2. new Vue({
  3. el: '#app',
  4. data: function() {
  5. return {
  6. tableData: [],
  7. nowForm:{
  8. postName:"",
  9. postCode:"",
  10. postSort:0,
  11. status:"0",
  12. remark:""
  13. },
  14. dialogVisible:false,
  15. inpKey:""
  16. }
  17. },
  18. created() {
  19. _this = this;
  20. _Tok = getCookie("Admin-Token") != "null" && getCookie("Admin-Token") != null ? getCookie("Admin-Token") : "";
  21. _this.getList();
  22. },
  23. methods: {
  24. getList() {
  25. let data1 = {
  26. pageNum:1,
  27. pageSize:100
  28. };
  29. let _opts = {
  30. url: baseUrl + "/system/post/list",
  31. type:"GET"
  32. };
  33. let _he = {
  34. "Authorization":"Bearer "+_Tok
  35. };
  36. getAxios(_opts, data1,_he)
  37. .then(function(res) {
  38. if (res.code == 200) {
  39. _this.tableData = res.rows;
  40. dataObj = res.rows;
  41. }else{
  42. _this.$message.error(res.msg);
  43. }
  44. })
  45. },
  46. Search(_key){
  47. let newArr = [],_ovj = dataObj;
  48. if(_key == ""){
  49. newArr = dataObj;
  50. }else{
  51. for(var i=0;i<_ovj.length;i++){
  52. if( JSON.stringify(_ovj[i]).indexOf(_key) != -1){
  53. newArr.push(_ovj[i])
  54. }
  55. }
  56. }
  57. _this.tableData = newArr;
  58. },
  59. newAdd(){
  60. _this.nowForm = {
  61. postName:"",
  62. postCode:"",
  63. postSort:0,
  64. status:"0",
  65. remark:""
  66. };
  67. _this.dialogVisible = true;
  68. },
  69. Edit(_row){
  70. let data1 = {};
  71. let _opts = {
  72. url: baseUrl + "/system/post/" + _row.postId,
  73. type:"GET"
  74. };
  75. let _he = {
  76. "Authorization":"Bearer "+_Tok
  77. };
  78. getAxios(_opts, data1,_he)
  79. .then(function(res) {
  80. if (res.code == 200) {
  81. _this.nowForm = res.data;
  82. _this.dialogVisible = true;
  83. }
  84. })
  85. },
  86. Delete(_row){
  87. _this.$confirm('是否确认删除编号为"'+_row.postId+'"的数据项?', '温馨提示', {
  88. confirmButtonText: '确定',
  89. cancelButtonText: '取消',
  90. type: 'warning'
  91. }).then(() => {
  92. let data1 = {};
  93. let _opts = {
  94. url: baseUrl + "/system/post/"+_row.postId,
  95. type:"DELETE"
  96. };
  97. let _he = {
  98. "Authorization":"Bearer "+_Tok
  99. };
  100. getAxios(_opts, data1,_he)
  101. .then(function(res) {
  102. if(res.code == 200){
  103. _this.$message({
  104. type: 'success',
  105. message: '删除成功!'
  106. });
  107. _this.getList();
  108. }else{
  109. _this.$message.error(res.msg);
  110. }
  111. })
  112. }).catch(() => {
  113. });
  114. },
  115. conFirm(){
  116. if(_this.nowForm.postName == ""){
  117. _this.$message({
  118. type: 'warning',
  119. message: "请输入岗位名称"
  120. });
  121. return;
  122. }
  123. if(_this.nowForm.postCode == ""){
  124. _this.$message({
  125. type: 'warning',
  126. message: "请输入岗位编码"
  127. });
  128. return;
  129. }
  130. let data1 = JSON.stringify(_this.nowForm);
  131. let _opts = {
  132. url:baseUrl + "/system/post",
  133. type: _this.nowForm.postId == undefined?"POST":"PUT"
  134. };
  135. let _he = {
  136. "Authorization":"Bearer "+_Tok,
  137. "Content-Type": 'application/json; charset=UTF-8'
  138. };
  139. postAxios(_opts,data1,_he)
  140. .then(function(res){
  141. if(res.code == 200){
  142. _this.$message({
  143. type: 'success',
  144. message: '操作成功!'
  145. });
  146. _this.getList();
  147. _this.dialogVisible = false;
  148. }else{
  149. _this.$message.error(res.msg);
  150. }
  151. })
  152. }
  153. }
  154. })