首次提交

This commit is contained in:
liuyuan
2024-12-25 16:15:05 +08:00
parent ad870e7af7
commit bb6822bdc4
977 changed files with 323846 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<template>
<svg
:class="getClassName"
:width="width"
:height="height"
aria-hidden="true">
<use :xlink:href="getName"></use>
</svg>
</template>
<script>
export default {
name: 'icon-svg',
props: {
name: {
type: String,
required: true
},
className: {
type: String
},
width: {
type: String
},
height: {
type: String
}
},
computed: {
getName () {
return `#icon-${this.name}`
},
getClassName () {
return [
'icon-svg',
`icon-svg__${this.name}`,
this.className && /\S/.test(this.className) ? `${this.className}` : ''
]
}
}
}
</script>
<style>
.icon-svg {
width: 1em;
height: 1em;
fill: currentColor;
overflow: hidden;
}
</style>

View File

@@ -0,0 +1,98 @@
<template>
<div>
<!-- 图片预览 -->
<div id="modal" class="modal">
<span class="close" @click="close">&times;</span>
<img class="modal-content" :src="url">
</div>
</div>
</template>
<script>
export default {
props:['url'],
methods:{
close(){
this.$emit('close')
},
}
}
</script>
<style>
.zoomable {
width: 100%;
max-width: 300px;
cursor: pointer;
}
/* 模态框 */
.modal {
/* display: none; */
display: flex; align-items: center;
position: fixed;
/* 确保层级在上 */
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.2);
}
.modal-content {
margin: auto;
display: block; background: #fff;
/* width: 80%; */
max-width: 700px;
max-height: 80vh;
}
.modal-content {
-webkit-animation-name: zoom;
-webkit-animation-duration: 0.6s;
animation-name: zoom;
animation-duration: 0.6s;
}
@-webkit-keyframes zoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
@keyframes zoom {
from {
transform: scale(0)
}
to {
transform: scale(1)
}
}
/* 关闭按钮 */
.close {
position: absolute;
top: 15%;
right: 35px;
color: #fff;
font-size: 40px;
font-weight: bold;
transition: 0.3s;
}
.close:hover,
.close:focus {
color: #14b3e4;
text-decoration: none;
cursor: pointer;
}
</style>

View File

@@ -0,0 +1,229 @@
<template>
<el-drawer
size="50%"
title="请选择"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose"
>
<div style="padding:15px">
<!-- <el-button class="closeBtn" type="primary" plain
@click="handleClose">确定选中并关闭</el-button
> -->
<el-form
:inline="true"
:model="query"
@keyup.enter.native="getDataList()"
>
<el-form-item label="课程名称" v-if="type == 1">
<el-input
v-model="query.courseName"
placeholder="课程名称"
clearable
></el-input>
</el-form-item>
<el-form-item label="商品名称" v-if="type == 4">
<el-input
v-model="query.productName"
placeholder="商品名称"
clearable
></el-input>
</el-form-item>
<el-form-item>
<el-button
@click="
pageIndex = 1;
getDataList();
"
>查询</el-button
>
</el-form-item>
</el-form>
</div>
<div style="padding: 15px">
<el-table
v-loading="dataListLoading"
:data="dataList"
border
style="width: 100%; "
>
<!-- <el-table-column type="selection" > </el-table-column> -->
<el-table-column prop="title" label="名称" v-if="type == 1">
</el-table-column>
<el-table-column prop="productName" label="名称" v-if="type == 4">
</el-table-column>
<el-table-column prop="description" label="操作" width="100">
<template slot-scope="scope">
<el-button
:disabled="checkBtnStatus(scope.row)"
type="primary"
plain
size="small"
@click="handleSelect(scope.row)"
>
{{ checkBtnStatus(scope.row) ? "已选择" : "选择" }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
style="padding: 30px 0; text-align: center;"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
</div>
</el-drawer>
</template>
<script>
export default {
name: "selectPro",
props: ["requesturl", "oldData", "type"],
data() {
return {
drawer: true,
direction: "rtl",
dataList: [],
selected: [],
query: {
courseName: "",
productName: ""
},
pageSize: 10,
pageIndex: 1,
totalPage: 0,
dataListLoading: false
};
},
mounted() {
console.log("挂载");
this.getDataList();
},
filters: {},
methods: {
checkBtnStatus(val) {
var index;
if (this.type == 1) {
index = this.oldData.findIndex(item => item.id === val.id);
} else if (this.type == 4) {
index = this.oldData.findIndex(item => item.productId === val.productId);
}
if (index > -1) {
return true;
} else {
return false;
}
},
handleSelect(row) {
var _list;
if (this.type == 1) {
console.log("课程", row);
_list = this.selected.map(item => item.id);
if (_list.includes(row.id)) {
this.$message({
message: "已选择该课程",
type: "warning"
});
return;
}
}
else if (this.type == 4) {
console.log("商品", row);
_list = this.selected.map(item => item.productId);
if (_list.includes(row.productId)) {
this.$message({
message: "已选择该商品",
type: "warning"
});
return;
}
}
this.selected.push(row);
var index;
if(this.type==1){
index = this.dataList.findIndex(item => item.id === row.id);
}
else if(this.type==4){
index = this.dataList.findIndex(item => item.productId === row.productId);
}
this.$forceUpdate()
this.dataList.splice(index, 1);
this.$message({
message: "选择成功",
type: "success"
});
console.log("选择的课程", this.selected);
},
// 每页数
sizeChangeHandle(val) {
this.pageSize = val;
this.pageIndex = 1;
this.getDataList();
},
// 当前页
currentChangeHandle(val) {
this.pageIndex = val;
this.getDataList();
},
handleClose(done) {
this.$emit("close", this.selected);
this.selected = [];
},
getDataList() {
this.dataListLoading = true;
this.$http({
url: this.$http.adornUrl(this.requesturl),
method: "post",
data: this.$http.adornData(
this.type == 1
? {
page: this.pageIndex,
limit: this.pageSize,
title: this.query.courseName
}
: {
current: this.pageIndex,
limit: this.pageSize,
productName: this.query.productName,
goodsType: "00"
}
)
})
.then(({ data }) => {
if (data.code != 0) return this.$message.error(data.msg);
if (data && data.code === 0) {
if (this.type == 1) {
this.dataList = data.courses.records;
this.totalPage = data.courses.total;
} else if (this.type == 4) {
this.dataList = data.result.records;
this.totalPage = data.result.total;
}
} else {
this.dataList = [];
this.totalPage = 0;
}
this.dataListLoading = false;
})
.catch(e => {
this.$message.error(e.msg);
this.dataListLoading = false;
});
}
}
};
</script>
<style lang="sass" scoped>
.closeBtn{position: absolute;right: 15px;top: 15px;}
</style>

View File

@@ -0,0 +1,84 @@
<template>
<el-table-column :prop="prop" v-bind="$attrs">
<template slot-scope="scope">
<span @click.prevent="toggleHandle(scope.$index, scope.row)" :style="childStyles(scope.row)">
<i :class="iconClasses(scope.row)" :style="iconStyles(scope.row)"></i>
{{ scope.row[prop] }}
</span>
</template>
</el-table-column>
</template>
<script>
import isArray from 'lodash/isArray'
export default {
name: 'table-tree-column',
props: {
prop: {
type: String
},
treeKey: {
type: String,
default: 'id'
},
parentKey: {
type: String,
default: 'parentId'
},
levelKey: {
type: String,
default: '_level'
},
childKey: {
type: String,
default: 'children'
}
},
methods: {
childStyles (row) {
return { 'padding-left': (row[this.levelKey] > 1 ? row[this.levelKey] * 7 : 0) + 'px' }
},
iconClasses (row) {
return [ !row._expanded ? 'el-icon-caret-right' : 'el-icon-caret-bottom' ]
},
iconStyles (row) {
return { 'visibility': this.hasChild(row) ? 'visible' : 'hidden' }
},
hasChild (row) {
return (isArray(row[this.childKey]) && row[this.childKey].length >= 1) || false
},
// 切换处理
toggleHandle (index, row) {
if (this.hasChild(row)) {
var data = this.$parent.store.states.data.slice(0)
data[index]._expanded = !data[index]._expanded
if (data[index]._expanded) {
data = data.splice(0, index + 1).concat(row[this.childKey]).concat(data)
} else {
data = this.removeChildNode(data, row[this.treeKey])
}
this.$parent.store.commit('setData', data)
this.$nextTick(() => {
this.$parent.doLayout()
})
}
},
// 移除子节点
removeChildNode (data, parentId) {
var parentIds = isArray(parentId) ? parentId : [parentId]
if (parentId.length <= 0) {
return data
}
var ids = []
for (var i = 0; i < data.length; i++) {
if (parentIds.indexOf(data[i][this.parentKey]) !== -1 && parentIds.indexOf(data[i][this.treeKey]) === -1) {
data[i]._expanded = false
ids.push(data.splice(i, 1)[0][this.treeKey])
i--
}
}
return this.removeChildNode(data, ids)
}
}
}
</script>