From d3fe17c4cc5ae2dda4e2c1cfd5c506faa74f6a0d Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 26 一月 2026 14:17:34 +0800
Subject: [PATCH] 设备维修添加维修状态
---
src/pages/procurementManagement/receiptPaymentHistory/index.vue | 395 +++++++------
src/pages/equipmentManagement/repair/maintain.vue | 495 +++++++++-------
src/pages/equipmentManagement/repair/add.vue | 840 +++++++++++++++-------------
3 files changed, 934 insertions(+), 796 deletions(-)
diff --git a/src/pages/equipmentManagement/repair/add.vue b/src/pages/equipmentManagement/repair/add.vue
index 0940052..71de940 100644
--- a/src/pages/equipmentManagement/repair/add.vue
+++ b/src/pages/equipmentManagement/repair/add.vue
@@ -1,435 +1,489 @@
<template>
- <view class="repair-add">
- <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
- <PageHeader :title="operationType === 'edit' ? '缂栬緫鎶ヤ慨' : '鏂板鎶ヤ慨'" @back="goBack" />
-
- <!-- 琛ㄥ崟鍐呭 -->
- <u-form @submit="sendForm" ref="formRef" :rules="formRules" :model="form" label-width="110">
- <!-- 鍩烘湰淇℃伅 -->
- <u-cell-group title="鍩烘湰淇℃伅">
- <u-form-item label="璁惧鍚嶇О" prop="deviceLedgerId" required border-bottom>
- <u-input
- v-model="deviceNameText"
- placeholder="璇烽�夋嫨璁惧鍚嶇О"
- @click="showDevicePicker"
- clearable
- readonly=""
- />
- <template #right>
- <u-icon name="scan" @click="startScan" class="scan-icon" />
- </template>
- </u-form-item>
- <u-form-item label="瑙勬牸鍨嬪彿" prop="deviceModel" border-bottom>
- <u-input
- v-model="form.deviceModel"
- placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
- clearable
- />
- </u-form-item>
- <u-form-item label="鎶ヤ慨鏃ユ湡" prop="repairTime" required border-bottom>
- <u-input
- v-model="form.repairTime"
- placeholder="璇烽�夋嫨鎶ヤ慨鏃ユ湡"
- readonly
- @click="showDatePicker"
- clearable
- />
- <template #right>
- <u-icon name="arrow-right" @click="showDatePicker"></u-icon>
- </template>
- </u-form-item>
- <u-form-item label="鎶ヤ慨浜�" prop="repairName" required border-bottom>
- <u-input
- v-model="form.repairName"
- placeholder="璇疯緭鍏ユ姤淇汉"
- clearable
- />
- </u-form-item>
- <u-form-item label="鏁呴殰鐜拌薄" prop="remark" required border-bottom>
- <u-textarea
- v-model="form.remark"
- rows="3"
- placeholder="璇疯緭鍏ユ晠闅滅幇璞�"
- clearable
- count
- maxlength="200"
- />
- </u-form-item>
- </u-cell-group>
-
- <!-- 鎻愪氦鎸夐挳 -->
- <view class="footer-btns">
- <u-button class="cancel-btn" @click="goBack">鍙栨秷</u-button>
- <u-button class="save-btn" type="primary" @click="sendForm" :loading="loading">淇濆瓨</u-button>
- </view>
- </u-form>
-
- <!-- 璁惧閫夋嫨鍣� -->
- <up-action-sheet
- :show="showDevice"
- :actions="deviceActionList"
- title="閫夋嫨璁惧鍚嶇О"
- @select="onDeviceSelect"
- @close="showDevice = false"
- />
-
- <!-- 鏃ユ湡閫夋嫨鍣� -->
- <up-datetime-picker
- :show="showDate"
- v-model="pickerDateValue"
- @confirm="onDateConfirm"
- @cancel="showDate = false"
- mode="date"
- />
- </view>
+ <view class="repair-add">
+ <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
+ <PageHeader :title="operationType === 'edit' ? '缂栬緫鎶ヤ慨' : '鏂板鎶ヤ慨'"
+ @back="goBack" />
+ <!-- 琛ㄥ崟鍐呭 -->
+ <u-form @submit="sendForm"
+ ref="formRef"
+ :rules="formRules"
+ :model="form"
+ label-width="110">
+ <!-- 鍩烘湰淇℃伅 -->
+ <u-cell-group title="鍩烘湰淇℃伅">
+ <u-form-item label="璁惧鍚嶇О"
+ prop="deviceLedgerId"
+ required
+ border-bottom>
+ <u-input v-model="deviceNameText"
+ placeholder="璇烽�夋嫨璁惧鍚嶇О"
+ @click="showDevicePicker"
+ clearable
+ readonly="" />
+ <template #right>
+ <u-icon name="scan"
+ @click="startScan"
+ class="scan-icon" />
+ </template>
+ </u-form-item>
+ <u-form-item label="瑙勬牸鍨嬪彿"
+ prop="deviceModel"
+ border-bottom>
+ <u-input v-model="form.deviceModel"
+ placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
+ clearable />
+ </u-form-item>
+ <u-form-item label="鎶ヤ慨鏃ユ湡"
+ prop="repairTime"
+ required
+ border-bottom>
+ <u-input v-model="form.repairTime"
+ placeholder="璇烽�夋嫨鎶ヤ慨鏃ユ湡"
+ readonly
+ @click="showDatePicker"
+ clearable />
+ <template #right>
+ <u-icon name="arrow-right"
+ @click="showDatePicker"></u-icon>
+ </template>
+ </u-form-item>
+ <u-form-item label="鎶ヤ慨鐘舵��"
+ prop="repairTime"
+ required
+ border-bottom>
+ <u-input v-model="repairStatusText"
+ placeholder="璇烽�夋嫨鎶ヤ慨鐘舵��"
+ readonly
+ @click="openRepairStatusPicker"
+ clearable />
+ <template #right>
+ <u-icon name="arrow-right"
+ @click="openRepairStatusPicker"></u-icon>
+ </template>
+ </u-form-item>
+ <u-form-item label="鎶ヤ慨浜�"
+ prop="repairName"
+ required
+ border-bottom>
+ <u-input v-model="form.repairName"
+ placeholder="璇疯緭鍏ユ姤淇汉"
+ clearable />
+ </u-form-item>
+ <u-form-item label="鏁呴殰鐜拌薄"
+ prop="remark"
+ required
+ border-bottom>
+ <u-textarea v-model="form.remark"
+ rows="3"
+ placeholder="璇疯緭鍏ユ晠闅滅幇璞�"
+ clearable
+ count
+ maxlength="200" />
+ </u-form-item>
+ </u-cell-group>
+ <!-- 鎻愪氦鎸夐挳 -->
+ <view class="footer-btns">
+ <u-button class="cancel-btn"
+ @click="goBack">鍙栨秷</u-button>
+ <u-button class="save-btn"
+ type="primary"
+ @click="sendForm"
+ :loading="loading">淇濆瓨</u-button>
+ </view>
+ </u-form>
+ <!-- 璁惧閫夋嫨鍣� -->
+ <up-action-sheet :show="showDevice"
+ :actions="deviceActionList"
+ title="閫夋嫨璁惧鍚嶇О"
+ @select="onDeviceSelect"
+ @close="showDevice = false" />
+ <!-- 鏃ユ湡閫夋嫨鍣� -->
+ <up-datetime-picker :show="showDate"
+ v-model="pickerDateValue"
+ @confirm="onDateConfirm"
+ @cancel="showDate = false"
+ mode="date" />
+ </view>
</template>
<script setup>
-import { ref, computed, onMounted, onUnmounted } from 'vue';
-import { onShow } from '@dcloudio/uni-app';
-import PageHeader from '@/components/PageHeader.vue';
-import { getDeviceLedger } from '@/api/equipmentManagement/ledger';
-import { addRepair, editRepair, getRepairById } from '@/api/equipmentManagement/repair';
-import dayjs from "dayjs";
-import { formatDateToYMD } from '@/utils/ruoyi';
-const showToast = (message) => {
- uni.showToast({
- title: message,
- icon: 'none'
- })
-}
+ import { ref, computed, onMounted, onUnmounted } from "vue";
+ import { onShow } from "@dcloudio/uni-app";
+ import PageHeader from "@/components/PageHeader.vue";
+ import { getDeviceLedger } from "@/api/equipmentManagement/ledger";
+ import {
+ addRepair,
+ editRepair,
+ getRepairById,
+ } from "@/api/equipmentManagement/repair";
+ import dayjs from "dayjs";
+ import { formatDateToYMD } from "@/utils/ruoyi";
+ const showToast = message => {
+ uni.showToast({
+ title: message,
+ icon: "none",
+ });
+ };
-defineOptions({
- name: "璁惧鎶ヤ慨琛ㄥ崟",
-});
+ defineOptions({
+ name: "璁惧鎶ヤ慨琛ㄥ崟",
+ });
-// 琛ㄥ崟寮曠敤
-const formRef = ref(null);
-const operationType = ref('add');
-const loading = ref(false);
-const showDevice = ref(false);
-const showDate = ref(false);
-const pickerDateValue = ref(Date.now());
+ // 琛ㄥ崟寮曠敤
+ const formRef = ref(null);
+ const operationType = ref("add");
+ const loading = ref(false);
+ const showDevice = ref(false);
+ const showDate = ref(false);
+ const pickerDateValue = ref(Date.now());
-// 璁惧閫夐」
-const deviceOptions = ref([]);
-const deviceNameText = ref('');
-const deviceActionList = computed(() => {
- return deviceOptions.value.map(item => ({
- name: item.deviceName,
- value: item.id
- }));
-});
+ // 璁惧閫夐」
+ const deviceOptions = ref([]);
+ const deviceNameText = ref("");
+ const deviceActionList = computed(() => {
+ return deviceOptions.value.map(item => ({
+ name: item.deviceName,
+ value: item.id,
+ }));
+ });
-// 鎵爜鐩稿叧鐘舵��
-const isScanning = ref(false);
-const scanTimer = ref(null);
+ // 鎵爜鐩稿叧鐘舵��
+ const isScanning = ref(false);
+ const scanTimer = ref(null);
-// 琛ㄥ崟楠岃瘉瑙勫垯
-const formRules = {
- deviceLedgerId: [{ required: true, trigger: "change", message: "璇烽�夋嫨璁惧鍚嶇О" }],
- repairTime: [{ required: true, trigger: "change", message: "璇烽�夋嫨鎶ヤ慨鏃ユ湡" }],
- repairName: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ姤淇汉" }],
- remark: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ晠闅滅幇璞�" }],
-};
+ // 琛ㄥ崟楠岃瘉瑙勫垯
+ const formRules = {
+ deviceLedgerId: [
+ { required: true, trigger: "change", message: "璇烽�夋嫨璁惧鍚嶇О" },
+ ],
+ repairTime: [
+ { required: true, trigger: "change", message: "璇烽�夋嫨鎶ヤ慨鏃ユ湡" },
+ ],
+ repairName: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ姤淇汉" }],
+ remark: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ晠闅滅幇璞�" }],
+ };
-// 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
-const form = ref({
- deviceLedgerId: undefined, // 璁惧ID
- deviceModel: undefined, // 瑙勬牸鍨嬪彿
- repairTime: dayjs().format("YYYY-MM-DD"), // 鎶ヤ慨鏃ユ湡
- repairName: undefined, // 鎶ヤ慨浜�
- remark: undefined, // 鏁呴殰鐜拌薄
-});
+ // 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
+ const form = ref({
+ deviceLedgerId: undefined, // 璁惧ID
+ deviceModel: undefined, // 瑙勬牸鍨嬪彿
+ repairTime: dayjs().format("YYYY-MM-DD"), // 鎶ヤ慨鏃ユ湡
+ repairName: undefined, // 鎶ヤ慨浜�
+ remark: undefined, // 鏁呴殰鐜拌薄
+ });
-// 鍔犺浇璁惧鍒楄〃
-const loadDeviceName = async () => {
- try {
- const { data } = await getDeviceLedger();
- deviceOptions.value = data || [];
- } catch (e) {
- showToast('鑾峰彇璁惧鍒楄〃澶辫触');
- }
-};
+ // 鎶ヤ慨鐘舵�侀�夐」
+ const repairStatusOptions = ref([
+ { name: "寰呯淮淇�", value: "0" },
+ { name: "瀹岀粨", value: "1" },
+ { name: "澶辫触", value: "2" },
+ ]);
+ const repairStatusText = ref("");
-// 璁剧疆璁惧瑙勬牸鍨嬪彿
-const setDeviceModel = (id) => {
- const option = deviceOptions.value.find((item) => item.id === id);
- if (option) {
- form.value.deviceModel = option.deviceModel;
- deviceNameText.value = option.deviceName;
- }
-};
+ // 鎵撳紑鎶ヤ慨鐘舵�侀�夋嫨鍣�
+ const openRepairStatusPicker = () => {
+ uni.showActionSheet({
+ itemList: repairStatusOptions.value.map(item => item.name),
+ success: res => {
+ form.value.status = repairStatusOptions.value[res.tapIndex].value;
+ repairStatusText.value = repairStatusOptions.value[res.tapIndex].name;
+ },
+ });
+ };
-// 鍔犺浇琛ㄥ崟鏁版嵁锛堢紪杈戞ā寮忥級
-const loadForm = async (id) => {
- if (id) {
- operationType.value = 'edit';
- try {
- const { code, data } = await getRepairById(id);
- if (code == 200) {
- form.value.deviceLedgerId = data.deviceLedgerId;
- form.value.deviceModel = data.deviceModel;
- form.value.repairTime = dayjs(data.repairTime).format("YYYY-MM-DD");
- form.value.repairName = data.repairName;
- form.value.remark = data.remark;
- // 璁剧疆璁惧鍚嶇О鏄剧ず
- const device = deviceOptions.value.find(item => item.id === data.deviceLedgerId);
- if (device) {
- deviceNameText.value = device.deviceName;
- }
- }
- } catch (e) {
- showToast('鑾峰彇璇︽儏澶辫触');
- }
- } else {
- // 鏂板妯″紡
- operationType.value = 'add';
- }
-};
+ // 鍔犺浇璁惧鍒楄〃
+ const loadDeviceName = async () => {
+ try {
+ const { data } = await getDeviceLedger();
+ deviceOptions.value = data || [];
+ } catch (e) {
+ showToast("鑾峰彇璁惧鍒楄〃澶辫触");
+ }
+ };
-// 鎵弿浜岀淮鐮佸姛鑳�
-const startScan = () => {
- if (isScanning.value) {
- showToast('姝e湪鎵弿涓紝璇风◢鍊�...');
- return;
- }
-
- // 璋冪敤uni-app鐨勬壂鐮丄PI
- uni.scanCode({
- scanType: ['qrCode', 'barCode'],
- success: (res) => {
- handleScanResult(res.result);
- },
- fail: (err) => {
- console.error('鎵爜澶辫触:', err);
- showToast('鎵爜澶辫触锛岃閲嶈瘯');
- }
- });
-};
+ // 璁剧疆璁惧瑙勬牸鍨嬪彿
+ const setDeviceModel = id => {
+ const option = deviceOptions.value.find(item => item.id === id);
+ if (option) {
+ form.value.deviceModel = option.deviceModel;
+ deviceNameText.value = option.deviceName;
+ }
+ };
-// 澶勭悊鎵爜缁撴灉
-const handleScanResult = (scanResult) => {
- if (!scanResult) {
- showToast('鎵爜缁撴灉涓虹┖');
- return;
- }
-
- isScanning.value = true;
- showToast('鎵爜鎴愬姛');
-
- // 3绉掑悗澶勭悊鎵爜缁撴灉
- scanTimer.value = setTimeout(() => {
- processScanResult(scanResult);
- isScanning.value = false;
- }, 100);
-};
-function getDeviceIdByRegExp(url) {
- // 鍖归厤deviceId=鍚庨潰鐨勬暟瀛�
- const reg = /deviceId=(\d+)/;
- const match = url.match(reg);
- // 濡傛灉鍖归厤鍒扮粨鏋滐紝杩斿洖鏁板瓧绫诲瀷锛屽惁鍒欒繑鍥瀗ull
- return match ? Number(match[1]) : null;
-}
+ // 鍔犺浇琛ㄥ崟鏁版嵁锛堢紪杈戞ā寮忥級
+ const loadForm = async id => {
+ if (id) {
+ operationType.value = "edit";
+ try {
+ const { code, data } = await getRepairById(id);
+ if (code == 200) {
+ form.value.deviceLedgerId = data.deviceLedgerId;
+ form.value.deviceModel = data.deviceModel;
+ form.value.repairTime = dayjs(data.repairTime).format("YYYY-MM-DD");
+ form.value.repairName = data.repairName;
+ form.value.remark = data.remark;
+ repairStatusText.value =
+ repairStatusOptions.value.find(item => item.value == data.status)
+ ?.name || "";
+ // 璁剧疆璁惧鍚嶇О鏄剧ず
+ const device = deviceOptions.value.find(
+ item => item.id === data.deviceLedgerId
+ );
+ if (device) {
+ deviceNameText.value = device.deviceName;
+ }
+ }
+ } catch (e) {
+ showToast("鑾峰彇璇︽儏澶辫触");
+ }
+ } else {
+ // 鏂板妯″紡
+ operationType.value = "add";
+ }
+ };
-// 澶勭悊鎵爜缁撴灉骞跺尮閰嶈澶�
-const processScanResult = (scanResult) => {
- const deviceId = getDeviceIdByRegExp(scanResult);
- const matchedDevice = deviceOptions.value.find(item => item.id == deviceId);
-
- if (matchedDevice) {
- // 鎵惧埌鍖归厤鐨勮澶囷紝鑷姩濉厖
- form.value.deviceLedgerId = matchedDevice.id;
- deviceNameText.value = matchedDevice.deviceName;
- form.value.deviceModel = matchedDevice.deviceModel;
- showToast('璁惧淇℃伅宸茶嚜鍔ㄥ~鍏�');
- } else {
- // 鏈壘鍒板尮閰嶇殑璁惧
- showToast('鏈壘鍒板尮閰嶇殑璁惧锛岃鎵嬪姩閫夋嫨');
- }
-};
+ // 鎵弿浜岀淮鐮佸姛鑳�
+ const startScan = () => {
+ if (isScanning.value) {
+ showToast("姝e湪鎵弿涓紝璇风◢鍊�...");
+ return;
+ }
-// 鏄剧ず璁惧閫夋嫨鍣�
-const showDevicePicker = () => {
- showDevice.value = true;
-};
+ // 璋冪敤uni-app鐨勬壂鐮丄PI
+ uni.scanCode({
+ scanType: ["qrCode", "barCode"],
+ success: res => {
+ handleScanResult(res.result);
+ },
+ fail: err => {
+ console.error("鎵爜澶辫触:", err);
+ showToast("鎵爜澶辫触锛岃閲嶈瘯");
+ },
+ });
+ };
-// 纭璁惧閫夋嫨
-const onDeviceSelect = (e) => {
- form.value.deviceLedgerId = e.value;
- setDeviceModel(e.value);
- showDevice.value = false;
-};
+ // 澶勭悊鎵爜缁撴灉
+ const handleScanResult = scanResult => {
+ if (!scanResult) {
+ showToast("鎵爜缁撴灉涓虹┖");
+ return;
+ }
-// 鏄剧ず鏃ユ湡閫夋嫨鍣�
-const showDatePicker = () => {
- showDate.value = true;
-};
+ isScanning.value = true;
+ showToast("鎵爜鎴愬姛");
-// 纭鏃ユ湡閫夋嫨
-const onDateConfirm = (e) => {
- form.value.repairTime = formatDateToYMD(e.value);
- pickerDateValue.value = dayjs(e.value).format("YYYY-MM-DD");
- showDate.value = false;
-};
+ // 3绉掑悗澶勭悊鎵爜缁撴灉
+ scanTimer.value = setTimeout(() => {
+ processScanResult(scanResult);
+ isScanning.value = false;
+ }, 100);
+ };
+ function getDeviceIdByRegExp(url) {
+ // 鍖归厤deviceId=鍚庨潰鐨勬暟瀛�
+ const reg = /deviceId=(\d+)/;
+ const match = url.match(reg);
+ // 濡傛灉鍖归厤鍒扮粨鏋滐紝杩斿洖鏁板瓧绫诲瀷锛屽惁鍒欒繑鍥瀗ull
+ return match ? Number(match[1]) : null;
+ }
-onShow(() => {
- // 椤甸潰鏄剧ず鏃惰幏鍙栧弬鏁�
- getPageParams();
-});
+ // 澶勭悊鎵爜缁撴灉骞跺尮閰嶈澶�
+ const processScanResult = scanResult => {
+ const deviceId = getDeviceIdByRegExp(scanResult);
+ const matchedDevice = deviceOptions.value.find(item => item.id == deviceId);
-onMounted(() => {
- // 椤甸潰鍔犺浇鏃惰幏鍙栬澶囧垪琛ㄥ拰鍙傛暟
- loadDeviceName();
- getPageParams();
-});
+ if (matchedDevice) {
+ // 鎵惧埌鍖归厤鐨勮澶囷紝鑷姩濉厖
+ form.value.deviceLedgerId = matchedDevice.id;
+ deviceNameText.value = matchedDevice.deviceName;
+ form.value.deviceModel = matchedDevice.deviceModel;
+ showToast("璁惧淇℃伅宸茶嚜鍔ㄥ~鍏�");
+ } else {
+ // 鏈壘鍒板尮閰嶇殑璁惧
+ showToast("鏈壘鍒板尮閰嶇殑璁惧锛岃鎵嬪姩閫夋嫨");
+ }
+ };
-// 缁勪欢鍗歌浇鏃舵竻鐞嗗畾鏃跺櫒
-onUnmounted(() => {
- if (scanTimer.value) {
- clearTimeout(scanTimer.value);
- }
-});
+ // 鏄剧ず璁惧閫夋嫨鍣�
+ const showDevicePicker = () => {
+ showDevice.value = true;
+ };
-// 鎻愪氦琛ㄥ崟
-const sendForm = async () => {
- try {
- // 鎵嬪姩楠岃瘉琛ㄥ崟
- let isValid = true;
- let errorMessage = '';
- if (!form.value.deviceLedgerId) {
- isValid = false;
- errorMessage = '璇烽�夋嫨璁惧鍚嶇О';
- } else if (!form.value.repairTime || form.value.repairTime.trim() === '') {
- isValid = false;
- errorMessage = '璇烽�夋嫨鎶ヤ慨鏃ユ湡';
- } else if (!form.value.repairName || form.value.repairName.trim() === '') {
- isValid = false;
- errorMessage = '璇疯緭鍏ユ姤淇汉';
- } else if (!form.value.remark || form.value.remark.trim() === '') {
- isValid = false;
- errorMessage = '璇疯緭鍏ユ晠闅滅幇璞�';
- }
+ // 纭璁惧閫夋嫨
+ const onDeviceSelect = e => {
+ form.value.deviceLedgerId = e.value;
+ setDeviceModel(e.value);
+ showDevice.value = false;
+ };
- if (!isValid) {
- showToast(errorMessage);
- return;
- }
+ // 鏄剧ず鏃ユ湡閫夋嫨鍣�
+ const showDatePicker = () => {
+ showDate.value = true;
+ };
- loading.value = true;
- const id = getPageId();
+ // 纭鏃ユ湡閫夋嫨
+ const onDateConfirm = e => {
+ form.value.repairTime = formatDateToYMD(e.value);
+ pickerDateValue.value = dayjs(e.value).format("YYYY-MM-DD");
+ showDate.value = false;
+ };
- // 鍑嗗鎻愪氦鏁版嵁
- const submitData = { ...form.value };
+ onShow(() => {
+ // 椤甸潰鏄剧ず鏃惰幏鍙栧弬鏁�
+ getPageParams();
+ });
- const { code } = id
- ? await editRepair({ id: id, ...submitData })
- : await addRepair(submitData);
+ onMounted(() => {
+ // 椤甸潰鍔犺浇鏃惰幏鍙栬澶囧垪琛ㄥ拰鍙傛暟
+ loadDeviceName();
+ getPageParams();
+ });
- if (code == 200) {
- showToast(`${id ? "缂栬緫" : "鏂板"}鎶ヤ慨鎴愬姛`);
- setTimeout(() => {
- uni.navigateBack();
- }, 1500);
- } else {
- loading.value = false;
- }
- } catch (e) {
- loading.value = false;
- showToast('琛ㄥ崟楠岃瘉澶辫触');
- }
-};
+ // 缁勪欢鍗歌浇鏃舵竻鐞嗗畾鏃跺櫒
+ onUnmounted(() => {
+ if (scanTimer.value) {
+ clearTimeout(scanTimer.value);
+ }
+ });
-// 杩斿洖涓婁竴椤�
-const goBack = () => {
- uni.removeStorageSync('repairId');
- uni.navigateBack();
-};
+ // 鎻愪氦琛ㄥ崟
+ const sendForm = async () => {
+ try {
+ // 鎵嬪姩楠岃瘉琛ㄥ崟
+ let isValid = true;
+ let errorMessage = "";
+ if (!form.value.deviceLedgerId) {
+ isValid = false;
+ errorMessage = "璇烽�夋嫨璁惧鍚嶇О";
+ } else if (!form.value.repairTime || form.value.repairTime.trim() === "") {
+ isValid = false;
+ errorMessage = "璇烽�夋嫨鎶ヤ慨鏃ユ湡";
+ } else if (!form.value.repairName || form.value.repairName.trim() === "") {
+ isValid = false;
+ errorMessage = "璇疯緭鍏ユ姤淇汉";
+ } else if (!form.value.remark || form.value.remark.trim() === "") {
+ isValid = false;
+ errorMessage = "璇疯緭鍏ユ晠闅滅幇璞�";
+ }
-// 鑾峰彇椤甸潰鍙傛暟
-const getPageParams = () => {
- // 浣跨敤uni.getStorageSync鑾峰彇id
- const id = uni.getStorageSync('repairId');
-
- // 鏍规嵁鏄惁鏈塱d鍙傛暟鏉ュ垽鏂槸鏂板杩樻槸缂栬緫
- if (id) {
- // 缂栬緫妯″紡锛岃幏鍙栬鎯�
- loadForm(id);
- // 鍙�夛細鑾峰彇鍚庢竻闄ゅ瓨鍌ㄧ殑id锛岄伩鍏嶅奖鍝嶅悗缁搷浣�
- uni.removeStorageSync('repairId');
- } else {
- // 鏂板妯″紡
- loadForm();
- }
-};
+ if (!isValid) {
+ showToast(errorMessage);
+ return;
+ }
-// 鑾峰彇椤甸潰ID
-const getPageId = () => {
- // 浣跨敤uni.getStorageSync鑾峰彇id
- const id = uni.getStorageSync('repairId');
- return id;
-};
+ loading.value = true;
+ const id = getPageId();
+
+ // 鍑嗗鎻愪氦鏁版嵁
+ const submitData = { ...form.value };
+
+ const { code } = id
+ ? await editRepair({ id: id, ...submitData })
+ : await addRepair(submitData);
+
+ if (code == 200) {
+ showToast(`${id ? "缂栬緫" : "鏂板"}鎶ヤ慨鎴愬姛`);
+ setTimeout(() => {
+ uni.navigateBack();
+ }, 1500);
+ } else {
+ loading.value = false;
+ }
+ } catch (e) {
+ loading.value = false;
+ showToast("琛ㄥ崟楠岃瘉澶辫触");
+ }
+ };
+
+ // 杩斿洖涓婁竴椤�
+ const goBack = () => {
+ uni.removeStorageSync("repairId");
+ uni.navigateBack();
+ };
+
+ // 鑾峰彇椤甸潰鍙傛暟
+ const getPageParams = () => {
+ // 浣跨敤uni.getStorageSync鑾峰彇id
+ const id = uni.getStorageSync("repairId");
+
+ // 鏍规嵁鏄惁鏈塱d鍙傛暟鏉ュ垽鏂槸鏂板杩樻槸缂栬緫
+ if (id) {
+ // 缂栬緫妯″紡锛岃幏鍙栬鎯�
+ loadForm(id);
+ // 鍙�夛細鑾峰彇鍚庢竻闄ゅ瓨鍌ㄧ殑id锛岄伩鍏嶅奖鍝嶅悗缁搷浣�
+ uni.removeStorageSync("repairId");
+ } else {
+ // 鏂板妯″紡
+ loadForm();
+ }
+ };
+
+ // 鑾峰彇椤甸潰ID
+ const getPageId = () => {
+ // 浣跨敤uni.getStorageSync鑾峰彇id
+ const id = uni.getStorageSync("repairId");
+ return id;
+ };
</script>
<style scoped lang="scss">
-@import '@/static/scss/form-common.scss';
-.repair-add {
- min-height: 100vh;
- background: #f8f9fa;
- padding-bottom: 5rem;
-}
+ @import "@/static/scss/form-common.scss";
+ .repair-add {
+ min-height: 100vh;
+ background: #f8f9fa;
+ padding-bottom: 5rem;
+ }
-.footer-btns {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- background: #fff;
- display: flex;
- justify-content: space-around;
- align-items: center;
- padding: 0.75rem 0;
- box-shadow: 0 -0.125rem 0.5rem rgba(0,0,0,0.05);
- z-index: 1000;
-}
+ .footer-btns {
+ position: fixed;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: #fff;
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ padding: 0.75rem 0;
+ box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
+ z-index: 1000;
+ }
-.cancel-btn {
- font-weight: 400;
- font-size: 1rem;
- color: #FFFFFF;
- width: 6.375rem;
- background: #C7C9CC;
- box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2);
- border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
-}
+ .cancel-btn {
+ font-weight: 400;
+ font-size: 1rem;
+ color: #ffffff;
+ width: 6.375rem;
+ background: #c7c9cc;
+ box-shadow: 0 0.25rem 0.625rem 0 rgba(3, 88, 185, 0.2);
+ border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+ }
-.save-btn {
- font-weight: 400;
- font-size: 1rem;
- color: #FFFFFF;
- width: 14rem;
- background: linear-gradient( 140deg, #00BAFF 0%, #006CFB 100%);
- box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2);
- border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
-}
+ .save-btn {
+ font-weight: 400;
+ font-size: 1rem;
+ color: #ffffff;
+ width: 14rem;
+ background: linear-gradient(140deg, #00baff 0%, #006cfb 100%);
+ box-shadow: 0 0.25rem 0.625rem 0 rgba(3, 88, 185, 0.2);
+ border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+ }
-// 鍝嶅簲寮忚皟鏁�
-@media (max-width: 768px) {
- .submit-section {
- padding: 12px;
- }
-}
+ // 鍝嶅簲寮忚皟鏁�
+ @media (max-width: 768px) {
+ .submit-section {
+ padding: 12px;
+ }
+ }
-.tip-text {
- padding: 4px 16px 0 16px;
- font-size: 12px;
- color: #888;
-}
+ .tip-text {
+ padding: 4px 16px 0 16px;
+ font-size: 12px;
+ color: #888;
+ }
-.scan-icon {
- color: #1989fa;
- font-size: 18px;
- margin-left: 8px;
- cursor: pointer;
-}
+ .scan-icon {
+ color: #1989fa;
+ font-size: 18px;
+ margin-left: 8px;
+ cursor: pointer;
+ }
</style>
\ No newline at end of file
diff --git a/src/pages/equipmentManagement/repair/maintain.vue b/src/pages/equipmentManagement/repair/maintain.vue
index aa8a8e3..46b45aa 100644
--- a/src/pages/equipmentManagement/repair/maintain.vue
+++ b/src/pages/equipmentManagement/repair/maintain.vue
@@ -1,256 +1,297 @@
<template>
- <view class="repair-maintain">
- <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
- <PageHeader title="鏂板缁翠慨" @back="goBack" />
-
- <!-- 琛ㄥ崟鍐呭 -->
- <u-form ref="formRef" :model="form" :rules="formRules" label-width="140rpx">
- <!-- 鍩烘湰淇℃伅 -->
- <u-cell-group title="缁翠慨淇℃伅" inset>
- <u-form-item prop="maintenanceName" label="缁翠慨浜�" required>
- <u-input
- v-model="form.maintenanceName"
- placeholder="璇疯緭鍏ョ淮淇汉"
- clearable
- />
- </u-form-item>
- <u-form-item prop="maintenanceResult" label="缁翠慨缁撴灉" required>
- <u-input
- v-model="form.maintenanceResult"
- type="textarea"
- rows="3"
- placeholder="璇疯緭鍏ョ淮淇粨鏋�"
- clearable
- maxlength="200"
- show-word-limit
- />
- </u-form-item>
- <u-form-item label="缁翠慨鏃ユ湡" prop="maintenanceTime" required border-bottom>
- <u-input
- v-model="form.maintenanceTime"
- placeholder="璇烽�夋嫨缁翠慨鏃ユ湡"
- readonly
- @click="showDatePicker = true"
- clearable
- />
- <template #right>
- <u-icon name="arrow-right" @click="showDatePicker = true"></u-icon>
- </template>
- </u-form-item>
- </u-cell-group>
-
- <!-- 鎻愪氦鎸夐挳 -->
- <view class="footer-btns">
- <u-button class="cancel-btn" @click="goBack">鍙栨秷</u-button>
- <u-button class="save-btn" @click="submitForm" :loading="loading">淇濆瓨</u-button>
- </view>
- </u-form>
-
- <!-- 鏃ユ湡閫夋嫨鍣� -->
- <up-datetime-picker
- :show="showDatePicker"
- v-model="pickerDateValue"
- mode="datetime"
- title="閫夋嫨鏃ユ湡"
- format="YYYY-MM-DD HH:mm:ss"
- @confirm="onDateConfirm"
- @cancel="showDatePicker = false"
- />
- </view>
+ <view class="repair-maintain">
+ <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
+ <PageHeader title="鏂板缁翠慨"
+ @back="goBack" />
+ <!-- 琛ㄥ崟鍐呭 -->
+ <u-form ref="formRef"
+ :model="form"
+ :rules="formRules"
+ label-width="140rpx">
+ <!-- 鍩烘湰淇℃伅 -->
+ <u-cell-group title="缁翠慨淇℃伅"
+ inset>
+ <u-form-item prop="maintenanceName"
+ label="缁翠慨浜�"
+ required>
+ <u-input v-model="form.maintenanceName"
+ placeholder="璇疯緭鍏ョ淮淇汉"
+ clearable />
+ </u-form-item>
+ <u-form-item prop="maintenanceResult"
+ label="缁翠慨缁撴灉"
+ required>
+ <u-input v-model="form.maintenanceResult"
+ type="textarea"
+ rows="3"
+ placeholder="璇疯緭鍏ョ淮淇粨鏋�"
+ clearable
+ maxlength="200"
+ show-word-limit />
+ </u-form-item>
+ <u-form-item label="缁翠慨鐘舵��"
+ prop="repairTime"
+ required
+ border-bottom>
+ <u-input v-model="repairStatusText"
+ placeholder="璇烽�夋嫨缁翠慨鐘舵��"
+ readonly
+ @click="openRepairStatusPicker"
+ clearable />
+ <template #right>
+ <u-icon name="arrow-right"
+ @click="openRepairStatusPicker"></u-icon>
+ </template>
+ </u-form-item>
+ <u-form-item label="缁翠慨鏃ユ湡"
+ prop="maintenanceTime"
+ required
+ border-bottom>
+ <u-input v-model="form.maintenanceTime"
+ placeholder="璇烽�夋嫨缁翠慨鏃ユ湡"
+ readonly
+ @click="showDatePicker = true"
+ clearable />
+ <template #right>
+ <u-icon name="arrow-right"
+ @click="showDatePicker = true"></u-icon>
+ </template>
+ </u-form-item>
+ </u-cell-group>
+ <!-- 鎻愪氦鎸夐挳 -->
+ <view class="footer-btns">
+ <u-button class="cancel-btn"
+ @click="goBack">鍙栨秷</u-button>
+ <u-button class="save-btn"
+ @click="submitForm"
+ :loading="loading">淇濆瓨</u-button>
+ </view>
+ </u-form>
+ <!-- 鏃ユ湡閫夋嫨鍣� -->
+ <up-datetime-picker :show="showDatePicker"
+ v-model="pickerDateValue"
+ mode="datetime"
+ title="閫夋嫨鏃ユ湡"
+ format="YYYY-MM-DD HH:mm:ss"
+ @confirm="onDateConfirm"
+ @cancel="showDatePicker = false" />
+ </view>
</template>
<script setup>
-import { ref, onMounted } from 'vue';
-import { onShow } from '@dcloudio/uni-app';
-import PageHeader from '@/components/PageHeader.vue';
-import { addMaintain } from '@/api/equipmentManagement/repair';
-import useUserStore from "@/store/modules/user";
-import dayjs from "dayjs";
+ import { ref, onMounted } from "vue";
+ import { onShow } from "@dcloudio/uni-app";
+ import PageHeader from "@/components/PageHeader.vue";
+ import { addMaintain } from "@/api/equipmentManagement/repair";
+ import useUserStore from "@/store/modules/user";
+ import dayjs from "dayjs";
-defineOptions({
- name: "璁惧缁翠慨琛ㄥ崟",
-});
+ defineOptions({
+ name: "璁惧缁翠慨琛ㄥ崟",
+ });
-const userStore = useUserStore();
+ const userStore = useUserStore();
-// 琛ㄥ崟寮曠敤
-const formRef = ref(null);
-const loading = ref(false);
-const showDatePicker = ref(false);
-const pickerDateValue = ref(Date.now());; // 浣跨敤鏃堕棿鎴�
+ // 琛ㄥ崟寮曠敤
+ const formRef = ref(null);
+ const loading = ref(false);
+ const showDatePicker = ref(false);
+ const pickerDateValue = ref(Date.now()); // 浣跨敤鏃堕棿鎴�
-// 琛ㄥ崟楠岃瘉瑙勫垯
-const formRules = {
- maintenanceName: [{ required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇汉" }],
- maintenanceResult: [{ required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇粨鏋�" }],
- maintenanceTime: [{ required: true, trigger: "change", message: "璇烽�夋嫨缁翠慨鏃ユ湡" }],
-};
+ // 琛ㄥ崟楠岃瘉瑙勫垯
+ const formRules = {
+ maintenanceName: [
+ { required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇汉" },
+ ],
+ maintenanceResult: [
+ { required: true, trigger: "blur", message: "璇疯緭鍏ョ淮淇粨鏋�" },
+ ],
+ maintenanceTime: [
+ { required: true, trigger: "change", message: "璇烽�夋嫨缁翠慨鏃ユ湡" },
+ ],
+ };
+ const repairStatusOptions = ref([
+ { name: "寰呯淮淇�", value: "0" },
+ { name: "瀹岀粨", value: "1" },
+ { name: "澶辫触", value: "2" },
+ ]);
+ const repairStatusText = ref("瀹岀粨");
+ // 鎵撳紑鎶ヤ慨鐘舵�侀�夋嫨鍣�
+ const openRepairStatusPicker = () => {
+ uni.showActionSheet({
+ itemList: repairStatusOptions.value.map(item => item.name),
+ success: res => {
+ form.value.status = repairStatusOptions.value[res.tapIndex].value;
+ repairStatusText.value = repairStatusOptions.value[res.tapIndex].name;
+ },
+ });
+ };
+ // 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
+ const form = ref({
+ maintenanceName: userStore.nickName || "", // 榛樿浣跨敤褰撳墠鐢ㄦ埛鏄电О
+ maintenanceResult: undefined, // 缁翠慨缁撴灉
+ maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛�
+ });
-// 浣跨敤 ref 澹版槑琛ㄥ崟鏁版嵁
-const form = ref({
- maintenanceName: userStore.nickName || '', // 榛樿浣跨敤褰撳墠鐢ㄦ埛鏄电О
- maintenanceResult: undefined, // 缁翠慨缁撴灉
- maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 缁翠慨鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛�
-});
+ // 鑷畾涔塻howToast鍑芥暟
+ const showToast = message => {
+ uni.showToast({
+ title: message,
+ icon: "none",
+ });
+ };
-// 鑷畾涔塻howToast鍑芥暟
-const showToast = (message) => {
- uni.showToast({
- title: message,
- icon: 'none'
- })
-};
+ // 閲嶇疆琛ㄥ崟鏁版嵁鍜屾牎楠岀姸鎬�
+ const resetForm = () => {
+ form.value = {
+ maintenanceName: userStore.nickName || "",
+ maintenanceResult: undefined,
+ maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
+ };
+ };
-// 閲嶇疆琛ㄥ崟鏁版嵁鍜屾牎楠岀姸鎬�
-const resetForm = () => {
- form.value = {
- maintenanceName: userStore.nickName || '',
- maintenanceResult: undefined,
- maintenanceTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
- };
-};
+ const resetFormAndValidate = () => {
+ resetForm();
+ };
-const resetFormAndValidate = () => {
- resetForm();
-};
+ // 鎻愪氦琛ㄥ崟
+ const submitForm = async () => {
+ try {
+ // 浣跨敤uview-plus鐨勮〃鍗曢獙璇佹柟寮�
+ const valid = await formRef.value.validate();
+ if (valid) {
+ submitFormData();
+ }
+ } catch (e) {
+ showToast("琛ㄥ崟楠岃瘉澶辫触");
+ }
+ };
-// 鎻愪氦琛ㄥ崟
-const submitForm = async () => {
- try {
- // 浣跨敤uview-plus鐨勮〃鍗曢獙璇佹柟寮�
- const valid = await formRef.value.validate();
- if (valid) {
- submitFormData();
- }
- } catch (e) {
- showToast('琛ㄥ崟楠岃瘉澶辫触');
- }
-};
+ // 鎻愪氦琛ㄥ崟鏁版嵁
+ const submitFormData = async () => {
+ try {
+ loading.value = true;
+ const id = getPageId();
-// 鎻愪氦琛ㄥ崟鏁版嵁
-const submitFormData = async () => {
- try {
- loading.value = true;
- const id = getPageId();
-
- if (!id) {
- showToast('鍙傛暟閿欒');
- loading.value = false;
- return;
- }
-
- // 鍑嗗鎻愪氦鏁版嵁锛宮aintenanceTime 鍔犱笂褰撳墠鏃跺垎绉�
- const submitData = { ...form.value };
-
- const { code } = await addMaintain({ id: id, ...submitData });
-
- if (code == 200) {
- showToast('鏂板缁翠慨鎴愬姛');
- resetFormAndValidate();
- setTimeout(() => {
- goBack();
- }, 500);
- } else {
- loading.value = false;
- }
- } catch (e) {
- console.log(e);
-
- loading.value = false;
- showToast('鎿嶄綔澶辫触');
- }
-};
+ if (!id) {
+ showToast("鍙傛暟閿欒");
+ loading.value = false;
+ return;
+ }
+ form.value.status = Number(form.value.status);
+ // 鍑嗗鎻愪氦鏁版嵁锛宮aintenanceTime 鍔犱笂褰撳墠鏃跺垎绉�
+ const submitData = { ...form.value };
-// 杩斿洖涓婁竴椤�
-const goBack = () => {
- uni.removeStorageSync('repairId');
- uni.navigateBack();
-};
+ const { code } = await addMaintain({ id: id, ...submitData });
-// 鑾峰彇椤甸潰ID
-const getPageId = () => {
- const id = uni.getStorageSync('repairId');
- return id;
-};
+ if (code == 200) {
+ showToast("鏂板缁翠慨鎴愬姛");
+ resetFormAndValidate();
+ setTimeout(() => {
+ goBack();
+ }, 500);
+ } else {
+ loading.value = false;
+ }
+ } catch (e) {
+ console.log(e);
-// 纭鏃ユ湡閫夋嫨
-const onDateConfirm = (e) => {
- form.value.maintenanceTime = dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
- pickerDateValue.value = e.value
- showDatePicker.value = false;
-};
+ loading.value = false;
+ showToast("鎿嶄綔澶辫触");
+ }
+ };
-// 鍒濆鍖栬〃鍗曟暟鎹�
-const initForm = () => {
- // 璁剧疆缁翠慨浜轰负褰撳墠鐢ㄦ埛鏄电О
- form.value.maintenanceName = userStore.nickName || '';
- // 璁剧疆褰撳墠鏃ユ湡锛堝彧鍖呭惈骞存湀鏃ワ級
- form.value.maintenanceTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
-};
+ // 杩斿洖涓婁竴椤�
+ const goBack = () => {
+ uni.removeStorageSync("repairId");
+ uni.navigateBack();
+ };
-onShow(() => {
- // 椤甸潰鏄剧ず鏃跺垵濮嬪寲琛ㄥ崟
- initForm();
-});
+ // 鑾峰彇椤甸潰ID
+ const getPageId = () => {
+ const id = uni.getStorageSync("repairId");
+ return id;
+ };
-onMounted(() => {
- // 椤甸潰鍔犺浇鏃跺垵濮嬪寲琛ㄥ崟
- initForm();
-});
+ // 纭鏃ユ湡閫夋嫨
+ const onDateConfirm = e => {
+ form.value.maintenanceTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss");
+ pickerDateValue.value = e.value;
+ showDatePicker.value = false;
+ };
+
+ // 鍒濆鍖栬〃鍗曟暟鎹�
+ const initForm = () => {
+ form.value.status = "1";
+ // 璁剧疆缁翠慨浜轰负褰撳墠鐢ㄦ埛鏄电О
+ form.value.maintenanceName = userStore.nickName || "";
+ // 璁剧疆褰撳墠鏃ユ湡锛堝彧鍖呭惈骞存湀鏃ワ級
+ form.value.maintenanceTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
+ };
+
+ onShow(() => {
+ // 椤甸潰鏄剧ず鏃跺垵濮嬪寲琛ㄥ崟
+ initForm();
+ });
+
+ onMounted(() => {
+ // 椤甸潰鍔犺浇鏃跺垵濮嬪寲琛ㄥ崟
+ initForm();
+ });
</script>
<style scoped lang="scss">
-@import '@/static/scss/form-common.scss';
-.repair-maintain {
- min-height: 100vh;
- background: #f8f9fa;
- padding-bottom: 5rem;
-}
+ @import "@/static/scss/form-common.scss";
+ .repair-maintain {
+ min-height: 100vh;
+ background: #f8f9fa;
+ padding-bottom: 5rem;
+ }
-.footer-btns {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- background: #fff;
- display: flex;
- justify-content: space-around;
- align-items: center;
- padding: 0.75rem 0;
- box-shadow: 0 -0.125rem 0.5rem rgba(0,0,0,0.05);
- z-index: 1000;
-}
+ .footer-btns {
+ position: fixed;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: #fff;
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ padding: 0.75rem 0;
+ box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
+ z-index: 1000;
+ }
-.cancel-btn {
- font-weight: 400;
- font-size: 1rem;
- color: #FFFFFF;
- width: 6.375rem;
- background: #C7C9CC;
- box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2);
- border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
-}
+ .cancel-btn {
+ font-weight: 400;
+ font-size: 1rem;
+ color: #ffffff;
+ width: 6.375rem;
+ background: #c7c9cc;
+ box-shadow: 0 0.25rem 0.625rem 0 rgba(3, 88, 185, 0.2);
+ border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+ }
-.save-btn {
- font-weight: 400;
- font-size: 1rem;
- color: #FFFFFF;
- width: 14rem;
- background: linear-gradient( 140deg, #00BAFF 0%, #006CFB 100%);
- box-shadow: 0 0.25rem 0.625rem 0 rgba(3,88,185,0.2);
- border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
-}
+ .save-btn {
+ font-weight: 400;
+ font-size: 1rem;
+ color: #ffffff;
+ width: 14rem;
+ background: linear-gradient(140deg, #00baff 0%, #006cfb 100%);
+ box-shadow: 0 0.25rem 0.625rem 0 rgba(3, 88, 185, 0.2);
+ border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
+ }
-// 鍝嶅簲寮忚皟鏁�
-@media (max-width: 768px) {
- .submit-section {
- padding: 12px;
- }
-}
+ // 鍝嶅簲寮忚皟鏁�
+ @media (max-width: 768px) {
+ .submit-section {
+ padding: 12px;
+ }
+ }
-.tip-text {
- padding: 4px 16px 0 16px;
- font-size: 12px;
- color: #888;
-}
+ .tip-text {
+ padding: 4px 16px 0 16px;
+ font-size: 12px;
+ color: #888;
+ }
</style>
\ No newline at end of file
diff --git a/src/pages/procurementManagement/receiptPaymentHistory/index.vue b/src/pages/procurementManagement/receiptPaymentHistory/index.vue
index 340f3b2..cf59117 100644
--- a/src/pages/procurementManagement/receiptPaymentHistory/index.vue
+++ b/src/pages/procurementManagement/receiptPaymentHistory/index.vue
@@ -1,79 +1,86 @@
<template>
- <view class="sales-account">
- <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
- <PageHeader title="浠樻娴佹按" @back="goBack" />
-
- <!-- 鎼滅储鍖哄煙 -->
- <view class="search-section">
- <view class="search-bar">
- <view class="search-input">
- <up-input
- class="search-text"
- placeholder="璇疯緭鍏ヤ緵搴斿晢鍚嶇О"
- v-model="searchForm.searchText"
- @change="getList"
- clearable
- />
- </view>
- <view class="search-button" @click="getList">
- <up-icon name="search" size="24" color="#999"></up-icon>
- </view>
- </view>
- </view>
- <!-- 缁熻淇℃伅 -->
- <view class="summary-info" v-if="tableData.length > 0">
- <view class="summary-item">
- <text class="summary-label">鎬昏褰曟暟</text>
- <text class="summary-value">{{ tableData.length }}</text>
- </view>
- <view class="summary-item">
- <text class="summary-label">鎬婚噾棰�</text>
- <text class="summary-value highlight">{{ formatAmount(totalAmount) }}</text>
- </view>
- </view>
- <!-- 浠樻鍘嗗彶鍒楄〃 -->
- <view class="history-list" v-if="tableData.length > 0">
- <view v-for="(item, index) in tableData" :key="index">
- <view class="history-item">
- <view class="item-header">
- <view class="item-left">
- <view class="document-icon">
- <up-icon name="file-text" size="16" color="#ffffff"></up-icon>
- </view>
- <text class="item-id">{{ item.purchaseContractNumber }}</text>
- </view>
- <view class="item-tag" :class="getTagClass(item.paymentMethod)">
- <text class="tag-text">{{ item.paymentMethod }}</text>
- </view>
- </view>
- <up-divider></up-divider>
- <view class="item-details">
- <view class="detail-row">
- <text class="detail-label">渚涘簲鍟嗗悕绉�</text>
- <text class="detail-value">{{ item.supplierName }}</text>
- </view>
- <view class="detail-row">
- <text class="detail-label">浠樻閲戦(鍏�)</text>
- <text class="detail-value highlight">{{ formatAmount(item.currentPaymentAmount) }}</text>
- </view>
- <view class="detail-row">
- <text class="detail-label">浠樻鏃ユ湡</text>
- <text class="detail-value">{{ item.paymentDate }}</text>
- </view>
- <up-divider></up-divider>
- <view class="detail-info">
- <view class="detail-row">
- <text class="detail-label">鐧昏浜�</text>
- <text class="detail-value">{{ item.registrant }}</text>
- </view>
- <view class="detail-row">
- <text class="detail-label">鐧昏鏃ユ湡</text>
- <text class="detail-value">{{ item.registrationtDate }}</text>
- </view>
- </view>
- <!-- 鎿嶄綔鎸夐挳 -->
- <view class="action-buttons">
- <u-button
+ <view class="sales-account">
+ <!-- 浣跨敤閫氱敤椤甸潰澶撮儴缁勪欢 -->
+ <PageHeader title="浠樻娴佹按"
+ @back="goBack" />
+ <!-- 鎼滅储鍖哄煙 -->
+ <view class="search-section">
+ <view class="search-bar">
+ <view class="search-input">
+ <up-input class="search-text"
+ placeholder="璇疯緭鍏ヤ緵搴斿晢鍚嶇О"
+ v-model="searchForm.searchText"
+ @change="getList"
+ clearable />
+ </view>
+ <view class="search-button"
+ @click="getList">
+ <up-icon name="search"
+ size="24"
+ color="#999"></up-icon>
+ </view>
+ </view>
+ </view>
+ <!-- 缁熻淇℃伅 -->
+ <view class="summary-info"
+ v-if="tableData.length > 0">
+ <view class="summary-item">
+ <text class="summary-label">鎬昏褰曟暟</text>
+ <text class="summary-value">{{ tableData.length }}</text>
+ </view>
+ <view class="summary-item">
+ <text class="summary-label">鎬婚噾棰�</text>
+ <text class="summary-value highlight">{{ formatAmount(totalAmount) }}</text>
+ </view>
+ </view>
+ <!-- 浠樻鍘嗗彶鍒楄〃 -->
+ <view class="history-list"
+ v-if="tableData.length > 0">
+ <view v-for="(item, index) in tableData"
+ :key="index">
+ <view class="history-item">
+ <view class="item-header">
+ <view class="item-left">
+ <view class="document-icon">
+ <up-icon name="file-text"
+ size="16"
+ color="#ffffff"></up-icon>
+ </view>
+ <text class="item-id">{{ item.purchaseContractNumber }}</text>
+ </view>
+ <view class="item-tag"
+ :class="getTagClass(item.paymentMethod)">
+ <text class="tag-text">{{ item.paymentMethod }}</text>
+ </view>
+ </view>
+ <up-divider></up-divider>
+ <view class="item-details">
+ <view class="detail-row">
+ <text class="detail-label">渚涘簲鍟嗗悕绉�</text>
+ <text class="detail-value">{{ item.supplierName }}</text>
+ </view>
+ <view class="detail-row">
+ <text class="detail-label">浠樻閲戦(鍏�)</text>
+ <text class="detail-value highlight">{{ formatAmount(item.currentPaymentAmount) }}</text>
+ </view>
+ <view class="detail-row">
+ <text class="detail-label">浠樻鏃ユ湡</text>
+ <text class="detail-value">{{ item.paymentDate }}</text>
+ </view>
+ <up-divider></up-divider>
+ <view class="detail-info">
+ <view class="detail-row">
+ <text class="detail-label">鐧昏浜�</text>
+ <text class="detail-value">{{ item.registrant }}</text>
+ </view>
+ <view class="detail-row">
+ <text class="detail-label">鐧昏鏃ユ湡</text>
+ <text class="detail-value">{{ item.registrationtDate }}</text>
+ </view>
+ </view>
+ <!-- 鎿嶄綔鎸夐挳 -->
+ <view class="action-buttons">
+ <!-- <u-button
type="primary"
size="small"
class="action-btn"
@@ -81,124 +88,160 @@
@click="openForm(item)"
>
缂栬緫浠樻
- </u-button>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view v-else class="no-data">
- <text>鏆傛棤浠樻鍘嗗彶鏁版嵁</text>
- </view>
- </view>
+ </u-button> -->
+ <u-button type="error"
+ size="small"
+ class="action-btn"
+ :disabled="item.registrant !== userStore.nickName"
+ @click="deleteItem(item)">
+ 鍒犻櫎
+ </u-button>
+ </view>
+ </view>
+ </view>
+ </view>
+ </view>
+ <view v-else
+ class="no-data">
+ <text>鏆傛棤浠樻鍘嗗彶鏁版嵁</text>
+ </view>
+ </view>
</template>
<script setup>
-import { ref, computed } from 'vue';
-import { onShow } from '@dcloudio/uni-app';
-import {paymentHistoryListPage} from "@/api/procurementManagement/paymentEntry";
-import useUserStore from "@/store/modules/user";
-const userStore = useUserStore()
+ import { ref, computed } from "vue";
+ import { onShow } from "@dcloudio/uni-app";
+ import { paymentHistoryListPage } from "@/api/procurementManagement/paymentEntry";
+ import { delPaymentRegistration } from "@/api/procurementManagement/procurementInvoiceLedger";
+ import useUserStore from "@/store/modules/user";
+ const userStore = useUserStore();
-// 鎼滅储琛ㄥ崟
-const searchForm = ref({
- searchText: '',
-});
+ // 鎼滅储琛ㄥ崟
+ const searchForm = ref({
+ searchText: "",
+ });
-// 琛ㄦ牸鏁版嵁
-const tableData = ref([]);
+ // 琛ㄦ牸鏁版嵁
+ const tableData = ref([]);
-// 鍒嗛〉鍙傛暟
-const page = ref({
- current: -1,
- size: -1,
-});
+ // 鍒嗛〉鍙傛暟
+ const page = ref({
+ current: -1,
+ size: -1,
+ });
-const totalAmount = computed(() => {
- return tableData.value.reduce((sum, item) => {
- return sum + (parseFloat(item.receiptPaymentAmount) || 0);
- }, 0);
-});
+ const totalAmount = computed(() => {
+ return tableData.value.reduce((sum, item) => {
+ return sum + (parseFloat(item.receiptPaymentAmount) || 0);
+ }, 0);
+ });
-// 杩斿洖涓婁竴椤�
-const goBack = () => {
- uni.navigateBack();
-};
+ // 杩斿洖涓婁竴椤�
+ const goBack = () => {
+ uni.navigateBack();
+ };
+ const deleteItem = item => {
+ uni.showModal({
+ title: "纭鍒犻櫎",
+ content: `鏄惁纭鍒犻櫎璇ユ暟鎹悧锛焋,
+ success: res => {
+ if (res.confirm) {
+ // 璋冪敤鍒犻櫎鎺ュ彛
+ delPaymentRegistration([item.id])
+ .then(() => {
+ uni.showToast({
+ title: "鍒犻櫎鎴愬姛",
+ icon: "success",
+ });
+ // 鍒锋柊鍒楄〃
+ getList();
+ })
+ .catch(() => {
+ uni.showToast({
+ title: "鍒犻櫎澶辫触",
+ icon: "error",
+ });
+ });
+ }
+ },
+ });
+ };
+ // 鏌ヨ鍒楄〃
+ const getList = () => {
+ showLoadingToast("鍔犺浇涓�...");
+ const params = {
+ ...searchForm.value,
+ ...page.value,
+ };
+ paymentHistoryListPage(params)
+ .then(res => {
+ tableData.value = res.records;
+ closeToast();
+ })
+ .catch(() => {
+ closeToast();
+ uni.showToast({
+ title: "鏌ヨ澶辫触",
+ icon: "error",
+ });
+ });
+ };
-// 鏌ヨ鍒楄〃
-const getList = () => {
- showLoadingToast('鍔犺浇涓�...')
- const params = {
- ...searchForm.value,
- ...page.value
- };
- paymentHistoryListPage(params).then((res) => {
- tableData.value = res.records;
- closeToast()
- }).catch(() => {
- closeToast()
- uni.showToast({
- title: '鏌ヨ澶辫触',
- icon: 'error'
- });
- });
-};
+ // 鑾峰彇鏍囩鏍峰紡绫�
+ const getTagClass = type => {
+ if (type == "鐢垫眹") {
+ return "tag-electric";
+ } else if (type == "鎵垮厬") {
+ return "tag-acceptance";
+ } else {
+ return "tag-unknown";
+ }
+ };
-// 鑾峰彇鏍囩鏍峰紡绫�
-const getTagClass = (type) => {
- if (type == '鐢垫眹') {
- return "tag-electric";
- } else if (type == '鎵垮厬') {
- return "tag-acceptance";
- } else {
- return "tag-unknown";
- }
-};
+ // 鏍煎紡鍖栭噾棰�
+ const formatAmount = amount => {
+ return amount ? parseFloat(amount).toFixed(2) : "0.00";
+ };
-// 鏍煎紡鍖栭噾棰�
-const formatAmount = (amount) => {
- return amount ? parseFloat(amount).toFixed(2) : '0.00';
-};
+ // 鏄剧ず鍔犺浇鎻愮ず
+ const showLoadingToast = message => {
+ uni.showLoading({
+ title: message,
+ mask: true,
+ });
+ };
-// 鏄剧ず鍔犺浇鎻愮ず
-const showLoadingToast = (message) => {
- uni.showLoading({
- title: message,
- mask: true
- });
-};
+ // 鍏抽棴鎻愮ず
+ const closeToast = () => {
+ uni.hideLoading();
+ };
-// 鍏抽棴鎻愮ず
-const closeToast = () => {
- uni.hideLoading();
-};
-
-// 鎵撳紑缂栬緫琛ㄥ崟
-const openForm = (item) => {
- uni.setStorageSync('invoiceLedgerEditRow', JSON.stringify(item))
- uni.navigateTo({ url: '/pages/procurementManagement/paymentEntry/edit' })
-}
-onShow(() => {
- // 椤甸潰鏄剧ず鏃跺埛鏂板垪琛�
- getList();
-});
+ // 鎵撳紑缂栬緫琛ㄥ崟
+ const openForm = item => {
+ uni.setStorageSync("invoiceLedgerEditRow", JSON.stringify(item));
+ uni.navigateTo({ url: "/pages/procurementManagement/paymentEntry/edit" });
+ };
+ onShow(() => {
+ // 椤甸潰鏄剧ず鏃跺埛鏂板垪琛�
+ getList();
+ });
</script>
<style scoped lang="scss">
-@import '@/styles/procurement-common.scss';
+ @import "@/styles/procurement-common.scss";
-// 浠樻娴佹按鐗规湁鏍峰紡
-.action-buttons {
- padding: 12px 0 0 0; // 涓庡叕鍏辨牱寮忎腑鐨� 0 0 16px 0 涓嶅悓
-}
+ // 浠樻娴佹按鐗规湁鏍峰紡
+ .action-buttons {
+ padding: 12px 0 0 0; // 涓庡叕鍏辨牱寮忎腑鐨� 0 0 16px 0 涓嶅悓
+ }
-.item-tag {
- padding: 2px 8px; // 涓庡叕鍏辨牱寮忎腑鐨� 2px 4px 涓嶅悓
-}
+ .item-tag {
+ padding: 2px 8px; // 涓庡叕鍏辨牱寮忎腑鐨� 2px 4px 涓嶅悓
+ }
-.tag-text {
- font-size: 14px; // 涓庡叕鍏辨牱寮忎腑鐨� 11px 涓嶅悓
- color: #ffffff;
- font-weight: 500;
-}
+ .tag-text {
+ font-size: 14px; // 涓庡叕鍏辨牱寮忎腑鐨� 11px 涓嶅悓
+ color: #ffffff;
+ font-weight: 500;
+ }
</style>
\ No newline at end of file
--
Gitblit v1.9.3