yanghao 21 órája
szülő
commit
f450e527a3
4 módosított fájl, 284 hozzáadás és 10 törlés
  1. 11 0
      api/repair.js
  2. 6 4
      pages/recordFilling/detail.vue
  3. 31 3
      pages/repair/detail.vue
  4. 236 3
      pages/repair/index.vue

+ 11 - 0
api/repair.js

@@ -68,3 +68,14 @@ export function getRepairProjectManagerList(params) {
 		params
 	})
 }
+
+
+  export function maintainMethod(data) {
+		// return request.post({ url: `/rq/iot-maintain/method`, data })
+		
+		return request({
+			url: `/rq/iot-maintain/method`,
+			method: 'post',
+			data
+	  })
+  }

+ 6 - 4
pages/recordFilling/detail.vue

@@ -611,7 +611,7 @@ onLoad(async option => {
       wellNamePair: {},
     };
 
-    taskOptions.value = Object.keys(daily.wellNamePair).map(key => ({
+    taskOptions.value = Object.keys(daily.wellNamePair ?? {}).map(key => ({
       text: daily.wellNamePair[key],
       value: Number(key),
     }));
@@ -638,6 +638,7 @@ onLoad(async option => {
   console.log("🚀 ~ params.value:", params.value);
   // 处理是否可编辑 {0: '待填写', 1: '已完成', 2: '填写中', 3: '忽略'}
   isView.value = params.value?.orderStatus % 2 == 0;
+
   console.log("🚀 ~ isView.value:", isView.value);
 });
 const paging = ref(null);
@@ -1390,10 +1391,11 @@ const isSubmitting = ref(false); // 添加提交状态
 const formRef = ref(null);
 
 const onSubmit = async () => {
-  if (!formRef.value) return;
   try {
-    for (const item of formRef.value) {
-      await item.validate();
+    if (formRef.value) {
+      for (const item of formRef.value) {
+        await item.validate();
+      }
     }
   } catch (error) {
     return;

+ 31 - 3
pages/repair/detail.vue

@@ -39,6 +39,23 @@
             >
             </uni-data-select>
           </uni-forms-item>
+
+          <!-- 维修方式 -->
+          <uni-forms-item
+            v-if="maintain.maintainMethod"
+            class="form-item"
+            label="维修方式"
+            name="maintainMethod"
+            :required="false"
+          >
+            <uni-data-select
+              :clear="false"
+              :disabled="true"
+              v-model="maintain.maintainMethod"
+              :localdata="typeRange2"
+            >
+            </uni-data-select>
+          </uni-forms-item>
           <!-- 是否停机 -->
           <uni-forms-item
             class="form-item"
@@ -536,7 +553,10 @@
             </view>
           </view>
           <!-- 是否消耗物料 -->
-          <view class="item-content flex-row align-center justify-between" v-if="bom.rule">
+          <view
+            class="item-content flex-row align-center justify-between"
+            v-if="bom.rule"
+          >
             <view class="item-title">
               <span class="item-title-width">
                 {{ $t("workOrder.isConsumptionMaterial") }}:
@@ -629,13 +649,21 @@ const { appContext } = getCurrentInstance();
 const t = appContext.config.globalProperties.$t;
 // 获取维修类型
 const typeDict = getDataDictList("pms_main_type");
+
+// 获取维修方式
+const typeDict2 = getDataDictList("maintain_method");
 // 遍历typeDict,新增text字段 值为label
 typeDict.forEach((item) => {
   item.text = item.label;
 });
-console.log("typeDict", typeDict);
+
+typeDict2.forEach((item) => {
+  item.text = item.label;
+});
+
 // 维修类型
 const typeRange = ref(typeDict);
+const typeRange2 = ref(typeDict2);
 // 是否停机
 const ifStopRange = ref([
   {
@@ -675,7 +703,7 @@ const maintainClassifyRange = getDataDictList("pms_maintain_classify").map(
       value: item.value,
       text: item.label,
     };
-  }
+  },
 );
 console.log("🚀 ~ maintainClassifyRange:", maintainClassifyRange);
 

+ 236 - 3
pages/repair/index.vue

@@ -76,7 +76,11 @@
           <view class="module-name">
             {{ $t("equipmentMaintenance.repairCode") }}: {{ item.failureCode }}
           </view>
-          <view class="module-status" :class="{ pending: item.status == 'tx' }" v-if="statusDict[item.status]">
+          <view
+            class="module-status"
+            :class="{ pending: item.status == 'tx' }"
+            v-if="statusDict[item.status]"
+          >
             <!-- 状态 -->
             <span>{{ statusDict[item.status] }}</span>
           </view>
@@ -148,7 +152,10 @@
             <span>{{ item.maintainType }}</span>
           </view>
         </view>
-        <view class="item-btn flex-row align-center justify-end">
+        <view
+          class="item-btn flex-row align-center justify-end"
+          v-if="companyInfo.data !== 'rh'"
+        >
           <button
             type="primary"
             :plain="false"
@@ -161,14 +168,87 @@
             {{ $t("operation.fill") }}
           </button>
         </view>
+
+        <view class="item-btn flex-row align-center justify-end" v-else>
+          <button type="primary" :plain="false" @click="onView(item)">
+            {{ $t("workOrder.viewDetails") }}
+          </button>
+
+          <button
+            type="primary"
+            :plain="false"
+            v-if="
+              item.status === 'personnel' && userInfo.id === item.maintainPerson
+            "
+            @click="changeMethod(item)"
+          >
+            维修方式
+          </button>
+
+          <button
+            type="primary"
+            @click="onEdit(item)"
+            v-if="
+              item.status === 'tx' &&
+              (item.auditStatus === 20 || item.auditStatus === null)
+            "
+          >
+            {{ $t("operation.fill") }}
+          </button>
+        </view>
       </view>
     </view>
   </z-paging>
+
+  <uni-popup type="dialog" ref="chooseMethodRef" @close="cancelRepairMethod">
+    <view class="popup-content">
+      <view class="popup-title">维修方式</view>
+      <view class="form-item">
+        <text class="label">*</text>
+        <text class="label-text">维修方式</text>
+        <picker
+          @change="onPickerChange"
+          :value="selectedValue"
+          :range="methodOptions"
+        >
+          <view class="picker-view">
+            {{ methodOptions[selectedValue] || "请选择维修方式" }}
+          </view>
+        </picker>
+
+        <!-- <uni-data-select
+          :clear="false"
+          v-model="selectedValue"
+          :localdata="methodOptions"
+          @change="onPickerChange"
+        >
+        </uni-data-select> -->
+      </view>
+
+      <view class="form-item">
+        <text class="label">*</text>
+        <text class="label-text">备注说明</text>
+        <textarea
+          v-model="repairMethodForm.remark"
+          placeholder="请输入备注说明"
+          class="textarea"
+          maxlength="200"
+        ></textarea>
+      </view>
+
+      <view class="popup-footer">
+        <view class="btn-cancel" @click="cancelRepairMethod">取消</view>
+        <view class="btn-confirm" @click="submitRepairMethod">确定</view>
+      </view>
+    </view>
+  </uni-popup>
 </template>
 <script setup>
 import { ref, reactive, onMounted, nextTick } from "vue";
 import { onShow } from "@dcloudio/uni-app";
-import { getRepairCount, getRepairList } from "@/api/repair";
+import { getRepairCount, getRepairList, maintainMethod } from "@/api/repair";
+import { getLoginUserInfo } from "@/api/login";
+import { getDeptName } from "@/api/recordFilling";
 import dayjs from "dayjs";
 import { useDataDictStore } from "@/store/modules/dataDict";
 // 字典项
@@ -184,6 +264,14 @@ const auditStatusDict = reactive({});
 getDataDictList("crm_audit_status").map((item) => {
   auditStatusDict[item.value] = item.label;
 });
+
+const methodOptions = ref([]); // 使用 ref 创建数组
+const methodOptionsMap = reactive({}); // 保存 value -> label 的映射
+
+getDataDictList("maintain_method").forEach((item) => {
+  methodOptions.value.push(item.label); // 只存储 label 用于显示
+  methodOptionsMap[item.value] = item.label;
+});
 console.log("auditStatusDict", auditStatusDict);
 
 //  --- 列表 ---start---
@@ -227,6 +315,81 @@ const getCount = () => {
     statistics.average = 4.8;
   });
 };
+const currentRepairItem = ref(null); // 当前操作的工单项
+const repairMethodForm = ref({
+  // 表单数据
+  maintainMethod: "",
+  remark: "",
+});
+const chooseMethodRef = ref(null); // 控制弹窗显示
+
+const selectedValue = ref(null);
+const changeMethod = (item) => {
+  console.log("选择维修方式的工单项", item);
+  // 打开弹窗前先初始化表单数据
+  currentRepairItem.value = item;
+  repairMethodForm.value.maintainMethod = "";
+  repairMethodForm.value.remark = "";
+  chooseMethodRef.value.open();
+};
+
+const submitRepairMethod = () => {
+  if (!repairMethodForm.value.maintainMethod) {
+    uni.showToast({
+      title: "请选择维修方式",
+      icon: "none",
+    });
+    return;
+  }
+  if (!repairMethodForm.value.remark) {
+    uni.showToast({
+      title: "请输入备注说明",
+      icon: "none",
+    });
+    return;
+  }
+
+  // 调用接口
+  maintainMethod({
+    id: currentRepairItem.value.id,
+    maintainMethod: repairMethodForm.value.maintainMethod,
+    remark: repairMethodForm.value.remark,
+  })
+    .then((res) => {
+      uni.showToast({
+        title: "提交成功",
+        icon: "success",
+      });
+      chooseMethodRef.value.close();
+      // 可选:刷新列表或更新当前项状态
+      onSearch(); // 刷新列表
+    })
+    .catch((err) => {
+      uni.showToast({
+        title: "提交失败",
+        icon: "none",
+      });
+    });
+};
+
+const cancelRepairMethod = () => {
+  chooseMethodRef.value.close();
+  repairMethodForm.value.maintainMethod = "";
+  repairMethodForm.value.remark = "";
+  selectedValue.value = null;
+};
+const onPickerChange = (e) => {
+  const selectedIndex = e.detail.value;
+  selectedValue.value = selectedIndex;
+
+  // 通过索引找到对应的 value
+  const selectedLabel = methodOptions.value[selectedIndex];
+  const selectedKey = Object.keys(methodOptionsMap).find(
+    (key) => methodOptionsMap[key] === selectedLabel,
+  );
+
+  repairMethodForm.value.maintainMethod = selectedKey; // 设置表单值为 key
+};
 onShow(() => {
   getCount();
   nextTick(() => {
@@ -252,7 +415,77 @@ const onView = (item) => {
 const navigatorBack = () => {
   uni.navigateBack();
 };
+
+const userInfo = ref({});
+const companyInfo = ref({});
+
+onMounted(async () => {
+  userInfo.value = (await getLoginUserInfo()).data;
+  companyInfo.value = await getDeptName(userInfo.value.dept.id);
+
+  useDataDictStore().loadDataDictList();
+});
 </script>
 <style lang="scss" scoped>
 @import "@/style/work-order.scss";
+
+.popup-content {
+  width: 500rpx;
+  padding: 30rpx;
+  background-color: #fff;
+  border-radius: 16rpx;
+
+  .popup-title {
+    font-size: 36rpx;
+    margin-bottom: 30rpx;
+    text-align: center;
+  }
+
+  .form-item {
+    margin-bottom: 40rpx;
+
+    .label {
+      color: red;
+      font-size: 28rpx;
+      margin-right: 10rpx;
+    }
+
+    .label-text {
+      font-size: 28rpx;
+      color: #333;
+    }
+
+    .picker-view {
+      margin-top: 10rpx;
+      padding: 20rpx;
+      border: 1px solid #ccc;
+      border-radius: 8rpx;
+      font-size: 28rpx;
+    }
+
+    .textarea {
+      width: 95.5%;
+      height: 150rpx;
+      padding: 10rpx;
+      border: 1px solid #ccc;
+      border-radius: 8rpx;
+      font-size: 28rpx;
+    }
+  }
+
+  .popup-footer {
+    display: flex;
+    justify-content: flex-end;
+    gap: 30rpx;
+
+    .btn-cancel {
+      color: #333;
+      border: none;
+    }
+
+    .btn-confirm {
+      color: #007aff;
+    }
+  }
+}
 </style>