songshankun
2023-11-22 f6739d7542be48f7f8139c3d5fc7b2326e5cfc8d
src/components/TaskControlModal.vue
@@ -93,6 +93,10 @@
                >
                  工艺参数
                </div>
                <!-- 未获取到工艺参数, 且当前设备允许在没有工艺参数的情况下生产, 则提示-->
                <div v-if="processParamsLoaded &&  !currentProcessParams?.length && currentDeviceAllowNoParams" class="title-item title-item-two">
                  未获取到工艺参数, 请手动设置或在云端工艺模型中上传
                </div>
                <div
                  class="title-item title-item-two"
                  v-for="(item, index) in currentProcessParams"
@@ -103,7 +107,7 @@
                </div>
              </div>
            </div>
            <div class="process-err-tip" v-if="getProcessParamsErrMsg">
            <div class="process-err-tip" v-if="getProcessParamsErrMsg && !currentDeviceAllowNoParams">
              <div class="tip-icon">
                <span class="el-icon-error color_error"></span>
              </div>
@@ -170,7 +174,7 @@
      </div>
      <div slot="footer" :class="messageError?'dialog-footer tac btn-error':'dialog-footer tac'"
           style="overflow: hidden">
        <template v-if="messageError || getProcessParamsErrMsg">
        <template v-if="(messageError || getProcessParamsErrMsg) && !currentDeviceAllowNoParams">
          <div class="btn" v-if="messageError ==='下发成功!'||getProcessParamsErrMsg" @click="closeClick">
            <img src="../../public/close-btn.png"/>
          </div>
@@ -215,7 +219,7 @@
</template>
<script>
import {getTaskInfo, sendProcessParams, startTask,} from "@/api/home"; // 产线
import {getDeviceList, getTaskInfo, sendProcessParams, startTask,} from "@/api/home"; // 产线
import {channelNameConfig} from "@/common/constants";
export default {
  name: 'TaskControlModal',
@@ -235,6 +239,7 @@
      currentTaskIndex: 0,
      // 当前展示的任务对应的工艺参数
      currentProcessParams: [],
      processParamsLoaded:false,
      getProcessParamsErrMsg: '',
      // 任务列表
      taskList: [],
@@ -248,13 +253,17 @@
      isLoading: false,
      second: 0,
      secondTimer: null,
      channelNameConfig: channelNameConfig
      channelNameConfig: channelNameConfig,
      currentDeviceAllowNoParams:false,
      deviceInfo:null
    };
  },
  mounted() {
    this.getTaskList().then(() => {
      const firstData = this.taskList[0]
      const id = firstData?.Procedure?.ID
      console.log(this.taskList)
      this.getDeviceInfo()
      if (id) {
        this.currentTaskIndex = this.taskList.findIndex(ele => ele.Procedure.ID === id)
        this.getCurrentTaskProduceParams(id)
@@ -304,6 +313,7 @@
      if (this.secondTimer) {
        clearInterval(this.secondTimer)
      }
      this.processParamsLoaded=false
      this.num = 0;
      this.showBtn = 1;
      this.isLoading = false
@@ -312,6 +322,7 @@
      this.messageError = ''
      this.resParams = {};
      if (newVal) {
        this.getDeviceInfo()
        this.getTaskList().then(() => {
          const firstData = this.taskList[0]
          const id = firstData?.Procedure?.ID
@@ -361,6 +372,20 @@
        console.error(err)
      },)
    },
    getDeviceInfo(){
      getDeviceList().then(res=>{
        this.deviceInfo = res.data
        this.currentDeviceAllowNoParams=this.getConfig(this.deviceInfo)
      }).catch(err=>{
        console.error(err)
      })
    },
    getConfig(deviceInfo){
      const currentDeviceInfo = deviceInfo.deviceList?.find((ele) => {
        return ele.deviceID === deviceInfo.currentDeviceID
      })
      return !currentDeviceInfo?.needSetProcessParams
    },
    /**
     * 获取当前展示的任务的工艺参数
     */
@@ -369,6 +394,7 @@
      if (id) {
        this.currentProcessParams = []
        this.getProcessParamsErrMsg = ""
        this.processParamsLoaded =false
        startTask({id}).then((res) => {
          if (res.code === 200) {
            this.currentProcessParams = res.data.Params ?? []
@@ -382,6 +408,8 @@
          console.error(err)
          this.currentProcessParams = []
          this.getProcessParamsErrMsg = '获取工艺参数失败!'
        }).finally(()=>{
          this.processParamsLoaded =true
        });
      }
    },