| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form |
| | | :model="queryParams" |
| | | ref="queryRef" |
| | | :inline="true" |
| | | v-show="showSearch" |
| | | label-width="90px" |
| | | <div class="search_form"> |
| | | <div> |
| | | <span class="search_title">承包商名称:</span> |
| | | <el-input |
| | | v-model="searchForm.customerName" |
| | | style="width: 240px" |
| | | placeholder="请输入" |
| | | @change="handleQuery" |
| | | clearable |
| | | :prefix-icon="Search" |
| | | /> |
| | | <el-button type="primary" @click="handleQuery" style="margin-left: 10px" |
| | | >搜索</el-button |
| | | > |
| | | </div> |
| | | <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 |
| | | 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="70%" |
| | | @close="closeDia" |
| | | > |
| | | <el-form-item label="承包商名称" prop="contractorName"> |
| | | <el-input |
| | | v-model="queryParams.contractorName" |
| | | placeholder="请输入承包商名称" |
| | | clearable |
| | | style="width: 220px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="联系人" prop="contactPerson"> |
| | | <el-input |
| | | v-model="queryParams.contactPerson" |
| | | placeholder="请输入联系人" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="联系电话" prop="contactPhone"> |
| | | <el-input |
| | | v-model="queryParams.contactPhone" |
| | | placeholder="请输入联系电话" |
| | | clearable |
| | | style="width: 240px" |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="状态" prop="status"> |
| | | <el-select |
| | | v-model="queryParams.status" |
| | | placeholder="承包商状态" |
| | | clearable |
| | | style="width: 240px" |
| | | > |
| | | <el-option |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :label="dict.label" |
| | | :value="dict.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="Search" @click="handleQuery" |
| | | >搜索</el-button |
| | | > |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | >新增</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | >修改</el-button |
| | | > |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | >删除</el-button |
| | | > |
| | | </el-col> |
| | | <right-toolbar |
| | | v-model:showSearch="showSearch" |
| | | @queryTable="getList" |
| | | :columns="columns" |
| | | ></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table |
| | | v-loading="loading" |
| | | :data="contractorList" |
| | | @selection-change="handleSelectionChange" |
| | | stripe |
| | | > |
| | | <el-table-column type="selection" width="50" align="center" /> |
| | | <el-table-column |
| | | label="承包商编号" |
| | | align="center" |
| | | key="contractorId" |
| | | prop="contractorId" |
| | | v-if="columns[0].visible" |
| | | /> |
| | | <el-table-column |
| | | label="承包商名称" |
| | | align="center" |
| | | key="contractorName" |
| | | prop="contractorName" |
| | | v-if="columns[1].visible" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="联系人" |
| | | align="center" |
| | | key="contactPerson" |
| | | prop="contactPerson" |
| | | v-if="columns[2].visible" |
| | | /> |
| | | <el-table-column |
| | | label="联系电话" |
| | | align="center" |
| | | key="contactPhone" |
| | | prop="contactPhone" |
| | | v-if="columns[3].visible" |
| | | /> |
| | | <el-table-column |
| | | label="联系邮箱" |
| | | align="center" |
| | | key="contactEmail" |
| | | prop="contactEmail" |
| | | v-if="columns[4].visible" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="地址" |
| | | align="center" |
| | | key="address" |
| | | prop="address" |
| | | v-if="columns[5].visible" |
| | | :show-overflow-tooltip="true" |
| | | /> |
| | | <el-table-column |
| | | label="状态" |
| | | align="center" |
| | | key="status" |
| | | v-if="columns[6].visible" |
| | | <el-form |
| | | :model="form" |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | ref="formRef" |
| | | > |
| | | <template #default="scope"> |
| | | <el-switch |
| | | v-model="scope.row.status" |
| | | active-value="0" |
| | | inactive-value="1" |
| | | @change="handleStatusChange(scope.row)" |
| | | ></el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="创建时间" |
| | | align="center" |
| | | prop="createTime" |
| | | v-if="columns[7].visible" |
| | | width="160" |
| | | > |
| | | <template #default="scope"> |
| | | <span>{{ parseTime(scope.row.createTime) }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="操作" |
| | | align="center" |
| | | width="150" |
| | | class-name="small-padding fixed-width" |
| | | > |
| | | <template #default="scope"> |
| | | <el-tooltip |
| | | content="修改" |
| | | placement="top" |
| | | > |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Edit" |
| | | @click="handleUpdate(scope.row)" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | <el-tooltip |
| | | content="删除" |
| | | placement="top" |
| | | > |
| | | <el-button |
| | | link |
| | | type="primary" |
| | | icon="Delete" |
| | | @click="handleDelete(scope.row)" |
| | | ></el-button> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- 添加或修改承包商配置对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="600px" append-to-body> |
| | | <el-form :model="form" :rules="rules" ref="contractorRef" label-width="80px"> |
| | | <el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="承包商名称" prop="contractorName"> |
| | | <el-form-item label="承包商名称:" prop="customerName"> |
| | | <el-input |
| | | v-model="form.contractorName" |
| | | placeholder="请输入承包商名称" |
| | | maxlength="50" |
| | | v-model="form.customerName" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系人" prop="contactPerson"> |
| | | <el-form-item |
| | | label="纳税人识别号:" |
| | | prop="taxpayerIdentificationNumber" |
| | | > |
| | | <el-input |
| | | v-model="form.contactPerson" |
| | | placeholder="请输入联系人" |
| | | maxlength="20" |
| | | v-model="form.taxpayerIdentificationNumber" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系电话" prop="contactPhone"> |
| | | <el-form-item label="公司地址:" prop="companyAddress"> |
| | | <el-input |
| | | v-model="form.contactPhone" |
| | | placeholder="请输入联系电话" |
| | | maxlength="11" |
| | | v-model="form.companyAddress" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="联系邮箱" prop="contactEmail"> |
| | | <el-form-item label="公司电话:" prop="companyPhone"> |
| | | <el-input |
| | | v-model="form.contactEmail" |
| | | placeholder="请输入联系邮箱" |
| | | maxlength="50" |
| | | v-model="form.companyPhone" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="地址" prop="address"> |
| | | <el-input |
| | | v-model="form.address" |
| | | placeholder="请输入地址" |
| | | maxlength="100" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="状态"> |
| | | <el-radio-group v-model="form.status"> |
| | | <el-radio |
| | | v-for="dict in sys_normal_disable" |
| | | :key="dict.value" |
| | | :value="dict.value" |
| | | >{{ dict.label }}</el-radio |
| | | > |
| | | </el-radio-group> |
| | | <el-form-item label="银行基本户:" prop="basicBankAccount"> |
| | | <el-input |
| | | v-model="form.basicBankAccount" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="银行账号:" prop="bankAccount"> |
| | | <el-input |
| | | v-model="form.bankAccount" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="备注"> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="开户行号:" prop="bankCode"> |
| | | <el-input |
| | | v-model="form.remark" |
| | | type="textarea" |
| | | placeholder="请输入内容" |
| | | ></el-input> |
| | | v-model="form.bankCode" |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </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"> |
| | | <el-select |
| | | v-model="form.maintainer" |
| | | placeholder="请选择" |
| | | clearable |
| | | disabled |
| | | > |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.nickName" |
| | | :label="item.nickName" |
| | | :value="item.nickName" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="维护时间:" prop="maintenanceTime"> |
| | | <el-date-picker |
| | | style="width: 100%" |
| | | v-model="form.maintenanceTime" |
| | | value-format="YYYY-MM-DD" |
| | | format="YYYY-MM-DD" |
| | | type="date" |
| | | placeholder="请选择" |
| | | clearable |
| | | disabled |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">确 定</el-button> |
| | | <el-button @click="cancel">取 消</el-button> |
| | | <el-button type="primary" @click="submitForm">确认</el-button> |
| | | <el-button @click="closeDia">取消</el-button> |
| | | </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" |
| | | :before-upload="upload.beforeUpload" |
| | | :on-progress="upload.onProgress" |
| | | :on-success="upload.onSuccess" |
| | | :on-error="upload.onError" |
| | | :on-change="upload.onChange" |
| | | :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>仅允许导入xls、xlsx格式文件。</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> |
| | | |
| | | <script setup name="Contractor"> |
| | | import { ref, reactive, toRefs, watch, onMounted } from 'vue'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { parseTime } from '@/utils/ruoyi'; |
| | | <script setup> |
| | | import {onMounted, ref} from "vue"; |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import { |
| | | addCustomer, |
| | | delCustomer, |
| | | getCustomer, |
| | | listCustomer, |
| | | updateCustomer, |
| | | } from "@/api/basicData/customerFile.js"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { getToken } from "@/utils/auth.js"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const userStore = useUserStore(); |
| | | |
| | | const contractorList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | |
| | | // 列显隐信息 |
| | | const columns = ref([ |
| | | { key: 0, label: `承包商编号`, visible: true }, |
| | | { key: 1, label: `承包商名称`, visible: true }, |
| | | { key: 2, label: `联系人`, visible: true }, |
| | | { key: 3, label: `联系电话`, visible: true }, |
| | | { key: 4, label: `联系邮箱`, visible: true }, |
| | | { key: 5, label: `地址`, visible: true }, |
| | | { key: 6, label: `状态`, visible: true }, |
| | | { key: 7, label: `创建时间`, visible: true }, |
| | | ]); |
| | | |
| | | const data = reactive({ |
| | | form: { |
| | | contractorId: undefined, |
| | | contractorName: undefined, |
| | | contactPerson: undefined, |
| | | contactPhone: undefined, |
| | | contactEmail: undefined, |
| | | address: undefined, |
| | | status: "0", |
| | | remark: undefined, |
| | | const tableColumn = ref([ |
| | | { |
| | | label: "承包商名称", |
| | | prop: "customerName", |
| | | width: 220, |
| | | }, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | contractorName: undefined, |
| | | contactPerson: undefined, |
| | | contactPhone: undefined, |
| | | status: undefined, |
| | | { |
| | | label: "纳税人识别码", |
| | | prop: "taxpayerIdentificationNumber", |
| | | width: 220, |
| | | }, |
| | | { |
| | | label: "地址及联系方式", |
| | | prop: "addressPhone", |
| | | width: 250, |
| | | }, |
| | | { |
| | | label: "联系人", |
| | | prop: "contactPerson", |
| | | }, |
| | | { |
| | | label: "联系电话", |
| | | prop: "contactPhone", |
| | | width:150 |
| | | }, |
| | | { |
| | | label: "银行基本户", |
| | | prop: "basicBankAccount", |
| | | width: 220, |
| | | }, |
| | | { |
| | | label: "银行账号", |
| | | prop: "bankAccount", |
| | | width: 220, |
| | | }, |
| | | { |
| | | label: "开户行号", |
| | | prop: "bankCode", |
| | | width:220 |
| | | }, |
| | | { |
| | | label: "维护人", |
| | | prop: "maintainer", |
| | | }, |
| | | { |
| | | label: "维护时间", |
| | | prop: "maintenanceTime", |
| | | width: 100, |
| | | }, |
| | | { |
| | | dataType: "action", |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: 'right', |
| | | operation: [ |
| | | { |
| | | name: "编辑", |
| | | type: "text", |
| | | clickFun: (row) => { |
| | | openForm("edit", row); |
| | | }, |
| | | disabled: (row) => { |
| | | return row.maintainer !== userStore.nickName |
| | | } |
| | | }, |
| | | ], |
| | | }, |
| | | ]); |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const userList = ref([]); |
| | | const tableLoading = ref(false); |
| | | const page = reactive({ |
| | | current: 1, |
| | | 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: "", |
| | | }, |
| | | form: { |
| | | customerName: "", |
| | | taxpayerIdentificationNumber: "", |
| | | companyAddress: "", |
| | | companyPhone: "", |
| | | contactPerson: "", |
| | | contactPhone: "", |
| | | maintainer: "", |
| | | maintenanceTime: "", |
| | | basicBankAccount: "", |
| | | bankAccount: "", |
| | | bankCode: "", |
| | | }, |
| | | rules: { |
| | | contractorName: [ |
| | | { required: true, message: "承包商名称不能为空", trigger: "blur" }, |
| | | customerName: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | taxpayerIdentificationNumber: [ |
| | | { required: true, message: "请输入", trigger: "blur" }, |
| | | ], |
| | | contactPerson: [ |
| | | { required: true, message: "联系人不能为空", trigger: "blur" }, |
| | | companyAddress: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | companyPhone: [{ 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" }, |
| | | ], |
| | | contactPhone: [ |
| | | { required: true, message: "联系电话不能为空", trigger: "blur" }, |
| | | { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }, |
| | | ], |
| | | contactEmail: [ |
| | | { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }, |
| | | ], |
| | | address: [ |
| | | { required: true, message: "地址不能为空", trigger: "blur" }, |
| | | ], |
| | | basicBankAccount: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | bankAccount: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | bankCode: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | }, |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | // 模拟数据 |
| | | const mockContractors = [ |
| | | { |
| | | contractorId: 1, |
| | | contractorName: "北京建工集团", |
| | | contactPerson: "张三", |
| | | contactPhone: "13800138001", |
| | | contactEmail: "zhangsan@example.com", |
| | | address: "北京市朝阳区建国路88号", |
| | | status: "0", |
| | | createTime: "2024-01-01 10:00:00", |
| | | remark: "大型建筑施工企业", |
| | | }, |
| | | { |
| | | contractorId: 2, |
| | | contractorName: "上海城建集团", |
| | | contactPerson: "李四", |
| | | contactPhone: "13800138002", |
| | | contactEmail: "lisi@example.com", |
| | | address: "上海市浦东新区世纪大道100号", |
| | | status: "0", |
| | | createTime: "2024-01-02 10:00:00", |
| | | remark: "城市基础设施建设企业", |
| | | }, |
| | | { |
| | | contractorId: 3, |
| | | contractorName: "广州建筑集团", |
| | | contactPerson: "王五", |
| | | contactPhone: "13800138003", |
| | | contactEmail: "wangwu@example.com", |
| | | address: "广州市天河区珠江新城冼村路5号", |
| | | status: "1", |
| | | createTime: "2024-01-03 10:00:00", |
| | | remark: "广东省知名建筑企业", |
| | | }, |
| | | { |
| | | contractorId: 4, |
| | | contractorName: "深圳建工集团", |
| | | contactPerson: "赵六", |
| | | contactPhone: "13800138004", |
| | | contactEmail: "zhaoliu@example.com", |
| | | address: "深圳市福田区福中三路1006号", |
| | | status: "0", |
| | | createTime: "2024-01-04 10:00:00", |
| | | remark: "深圳市重点建筑企业", |
| | | }, |
| | | { |
| | | contractorId: 5, |
| | | contractorName: "杭州建工集团", |
| | | contactPerson: "孙七", |
| | | contactPhone: "13800138005", |
| | | contactEmail: "sunqi@example.com", |
| | | address: "杭州市江干区钱江新城富春路188号", |
| | | status: "0", |
| | | createTime: "2024-01-05 10:00:00", |
| | | remark: "浙江省知名建筑企业", |
| | | }, |
| | | ]; |
| | | |
| | | /** 查询承包商列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | // 模拟API请求延迟 |
| | | setTimeout(() => { |
| | | let data = [...mockContractors]; |
| | | // 模拟搜索过滤 |
| | | if (queryParams.value.contractorName) { |
| | | data = data.filter(item => item.contractorName.includes(queryParams.value.contractorName)); |
| | | const upload = reactive({ |
| | | // 是否显示弹出层(客户导入) |
| | | open: false, |
| | | // 弹出层标题(客户导入) |
| | | title: "", |
| | | // 是否禁用上传 |
| | | isUploading: false, |
| | | // 设置上传的请求头部 |
| | | 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 文件"); |
| | | } |
| | | if (queryParams.value.contactPerson) { |
| | | data = data.filter(item => item.contactPerson.includes(queryParams.value.contactPerson)); |
| | | return isValid; |
| | | }, |
| | | // 文件状态改变时的回调 |
| | | onChange: (file, fileList) => { |
| | | console.log('文件状态改变', file, fileList); |
| | | }, |
| | | // 文件上传成功时的回调 |
| | | onSuccess: (response, file, fileList) => { |
| | | console.log('上传成功', response, file, fileList); |
| | | if(response.code === 200){ |
| | | proxy.$modal.msgSuccess("文件上传成功"); |
| | | }else if(response.code === 500){ |
| | | proxy.$modal.msgError(response.msg); |
| | | }else{ |
| | | proxy.$modal.msgWarning(response.msg); |
| | | } |
| | | if (queryParams.value.contactPhone) { |
| | | data = data.filter(item => item.contactPhone.includes(queryParams.value.contactPhone)); |
| | | } |
| | | if (queryParams.value.status) { |
| | | data = data.filter(item => item.status === queryParams.value.status); |
| | | } |
| | | // 模拟分页 |
| | | const start = (queryParams.value.pageNum - 1) * queryParams.value.pageSize; |
| | | const end = start + queryParams.value.pageSize; |
| | | contractorList.value = data.slice(start, end); |
| | | total.value = data.length; |
| | | loading.value = false; |
| | | }, 500); |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | Object.assign(queryParams.value, { |
| | | contractorName: undefined, |
| | | contactPerson: undefined, |
| | | contactPhone: undefined, |
| | | status: undefined, |
| | | }); |
| | | handleQuery(); |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const contractorIds = row.contractorId || ids.value; |
| | | ElMessage.confirm(`是否确认删除承包商编号为"${contractorIds}"的数据项?`).then(() => { |
| | | // 模拟删除操作 |
| | | ElMessage.success("删除成功"); |
| | | getList(); |
| | | }).catch(() => {}); |
| | | } |
| | | |
| | | /** 状态修改 */ |
| | | function handleStatusChange(row) { |
| | | let text = row.status === "0" ? "启用" : "停用"; |
| | | ElMessage.confirm(`确认要"${text}""${row.contractorName}"承包商吗?`).then(() => { |
| | | // 模拟状态修改 |
| | | ElMessage.success(text + "成功"); |
| | | getList(); |
| | | }).catch(() => { |
| | | row.status = row.status === "0" ? "1" : "0"; |
| | | }); |
| | | } |
| | | |
| | | /** 选择条数 */ |
| | | function handleSelectionChange(selection) { |
| | | ids.value = selection.map((item) => item.contractorId); |
| | | single.value = selection.length != 1; |
| | | multiple.value = !selection.length; |
| | | } |
| | | |
| | | /** 重置操作表单 */ |
| | | function reset() { |
| | | form.value = { |
| | | contractorId: undefined, |
| | | contractorName: undefined, |
| | | contactPerson: undefined, |
| | | contactPhone: undefined, |
| | | contactEmail: undefined, |
| | | address: undefined, |
| | | status: "0", |
| | | remark: undefined, |
| | | }; |
| | | } |
| | | |
| | | /** 取消按钮 */ |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | } |
| | | |
| | | /** 新增按钮操作 */ |
| | | function handleAdd() { |
| | | reset(); |
| | | open.value = true; |
| | | title.value = "添加承包商"; |
| | | } |
| | | |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const contractorId = row.contractorId || ids.value; |
| | | // 模拟获取详情 |
| | | const contractor = mockContractors.find(item => item.contractorId === contractorId); |
| | | if (contractor) { |
| | | form.value = { ...contractor }; |
| | | open.value = true; |
| | | title.value = "修改承包商"; |
| | | }, |
| | | // 文件上传失败时的回调 |
| | | onError: (error, file, fileList) => { |
| | | console.error('上传失败', error, file, fileList); |
| | | 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 = () => { |
| | | page.current = 1; |
| | | getList(); |
| | | }; |
| | | const pagination = (obj) => { |
| | | page.current = obj.page; |
| | | page.size = obj.limit; |
| | | getList(); |
| | | }; |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | listCustomer({ ...searchForm.value, ...page }).then((res) => { |
| | | tableLoading.value = false; |
| | | tableData.value = res.records; |
| | | page.total = res.total; |
| | | }); |
| | | }; |
| | | // 表格选择数据 |
| | | const handleSelectionChange = (selection) => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | /** 提交上传文件 */ |
| | | function submitFileForm() { |
| | | proxy.$refs["uploadRef"].submit(); |
| | | } |
| | | /** 导入按钮操作 */ |
| | | function handleImport() { |
| | | upload.title = "客户导入"; |
| | | upload.open = true; |
| | | } |
| | | // 打开弹框 |
| | | 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; |
| | | }); |
| | | 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] |
| | | } |
| | | }); |
| | | |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | // 模拟表单验证 |
| | | const requiredFields = ['contractorName', 'contactPerson', 'contactPhone', 'address']; |
| | | const isInvalid = requiredFields.some(field => !form.value[field]); |
| | | |
| | | if (isInvalid) { |
| | | ElMessage.error("请填写必填字段"); |
| | | }); |
| | | } |
| | | dialogFormVisible.value = true; |
| | | }; |
| | | // 提交表单 |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate((valid) => { |
| | | if (valid) { |
| | | if (operationType.value === "edit") { |
| | | submitEdit(); |
| | | } else { |
| | | submitAdd(); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | | // 提交新增 |
| | | 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(); |
| | | getList(); |
| | | }); |
| | | }; |
| | | // 提交修改 |
| | | 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(); |
| | | getList(); |
| | | }); |
| | | }; |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |
| | | dialogFormVisible.value = false; |
| | | }; |
| | | // 导出 |
| | | const handleOut = () => { |
| | | ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | proxy.download("/basic/customer/export", {}, "客户档案.xlsx"); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | // 删除 |
| | | 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("请选择数据"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除提示", { |
| | | confirmButtonText: "确认", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | tableLoading.value = true; |
| | | delCustomer(ids) |
| | | .then((res) => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }) |
| | | .finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }); |
| | | }; |
| | | |
| | | // 模拟提交操作 |
| | | ElMessage.success(title.value === "添加承包商" ? "新增成功" : "修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | // 获取当前日期并格式化为 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 sys_normal_disable = [ |
| | | { value: "0", label: "正常" }, |
| | | { value: "1", label: "禁用" }, |
| | | ]; |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"></style> |