| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <template>
- <uni-popup
- class="delay-popup"
- ref="delayPopRef"
- type="bottom"
- :is-mask-click="false"
- borderRadius="10px 10px 0 0 "
- background-color="#FFF"
- >
- <view class="popup-container">
- <view class="delay-head">
- <uni-row class="pop-title flex-row align-center justify-center">
- <uni-col :span="3" class="align-center justify-end">
- {{ $t("maintenanceWorkOrder.equipment") }}
- </uni-col>
- <uni-col class="title align-center justify-center">
- {{ maintenance.deviceCode }}-{{ maintenance.name }}
- </uni-col>
- <uni-col :span="6" class="align-center justify-start">
- {{ $t("maintenanceWorkOrder.maintenanceItemConfiguration") }}
- </uni-col>
- </uni-row>
- <uni-icons
- type="closeempty"
- color="#666"
- class="pop-close"
- @click="oncancel"
- ></uni-icons>
- </view>
- <scroll-view scroll-y="true" class="delay-sections">
- <uni-forms
- ref="delayFormRef"
- labelWidth="140px"
- :rules="delayRules"
- :modelValue="maintenanceInfo"
- >
- <!-- 基础保养记录 -->
- <uni-section
- :title="$t('maintenanceWorkOrder.basicMaintenanceRecords')"
- type="line"
- >
- <!-- 运行里程 保养规则-里程(0启用 1停用)-->
- <view v-if="maintenanceInfo.mileageRule == 0">
- <!-- 上次保养里程数(KM) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.lastMaintenanceMileage')"
- name="lastRunningKilometers"
- :required="false"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.lastRunningKilometers"
- placeholder=""
- />
- </uni-forms-item>
- <!-- 推迟公里数((KM) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.delayedKilometers')"
- name="delayKilometers"
- :required="false"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="true"
- :disabled="false"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.delayKilometers"
- placeholder=""
- />
- </uni-forms-item>
- </view>
- <!-- 运行时间 保养规则-运行时间(0启用 1停用)-->
- <view v-if="maintenanceInfo.runningTimeRule == 0">
- <!-- 上次保养运行时间(H) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.lastMaintenanceRunningTime')"
- name="lastRunningTime"
- :required="false"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.lastRunningTime"
- placeholder=""
- />
- </uni-forms-item>
- <!-- 推迟时长(H) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.delayedDuration')"
- name="delayDuration"
- :required="false"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="true"
- :disabled="false"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.delayDuration"
- placeholder=""
- />
- </uni-forms-item>
- </view>
- <!-- 自然日 保养规则-自然日期(0启用 1停用)-->
- <view v-if="maintenanceInfo.naturalDateRule == 0">
- <!-- 上次保养自然日期 -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.lastMaintenanceNaturalDate')"
- name="lastNaturalDate"
- :required="false"
- >
- <uni-datetime-picker
- type="date"
- :border="false"
- :placeholder="' '"
- :clear-icon="false"
- :disabled="true"
- :style="{
- color: maintenanceInfo.lastNaturalDate ? '#999' : '#999',
- 'font-size': maintenanceInfo.lastNaturalDate
- ? '14px !important'
- : 'inherit !important',
- }"
- v-model="maintenanceInfo.lastNaturalDate"
- >
- </uni-datetime-picker>
- </uni-forms-item>
- <!-- 推迟自然日期(D) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.delayedNaturalDate')"
- name="delayNaturalDate"
- :required="false"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="true"
- :disabled="false"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.delayNaturalDate"
- placeholder=""
- />
- </uni-forms-item>
- </view>
- <!-- 推迟原因 -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.delayReason')"
- name="delayReason"
- :required="false"
- >
- <uni-easyinput
- type="textarea"
- :autoHeight="true"
- :inputBorder="false"
- :clearable="true"
- :disabled="false"
- style="text-align: right"
- :styles="{ disableColor: '#F3F5F9' }"
- v-model="maintenanceInfo.delayReason"
- placeholder=""
- />
- </uni-forms-item>
- </uni-section>
- <!-- 运行里程规则配置 里程(0启用 1停用)-->
- <uni-section
- :title="$t('maintenanceWorkOrder.runningMileageRuleConfig')"
- type="line"
- v-if="maintenanceInfo.mileageRule == 0"
- >
- <!-- 运行里程周期(KM) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.runningMileageCycle')"
- name="kilometerCycle"
- :required="true"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.nextRunningKilometers"
- placeholder=""
- />
- </uni-forms-item>
- <!-- 运行里程周期-提前量(KM) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.runningMileageCycleLead')"
- name="runningMileageCycleAdvance"
- :required="true"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.kiloCycleLead"
- placeholder=""
- />
- </uni-forms-item>
- </uni-section>
- <!-- 运行时间规则配置 -->
- <uni-section
- :title="$t('maintenanceWorkOrder.runningTimeRuleConfig')"
- type="line"
- v-if="maintenanceInfo.runningTimeRule == 0"
- >
- <!-- 运行时间周期(H) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.runningTimeCycle')"
- name="timePeriod"
- :required="true"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.nextRunningTime"
- placeholder=""
- />
- </uni-forms-item>
- <!-- 运行时间周期-提前量(H) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.runningTimeCycleLead')"
- name="timePeriodLead"
- :required="true"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.timePeriodLead"
- placeholder=""
- />
- </uni-forms-item>
- </uni-section>
- <!-- 自然日规则配置 -->
- <uni-section
- :title="$t('maintenanceWorkOrder.naturalDateRuleConfig')"
- type="line"
- v-if="maintenanceInfo.naturalDateRule == 0"
- >
- <!-- 自然日周期(D) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.naturalDateCycle')"
- name="naturalDatePeriod"
- :required="true"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.nextNaturalDate"
- placeholder=""
- />
- </uni-forms-item>
- <!-- 自然日周期-提前量(D) -->
- <uni-forms-item
- class="form-item"
- :label="$t('maintenanceWorkOrder.naturalDateCycleLead')"
- name="naturalDatePeriodLead"
- :required="true"
- >
- <uni-easyinput
- style="text-align: right"
- :inputBorder="false"
- :clearable="false"
- :disabled="true"
- :styles="{ disableColor: '#F3F5F9' }"
- type="digit"
- v-model="maintenanceInfo.naturalDatePeriodLead"
- placeholder=""
- />
- </uni-forms-item>
- </uni-section>
- </uni-forms>
- </scroll-view>
- <button
- class="submit-btn"
- type="primary"
- @click="onConfirm(delayFormRef)"
- >
- {{ $t("operation.save") }}
- </button>
- </view>
- </uni-popup>
- </template>
- <script setup>
- import dayjs from "dayjs";
- import { computed, ref, reactive, watch, onMounted } from "vue";
- import { useI18n } from "vue-i18n";
- import { getDeptId } from "@/utils/auth";
- import { getMaterialListData } from "@/api/material";
- import { devicePage } from "@/api/device";
- const { t, locale } = useI18n({
- useScope: "global",
- });
- // 接收父组件传递的参数
- const props = defineProps({
- maintenance: {
- type: Object,
- default: () => ({}),
- },
- });
- const oncancel = () => {
- close();
- };
- const onConfirm = async (formEl) => {
- if (!formEl) return;
- await formEl
- .validate()
- .then((res) => {
- console.log("success", res);
- emit("delay-set", maintenanceInfo.value);
- oncancel();
- })
- .catch((err) => {
- console.log("err", err);
- });
- };
- onMounted(() => {});
- const delayPopRef = ref(null);
- const maintenanceInfo = ref({});
- // 打开弹窗
- const open = (info) => {
- console.log("open info-", info);
- maintenanceInfo.value = info;
- delayPopRef.value.open();
- };
- // 关闭弹窗
- const close = () => {
- delayPopRef.value.close();
- };
- const delayFormRef = ref(null);
- const baseRules = ref({
- delayReason: {
- rules: [
- {
- required: false,
- errorMessage: `${t("operation.PleaseFillIn")}${t(
- "maintenanceWorkOrder.delayReason"
- )}`,
- },
- ],
- },
- });
- // 动态计算校验规则
- const delayRules = computed(() => {
- const rules = JSON.parse(JSON.stringify(baseRules.value));
- // 根据填写内容调整规则
- if (
- maintenanceInfo.value.delayKilometers > 0 ||
- maintenanceInfo.value.delayDuration > 0 ||
- maintenanceInfo.value.delayNaturalDate > 0
- ) {
- // 如果填写了推迟公里数、推迟时长或推迟自然日期,则推迟原因必填
- rules.delayReason.rules[0].required = true;
- } else {
- rules.delayReason.rules[0].required = false;
- }
- return rules;
- });
- const emit = defineEmits(["delay-set"]);
- // 提供外部方法
- const expose = {
- open,
- };
- defineExpose(expose);
- </script>
- <style lang="scss" scoped>
- @import "@/style/work-order-detail.scss";
- :deep(.uni-popup__wrapper) {
- padding: 20px 15px;
- }
- .popup-container {
- width: 100%;
- height: 450px;
- box-sizing: border-box;
- background-color: #fff;
- position: relative;
- }
- .pop-title {
- width: 100%;
- font-size: 16px;
- color: #333333;
- line-height: 22px;
- margin-bottom: 20px;
- .title {
- // min-width: 49.999999992%;
- width: max-content;
- max-width: 62.49999999%;
- font-weight: 700;
- }
- }
- .pop-close {
- position: absolute;
- right: -5px;
- top: -10px;
- }
- .delay-sections {
- position: relative;
- height: calc(100% - 80px);
- }
- :deep(.uni-section) {
- background: #f3f5f9;
- // border: 1px solid #999;
- margin-bottom: 10px;
- }
- :deep(.uni-section-content) {
- background: #f3f5f9;
- padding: 0 10px 10px;
- }
- :deep(.uni-section-header__content) {
- font-weight: 600;
- }
- :deep(.uni-section-header__decoration) {
- // position: absolute;
- // left: 0;
- margin-right: 10px !important;
- margin-left: -10px;
- }
- :deep(uni-text) {
- font-size: 14px;
- }
- :deep(.uni-date-x) {
- background: #f3f5f9;
- }
- .pop-btn {
- margin-top: 20px;
- width: 120px;
- height: 32px;
- line-height: 32px;
- font-size: 14px;
- }
- </style>
|