|
@@ -136,6 +136,15 @@
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column :label="t('iotMaintain.operation')" align="center" :width="columnWidths.operation" fixed="right">
|
|
<el-table-column :label="t('iotMaintain.operation')" align="center" :width="columnWidths.operation" fixed="right">
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ v-if="isNegativeMainDistance(scope.row.mainDistance)"
|
|
|
|
|
+ link
|
|
|
|
|
+ :type="getDelayReasonButtonType(scope.row.delayReason)"
|
|
|
|
|
+ @click="openDelayReasonDialog(scope.row)"
|
|
|
|
|
+ v-hasPermi="['pms:iot-main-work-order:update']"
|
|
|
|
|
+ >
|
|
|
|
|
+ {{ t('workOrderMaterial.delayReason') || '延保原因' }}
|
|
|
|
|
+ </el-button>
|
|
|
<el-button
|
|
<el-button
|
|
|
link
|
|
link
|
|
|
type="primary"
|
|
type="primary"
|
|
@@ -168,6 +177,36 @@
|
|
|
</el-row>
|
|
</el-row>
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
|
<IotMainWorkOrderForm ref="formRef" @success="getList" />
|
|
<IotMainWorkOrderForm ref="formRef" @success="getList" />
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 延保原因弹窗 -->
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ v-model="delayReasonDialogVisible"
|
|
|
|
|
+ :title="t('workOrderMaterial.delayReason') || '延保原因'"
|
|
|
|
|
+ width="500px"
|
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-form :model="delayReasonForm" label-width="80px">
|
|
|
|
|
+ <el-form-item :label="t('workOrderMaterial.delayReason') || '延保原因'">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="delayReasonForm.delayReason"
|
|
|
|
|
+ type="textarea"
|
|
|
|
|
+ :rows="4"
|
|
|
|
|
+ :placeholder="t('workOrderMaterial.inputDelayReason') || '请输入延保原因'"
|
|
|
|
|
+ maxlength="500"
|
|
|
|
|
+ show-word-limit
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <el-button @click="delayReasonDialogVisible = false">
|
|
|
|
|
+ {{ t('common.cancel') || '取消' }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button type="primary" @click="saveDelayReason" :loading="saveDelayReasonLoading">
|
|
|
|
|
+ {{ t('common.save') || '保存' }}
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
@@ -250,6 +289,70 @@ const getTextWidth = (text: string, fontSize = 14) => {
|
|
|
return width;
|
|
return width;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/** 延保原因相关状态 */
|
|
|
|
|
+const delayReasonDialogVisible = ref(false)
|
|
|
|
|
+const saveDelayReasonLoading = ref(false)
|
|
|
|
|
+const delayReasonForm = reactive({
|
|
|
|
|
+ id: undefined as number | undefined,
|
|
|
|
|
+ delayReason: ''
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+/** 判断mainDistance是否为负值 */
|
|
|
|
|
+const isNegativeMainDistance = (mainDistance: string | null): boolean => {
|
|
|
|
|
+ if (!mainDistance) return false
|
|
|
|
|
+
|
|
|
|
|
+ // 使用正则提取数字部分(包括负号、小数点和科学计数法)
|
|
|
|
|
+ const numericPart = mainDistance.match(/[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/)?.[0]
|
|
|
|
|
+
|
|
|
|
|
+ if (numericPart) {
|
|
|
|
|
+ const num = parseFloat(numericPart)
|
|
|
|
|
+ return num < 0
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 打开延保原因弹窗 */
|
|
|
|
|
+const openDelayReasonDialog = (row: IotMainWorkOrderVO) => {
|
|
|
|
|
+ delayReasonForm.id = row.id
|
|
|
|
|
+ delayReasonForm.delayReason = row.delayReason || ''
|
|
|
|
|
+ delayReasonDialogVisible.value = true
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 保存延保原因 */
|
|
|
|
|
+const saveDelayReason = async () => {
|
|
|
|
|
+ if (!delayReasonForm.id) {
|
|
|
|
|
+ message.error('ID不能为空')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ saveDelayReasonLoading.value = true
|
|
|
|
|
+ // 调用更新接口,只传递id和delayReason字段
|
|
|
|
|
+ await IotMainWorkOrderApi.updateIotMainWorkOrder({
|
|
|
|
|
+ id: delayReasonForm.id,
|
|
|
|
|
+ delayReason: delayReasonForm.delayReason
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ message.success(t('common.saveSuccess') || '保存成功')
|
|
|
|
|
+ delayReasonDialogVisible.value = false
|
|
|
|
|
+
|
|
|
|
|
+ // 刷新列表数据
|
|
|
|
|
+ await getList()
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('保存延保原因失败:', error)
|
|
|
|
|
+ message.error(t('common.saveFailed') || '保存失败')
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ saveDelayReasonLoading.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** 根据delayReason是否有值返回按钮类型 */
|
|
|
|
|
+const getDelayReasonButtonType = (delayReason: string | null | undefined): string => {
|
|
|
|
|
+ // 如果delayReason有值(不为null、undefined且不是空字符串),返回success,否则返回warning
|
|
|
|
|
+ return delayReason ? 'success' : 'warning'
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/** 处理部门被点击 */
|
|
/** 处理部门被点击 */
|
|
|
const handleDeptNodeClick = async (row) => {
|
|
const handleDeptNodeClick = async (row) => {
|
|
|
queryParams.deptId = row.id
|
|
queryParams.deptId = row.id
|
|
@@ -310,8 +413,8 @@ const calculateColumnWidths = () => {
|
|
|
calculateColumnMinWidth('updateTime', t('dict.fillTime'), (row: any) => row.result == 2 ? formatCellDate(row.updateTime) : '');
|
|
calculateColumnMinWidth('updateTime', t('dict.fillTime'), (row: any) => row.result == 2 ? formatCellDate(row.updateTime) : '');
|
|
|
|
|
|
|
|
// 操作列固定宽度
|
|
// 操作列固定宽度
|
|
|
- minWidths.operation = 150;
|
|
|
|
|
- totalMinWidth += 150;
|
|
|
|
|
|
|
+ minWidths.operation = 200;
|
|
|
|
|
+ totalMinWidth += 200;
|
|
|
|
|
|
|
|
// 2. 计算可伸缩列最终宽度
|
|
// 2. 计算可伸缩列最终宽度
|
|
|
const newWidths: Record<string, string> = {};
|
|
const newWidths: Record<string, string> = {};
|