haoxuan
2023-09-02 ca5a51b272cbf4626a09179dbe6d7bc2f9e93ea6
下发成功之后 关闭弹框+刷新get 接口获取status
1个文件已添加
2个文件已修改
125 ■■■■■ 已修改文件
src/api/global-directives.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/AddIssue.vue 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/global-directives.js
New file
@@ -0,0 +1,17 @@
import Vue from 'vue'
// import { Message } from 'element-ui'
// 防止重复提交指令
const preventReClick = Vue.directive('preventReClick', {
  inserted (el, binding) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true
        // Message.warning('操作频繁!')
        setTimeout(() => {
          el.disabled = false
        }, binding.value || 2000)
      }
    })
  }
})
export { preventReClick }
src/components/AddIssue.vue
@@ -7,7 +7,7 @@
    class="add-event-dialog"
    :show-close="false"
  >
    <div class="tank-box">
    <div class="tank-box" v-loading.fullscreen.lock="isLoading" element-loading-text="下发中,请稍后...">
      <div slot="title" class="tac drawerHeader">新任务</div>
      <div class="dialog-content-box">
        <div
@@ -35,7 +35,12 @@
            <div class="error-m">
              {{ messageError }}
            </div>
            <div class="font_size_20 color_fff" style="text-align:center;width:100%;margin:10px 0;">请重试</div>
            <div
              class="font_size_20 color_fff"
              style="text-align: center; width: 100%; margin: 10px 0"
            >
              请重试
            </div>
          </template>
          <template v-else>
            <div class="title-auto-box">
@@ -50,7 +55,8 @@
                产品名称:{{ taskData.Order.productName || "" }}
              </div>
              <div class="title-item">
                数量:{{ taskData.Order.amount || 0 }}{{ taskData.Order.unit }}
                  数量:{{ taskData.Order.amount || 0
                  }}{{ taskData.Order.unit }}
              </div>
              <div class="title-item">
                交货日期:{{ taskData.Order.deliverDate || "" }}
@@ -110,7 +116,7 @@
              {{ message }}
            </div>
            <div class="progress-item">
              <span>{{ parseInt(num/60*100) }}%</span>
                <span>{{ parseInt((num / 60) * 100) }}%</span>
            <el-progress
             style="width:calc(100% - 50px);float:right"
                  define-back-color="#CDC6C6"
@@ -118,7 +124,7 @@
                  text-color="#fff"
                  :text-inside="true"
                  :stroke-width="20"
                  :percentage="parseInt(num/60*100)"
                  :percentage="parseInt((num / 60) * 100)"
                ></el-progress>
                </div>
          </div>
@@ -133,7 +139,7 @@
      </div>
      <div slot="footer" class="dialog-footer tac" style="overflow: hidden">
        <template v-if="messageError">
          <div class="btn" style="margin-left:220px;"  @click="confirmClick2">
          <div class="btn" style="margin-left: 220px" @click="confirmClick2">
            <img src="../../public/confirm3.png" />
          </div>
        </template>
@@ -147,20 +153,27 @@
        <div class="btn" v-if="showBtn==2">
          <img src="../../public/confirm2.png" />
        </div>
        <div class="btn" v-if="showBtn==3" @click="onSubmit()">
          <div
            class="btn"
            v-if="showBtn == 3"
            v-prevent-re-click="3000"
            @click="onSubmit()"
          >
          <img src="../../public/confirm1.png" />
        </div>
        </template>
      </div>
      <!-- <ErrorIssue ref="error" :messageError="messageError" @shutdown="shutdown"/> -->
    </div>
  </el-dialog>
</template>
<script>
import { startTask, setProductNumber,sendProcessParams } from "@/api/home/index"; // 产线
import {
  startTask,
  setProductNumber,
  sendProcessParams,
} from "@/api/home/index"; // 产线
// import ErrorIssue from "@/components/ErrorIssue";
export default {
  components: {},
@@ -190,9 +203,10 @@
      showBtn:1,
      num:0,
      timer:null,
      message:'请确认生产安全!',
      messageError:'',
      message: "请确认生产安全!",
      messageError: "",
      resParams:{},
      isLoading:false,
    };
  },
  mounted() {
@@ -204,34 +218,36 @@
    },
    num(){
      if(this.num==60){
        clearInterval(this.timer)
        clearInterval(this.timer);
        this.showBtn=3;
      }
    }
    },
  },
  methods: {
    confirmClick2(){
      this.messageError=''
      this.messageError = "";
    },
    confirmClick1(){
      this.num=0;
      this.showBtn=2;
      this.message='请确认生产安全!',
      this.timer=setInterval(()=>{
      (this.message = "请确认生产安全!"),
        (this.timer = setInterval(() => {
       this.num=this.num+1;
      },1000)
        }, 1000));
    },
    closeClick(){
      if(this.timer){
        clearInterval(this.timer)
        clearInterval(this.timer);
      }
      this.num=0;
      this.shutdown();
    },
    getInfo() {
      if (Object.keys(this.taskData).length > 0 && this.taskData.Procedure.ID && this.taskData.Procedure.Status == 1) {
      if (
        Object.keys(this.taskData).length > 0 &&
        this.taskData.Procedure.ID &&
        this.taskData.Procedure.Status == 1
      ) {
        this.num=0;
        this.showBtn= 1;
        this.islook=true;
@@ -279,48 +295,51 @@
    },
  
    onSubmit() {
      if(this.taskData.Procedure.ID){
        this.message='参数下发中...',
        this.num=0
        (this.message = "参数下发中..."), (this.num = 0);
        this.timer=setInterval(()=>{
         this.num=this.num+1;
         if(this.num==60||this.resParams){
          this.num=60
          this.getCode(this.resParams)
            this.num = 60;
            this.getCode(this.resParams);
         }
        },1000)
        sendProcessParams({id:this.taskData.Procedure.ID}).then(res=>{
        }, 1000);
        this.isLoading=true;
          sendProcessParams({ id: this.taskData.Procedure.ID }).then((res) => {
          if(res.code==200){
            setProductNumber().then((res) => {
              this.resParams=res;
                this.isLoading=false;
            });
          }else{
              this.isLoading=false;
            this.resParams=res;
          }
        })
          });
      }
    },
    getCode(res){
      if (res.code == 200) {
                if(this.num==60){
                  this.messageError='下发成功!'
                  clearInterval(this.timer)
                  this.num=60;
                  this.showBtn=2;
                  this.message='请确认生产安全!'
          this.messageError = "下发成功!";
          clearInterval(this.timer);
          // this.num = 60;
          // this.showBtn = 2;
          this.message = "请确认生产安全!";
          this.num = 0;
          this.showBtn= 1
          this.shutdown();
          this.$emit('getSetProductNumber')
                  // this.$message.success("下发生产数量成功!");
                }
              }else{
                this.messageError=res.msg?res.msg:'抱歉,工序下发失败!'
                clearInterval(this.timer)
        this.messageError = res.msg ? res.msg : "抱歉,工序下发失败!";
        clearInterval(this.timer);
                this.num=60;
                  this.showBtn=2;
                  this.message='请确认生产安全!'
        this.message = "请确认生产安全!";
              }
    },
    shutdown() {
src/main.js
@@ -9,7 +9,10 @@
// import Element from "element-ui"
// Vue.use(Element, { size: "small", zIndex: 3000 })
// 防止连续点击
// 全局指令
import { preventReClick } from "@/api/global-directives";
Vue.use(preventReClick);
Vue.use(ElementUI)
new Vue({