王震
2023-12-13 67da82f0b0c24df5f19bbfcfec63801d9ae902d8
src/views/product/workbench/operation-task-pane.vue
@@ -8,16 +8,25 @@
    >
    </el-alert>
    <el-card
      v-for="(item, index) in operationTasks"
      @click.native="setCheckFlag(item)"
      shadow="hover"
      :key="index"
      :class="['task-item', item.checkFlag ? 'card-checked' : 'card-unchecked']"
    >
  v-for="(item, index) in operationTasks"
  @click.native="setCheckFlag(item)"
  shadow="hover"
  :key="index"
  :class="['task-item', item.checkFlag ? 'card-checked' : 'card-unchecked']"
>
      <img class="selectedImg" src="/img/workbench/icon_selected.png" />
      <div class="header">
        <div>工单号:{{ item.taskNo }}</div>
        <div>计划号:{{ item.mpsNo }}</div>
        <el-alert
          center
          style="width: 80px;height:28px;line-height: 100%;font-size:10px"
          :title="getTagText(item.planFinishDay)"
          :type="getTagColor(item.planFinishDay)"
          effect="dark"
          :closable="false">
        </el-alert>
        <!-- <div>计划号:{{ item.mpsNo }}</div> -->
        <div
          :class="[
            'status-change-div',
@@ -52,10 +61,10 @@
          <div class="l">零件号:</div>
          <div class="r">{{ item.partNo }}</div>
        </div>
        <div class="row">
        <!-- <div class="row">
          <div class="l">成品:</div>
          <div class="r">{{ item.productName }}</div>
        </div>
        </div> -->
        <div class="row">
          <div class="l">计划完成时间:</div>
          <div class="r">{{ item.planFinishDay }}</div>
@@ -91,6 +100,19 @@
  flex-direction: column;
  align-items: center;
}
.tag{
width: 80px;
height: 30px;
line-height: 30px;
border-radius:15% ;
text-align: center;
font-size:8px;
color:white;
align-content: 30px;
}
.task-item {
  width: 100%;
  border-radius: 12px;
@@ -214,7 +236,7 @@
}
.status-change-div {
  width: 20%;
  max-width: 100px;
  max-width: 160px;
}
.status-change-div >>> .el-select {
  width: 100%;
@@ -250,7 +272,7 @@
</style>
<script>
import {
  getOperationTask,
  getOperationTaskCopy,
  changeBackState,
  changeOperationTaskState,
  getDraftProductOut,
@@ -324,7 +346,7 @@
    }
  },
  computed: {
    ...mapGetters(['permissions'])
    ...mapGetters(['permissions']),
  },
  created() {
    if (!this.defaultOperationId) {
@@ -344,6 +366,57 @@
    }
  },
  methods: {
//     getBackgroundColor(planFinishDay) {
//   const today = new Date();
//   const planDate = new Date(planFinishDay);
//   if (planDate < today) {
//     return 'rgba( 255,0,0,1)'; // 超期为红色
//   } else {
//     const timeDiff = planDate.getTime() - today.getTime();
//     const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
//     if (daysDiff <= 3) {
//       return 'rgba(255,204,62, 1)';  // 临期为黄色
//     } else {
//       return 'rgba(86,219, 25,1)';  // 正常为绿色
//     }
//   }
// },
getTagColor(planFinishDay) {
  const today = new Date();
  const planDate = new Date(planFinishDay);
  if (planDate < today) {
    //return 'rgba( 255,0,0,1)'; // 超期为红色
    return 'error'; // 超期为红色
  } else {
    const timeDiff = planDate.getTime() - today.getTime();
    const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
    if (daysDiff <= 3) {
      //return 'rgba(255,204,62, 1)';  // 临期为黄色
      return 'warning';  // 临期为黄色
    } else {
      //return 'rgba(86,219, 25,1)';  // 正常为绿色
      return 'success';  // 正常为绿色
    }
  }
},
getTagText(planFinishDay) {
  const today = new Date();
  const planDate = new Date(planFinishDay);
  if (planDate < today) {
    return '超期';
  } else {
    const timeDiff = planDate.getTime() - today.getTime();
    const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
    if (daysDiff <= 3) {
      return '临期';
    } else {
      return '正常';
    }
  }
},
    // 点击工单,选中工单
    setCheckFlag(item) {
      if (item.checkFlag) {
@@ -477,16 +550,13 @@
          .then((res) => {
            if (!res.data.data) {
              changeSubmitState(taskId, true).then((res) => {
                console.log(res)
              })
              getDraftProductOut(taskId).then((response) => {
                console.log(response)
                const list = response.data.data || []
                if (list.length > 0) {
                  this.batchChangeSubmit(list, 0, currItem)
                } else {
                  changeSubmitState(taskId, false).then((res) => {
                    console.log(res)
                  })
                  currItem.statusAction = null
                  this.$message.warning('没有可提交的数据')
@@ -516,7 +586,6 @@
          .catch((error) => {
            console.log(error)
            changeSubmitState(taskId, false).then((res) => {
              console.log(res)
            })
          })
      }
@@ -539,7 +608,6 @@
            this.batchChangeSubmit(list, i, currItem)
          } else {
            changeSubmitState(this.taskID, false).then((res) => {
              console.log(res)
            })
            // 批量提交完成,刷新报工页面数据
            this.$emit('refreshReport')
@@ -549,7 +617,6 @@
          console.log(error)
          loading.close()
          changeSubmitState(this.taskID, false).then((res) => {
            console.log(res)
          })
          const errorMsg = '报工单号' + list[i].productNo + ':'
          this.$message.error(errorMsg + '处理失败')
@@ -579,7 +646,7 @@
          if (this.mpsNo && this.mpsNo != null) {
            query.mpsNo = this.mpsNo
          }
          getOperationTask(query)
          getOperationTaskCopy(query)
            .then((response) => {
              var data = response.data
              if (data.code === 0) {
@@ -652,7 +719,7 @@
                      break
                    }
                  }
                  console.log(this.operationTasks)
                  // console.log(this.operationTasks)
                  // 若当前工单在工单列表未被找到且当前工单状态为已完成或已取消时,则将当前工单重置为空并抛出事件,否则不管
                  if (isResetCurrOpertionTaskFlag) {
                    getOperationTaskById(taskId).then((res) => {