车间能级提升-智能设备管理系统
baoshiwei
2025-06-24 f571cf0182abd65176fb1512c5cb5ddaea49c4a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<template>
  <view class="bg-base">
 
    <z-paging ref="paging" v-model="dataList" @query="queryList" class="bg-base">
      <template #top>
        <wd-search v-model="searchValue" placeholder="设备名称/资产编号" @search="reloadData" />
        <wd-tabs v-model="activeTab" @change="handleTabChange">
          <wd-tab title="待确认"></wd-tab>
          <wd-tab title="已同意"></wd-tab>
          <wd-tab title="已驳回"></wd-tab>
        </wd-tabs>
      </template>
      <view v-for="item in dataList" :key="item.equStatuId" class="mb-2" >
        <wd-card type="rectangle">
          <template #title>
            <view class="flex justify-between items-center menu-title-box">
              <view class="flex items-center">
                <view class="menu-indicator"></view>
                <text class="ml-1 text-sm">{{ item.equName || '-' }}</text>
                <text class="ml-2 text-color-gray text-mini">{{ item.assetNo || '-' }}</text>
              </view>
              <wd-tag v-if="item.orderStatus === '0'" type="warning">待确认</wd-tag>
              <wd-tag v-else-if="item.orderStatus === '1'" type="success">已同意</wd-tag>
              <wd-tag v-else type="error">已驳回</wd-tag>
            </view>
          </template>
          <view class="flex h-[200rpx] items-center">
            <image class="slot-img text-center" src="/static/images/camera.png" />
            <view class="flex-1">
              <view class="text-color-base mt-1">变更前:{{ statusText(item.beforeChange) }} → 变更后:{{ statusText(item.afterChange) }}</view>
              <view class="text-color-gray text-sm mt-1">变更原因:{{ item.changeDesc }}</view>
              <view class="text-color-gray text-sm mt-1">变更时间:{{ item.changeDate || '-' }}</view>
              <view class="text-color-gray text-sm mt-1">变更人:{{ item.changeUserName || '-' }}</view>
              <view v-if="item.orderStatus === '2' && item.remark" class="text-color-error text-sm mt-1">驳回理由:{{ item.remark }}</view>
            </view>
            <view v-if="item.orderStatus === '0' && isEquAdmin()" class="flex flex-col gap-2 ml-2">
              <wd-button size="small" type="success" @click="handleAgree(item)">同意</wd-button>
              <wd-button size="small" type="error" @click="openReject(item)">驳回</wd-button>
            </view>
          </view>
        </wd-card>
      </view>
    </z-paging>
    <wd-popup v-model="showReject" position="center" round :close-on-click-modal="false">
      <view class="popup-container">
        <view class="popup-title">填写驳回理由</view>
        <wd-textarea v-model="rejectReason" placeholder="请输入驳回理由" :maxlength="100" show-word-limit required />
        <view class="popup-actions">
          <wd-button block @click="showReject = false">取消</wd-button>
          <wd-button type="error" block class="ml-2" @click="handleRejectConfirm">确定</wd-button>
        </view>
      </view>
    </wd-popup>
  </view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { getEquStatuList, updateEquStatu } from '@/service/equ_status'
import { useToast } from 'wot-design-uni'
import { isEquAdmin } from "@/utils/RoleUtils";
const toast = useToast()
const searchValue = ref('')
const activeTab = ref(0)
const dataList = ref<any[]>([])
const paging = ref()
const showReject = ref(false)
const rejectReason = ref('')
const rejectItem = ref<any>(null)
 
const statusMap = [
  { label: '试用', value: '0' },
  { label: '使用', value: '1' },
  { label: '停用', value: '2' },
  { label: '报废', value: '3' },
  { label: '闲置', value: '4' },
  { label: '新增', value: '5' },
]
function statusText(val: string) {
  return statusMap.find((s) => s.value === val)?.label || '-'
}
function handleTabChange({ index }) {
  activeTab.value = index
  reloadData()
}
function reloadData() {
  paging.value.reload()
}
function queryList(pageNum?: number, pageSize?: number) {
  const params: any = {
    pageNum,
    pageSize,
    params: {
      searchValue: searchValue.value,
    },
    orderStatus: String(activeTab.value),
  }
  getEquStatuList(params).then((res: any) => {
    paging.value.completeByTotal(res.rows, res.total)
  }).catch(() => {
    paging.value.complete(false)
  })
}
function handleAgree(item: any) {
  updateEquStatu({
    equStatuId: item.equStatuId,
    orderStatus: '1',
    remark: '',
  }).then(() => {
    toast.success('操作成功')
    reloadData()
  })
}
function openReject(item: any) {
  rejectItem.value = item
  rejectReason.value = ''
  showReject.value = true
}
function handleRejectConfirm() {
  if (!rejectReason.value.trim()) {
    toast.info('请填写驳回理由')
    return
  }
  updateEquStatu({
    equStatuId: rejectItem.value.equStatuId,
    orderStatus: '2',
    remark: rejectReason.value,
  }).then(() => {
    toast.success('已驳回')
    showReject.value = false
    reloadData()
  })
}
</script>
<style scoped lang="scss">
.menu-title-box {
}
.slot-img {
  width: 72rpx;
  height: 72rpx;
  margin-right: 24rpx;
}
.text-mini {
  font-size: 24rpx;
}
.menu-indicator {
  width: 6rpx;
  height: 26rpx;
  border-radius: 10rpx;
  background-color: $uni-color-primary;
}
:deep(.wd-card__footer) {
  padding: 10rpx !important;
}
:deep(.wd-card__title-content) {
  padding: 24rpx 0 !important;
}
.popup-container {
  width: 600rpx;
  background: #fff;
  border-radius: 16rpx;
  padding: 32rpx 24rpx 24rpx 24rpx;
}
.popup-title {
  font-size: 32rpx;
  font-weight: bold;
  text-align: center;
  margin-bottom: 24rpx;
}
.popup-actions {
  display: flex;
  margin-top: 24rpx;
  gap: 16rpx;
}
</style>