Browse Source

关联模版

ctt_dev_new
chutingting 1 year ago
parent
commit
19d23fd81d
4 changed files with 43 additions and 102 deletions
  1. +1
    -1
      src/router/index.ts
  2. +2
    -0
      src/types/components.d.ts
  3. +4
    -1
      src/views/apiManage/businessCheck.vue
  4. +36
    -100
      src/views/apiManage/model.vue

+ 1
- 1
src/router/index.ts View File

@@ -103,7 +103,7 @@ export const constantRoutes: RouteRecordRaw[] = [
children: [
{
path: "businessCheck",
component: () => import("@/views/business/businessCheck.vue"),
component: () => import("@/views/apiManage/businessCheck.vue"),
name: "businessCheck",
meta: {
title: "businessCheck",


+ 2
- 0
src/types/components.d.ts View File

@@ -15,6 +15,8 @@ declare module '@vue/runtime-core' {
'EditPosition copy': typeof import('./../components/EditPosition copy.vue')['default']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']


+ 4
- 1
src/views/apiManage/businessCheck.vue View File

@@ -74,6 +74,8 @@ const appId = ref("");
const hideCode = ref("");
const showCode = ref("");
const showText = ref("查看");
const detailId = ref("");


const showHideCode = () => {
if (showText.value == "查看") {
@@ -120,6 +122,7 @@ const getKeyFunc = async () => {
try {
const res = await getKeyByIdApi(id);
console.log(res, "res");
detailId.value = res.data.id
appId.value = res.data.appId;
appKey.value = res.data.appKey;
signKey.value = res.data.signKey;
@@ -171,7 +174,7 @@ const copyKey = (text) => {
const keyStatus = ref("");

const changeStatus = async (status) => {
const id = keyId.value;
const id = detailId.value;
if (status) {
ElMessageBox.confirm("此操作将作废密钥,确定?", "Warning", {
confirmButtonText: "确定",


+ 36
- 100
src/views/apiManage/model.vue View File

@@ -1,48 +1,18 @@
<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 style="margin-top: 20px">
<el-button @click="handleClose"
>取消</el-button
>
<el-button type="primary" @click="addModel()">确认关联</el-button>
</div>
</div>
</template>

<script setup>
@@ -62,78 +32,32 @@ const getDate = (val) => {
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 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 {
const res = await modelAllList(PageNum, PageSize);
debugger
const res = await modelAllList(1, 10000);
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;
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) {
console.log(error, "err");
}
};

const addModel = async () => {
console.log(multipleSelection.value)
let mouldIds = []
multipleSelection.value.forEach(res => {
mouldIds.push(res.id)
})
const data = {
mouldIds: mouldIds,
mouldIds: checkboxGroup.value,
serviceId: props.serviceId
}
const res = await associatedMould(data);
@@ -150,3 +74,15 @@ onMounted(() => {
modelAllListFunc(1, 10);
});
</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>

Loading…
Cancel
Save