From 29be8639dc16b5d82bddc6099b1fa5cdca75f77a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 20 十月 2026 16:28:22 +0800
Subject: [PATCH] feat(import): 统一导入弹框与模板,修复模板日期格式及上传报错
---
src/views/CNAS/process/ensureResults/qualityControlPlan/index.vue | 113 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 79 insertions(+), 34 deletions(-)
diff --git a/src/views/CNAS/process/ensureResults/qualityControlPlan/index.vue b/src/views/CNAS/process/ensureResults/qualityControlPlan/index.vue
index 6df53e6..fe29f64 100644
--- a/src/views/CNAS/process/ensureResults/qualityControlPlan/index.vue
+++ b/src/views/CNAS/process/ensureResults/qualityControlPlan/index.vue
@@ -25,12 +25,6 @@
<div style="display: flex;justify-content: space-between">
<div style="display: flex;">
<div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
- <el-radio-group v-model="yearDetailForm.causeType" @change="getYearDetailPlan" size="small">
- <el-radio-button :value="1">瀹氭湡鐩戠潱</el-radio-button>
- <el-radio-button :value="2">鍔ㄦ�佺洃鐫�</el-radio-button>
- </el-radio-group>
- </div>
- <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
<span style="width: 88px;font-size: 14px;font-weight: 700;color: var(--lims-text-2);">鐩戞帶鐩殑</span>
<el-input v-model="yearDetailForm.supervisePurpose" placeholder="璇疯緭鍏�" size="small"
@keyup.enter="getYearDetailPlan"></el-input>
@@ -118,33 +112,46 @@
<!--瀵煎叆璁″垝-->
<el-dialog v-model="uploadDia" title="鏁版嵁瀵煎叆" width="500px" :close-on-click-modal="false"
:close-on-press-escape="false">
- <div style="display: flex; align-items: center;">
- <span style="width: 80px">骞翠唤锛�</span>
- <el-date-picker v-model="superviseYear" type="year" value-format="YYYY" clearable size="small" format="YYYY"
- placeholder="閫夋嫨骞�">
- </el-date-picker>
- <span style="width: 110px">鐩戠潱鍛橈細</span>
- <el-select v-model="recordUserIds" placeholder="璇烽�夋嫨" size="small" @change="splitList" :multiple-limit="2"
- filterable multiple style="width: 100%">
- <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </div>
- <div style="display: flex;align-items: center;margin: 10px 0">
- <div style="width: 60px">鎵瑰噯浜猴細</div>
- <el-select v-model="ratifyUserId" clearable filterable size="small" style="width: 50%;">
- <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
+ <el-form label-width="70px" size="small">
+ <el-form-item label="骞翠唤">
+ <el-date-picker v-model="superviseYear" type="year" value-format="YYYY" clearable format="YYYY"
+ placeholder="閫夋嫨骞�" style="width: 100%">
+ </el-date-picker>
+ </el-form-item>
+ <el-form-item label="鐩戠潱鍛�">
+ <el-select v-model="recordUserIds" placeholder="璇烽�夋嫨" @change="splitList" :multiple-limit="2"
+ filterable multiple style="width: 100%">
+ <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id"></el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鎵瑰噯浜�">
+ <el-select v-model="ratifyUserId" clearable filterable style="width: 100%">
+ <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id">
+ </el-option>
+ </el-select>
+ </el-form-item>
+ </el-form>
+ <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 8px 12px; border-radius: 4px; background: var(--el-color-primary-light-9); font-size: 13px;">
+ <span>绗竴娆″鍏ヨ鍏堜笅杞芥ā鏉匡紝鎸夋ā鏉挎牸寮忓~鍐欏悗鍐嶄笂浼犮��</span>
+ <el-button link type="primary" @click="downloadTemplate">涓嬭浇瀵煎叆妯℃澘</el-button>
</div>
<div style="margin: 0 auto;">
<el-upload ref="upload1" :action="action" :auto-upload="false" :file-list="fileList" :headers="uploadHeader"
- :limit="1" accept='.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
+ :limit="1" accept=".xls,.xlsx"
:on-change="beforeUpload" :on-error="onError" :on-success="handleSuccessUp" drag
:data="{ recordUserIds: recordUserIds1, superviseYear: superviseYear, ratifyUserId: ratifyUserId }"
name="file">
<lims-icon name="el-icon-upload"></lims-icon>
<div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
</el-upload>
+ </div>
+ <div style="margin-top: 10px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 20px;">
+ <div>鏀寔鏍煎紡锛�.xls銆�.xlsx锛涘崟涓枃浠朵笉瓒呰繃10MB銆�</div>
+ <div>鐩戠潱鏃ユ湡銆佺洃鎺ч」鐩�佽鐩戠潱浜哄憳涓哄繀濉」銆�</div>
+ <div>鐩戠潱鏃ユ湡寤鸿濉�滃勾.鏈堚�濓紙濡� 2026.3锛夛紱濉垚 2026-03-15 涔熷彲浠ワ紝绯荤粺浼氳嚜鍔ㄦ崲绠椾负 2026.3銆�</div>
+ <div>琚洃鐫d汉鍛樺繀椤诲~鍐欑郴缁熶腑宸插瓨鍦ㄧ殑浜哄憳濮撳悕锛屽惁鍒欐暣鎵瑰鍏ュけ璐ャ��</div>
+ <div>瀵煎叆鍙鍙栨ā鏉跨殑绗竴涓伐浣滆〃銆�</div>
+ <div style="color: var(--el-color-warning);">瀵煎叆鍚庤鍒掍负鈥滃緟鎵瑰噯鈥濓細闇�浣跨敤鎵�閫夋壒鍑嗕汉璐﹀彿鐧诲綍骞剁偣鍑烩�滄壒鍑嗏�濓紝鎵瑰噯鍚庢墠鑳戒笅鍙戝拰瀵煎嚭銆�</div>
</div>
<template #footer><span class="dialog-footer">
<el-button @click="closeUploadDia">鍙� 娑�</el-button>
@@ -208,7 +215,7 @@
} else if (params === 1) {
return '鎵瑰噯';
} else {
- return null;
+ return '寰呮壒鍑�';
}
},
formatType: (params) => {
@@ -217,7 +224,7 @@
} else if (params === 1) {
return 'success';
} else {
- return null;
+ return 'warning';
}
}
}, {
@@ -316,8 +323,7 @@
yearLoading: false,
yearDetailForm: {
supervisePurpose: '',
- superviseProject: '',
- causeType: 1
+ superviseProject: ''
},
yearDetailColumnData: [
{
@@ -570,13 +576,29 @@
this.yearPage.size = limit;
this.getYearPlanList();
},
+ // 涓嬭浇瀵煎叆妯℃澘
+ downloadTemplate() {
+ const link = document.createElement('a')
+ // 甯︾増鏈弬鏁伴伩鍏嶆祻瑙堝櫒缁х画浣跨敤缂撳瓨閲岀殑鏃фā鏉�
+ link.href = '/import-templates/璐ㄩ噺鐩戠潱璁″垝瀵煎叆妯℃澘.xlsx?v=3'
+ link.download = '璐ㄩ噺鐩戠潱璁″垝瀵煎叆妯℃澘.xlsx'
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
+ },
// 瀵煎叆娴佺▼
beforeUpload(file) {
+ if (!/\.(xls|xlsx)$/i.test(file.name || '')) {
+ this.$message.error('璇烽�夋嫨 .xls 鎴� .xlsx 鏍煎紡鐨勬枃浠�');
+ this.$refs.upload1.clearFiles()
+ return false;
+ }
if (file.size > 1024 * 1024 * 10) {
this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
this.$refs.upload1.clearFiles()
return false;
}
+ return true;
},
onError(err, file, fileList) {
this.$message.error('涓婁紶澶辫触')
@@ -585,7 +607,13 @@
handleSuccessUp(response) {
this.uploading = false;
if (response.code == 200) {
- this.$message.success('涓婁紶鎴愬姛');
+ const approver = this.userList.find(item => Number(item.id) === Number(this.ratifyUserId))
+ const approverName = approver ? approver.name : '鎵�閫夋壒鍑嗕汉'
+ if (Number(this.ratifyUserId) === Number(this.userId)) {
+ this.$message.success('瀵煎叆鎴愬姛锛岃鍦ㄥ垪琛ㄤ腑鐐瑰嚮鈥滄壒鍑嗏�濆畬鎴愭壒鍑嗭紝鎵瑰噯鍚庢墠鑳戒笅鍙戝拰瀵煎嚭')
+ } else {
+ this.$message.success(`瀵煎叆鎴愬姛锛岃鍒掑凡鎻愪氦缁�${approverName}鎵瑰噯锛涜鐢ㄨ璐﹀彿鐧诲綍鎵瑰噯锛屾壒鍑嗗悗鎵嶈兘涓嬪彂鍜屽鍑篳)
+ }
this.recordUserIds = []
this.superviseYear = ''
this.fileList = []
@@ -636,7 +664,12 @@
getUserList() {
// 璐ㄩ噺鐩戠潱闈㈠悜鍏ㄥ疄楠屽, 浜哄憳鍒楄〃涓嶆寜閮ㄩ棬绛涢��
selectUserCondition({ type: 1 }).then((res) => {
- this.userList = res.data || [];
+ const list = res.data || []
+ // 褰撳墠鐧诲綍鐢ㄦ埛鍙兘鍥犺鑹诧紙濡� admin锛夎鎺ュ彛杩囨护锛屼粛鍏佽閫夎嚜宸变綔涓烘壒鍑嗕汉锛岄伩鍏嶅鍏ュ悗鏃犱汉鍙壒鍑�
+ if (this.userId && !list.some(item => Number(item.id) === Number(this.userId))) {
+ list.unshift({ id: this.userId, name: this.nickName })
+ }
+ this.userList = list
})
},
// 鎵瑰噯
@@ -747,18 +780,30 @@
this.getYearDetailPlanList()
},
// 鑾峰彇骞村害鏄庣粏琛�
+ // 鐩戠潱鏃ユ湡缁熶竴鎴� "YYYY.M"锛氬吋瀹� 2026-03-15 / 2026/3/15 / 2026骞�3鏈�15鏃� 绛夊鍏ュ啓娉�
+ normalizeSuperviseMonth(value) {
+ if (!value) return value
+ const text = String(value).trim()
+ const matched = text.match(/^(\d{4})\s*[./骞�-]\s*(\d{1,2})(?:\s*[./鏈�-]\s*\d{1,2}\s*鏃�?)?$/)
+ if (!matched) return text
+ const month = Number(matched[2])
+ return month >= 1 && month <= 12 ? `${matched[1]}.${month}` : text
+ },
getYearDetailPlanList() {
const entity = {
superviseId: this.superviseId,
supervisePurpose: this.yearDetailForm.supervisePurpose,
superviseProject: this.yearDetailForm.superviseProject,
- causeType: this.yearDetailForm.causeType,
}
const page = this.yearDetailPage
this.yearDetailLoading = true
pageQualitySuperviseDetail({ ...entity, ...page }).then(res => {
this.yearDetailLoading = false
- this.yearDetailTableData = res.data.records
+ // 鍘嗗彶瀵煎叆鐨勭洃鐫f棩鏈熷彲鑳芥槸 2026/3/15銆�2026-03-15 绛夊畬鏁存棩鏈燂紝缁熶竴鏄剧ず鎴� 2026.3
+ this.yearDetailTableData = (res.data.records || []).map(item => ({
+ ...item,
+ superviseTime: this.normalizeSuperviseMonth(item.superviseTime)
+ }))
this.yearDetailPage.total = res.data.total
}).catch(err => {
console.log('err---', err);
@@ -779,7 +824,7 @@
showDialog(type, row) {
this.formDia = true
this.$nextTick(() => {
- this.$refs.formDia.openDia(type, row, this.yearDetailForm.causeType)
+ this.$refs.formDia.openDia(type, row)
})
},
closeDia() {
@@ -872,7 +917,7 @@
action() {
return this.javaApi + '/qualitySupervise/importQualitySupervise'
},
- ...mapGetters(["userId"]),
+ ...mapGetters(["userId", "nickName"]),
},
};
</script>
--
Gitblit v1.9.3