update:人员临时库放到单页应用中

This commit is contained in:
2021-06-17 17:40:29 +08:00
parent 0da9f368b8
commit d2131c8188
2 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
<template>
<router-view></router-view>
</template>

View File

@@ -0,0 +1,93 @@
<template>
<a-button class="editable-add-btn" style="margin-bottom: 8px" @click="add"
>Add</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"
>
<div v-if="editableData[record.id]">
<a-input
v-model:value="editableData[record.id][col.dataIndex]"
style="margin: -5px 0"
/>
</div>
<template v-else>
{{ text }}
</template>
</template>
<template #opt="{record}">
{{ record.name }}
</template>
</a-table>
</template>
<style></style>
<script>
import { ref } from "@vue/reactivity";
import { onMounted } from "@vue/runtime-core";
export default {
setup() {
var idx = 0;
var users = ref([]);
var editableData = ref({});
var columns = [
{
title: "姓名",
dataIndex: "name"
},
{
title: "证件号码",
dataIndex: "idCard"
},
{
title: "联系电话",
dataIndex: "phone"
},
{
title: "承担工作",
dataIndex: "duty"
},
{
title: "从事专业",
dataIndex: "specialty"
},
{
title: "备注说明",
dataIndex: "remarks"
},
{
title: "操作",
dataIndex: "opt",
editable: false
}
].map(p => ({ ...p, slot: { 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;
}
};
onMounted(() => {
var acceptId = new URL(location.href).searchParams.get("acceptId");
getUsers(acceptId);
});
var edit = id => {
editableData.value[id] = { ...users.value.find(p => p.id) };
};
var add = () => {
var user = {
id: idx--
};
users.value.push(user);
};
var save = () => {};
var cancel = () => {};
return { users, columns, editableData, edit, add, save, cancel };
}
};
</script>