haoxuan
2023-11-06 75c41cc8a2f25cff74e976cdc7851cbaddd97b3f
src/views/dashboard/components/ProcessInfo.vue
@@ -11,29 +11,55 @@
    <div v-if="craftModel.isUpdate" class="tip-r">
      <img src="~@/assets/images/process-tip.png" />
    </div>
    <div v-if="craftModel.isUpdate" class="tip-current">当前使用</div>
    <div v-if="craftModel.number == task?.Procedure?.processModelNumber" class="tip-current">当前使用</div>
    <div class="btn">
      <el-button type="primary" @click="onUpdateClick"> 更新工艺 </el-button>
      <el-button type="primary" :disabled="craftModel.isUpdate ? false : true" @click="onUpdateClick">
        <el-icon v-if="loading" color="#fff" :size="16" class="refresh-top-icon">
          <Loading />
        </el-icon>
        更新工艺
      </el-button>
    </div>
  </div>
</template>
<script setup lang="ts">
import { toRefs } from 'vue'
import { toRefs, ref, watch } from 'vue'
import { Loading } from '@element-plus/icons-vue'
import type { CraftModel } from '@/api/craftModel'
import type { Task } from '@/api/task'
const props = defineProps<{
  craftModel: CraftModel
  activeArr: Array
  task?: Task
}>()
const { craftModel } = toRefs(props)
const { craftModel, task, activeArr } = toRefs(props)
const emit = defineEmits<{
  update: [craftModel: CraftModel]
  detail: [craftModel: CraftModel]
}>()
const loading = ref(false)
watch(activeArr.value, () => {
  // 弹窗显示时获取工艺参数
  if (activeArr.value) {
    getLoading()
  }
})
function getLoading() {
  for (let i in activeArr.value) {
    if (activeArr.value[i] == craftModel.value.number) {
      loading.value = true
      break
    }
  }
}
function onDetailClick() {
  emit('detail', craftModel.value)
}
function onUpdateClick() {
  if (loading.value) {
    return true
  }
  emit('update', craftModel.value)
}
</script>
@@ -42,12 +68,13 @@
$status-running: #f76c0f;
$status-done: #2c5dbb82;
$status-ready: #00ff00f0;
$status-disabled: #7b95d3;
.font_weight {
  font-weight: 600;
}
.process-info {
  width: calc(50% - 35px);
  height: 110px;
  height: 140px;
  padding: 23px 10px 10px;
  background: $status-done;
  border-radius: 8px;
@@ -69,6 +96,11 @@
    img {
      width: 100%;
    }
  }
  .refresh-top-icon {
    display: flex;
    align-items: center;
    color: #fff;
  }
  .item-r {
@@ -114,12 +146,18 @@
  .btn {
    width: 100px;
    position: absolute;
    right: 0px;
    right: 10px;
    bottom: 10px;
    .el-button--primary {
      background: $status-running;
      border: 0 !important;
    }
    .el-button.is-disabled,
    .el-button.is-disabled:focus,
    .el-button.is-disabled:hover {
      color: #fff !important;
      background: $status-disabled;
    }
  }
}
</style>