From 188eb07cbc0717ccee654290ec641a79d96713e4 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期一, 16 六月 2025 17:04:14 +0800
Subject: [PATCH] feat: 客户 供应商导入
---
src/views/basicData/supplierManage/index.vue | 76 ++++++++++++++++++++++++++++++++++----
1 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/src/views/basicData/supplierManage/index.vue b/src/views/basicData/supplierManage/index.vue
index e9932c6..6270639 100644
--- a/src/views/basicData/supplierManage/index.vue
+++ b/src/views/basicData/supplierManage/index.vue
@@ -16,11 +16,12 @@
<div>
<el-button type="primary" @click="openForm('add')">鏂板渚涘簲鍟�</el-button>
<el-button @click="handleOut">瀵煎嚭</el-button>
+ <el-button type="info" plain icon="Upload" @click="handleImport">瀵煎叆</el-button>
<el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
</div>
</div>
<div class="table_list">
- <PIMTable :column="tableColumn" :tableData="tableData" :page="page" :handleSelectionChange="handleSelectionChange"
+ <PIMTable :column="tableColumn" :tableData="tableData" :page="page" :isSelection="true" :handleSelectionChange="handleSelectionChange"
:tableLoading="tableLoading" @pagination="pagination" :total="total"></PIMTable>
</div>
<el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '鏂板渚涘簲鍟嗕俊鎭�' : '缂栬緫渚涘簲鍟嗕俊鎭�'" width="70%" @close="closeDia">
@@ -76,7 +77,7 @@
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="缁存姢浜猴細" prop="maintainUserId">
- <el-select v-model="form.maintainUserId" placeholder="璇烽�夋嫨" clearable>
+ <el-select v-model="form.maintainUserId" placeholder="璇烽�夋嫨" clearable disabled>
<el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.userId"/>
</el-select>
</el-form-item>
@@ -91,6 +92,7 @@
type="date"
placeholder="璇烽�夋嫨"
clearable
+ disabled
/>
</el-form-item>
</el-col>
@@ -103,6 +105,26 @@
</div>
</template>
</el-dialog>
+
+ <!-- 渚涘簲鍟嗗鍏ュ璇濇 -->
+ <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
+ <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
+ <el-icon class="el-icon--upload"><upload-filled /></el-icon>
+ <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+ <template #tip>
+ <div class="el-upload__tip text-center">
+ <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span>
+ <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">涓嬭浇妯℃澘</el-link>
+ </div>
+ </template>
+ </el-upload>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+ <el-button @click="upload.open = false">鍙� 娑�</el-button>
+ </div>
+ </template>
+ </el-dialog>
</div>
</template>
@@ -112,17 +134,22 @@
import { delSupplier} from "@/api/basicData/supplierManageFile.js";
import {ElMessageBox } from "element-plus";
import {userListNoPage} from "@/api/system/user.js";
-import {addSupplier,getSupplier,listSupplier,updateSupplier} from "../../../api/basicData/supplierManageFile.js";
+import {addSupplier,getSupplier,listSupplier,updateSupplier} from "@/api/basicData/supplierManageFile.js";
+import useUserStore from "@/store/modules/user"
+import {getToken} from "@/utils/auth.js";
const { proxy } = getCurrentInstance()
+const userStore = useUserStore()
const tableColumn = ref([
{
label: '渚涘簲鍟嗗悕绉�',
prop: 'supplierName',
+ width: 250,
},
{
label: '鍏徃鍦板潃',
- prop: 'companyAddress'
+ prop: 'companyAddress',
+ width: 220,
},
{
label: '鑱旂郴鏂瑰紡',
@@ -218,18 +245,39 @@
page.current = 1
getList()
}
-const pagination = ({ current, limit }) => {
- page.current = current;
- page.size = limit;
+const pagination = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
getList()
+}
+/** 鎻愪氦涓婁紶鏂囦欢 */
+function submitFileForm() {
+ proxy.$refs["uploadRef"].submit()
}
const getList = () => {
tableLoading.value = true
listSupplier({...searchForm.value, ...page}).then(res => {
tableLoading.value = false
tableData.value = res.data.records
- total.value = res.total
+ total.value = res.data.total
})
+}
+const upload = reactive({
+ // 鏄惁鏄剧ず寮瑰嚭灞傦紙渚涘簲鍟嗗鍏ワ級
+ open: false,
+ // 寮瑰嚭灞傛爣棰橈紙渚涘簲鍟嗗鍏ワ級
+ title: "",
+ // 鏄惁绂佺敤涓婁紶
+ isUploading: false,
+ // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+ headers: { Authorization: "Bearer " + getToken() },
+ // 涓婁紶鐨勫湴鍧�
+ url: import.meta.env.VITE_APP_BASE_API + "/system/supplier/import"
+})
+/** 瀵煎叆鎸夐挳鎿嶄綔 */
+function handleImport() {
+ upload.title = "渚涘簲鍟嗗鍏�"
+ upload.open = true
}
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
@@ -239,6 +287,8 @@
const openForm = (type, row) => {
operationType.value = type
form.value = {}
+ form.value.maintainUserId = userStore.id
+ form.value.maintainTime = getCurrentDate();
userListNoPage().then(res => {
userList.value = res.data
})
@@ -325,6 +375,16 @@
proxy.$modal.msg("宸插彇娑�")
})
}
+
+// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD
+function getCurrentDate() {
+ const today = new Date();
+ const year = today.getFullYear();
+ const month = String(today.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮�
+ const day = String(today.getDate()).padStart(2, '0');
+ return `${year}-${month}-${day}`;
+}
+
getList()
</script>
--
Gitblit v1.9.3