vue js 写法

本文深入探讨Vue.js的编程技巧,包括组件化开发、响应式原理、Vuex状态管理和API使用等,旨在帮助开发者提升Vue.js应用的构建效率和质量。
摘要由CSDN通过智能技术生成
<script>
import axios from "axios";

export default {
  name: 'task_management',
  data() {
    return {
      aa: '',
      sites: [],
      isShowPutong: true,
      isShowGaoji: false,
      id_search: '',
      id_input: '',
      id_picker: '',
      visible: false,
      taskList: [],
      loading_task: [
        {
          icon: 'snippets',
          start_icon: 'pause-circle',
          del_icon: 'delete',
          detail_icon: 'container',
          task_name: 'loading_task',
          plan_start_time: '2020/12/23 14:10:55',
          aff_ip: '机器人甲'
        },
      ],
      success_task: [
        {
          icon: 'snippets',
          icon1: 'container',
          name: 'success_task',
          time: '2020/12/23 14:10:55',
          affiliation: '机器人甲'
        },
      ],
      abort_task: [
        {
          icon: 'snippets',
          icon1: 'container',
          name: 'abort_task',
          time: '2020/12/23 14:10:55',
          affiliation: '机器人甲'
        },
      ],
      error_task: [
        {
          icon: 'snippets',
          icon1: 'container',
          name: 'error_task',
          time: '2020/12/23 14:10:55',
          affiliation: '机器人甲'
        },
      ],
      labelCol: {span: 4},
      wrapperCol: {span: 14},
      form: {
        // taskname: '',
        // execute_path: '',
        // loop_model: '',
        // start_time: '',
        // robot: '',
        // definetime: '',
        // aff_ip: '',
      }
    }
  },
  created() {
    let that = this;
    const url = 'http://192.168.0.196:8001/task/';
    axios.get(url).then(function (res) {
        that.taskList = res.data.tasks_list;
      }
    ).catch(
      function (error){
        alert('hdsjdshgd')
      }
    )
  },
  methods: {
    // 搜索框
    onSearch(value) {
      console.log(value);
      console.log(this.taskList, '1111');
    },
    // 高级搜索按钮
    advanced() {
      console.log("高级搜索");
      this.isShowPutong = !this.isShowPutong;
      this.isShowGaoji = !this.isShowGaoji;

      var self = this;
      $.ajax({
        url: 'http://192.168.0.196:8001/task/',
        type: 'get',
        data: {},
        dataType: 'json'
      }).then(function (res) {
        console.log(res);
        //把从json获取的数据赋值给数组
        self.sites = res;
      }).fail(function () {
        console.log('失败');
      })
    },
    // 日历
    onChange(date, dateString) {
      console.log(date, dateString);
    },
    // 普通搜索按钮
    gj_advanced() {
      console.log('普通搜索');
      this.isShowGaoji = !this.isShowGaoji;
      this.isShowPutong = !this.isShowPutong;
    },
    // 清空按钮
    empty() {
      console.log('清空');
      this.id_search = '';
      this.id_input = '';
      this.id_picker = '';
    },
    // 新建任务按钮
    showModal() {
      this.visible = true;
    },
    // 新建任务
    handleOk(e) {
      console.log(e);
      // let s = JSON.toString(this.form)
      var self = this;
      const url = 'http://192.168.0.196:8001/task/';
      let addTask = {
        "starttime": this.form.start_time.format('YYYY-MM-DD HH:mm:ss'),
        "runtime": 30,
        "endtime": '',
        "loop_model": this.form.loop_model,
        "execute_path": this.form.execute_path,
        "remark": '111',
        "task_name": this.form.taskname,
        "aff_ip": this.form.aff_ip,
      };
      axios.post(url, addTask).then(function (res){
        self.sites = res
        }
      )
      this.visible = false;
    },
    // 开始任务
    start_task(task_id, execute_path, task_name) {
      const url = 'http://192.168.0.196:8001/data/';
      let startTask = {
        "task_id": task_id,
        "execute_path": execute_path,
        "task_name": task_name,
      };
      axios.post(url, startTask).then(
        function (res){

        }
      )
    },
    // 删除任务
    del_task(task_id) {
      const url = 'http://192.168.0.196:8001/task/';
      let datas = {
        "task_id": task_id,
      };
      axios.delete(url, {data: datas}).then(
        function (res){
        }
      )
    },
  }
}
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值