snManage.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. var _this,baseTok,dataObj;
  2. new Vue({
  3. el: '#app',
  4. data: function() {
  5. return {
  6. tableData: [],
  7. nowForm:{
  8. dev_id: null,
  9. dev_name: "",
  10. sn: "",
  11. distance: 1,
  12. dev_state: 0,
  13. mmsi: null,
  14. user_id: "",
  15. dev_ver: 6,
  16. en_name: "",
  17. other_info: ""
  18. },
  19. dialogVisible:false,
  20. inpKey:"",
  21. userForm: {}
  22. }
  23. },
  24. created() {
  25. baseTok = getCookie("Admin-Token") != "null" && getCookie("Admin-Token") != null ? getCookie("Admin-Token") : "";
  26. _this = this;
  27. _this.userForm = JSON.parse(getCookie("Admin-User"));
  28. _this.getSnList();
  29. },
  30. methods: {
  31. getSnList(){
  32. let _opts = {
  33. url: baseUrl + "/SelCctvListByUserId",
  34. // url: baseUrl + "/SelHswsSn",
  35. type:"GET"
  36. };
  37. let _data = {
  38. "user_id": _this.userForm.userId
  39. };
  40. let _hea = {
  41. "Authorization": "Bearer " + baseTok
  42. };
  43. getAxios(_opts, _data, _hea).then((res) => {
  44. if(res.code == 200){
  45. _this.tableData = res.data;
  46. dataObj = res.data;
  47. }
  48. })
  49. },
  50. Search(_key){
  51. let newArr = [],_ovj = dataObj;
  52. if(_key == ""){
  53. newArr = dataObj;
  54. }else{
  55. for(var i=0;i<_ovj.length;i++){
  56. if( JSON.stringify(_ovj[i]).indexOf(_key) != -1){
  57. newArr.push(_ovj[i])
  58. }
  59. }
  60. }
  61. _this.tableData = newArr;
  62. },
  63. newAdd(){
  64. _this.nowForm = {
  65. dev_id: null,
  66. dev_name: "",
  67. sn: "",
  68. distance: 1,
  69. dev_state: 0,
  70. mmsi: null,
  71. other_info: "",
  72. user_id: "",
  73. dev_ver: 6,
  74. en_name: ""
  75. };
  76. _this.dialogVisible = true;
  77. },
  78. Edit(_row){
  79. _this.nowForm = JSON.parse(JSON.stringify(_row));
  80. _this.dialogVisible = true;
  81. },
  82. conFirm(){
  83. if(_this.nowForm.dev_name == ""){
  84. _this.$message({
  85. type: 'warning',
  86. message: "请输入设备名称"
  87. });
  88. return;
  89. }
  90. if(_this.nowForm.sn == ""){
  91. _this.$message({
  92. type: 'warning',
  93. message: "请输入设备编号"
  94. });
  95. return;
  96. }
  97. const loading = this.$loading({
  98. background: 'rgba(0, 0, 0, 0.4)'
  99. })
  100. _this.nowForm.user_id = _this.userForm.userId;
  101. let _opts = {
  102. url: baseUrl + (_this.nowForm.dev_id == null?"/CctvAddDev":"/CctvUpdateDevConfig"),
  103. type:"POST"
  104. };
  105. let _data = JSON.stringify(_this.nowForm);
  106. let _he = {
  107. "Authorization": "Bearer " + baseTok,
  108. "Content-Type": 'application/json; charset=UTF-8'
  109. };
  110. postAxios(_opts,_data ,_he)
  111. .then(function(res) {
  112. if(res.code == 200){
  113. _this.$message({
  114. type: 'success',
  115. message: '操作成功!'
  116. });
  117. _this.getSnList();
  118. _this.dialogVisible = false;
  119. }else{
  120. _this.$message.error(res.msg);
  121. }
  122. loading.close();
  123. })
  124. }
  125. }
  126. })