delay.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <uni-popup
  3. class="delay-popup"
  4. ref="delayPopRef"
  5. type="bottom"
  6. :is-mask-click="false"
  7. borderRadius="10px 10px 0 0 "
  8. background-color="#FFF"
  9. >
  10. <view class="popup-container">
  11. <view class="delay-head">
  12. <uni-row class="pop-title flex-row align-center justify-center">
  13. <uni-col :span="3" class="align-center justify-end">
  14. {{ $t("maintenanceWorkOrder.equipment") }}
  15. </uni-col>
  16. <uni-col class="title align-center justify-center">
  17. {{ maintenance.deviceCode }}-{{ maintenance.name }}
  18. </uni-col>
  19. <uni-col :span="6" class="align-center justify-start">
  20. {{ $t("maintenanceWorkOrder.maintenanceItemConfiguration") }}
  21. </uni-col>
  22. </uni-row>
  23. <uni-icons
  24. type="closeempty"
  25. color="#666"
  26. class="pop-close"
  27. @click="oncancel"
  28. ></uni-icons>
  29. </view>
  30. <scroll-view scroll-y="true" class="delay-sections">
  31. <uni-forms
  32. ref="delayFormRef"
  33. labelWidth="140px"
  34. :rules="delayRules"
  35. :modelValue="maintenanceInfo"
  36. >
  37. <!-- 基础保养记录 -->
  38. <uni-section
  39. :title="$t('maintenanceWorkOrder.basicMaintenanceRecords')"
  40. type="line"
  41. >
  42. <!-- 运行里程 保养规则-里程(0启用 1停用)-->
  43. <view v-if="maintenanceInfo.mileageRule == 0">
  44. <!-- 上次保养里程数(KM) -->
  45. <uni-forms-item
  46. class="form-item"
  47. :label="$t('maintenanceWorkOrder.lastMaintenanceMileage')"
  48. name="lastRunningKilometers"
  49. :required="false"
  50. >
  51. <uni-easyinput
  52. style="text-align: right"
  53. :inputBorder="false"
  54. :clearable="false"
  55. :disabled="true"
  56. :styles="{ disableColor: '#F3F5F9' }"
  57. type="digit"
  58. v-model="maintenanceInfo.lastRunningKilometers"
  59. placeholder=""
  60. />
  61. </uni-forms-item>
  62. <!-- 推迟公里数((KM) -->
  63. <uni-forms-item
  64. class="form-item"
  65. :label="$t('maintenanceWorkOrder.delayedKilometers')"
  66. name="delayKilometers"
  67. :required="false"
  68. >
  69. <uni-easyinput
  70. style="text-align: right"
  71. :inputBorder="false"
  72. :clearable="true"
  73. :disabled="false"
  74. :styles="{ disableColor: '#F3F5F9' }"
  75. type="digit"
  76. v-model="maintenanceInfo.delayKilometers"
  77. placeholder=""
  78. />
  79. </uni-forms-item>
  80. </view>
  81. <!-- 运行时间 保养规则-运行时间(0启用 1停用)-->
  82. <view v-if="maintenanceInfo.runningTimeRule == 0">
  83. <!-- 上次保养运行时间(H) -->
  84. <uni-forms-item
  85. class="form-item"
  86. :label="$t('maintenanceWorkOrder.lastMaintenanceRunningTime')"
  87. name="lastRunningTime"
  88. :required="false"
  89. >
  90. <uni-easyinput
  91. style="text-align: right"
  92. :inputBorder="false"
  93. :clearable="false"
  94. :disabled="true"
  95. :styles="{ disableColor: '#F3F5F9' }"
  96. type="digit"
  97. v-model="maintenanceInfo.lastRunningTime"
  98. placeholder=""
  99. />
  100. </uni-forms-item>
  101. <!-- 推迟时长(H) -->
  102. <uni-forms-item
  103. class="form-item"
  104. :label="$t('maintenanceWorkOrder.delayedDuration')"
  105. name="delayDuration"
  106. :required="false"
  107. >
  108. <uni-easyinput
  109. style="text-align: right"
  110. :inputBorder="false"
  111. :clearable="true"
  112. :disabled="false"
  113. :styles="{ disableColor: '#F3F5F9' }"
  114. type="digit"
  115. v-model="maintenanceInfo.delayDuration"
  116. placeholder=""
  117. />
  118. </uni-forms-item>
  119. </view>
  120. <!-- 自然日 保养规则-自然日期(0启用 1停用)-->
  121. <view v-if="maintenanceInfo.naturalDateRule == 0">
  122. <!-- 上次保养自然日期 -->
  123. <uni-forms-item
  124. class="form-item"
  125. :label="$t('maintenanceWorkOrder.lastMaintenanceNaturalDate')"
  126. name="lastNaturalDate"
  127. :required="false"
  128. >
  129. <uni-datetime-picker
  130. type="date"
  131. :border="false"
  132. :placeholder="' '"
  133. :clear-icon="false"
  134. :disabled="true"
  135. :style="{
  136. color: maintenanceInfo.lastNaturalDate ? '#999' : '#999',
  137. 'font-size': maintenanceInfo.lastNaturalDate
  138. ? '14px !important'
  139. : 'inherit !important',
  140. }"
  141. v-model="maintenanceInfo.lastNaturalDate"
  142. >
  143. </uni-datetime-picker>
  144. </uni-forms-item>
  145. <!-- 推迟自然日期(D) -->
  146. <uni-forms-item
  147. class="form-item"
  148. :label="$t('maintenanceWorkOrder.delayedNaturalDate')"
  149. name="delayNaturalDate"
  150. :required="false"
  151. >
  152. <uni-easyinput
  153. style="text-align: right"
  154. :inputBorder="false"
  155. :clearable="true"
  156. :disabled="false"
  157. :styles="{ disableColor: '#F3F5F9' }"
  158. type="digit"
  159. v-model="maintenanceInfo.delayNaturalDate"
  160. placeholder=""
  161. />
  162. </uni-forms-item>
  163. </view>
  164. <!-- 推迟原因 -->
  165. <uni-forms-item
  166. class="form-item"
  167. :label="$t('maintenanceWorkOrder.delayReason')"
  168. name="delayReason"
  169. :required="false"
  170. >
  171. <uni-easyinput
  172. type="textarea"
  173. :autoHeight="true"
  174. :inputBorder="false"
  175. :clearable="true"
  176. :disabled="false"
  177. style="text-align: right"
  178. :styles="{ disableColor: '#F3F5F9' }"
  179. v-model="maintenanceInfo.delayReason"
  180. placeholder=""
  181. />
  182. </uni-forms-item>
  183. </uni-section>
  184. <!-- 运行里程规则配置 里程(0启用 1停用)-->
  185. <uni-section
  186. :title="$t('maintenanceWorkOrder.runningMileageRuleConfig')"
  187. type="line"
  188. v-if="maintenanceInfo.mileageRule == 0"
  189. >
  190. <!-- 运行里程周期(KM) -->
  191. <uni-forms-item
  192. class="form-item"
  193. :label="$t('maintenanceWorkOrder.runningMileageCycle')"
  194. name="kilometerCycle"
  195. :required="true"
  196. >
  197. <uni-easyinput
  198. style="text-align: right"
  199. :inputBorder="false"
  200. :clearable="false"
  201. :disabled="true"
  202. :styles="{ disableColor: '#F3F5F9' }"
  203. type="digit"
  204. v-model="maintenanceInfo.nextRunningKilometers"
  205. placeholder=""
  206. />
  207. </uni-forms-item>
  208. <!-- 运行里程周期-提前量(KM) -->
  209. <uni-forms-item
  210. class="form-item"
  211. :label="$t('maintenanceWorkOrder.runningMileageCycleLead')"
  212. name="runningMileageCycleAdvance"
  213. :required="true"
  214. >
  215. <uni-easyinput
  216. style="text-align: right"
  217. :inputBorder="false"
  218. :clearable="false"
  219. :disabled="true"
  220. :styles="{ disableColor: '#F3F5F9' }"
  221. type="digit"
  222. v-model="maintenanceInfo.kiloCycleLead"
  223. placeholder=""
  224. />
  225. </uni-forms-item>
  226. </uni-section>
  227. <!-- 运行时间规则配置 -->
  228. <uni-section
  229. :title="$t('maintenanceWorkOrder.runningTimeRuleConfig')"
  230. type="line"
  231. v-if="maintenanceInfo.runningTimeRule == 0"
  232. >
  233. <!-- 运行时间周期(H) -->
  234. <uni-forms-item
  235. class="form-item"
  236. :label="$t('maintenanceWorkOrder.runningTimeCycle')"
  237. name="timePeriod"
  238. :required="true"
  239. >
  240. <uni-easyinput
  241. style="text-align: right"
  242. :inputBorder="false"
  243. :clearable="false"
  244. :disabled="true"
  245. :styles="{ disableColor: '#F3F5F9' }"
  246. type="digit"
  247. v-model="maintenanceInfo.nextRunningTime"
  248. placeholder=""
  249. />
  250. </uni-forms-item>
  251. <!-- 运行时间周期-提前量(H) -->
  252. <uni-forms-item
  253. class="form-item"
  254. :label="$t('maintenanceWorkOrder.runningTimeCycleLead')"
  255. name="timePeriodLead"
  256. :required="true"
  257. >
  258. <uni-easyinput
  259. style="text-align: right"
  260. :inputBorder="false"
  261. :clearable="false"
  262. :disabled="true"
  263. :styles="{ disableColor: '#F3F5F9' }"
  264. type="digit"
  265. v-model="maintenanceInfo.timePeriodLead"
  266. placeholder=""
  267. />
  268. </uni-forms-item>
  269. </uni-section>
  270. <!-- 自然日规则配置 -->
  271. <uni-section
  272. :title="$t('maintenanceWorkOrder.naturalDateRuleConfig')"
  273. type="line"
  274. v-if="maintenanceInfo.naturalDateRule == 0"
  275. >
  276. <!-- 自然日周期(D) -->
  277. <uni-forms-item
  278. class="form-item"
  279. :label="$t('maintenanceWorkOrder.naturalDateCycle')"
  280. name="naturalDatePeriod"
  281. :required="true"
  282. >
  283. <uni-easyinput
  284. style="text-align: right"
  285. :inputBorder="false"
  286. :clearable="false"
  287. :disabled="true"
  288. :styles="{ disableColor: '#F3F5F9' }"
  289. type="digit"
  290. v-model="maintenanceInfo.nextNaturalDate"
  291. placeholder=""
  292. />
  293. </uni-forms-item>
  294. <!-- 自然日周期-提前量(D) -->
  295. <uni-forms-item
  296. class="form-item"
  297. :label="$t('maintenanceWorkOrder.naturalDateCycleLead')"
  298. name="naturalDatePeriodLead"
  299. :required="true"
  300. >
  301. <uni-easyinput
  302. style="text-align: right"
  303. :inputBorder="false"
  304. :clearable="false"
  305. :disabled="true"
  306. :styles="{ disableColor: '#F3F5F9' }"
  307. type="digit"
  308. v-model="maintenanceInfo.naturalDatePeriodLead"
  309. placeholder=""
  310. />
  311. </uni-forms-item>
  312. </uni-section>
  313. </uni-forms>
  314. </scroll-view>
  315. <button
  316. class="submit-btn"
  317. type="primary"
  318. @click="onConfirm(delayFormRef)"
  319. >
  320. {{ $t("operation.save") }}
  321. </button>
  322. </view>
  323. </uni-popup>
  324. </template>
  325. <script setup>
  326. import dayjs from "dayjs";
  327. import { computed, ref, reactive, watch, onMounted } from "vue";
  328. import { useI18n } from "vue-i18n";
  329. import { getDeptId } from "@/utils/auth";
  330. import { getMaterialListData } from "@/api/material";
  331. import { devicePage } from "@/api/device";
  332. const { t, locale } = useI18n({
  333. useScope: "global",
  334. });
  335. // 接收父组件传递的参数
  336. const props = defineProps({
  337. maintenance: {
  338. type: Object,
  339. default: () => ({}),
  340. },
  341. });
  342. const oncancel = () => {
  343. close();
  344. };
  345. const onConfirm = async (formEl) => {
  346. if (!formEl) return;
  347. await formEl
  348. .validate()
  349. .then((res) => {
  350. console.log("success", res);
  351. emit("delay-set", maintenanceInfo.value);
  352. oncancel();
  353. })
  354. .catch((err) => {
  355. console.log("err", err);
  356. });
  357. };
  358. onMounted(() => {});
  359. const delayPopRef = ref(null);
  360. const maintenanceInfo = ref({});
  361. // 打开弹窗
  362. const open = (info) => {
  363. console.log("open info-", info);
  364. maintenanceInfo.value = info;
  365. delayPopRef.value.open();
  366. };
  367. // 关闭弹窗
  368. const close = () => {
  369. delayPopRef.value.close();
  370. };
  371. const delayFormRef = ref(null);
  372. const baseRules = ref({
  373. delayReason: {
  374. rules: [
  375. {
  376. required: false,
  377. errorMessage: `${t("operation.PleaseFillIn")}${t(
  378. "maintenanceWorkOrder.delayReason"
  379. )}`,
  380. },
  381. ],
  382. },
  383. });
  384. // 动态计算校验规则
  385. const delayRules = computed(() => {
  386. const rules = JSON.parse(JSON.stringify(baseRules.value));
  387. // 根据填写内容调整规则
  388. if (
  389. maintenanceInfo.value.delayKilometers > 0 ||
  390. maintenanceInfo.value.delayDuration > 0 ||
  391. maintenanceInfo.value.delayNaturalDate > 0
  392. ) {
  393. // 如果填写了推迟公里数、推迟时长或推迟自然日期,则推迟原因必填
  394. rules.delayReason.rules[0].required = true;
  395. } else {
  396. rules.delayReason.rules[0].required = false;
  397. }
  398. return rules;
  399. });
  400. const emit = defineEmits(["delay-set"]);
  401. // 提供外部方法
  402. const expose = {
  403. open,
  404. };
  405. defineExpose(expose);
  406. </script>
  407. <style lang="scss" scoped>
  408. @import "@/style/work-order-detail.scss";
  409. :deep(.uni-popup__wrapper) {
  410. padding: 20px 15px;
  411. }
  412. .popup-container {
  413. width: 100%;
  414. height: 450px;
  415. box-sizing: border-box;
  416. background-color: #fff;
  417. position: relative;
  418. }
  419. .pop-title {
  420. width: 100%;
  421. font-size: 16px;
  422. color: #333333;
  423. line-height: 22px;
  424. margin-bottom: 20px;
  425. .title {
  426. // min-width: 49.999999992%;
  427. width: max-content;
  428. max-width: 62.49999999%;
  429. font-weight: 700;
  430. }
  431. }
  432. .pop-close {
  433. position: absolute;
  434. right: -5px;
  435. top: -10px;
  436. }
  437. .delay-sections {
  438. position: relative;
  439. height: calc(100% - 80px);
  440. }
  441. :deep(.uni-section) {
  442. background: #f3f5f9;
  443. // border: 1px solid #999;
  444. margin-bottom: 10px;
  445. }
  446. :deep(.uni-section-content) {
  447. background: #f3f5f9;
  448. padding: 0 10px 10px;
  449. }
  450. :deep(.uni-section-header__content) {
  451. font-weight: 600;
  452. }
  453. :deep(.uni-section-header__decoration) {
  454. // position: absolute;
  455. // left: 0;
  456. margin-right: 10px !important;
  457. margin-left: -10px;
  458. }
  459. :deep(uni-text) {
  460. font-size: 14px;
  461. }
  462. :deep(.uni-date-x) {
  463. background: #f3f5f9;
  464. }
  465. .pop-btn {
  466. margin-top: 20px;
  467. width: 120px;
  468. height: 32px;
  469. line-height: 32px;
  470. font-size: 14px;
  471. }
  472. </style>