车间能级提升-智能设备管理系统
baoshiwei
2025-06-24 f571cf0182abd65176fb1512c5cb5ddaea49c4a3
eims-ui-mobile/src/pages/repair/res-detail.vue
@@ -30,7 +30,15 @@
        <wd-cell title="故障类型" title-width="200rpx" is-link>
          <text>{{ reqType?.dictLabel }}</text>
        </wd-cell>
        <wd-cell title="报修描述" :label="repairRes?.reqDesc" is-link />
        <wd-textarea
          label="报修描述"
          label-width="200rpx"
          type="textarea"
          v-model="repairRes.reqDesc"
          auto-height
          readonly
        />
      </wd-cell-group>
      <wd-cell-group
@@ -64,6 +72,11 @@
      </wd-cell-group>
      <wd-cell-group custom-class="mt-2" title="维修信息" use-slot border>
        <wd-cell title="故障类别" title-width="200rpx" prop="faultType">
          <wd-radio-group v-model="repairRes.faultType" inline  shape="dot"> >
            <wd-radio v-for="item in faultList" :value="item.dictValue">{{item.dictLabel}}</wd-radio>
          </wd-radio-group>
        </wd-cell>
        <wd-textarea
          label="原因分析"
          label-width="200rpx"
@@ -112,28 +125,93 @@
          clearable
        />
      </wd-cell-group>
      <wd-cell-group custom-class="mt-2" title="备件信息" use-slot border>
      <!-- 备件信息录入区域 -->
      <view v-if="repairRes.spareParts && repairRes.spareParts.length > 0" class="mt-2">
        <view
          v-for="(part, partIndex) in repairRes.spareParts"
          :key="partIndex"
          class="flex justify-between mt-1"
        >
          <wd-input
            v-model="part.name"
            label="名称:"
            label-width="100rpx"
            placeholder="备件名称"
          />
          <wd-input
            v-model="part.quantity"
            label="数量:"
            label-width="100rpx"
            placeholder="数量" type="number" :maxlength="5" />
        </view>
      </view>
      <!-- 维修说明区域 -->
      <view class="mt-2 flex justify-end">
        <wd-button type="info" style="margin: 20px" @click.stop="addSparePart()">
          添加备件
        </wd-button>
      </view>
      <view class="h-[2px] w-full bg-base"></view>
      </wd-cell-group>
    </wd-form>
    <view class="h-[5px] w-full bg-base"></view>
    <view class=" flex justify-around py-4">
      <wd-button block @click="saveOrder">保存</wd-button>
      <wd-button type="success" block @click="submitOrder">提交</wd-button>
    </view>
  </view>
  <!-- 备件选择弹出层 -->
  <wd-popup v-model="showSparePopup" position="bottom" height="33.33vh">
    <view class="flex justify-between p-2 bg-white">
      <wd-button type="text" @click="closeSparePopup">取消</wd-button>
      <wd-button type="text" @click="addOtherSparePart">其他</wd-button>
    </view>
    <wd-input
      v-model="searchKeyword"
      placeholder="请输入备件名称或型号"
      clearable
      @input="filterSpareParts"
    />
    <view class="p-2">
      <view
        v-for="(part, index) in sparePartsList"
        :key="index"
        class="flex justify-between items-center p-2 border-b"
        @click="selectFilteredSparePart(part)"
      >
        <text>{{ part.name }} ({{ part.code }})</text>
        <text>剩余: {{ part.actualStock }}</text>
      </view>
    </view>
  </wd-popup>
</template>
<script setup lang="ts">
import { getRepairRes, updateRepairRes } from '@/service/repair'
import { RepairResVO } from '@/service/repair.d'
import { reactive, onMounted, ref } from 'vue'
import { FormRules } from 'wot-design-uni/components/wd-form/types'
import { useToast, useMessage } from 'wot-design-uni'
import { isLeader, isOperatorOrRepair } from '@/utils/RoleUtils'
import { DICT_REPAIR_REQ_TYPE, getDictInfo } from '@/service/dict'
import { isEquAdmin, isLeader, isLineOrRepair, isRepair } from "@/utils/RoleUtils";
import { DICT_REPAIR_FAULT_TYPE, DICT_REPAIR_REQ_TYPE, getDictInfo } from "@/service/dict";
import { formatDate } from '@/utils/DateUtils'
const toast = useToast()
const message = useMessage()
const showSparePopup = ref(false)
import { getSpareList } from '@/service/spare'
import { ref } from "vue";
const fileList = ref<[]>()
const selectedPartIndex = ref(-1)
const sparePartsList = ref([])
const searchKeyword = ref('')
// 报修单类型
const reqTypeList = ref<any>([])
// 故障类别
const faultList = ref<any>([])
const repairRes = reactive<RepairResVO>({
  id: '',
  resCode: '',
@@ -158,6 +236,59 @@
  ],
}
function filterSpareParts() {
  if (!searchKeyword.value) {
    loadSpareParts()
  } else {
    loadSpareParts(searchKeyword.value)
  }
}
// 备件选择相关逻辑
function addSparePart() {
  // if (!item.spareParts) {
  //   item.spareParts = []
  // }
  repairRes.spareParts.value = []
  selectSparePart()
}
function selectSparePart(item: any) {
  showSparePopup.value = true
  loadSpareParts()
}
function loadSpareParts(value?: string) {
  getSpareList({ name: value, pageNum: 1, pageSize: 10 }).then((res: any) => {
    sparePartsList.value = res.rows
  })
}
function selectFilteredSparePart(part: any) {
  repairRes.spareParts.value.push({
    id: part.id,
    name: part.name,
    quantity: '',
  })
  closeSparePopup()
}
function addOtherSparePart() {
  repairRes.spareParts.value.push({
    id:  '',
    name: '',
    quantity: '',
  })
  closeSparePopup();
}
function closeSparePopup() {
  showSparePopup.value = false
  selectedPartIndex.value = -1
  searchKeyword.value = ''
}
function handleFileChange({ fileList }) {}
function initRepairRes(id: any) {
@@ -172,6 +303,8 @@
  initRepairRes(options.id)
  const reqList = await getDictInfo(DICT_REPAIR_REQ_TYPE)
  reqTypeList.value = reqList
  const fList = await getDictInfo(DICT_REPAIR_FAULT_TYPE)
  faultList.value = fList
}
function hanldeUpdateRepairRes(data: any, resolve: any) {
@@ -179,7 +312,8 @@
    .then((res: any) => {
      resolve(true)
      toastSucces()
      uni.$emit('res-list-refresh')
      uni.$emit('list-refresh')
      uni.navigateBack()
    })
    .catch((res) => {
      console.error(res)
@@ -192,7 +326,7 @@
function handleClickRight(data: any) {
  message
    .confirm({
      msg: '确定提交?',
      msg: '确定' + (data.status === '3' ? '提交' : '保存') + '?',
      title: '提示',
      beforeConfirm: ({ resolve }) => {
        hanldeUpdateRepairRes(data, resolve)
@@ -204,12 +338,28 @@
    })
}
function submitOrder() {
  const data = Object.assign({}, repairRes)
  // 提交修改状态为完成
  data.status = '3'
  // 设置维修完成时间
  data.endTime = formatDate(new Date())
  handleClickRight(data)
}
function saveOrder() {
  const data = Object.assign({}, repairRes)
  // 仅保存不修改状态为完成
  data.status = '2'
  // 仅保存不设置完成时间
  data.endTime = ''
  handleClickRight(data)
}
onNavigationBarButtonTap((e) => {
  if (e.index === 0) {
    // 管理员角色
    if (isLeader()) {
      toast.warning('当前登录角色不可操作')
    } else if (isOperatorOrRepair()) {
    if (isRepair() || isEquAdmin()) {
      switch (repairRes.status) {
        // 已接单
        case '1':
@@ -232,9 +382,7 @@
      }
    }
  } else if (e.index === 1) {
    if (isLeader()) {
      toast.warning('当前登录角色不可操作')
    } else if (isOperatorOrRepair()) {
    if (isRepair() || isEquAdmin()) {
      switch (repairRes.status) {
        // 已接单
        case '1':