|
@@ -17,7 +17,7 @@
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
icon="Check"
|
|
|
- style="margin-right: 10px"
|
|
|
+ style="margin-right: 10px;margin-left: 10px;"
|
|
|
@click="handleSave"
|
|
|
>保 存
|
|
|
</el-button
|
|
@@ -30,7 +30,7 @@
|
|
|
<el-button
|
|
|
type="warning"
|
|
|
icon="Plus"
|
|
|
- @click="handleOpenPerson('person')"
|
|
|
+ @click="handleAddConcacts()"
|
|
|
>添加人员
|
|
|
</el-button
|
|
|
>
|
|
@@ -55,11 +55,40 @@
|
|
|
height="100%"
|
|
|
>
|
|
|
<el-table-column type="selection" width="40" align="center"/>
|
|
|
- <el-table-column label="姓名" prop="name" align="center"/>
|
|
|
- <el-table-column label="职务" prop="rule" align="center"/>
|
|
|
- <el-table-column label="电话" prop="phoneNumber" align="center"/>
|
|
|
- <el-table-column label="邮箱" prop="eamil" align="center"/>
|
|
|
- <el-table-column label="默认联系人" align="center" prop="status" width="200">
|
|
|
+ <el-table-column type="index" label="行号" width="50" align="center" />
|
|
|
+ <el-table-column label="姓名" prop="name" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="scope.row.name"
|
|
|
+ placeholder="请输入姓名"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="职务" prop="rule" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="scope.row.rule"
|
|
|
+ placeholder="请输入职务"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="电话" prop="phoneNumber" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="scope.row.phoneNumber"
|
|
|
+ placeholder="请输入电话"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="邮箱" prop="email" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input
|
|
|
+ v-model.trim="scope.row.email"
|
|
|
+ placeholder="请输入邮箱"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="是否默认联系人" align="center" prop="status" width="200">
|
|
|
<template #default="scope">
|
|
|
<el-switch
|
|
|
v-model="scope.row.isDefault"
|
|
@@ -78,18 +107,34 @@
|
|
|
</el-drawer>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
+import {saveSupplierContacts, getSupplierContacts} from "@/api/business/supplier";
|
|
|
const {proxy} = getCurrentInstance();
|
|
|
-const emit = defineEmits(["handleSaveResourceSuccess"]);
|
|
|
+const emit = defineEmits(["handleSaveSuccess"]);
|
|
|
/** 表单抽屉 页变量 */
|
|
|
const selections = ref([]);
|
|
|
const loading = ref(false);
|
|
|
+const info = ref({})
|
|
|
const contactsList = ref([]);
|
|
|
const visible = ref(false);
|
|
|
+const detailsRow = {
|
|
|
+ id: null,
|
|
|
+ name: "",
|
|
|
+ rule: "",
|
|
|
+ phoneNumber: "",
|
|
|
+ email:"",
|
|
|
+ isDefault:0
|
|
|
+};
|
|
|
|
|
|
/*********************** 方法区 ****************************/
|
|
|
/** 打开抽屉 */
|
|
|
-const open = (row) => {
|
|
|
+const open = (data) => {
|
|
|
loading.value = true;
|
|
|
+ info.value = data
|
|
|
+ getSupplierContacts({supplierId: data.id}).then(res =>{
|
|
|
+ if(res.code == 200) {
|
|
|
+ contactsList.value = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
loading.value = false;
|
|
|
visible.value = true;
|
|
|
};
|
|
@@ -100,17 +145,33 @@ const open = (row) => {
|
|
|
function handleSelectionChange(selection) {
|
|
|
selections.value = selection;
|
|
|
}
|
|
|
+//添加人员
|
|
|
+function handleAddConcacts() {
|
|
|
+ const newDetail = JSON.parse(JSON.stringify(detailsRow));
|
|
|
+ newDetail.supplierId = info.value.id
|
|
|
+ newDetail.supplierName = info.value.name
|
|
|
+ contactsList.value.push(newDetail)
|
|
|
+}
|
|
|
+function handleChangeAuditStatus(row) {
|
|
|
+ if(row.isDefault == 1) {
|
|
|
+ var defaultList = contactsList.value.filter(item => {return item.isDefault == 1 && item!=row})
|
|
|
+ console.log(defaultList)
|
|
|
+ if (defaultList.length > 0) {
|
|
|
+ contactsList.value = contactsList.value.map(item => {
|
|
|
+ if (item.isDefault == 1) {
|
|
|
+ return defaultList[0] === item ? { ...item, isDefault: 0 }: item ;
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
/**批量删除 */
|
|
|
function handleDelete() {
|
|
|
- checkUseEquipment(selections.value).then(res => {
|
|
|
- if(res.code == 200) {
|
|
|
- form.value.groupDetailList = form.value.groupDetailList.filter(
|
|
|
+ contactsList.value = contactsList.value.filter(
|
|
|
(item) => !selections.value.some((selectedItem) => selectedItem === item)
|
|
|
);
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -122,7 +183,36 @@ function close() {
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
const handleSave = () => {
|
|
|
-
|
|
|
+ var flag = true
|
|
|
+ for(let i = 0; i < contactsList.value.length; i++) {
|
|
|
+ if(contactsList.value[i].name =="") {
|
|
|
+ proxy.$modal.msgError("第"+(i+1)+"行姓名不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(contactsList.value[i].phoneNumber =="") {
|
|
|
+ proxy.$modal.msgError("第"+(i+1)+"行电话不能为空");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(contactsList.value.length == 0) {
|
|
|
+ flag = false
|
|
|
+ proxy.$modal.msgError("请添加联系人");
|
|
|
+ }
|
|
|
+ let isDefaultList = contactsList.value.filter(item => { return item.isDefault == 1
|
|
|
+ })
|
|
|
+ if(isDefaultList.length == 0) {
|
|
|
+ flag = false
|
|
|
+ proxy.$modal.msgError("请设置默认联系人");
|
|
|
+ }
|
|
|
+ if(flag) {
|
|
|
+ saveSupplierContacts(contactsList.value).then(res => {
|
|
|
+ if(res.code == 200) {
|
|
|
+ proxy.$modal.msgSuccess("保存成功");
|
|
|
+ visible.value = false;
|
|
|
+ emit("handleSaveSuccess");
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
}
|
|
|
|
|
|
|