progressRateProjectC.vue 6.77 KB
<template>
  <a-modal
    :title="title"
    :width="1500"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleCancel"
    @cancel="handleCancel"
    cancelText="关闭"
    wrapClassName="ant-modal-cust-warp"
    style="top:5%;height: 85%;overflow-y: hidden">
  <div>
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="10">
          <a-col :md="4" :sm="24">
            <a-form-item>
              <a-input v-model="queryParam.workNo" placeholder="请输入工作令 " />
            </a-form-item>
          </a-col>


          <a-col :md="6" :sm="24">
            <a-button type="primary" @click="getTask(queryParam.workNo)">查询</a-button>
            <a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <p1 style="ont-size:200px;font-weight: bold;font-size: 20px; vertical-align: middle; font-weight: 400; line-height: 35px; padding-left: 22px; letter-spacing: 1px;">{{field0047}}</p1>

    <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>
  </a-modal>
</template>

<script>
import GanttElastic from 'gantt-elastic'
import GanttHeader from 'gantt-elastic-header'
import moment from 'moment'
import dayjs from 'dayjs'
import { projectName, getKanbanInfo } from '../../api/schedulerApi'


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 = [
  {
    "duration": 15267159000,
    "end": 1601308800000,
    "id": "1",
    "isOnTime": "否",
    "start": 1616575959000,
    "taskPoint": "展示",
    "type": "task",
    "style": {
      "base": {
        "fill": "#1EBC61",
        "stroke": "#1EBC61"
      }
    }
  },
  {
    "duration": 86400000,
    "end": 1601395200000,
    "id": "2",
    "isOnTime": false,
    "opinion": "\r\n    吴乐\r\n\r\n\r\n    黄何嵘",
    "parentId": "HHCS-L-2020-0123",
    "principal": "-4266017801783787060",
    "responsible": "9024998056131579524",
    "start": 1601308800000,
    "taskPoint": "电气设计实际",
    "type": "task",
    "style": {
      "base": {
        "fill": "#1EBC61",
        "stroke": "#0EAC51"
      }
    }
  },
  {
    "duration": 86400000,
    "end": 1601395200000,
    "id": "3",
    "isOnTime": false,
    "opinion": "\r\n    冷师红\r\n\r\n\r\n    文禄强",
    "parentId": "HHCS-L-2020-0123",
    "principal": "-4127252952202197745",
    "responsible": "2457865889357907883",
    "start": 1601308800000,
    "taskPoint": "机械设计计划",
    "type": "task"
  }
];
let options = {
  taskMapping: {
    progress: "percent"
  },
  maxRows: 100,
  maxHeight: 500,
  title: {
    label: "",
    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: "taskPoint",
        width: 150,
        expander: true
      },
      {
        id: 3,
        label: "计划日期",
        value: task => dayjs(task.start).format("YYYY-MM-DD"),
        width: 130
      },
      {
        id: 4,
        label: "完成日期",
        value: task => dayjs(task.end).format("YYYY-MM-DD"),
        width: 100,
      },
      {
        id: 5,
        label: "意见",
        value: "opinion",
        width: 100
      },
      {
        id: 6,
        label: "按时完成",
        value: "isOnTime",
        width: 60,
        expander: true
      }
    ]
  },
  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: 'progressRateCopy',
  components: {
    GanttElastic,
    GanttHeader
  },
  mounted() {
    that = this
  },
  data() {
    return {
      field0047:'进度看板',
      visible:false,
      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
    },
    show(record){
      this.visible=true
      this.queryParam.workNo=record.field0056
      this.getTask(record.field0056)
    },
    handleCancel () {
      this.visible=false
    },
    getTask(workno) {
      if (workno == null || workno === "") {
        return;
      }
      let params = {
        "workno": this.queryParam.workNo
      };
      getKanbanInfo(params).then((res)=> {
        console.log(res)
        if (res.success) {
          this.tasks = res.result
        }else{
          this.$message.error("请输入正确的工作令!");
        }
      })
    },
    findCarNumberClick(row){  
      this.field0047=row.field0047+"--进度看板"; 
      this.queryParam['workNo'] =row.field0056;

    }
  }
}
</script>

<style scoped>

</style>