feat:新增模具管理-点检任务

master
黄伟杰 2 weeks ago
parent b4b7c1359c
commit 929dea162b

@ -0,0 +1,41 @@
import request from '@/utils/request'
export function getTaskManagementPage(params = {}) {
return request({
url: '/admin-api/mes/mold-task-management/page',
method: 'get',
params
})
}
export function createTaskManagement(data) {
return request({
url: '/admin-api/mes/mold-task-management/create',
method: 'post',
data
})
}
export function updateTaskManagement(data) {
return request({
url: '/admin-api/mes/mold-task-management/update',
method: 'put',
data
})
}
export function deleteTaskManagement(ids = []) {
return request({
url: '/admin-api/mes/mold-task-management/delete',
method: 'delete',
params: { ids: Array.isArray(ids) ? ids.join(',') : String(ids) }
})
}
export function createTaskManagementTicket(id) {
return request({
url: '/admin-api/mes/mold-task-management/createMoldTicket',
method: 'post',
params: { id }
})
}

@ -362,6 +362,52 @@ export default {
inspectionMethod: 'Inspection Method',
judgmentCriteria: 'Judgment Criteria'
},
moldTaskConfig: {
moduleName: 'Inspection Task',
subTitle: 'Mold management inspection task',
detailTitle: 'Inspection Task Detail',
basicInfo: 'Basic Info',
name: 'Task Name',
taskType: 'Task Type',
taskTypeInspect: 'Inspection',
taskTypeMaintain: 'Maintenance',
moldList: 'Mold List',
projectForm: 'Inspection Plan',
projectFormName: 'Project Form',
dateRange: 'Valid Date Range',
startDate: 'Start Date',
endDate: 'End Date',
cronExpression: 'Cron Expression',
operableUsers: 'Operable Users',
enabled: 'Enabled',
creatorName: 'Creator',
createTime: 'Created At',
updateTime: 'Updated At',
searchPlaceholder: 'Enter task name',
createTitle: 'Create Inspection Task',
editTitle: 'Edit Inspection Task',
empty: 'No inspection task data',
loadEditFailed: 'Failed to load edit data',
confirmDeleteContent: 'Confirm delete this inspection task [{name}]?',
placeholderName: 'Enter task name',
placeholderTaskType: 'Select task type',
placeholderMoldList: 'Select molds',
placeholderProjectForm: 'Select inspection plans',
placeholderStartDate: 'Select start date',
placeholderEndDate: 'Select end date',
placeholderCron: 'Enter cron expression',
placeholderOperableUsers: 'Select operable users',
validatorNameRequired: 'Task name is required',
validatorTaskTypeRequired: 'Task type is required',
validatorMoldListRequired: 'Mold list is required',
validatorProjectFormRequired: 'Inspection plan is required',
validatorDateRangeRequired: 'Date range is required',
createTicketSuccess: 'Work order created successfully',
createTicketFail: 'Work order creation failed',
moldSelectTitle: 'Select Molds',
planSelectTitle: 'Select Inspection Plans',
userSelectTitle: 'Select Operable Users'
},
mine: {
clickLogin: 'Tap to sign in',
username: 'Username: {name}',

@ -73,7 +73,9 @@ const literalMap = {
'点检项库': 'moldInspectionItems.moduleName',
'点检项库详情': 'moldInspectionItems.detailTitle',
'点检模板': 'moldInspectionPlan.moduleName',
'点检模板详情': 'moldInspectionPlan.detailTitle'
'点检模板详情': 'moldInspectionPlan.detailTitle',
'点检任务': 'moldTaskConfig.moduleName',
'点检任务详情': 'moldTaskConfig.detailTitle'
}
function applyTabBarLanguage() {

@ -362,6 +362,52 @@ export default {
inspectionMethod: '检验方式',
judgmentCriteria: '判定基准'
},
moldTaskConfig: {
moduleName: '点检任务',
subTitle: '模具管理点检任务维护',
detailTitle: '点检任务详情',
basicInfo: '基础信息',
name: '任务名称',
taskType: '任务类型',
taskTypeInspect: '点检',
taskTypeMaintain: '保养',
moldList: '模具列表',
projectForm: '点检模板',
projectFormName: '项目方案',
dateRange: '有效日期',
startDate: '开始日期',
endDate: '结束日期',
cronExpression: 'Cron表达式',
operableUsers: '可操作用户',
enabled: '是否启用',
creatorName: '创建人',
createTime: '创建时间',
updateTime: '更新时间',
searchPlaceholder: '请输入任务名称',
createTitle: '新增点检任务',
editTitle: '编辑点检任务',
empty: '暂无点检任务数据',
loadEditFailed: '加载编辑数据失败',
confirmDeleteContent: '确认删除该点检任务【{name}】吗?',
placeholderName: '请输入任务名称',
placeholderTaskType: '请选择任务类型',
placeholderMoldList: '请选择模具',
placeholderProjectForm: '请选择点检模板',
placeholderStartDate: '选择开始日期',
placeholderEndDate: '选择结束日期',
placeholderCron: '请输入Cron表达式',
placeholderOperableUsers: '请选择可操作用户',
validatorNameRequired: '任务名称不能为空',
validatorTaskTypeRequired: '任务类型不能为空',
validatorMoldListRequired: '模具列表不能为空',
validatorProjectFormRequired: '点检模板不能为空',
validatorDateRangeRequired: '有效日期不能为空',
createTicketSuccess: '工单创建成功',
createTicketFail: '工单创建失败',
moldSelectTitle: '选择模具',
planSelectTitle: '选择点检模板',
userSelectTitle: '选择可操作用户'
},
mine: {
clickLogin: '点击登录',
username: '用户名:{name}',

@ -519,6 +519,20 @@
"navigationStyle": "custom"
}
},
{
"path": "moldTaskConfiguration/index",
"style": {
"navigationBarTitleText": "点检任务",
"navigationStyle": "custom"
}
},
{
"path": "moldTaskConfiguration/detail",
"style": {
"navigationBarTitleText": "点检任务详情",
"navigationStyle": "custom"
}
},
{
"path": "planList/index",
"style": {

@ -273,9 +273,9 @@
</view>
<view class="function-item" @click="handleClick('点检任务')">
<view class="function-icon" style="background: rgba(0, 188, 212, 0.1);">
<text class="icon-inner"></text>
<uni-icons type="checkbox" size="22" color="#00bcd4"></uni-icons>
</view>
<text class="function-name">点检任务</text>
<text class="function-name">{{ t('moldTaskConfig.moduleName') }}</text>
</view>
<view class="function-item" @click="handleClick('点检记录')">
<view class="function-icon" style="background: rgba(0, 188, 212, 0.1);">
@ -382,7 +382,7 @@ function handleClick(name) {
moldInspectionItems: '/pages_function/pages/moldInspectionItems/index',
'点检项库': '',
'点检模板': '/pages_function/pages/moldInspectionPlan/index',
'点检任务': '',
'点检任务': '/pages_function/pages/moldTaskConfiguration/index',
'点检记录': '',
'维修项目': '',
'维修单': ''

@ -0,0 +1,164 @@
<template>
<view class="page-container">
<view class="fixed-header">
<AppTitleHeader :title="t('moldTaskConfig.detailTitle')" />
</view>
<scroll-view scroll-y class="detail-scroll">
<view class="content-section">
<!-- 基础信息 -->
<view class="info-card">
<view class="card-title">{{ t('moldTaskConfig.basicInfo') }}</view>
<view class="info-list">
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.name') }}</text>
<text class="info-value">{{ textValue(detailData.name) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.taskType') }}</text>
<text class="info-value">{{ taskTypeText }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.moldList') }}</text>
<text class="info-value">{{ moldListText }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.projectFormName') }}</text>
<text class="info-value">{{ textValue(detailData.projectFormName) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.dateRange') }}</text>
<text class="info-value">{{ formatDate(detailData.startDate) }} ~ {{ formatDate(detailData.endDate) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.cronExpression') }}</text>
<text class="info-value">{{ textValue(detailData.cronExpression) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.operableUsers') }}</text>
<text class="info-value">{{ operableUsersText }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.enabled') }}</text>
<text :class="['info-value', enabledClass]">{{ enabledText }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.creatorName') }}</text>
<text class="info-value">{{ textValue(detailData.creatorName) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.createTime') }}</text>
<text class="info-value">{{ formatDateTime(detailData.createTime) }}</text>
</view>
<view class="info-row">
<text class="info-label">{{ t('moldTaskConfig.updateTime') }}</text>
<text class="info-value">{{ formatDateTime(detailData.updateTime) }}</text>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { computed, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
const { t } = useI18n()
const detailData = reactive({})
const taskTypeText = computed(() => {
const v = detailData.taskType
if (v === 1) return t('moldTaskConfig.taskTypeInspect')
if (v === 2) return t('moldTaskConfig.taskTypeMaintain')
return textValue(v)
})
const enabledText = computed(() => {
const v = detailData.enabled
if (v === true || v === 1 || v === '1' || v === 'true') return t('functionCommon.yes')
if (v === false || v === 0 || v === '0' || v === 'false') return t('functionCommon.no')
return textValue(v)
})
const enabledClass = computed(() => {
const v = detailData.enabled
if (v === true || v === 1 || v === '1' || v === 'true') return 'text-success'
if (v === false || v === 0 || v === '0' || v === 'false') return 'text-danger'
return ''
})
const moldListText = computed(() => {
const v = detailData.moldList
if (!v) return '-'
if (Array.isArray(v)) return v.join(', ') || '-'
return textValue(v)
})
const operableUsersText = computed(() => {
const v = detailData.operableUsers
if (!v) return '-'
if (Array.isArray(v)) return v.join(', ') || '-'
return textValue(v)
})
function textValue(v) {
if (v === 0) return '0'
if (v === null || v === undefined) return '-'
const s = String(v).trim()
return s || '-'
}
function formatDate(v) {
if (!v) return '-'
if (Array.isArray(v) && v.length >= 3) {
const [y, m, d] = v
const p = (n) => String(n).padStart(2, '0')
return `${y}-${p(m)}-${p(d)}`
}
const s = String(v).trim().substring(0, 10)
return s || '-'
}
function formatDateTime(v) {
if (!v) return '-'
if (Array.isArray(v) && v.length >= 3) {
const [y, m, d, hh = 0, mm = 0, ss = 0] = v
const p = (n) => String(n).padStart(2, '0')
return `${y}-${p(m)}-${p(d)} ${p(hh)}:${p(mm)}:${p(ss)}`
}
const d = new Date(Number(v))
if (Number.isNaN(d.getTime())) return textValue(v)
const p = (n) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
}
onLoad(async () => {
try {
const cached = uni.getStorageSync('moldTaskConfigDetail')
if (cached) {
const data = JSON.parse(cached)
Object.assign(detailData, data)
uni.removeStorageSync('moldTaskConfigDetail')
}
} catch (e) {}
})
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background-color: #f0f2f5; }
.fixed-header { position: sticky; top: 0; z-index: 20; }
.detail-scroll { height: calc(100vh - 88rpx); }
.content-section { padding: 0 24rpx 24rpx; }
.info-card { margin-top: 20rpx; background: #fff; border-radius: 20rpx; padding: 28rpx; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05); }
.card-title { font-size: 32rpx; color: #1a3a5c; font-weight: 700; margin-bottom: 18rpx; }
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 18rpx 0; border-bottom: 1rpx solid #edf0f3; }
.info-label { font-size: 27rpx; color: #8a9099; width: 220rpx; }
.info-value { flex: 1; text-align: right; font-size: 28rpx; color: #303133; line-height: 1.45; }
.text-success { color: #18bc37; }
.text-danger { color: #e34d59; }
</style>

@ -0,0 +1,775 @@
<template>
<view class="page-container">
<AppTitleHeader :title="t('moldTaskConfig.moduleName')" :subTitle="t('moldTaskConfig.subTitle')" :showSubTitle="true" />
<view class="search-card">
<view class="search-row">
<view class="search-input-wrap">
<text class="iconfont icon-search search-icon"></text>
<input v-model="searchKeyword" class="search-input" :placeholder="t('moldTaskConfig.searchPlaceholder')" @confirm="handleSearch" />
</view>
<view class="search-btn" @click="handleSearch">{{ t('functionCommon.search') }}</view>
</view>
</view>
<scroll-view scroll-y class="list-scroll" :scroll-top="scrollTop" @scroll="onScroll" @scrolltolower="loadMore" :lower-threshold="80">
<view class="list-wrap">
<view v-for="item in list" :key="item.id" class="type-card" @click="openDetail(item)">
<view class="card-header">
<view class="header-left">
<text class="type-name">{{ textValue(item.name) }}</text>
<view class="tag-row">
<text :class="['type-code', item.taskType === 1 ? 'tag-inspect' : 'tag-maintain']">{{ taskTypeLabel(item.taskType) }}</text>
</view>
</view>
</view>
<view class="card-body">
<view class="row">
<text class="label">{{ t('moldTaskConfig.projectFormName') }}</text>
<text class="value">{{ textValue(item.projectFormName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldTaskConfig.dateRange') }}</text>
<text class="value">{{ formatDate(item.startDate) }} ~ {{ formatDate(item.endDate) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldTaskConfig.enabled') }}</text>
<text :class="['value', item.enabled ? 'text-success' : 'text-danger']">{{ enabledText(item.enabled) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldTaskConfig.creatorName') }}</text>
<text class="value">{{ textValue(item.creatorName) }}</text>
</view>
<view class="row">
<text class="label">{{ t('moldTaskConfig.createTime') }}</text>
<text class="value">{{ formatDateTime(item.createTime) }}</text>
</view>
</view>
<view class="card-actions">
<view class="action-btn ticket-btn" @click.stop="handleCreateTicket(item)">
<uni-icons type="paperplane" size="18" color="#ffffff"></uni-icons>
</view>
<view class="action-btn edit-btn" @click.stop="openEdit(item)">
<uni-icons type="compose" size="18" color="#ffffff"></uni-icons>
</view>
<view class="action-btn delete-btn" @click.stop="confirmDelete(item)">
<uni-icons type="trash" size="18" color="#ffffff"></uni-icons>
</view>
</view>
</view>
<view v-if="loading && pageNo === 1" class="hint">{{ t('functionCommon.loading') }}</view>
<view v-else-if="!list.length" class="hint">{{ t('moldTaskConfig.empty') }}</view>
<view v-else-if="loadingMore" class="hint">{{ t('functionCommon.loadingMore') }}</view>
<view v-else-if="finished" class="hint">{{ t('functionCommon.noMoreData') }}</view>
</view>
</scroll-view>
<view class="fab-btn" @click="openCreate">
<uni-icons type="plusempty" size="30" color="#fff"></uni-icons>
</view>
<view v-if="showGoTop" class="go-top-btn" @click="goTop">
<uni-icons type="arrow-up" size="20" color="#1a3a5c"></uni-icons>
</view>
<!-- 新增/编辑弹框 -->
<uni-popup ref="formPopupRef" type="center" background-color="#fff">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">{{ formMode === 'create' ? t('moldTaskConfig.createTitle') : t('moldTaskConfig.editTitle') }}</text>
<view class="popup-close" @click="closeForm">
<text class="close-icon">×</text>
</view>
</view>
<scroll-view scroll-y class="form-scroll">
<view class="form-content">
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.name') }} <text class="required-star">*</text></text>
<input v-model="formData.name" class="form-input" type="text" :placeholder="t('moldTaskConfig.placeholderName')" />
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.taskType') }} <text class="required-star">*</text></text>
<picker mode="selector" :range="taskTypeOptions" range-key="label" :value="taskTypeIndex" @change="onTaskTypeChange">
<view class="picker-view">{{ currentTaskTypeLabel || t('moldTaskConfig.placeholderTaskType') }}</view>
</picker>
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.moldList') }} <text class="required-star">*</text></text>
<view class="multi-select-wrap" @click="openMoldPicker">
<text v-if="selectedMoldLabels.length" class="selected-text">{{ selectedMoldLabels.join(', ') }}</text>
<text v-else class="placeholder-text">{{ t('moldTaskConfig.placeholderMoldList') }}</text>
</view>
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.projectForm') }} <text class="required-star">*</text></text>
<view class="multi-select-wrap" @click="openPlanPicker">
<text v-if="selectedPlanLabels.length" class="selected-text">{{ selectedPlanLabels.join(', ') }}</text>
<text v-else class="placeholder-text">{{ t('moldTaskConfig.placeholderProjectForm') }}</text>
</view>
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.dateRange') }} <text class="required-star">*</text></text>
<view class="date-range-wrap">
<picker mode="date" :value="formData.startDate" @change="onStartDateChange">
<view class="picker-view date-picker">{{ formData.startDate || t('moldTaskConfig.placeholderStartDate') }}</view>
</picker>
<text class="date-separator">~</text>
<picker mode="date" :value="formData.endDate" @change="onEndDateChange">
<view class="picker-view date-picker">{{ formData.endDate || t('moldTaskConfig.placeholderEndDate') }}</view>
</picker>
</view>
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.cronExpression') }}</text>
<input v-model="formData.cronExpression" class="form-input" type="text" :placeholder="t('moldTaskConfig.placeholderCron')" />
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.operableUsers') }}</text>
<view class="multi-select-wrap" @click="openUserPicker">
<text v-if="selectedUserLabels.length" class="selected-text">{{ selectedUserLabels.join(', ') }}</text>
<text v-else class="placeholder-text">{{ t('moldTaskConfig.placeholderOperableUsers') }}</text>
</view>
</view>
<view class="form-item">
<text class="form-label">{{ t('moldTaskConfig.enabled') }} <text class="required-star">*</text></text>
<view class="radio-wrap">
<view :class="['radio-item', formData.enabled ? 'radio-active' : '']" @click="formData.enabled = true">
<text :class="['radio-text', formData.enabled ? 'radio-text-active' : '']">{{ t('functionCommon.yes') }}</text>
</view>
<view :class="['radio-item', !formData.enabled ? 'radio-active' : '']" @click="formData.enabled = false">
<text :class="['radio-text', !formData.enabled ? 'radio-text-active' : '']">{{ t('functionCommon.no') }}</text>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="form-footer">
<view class="footer-btn cancel-btn" @click="closeForm"><text class="btn-text">{{ t('functionCommon.cancel') }}</text></view>
<view class="footer-btn confirm-btn" @click="submitForm"><text class="btn-text">{{ t('functionCommon.save') }}</text></view>
</view>
</view>
</uni-popup>
<!-- 模具选择弹框 -->
<uni-popup ref="moldPopupRef" type="center" background-color="#fff">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">{{ t('moldTaskConfig.moldSelectTitle') }}</text>
<view class="popup-close" @click="closeMoldPicker">
<text class="close-icon">×</text>
</view>
</view>
<scroll-view scroll-y class="subject-scroll">
<view class="subject-list">
<view v-for="item in moldOptions" :key="item.id" class="subject-item" @click="toggleMold(item)">
<view class="checkbox-wrap">
<view :class="['checkbox-box', isMoldSelected(item.id) ? 'checked' : '']">
<uni-icons v-if="isMoldSelected(item.id)" type="checkmarkempty" size="16" color="#fff"></uni-icons>
</view>
</view>
<view class="subject-info">
<text class="subject-name">{{ item.name }}</text>
</view>
</view>
</view>
</scroll-view>
<view class="form-footer">
<view class="footer-btn cancel-btn" @click="closeMoldPicker"><text class="btn-text">{{ t('functionCommon.cancel') }}</text></view>
<view class="footer-btn confirm-btn" @click="confirmMoldSelect"><text class="btn-text">{{ t('functionCommon.save') }}</text></view>
</view>
</view>
</uni-popup>
<!-- 点检模板选择弹框 -->
<uni-popup ref="planPopupRef" type="center" background-color="#fff">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">{{ t('moldTaskConfig.planSelectTitle') }}</text>
<view class="popup-close" @click="closePlanPicker">
<text class="close-icon">×</text>
</view>
</view>
<scroll-view scroll-y class="subject-scroll">
<view class="subject-list">
<view v-for="item in planOptions" :key="item.id" class="subject-item" @click="togglePlan(item)">
<view class="checkbox-wrap">
<view :class="['checkbox-box', isPlanSelected(item.id) ? 'checked' : '']">
<uni-icons v-if="isPlanSelected(item.id)" type="checkmarkempty" size="16" color="#fff"></uni-icons>
</view>
</view>
<view class="subject-info">
<text class="subject-name">{{ item.planName }}</text>
</view>
</view>
</view>
</scroll-view>
<view class="form-footer">
<view class="footer-btn cancel-btn" @click="closePlanPicker"><text class="btn-text">{{ t('functionCommon.cancel') }}</text></view>
<view class="footer-btn confirm-btn" @click="confirmPlanSelect"><text class="btn-text">{{ t('functionCommon.save') }}</text></view>
</view>
</view>
</uni-popup>
<!-- 用户选择弹框 -->
<uni-popup ref="userPopupRef" type="center" background-color="#fff">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">{{ t('moldTaskConfig.userSelectTitle') }}</text>
<view class="popup-close" @click="closeUserPicker">
<text class="close-icon">×</text>
</view>
</view>
<scroll-view scroll-y class="subject-scroll">
<view class="subject-list">
<view v-for="item in userOptions" :key="item.id" class="subject-item" @click="toggleUser(item)">
<view class="checkbox-wrap">
<view :class="['checkbox-box', isUserSelected(item.id) ? 'checked' : '']">
<uni-icons v-if="isUserSelected(item.id)" type="checkmarkempty" size="16" color="#fff"></uni-icons>
</view>
</view>
<view class="subject-info">
<text class="subject-name">{{ item.nickname }}</text>
</view>
</view>
</view>
</scroll-view>
<view class="form-footer">
<view class="footer-btn cancel-btn" @click="closeUserPicker"><text class="btn-text">{{ t('functionCommon.cancel') }}</text></view>
<view class="footer-btn confirm-btn" @click="confirmUserSelect"><text class="btn-text">{{ t('functionCommon.save') }}</text></view>
</view>
</view>
</uni-popup>
</view>
</template>
<script setup>
import { ref, reactive, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import AppTitleHeader from '@/components/common/AppTitleHeader.vue'
import { getTaskManagementPage, createTaskManagement, updateTaskManagement, deleteTaskManagement, createTaskManagementTicket } from '@/api/mes/moldTaskConfiguration'
import { getMoldList } from '@/api/mes/mold'
import { getMoldInspectionPlanPage } from '@/api/mes/moldInspectionPlan'
import { getSimpleUserList } from '@/api/mes/moldget'
const { t } = useI18n()
const formPopupRef = ref(null)
const moldPopupRef = ref(null)
const planPopupRef = ref(null)
const userPopupRef = ref(null)
const searchKeyword = ref('')
const list = ref([])
const loading = ref(false)
const loadingMore = ref(false)
const finished = ref(false)
const pageNo = ref(1)
const pageSize = ref(10)
const scrollTop = ref(0)
const showGoTop = ref(false)
const formMode = ref('create')
const ticketLoadingId = ref(null)
const taskTypeOptions = computed(() => [
{ label: t('moldTaskConfig.taskTypeInspect'), value: 1 },
{ label: t('moldTaskConfig.taskTypeMaintain'), value: 2 }
])
const formData = reactive({
id: undefined,
name: '',
taskType: undefined,
moldList: [],
projectForm: [],
startDate: '',
endDate: '',
cronExpression: '',
operableUsers: [],
enabled: true
})
const taskTypeIndex = computed(() => {
const idx = taskTypeOptions.value.findIndex(o => o.value === formData.taskType)
return idx === -1 ? 0 : idx
})
const currentTaskTypeLabel = computed(() => {
const opt = taskTypeOptions.value.find(o => o.value === formData.taskType)
return opt ? opt.label : ''
})
const moldOptions = ref([])
const planOptions = ref([])
const userOptions = ref([])
const tempMoldIds = ref([])
const tempPlanIds = ref([])
const tempUserIds = ref([])
const selectedMoldLabels = computed(() => {
return formData.moldList.map(id => {
const item = moldOptions.value.find(m => String(m.id) === String(id))
return item ? item.name : id
})
})
const selectedPlanLabels = computed(() => {
return formData.projectForm.map(id => {
const item = planOptions.value.find(p => String(p.id) === String(id))
return item ? item.planName : id
})
})
const selectedUserLabels = computed(() => {
return formData.operableUsers.map(id => {
const item = userOptions.value.find(u => String(u.id) === String(id))
return item ? item.nickname : id
})
})
onLoad(async () => {
await fetchList(true)
loadOptions()
})
async function loadOptions() {
try {
const [moldRes, planRes, userRes] = await Promise.all([
getMoldList(),
getMoldInspectionPlanPage({ pageNo: 1, pageSize: 10 }),
getSimpleUserList()
])
const moldRoot = moldRes && moldRes.data !== undefined ? moldRes.data : moldRes
moldOptions.value = Array.isArray(moldRoot) ? moldRoot : (moldRoot?.list || [])
const planRoot = planRes && planRes.data !== undefined ? planRes.data : planRes
planOptions.value = planRoot?.list || []
const userRoot = userRes && userRes.data !== undefined ? userRes.data : userRes
userOptions.value = Array.isArray(userRoot) ? userRoot : (userRoot?.list || [])
} catch (e) {}
}
async function handleSearch() {
await fetchList(true)
}
async function loadMore() {
if (loading.value || loadingMore.value || finished.value) return
pageNo.value += 1
await fetchList(false)
}
async function fetchList(reset) {
if (reset) {
pageNo.value = 1
finished.value = false
}
if (pageNo.value === 1) {
loading.value = true
} else {
loadingMore.value = true
}
try {
const params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
name: searchKeyword.value.trim() || undefined
}
const res = await getTaskManagementPage(params)
const page = normalizePageData(res)
if (reset) {
list.value = page.list
} else {
list.value = [...list.value, ...page.list]
}
finished.value = list.value.length >= page.total || page.list.length < pageSize.value
} catch (e) {
if (!reset) pageNo.value = Math.max(1, pageNo.value - 1)
uni.showToast({ title: t('functionCommon.loadFailed'), icon: 'none' })
} finally {
loading.value = false
loadingMore.value = false
}
}
function normalizePageData(res) {
const root = res && res.data !== undefined ? res.data : res
const candidateList = root?.list || root?.rows || root?.records || root?.data?.list || root?.data?.rows || root?.data?.records || []
const candidateTotal = root?.total ?? root?.data?.total ?? (Array.isArray(candidateList) ? candidateList.length : 0)
return { list: Array.isArray(candidateList) ? candidateList : [], total: Number(candidateTotal || 0) }
}
function onScroll(e) {
showGoTop.value = (e?.detail?.scrollTop || 0) > 600
}
function goTop() {
scrollTop.value = 0
}
function taskTypeLabel(v) {
if (v === 1) return t('moldTaskConfig.taskTypeInspect')
if (v === 2) return t('moldTaskConfig.taskTypeMaintain')
return textValue(v)
}
function enabledText(v) {
if (v === true || v === 1 || v === '1' || v === 'true') return t('functionCommon.yes')
if (v === false || v === 0 || v === '0' || v === 'false') return t('functionCommon.no')
return textValue(v)
}
function textValue(v) {
if (v === 0) return '0'
if (v === null || v === undefined) return '-'
const s = String(v).trim()
return s || '-'
}
function formatDate(v) {
if (!v) return '-'
if (Array.isArray(v) && v.length >= 3) {
const [y, m, d] = v
const p = (n) => String(n).padStart(2, '0')
return `${y}-${p(m)}-${p(d)}`
}
const s = String(v).trim().substring(0, 10)
return s || '-'
}
function formatDateTime(v) {
if (!v) return '-'
if (Array.isArray(v) && v.length >= 3) {
const [y, m, d, hh = 0, mm = 0, ss = 0] = v
const p = (n) => String(n).padStart(2, '0')
return `${y}-${p(m)}-${p(d)} ${p(hh)}:${p(mm)}:${p(ss)}`
}
const d = new Date(Number(v))
if (Number.isNaN(d.getTime())) return textValue(v)
const p = (n) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
}
function openDetail(item) {
if (!item?.id) {
uni.showToast({ title: t('functionCommon.noIdView'), icon: 'none' })
return
}
uni.setStorageSync('moldTaskConfigDetail', JSON.stringify(item))
uni.navigateTo({
url: `/pages_function/pages/moldTaskConfiguration/detail?id=${encodeURIComponent(String(item.id))}`
})
}
function openCreate() {
formMode.value = 'create'
resetForm()
formPopupRef.value?.open()
}
async function openEdit(item) {
if (!item?.id) {
uni.showToast({ title: t('functionCommon.noIdEdit'), icon: 'none' })
return
}
try {
const res = await getTaskManagementPage({ pageNo: 1, pageSize: 1, id: item.id })
const page = normalizePageData(res)
const detail = page.list.find(r => r.id === item.id) || item
formMode.value = 'update'
formData.id = detail.id
formData.name = detail.name || ''
formData.taskType = detail.taskType
formData.moldList = parseIdsValue(detail.moldList)
formData.projectForm = parseIdsValue(detail.projectForm)
if (!formData.projectForm.length && detail.projectFormName) {
const names = parseIdsValue(detail.projectFormName)
formData.projectForm = names.map(name => {
const p = planOptions.value.find(o => o.planName === name)
return p ? String(p.id) : null
}).filter(Boolean)
}
formData.startDate = detail.startDate || ''
formData.endDate = detail.endDate || ''
formData.cronExpression = detail.cronExpression || ''
formData.operableUsers = parseIdsValue(detail.operableUsers)
formData.enabled = detail.enabled === true || detail.enabled === 'true' || detail.enabled === 1
formPopupRef.value?.open()
} catch (e) {
uni.showToast({ title: t('moldTaskConfig.loadEditFailed'), icon: 'none' })
}
}
function parseIdsValue(value) {
if (!value) return []
if (Array.isArray(value)) return value.map(v => String(v).trim()).filter(Boolean)
return String(value).split(',').map(v => v.trim()).filter(Boolean)
}
function toCommaSeparatedIds(value) {
const ids = parseIdsValue(value)
return ids.length ? ids.join(',') : undefined
}
async function confirmDelete(item) {
if (!item?.id) {
uni.showToast({ title: t('functionCommon.noIdDelete'), icon: 'none' })
return
}
uni.showModal({
title: t('functionCommon.confirmDelete'),
content: t('moldTaskConfig.confirmDeleteContent', { name: textValue(item.name) }),
success: async (res) => {
if (!res.confirm) return
try {
await deleteTaskManagement([item.id])
uni.showToast({ title: t('functionCommon.deleteSuccess'), icon: 'success' })
await fetchList(true)
} catch (e) {
uni.showToast({ title: t('functionCommon.deleteFailed'), icon: 'none' })
}
}
})
}
async function handleCreateTicket(item) {
if (!item?.id) return
if (ticketLoadingId.value) return
ticketLoadingId.value = item.id
try {
await createTaskManagementTicket(item.id)
uni.showToast({ title: t('moldTaskConfig.createTicketSuccess'), icon: 'success' })
} catch (e) {
uni.showToast({ title: t('moldTaskConfig.createTicketFail'), icon: 'none' })
} finally {
ticketLoadingId.value = null
}
}
function closeForm() {
formPopupRef.value?.close()
}
function resetForm() {
formData.id = undefined
formData.name = ''
formData.taskType = undefined
formData.moldList = []
formData.projectForm = []
formData.startDate = ''
formData.endDate = ''
formData.cronExpression = ''
formData.operableUsers = []
formData.enabled = true
}
function onTaskTypeChange(e) {
const idx = e.detail.value
formData.taskType = taskTypeOptions.value[idx]?.value
}
function onStartDateChange(e) {
formData.startDate = e.detail.value
}
function onEndDateChange(e) {
formData.endDate = e.detail.value
}
async function submitForm() {
if (!formData.name.trim()) {
uni.showToast({ title: t('moldTaskConfig.validatorNameRequired'), icon: 'none' })
return
}
if (!formData.taskType) {
uni.showToast({ title: t('moldTaskConfig.validatorTaskTypeRequired'), icon: 'none' })
return
}
if (!formData.moldList.length) {
uni.showToast({ title: t('moldTaskConfig.validatorMoldListRequired'), icon: 'none' })
return
}
if (!formData.projectForm.length) {
uni.showToast({ title: t('moldTaskConfig.validatorProjectFormRequired'), icon: 'none' })
return
}
if (!formData.startDate || !formData.endDate) {
uni.showToast({ title: t('moldTaskConfig.validatorDateRangeRequired'), icon: 'none' })
return
}
const payload = {
id: formMode.value === 'update' ? formData.id : undefined,
name: formData.name.trim(),
taskType: formData.taskType,
moldList: toCommaSeparatedIds(formData.moldList),
projectForm: toCommaSeparatedIds(formData.projectForm),
startDate: formData.startDate,
endDate: formData.endDate,
cronExpression: formData.cronExpression.trim() || undefined,
operableUsers: toCommaSeparatedIds(formData.operableUsers),
enabled: formData.enabled
}
try {
if (formMode.value === 'create') {
await createTaskManagement(payload)
uni.showToast({ title: t('functionCommon.createSuccess'), icon: 'success' })
} else {
await updateTaskManagement(payload)
uni.showToast({ title: t('functionCommon.updateSuccess'), icon: 'success' })
}
closeForm()
await fetchList(true)
} catch (e) {
uni.showToast({ title: t('functionCommon.saveFailed'), icon: 'none' })
}
}
function openMoldPicker() {
tempMoldIds.value = [...formData.moldList]
moldPopupRef.value?.open()
}
function closeMoldPicker() {
moldPopupRef.value?.close()
}
function isMoldSelected(id) {
return tempMoldIds.value.includes(String(id))
}
function toggleMold(item) {
const id = String(item.id)
const idx = tempMoldIds.value.indexOf(id)
if (idx === -1) {
tempMoldIds.value.push(id)
} else {
tempMoldIds.value.splice(idx, 1)
}
}
function confirmMoldSelect() {
formData.moldList = [...tempMoldIds.value]
closeMoldPicker()
}
function openPlanPicker() {
tempPlanIds.value = [...formData.projectForm]
planPopupRef.value?.open()
}
function closePlanPicker() {
planPopupRef.value?.close()
}
function isPlanSelected(id) {
return tempPlanIds.value.includes(String(id))
}
function togglePlan(item) {
const id = String(item.id)
const idx = tempPlanIds.value.indexOf(id)
if (idx === -1) {
tempPlanIds.value.push(id)
} else {
tempPlanIds.value.splice(idx, 1)
}
}
function confirmPlanSelect() {
formData.projectForm = [...tempPlanIds.value]
closePlanPicker()
}
function openUserPicker() {
tempUserIds.value = [...formData.operableUsers]
userPopupRef.value?.open()
}
function closeUserPicker() {
userPopupRef.value?.close()
}
function isUserSelected(id) {
return tempUserIds.value.includes(String(id))
}
function toggleUser(item) {
const id = String(item.id)
const idx = tempUserIds.value.indexOf(id)
if (idx === -1) {
tempUserIds.value.push(id)
} else {
tempUserIds.value.splice(idx, 1)
}
}
function confirmUserSelect() {
formData.operableUsers = [...tempUserIds.value]
closeUserPicker()
}
</script>
<style lang="scss" scoped>
.page-container { min-height: 100vh; background-color: #f0f2f5; }
.search-card { background: #ffffff; margin: 20rpx 24rpx; border-radius: 18rpx; padding: 20rpx; box-shadow: 0 4rpx 18rpx rgba(0, 0, 0, 0.04); }
.search-row { display: flex; align-items: center; gap: 16rpx; }
.search-input-wrap { flex: 1; display: flex; align-items: center; background: #f5f7fa; border-radius: 44rpx; padding: 0 20rpx; }
.search-icon { margin-right: 16rpx; font-size: 34rpx; color: #666; }
.search-input { flex: 1; height: 72rpx; font-size: 28rpx; color: #333; background: transparent; }
.search-btn { min-width: 120rpx; height: 72rpx; background: linear-gradient(135deg, #1a3a5c 0%, #2d5a87 100%); border-radius: 14rpx; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 28rpx; font-weight: 600; }
.list-scroll { height: calc(100vh - 280rpx); }
.list-wrap { padding: 0 24rpx 130rpx; }
.type-card { background: #ffffff; border-radius: 18rpx; padding: 24rpx; margin-bottom: 18rpx; box-shadow: 0 4rpx 18rpx rgba(0, 0, 0, 0.05); }
.card-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 18rpx; border-bottom: 1rpx solid #edf0f3; }
.header-left { display: flex; flex-direction: column; gap: 8rpx; flex: 1; }
.type-name { font-size: 32rpx; font-weight: 700; color: #1f2d3d; }
.tag-row { display: flex; align-items: center; }
.type-code { font-size: 24rpx; padding: 4rpx 14rpx; border-radius: 8rpx; }
.tag-inspect { color: #1a3a5c; background: rgba(26, 58, 92, 0.08); }
.tag-maintain { color: #18bc37; background: rgba(24, 188, 55, 0.08); }
.card-actions { margin-top: 24rpx; display: flex; justify-content: flex-end; gap: 14rpx; }
.action-btn { width: 60rpx; height: 60rpx; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; }
.edit-btn { background: #1a3a5c; }
.delete-btn { background: #e34d59; }
.ticket-btn { background: #18bc37; }
.card-body { padding-top: 16rpx; }
.row { display: flex; justify-content: space-between; align-items: center; margin-top: 12rpx; }
.label { font-size: 26rpx; color: #8a9099; }
.value { font-size: 27rpx; color: #30363d; max-width: 62%; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-success { color: #18bc37; }
.text-danger { color: #e34d59; }
.hint { text-align: center; color: #909399; padding: 24rpx 0; }
.fab-btn { position: fixed; right: 28rpx; bottom: 140rpx; width: 96rpx; height: 96rpx; border-radius: 48rpx; background: linear-gradient(135deg, #1a3a5c 0%, #2d5a87 100%); display: flex; align-items: center; justify-content: center; box-shadow: 0 8rpx 24rpx rgba(26, 58, 92, 0.32); z-index: 99; }
.go-top-btn { position: fixed; right: 28rpx; bottom: 254rpx; width: 88rpx; height: 88rpx; border-radius: 44rpx; background: rgba(26, 58, 92, 0.9); display: flex; align-items: center; justify-content: center; z-index: 99; box-shadow: 0 6rpx 16rpx rgba(26, 58, 92, 0.25); }
.popup-content { width: 680rpx; max-height: 80vh; border-radius: 24rpx; overflow: hidden; }
.popup-header { padding: 24rpx; display: flex; align-items: center; justify-content: space-between; border-bottom: 1rpx solid #edf0f3; position: relative; }
.popup-title { font-size: 32rpx; color: #1a3a5c; font-weight: 700; }
.popup-close { position: absolute; right: 24rpx; top: 20rpx; width: 48rpx; height: 48rpx; display: flex; align-items: center; justify-content: center; }
.close-icon { font-size: 42rpx; color: #9aa0a6; line-height: 1; }
.form-scroll { max-height: calc(80vh - 180rpx); }
.form-content { padding: 22rpx 28rpx; }
.form-item { margin-bottom: 18rpx; }
.form-label { display: block; font-size: 25rpx; color: #5f6b7a; margin-bottom: 10rpx; }
.required-star { color: #e34d59; }
.form-input { min-height: 72rpx; background: #f7f9fc; border-radius: 12rpx; padding: 0 18rpx; display: flex; align-items: center; font-size: 26rpx; color: #2f3a45; }
.picker-view { min-height: 72rpx; background: #f7f9fc; border-radius: 12rpx; padding: 0 18rpx; display: flex; align-items: center; font-size: 26rpx; color: #2f3a45; }
.multi-select-wrap { min-height: 72rpx; background: #f7f9fc; border-radius: 12rpx; padding: 14rpx 18rpx; font-size: 26rpx; }
.selected-text { color: #2f3a45; word-break: break-all; }
.placeholder-text { color: #c0c4cc; }
.date-range-wrap { display: flex; align-items: center; gap: 12rpx; }
.date-picker { flex: 1; min-width: 0; }
.date-separator { font-size: 26rpx; color: #8a9099; }
.radio-wrap { display: flex; gap: 20rpx; }
.radio-item { min-width: 120rpx; height: 72rpx; background: #f7f9fc; border-radius: 12rpx; display: flex; align-items: center; justify-content: center; border: 2rpx solid #e4e7ed; }
.radio-active { border-color: #1a3a5c; background: rgba(26, 58, 92, 0.06); }
.radio-text { font-size: 26rpx; color: #8a9099; }
.radio-text-active { color: #1a3a5c; font-weight: 600; }
.form-footer { height: 88rpx; display: flex; border-top: 1rpx solid #edf0f3; }
.footer-btn { flex: 1; display: flex; align-items: center; justify-content: center; }
.btn-text { font-size: 28rpx; }
.cancel-btn { background: #f4f6fa; color: #5f6b7a; }
.confirm-btn { background: #1a3a5c; color: #fff; }
.subject-scroll { max-height: 50vh; }
.subject-list { padding: 16rpx 24rpx; }
.subject-item { display: flex; align-items: center; padding: 18rpx 0; border-bottom: 1rpx solid #f0f2f5; }
.checkbox-wrap { margin-right: 20rpx; }
.checkbox-box { width: 40rpx; height: 40rpx; border-radius: 8rpx; border: 2rpx solid #d0d5dd; display: flex; align-items: center; justify-content: center; background: #fff; }
.checkbox-box.checked { background: #1a3a5c; border-color: #1a3a5c; }
.subject-info { display: flex; flex-direction: column; gap: 4rpx; }
.subject-name { font-size: 28rpx; color: #30363d; }
</style>
Loading…
Cancel
Save