From a78e352b672fd6b634c24e0d9cf184f56b846f6a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 28 十月 2025 15:25:45 +0800
Subject: [PATCH] 库存预警,无用功能隐藏
---
src/views/basicData/customerFile/index.vue | 161 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 131 insertions(+), 30 deletions(-)
diff --git a/src/views/basicData/customerFile/index.vue b/src/views/basicData/customerFile/index.vue
index c4fa332..76a8c68 100644
--- a/src/views/basicData/customerFile/index.vue
+++ b/src/views/basicData/customerFile/index.vue
@@ -34,7 +34,6 @@
@selection-change="handleSelectionChange"
:tableLoading="tableLoading"
@pagination="pagination"
- :total="total"
></PIMTable>
</div>
<el-dialog
@@ -95,26 +94,6 @@
</el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="鑱旂郴浜猴細" prop="contactPerson">
- <el-input
- v-model="form.contactPerson"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactPhone">
- <el-input
- v-model="form.contactPhone"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
<el-form-item label="閾惰鍩烘湰鎴凤細" prop="basicBankAccount">
<el-input
v-model="form.basicBankAccount"
@@ -144,6 +123,24 @@
</el-form-item>
</el-col>
</el-row>
+ <el-row :gutter="30" v-for="(contact, index) in formYYs.contactList" :key="index">
+ <el-col :span="12">
+ <el-form-item label="鑱旂郴浜猴細" prop="contactPerson">
+ <el-input v-model="contact.contactPerson" placeholder="璇疯緭鍏�" clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactPhone">
+ <div style="display: flex; align-items: center;width: 100%;">
+ <el-input v-model="contact.contactPhone" placeholder="璇疯緭鍏�" clearable />
+ <el-button @click="removeContact(index)" type="danger" circle style="margin-left: 5px;">
+ <el-icon><Close /></el-icon>
+ </el-button>
+ </div>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-button @click="addNewContact" style="margin-bottom: 10px;">+ 鏂板鑱旂郴浜�</el-button>
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="缁存姢浜猴細" prop="maintainer">
@@ -199,8 +196,11 @@
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
- :on-progress="handleFileUploadProgress"
- :on-success="handleFileSuccess"
+ :before-upload="upload.beforeUpload"
+ :on-progress="upload.onProgress"
+ :on-success="upload.onSuccess"
+ :on-error="upload.onError"
+ :on-change="upload.onChange"
:auto-upload="false"
drag
>
@@ -230,7 +230,7 @@
</template>
<script setup>
-import { ref } from "vue";
+import {onMounted, ref} from "vue";
import { Search } from "@element-plus/icons-vue";
import {
addCustomer,
@@ -260,7 +260,7 @@
{
label: "鍦板潃鍙婅仈绯绘柟寮�",
prop: "addressPhone",
- width: 220,
+ width: 250,
},
{
label: "鑱旂郴浜�",
@@ -269,18 +269,22 @@
{
label: "鑱旂郴鐢佃瘽",
prop: "contactPhone",
+ width:150
},
{
label: "閾惰鍩烘湰鎴�",
prop: "basicBankAccount",
+ width: 220,
},
{
label: "閾惰璐﹀彿",
prop: "bankAccount",
+ width: 220,
},
{
label: "寮�鎴疯鍙�",
prop: "bankCode",
+ width:220
},
{
label: "缁存姢浜�",
@@ -289,11 +293,13 @@
{
label: "缁存姢鏃堕棿",
prop: "maintenanceTime",
+ width: 100,
},
{
dataType: "action",
label: "鎿嶄綔",
align: "center",
+ fixed: 'right',
operation: [
{
name: "缂栬緫",
@@ -301,6 +307,9 @@
clickFun: (row) => {
openForm("edit", row);
},
+ disabled: (row) => {
+ return row.maintainer !== userStore.nickName
+ }
},
],
},
@@ -311,13 +320,22 @@
const tableLoading = ref(false);
const page = reactive({
current: 1,
- size: 10,
+ size: 100,
+ total: 0,
});
const total = ref(0);
// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
const operationType = ref("");
const dialogFormVisible = ref(false);
+const formYYs = ref({ // 鍏朵粬瀛楁...
+ contactList: [
+ {
+ contactPerson: "",
+ contactPhone: ""
+ }
+ ]
+});
const data = reactive({
searchForm: {
customerName: "",
@@ -342,8 +360,8 @@
],
companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- contactPerson: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- contactPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ // contactPerson: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ // contactPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
maintainer: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
maintenanceTime: [
{ required: false, message: "璇烽�夋嫨", trigger: "change" },
@@ -364,9 +382,59 @@
headers: { Authorization: "Bearer " + getToken() },
// 涓婁紶鐨勫湴鍧�
url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
+ // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
+ beforeUpload: (file) => {
+ console.log('鏂囦欢鍗冲皢涓婁紶', file);
+ // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠�
+ const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls');
+ if (!isValid) {
+ proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢");
+ }
+ return isValid;
+ },
+ // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋�
+ onChange: (file, fileList) => {
+ console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList);
+ },
+ // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟
+ onSuccess: (response, file, fileList) => {
+ console.log('涓婁紶鎴愬姛', response, file, fileList);
+ upload.isUploading = false;
+ if(response.code === 200){
+ proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
+ upload.open = false;
+ proxy.$refs["uploadRef"].clearFiles();
+ getList();
+ }else if(response.code === 500){
+ proxy.$modal.msgError(response.msg);
+ }else{
+ proxy.$modal.msgWarning(response.msg);
+ }
+ },
+ // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟
+ onError: (error, file, fileList) => {
+ console.error('涓婁紶澶辫触', error, file, fileList);
+ upload.isUploading = false;
+ proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+ },
+ // 鏂囦欢涓婁紶杩涘害鍥炶皟
+ onProgress: (event, file, fileList) => {
+ console.log('涓婁紶涓�...', event.percent);
+ }
});
const { searchForm, form, rules } = toRefs(data);
+const addNewContact = () => {
+ formYYs.value.contactList.push({
+ contactPerson: "",
+ contactPhone: ""
+ });
+};
+const removeContact = (index) => {
+ if (formYYs.value.contactList.length > 1) {
+ formYYs.value.contactList.splice(index, 1);
+ }
+};
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
const handleQuery = () => {
@@ -383,7 +451,7 @@
listCustomer({ ...searchForm.value, ...page }).then((res) => {
tableLoading.value = false;
tableData.value = res.records;
- total.value = res.total;
+ page.total = res.total;
});
};
// 琛ㄦ牸閫夋嫨鏁版嵁
@@ -392,6 +460,7 @@
};
/** 鎻愪氦涓婁紶鏂囦欢 */
function submitFileForm() {
+ upload.isUploading = true;
proxy.$refs["uploadRef"].submit();
}
/** 瀵煎叆鎸夐挳鎿嶄綔 */
@@ -399,11 +468,21 @@
upload.title = "瀹㈡埛瀵煎叆";
upload.open = true;
}
+/** 涓嬭浇妯℃澘 */
+function importTemplate() {
+ proxy.download("/basic/customer/downloadTemplate", {}, "瀹㈡埛瀵煎叆妯℃澘.xlsx");
+}
// 鎵撳紑寮规
const openForm = (type, row) => {
operationType.value = type;
form.value = {};
form.value.maintainer = userStore.nickName;
+ formYYs.value.contactList = [
+ {
+ contactPerson: "",
+ contactPhone: ""
+ }
+ ];
form.value.maintenanceTime = getCurrentDate();
userListNoPage().then((res) => {
userList.value = res.data;
@@ -411,6 +490,13 @@
if (type === "edit") {
getCustomer(row.id).then((res) => {
form.value = { ...res.data };
+ formYYs.value.contactList = res.data.contactPerson.split(",").map((item, index) => {
+ return {
+ contactPerson: item,
+ contactPhone: res.data.contactPhone.split(",")[index]
+ }
+ });
+
});
}
dialogFormVisible.value = true;
@@ -429,6 +515,11 @@
};
// 鎻愪氦鏂板
const submitAdd = () => {
+ if(formYYs.value.contactList.length < 1){
+ return proxy.$modal.msgWarning("璇疯嚦灏戞坊鍔犱竴涓仈绯讳汉");
+ }
+ form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(",");
+ form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(",");
addCustomer(form.value).then((res) => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
closeDia();
@@ -437,6 +528,8 @@
};
// 鎻愪氦淇敼
const submitEdit = () => {
+ form.value.contactPerson = formYYs.value.contactList.map(item => item.contactPerson).join(",");
+ form.value.contactPhone = formYYs.value.contactList.map(item => item.contactPhone).join(",");
updateCustomer(form.value).then((res) => {
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
closeDia();
@@ -466,6 +559,12 @@
const handleDelete = () => {
let ids = [];
if (selectedRows.value.length > 0) {
+ // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
+ const unauthorizedData = selectedRows.value.filter(item => item.maintainer !== userStore.nickName);
+ if (unauthorizedData.length > 0) {
+ proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+ return;
+ }
ids = selectedRows.value.map((item) => item.id);
} else {
proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
@@ -501,7 +600,9 @@
return `${year}-${month}-${day}`;
}
-getList();
+onMounted(() => {
+ getList();
+});
</script>
<style scoped lang="scss"></style>
--
Gitblit v1.9.3