|
@@ -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('mainPlan.delayed') || '延时' }}
|
|
|
|
|
+ </el-button>
|
|
|
<el-button
|
|
<el-button
|
|
|
link
|
|
link
|
|
|
type="primary"
|
|
type="primary"
|
|
@@ -168,6 +177,37 @@
|
|
|
</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="0px" :rules="delayReasonRules"
|
|
|
|
|
+ ref="delayReasonFormRef">
|
|
|
|
|
+ <el-form-item label=" " prop="delayReason" class="required-item" label-width="16px">
|
|
|
|
|
+ <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">
|
|
@@ -182,6 +222,9 @@ const { push } = useRouter() // 路由跳转
|
|
|
/** 保养工单 列表 */
|
|
/** 保养工单 列表 */
|
|
|
defineOptions({ name: 'IotMainWorkOrder' })
|
|
defineOptions({ name: 'IotMainWorkOrder' })
|
|
|
|
|
|
|
|
|
|
+// 表单引用
|
|
|
|
|
+const delayReasonFormRef = ref<InstanceType<typeof ElForm>>()
|
|
|
|
|
+
|
|
|
const message = useMessage() // 消息弹窗
|
|
const message = useMessage() // 消息弹窗
|
|
|
const { t } = useI18n() // 国际化
|
|
const { t } = useI18n() // 国际化
|
|
|
const tableRef = ref() // 表格引用
|
|
const tableRef = ref() // 表格引用
|
|
@@ -219,6 +262,13 @@ const queryFormRef = ref() // 搜索的表单
|
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
const exportLoading = ref(false) // 导出的加载中
|
|
|
const hoverText = ref('');
|
|
const hoverText = ref('');
|
|
|
|
|
|
|
|
|
|
+// 定义表单验证规则
|
|
|
|
|
+const delayReasonRules = {
|
|
|
|
|
+ delayReason: [
|
|
|
|
|
+ { required: true, message: t('workOrderMaterial.inputDelayReason') || '请输入延时原因', trigger: 'blur' }
|
|
|
|
|
+ ]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 列宽度配置
|
|
// 列宽度配置
|
|
|
const columnWidths = ref({
|
|
const columnWidths = ref({
|
|
|
serial: '80px',
|
|
serial: '80px',
|
|
@@ -250,6 +300,75 @@ 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 (!delayReasonFormRef.value) return
|
|
|
|
|
+ const valid = await delayReasonFormRef.value.validate()
|
|
|
|
|
+ if (!valid) return
|
|
|
|
|
+
|
|
|
|
|
+ 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.success') || '保存成功')
|
|
|
|
|
+ delayReasonDialogVisible.value = false
|
|
|
|
|
+
|
|
|
|
|
+ // 刷新列表数据
|
|
|
|
|
+ await getList()
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('保存延保原因失败:', error)
|
|
|
|
|
+ message.error(t('sys.api.operationFailed') || '保存失败')
|
|
|
|
|
+ } 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 +429,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 = 160;
|
|
|
|
|
+ totalMinWidth += 160;
|
|
|
|
|
|
|
|
// 2. 计算可伸缩列最终宽度
|
|
// 2. 计算可伸缩列最终宽度
|
|
|
const newWidths: Record<string, string> = {};
|
|
const newWidths: Record<string, string> = {};
|
|
@@ -382,6 +501,10 @@ const resultOptions = computed(() => [
|
|
|
label: t('operationFill.all'),
|
|
label: t('operationFill.all'),
|
|
|
value: '0' // 空值会触发 clearable 效果
|
|
value: '0' // 空值会触发 clearable 效果
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ label: t('mainPlan.delayed'),
|
|
|
|
|
+ value: '3' // 空值会触发 clearable 效果
|
|
|
|
|
+ },
|
|
|
...getStrDictOptions(DICT_TYPE.PMS_MAIN_WORK_ORDER_RESULT)
|
|
...getStrDictOptions(DICT_TYPE.PMS_MAIN_WORK_ORDER_RESULT)
|
|
|
])
|
|
])
|
|
|
|
|
|
|
@@ -620,4 +743,15 @@ watch(isLeftContentCollapsed, () => {
|
|
|
transform: rotate(180deg);
|
|
transform: rotate(180deg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* 延时原因 必填星号样式 */
|
|
|
|
|
+:deep(.required-item .el-form-item__label:before) {
|
|
|
|
|
+ content: '*';
|
|
|
|
|
+ color: #ff4d4f;
|
|
|
|
|
+ margin-right: 2px;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 调整标签区域样式 */
|
|
|
|
|
+:deep(.required-item .el-form-item__label) {
|
|
|
|
|
+ padding-right: 0 !important;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|