update:项目临时人员

This commit is contained in:
2021-06-18 17:07:34 +08:00
parent d2131c8188
commit 8c6b9cb9c5
2 changed files with 150 additions and 28 deletions

20
src/services/specialty.js Normal file
View File

@@ -0,0 +1,20 @@
export default [
{ value: 1, label: "岩土" },
{ value: 4, label: "建筑" },
{ value: 5, label: "道路" },
{ value: 6, label: "桥梁" },
{ value: 7, label: "隧道" },
{ value: 24, label: "结构" },
{ value: 25, label: "暖通" },
{ value: 26, label: "给排水" },
{ value: 27, label: "电气" },
{ value: 28, label: "勘察" },
{ value: 31, label: "燃气工程" },
{ value: 32, label: "幕墙" },
{ value: 33, label: "弱电" },
{ value: 34, label: "装配" },
{ value: 35, label: "总图" },
{ value: 36, label: "仪表(仅限于消防相关图纸)" },
{ value: 37, label: "给排水(含消防)" },
{ value: 38, label: "电气(含电信、弱电)" }
];

View File

@@ -1,25 +1,58 @@
<template>
<a-button class="editable-add-btn" style="margin-bottom: 8px" @click="add"
>Add</a-button
>添加人员</a-button
>
<a-table bordered :data-source="users" :columns="columns">
<template
v-for="col in columns.filter(c => c.editable !== false)"
#[col.dataIndex]="{ text, record }"
:key="col"
:key="col.id"
>
<div v-if="editableData[record.id]">
<a-input
<div v-if="col.options">
<a-select
v-if="editableData[record.id]"
v-model:value="editableData[record.id][col.dataIndex]"
style="margin: -5px 0"
/>
>
<a-select-option
v-for="option in col.options"
:key="option"
:value="option.value"
>
{{ option.label }}
</a-select-option>
</a-select>
<template v-else>
{{ col.options.find(p => p.value == text)?.label }}
</template>
</div>
<div v-else>
<a-input
v-if="editableData[record.id]"
:maxlength="100"
v-model:value="editableData[record.id][col.dataIndex]"
/>
<template v-else>
{{ text }}
</template>
</div>
</template>
<template #opt="{ record }">
{{ record.name }}
<div v-if="record.freezed">已冻结</div>
<div v-else class="editable-row-operations">
<a-space v-if="editableData[record.id]">
<a @click="save(record.id)">保存</a>
<a-popconfirm title="确认取消?" @confirm="cancel(record.id)">
<a>取消</a>
</a-popconfirm>
</a-space>
<a-space v-else>
<a @click="edit(record.id)">编辑</a>
<a-popconfirm title="确认删除?" @confirm="del(record.id)">
<a>删除</a>
</a-popconfirm>
</a-space>
</div>
</template>
</a-table>
</template>
@@ -27,8 +60,18 @@
<script>
import { ref } from "@vue/reactivity";
import { onMounted } from "@vue/runtime-core";
import { get, post } from "@/services/http";
import { message } from "ant-design-vue";
import specialty from "@/services/specialty";
const duties = [
{ value: "项目负责人", label: "项目负责人" },
{ value: "专业负责人", label: "专业负责人" },
{ value: "设计人员", label: "设计人员" },
{ value: "校对人员", label: "校对人员" }
];
export default {
setup() {
var acceptId = new URL(location.href).searchParams.get("acceptId");
var idx = 0;
var users = ref([]);
var editableData = ref({});
@@ -47,11 +90,13 @@ export default {
},
{
title: "承担工作",
dataIndex: "duty"
dataIndex: "duty",
options: duties
},
{
title: "从事专业",
dataIndex: "specialty"
dataIndex: "specialtyId",
options: specialty
},
{
title: "备注说明",
@@ -60,34 +105,91 @@ export default {
{
title: "操作",
dataIndex: "opt",
editable: false
editable: false,
slots: { customRender: "opt" }
}
].map(p => ({ ...p, slot: { customRender: p.dataIndex } }));
].map(p => ({ ...p, slots: { customRender: p.dataIndex } }));
var getUsers = async acceptId => {
var response = await fetch(
"/api2/ProjectExtraUser/GetUsers?acceptId=" + acceptId
);
var body = await response.json();
if (body.errorCode == 0) {
users.value = body.data;
var res = await get("/api2/ProjectExtraUser/GetUsers", { acceptId });
if (res.errorCode == 0) {
users.value = res.data;
}
};
onMounted(() => {
var acceptId = new URL(location.href).searchParams.get("acceptId");
getUsers(acceptId);
});
var edit = id => {
editableData.value[id] = { ...users.value.find(p => p.id) };
editableData.value[id] = { ...users.value.find(u => u.id === id) };
};
var add = () => {
var id = idx--;
var user = {
id: idx--
id,
acceptId
};
users.value.push(user);
edit(user.id);
};
var save = id => {
if (id < 1) {
addUser(id);
} else {
modifyUser(id);
}
};
var del = id => {
if (id < 1) {
users.value = users.value.filter(u => u.id !== id);
} else {
deleteUser(id);
}
};
var cancel = id => {
delete editableData.value[id];
};
var addUser = async id => {
var user = users.value.find(u => u.id == id);
var param = { ...user, ...editableData.value[id] };
var res = await post("/api2/projectExtraUser/AddUser", param);
if (res.errorCode == 0) {
Object.assign(user, editableData.value[id]);
user.id = res.data;
delete editableData.value[id];
} else {
message.error(res.errorMsg);
}
};
var modifyUser = async id => {
var user = users.value.find(u => u.id == id);
var param = { ...user, ...editableData.value[id] };
var res = await post("/api2/projectExtraUser/ModifyUser", param);
if (res.errorCode == 0) {
Object.assign(user, editableData.value[id]);
delete editableData.value[id];
} else {
message.error(res.errorMsg);
}
};
var deleteUser = async id => {
var res = await post("/api2/projectExtraUser/DeleteUser", { id });
if (res.errorCode == 0) {
users.value = users.value.filter(u => u.id !== id);
} else {
message.error(res.errorMsg);
}
};
return {
users,
columns,
editableData,
edit,
add,
save,
cancel,
del,
addUser,
modifyUser
};
var save = () => {};
var cancel = () => {};
return { users, columns, editableData, edit, add, save, cancel };
}
};
</script>