123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- var _this,baseTok,dataObj;
- new Vue({
- el: '#app',
- data: function() {
- return {
- tableData: [],
- nowForm:{
- dev_id: null,
- dev_name: "",
- sn: "",
- distance: 1,
- dev_state: 0,
- mmsi: null,
- user_id: "",
- dev_ver: 6,
- en_name: "",
- other_info: ""
- },
- dialogVisible:false,
- inpKey:"",
- userForm: {}
- }
- },
- created() {
- baseTok = getCookie("Admin-Token") != "null" && getCookie("Admin-Token") != null ? getCookie("Admin-Token") : "";
- _this = this;
- _this.userForm = JSON.parse(getCookie("Admin-User"));
- _this.getSnList();
- },
- methods: {
- getSnList(){
- let _opts = {
- url: baseUrl + "/SelCctvListByUserId",
- // url: baseUrl + "/SelHswsSn",
- type:"GET"
- };
- let _data = {
- "user_id": _this.userForm.userId
- };
- let _hea = {
- "Authorization": "Bearer " + baseTok
- };
- getAxios(_opts, _data, _hea).then((res) => {
- if(res.code == 200){
- _this.tableData = res.data;
- dataObj = res.data;
- }
- })
- },
- Search(_key){
- let newArr = [],_ovj = dataObj;
- if(_key == ""){
- newArr = dataObj;
- }else{
- for(var i=0;i<_ovj.length;i++){
- if( JSON.stringify(_ovj[i]).indexOf(_key) != -1){
- newArr.push(_ovj[i])
- }
- }
- }
- _this.tableData = newArr;
- },
- newAdd(){
- _this.nowForm = {
- dev_id: null,
- dev_name: "",
- sn: "",
- distance: 1,
- dev_state: 0,
- mmsi: null,
- other_info: "",
- user_id: "",
- dev_ver: 6,
- en_name: ""
- };
- _this.dialogVisible = true;
- },
- Edit(_row){
- _this.nowForm = JSON.parse(JSON.stringify(_row));
- _this.dialogVisible = true;
- },
- conFirm(){
- if(_this.nowForm.dev_name == ""){
- _this.$message({
- type: 'warning',
- message: "请输入设备名称"
- });
- return;
- }
- if(_this.nowForm.sn == ""){
- _this.$message({
- type: 'warning',
- message: "请输入设备编号"
- });
- return;
- }
- const loading = this.$loading({
- background: 'rgba(0, 0, 0, 0.4)'
- })
- _this.nowForm.user_id = _this.userForm.userId;
- let _opts = {
- url: baseUrl + (_this.nowForm.dev_id == null?"/CctvAddDev":"/CctvUpdateDevConfig"),
- type:"POST"
- };
- let _data = JSON.stringify(_this.nowForm);
- let _he = {
- "Authorization": "Bearer " + baseTok,
- "Content-Type": 'application/json; charset=UTF-8'
- };
- postAxios(_opts,_data ,_he)
- .then(function(res) {
- if(res.code == 200){
- _this.$message({
- type: 'success',
- message: '操作成功!'
- });
- _this.getSnList();
- _this.dialogVisible = false;
- }else{
- _this.$message.error(res.msg);
- }
- loading.close();
- })
- }
- }
- })
|