progressRate.vue 7.99 KB
<template>
  <div>
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="10">
          <a-col :md="4" :sm="24">
            <a-form-item label="查询类别">
              <a-select allowClear v-model="queryParam.condition">
                <a-select-option key="TaskDescripe">任务描述</a-select-option>
                <a-select-option key="ResponseName">责任人</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="24">
            <a-form-item>
              <a-input v-model="queryParam.keyword" placeholder="关键字" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-button type="primary" @click="()=>(getDataList())">查询</a-button>
            <a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <gantt-elastic
      :options="options"
      :tasks="tasks"
      @tasks-changed="tasksUpdate"
      @options-changed="optionsUpdate"
      @dynamic-style-changed="styleUpdate"
    >
      <gantt-header slot="header" :options="options"></gantt-header>
    </gantt-elastic>
    <div class="q-mt-md" />
  </div>

</template>

<script>
import GanttElastic from 'gantt-elastic'
import GanttHeader from 'gantt-elastic-header'
import moment from 'moment'

function getDate(hours) {
  const currentDate = new Date()
  const currentYear = currentDate.getFullYear()
  const currentMonth = currentDate.getMonth()
  const currentDay = currentDate.getDate()
  const timeStamp = new Date(
    currentYear,
    currentMonth,
    currentDay,
    0,
    0,
    0
  ).getTime()
  return new Date(timeStamp + hours * 60 * 60 * 1000).getTime()
}

let that
let tasks = [
  {
    "actualCompletionTime": "",
    "completionTime": "",
    "drawingNo": "",
    "duration": 0,
    "end": 1615824000000,
    "id": 1,
    "name": "",
    "orderNo": "",
    "partNo": "",
    "preDate": "",
    "projectName": "test",
    "start": 1615824000000,
    "type": "project"
  },
  {
    "drawingNo": "",
    "duration": 0,
    "end": 1615824000000,
    "id": 2,
    "name": "",
    "orderNo": "4053-2020-010154-21",
    "parentId": 1,
    "preDate": "",
    "projectName": "test",
    "start": 1615824000000,
    "type": "milestone"
  },
  {
    "drawingNo": "091077-0700-0100-00",
    "duration": 0,
    "end": 1615824000000,
    "id": 3,
    "name": "上盖板",
    "orderNo": "4053-2020-010154-21",
    "parentId": 2,
    "preDate": "",
    "projectName": "test",
    "start": 1615824000000,
    "type": "task"
  },
  {
    "drawingNo": "091077-0700-0200-00",
    "duration": 0,
    "end": 1615824000000,
    "id": 4,
    "name": "电柜底座",
    "orderNo": "4053-2020-010154-21",
    "parentId": 2,
    "preDate": "",
    "projectName": "test",
    "start": 1615824000000,
    "type": "task"
  },
  {
    "actualCompletionTime": "",
    "completionTime": "",
    "drawingNo": "",
    "duration": 604800000,
    "end": 1616428800000,
    "id": 5,
    "name": "",
    "orderNo": "",
    "partNo": "",
    "preDate": "",
    "projectName": "内部项目",
    "start": 1615824000000,
    "type": "project"
  },
  {
    "drawingNo": "",
    "duration": 604800000,
    "end": 1616428800000,
    "id": 6,
    "name": "",
    "orderNo": "4053-2020-010154-20",
    "parentId": 5,
    "preDate": "",
    "projectName": "内部项目",
    "start": 1615824000000,
    "type": "milestone"
  },
  {
    "drawingNo": "091077-0700-0000-01",
    "duration": 604800000,
    "end": 1616428800000,
    "id": 7,
    "name": "支架板",
    "orderNo": "4053-2020-010154-20",
    "parentId": 6,
    "preDate": "",
    "projectName": "内部项目",
    "start": 1615824000000,
    "type": "task"
  },
  {
    "drawingNo": "091077-0700-0000-02",
    "duration": 0,
    "end": 1615824000000,
    "id": 8,
    "name": "底座踏板",
    "orderNo": "4053-2020-010154-20",
    "parentId": 6,
    "preDate": "",
    "projectName": "内部项目",
    "start": 1615824000000,
    "type": "task"
  },
  {
    "drawingNo": "091077-0700-0000-03",
    "duration": 86400000,
    "end": 1615910400000,
    "id": 9,
    "name": "橡胶1613",
    "orderNo": "4053-2020-010154-20",
    "parentId": 6,
    "preDate": "",
    "projectName": "内部项目",
    "start": 1615824000000,
    "type": "task"
  },
  {
    "drawingNo": "091077-0700-0200-00",
    "duration": 0,
    "end": 1615824000000,
    "id": 10,
    "name": "电柜底座",
    "orderNo": "4053-2020-010154-20",
    "parentId": 6,
    "preDate": "",
    "projectName": "内部项目",
    "start": 1615824000000,
    "type": "task"
  }
];
let options = {
  taskMapping: {
    progress: "percent"
  },
  maxRows: 100,
  maxHeight: 500,
  title: {
    label: "Your project title as html",
    html: false
  },
  row: {
    height: 24
  },
  calendar: {
    hour: {
      display: false
    }
  },
  chart: {
    progress: {
      bar: false
    },
    expander: {
      display: false
    }
  },
  taskList: {
    expander: {
      straight: false
    },
    columns: [
      {
        id: 1,
        label: "ID",
        value: "id",
        width: 50
      },
      {
        id: 2,
        label: "项目名称",
        value: "projectName",
        width: 150,
        expander: true
      },
      {
        id: 3,
        label: "项目编码",
        value: "projectCode",
        width: 130
      },
      {
        id: 4,
        label: "生产令号",
        value: "orderNo",
        width: 100,
        // expander: true
      },
      {
        id: 5,
        label: "部件号",
        value: "partNo",
        width: 100
      },
      {
        id: 5,
        label: "计划开始时间",
        value: "completionTime",
        width: 100
      },
      {
        id: 6,
        label: "计划完成时间",
        value: "actualCompletionTime",
        width: 100
      },
      {
        id: 7,
        label: "图号",
        value: "drawingNo",
        width: 120,
        // expander: true
      },
      {
        id: 8,
        label: "名称",
        value: "name",
        width: 120
      },
      {
        id: 9,
        label: "数量",
        value: "qty",
        width: 60
      }
    ]
  },
  locale: {
    name: "zh-cn",
    Now: "Now",
    "X-Scale": "Zoom-X",
    "Y-Scale": "Zoom-Y",
    "Task list width": "列头宽度",
    "Before/After": "Expand",
    "Display task list": "Task list",
    weekdays:["周日","周一","周二","周三","周四","周五","周六"],
    months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
  },
};

let doingStyle = {
  base: {
    fill: '#BFEFFF',
    stroke: '#BFEFFF'
  }
}
let warnStyle = {
  base: {
    fill: '#FF6A6A',
    stroke: '#FF6A6A'
  }
}
let finishStyle = {
  base: {
    fill: '#C1FFC1',
    stroke: '#C1FFC1'
  }
}
let cancelStyle = {
  base: {
    fill: '#BABABA',
    stroke: '#BABABA'
  }
}

export default {
  name: 'progressRate',
  components: {
    GanttElastic,
    GanttHeader
  },
  mounted() {
    that = this
  },
  data() {
    return {
      tasks,
      options,
      dynamicStyle: {},
      lastId: 16,
      queryParam: []
    }
  },
  methods: {
    moment,
    addTask() {
      this.tasks.push({
        id: this.lastId++,
        label:
          '<a href="https://images.pexels.com/photos/423364/pexels-photo-423364.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" target="_blank" style="color:#0077c0;">Yeaahh! you have added a task bro!</a>',
        projectCode:
          '<a href="https://images.pexels.com/photos/423364/pexels-photo-423364.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" target="_blank" style="color:#0077c0;">Awesome!</a>',
        start: getDate(24 * 3),
        duration: 1 * 24 * 60 * 60 * 1000,
        percent: 50,
        type: 'project'
      })
    },
    tasksUpdate(tasks) {
      this.tasks = tasks
    },
    optionsUpdate(options) {
      this.options = options
    },
    styleUpdate(style) {
      this.dynamicStyle = style
    }
  }
}
</script>

<style scoped>

</style>