From 528a329c9a41a2789365d91eae1d27f736b1d876 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 08 七月 2026 09:38:14 +0800
Subject: [PATCH] 新疆马铃薯 1.赋默认值
---
src/views/basicData/supplierManage/components/HomeTab.vue | 1037 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 773 insertions(+), 264 deletions(-)
diff --git a/src/views/basicData/supplierManage/components/HomeTab.vue b/src/views/basicData/supplierManage/components/HomeTab.vue
index b594c2f..eea719d 100644
--- a/src/views/basicData/supplierManage/components/HomeTab.vue
+++ b/src/views/basicData/supplierManage/components/HomeTab.vue
@@ -1,95 +1,224 @@
<template>
- <div class="app-container">
+ <div>
<div class="search_form">
- <div>
+ <div style="margin-bottom: 10px;">
<span class="search_title">渚涘簲鍟嗘。妗堬細</span>
<el-input
- v-model="searchForm.supplierName"
- style="width: 240px"
- placeholder="杈撳叆鍚嶇О鎼滅储"
- @change="handleQuery"
- clearable
- :prefix-icon="Search"
+ v-model="searchForm.supplierName"
+ style="width: 240px"
+ placeholder="杈撳叆渚涘簲鍟嗗悕绉版悳绱�"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search"
/>
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
+ <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
+ >鎼滅储</el-button
+ >
</div>
- <div>
- <el-button type="primary" @click="openForm('add')">鏂板渚涘簲鍟�</el-button>
+ <div style="margin-bottom: 10px;">
+ <el-button type="primary" @click="openForm('add')"
+ >鏂板渚涘簲鍟�</el-button
+ >
<el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+ <el-button type="info" plain icon="Upload" @click="handleImport"
+ >瀵煎叆</el-button
+ >
+ <el-button type="danger" plain @click="handleDelete" v-hasPermi="['basicData:supplierManage:remove']">鍒犻櫎</el-button>
</div>
</div>
-
- <div class="table_list" style="margin-top: 20px">
+ <div class="table_list">
<PIMTable
- rowKey="id"
- :column="tableColumn"
- :tableData="tableData"
- :page="page"
- :isSelection="true"
- @selection-change="handleSelectionChange"
- :tableLoading="tableLoading"
- @pagination="pagination"
- />
+ rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ :tableLoading="tableLoading"
+ @pagination="pagination"
+ ></PIMTable>
</div>
-
<el-dialog
- v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板渚涘簲鍟嗕俊鎭�' : '缂栬緫渚涘簲鍟嗕俊鎭�'"
- width="600px"
- @close="closeDia"
+ v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板渚涘簲鍟嗕俊鎭�' : '缂栬緫渚涘簲鍟嗕俊鎭�'"
+ width="70%"
+ @close="closeDia"
>
- <el-form
- :model="form"
- label-width="120px"
- label-position="top"
- :rules="rules"
- ref="formRef"
- >
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鍚嶇О锛�" prop="supplierName">
- <el-input v-model="form.supplierName" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="绾崇◣浜鸿瘑鍒彿锛�" prop="taxpayerIdentificationNum">
- <el-input
- v-model="form.taxpayerIdentificationNum"
- placeholder="璇疯緭鍏�"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="缁存姢浜猴細" prop="maintainUserId">
- <el-select v-model="form.maintainUserId" placeholder="璇烽�夋嫨" clearable>
- <el-option
- v-for="item in userList"
- :key="item.userId"
- :label="item.nickName"
- :value="item.userId"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="缁存姢鏃堕棿锛�" prop="maintainTime">
- <el-date-picker
- style="width: 100%"
- v-model="form.maintainTime"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
+ <el-tabs v-model="supplierActiveTab">
+ <!-- 鍩烘湰淇℃伅 Tab -->
+ <el-tab-pane label="鍩烘湰淇℃伅" name="basic">
+ <el-form
+ :model="form"
+ label-width="140px"
+ label-position="top"
+ :rules="rules"
+ ref="formRef"
+ >
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="渚涘簲鍟嗗悕绉帮細" prop="supplierName">
+ <el-input
+ v-model="form.supplierName"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item
+ label="绾崇◣浜鸿瘑鍒彿锛�"
+ prop="taxpayerIdentificationNum"
+ >
+ <el-input
+ v-model="form.taxpayerIdentificationNum"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="鍏徃鍦板潃锛�" prop="companyAddress">
+ <el-input
+ v-model="form.companyAddress"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鍏徃鐢佃瘽锛�" prop="companyPhone">
+ <el-input
+ v-model="form.companyPhone"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="寮�鎴疯锛�" prop="bankAccountName">
+ <el-input
+ v-model="form.bankAccountName"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="璐﹀彿锛�" prop="bankAccountNum">
+ <el-input
+ v-model="form.bankAccountNum"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="鑱旂郴浜猴細" prop="contactUserName">
+ <el-input
+ v-model="form.contactUserName"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鑱旂郴鐢佃瘽锛�" prop="contactUserPhone">
+ <el-input
+ v-model="form.contactUserPhone"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="缁存姢浜猴細" prop="maintainUserId">
+ <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>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="缁存姢鏃堕棿锛�" prop="maintainTime">
+ <el-date-picker
+ style="width: 100%"
+ v-model="form.maintainTime"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ type="date"
+ placeholder="璇烽�夋嫨"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="渚涘簲鍟嗙被鍨嬶細" prop="supplierType">
+ <el-select v-model="form.supplierType" placeholder="璇烽�夋嫨" clearable>
+ <el-option label="鐢�" value="鐢�" />
+ <el-option label="涔�" value="涔�" />
+ <el-option label="涓�" value="涓�" />
+ <el-option label="涓�" value="涓�" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鏄惁鐧藉悕鍗曪細" prop="isWhite">
+ <el-select v-model="form.isWhite" placeholder="璇烽�夋嫨" clearable>
+ <el-option label="鏄�" :value="0" />
+ <el-option label="鍚�" :value="1" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ </el-tab-pane>
+
+ <!-- 鍚堝悓璁板綍 Tab -->
+ <el-tab-pane label="鍚堝悓璁板綍" name="contract" :disabled="operationType === 'add' || !currentSupplierId">
+ <div style="margin-bottom: 15px;">
+ <el-button type="primary" size="small" @click="handleAddContract">鏂板鍚堝悓璁板綍</el-button>
+ </div>
+ <el-table :data="contractRecordList" border style="width: 100%">
+ <el-table-column prop="masterContractNo" label="鎬诲悎鍚屽彿" show-overflow-tooltip />
+ <el-table-column prop="entryDate" label="褰曞叆鏃ユ湡" width="180" />
+ <el-table-column prop="entryPerson" label="褰曞叆浜�" width="120" />
+ <el-table-column prop="remark" label="澶囨敞" show-overflow-tooltip />
+ <el-table-column label="闄勪欢" width="100">
+ <template #default="{ row }">
+ <el-link type="primary" v-if="row.fileList && row.fileList.length" @click="handleViewContractFiles(row)">
+ 鏌ョ湅({{ row.fileList.length }})
+ </el-link>
+ <span v-else>-</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="150">
+ <template #default="{ row }">
+ <el-button link type="primary" @click="handleEditContract(row)">缂栬緫</el-button>
+ <el-button link type="danger" @click="handleDeleteContract(row)">鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ </el-tab-pane>
+ </el-tabs>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm">纭</el-button>
@@ -97,231 +226,611 @@
</div>
</template>
</el-dialog>
+
+ <!-- 鍚堝悓璁板綍寮圭獥 -->
+ <el-dialog
+ v-model="contractDialogVisible"
+ :title="contractDialogTitle"
+ width="600px"
+ :close-on-click-modal="false"
+ >
+ <el-form
+ :model="contractForm"
+ :rules="contractRules"
+ ref="contractFormRef"
+ label-width="100px"
+ >
+ <el-form-item label="鎬诲悎鍚屽彿" prop="masterContractNo">
+ <el-input v-model="contractForm.masterContractNo" placeholder="璇疯緭鍏ユ�诲悎鍚屽彿" clearable />
+ </el-form-item>
+ <el-form-item label="褰曞叆鏃ユ湡" prop="entryDate">
+ <el-date-picker
+ v-model="contractForm.entryDate"
+ type="datetime"
+ placeholder="閫夋嫨鏃ユ湡鏃堕棿"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ style="width: 100%"
+ clearable
+ />
+ </el-form-item>
+ <el-form-item label="褰曞叆浜�" prop="entryPerson">
+ <el-input v-model="contractForm.entryPerson" placeholder="璇疯緭鍏ュ綍鍏ヤ汉" clearable />
+ </el-form-item>
+ <el-form-item label="闄勪欢">
+ <FileUpload
+ v-model="contractForm.storageBlobDTOs"
+ :record-type="'supplier_contract_record'"
+ :record-id="contractForm.id"
+ />
+ </el-form-item>
+ <el-form-item label="澶囨敞">
+ <el-input v-model="contractForm.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉�" />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="submitContractForm">纭</el-button>
+ <el-button @click="contractDialogVisible = false">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+
+ <!-- 鍚堝悓闄勪欢鏌ョ湅寮圭獥 -->
+ <el-dialog
+ v-model="contractFileDialogVisible"
+ title="鍚堝悓闄勪欢"
+ width="700px"
+ :close-on-click-modal="false"
+ >
+ <el-table :data="contractFileList" border v-if="contractFileList.length">
+ <el-table-column prop="name" label="鏂囦欢鍚嶇О" show-overflow-tooltip />
+ <el-table-column prop="byteSize" label="鏂囦欢澶у皬" width="120">
+ <template #default="{ row }">
+ {{ formatFileSize(row.byteSize) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="150">
+ <template #default="{ row }">
+ <el-link type="primary" :href="row.previewURL" target="_blank">棰勮</el-link>
+ <el-link type="primary" :href="row.downloadURL" style="margin-left: 10px">涓嬭浇</el-link>
+ </template>
+ </el-table-column>
+ </el-table>
+ <el-empty v-else description="鏆傛棤闄勪欢" />
+ </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"
+ :on-error="handleFileError"
+ :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>
+ <FileList v-if="fileListDialogVisible"
+ v-model:visible="fileListDialogVisible"
+ record-type="supplier_manage"
+ :record-id="recordId" />
</div>
</template>
<script setup>
- import { getCurrentInstance, onMounted, reactive, ref, toRefs } from "vue";
- import { Search } from "@element-plus/icons-vue";
- import { ElMessageBox } from "element-plus";
- import { addSupplier, delSupplier, getSupplier, listSupplier, updateSupplier } from "@/api/basicData/supplierManageFile.js";
- import useUserStore from "@/store/modules/user";
- import { userListNoPage } from "@/api/system/user.js";
- import { getToken } from "@/utils/auth.js";
+import { onMounted, ref } from "vue";
+import { Search } from "@element-plus/icons-vue";
+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 {
+ getSupplierContractList,
+ getSupplierContractById,
+ addSupplierContract,
+ updateSupplierContract,
+ delSupplierContract,
+} from "@/api/basicData/supplierContract.js";
+import useUserStore from "@/store/modules/user";
+import { getToken } from "@/utils/auth.js";
+import FileUpload from "@/components/AttachmentUpload/file/index.vue";
+const FileList = defineAsyncComponent(() =>
+ import("@/components/Dialog/FileList.vue")
+);
+const { proxy } = getCurrentInstance();
+const userStore = useUserStore();
- const { proxy } = getCurrentInstance();
- const userStore = useUserStore();
+const tableColumn = ref([
+ {
+ label: "渚涘簲鍟嗗悕绉�",
+ prop: "supplierName",
+ width: 250,
+ },
+ {
+ label: "渚涘簲鍟嗙被鍨�",
+ prop: "supplierType",
+ width: 120,
+ },
+ {
+ label: "绾崇◣浜鸿瘑鍒彿",
+ prop: "taxpayerIdentificationNum",
+ width: 230,
+ },
+ {
+ label: "鍏徃鍦板潃",
+ prop: "companyAddress",
+ width: 220,
+ },
+ {
+ label: "鑱旂郴鏂瑰紡",
+ prop: "companyPhone",
+ width:150
+ },
+ {
+ label: "寮�鎴疯",
+ prop: "bankAccountName",
+ width: 220,
+ },
+ {
+ label: "璐﹀彿",
+ prop: "bankAccountNum",
+ width: 220,
+ },
+ {
+ label: "鑱旂郴浜�",
+ prop: "contactUserName",
+ },
+ {
+ label: "鑱旂郴鐢佃瘽",
+ prop: "contactUserPhone",
+ width: 150,
+ },
+ {
+ label: "缁存姢浜�",
+ prop: "maintainUserName",
+ },
- const tableColumn = ref([
- {
- label: "鍚嶇О",
- prop: "supplierName",
- },
- {
- label: "绾崇◣浜鸿瘑鍒彿",
- prop: "taxpayerIdentificationNum",
- },
- {
- label: "缁存姢浜�",
- prop: "maintainUserName",
- },
- {
- label: "缁存姢鏃堕棿",
- prop: "maintainTime",
- },
- {
- dataType: "action",
- label: "鎿嶄綔",
- align: "center",
- fixed: "right",
- width: 150,
- operation: [
- {
- name: "缂栬緫",
- type: "text",
- clickFun: row => {
- openForm("edit", row);
- },
+ {
+ label: "缁存姢鏃堕棿",
+ prop: "maintainTime",
+ width:100
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ fixed: 'right',
+ width: 150,
+ operation: [
+ {
+ name: "缂栬緫",
+ type: "text",
+ clickFun: (row) => {
+ openForm("edit", row);
},
- ],
- },
- ]);
+ },
+ {
+ //璧勮川闄勪欢
+ name: "璧勮川鏂囦欢",
+ type: "text",
+ clickFun: (row) => {
+ openFileDialog(row)
+ }
+ }
+ ],
+ },
+]);
+const tableData = ref([]);
+const selectedRows = ref([]);
+const userList = ref([]);
+const tableLoading = ref(false);
+const fileListDialogVisible = ref(false);
+const recordId = ref();
+const page = reactive({
+ current: 1,
+ size: 100,
+ total: 0,
+});
- const tableData = ref([]);
- const selectedRows = ref([]);
- const userList = ref([]);
- const tableLoading = ref(false);
- const page = reactive({
- current: 1,
- size: 100,
- total: 0,
+// 渚涘簲鍟嗚鎯匱ab鐩稿叧
+const supplierActiveTab = ref('basic');
+const currentSupplierId = ref(null);
+const contractRecordList = ref([]);
+
+// 鍚堝悓璁板綍寮圭獥鐩稿叧
+const contractDialogVisible = ref(false);
+const contractDialogTitle = ref('');
+const contractFormRef = ref();
+const contractForm = reactive({
+ id: null,
+ supplierId: null,
+ masterContractNo: '',
+ entryDate: '',
+ entryPerson: '',
+ entryPersonId: null,
+ remark: '',
+ storageBlobDTOs: []
+});
+const contractRules = {
+ masterContractNo: [{ required: true, message: '璇疯緭鍏ユ�诲悎鍚屽彿', trigger: 'blur' }],
+ entryDate: [{ required: true, message: '璇烽�夋嫨褰曞叆鏃ユ湡', trigger: 'change' }]
+};
+
+// 鍚堝悓闄勪欢寮圭獥鐩稿叧
+const contractFileDialogVisible = ref(false);
+const contractFileList = ref([]);
+// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
+const operationType = ref("");
+const dialogFormVisible = ref(false);
+const data = reactive({
+ searchForm: {
+ supplierName: "",
+ },
+ form: {
+ supplierName: "",
+ taxpayerIdentificationNum: "",
+ companyAddress: "",
+ companyPhone: "",
+ bankAccountName: "",
+ bankAccountNum: "",
+ contactUserName: "",
+ contactUserPhone: "",
+ maintainUserId: "",
+ maintainTime: "",
+ supplierType: "",
+ isWhite: "",
+ },
+ rules: {
+ supplierName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ taxpayerIdentificationNum: [
+ { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+ ],
+ companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ bankAccountName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ bankAccountNum: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
+ contactUserName: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ contactUserPhone: [{ required: false, message: "璇疯緭鍏�", trigger: "blur" }],
+ maintainUserId: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
+ maintainTime: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
+ supplierType: [{ required: true, message: "璇烽�夋嫨渚涘簲鍟嗙被鍨�", trigger: "change" }],
+ },
+});
+const { searchForm, form, rules } = toRefs(data);
+
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1;
+ getList();
+};
+const pagination = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+};
+/** 鎻愪氦涓婁紶鏂囦欢 */
+function submitFileForm() {
+ upload.isUploading = true;
+ proxy.$refs["uploadRef"].submit();
+}
+const getList = () => {
+ tableLoading.value = true;
+ listSupplier({ ...searchForm.value, ...page, isWhite: 0 }).then((res) => {
+ tableLoading.value = false;
+ tableData.value = res.data.records;
+ page.total = res.data.total;
});
- const operationType = ref("");
- const dialogFormVisible = ref(false);
- const formRef = ref();
+};
+const upload = reactive({
+ // 鏄惁鏄剧ず寮瑰嚭灞傦紙渚涘簲鍟嗗鍏ワ級
+ open: false,
+ // 寮瑰嚭灞傛爣棰橈紙渚涘簲鍟嗗鍏ワ級
+ title: "",
+ // 鏄惁绂佺敤涓婁紶
+ isUploading: false,
+ // 鏄惁鏇存柊宸茬粡瀛樺湪鐨勭敤鎴锋暟鎹�
+ updateSupport: 1,
+ // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+ headers: { Authorization: "Bearer " + getToken() },
+ // 涓婁紶鐨勫湴鍧�
+ url: import.meta.env.VITE_APP_BASE_API + "/system/supplier/import",
+});
+/** 瀵煎叆鎸夐挳鎿嶄綔 */
+function handleImport() {
+ upload.title = "渚涘簲鍟嗗鍏�";
+ upload.open = true;
+}
+/** 涓嬭浇妯℃澘 */
+function importTemplate() {
+ proxy.download("/system/supplier/downloadTemplate", {}, "渚涘簲鍟嗗鍏ユā鏉�.xlsx");
+}
- const data = reactive({
- searchForm: {
- supplierName: "",
- },
- form: {
- supplierName: "",
- taxpayerIdentificationNum: "",
- maintainUserId: "",
- maintainTime: "",
- },
- rules: {
- supplierName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- taxpayerIdentificationNum: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- maintainUserId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- maintainTime: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- },
- });
- const { searchForm, form, rules } = toRefs(data);
+/**鏂囦欢涓婁紶涓鐞� */
+const handleFileUploadProgress = (event, file, fileList) => {
+ upload.isUploading = true;
+};
- const upload = reactive({
- open: false,
- title: "",
- isUploading: false,
- updateSupport: 1,
- headers: { Authorization: "Bearer " + getToken() },
- url: import.meta.env.VITE_APP_BASE_API + "/system/supplier/import",
- });
-
- const handleQuery = () => {
- page.current = 1;
+/** 鏂囦欢涓婁紶鎴愬姛澶勭悊 */
+const handleFileSuccess = (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);
+ }
+};
- const pagination = obj => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
- };
+/** 鏂囦欢涓婁紶澶辫触澶勭悊 */
+const handleFileError = (error, file, fileList) => {
+ upload.isUploading = false;
+ proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
+};
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ selectedRows.value = selection;
+};
+// 鎵撳紑寮规
+const openForm = async (type, row) => {
+ operationType.value = type;
+ form.value = {};
+ form.value.maintainUserId = userStore.id;
+ form.value.maintainTime = getCurrentDate();
+ supplierActiveTab.value = 'basic';
+ currentSupplierId.value = null;
+ contractRecordList.value = [];
- const getList = () => {
- tableLoading.value = true;
- listSupplier({ ...searchForm.value, ...page, isWhite: 0 }).then(res => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- page.total = res.data.total;
+ userListNoPage().then((res) => {
+ userList.value = res.data;
+ });
+
+ if (type === "edit") {
+ currentSupplierId.value = row.id;
+ getSupplier(row.id).then((res) => {
+ form.value = { ...res.data };
});
- };
+ // 鍔犺浇鍚堝悓璁板綍鍒楄〃
+ loadContractList(row.id);
+ }
+ dialogFormVisible.value = true;
+};
- const handleSelectionChange = selection => {
- selectedRows.value = selection;
- };
-
- const openForm = (type, row) => {
- operationType.value = type;
- form.value = {
- supplierName: "",
- taxpayerIdentificationNum: "",
- maintainUserId: userStore.id,
- maintainTime: getCurrentDate(),
- };
- userListNoPage().then(res => {
- userList.value = res.data;
- });
- if (type === "edit") {
- getSupplier(row.id).then(res => {
- form.value = {
- id: res.data.id || "",
- supplierName: res.data.supplierName || "",
- taxpayerIdentificationNum: res.data.taxpayerIdentificationNum || "",
- maintainUserId: res.data.maintainUserId || userStore.id,
- maintainTime: res.data.maintainTime || getCurrentDate(),
- };
- });
+// 鍔犺浇鍚堝悓璁板綍鍒楄〃
+const loadContractList = async (supplierId) => {
+ try {
+ const res = await getSupplierContractList(supplierId);
+ if (res.code === 200) {
+ contractRecordList.value = res.data || [];
}
- dialogFormVisible.value = true;
- };
+ } catch (error) {
+ console.error('鑾峰彇鍚堝悓璁板綍鍒楄〃澶辫触:', error);
+ }
+};
- const submitForm = () => {
- proxy.$refs["formRef"].validate(valid => {
- if (!valid) {
- return;
- }
+// 鏂板鍚堝悓璁板綍
+const handleAddContract = () => {
+ contractDialogTitle.value = '鏂板鍚堝悓璁板綍';
+ Object.assign(contractForm, {
+ id: null,
+ supplierId: currentSupplierId.value,
+ masterContractNo: '',
+ entryDate: '',
+ entryPerson: userStore.nickName,
+ entryPersonId: userStore.id,
+ remark: '',
+ storageBlobDTOs: []
+ });
+ contractDialogVisible.value = true;
+};
+
+// 缂栬緫鍚堝悓璁板綍
+const handleEditContract = async (row) => {
+ contractDialogTitle.value = '缂栬緫鍚堝悓璁板綍';
+ try {
+ const res = await getSupplierContractById(row.id);
+ if (res.code === 200) {
+ Object.assign(contractForm, {
+ ...res.data,
+ storageBlobDTOs: res.data.fileList ? res.data.fileList.map(f => ({ id: f.id })) : []
+ });
+ contractDialogVisible.value = true;
+ }
+ } catch (error) {
+ console.error('鑾峰彇鍚堝悓璁板綍璇︽儏澶辫触:', error);
+ }
+};
+
+// 鍒犻櫎鍚堝悓璁板綍
+const handleDeleteContract = async (row) => {
+ try {
+ await ElMessageBox.confirm('纭畾鍒犻櫎璇ュ悎鍚岃褰曞悧锛�', '鎻愮ず', { type: 'warning' });
+ const res = await delSupplierContract(row.id);
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess('鍒犻櫎鎴愬姛');
+ loadContractList(currentSupplierId.value);
+ }
+ } catch (error) {
+ if (error !== 'cancel') {
+ console.error('鍒犻櫎鍚堝悓璁板綍澶辫触:', error);
+ }
+ }
+};
+
+// 鎻愪氦鍚堝悓璁板綍琛ㄥ崟
+const submitContractForm = async () => {
+ try {
+ await contractFormRef.value.validate();
+ const api = contractForm.id ? updateSupplierContract : addSupplierContract;
+ const res = await api(contractForm);
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess('鎿嶄綔鎴愬姛');
+ contractDialogVisible.value = false;
+ loadContractList(currentSupplierId.value);
+ }
+ } catch (error) {
+ console.error('鎻愪氦鍚堝悓璁板綍澶辫触:', error);
+ }
+};
+
+// 鏌ョ湅鍚堝悓闄勪欢
+const handleViewContractFiles = (row) => {
+ contractFileList.value = row.fileList || [];
+ contractFileDialogVisible.value = true;
+};
+
+// 鏍煎紡鍖栨枃浠跺ぇ灏�
+const formatFileSize = (bytes) => {
+ if (!bytes) return '0 B';
+ const k = 1024;
+ const sizes = ['B', 'KB', 'MB', 'GB'];
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
+};
+
+// 鎻愪氦琛ㄥ崟
+const submitForm = () => {
+ proxy.$refs["formRef"].validate((valid) => {
+ if (valid) {
if (operationType.value === "edit") {
- updateSupplier(form.value).then(() => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- getList();
- });
+ submitEdit();
} else {
- addSupplier(form.value).then(() => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- getList();
- });
+ submitAdd();
}
- });
- };
-
- const closeDia = () => {
- proxy.resetForm("formRef");
- dialogFormVisible.value = false;
- };
-
- const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
+ }
+ });
+};
+// 鎻愪氦鏂板
+const submitAdd = () => {
+ addSupplier(form.value).then((res) => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ });
+};
+// 鎻愪氦淇敼
+const submitEdit = () => {
+ updateSupplier(form.value).then((res) => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ });
+};
+// 鍏抽棴寮规
+const closeDia = () => {
+ proxy.resetForm("formRef");
+ dialogFormVisible.value = false;
+};
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
.then(() => {
proxy.download("/system/supplier/export", { isWhite: 0 }, "渚涘簲鍟嗘。妗�.xlsx");
})
.catch(() => {
proxy.$modal.msg("宸插彇娑�");
});
- };
-
- const handleDelete = () => {
- if (selectedRows.value.length === 0) {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
+};
+// 鍒犻櫎
+const handleDelete = () => {
+ let ids = [];
+ if (selectedRows.value.length > 0) {
+ // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
const unauthorizedData = selectedRows.value.filter(item => item.maintainUserName !== userStore.nickName);
if (unauthorizedData.length > 0) {
proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
return;
}
- const ids = selectedRows.value.map(item => item.id);
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
+ ids = selectedRows.value.map((item) => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
.then(() => {
tableLoading.value = true;
delSupplier(ids)
- .then(() => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .finally(() => {
- tableLoading.value = false;
- });
+ .then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ })
+ .finally(() => {
+ tableLoading.value = false;
+ });
})
.catch(() => {
proxy.$modal.msg("宸插彇娑�");
});
- };
+};
- const getCurrentDate = () => {
- const today = new Date();
- const year = today.getFullYear();
- const month = String(today.getMonth() + 1).padStart(2, "0");
- const day = String(today.getDate()).padStart(2, "0");
- return `${year}-${month}-${day}`;
- };
+// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� 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}`;
+}
+// 鎵撳紑闄勪欢寮规
+const openFileDialog = async row => {
+ recordId.value = row.id;
+ fileListDialogVisible.value = true;
+};
- onMounted(() => {
- getList();
- });
+onMounted(() => {
+ getList();
+});
- defineExpose({
- getList,
- });
+defineExpose({
+ getList,
+});
</script>
+
--
Gitblit v1.9.3