123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <template>
- <div class="select-image">
- <el-dialog :visible.sync="showDialog" :title="titleObj[imgType]" :close-on-click-modal="false"
- :modal-append-to-body="false" @close="cancelHandle" custom-class="select-image-dialog" center width="820px"
- v-dialogDrag>
- <el-input v-model="keyword"
- :placeholder="$t('OnlineExcelPage.please_input') + inputName[imgType] + $t('ETable.BalanceSheetTable.name')"
- clearable style="width:200px;" @input="handleSearch"></el-input>
- <div class="image-list">
- <div class="image-item" v-for="item in list" :key="item.ImageConfId">
- <div class="img-box">
- <div class="opt-box">
- <div class="item full-fix" @click="handleShowImgFull(item)">
- <img src="~@/assets/img/icons/fullsreen.png" alt="">
- </div>
- <div class="radio-fix">
- <el-radio v-if="imgType != 3" size="medium" v-model="momentChooseId"
- @change="changeRadio" :label="item.ImageConfId"></el-radio>
- <el-radio class="backcover-radio" v-else size="medium" v-model="momentChooseId"
- @click.native.prevent="clickRadio(item.ImageConfId)"
- :label="item.ImageConfId"></el-radio>
- </div>
- </div>
- <img class="img" :src="item.Url" alt="">
- </div>
- <p class="name">{{ item.ImgName || item.ImageName }}</p>
- </div>
- </div>
- <div style="margin-top: 20px;display: flex;justify-content:flex-end;padding-right: 40px;">
- <el-pagination @current-change="handleCurrentChange" :current-page="page" :page-size="pageSize"
- layout="total, prev, pager, next, jumper" :total="total">
- </el-pagination>
- </div>
- <div style="text-align:center;padding: 30px 0;margin-top: 60px;">
- <el-button style="width:120px;" @click="cancelHandle()">{{ $t('Dialog.cancel_btn') }}</el-button>
- <el-button type="primary" style="margin-left:20px;width:120px;" @click="handleSave">{{
- $t('Dialog.confirm_save_btn') }}</el-button>
- </div>
- <el-image-viewer :zIndex="9999" v-if="showPptViewer"
- :on-close="() => { this.picShowList = []; this.showPptViewer = false }" :url-list="picShowList" />
- </el-dialog>
- </div>
- </template>
- <script>
- import ElImageViewer from 'element-ui/packages/image/src/image-viewer';
- import { apiSmartReport } from '@/api/modules/smartReport'
- export default {
- components: { ElImageViewer },
- props: {
- },
- data() {
- return {
- momentChooseId: 0,
- momentChooseUrl: '',
- total: 0,
- list: [],
- pageSize: 8,
- page: 1,
- keyword: '',
- showPptViewer: false,
- picShowList: [],
- imgType: 1,
- showDialog: false,
- inputName: {
- 1: this.$t('SystemManage.BaseConfig.ppt_type01'),
- 2: this.$t('SystemManage.BaseConfig.ppt_type02'),
- 3: this.$t('SystemManage.BaseConfig.ppt_type03')
- },
- titleObj: {
- 1: this.$t('Slides.more_cover_page'),
- 2: this.$t('Slides.select_ground_page'),
- 3: this.$t('Slides.select_back_page')
- }
- }
- },
- mounted() {
- },
- methods: {
- handleShowImgFull(e) {
- console.log(e);
- this.picShowList = [e.Url]
- this.showPptViewer = true
- },
- handleCurrentChange(val) {
- this.page = val
- this.getImgList()
- },
- // 保存
- handleSave() {
- const obj = {
- url: this.momentChooseUrl,
- type: this.imgType,
- id: this.momentChooseId
- }
- this.cancelHandle()
- this.$emit('saveChoose', obj)
- },
- // 选择图片
- changeRadio(val) {
- const index = this.list.findIndex(el => el.ImageConfId == val)
- if (index > -1) {
- this.momentChooseUrl = this.list[index].Url
- }
- },
- // 封底图片选择
- clickRadio(val) {
- if (val === this.momentChooseId) {
- this.momentChooseId = 0
- this.momentChooseUrl = ''
- } else {
- this.momentChooseId = val
- const index = this.list.findIndex(el => el.ImageConfId == val)
- if (index > -1) {
- this.momentChooseUrl = this.list[index].Url
- }
- }
- },
- //资源库列表
- getImgList() {
- apiSmartReport.pptMaterialList({
- CurrentIndex: this.page,
- PageSize: this.pageSize,
- ImageType: this.imgType,
- ImageName: this.keyword,
- ConfType: 1
- }).then(res => {
- this.list = res.Data ? res.Data.List : []
- this.total = res.Data ? res.Data.Paging.Totals : 0
- if (!this.momentChooseId&&this.imgType!=3) {
- if (this.list.length) {
- this.momentChooseId = this.list[0].ImageConfId
- this.momentChooseUrl = this.list[0].Url
- }
- }
- })
- },
- // 搜索图片
- handleSearch() {
- this.page = 1
- this.getImgList()
- },
- // 打开弹框
- showHandle(type, id, url) {
- // console.log(type, id, url)
- this.showDialog = true
- this.imgType = type
- this.keyword = ''
- this.momentChooseId = id
- this.momentChooseUrl = url
- this.handleSearch()
- },
- // 关闭弹窗
- cancelHandle() {
- this.showDialog = false
- }
- }
- }
- </script>
- <style lang="scss">
- .select-image-dialog {
- .el-dialog__body {
- padding: 40px 60px !important;
- }
- .image-list {
- margin-top: 20px;
- display: flex;
- flex-wrap: wrap;
- gap: 20px;
- .image-item {
- width: 160px;
- .img-box {
- position: relative;
- cursor: pointer;
- width: 160px;
- .img {
- display: block;
- width: 100%;
- height: 160px;
- background-color: var(--gary-gy-3-disabled, #EBEFF6);
- object-fit: contain !important;
- box-sizing: border-box;
- &:hover {
- border: 1px solid #3375e1;
- }
- }
- .opt-box {
- position: absolute;
- z-index: 5;
- width: 100%;
- height: 100%;
- .item {
- width: 24px;
- height: 24px;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #fff;
- border-radius: 50%;
- margin-left: 10px;
- img {
- width: 16px;
- height: 16px;
- }
- }
- .full-fix {
- position: absolute;
- top: 12px;
- right: 12px;
- }
- .radio-fix {
- position: absolute;
- top: 12px;
- left: 12px;
- }
- }
- &:hover {
- .opt-box {
- display: flex;
- }
- .select-box {
- display: block;
- }
- }
- }
- .name {
- padding-top: 5px;
- display: -webkit-box;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-line-clamp: 2;
- line-break: anywhere;
- -webkit-box-orient: vertical;
- }
- }
- }
- .el-radio {
- .el-radio__label {
- display: none;
- }
- }
- .backcover-radio.el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
- -webkit-box-shadow: none !important;
- box-shadow: none !important;
- }
- }
- </style>
|