feat:修改案例

This commit is contained in:
lixg
2023-02-25 16:49:06 +08:00
parent 7a08d62e0d
commit 2a8f06b027
2 changed files with 179 additions and 89 deletions

View File

@@ -3,20 +3,20 @@
<slot></slot> <slot></slot>
</div> </div>
<a-drawer <a-drawer
:visible="visible" :visible="visible"
class="drawerStyle addcaseDrawer" class="drawerStyle addcaseDrawer"
width="1000" width="1000"
title="添加案例" title="添加案例"
placement="right" placement="right"
> >
<div class="drawerMain"> <div class="drawerMain">
<div class="header"> <div class="header">
<div v-if="taskIndex>=0" class="headerTitle">编辑案例</div> <div v-if="taskIndex >= 0" class="headerTitle">编辑案例</div>
<div v-else class="headerTitle">添加案例</div> <div v-else class="headerTitle">添加案例</div>
<img <img
style="width: 29px; height: 29px; cursor: pointer" style="width: 29px; height: 29px; cursor: pointer"
src="../../assets/images/basicinfo/close.png" src="../../assets/images/basicinfo/close.png"
@click="closeDrawer" @click="closeDrawer"
/> />
</div> </div>
<div class="contentMain"> <div class="contentMain">
@@ -26,16 +26,21 @@
<div class="ipt_name"></div> <div class="ipt_name"></div>
<div class="fi_input"> <div class="fi_input">
<a-input <a-input
v-model:value="params.keyWord" v-model:value="params.keyWord"
style="width: 200px; height: 40px; border-radius: 8px;margin-right:24px;" style="
placeholder="请输入案例标题" width: 200px;
height: 40px;
border-radius: 8px;
margin-right: 24px;
"
placeholder="请输入案例标题"
/> />
</div> </div>
<div class="fi_input"> <div class="fi_input">
<a-input <a-input
v-model:value="params.authorName" v-model:value="params.authorName"
style="width: 200px; height: 40px; border-radius: 8px" style="width: 200px; height: 40px; border-radius: 8px"
placeholder="请输入作者名字" placeholder="请输入作者名字"
/> />
</div> </div>
</div> </div>
@@ -51,18 +56,55 @@
</div> </div>
</div> </div>
</div> </div>
<div
class="main_notice"
v-if="taskIndex >= 0"
style="
background-color: #e9f6fe;
height: 40px;
display: flex;
align-items: center;
"
>
<div class="mntc_left" v-if="selectedRows">
<div class="notice_icon"></div>
<div>
<div>
<span class="title"
>已选择
<span class="data" style="color: #4ea6ff">{{ 1 }}</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span
>
<span class="title"
>案例标题
<span
class="data"
style="color: #4ea6ff; margin-right: 15px"
>{{
selectedRows?.name
? selectedRows?.name
: selectedRows?.title
}}</span
>
</span>
</div>
</div>
</div>
</div>
<div class="main_table"> <div class="main_table">
<a-table <a-table
:customRow="customRow" :customRow="customRow"
class="ant-table-striped" class="ant-table-striped"
:row-class-name="(_, index) => (index % 2 === 1 ? 'table-striped' : null)" :row-class-name="
row-key="id" (_, index) => (index % 2 === 1 ? 'table-striped' : null)
:columns="columns" "
:data-source="data" row-key="id"
:loading="loading" :columns="columns"
:pagination="pagination" :data-source="data"
:row-selection="rowSelection" :loading="loading"
:pagination="pagination"
:row-selection="rowSelection"
/> />
</div> </div>
</div> </div>
@@ -74,17 +116,17 @@
</a-drawer> </a-drawer>
</template> </template>
<script setup> <script setup>
import {computed, defineEmits, defineProps, ref, watch} from "vue"; import { computed, defineEmits, defineProps, ref, watch } from "vue";
import {useBoeApiPage} from "@/api/request"; import { useBoeApiPage } from "@/api/request";
import {CASE_PAGE} from "@/api/ThirdApi"; import { CASE_PAGE } from "@/api/ThirdApi";
import {message} from "ant-design-vue"; import { message } from "ant-design-vue";
const props = defineProps({ const props = defineProps({
type: Number, type: Number,
taskList: [] taskList: [],
}) });
const visible = ref(false) const visible = ref(false);
const emit = defineEmits({}) const emit = defineEmits({});
const columns = ref([ const columns = ref([
{ {
@@ -101,40 +143,43 @@ const columns = ref([
width: "200px", width: "200px",
align: "center", align: "center",
}, },
]) ]);
const initParams = { const initParams = {
keyWord: '', keyWord: "",
authorName: '', authorName: "",
pageIndex: 1, pageIndex: 1,
pageSize: 10, pageSize: 10,
orderAsc: true orderAsc: true,
} };
const params = ref(initParams) const params = ref(initParams);
const rowSelectKeys = ref([]); const rowSelectKeys = ref([]);
const selectsData = ref([]); const selectsData = ref([]);
const taskIndex = ref(-1); const taskIndex = ref(-1);
const {data, loading, total, fetch} = useBoeApiPage(CASE_PAGE, params.value, { const { data, loading, total, fetch } = useBoeApiPage(CASE_PAGE, params.value, {
init: false, init: false,
result: res => res.result.list, result: (res) => res.result.list,
totalPage: res => res.result.totalPages, totalPage: (res) => res.result.totalPages,
total: res => res.result.count total: (res) => res.result.count,
}) });
watch(taskIndex, () => { watch(taskIndex, () => {
if (taskIndex.value >= 0) { if (taskIndex.value >= 0) {
rowSelectKeys.value = [props.taskList[taskIndex.value].courseId] rowSelectKeys.value = [props.taskList[taskIndex.value].courseId];
selectsData.value = data.value.find(t => t.id === props.taskList[taskIndex.value].courseId) || {} selectsData.value =
data.value.find(
(t) => t.id === props.taskList[taskIndex.value].courseId
) || {};
} }
}) });
const customRow = (record) => ({ const customRow = (record) => ({
onClick: () => { onClick: () => {
rowSelectKeys.value = [record.id] rowSelectKeys.value = [record.id];
selectsData.value = [record] selectsData.value = [record];
} },
}) });
const pagination = computed(() => ({ const pagination = computed(() => ({
total: total.value, total: total.value,
@@ -146,76 +191,82 @@ const pagination = computed(() => ({
const changePagination = (e) => { const changePagination = (e) => {
params.value.pageIndex = e; params.value.pageIndex = e;
fetch() fetch();
}; };
const rowSelection = computed(() => ({ const rowSelection = computed(() => ({
type: 'radio', type: "radio",
columnWidth: 20, columnWidth: 20,
selectedRowKeys: rowSelectKeys.value, selectedRowKeys: rowSelectKeys.value,
onChange: onSelectChange, onChange: onSelectChange,
preserveSelectedRowKeys: true, preserveSelectedRowKeys: true,
getCheckboxProps: getCheckboxProps getCheckboxProps: getCheckboxProps,
})); }));
const getCheckboxProps = () => ({ const getCheckboxProps = () => ({
// 某几项默认禁止选中(R: 当state等于1时) // 某几项默认禁止选中(R: 当state等于1时)
disabled: false disabled: false,
}) });
function onSelectChange(e, l) { function onSelectChange(e, l) {
rowSelectKeys.value = e; rowSelectKeys.value = e;
selectsData.value = l; selectsData.value = l;
selectedRows.value = l[0];
console.log("llllllllll", l);
console.log("selectedRows", selectedRows);
} }
function search() { function search() {
params.value.pageIndex = 1 params.value.pageIndex = 1;
fetch() fetch();
} }
function reset() { function reset() {
rowSelectKeys.value = []; rowSelectKeys.value = [];
selectsData.value = []; selectsData.value = [];
params.value.pageIndex = 1 params.value.pageIndex = 1;
params.value.keyWord = '' params.value.keyWord = "";
params.value.authorName = '' params.value.authorName = "";
fetch() fetch();
} }
const closeDrawer = () => { const closeDrawer = () => {
visible.value = false visible.value = false;
taskIndex.value = -1 taskIndex.value = -1;
reset() selectedRows.value = null;
reset();
}; };
function confirm() { function confirm() {
if (!selectsData.value.length || !rowSelectKeys.value.length) { if (!selectsData.value.length || !rowSelectKeys.value.length) {
message.warning("请选择案例"); message.warning("请选择案例");
return return;
} }
if (taskIndex.value === -1) { if (taskIndex.value === -1) {
const list = props.taskList const list = props.taskList;
list.push({ list.push({
name: selectsData.value[0].title, name: selectsData.value[0].title,
type: props.type, type: props.type,
courseId: selectsData.value[0].id, courseId: selectsData.value[0].id,
info: {...selectsData.value[0]} info: { ...selectsData.value[0] },
}) });
} else { } else {
const data = props.taskList[taskIndex.value] const data = props.taskList[taskIndex.value];
data.name = selectsData.value[0].title data.name = selectsData.value[0].title;
data.courseId = selectsData.value[0].id data.courseId = selectsData.value[0].id;
data.info = selectsData.value[0] data.info = selectsData.value[0];
} }
emit('update:taskList', [...props.taskList]) emit("update:taskList", [...props.taskList]);
closeDrawer() closeDrawer();
} }
let selectedRows = ref(null);
function openDrawer(i, row) { function openDrawer(i, row) {
console.log("iiiiiiiii", i, row);
row && (rowSelectKeys.value = [row.info]); row && (rowSelectKeys.value = [row.info]);
row && (selectsData.value = [{title: row.name, id: row.courseId}]); row && (selectsData.value = [{ title: row.name, id: row.courseId }]);
(i >= 0) && (taskIndex.value = i); i >= 0 && (taskIndex.value = i);
visible.value = true visible.value = true;
selectedRows.value = row;
} }
defineExpose({openDrawer}) defineExpose({ openDrawer });
</script> </script>
<style lang="scss"> <style lang="scss">
.ant-table-striped :deep(.table-striped) td { .ant-table-striped :deep(.table-striped) td {
@@ -376,8 +427,8 @@ defineExpose({openDrawer})
} }
.ant-table-tbody .ant-table-tbody
> tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) > tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected)
> td { > td {
background: #f6f9fd; background: #f6f9fd;
} }
@@ -424,5 +475,31 @@ defineExpose({openDrawer})
} }
} }
} }
.main_notice {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 3px;
height: 40px;
background-color: #e9f6fe;
.mntc_left {
display: flex;
align-items: center;
.notice_icon {
width: 14px;
height: 14px;
margin-right: 9px;
margin-left: 9px;
background-image: url(@/assets/images/coursewareManage/gan.png);
background-size: 100% 100%;
}
}
.mntc_right {
cursor: pointer;
}
}
} }
</style> </style>

View File

@@ -76,7 +76,11 @@
<button class="xkbtn" @click="goProjectmanage">新建项目</button> <button class="xkbtn" @click="goProjectmanage">新建项目</button>
</div> </div>
<div class="main_notice" v-if="taskIndex >= 0"> <div
class="main_notice"
v-if="taskIndex >= 0"
style="background-color: #e9f6fe; height: 40px"
>
<div class="mntc_left" v-if="selectedRows"> <div class="mntc_left" v-if="selectedRows">
<div class="notice_icon"></div> <div class="notice_icon"></div>
<div> <div>
@@ -204,13 +208,22 @@ const columns = ref([
width: "20%", width: "20%",
ellipsis: true, ellipsis: true,
customRender: ({ record: { gaName, faName, name } }) => ( customRender: ({ record: { gaName, faName, name } }) => (
<div title={faName ? gaName !== null ? gaName + "/" + faName : faName : name}> <div
{ title={
faName ? gaName !== null faName ? (gaName !== null ? gaName + "/" + faName : faName) : name
? (gaName + "/" + faName).length > 16 ? (gaName + "/" + faName).slice(0, 16) + '...' : (gaName + "/" + faName)
: faName.length > 16 ? faName.slice(0, 16) + '...' : faName
: name.length > 16 ? name.slice(0, 16) + '...' : name
} }
>
{faName
? gaName !== null
? (gaName + "/" + faName).length > 16
? (gaName + "/" + faName).slice(0, 16) + "..."
: gaName + "/" + faName
: faName.length > 16
? faName.slice(0, 16) + "..."
: faName
: name.length > 16
? name.slice(0, 16) + "..."
: name}
</div> </div>
), ),
}, },
@@ -257,7 +270,7 @@ const { data, loading, total, fetch } = useRowsPage(
total: (res) => res.result.count, total: (res) => res.result.count,
} }
); );
console.log(data) console.log(data);
watch(taskIndex, () => { watch(taskIndex, () => {
// if (taskIndex.value >= 0) { // if (taskIndex.value >= 0) {
// rowSelectKeys.value = [props.taskList[taskIndex.value].courseId] // rowSelectKeys.value = [props.taskList[taskIndex.value].courseId]