| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- <template>
- <div class="select-commodity">
- <a class="close" @click="$emit('cancle')">+</a>
- <h3 class="title">{{title}}</h3>
- <div class="filter">
- <div>
- <input
- type="text"
- placeholder="输入关键词"
- v-model="key"
- @keyup.enter="isClickSearch = !!key, (paging.current = 1) && $emit('updateList',key)">
- <i class="iconfont iconsearch" @click="isClickSearch = !!key, (paging.current = 1) && $emit('updateList',key)"></i>
- </div>
- </div>
- <template>
- <div class="table-layer">
- <table class="list">
- <tr>
- <th>
- <div class="checkbox" v-if="!hideAll">
- <input
- type="checkbox"
- v-model="allSelect"
- @click="e => selectAll(e.target)">
- <span></span>
- </div>
- </th>
- <th v-for="(item,i) in tabHeaders" :key="i">{{item.name}}</th>
- </tr>
- <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>
- <tr v-if="list.length === 0">
- <td colspan="10">
- <div class="nodata">
- <img :src="$noresult" alt="">
- <span>{{isClickSearch?'未搜索到结果':'暂无素材,快去上传吧'}}</span>
- </div>
- </td>
- </tr>
- </table>
- </div>
- <div class="paging">
- <p></p>
- <Paging
- v-if="paging.total>0"
- style="float: right"
- :paging="paging"
- @changeCurrent="changeCurrent"
- />
- </div>
- </template>
- <div class="btns">
- <a @click="$emit('cancle')">取消</a>
- <a :class="{disable:disable}" @click="$emit('submit', select)" >确定</a>
- </div>
- </div>
- </template>
- <script>
- import Paging from './paging'
- import vAudio from '@/components/audio'
- export default {
- props:{
- list:{
- default(){
- return []
- },
- type:Array
- },
- tabHeader:{
- default(){
- return []
- },
- type:Array
- },
-
- paging: {
- default:function () {
- return {}
- },
- type: Object
- },
- selected:{
- default(){
- return []
- },
- type:Array
- },
- title:{
- default:'',
- type:String
- },
- current: {
- default:''
- },
- primaryKey: {
- default:'id'
- },
- hideAll:{
- type:Boolean,
- default:false
- }
- },
- components:{
- Paging,
- vAudio
- },
- watch:{
- select(){
- }
- },
- computed:{
- disable(){
- return !this.select.length
- },
- tabHeaders(){
- return this.tabHeader.filter(item=>{
- return item.key!='detail'
- })
- }
- },
- data () {
- return {
- categs: [],
- isClickSearch:'',
- select: [...this.selected],
- allSelect: false,
- key:'',
- tmppaging:{...this.paging}
- }
- },
- methods: {
- changeCurrent(data){
- this.$emit('changeCurrent',data)
- },
- selectAll(isSelect) {
- this.list.forEach(item => {
- this.selectItem(item, isSelect)
- })
- },
- selectItem(item, e) {
- let isSelect = e.checked
- if (this.hideAll) {
- if (item.isUse == '1') {
- e.checked = false
- return this.$alert({content:'选中素材不能超过600kb'})
- }
- this.select = [item]
- }
- else{
- let index = this.select.findIndex(i => i[this.primaryKey] === item[this.primaryKey])
- if (isSelect) {
- !~index && this.select.push(item)
- } else {
- ~index && this.select.splice(index, 1)
- }
- }
- },
-
- },
- mounted() {
- this.key = ''
- }
- }
- </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;
- }
- .filter {
- padding: 15px;
- }
- .filter > 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;
- }
- .filter > div > select,
- .filter > 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;
- }
- .filter > div > input {
- padding-right: 40px;
- }
- .filter > 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-layer {
- min-height: 400px;
- max-height: 60vh;
- overflow-y: auto;
- }
- .list {
- border-collapse: collapse;
- width: 100%;
- }
- .list td,
- .list th {
- font-size:14px;
- line-height:20px;
- text-align: center;
- padding: 10px 0;
- color: #909090;
- border-bottom: 1px solid #EBEBEB;
- }
- .list th {
- font-weight: bold;
- color: #202020;
- }
- .list-img {
- height: 40px;
- line-height: 40px;
- position: relative;
- }
- .list-img > 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 rgba(0,200,175,1);
- background:#00C8AF 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;
- }
- .paging {
- display: flex;
- align-items: center;
- justify-content: space-between;
- p {
- font-size: 12px;
- }
- }
- .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: #00C8AF;
- margin: 0 10px;
- &:nth-child(2) {
- background-color: #00C8AF;
- color: #fff;
- }
- &:nth-child(1) {
- border:1px solid #00C8AF;
- }
- }
- .disable{
- pointer-events: none!important;
- opacity: 0.5!important;
- }
- }
- </style>
|