|
@@ -1,48 +1,18 @@ |
|
|
<template> |
|
|
<template> |
|
|
<el-table |
|
|
|
|
|
ref="multipleTableRef" |
|
|
|
|
|
:data="tableData" |
|
|
|
|
|
style="width: 100%" |
|
|
|
|
|
border |
|
|
|
|
|
@selection-change="handleSelectionChange" |
|
|
|
|
|
> |
|
|
|
|
|
<el-table-column type="selection" width="55" align="center"/> |
|
|
|
|
|
<el-table-column property="title" label="标题" align="center"/> |
|
|
|
|
|
<el-table-column label="图片" align="center"> |
|
|
|
|
|
<template #default="scope"> |
|
|
|
|
|
<img :src="scope.row.coverImg" width="50" /> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column |
|
|
|
|
|
prop="createTime" |
|
|
|
|
|
:label="$t('businessMangage.createTime')" |
|
|
|
|
|
align="center" |
|
|
|
|
|
|
|
|
<div> |
|
|
|
|
|
<el-checkbox-group v-model="checkboxGroup" size="small" class="checkbox"> |
|
|
|
|
|
<el-checkbox v-for="(item, index) in tableData" :key="index" :label="item.id" border> |
|
|
|
|
|
<img :src="item.coverImg" width="50" /> |
|
|
|
|
|
<p>{{ item.title }}</p> |
|
|
|
|
|
</el-checkbox> |
|
|
|
|
|
</el-checkbox-group> |
|
|
|
|
|
<div style="margin-top: 20px"> |
|
|
|
|
|
<el-button @click="handleClose" |
|
|
|
|
|
>取消</el-button |
|
|
> |
|
|
> |
|
|
<template #default="scope"> |
|
|
|
|
|
{{ getDate(scope.row.createDate) }} |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
</el-table> |
|
|
|
|
|
<div class="pagination"> |
|
|
|
|
|
<el-pagination |
|
|
|
|
|
v-model:current-page="pageNum" |
|
|
|
|
|
v-model:page-size="pageSize" |
|
|
|
|
|
:page-sizes="[10, 50, 100]" |
|
|
|
|
|
:small="false" |
|
|
|
|
|
:disabled="false" |
|
|
|
|
|
:background="true" |
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper" |
|
|
|
|
|
:total="total" |
|
|
|
|
|
@size-change="handleSizeChange" |
|
|
|
|
|
@current-change="handleCurrentChange" |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
<el-button type="primary" @click="addModel()">确认关联</el-button> |
|
|
</div> |
|
|
</div> |
|
|
<div style="margin-top: 20px"> |
|
|
|
|
|
<el-button @click="handleClose" |
|
|
|
|
|
>取消</el-button |
|
|
|
|
|
> |
|
|
|
|
|
<el-button type="primary" @click="addModel()">确认关联</el-button> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script setup> |
|
|
<script setup> |
|
@@ -62,78 +32,32 @@ const getDate = (val) => { |
|
|
return dayjs(val).format("YYYY-MM-DD"); |
|
|
return dayjs(val).format("YYYY-MM-DD"); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const multipleTableRef = ref() |
|
|
|
|
|
const multipleSelection = ref([]) |
|
|
|
|
|
const toggleSelection = (rows) => { |
|
|
|
|
|
if (rows) { |
|
|
|
|
|
rows.forEach((row) => { |
|
|
|
|
|
// TODO: improvement typing when refactor table |
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment |
|
|
|
|
|
// @ts-expect-error |
|
|
|
|
|
multipleTableRef.value.toggleRowSelection(row, undefined) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
multipleTableRef.value.clearSelection() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
const handleSelectionChange = (val) => { |
|
|
|
|
|
multipleSelection.value = val |
|
|
|
|
|
} |
|
|
|
|
|
const pageNum = ref(1); |
|
|
|
|
|
const pageSize = ref(10); |
|
|
|
|
|
|
|
|
const checkboxGroup = ref([]) |
|
|
const total = ref(0); |
|
|
const total = ref(0); |
|
|
const tableData = ref([]); |
|
|
const tableData = ref([]); |
|
|
|
|
|
|
|
|
const handleSizeChange = (val) => { |
|
|
|
|
|
pageSize.value = val; |
|
|
|
|
|
modelAllListFunc(pageNum.value, pageSize.value); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const handleCurrentChange = (val) => { |
|
|
|
|
|
pageNum.value = val; |
|
|
|
|
|
modelAllListFunc(pageNum.value, pageSize.value); |
|
|
|
|
|
}; |
|
|
|
|
|
const modelAllListFunc = async (PageNum, PageSize) => { |
|
|
|
|
|
|
|
|
const modelAllListFunc = async () => { |
|
|
try { |
|
|
try { |
|
|
const res = await modelAllList(PageNum, PageSize); |
|
|
|
|
|
debugger |
|
|
|
|
|
|
|
|
const res = await modelAllList(1, 10000); |
|
|
const modelIds = await personMouldIdList(props.serviceId); |
|
|
const modelIds = await personMouldIdList(props.serviceId); |
|
|
let idIndx = [] |
|
|
|
|
|
if(modelIds.data && modelIds.data.length > 0) { |
|
|
|
|
|
res.data.list.forEach((ele, idx) => { |
|
|
|
|
|
modelIds.data.forEach((item) => { |
|
|
|
|
|
if (ele.id === item.personMouldId) { |
|
|
|
|
|
idIndx.push(idx) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
tableData.value = res.data.list; |
|
|
tableData.value = res.data.list; |
|
|
total.value = res.data.total * 1; |
|
|
total.value = res.data.total * 1; |
|
|
// 选中关联模版 |
|
|
|
|
|
if(idIndx.length) { |
|
|
|
|
|
setTimeout(()=> { |
|
|
|
|
|
let list = [] |
|
|
|
|
|
idIndx.forEach(d => { |
|
|
|
|
|
list.push(tableData.value[d]) |
|
|
|
|
|
}) |
|
|
|
|
|
toggleSelection(list) |
|
|
|
|
|
}, 500) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
setTimeout(()=> { |
|
|
|
|
|
if(modelIds.data && modelIds.data.length > 0) { |
|
|
|
|
|
modelIds.data.forEach((item) => { |
|
|
|
|
|
checkboxGroup.value.push(item) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(error, "err"); |
|
|
console.log(error, "err"); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const addModel = async () => { |
|
|
const addModel = async () => { |
|
|
console.log(multipleSelection.value) |
|
|
|
|
|
let mouldIds = [] |
|
|
|
|
|
multipleSelection.value.forEach(res => { |
|
|
|
|
|
mouldIds.push(res.id) |
|
|
|
|
|
}) |
|
|
|
|
|
const data = { |
|
|
const data = { |
|
|
mouldIds: mouldIds, |
|
|
|
|
|
|
|
|
mouldIds: checkboxGroup.value, |
|
|
serviceId: props.serviceId |
|
|
serviceId: props.serviceId |
|
|
} |
|
|
} |
|
|
const res = await associatedMould(data); |
|
|
const res = await associatedMould(data); |
|
@@ -150,3 +74,15 @@ onMounted(() => { |
|
|
modelAllListFunc(1, 10); |
|
|
modelAllListFunc(1, 10); |
|
|
}); |
|
|
}); |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|
|
.checkbox { |
|
|
|
|
|
max-height: 500px; |
|
|
|
|
|
overflow: auto; |
|
|
|
|
|
:deep .el-checkbox.el-checkbox--small { |
|
|
|
|
|
width: 110px; |
|
|
|
|
|
height:110px; |
|
|
|
|
|
margin-bottom: 10px; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
</style> |