|
|
@@ -0,0 +1,411 @@
|
|
|
+<template>
|
|
|
+ <div class="select-commodity">
|
|
|
+ <a class="close" @click="$emit('cancle')">+</a>
|
|
|
+ <h3 class="title">{{title}}</h3>
|
|
|
+
|
|
|
+ <div class="material-tab">
|
|
|
+ <button class="material-tab-item" @click="currentMaterialType = 'image'">图片</button>
|
|
|
+ <button class="material-tab-item" @click="currentMaterialType = 'pano'">全景图</button>
|
|
|
+ <button class="material-tab-item" @click="currentMaterialType = '3D'">三维场景</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="filtert">
|
|
|
+ <div>
|
|
|
+ <input type="text" placeholder="输入关键词" v-model="key"
|
|
|
+ @keyup.enter="onSearch">
|
|
|
+ <i class="iconfont iconsearch"
|
|
|
+ @click="onSearch"></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <table>
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th></th>
|
|
|
+ <th v-for="(item,i) in tabHeaders" :key="i">{{item.name}}</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <br/>
|
|
|
+ <tbody
|
|
|
+ class="data"
|
|
|
+ v-infinite-scroll="requestMoreData"
|
|
|
+ :infinite-scroll-disabled="!hasMoreData || isRequestingMoreData"
|
|
|
+ >
|
|
|
+ <tr v-for="(item,i) in list" :key="i">
|
|
|
+ <td>
|
|
|
+ <div class="checkbox">
|
|
|
+ <input type="checkbox" @change="e => selectItem(item, e.target)"
|
|
|
+ :checked="select.some(i => i[primaryKey] === item[primaryKey])">
|
|
|
+ <span></span>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td v-for="(sub,idx) in tabHeaders" :key="idx">
|
|
|
+ <div v-if="sub.type=='image'" class="list-img">
|
|
|
+ <img :src="item[sub.key]" alt="">
|
|
|
+ </div>
|
|
|
+ <div class="audio" v-else-if="sub.type=='audio'">
|
|
|
+ <v-audio :vkey="item.id" :idleft="`_${$randomWord(true,8,8)}`" :idright="`_${$randomWord(true,8,8)}`"
|
|
|
+ :myAudioUrl="item[sub.key]"></v-audio>
|
|
|
+ </div>
|
|
|
+ <span class="shenglvhao" v-else>{{item[sub.key]}}</span>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ <!-- 无数据时的提示 -->
|
|
|
+ <tbody v-if="list.length === 0">
|
|
|
+ <tr>
|
|
|
+ <td colspan="10">
|
|
|
+ <div class="nodata">
|
|
|
+ <img :src="$noresult" alt="">
|
|
|
+ <span>{{haveClickedSearch?'未搜索到结果~':'暂无素材,快去上传吧'}}</span>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+
|
|
|
+ <div class="btns">
|
|
|
+ <a @click="$emit('cancle')">取消</a>
|
|
|
+ <a :class="{disable:disable}" @click="$emit('submit', select)">确定</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import vAudio from '@/components/audio'
|
|
|
+import { getMaterialList} from "@/api";
|
|
|
+import { changeByteUnit } from '@/utils/file'
|
|
|
+import config from "@/config";
|
|
|
+
|
|
|
+export default {
|
|
|
+ props:{
|
|
|
+ tabHeader:{
|
|
|
+ default(){
|
|
|
+ return []
|
|
|
+ },
|
|
|
+ type:Array
|
|
|
+ },
|
|
|
+
|
|
|
+ selected:{
|
|
|
+ default(){
|
|
|
+ return []
|
|
|
+ },
|
|
|
+ type:Array
|
|
|
+ },
|
|
|
+ title:{
|
|
|
+ default:'',
|
|
|
+ type:String
|
|
|
+ },
|
|
|
+ current: {
|
|
|
+ default:''
|
|
|
+ },
|
|
|
+ primaryKey: {
|
|
|
+ default:'id'
|
|
|
+ },
|
|
|
+ },
|
|
|
+ components:{
|
|
|
+ vAudio
|
|
|
+ },
|
|
|
+ watch:{
|
|
|
+ select(){
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed:{
|
|
|
+ disable(){
|
|
|
+ return !this.select.length
|
|
|
+ },
|
|
|
+ tabHeaders(){
|
|
|
+ return this.tabHeader.filter(item=>{
|
|
|
+ return ['icon', 'name', 'fileSize', 'dpi'].includes(item.key)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ list: [],
|
|
|
+
|
|
|
+ haveClickedSearch:'',
|
|
|
+ select: [...this.selected],
|
|
|
+ key:'', // 搜索关键词
|
|
|
+
|
|
|
+ currentMaterialType: 'image',
|
|
|
+
|
|
|
+ isRequestingMoreData: false,
|
|
|
+ hasMoreData: true,
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ changeCurrent(data){
|
|
|
+ this.$emit('changeCurrent',data)
|
|
|
+ },
|
|
|
+ selectItem(item, e) {
|
|
|
+ let isSelect = e.checked
|
|
|
+ if (item.isUse == '1') {
|
|
|
+ e.checked = false
|
|
|
+ return this.$alert({content:'选中素材不能超过600kb'})
|
|
|
+ }
|
|
|
+ this.select = [item]
|
|
|
+ },
|
|
|
+ onSearch() {
|
|
|
+ this.haveClickedSearch = !!this.key
|
|
|
+ this.refreshMaterialList()
|
|
|
+ },
|
|
|
+ requestMoreData() {
|
|
|
+ this.isRequestingMoreData = true
|
|
|
+ getMaterialList(
|
|
|
+ {
|
|
|
+ pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
|
|
|
+ pageSize: config.PAGE_SIZE,
|
|
|
+ searchKey: this.key,
|
|
|
+ type: 'image',
|
|
|
+ },
|
|
|
+ (data) => {
|
|
|
+ const newData = data.data.list.map((i) => {
|
|
|
+ i.isUse = i.fileSize > 600 ? '1' : '0'
|
|
|
+ i.fileSize = changeByteUnit(Number(i.fileSize));
|
|
|
+ i.createTime = i.createTime.substring(0, i.createTime.length - 3)
|
|
|
+ i.updateTime = i.updateTime.substring(0, i.updateTime.length - 3)
|
|
|
+ return i;
|
|
|
+ });
|
|
|
+ this.list = this.list.concat(newData)
|
|
|
+ if (this.list.length === data.data.total) {
|
|
|
+ this.hasMoreData = false
|
|
|
+ }
|
|
|
+ this.isRequestingMoreData = false
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ this.isRequestingMoreData = false
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ refreshMaterialList() {
|
|
|
+ this.list = []
|
|
|
+ this.requestMoreData()
|
|
|
+ },
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+::-webkit-scrollbar-track {
|
|
|
+ box-shadow: inset 0 0 5px rgb(0 0 0 / 20%);
|
|
|
+ border-radius: 4px;
|
|
|
+ background: #fff;
|
|
|
+}
|
|
|
+.shenglvhao{
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ max-width: 200px;
|
|
|
+ display: inline-block;
|
|
|
+}
|
|
|
+.select-commodity {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 3;
|
|
|
+ left: 50%;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateX(-50%) translateY(-50%);
|
|
|
+ color: #202020;
|
|
|
+ background: #FFFFFF;
|
|
|
+ max-width: 960px;
|
|
|
+ width: 100%;
|
|
|
+ border-radius: 6px;
|
|
|
+}
|
|
|
+
|
|
|
+.select-commodity > * {
|
|
|
+ padding: 15px;
|
|
|
+}
|
|
|
+
|
|
|
+.title {
|
|
|
+ font-size: 16px;
|
|
|
+ line-height: 20px;
|
|
|
+ font-weight: 400;
|
|
|
+ margin: 0;
|
|
|
+ font-weight: bold;
|
|
|
+ border-bottom: 1px solid rgba(255,255,255,0.3);
|
|
|
+}
|
|
|
+
|
|
|
+.close {
|
|
|
+ position: absolute;
|
|
|
+ right: -8px;
|
|
|
+ top: -15px;
|
|
|
+ font-size: 25px;
|
|
|
+ color: #909090;
|
|
|
+ transform: rotate(45deg);
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+
|
|
|
+.filtert {
|
|
|
+ padding: 15px;
|
|
|
+}
|
|
|
+
|
|
|
+.filtert > div {
|
|
|
+ width: 210px;
|
|
|
+ height: 34px;
|
|
|
+ background: rgba(22,26,26,1);
|
|
|
+ border-radius: 2px;
|
|
|
+ display: inline-block;
|
|
|
+ margin-right: 10px;
|
|
|
+ position: relative;
|
|
|
+ vertical-align: middle;
|
|
|
+}
|
|
|
+
|
|
|
+.filtert > div > select,
|
|
|
+.filtert > div > input {
|
|
|
+ box-sizing: border-box;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ border: none;
|
|
|
+ background: none;
|
|
|
+ color: #202020;
|
|
|
+ padding: 8px 10px;
|
|
|
+ outline: none;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border: 1px solid #EBEBEB;
|
|
|
+}
|
|
|
+
|
|
|
+.filtert > div > input {
|
|
|
+ padding-right: 40px;
|
|
|
+}
|
|
|
+
|
|
|
+.filtert > div > i {
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ right: 10px;
|
|
|
+ cursor: pointer;
|
|
|
+ color:@color;
|
|
|
+}
|
|
|
+
|
|
|
+.scene-layer {
|
|
|
+ min-height: 400px;
|
|
|
+ max-height: 60vh;
|
|
|
+ overflow-y: auto;
|
|
|
+ position: relative;
|
|
|
+ .nodata{
|
|
|
+ position: absolute;
|
|
|
+ left: 50%;
|
|
|
+ top: 50%;
|
|
|
+ transform: translate(-50%,-50%);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+table {
|
|
|
+ border-collapse: collapse;
|
|
|
+ width: 100%;
|
|
|
+ > thead {
|
|
|
+ display: inline-block;
|
|
|
+ width: 100%;
|
|
|
+ > tr > th {
|
|
|
+ font-size:14px;
|
|
|
+ line-height:20px;
|
|
|
+ text-align: center;
|
|
|
+ padding: 10px 0;
|
|
|
+ border-bottom: 1px solid #EBEBEB;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #202020;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > tbody.data {
|
|
|
+ height: 350px;
|
|
|
+ overflow: auto;
|
|
|
+ display: inline-block;
|
|
|
+ width: 100%;
|
|
|
+ > tr {
|
|
|
+ height: 60px;
|
|
|
+ > td {
|
|
|
+ font-size:14px;
|
|
|
+ line-height:20px;
|
|
|
+ text-align: center;
|
|
|
+ padding: 10px 0;
|
|
|
+ color: #909090;
|
|
|
+ border-bottom: 1px solid #EBEBEB;
|
|
|
+ > .list-img {
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ position: relative;
|
|
|
+ > img {
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox {
|
|
|
+ position: relative;
|
|
|
+ width:14px;
|
|
|
+ height:14px;
|
|
|
+ border-radius:2px;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox > input,
|
|
|
+.checkbox > span {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox > input {
|
|
|
+ z-index: 1;
|
|
|
+ opacity: 0;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox > span {
|
|
|
+ z-index: 2;
|
|
|
+ background:#fff;
|
|
|
+ border:1px solid #ccc;
|
|
|
+ pointer-events: none;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox > input:checked + span {
|
|
|
+ background:#fff;
|
|
|
+ border:1px solid #0076F6;
|
|
|
+ background:@color url(/static/img/g.png) no-repeat center center;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox > input:disabled {
|
|
|
+ cursor: not-allowed;
|
|
|
+}
|
|
|
+
|
|
|
+.checkbox > input:disabled + span {
|
|
|
+ background:#CCCCCC;
|
|
|
+ background:rgba(0,200,175,0.3) no-repeat center center;
|
|
|
+}
|
|
|
+
|
|
|
+.btns {
|
|
|
+ text-align: center;
|
|
|
+ > a {
|
|
|
+ width:120px;
|
|
|
+ height:40px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 40px;
|
|
|
+ opacity:1;
|
|
|
+ border-radius:20px;
|
|
|
+ font-size:12px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: inline-block;
|
|
|
+ color: @color;
|
|
|
+ margin: 0 10px;
|
|
|
+ &:nth-child(2) {
|
|
|
+ background-color: @color;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ &:nth-child(1) {
|
|
|
+ border:1px solid @color;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .disable{
|
|
|
+ pointer-events: none!important;
|
|
|
+ opacity: 0.5!important;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|