|
|
@ -14,7 +14,7 @@ |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
<template v-else-if="['name', 'account', 'role', 'unit'].includes(column.dataIndex)"> |
|
|
|
<template v-else-if="['memberName', 'phone'].includes(column.dataIndex)"> |
|
|
|
<div> |
|
|
|
<a-input v-if="record.isEdit === 1" v-model:value="record[column.dataIndex]" style="margin: -5px 0" /> |
|
|
|
<template v-else> |
|
|
@ -30,37 +30,36 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { ref } from 'vue'; |
|
|
|
import { ref, computed } from 'vue'; |
|
|
|
import { useStore } from 'vuex'; |
|
|
|
import { PlusCircleOutlined } from '@ant-design/icons-vue'; |
|
|
|
// import { memberQuery, saveMember } from 'apis'; |
|
|
|
import { memberQuery } from 'apis'; |
|
|
|
import { memberQuery, saveMember, updateMember, delMember } from 'apis'; |
|
|
|
|
|
|
|
const store = useStore(); |
|
|
|
const projectId = computed(() => store.getters['projects/projectId']); |
|
|
|
const sessionProject = sessionStorage.getItem('project'); |
|
|
|
|
|
|
|
if (sessionProject) { |
|
|
|
const project = JSON.parse(sessionProject); |
|
|
|
store.commit('projects/setProject', project); |
|
|
|
} |
|
|
|
|
|
|
|
const columns = ref([ |
|
|
|
{ |
|
|
|
title: '序号', |
|
|
|
dataIndex: 'id', |
|
|
|
key: 'id', |
|
|
|
dataIndex: 'indexId', |
|
|
|
key: 'indexId', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '成员名', |
|
|
|
dataIndex: 'name', |
|
|
|
key: 'name', |
|
|
|
dataIndex: 'memberName', |
|
|
|
key: 'memberName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '账号', |
|
|
|
dataIndex: 'account', |
|
|
|
title: '手机号', |
|
|
|
dataIndex: 'phone', |
|
|
|
key: 'account', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '角色', |
|
|
|
key: 'role', |
|
|
|
dataIndex: 'role', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '所属单位', |
|
|
|
key: 'unit', |
|
|
|
dataIndex: 'unit', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
|
key: 'action', |
|
|
@ -68,60 +67,36 @@ const columns = ref([ |
|
|
|
}, |
|
|
|
]); |
|
|
|
|
|
|
|
const dataList = ref([ |
|
|
|
{ |
|
|
|
key: '1', |
|
|
|
id: '1', |
|
|
|
name: '郁教授', |
|
|
|
account: '12345678910', |
|
|
|
role: '课题主持人', |
|
|
|
unit: '课题主持人', |
|
|
|
isEdit: 0, |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: '2', |
|
|
|
id: '2', |
|
|
|
name: '张野', |
|
|
|
account: '10987654321', |
|
|
|
role: '子课题负责人1', |
|
|
|
unit: '子课题负责人1', |
|
|
|
isEdit: 0, |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: '3', |
|
|
|
id: '3', |
|
|
|
name: '郁教授', |
|
|
|
account: '12345678910', |
|
|
|
role: '课题主持人', |
|
|
|
unit: '课题主持人', |
|
|
|
isEdit: 0, |
|
|
|
}, |
|
|
|
{ |
|
|
|
key: '4', |
|
|
|
id: '4', |
|
|
|
name: '郁教授', |
|
|
|
account: '12345678910', |
|
|
|
role: '课题主持人', |
|
|
|
unit: '课题主持人', |
|
|
|
isEdit: 0, |
|
|
|
}, |
|
|
|
]); |
|
|
|
const dataList = ref([]); |
|
|
|
|
|
|
|
getList(); |
|
|
|
|
|
|
|
async function getList() { |
|
|
|
try { |
|
|
|
const params = { param: {} }; |
|
|
|
const params = { param: { projectId: projectId.value } }; |
|
|
|
const data = await memberQuery(params); |
|
|
|
return data; |
|
|
|
dataList.value = []; |
|
|
|
|
|
|
|
data.forEach((item, index) => { |
|
|
|
const obj = { |
|
|
|
key: index + 1, |
|
|
|
indexId: index + 1, |
|
|
|
memberId: item.memberId, |
|
|
|
memberName: item.memberName, |
|
|
|
phone: item.phone, |
|
|
|
isEdit: 0, |
|
|
|
}; |
|
|
|
|
|
|
|
dataList.value.push(obj); |
|
|
|
}); |
|
|
|
} catch (error) { |
|
|
|
console.log('error', error); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const addMember = () => { |
|
|
|
const num = (dataList.value.length + 1).toString; |
|
|
|
const obj = { key: num, id: num, name: '', account: '', role: '', unit: '', isEdit: 1 }; |
|
|
|
const num = dataList.value.length + 1; |
|
|
|
const obj = { key: num, indexId: num, memberName: '', phone: '', isEdit: 1 }; |
|
|
|
dataList.value.push(obj); |
|
|
|
}; |
|
|
|
|
|
|
@ -141,12 +116,52 @@ function cancel(key) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function save(key) { |
|
|
|
console.log(key); |
|
|
|
async function save(key) { |
|
|
|
const params = { |
|
|
|
param: { |
|
|
|
projectId: projectId.value, |
|
|
|
id: '', |
|
|
|
name: '', |
|
|
|
phone: '', |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
dataList.value.forEach(item => { |
|
|
|
if (key === item.key) { |
|
|
|
params.param.id = item.memberId; |
|
|
|
params.param.name = item.memberName; |
|
|
|
params.param.phone = item.phone; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
try { |
|
|
|
if (params.param.id) { |
|
|
|
await updateMember(params); |
|
|
|
} else { |
|
|
|
await saveMember(params); |
|
|
|
} |
|
|
|
|
|
|
|
getList(); |
|
|
|
} catch (error) { |
|
|
|
console.log('error', error); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function toDelete(key) { |
|
|
|
async function toDelete(key) { |
|
|
|
console.log(key); |
|
|
|
const params = { param: { id: '' } }; |
|
|
|
dataList.value.forEach(item => { |
|
|
|
if (key === item.key) { |
|
|
|
params.param.id = item.memberId; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
try { |
|
|
|
await delMember(params); |
|
|
|
getList(); |
|
|
|
} catch (error) { |
|
|
|
console.log('error', error); |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|