haoxuan
2023-08-18 8118f56d86267e443f147c17ccb014338607e247
src/views/visualization.vue
@@ -1,18 +1,28 @@
<template>
  <div class="home">
    <template v-if="Object.keys(taskData).length > 0">
    <div class="left">
      <div class="left_top">
        <p class="title">
          设A423生产管理看板
          <span class="font el-icon-setting set-title"></span>
            <span
              class="font el-icon-setting set-title"
              style="float: right"
              @click="setUrl"
            ></span>
        </p>
        <div class="statelist">
          <span class="title-item"
            >订单编号: <span class="color_4efefa">Q-22038</span>
              >订单编号:
              <span class="color_4efefa">{{
                taskData.order.orderId || ""
              }}</span>
          </span>
          <span class="title-item"
            >当前工序: <span class="color_4efefa">前纺(QF)</span>
              >当前工序:
              <span class="color_4efefa">{{
                taskData.procedure.procedure.procedureName || ""
              }}</span>
          </span>
          <span class="title-item"
            >后道工序: <span class="color_4efefa">Q-22038</span>
@@ -42,19 +52,21 @@
          </div>
          <div class="content_right">
            <el-descriptions :column="2" :colon="true">
              <el-descriptions-item label="产品名称"
                >kooriookami</el-descriptions-item
              >
              <el-descriptions-item label="数量:"
                >18100000000</el-descriptions-item
              >
              <el-descriptions-item label="交货日期:"
                >苏州市</el-descriptions-item
              >
              <el-descriptions-item label="工时:"> 学校 </el-descriptions-item>
              <el-descriptions-item label="起止时间"
                >江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item
              >
                <el-descriptions-item label="产品名称">{{
                  taskData.order.productName || ""
                }}</el-descriptions-item>
                <el-descriptions-item label="数量:">{{
                  taskData.order.amount || ""
                }}</el-descriptions-item>
                <el-descriptions-item label="交货日期:">{{
                  taskData.order.deliverDate || ""
                }}</el-descriptions-item>
                <el-descriptions-item label="工时:">
                  {{ taskData.order.deliverDate || "" }}
                </el-descriptions-item>
                <el-descriptions-item label="起止时间">{{
                  taskData.order.startTime || ""
                }}</el-descriptions-item>
              <el-descriptions-item label="货物描述"
                >江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item
              >
@@ -67,6 +79,7 @@
            </el-descriptions>
            <el-descriptions :column="1" :colon="true">
              <el-descriptions-item label="完成度" style="width: 100%">
                  <!--  -->
                <el-progress
                  define-back-color="#007101"
                  color="#00CC66"
@@ -91,73 +104,187 @@
        </div>
        <div class="bottom">
          <div class="bottom_list">
            <div class="bottom-title">输入资源</div>
            <Card />
            <Card />
            <Card />
            <!-- <span class="call">呼叫物料</span> -->
              <div class="bottom-title">
                输入资源
                <el-button type="primary" class="color_f70f83" size="small">
                  物料呼叫</el-button
                >
          </div>
          <i class="el-icon-arrow-right font-arrow-20"></i>
              <el-carousel
                direction="vertical"
                height="calc(100% -  0px)"
                :interval="500"
                class="card-box"
                ref="cardBox1"
                v-if="
                  taskData.procedure.procedure &&
                  taskData.procedure.procedure.inputMaterials
                "
              >
                <el-carousel-item
                  :key="index"
                  v-for="(item, index) in inputMaterials"
                >
                  <div
                    class="card"
                    :key="index2"
                    v-for="(list, index2) in item"
                  >
                    <div class="card_content">
                      <div class="card_contentLeft">
                        包号:G22122304 100吨{{ index }}
                      </div>
                    </div>
                    <div class="card_top">
                      <div>
                        设备12<i
                          style="font-size: 14px"
                          class="el-icon-right font-arrow-20"
                        ></i>
                        设备13
                      </div>
                    </div>
                    <div class="card_top-2">
                      <span class="card-top-r-t">生产完成</span>
                      <span class="card-top-r-b">12月28日 08:24</span>
                    </div>
                  </div>
                </el-carousel-item>
              </el-carousel>
            </div>
            <i class="el-icon-arrow-right font-arrow-20 color_4efefa"></i>
          <div class="bottom_list">
            <div class="bottom-title">当前工序:前纺(QF)</div>
            <!-- format:format(percentage) -->
            <div
              style="
                display: flex;
                margin: auto;
                width: 160px;
                margin-top: 12px;
              <el-carousel
                direction="vertical"
                height="calc(100% -  0px)"
                :interval="500"
                class="card-box"
                v-if="
                  taskData.procedure.procedure &&
                  taskData.procedure.procedure.inputMaterials
              "
            >
                <el-carousel-item
                  :key="index"
                  v-for="(item, index) in inputMaterials"
                >
                  <div class="card"
                  :key="index2"
                    v-for="(list, index2) in item">
                    <div class="card_content">
                      <div class="card_contentLeft color_blue">
                        包号:G22122304 100吨
                        <span style="float: right">6m/s</span>
                      </div>
                    </div>
                    <div class="card_top-3">
                      <span class="card-top-r-t">完成进度:50%</span>
                      <span class="card-top-r-b">
              <el-progress
                :stroke-width="12"
                text-color="#4EFEFA"
                color="#4C6CEC"
                define-back-color="#4EFEFA"
                type="circle"
                :percentage="production"
                :width="160"
                style="font-size: 20px"
                          define-back-color="#007101"
                          color="#00CC66"
                          :text-inside="true"
                          :stroke-width="10"
                          :percentage="50"
                          :show-text="false"
              ></el-progress>
                      </span>
            </div>
            <Card />
            <p style="font-size: 22px; margin-left: 12px; margin-top: 50px">
            </p>
            <!-- <div class="qfcall">
              <span
                style="
                  width: 63%;
                  height: 100%;
                  background: #4efefa;
                  display: inline-block;
                  border-radius: 5px;
                  color: #000;
                "
                >打印</span
              >
              <span
                style="
                  width: 33%;
                  height: 100%;
                  background: #ff0000;
                  display: inline-block;
                  border-radius: 5px;
                  margin-left: 2%;
                "
                >结束</span
              >
            </div> -->
                    <div class="card_top-2">
                      <span class="card-top-r-t">完成进度:50%</span>
                      <span class="card-top-r-b">12月28日 08:24</span>
          </div>
          <i class="el-icon-arrow-right font-arrow-20"></i>
                  </div>
                </el-carousel-item>
              </el-carousel>
              <div class="card">
                <div class="card_content">
                  <div class="card_contentLeft color_blue">
                    包号:G22122304 100吨
                  </div>
                </div>
                <div class="card_top-4">
                  此模型用于数值检测,精准检测相关生产数据。
                  此模型用于数值检测,精准检测相关生产数据
                </div>
              </div>
              <p
                style="font-size: 22px; margin-left: 12px; margin-top: 50px"
              ></p>
            </div>
            <i class="el-icon-arrow-right font-arrow-20 color_4efefa"></i>
          <div class="bottom_list">
            <div class="bottom-title">输出资源</div>
            <Card />
            <Card />
            <Card />
            <!-- <span class="call">呼叫运输</span> -->
              <div class="bottom-title">
                <span>输出资源</span>
                <el-button type="primary" class="color_organge" size="small">
                  运输呼叫</el-button
                >
          </div>
              <el-carousel
                direction="vertical"
                height="calc(100% -  0px)"
                :interval="500"
                ref="cardBox3"
                class="card-box"
                v-if="
                  taskData.procedure.procedure &&
                  taskData.procedure.procedure.outputMaterials
                "
              >
                <el-carousel-item
                  :key="index"
                  v-for="(item, index) in outputMaterials"
                >
                <div
                  class="card-box"
                  :key="index2"
                  v-for="(list, index2) in item"
                >
                  <div
                    class="card"
                  >
                    <div class="card_content">
                      <div class="card_contentLeft">包号:G22122304 100吨</div>
                    </div>
                    <div class="card_top">
                      <div>
                        设备12<i
                          style="font-size: 14px"
                          class="el-icon-right font-arrow-20"
                        ></i>
                        设备13
                      </div>
                    </div>
                    <div class="card_top-2">
                      <span class="card-top-r-t">生产完成</span>
                      <span class="card-top-r-b">12月28日 08:24</span>
                    </div>
                    <div class="card-info-box">预计10分钟送达</div>
                  </div>
                  <div class="card">
                    <div class="card_content">
                      <div class="card_contentLeft color_green">
                        包号:G22122304 100吨
                      </div>
                    </div>
                    <div class="card_top">
                      <div>
                        设备12<i
                          style="font-size: 14px"
                          class="el-icon-right font-arrow-20"
                        ></i>
                        设备13
                      </div>
                    </div>
                    <div class="card_top-2">
                      <span class="card-top-r-t">生产完成</span>
                      <span class="card-top-r-b">12月28日 08:24</span>
                    </div>
                  </div>
                </div>
                </el-carousel-item>
                </el-carousel>
        </div>
      </div>
    </div>
@@ -184,69 +311,273 @@
        </span>
      </div>
      <div class="right-top-m-btn">
        <el-button type="primary" @click="openorder">
               控制</el-button
              >
          <el-button type="primary" @click="controlClick"> 控制</el-button>
      </div>
      <div class="right_dutyLst">
        <div class="right-small-title">当前值班</div>
        <dl class='right-small-person'>
          <dl class="right-small-person">
          <dt>
            <el-avatar
            class="img-class"
              src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
            ></el-avatar>
          </dt>
          <span style="font-size:20px; font-weight:600;margin-right:10px">张三</span>
          <span style="color:#666;">1867654329</span>
            <span
              style="font-size: 20px; font-weight: 600; margin-right: 10px"
              >{{ taskData.procedure.procedure.workers.workerName || "" }}</span
            >
            <span style="color: #666">{{
              taskData.procedure.procedure.workers.phoneNum || ""
            }}</span>
        </dl>
        <div style="width:100%;font-size:18px;font-weight:600;margin-top:50px;text-align:center;line-height:50px;">编号:12233</div>
          <div
            style="
              width: 100%;
              font-size: 18px;
              font-weight: 600;
              margin-top: 50px;
              text-align: center;
              line-height: 50px;
            "
          >
            编号:{{ taskData.procedure.procedure.workers.workerId || "" }}
          </div>
        <div class="right-small-btn">
          <el-button type="primary" @click="openorder">
                打印</el-button
            <el-button type="primary"> 打印</el-button>
            <el-popover
              placement="top-end"
              width="160"
              class="button-finish"
              v-model="finishShow"
              trigger="click"
                >
                <el-button type="primary" @click="openorder">
                完成</el-button
              <p>请确认是否已完成该生产任务?</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" @click="finishShow = false">
                  取消</el-button
                >
                <el-button type="primary" size="mini" @click="finishClick">
                  确定</el-button
                >
              </div>
              <el-button type="primary" slot="reference"> 完成</el-button>
            </el-popover>
        </div>
      </div>
      <div class="right_base">
        <Knowledge />
        <div class="right-base-btn call">
        <el-button type="primary" @click="openorder">
          红灯呼叫</el-button
              >
      </div>
            <el-button type="primary"> 红灯呼叫</el-button>
      </div>
    </div>
  </div>
</template>
    <template v-else>
      <div
        style="
          width: 100%;
          height: 100%;
          font-size: 20px;
          text-align: center;
          line-height: 100px;
        "
      >
        <div
          style="
            width: 200px;
            height: 200px;
            margin: 0 auto;
            line-height: 200px;
            margin-top: calc(20% - 100px);
          "
        >
          暂无任务
        </div>
      </div>
    </template>
    <!-- 控制的弹框 -->
    <AddControl ref="control" :id="taskData.procedure.id" />
  </div>
</template>
<script>
import {
  getTaskInfo,
  finishTask,
  getMiniDictList,
  saveMiniDict,
} from "@/api/home/index"; // 产线
import Card from "@/components/Card.vue";
import Knowledge from "../components/Knowledge.vue";
import AddControl from "../components/AddControl.vue";
export default {
  components: {
    Card,
    Knowledge,
    AddControl,
  },
  data() {
    return {
      progress: 70, //进度
      passrate: 30, //合格率
      production: 25, //生产中
      // 右侧完成
      finishShow: false,
      inputMaterials: [],
      outputMaterials:[],
      taskData: {
        order: {
          amount: "",
          customer: "",
          deliverDate: "",
          endTime: "",
          orderAttr: [],
          orderId: "",
          parameter: "",
          productId: "",
          productName: "",
          startTime: "",
          unit: "",
        },
        procedure: {
          id: 1,
          procedure: {
            deviceId: "",
            endTime: "",
            inputMaterials: [
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
            ],
            outputMaterials: [
              {
                amount: "",
                materialId: "",
                materialName: "",
                unit: "",
              },
            ],
            procedureId: "",
            procedureName: "",
            startTime: "",
            workHours: "",
            workers: [
              {
                phoneNum: "",
                workerId: "",
                workerName: "",
              },
            ],
          },
        },
      },
    };
  },
  created() {
    setInterval(() => {
      this.progress = this.getRandomNumber(1, 100);
      this.passrate = this.getRandomNumber(1, 100);
      this.production = this.getRandomNumber(1, 100);
    }, 3000);
  mounted() {
    // setInterval(() => {
    //   this.progress = this.getRandomNumber(1, 100);
    //   this.passrate = this.getRandomNumber(1, 100);
    //   this.production = this.getRandomNumber(1, 100);
    // }, 3000);
    this.getTaskInfo();
  },
  methods: {
    setInterCard(value, name) {
      let height = 200;
      let num = 1;
      if (this.$refs[name]) {
        height = this.$refs[name].$el.offsetHeight;
        num = Math.floor(height / 80);
      }
      let inputMaterials = JSON.parse(
        JSON.stringify(this.taskData.procedure.procedure[value])
      );
      let newDataList = [];
      let current = 0;
      // let num=4;
      if (inputMaterials && inputMaterials.length > 0) {
        for (let i = 0; i <= inputMaterials.length - 1; i++) {
          if (i % num !== 0 || i === 0) {
            if (!newDataList[current]) {
              newDataList[current] = [];
              newDataList[current].push(inputMaterials[i]);
            } else {
              newDataList[current].push(inputMaterials[i]);
            }
          } else {
            current++;
            newDataList[current] = [];
            newDataList[current].push(inputMaterials[i]);
          }
        }
      }
      this[value] = [...newDataList];
      console.log(this.inputMaterials, "inputMaterials");
    },
    getTaskInfo() {
      getTaskInfo().then((res) => {
        if (res.code == 200) {
          // setTimeout(() => {
            this.setInterCard("inputMaterials", "cardBox1");
            this.setInterCard('outputMaterials','cardBox3')
          // }, 5000);
        }
      });
    },
    // 设置
    setUrl() {
      const { href } = this.$router.resolve({
        path: "/set",
      });
      window.open(href, "_blank");
    },
    // 右侧控制
    controlClick() {
      this.$refs.control.islook = true;
    },
    // 右侧完成
    finishClick() {
      finishTask({ id: this.taskData.procedure.id }).then((res) => {
        if (res.code == 200) {
          this.$message.success("操作成功!");
        }
      });
    },
    getRandomNumber(min, max) {
      return Math.floor(Math.random() * (max - min + 1) + min);
    },
@@ -260,17 +591,44 @@
<style lang="scss">
.font-arrow-20 {
  font-size: 30px;
  color: #4efefa;
  font-weight: 700;
}
.color_4efefa {
  color: #4efefa;
}
.el-carousel__indicators--vertical{
  display:none;
}
.color_blue {
  background: #33ccff !important;
}
.color_green {
  background: #00cc66 !important;
}
.color_organge {
  background: #f76c0f !important;
}
.color_f70f83 {
  background: #f70f83 !important;
}
.bottom_list {
  position: relative;
  padding:10px;
  width: 30%;
  height: 100%;
  background: #111438;
  // float:left;
  .bottom-title{
    font-weight: 600;
    font-size:16px;
    height: 30px;
    line-height: 30px;
    margin-bottom: 10px;
    .el-button--primary {
      color: #fff;
      float: right;
      border: 0 !important;
    }
  }
  .call {
    background: #4efefa;
@@ -301,6 +659,12 @@
    // color: #000;
    font-size: 16px;
  }
  .card-box {
    width: 100%;
    height: calc(100% - 40px);
    // overflow:auto;
    // height:300px;
  }
}
.small_title {
@@ -309,14 +673,13 @@
}
.home {
  width: 100%;
  height: auto;
  min-height: 100%;
  height: 100%;
  color: #fff;
  background: rgba(2, 10, 38, 1);
  overflow: hidden;
  .left {
    width: calc(78% - 60px);
    height: auto;
    height: 100%;
    min-height: 100%;
    background: rgba(2, 10, 38, 1);
    float: left;
@@ -327,9 +690,6 @@
      font-weight: 600;
      text-align: center;
    }
    .color_4efefa {
      color: #4efefa;
    }
    .statelist {
@@ -415,30 +775,26 @@
    .bottom {
      width: 100%;
      height: 500px;
      height: calc(100% - 470px);
      display: flex;
      flex-wrap: nowrap;
      align-content: center;
      justify-content: space-between;
      align-items: center;
      margin-top: 6%;
      margin-top: 20px;
      // position: relative;
      > div {
        // background: #333333;
        width: 30%;
        height: 100%;
        background: #111438;
        .card {
          width: calc(100% - 20px);
          width: 100%;
          height: 70px;
          // border: 1px solid #ccc;
          background:#ffff;
          border-radius: 5px;
          margin-top: 10px;
          color: #333;
          .card_top-2{
          position: relative;
          .card_top-2,
          .card_top-3 {
            width: 50%;
            height:45px;
            border-radius: 5px;
@@ -459,10 +815,27 @@
              line-height:20px;
               text-align:center;
              display:inline-block;
            }
          }
          .card_top-3 {
            background: #f2f2f2;
            .card-top-r-t {
              width: 90%;
              
              margin: 0 auto;
              margin-bottom: 5px;
              display: block;
              text-align: left;
            }
            .card-top-r-b {
              width: 90%;
              display: block;
              margin: 0 auto;
            }
          }
          .card_top {
          .card_top,
          .card_top-4 {
            width: 50%;
            height:45px;
            border-radius: 5px;
@@ -470,7 +843,6 @@
            font-size: 12px;
            line-height: 45px;
            float:left;
           
            > div {
              margin-left: 12px;
@@ -482,6 +854,21 @@
                font-size: 14px;
              }
            }
          }
          .card_top-4 {
            width: calc(100% - 20px);
            padding: 0 10px;
            line-height: 20px;
          }
          .card-info-box {
            position: absolute;
            background: red;
            border-radius: 6px;
            font-size: 12px;
            color: #fff;
            padding: 3px 5px;
            top: 3px;
            right: 40px;
          }
          .card_content {
            width: 100%;
@@ -497,6 +884,7 @@
              border-radius:5px 5px 0 0;
              background:#ffcc33;
            }
            .card_contentRight {
              width: 100%;
              height: 38%;
@@ -506,10 +894,9 @@
        }
      }
    }
  }
  .right {
    width: calc(20% - 10px);
    height: auto;
    height: 100%;
    min-height: 100%;
    background: #233b9e;
    float: left;
@@ -568,7 +955,6 @@
        display: block;
        border-radius: 50%;
        float:right;
      }
    }
    .right-top-m-btn{
@@ -588,7 +974,7 @@
      border-radius: 4px;
      line-height:30px;
      overflow: hidden;
      background:#00CC66;
      background: #00cc66;
      margin-top:10px;
      padding:5px 10px;
      .right-small-title{
@@ -625,25 +1011,36 @@
      .right-small-btn{
        margin-top:10px;
        width:100%;
        overflow: hidden;
        .el-button--primary{
          width:45%;
          width: 46%;
          background:#fff;
          float:right;
          float: left;
          border-radius:6px;
          color:#4765c0;
          font-weight: 700;
          font-size:18px;
          &:nth-of-type(1){
            float:left;
        }
        .button-finish {
          width: 46%;
          float: right;
          .el-button--primary {
            width: 100%;
          }
        }
      }
    }
    .right_base {
      width: 100%;
      height: 45%;
      height: calc(100% - 520px);
      min-height:200px;
      // overflow-y:auto;
      position: relative;
      .right-base-btn{
        width:100%;
        position:absolute;
        bottom:0;
        left:0;
        .el-button--primary{
          width:100%;
          background:#ff0000;
@@ -652,7 +1049,6 @@
          color:#fff;
          font-weight: 700;
          font-size:18px;
        }
      }
      // .call {