index.vue 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. <template>
  2. <div class="Modal" :class="{ 'fill-window': !isPage }">
  3. <div class="colLeft">
  4. <div class="Nav">
  5. <!-- <div class="input">
  6. <Input
  7. search
  8. enter-button
  9. placeholder="请输入分类名称"
  10. v-model="uploadName.name"
  11. style="width: 90%"
  12. @on-search="changePage"
  13. />
  14. </div> -->
  15. <div class="trees-coadd">
  16. <div class="scollhide">
  17. <div class="tree">
  18. <!-- <Tree :data="treeData" :render="renderContent" :load-data="loadData" class="treeBox" ref="tree"></Tree> -->
  19. <el-tree
  20. :data="treeData"
  21. node-key="id"
  22. default-expand-all
  23. :expand-on-click-node="false"
  24. @node-click="appendBtn"
  25. :current-node-key="treeId"
  26. >
  27. <span class="custom-tree-node" slot-scope="{ data }">
  28. <span class="file-name">
  29. <i class="icon el-icon-folder-remove"></i>
  30. {{ data.title }}</span
  31. >
  32. <span>
  33. <el-dropdown @command="(command) => clickMenu(data, command)">
  34. <Icon class="add" type="ios-more" />
  35. <template slot="dropdown">
  36. <el-dropdown-menu>
  37. <el-dropdown-item command="1">新增分类</el-dropdown-item>
  38. <el-dropdown-item v-if="data.id" command="2">编辑分类</el-dropdown-item>
  39. <el-dropdown-item v-if="data.id" command="3">删除</el-dropdown-item>
  40. </el-dropdown-menu>
  41. </template>
  42. </el-dropdown>
  43. </span>
  44. </span>
  45. </el-tree>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <div class="conter">
  51. <div class="bnt acea-row row-middle df-jcsb">
  52. <div class="">
  53. <el-button
  54. type="primary"
  55. :disabled="checkPicList.length === 0"
  56. @click="checkPics"
  57. size="small"
  58. v-if="isShow !== 0"
  59. >使用选中图片</el-button
  60. >
  61. <el-button size="small" type="primary" @click="uploadModal">上传图片</el-button>
  62. <el-button
  63. type="error"
  64. class="mr10"
  65. size="small"
  66. :disabled="!checkPicList.length && !ids.length"
  67. @click.stop="editPicList()"
  68. >删除图片</el-button
  69. >
  70. <el-cascader
  71. v-model="pids"
  72. placeholder="图片移动至"
  73. style="width: 150px"
  74. class="treeSel"
  75. :options="treeData2"
  76. :props="{ checkStrictly: true, emitPath: false, label: 'title', value: 'id' }"
  77. clearable
  78. size="small"
  79. @visible-change="moveImg"
  80. ></el-cascader>
  81. </div>
  82. <div v-if="isPage">
  83. <el-input
  84. class="mr10"
  85. v-model="fileData.real_name"
  86. placeholder="请输入图片名"
  87. size="small"
  88. style="width: 150px"
  89. >
  90. <i slot="suffix" class="el-icon-search el-input__icon" @click="getFileList"></i>
  91. </el-input>
  92. <el-radio-group v-model="lietStyle" size="small" @change="radioChange">
  93. <el-radio-button label="list">
  94. <i class="el-icon-menu"></i>
  95. </el-radio-button>
  96. <el-radio-button label="table">
  97. <i class="el-icon-files"></i>
  98. </el-radio-button>
  99. </el-radio-group>
  100. </div>
  101. </div>
  102. <div class="pictrueList acea-row" :class="{ 'is-modal': !isPage }">
  103. <div v-if="lietStyle == 'list'" style="width: 100%">
  104. <div v-show="isShowPic" class="imagesNo">
  105. <Icon type="ios-images" size="60" color="#dbdbdb" />
  106. <span class="imagesNo_sp">图片库为空</span>
  107. </div>
  108. <div class="acea-row mb10">
  109. <div
  110. class="pictrueList_pic mr10 mb10"
  111. v-for="(item, index) in pictrueList"
  112. :key="index"
  113. @mouseenter="enterMouse(item)"
  114. @mouseleave="enterMouse(item)"
  115. >
  116. <p class="number" v-if="item.num > 0">
  117. <Badge :count="item.num" type="error" :offset="[11, 12]">
  118. <a href="#" class="demo-badge"></a>
  119. </Badge>
  120. </p>
  121. <img
  122. :class="item.isSelect ? 'on' : ''"
  123. v-lazy="item.satt_dir"
  124. @click.stop="changImage(item, index, pictrueList)"
  125. />
  126. <div style="operate-item " @mouseenter="enterLeave(item)" @mouseleave="enterLeave(item)">
  127. <p v-if="!item.isEdit">
  128. {{ item.editName }}
  129. </p>
  130. <el-input size="small" type="text" v-model="item.real_name" v-else @blur="bindTxt(item)" />
  131. <div class="operate-item operate-height">
  132. <span class="operate mr10" @click="editPicList(item.att_id)" v-if="item.isShowEdit">删除</span>
  133. <span class="operate mr10" @click="item.isEdit = !item.isEdit" v-if="item.isShowEdit">改名</span>
  134. <span class="operate" @click="lookImg(item)" v-if="item.isShowEdit">查看</span>
  135. </div>
  136. </div>
  137. <!-- <div class="nameStyle" v-show="item.realName && item.real_name">
  138. {{ item.real_name }}
  139. </div> -->
  140. </div>
  141. </div>
  142. <!--<Col class="mb20" v-bind="gridPic"-->
  143. <!--v-for="(item, index) in pictrueList" :key="index" >-->
  144. <!--<div class="pictrueList_pic">-->
  145. <!--<img :class="item.isSelect ? 'on': '' " v-lazy="item.satt_dir"-->
  146. <!--@click.stop="changImage(item, index, pictrueList)"/>-->
  147. <!--</div>-->
  148. <!--</Col>-->
  149. </div>
  150. <el-table
  151. v-if="lietStyle == 'table'"
  152. ref="table"
  153. :data="pictrueList"
  154. v-loading="loading"
  155. highlight-row
  156. :row-key="getRowKey"
  157. @selection-change="handleSelectRow"
  158. no-data-text="暂无数据"
  159. no-filtered-data-text="暂无筛选结果"
  160. >
  161. <el-table-column type="selection" width="60" :reserve-selection="true"> </el-table-column>
  162. <el-table-column label="图片名称" min-width="190">
  163. <template slot-scope="scope">
  164. <div class="df-aic">
  165. <div class="tabBox_img mr10" v-viewer>
  166. <img v-lazy="scope.row.att_dir" />
  167. </div>
  168. <span v-if="!scope.row.isEdit" class="line2 real-name">{{ scope.row.real_name }}</span>
  169. <el-input
  170. size="small"
  171. type="text"
  172. style="width: 90%"
  173. v-model="scope.row.real_name"
  174. v-else
  175. @blur="bindTxt(scope.row)"
  176. />
  177. </div>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="大小" min-width="80">
  181. <template slot-scope="scope">
  182. <span>{{ scope.row.size }}</span>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="上传时间" min-width="100">
  186. <template slot-scope="scope">
  187. <span>{{ scope.row.time }}</span>
  188. </template>
  189. </el-table-column>
  190. <el-table-column label="操作" fixed="right" width="170">
  191. <template slot-scope="scope">
  192. <a @click="editPicList(scope.row)">删除</a>
  193. <el-divider direction="vertical"></el-divider>
  194. <a @click="scope.row.isEdit = !scope.row.isEdit">{{ scope.row.isEdit ? '确定' : '重名命' }}</a>
  195. <el-divider direction="vertical"></el-divider>
  196. <a @click="lookImg(scope.row)">查看</a>
  197. </template>
  198. </el-table-column>
  199. </el-table>
  200. </div>
  201. <div class="footer acea-row row-right">
  202. <Page :total="total" show-elevator show-total @on-change="pageChange" :page-size="fileData.limit" />
  203. </div>
  204. </div>
  205. </div>
  206. <uploadImg ref="upload" :isPage="isPage" :categoryId="treeId" :categoryList="treeData" @uploadSuccess="uploadSuccess"></uploadImg>
  207. <div class="images" v-show="false" v-viewer="{ movable: false }">
  208. <img v-for="src in pictrueList" :src="src.att_dir" :key="src.att_id" />
  209. </div>
  210. </div>
  211. </template>
  212. <script>
  213. import {
  214. getCategoryListApi,
  215. createApi,
  216. fileListApi,
  217. categoryEditApi,
  218. moveApi,
  219. fileUpdateApi,
  220. } from '@/api/uploadPictures';
  221. import Setting from '@/setting';
  222. import { getCookies } from '@/libs/util';
  223. import uploadImg from '@/components/uploadImg';
  224. import { VueTreeList, Tree, TreeNode } from 'vue-tree-list';
  225. export default {
  226. name: 'uploadPictures',
  227. components: { uploadImg, VueTreeList },
  228. props: {
  229. isChoice: {
  230. type: String,
  231. default: '',
  232. },
  233. isPage: {
  234. type: Boolean,
  235. default: false,
  236. },
  237. gridBtn: {
  238. type: Object,
  239. default: null,
  240. },
  241. gridPic: {
  242. type: Object,
  243. default: null,
  244. },
  245. isShow: {
  246. type: Number,
  247. default: 1,
  248. },
  249. pageLimit: {
  250. type: Number,
  251. default: 0,
  252. },
  253. },
  254. data() {
  255. return {
  256. spinShow: false,
  257. fileUrl: Setting.apiBaseURL + '/file/upload',
  258. modalPic: false,
  259. treeData: [],
  260. treeData2: [],
  261. pictrueList: [],
  262. uploadData: {}, // 上传参数
  263. checkPicList: [],
  264. uploadName: {
  265. name: '',
  266. all: 1,
  267. },
  268. formValidate: { id: 0 },
  269. FromData: null,
  270. treeId: 0,
  271. isJudge: false,
  272. buttonProps: {
  273. type: 'default',
  274. size: 'small',
  275. },
  276. fileData: {
  277. pid: 0,
  278. real_name: '',
  279. page: 1,
  280. limit: this.pageLimit || 18,
  281. },
  282. total: 0,
  283. pids: 0,
  284. list: [],
  285. modalTitleSs: '',
  286. isShowPic: false,
  287. header: {},
  288. ids: [], // 选中附件的id集合
  289. lietStyle: 'list',
  290. imageUrl: '',
  291. loading: false,
  292. multipleSelection: [],
  293. };
  294. },
  295. mounted() {
  296. this.getToken();
  297. this.getList();
  298. this.getFileList();
  299. },
  300. methods: {
  301. radioChange() {
  302. this.initData();
  303. },
  304. lookImg(item) {
  305. this.imageUrl = item.att_dir;
  306. const viewer = this.$el.querySelector('.images').$viewer;
  307. viewer.show();
  308. this.$nextTick(() => {
  309. let i = this.pictrueList.findIndex((e) => e.att_dir === item.att_dir);
  310. viewer.update().view(i);
  311. });
  312. },
  313. onDel(node) {
  314. let method = node.cate_id ? routeDel : routeCateDel;
  315. this.$Modal.confirm({
  316. title: '警告',
  317. content: '<p>删除后无法恢复,请确认后删除!</p>',
  318. onOk: () => {
  319. method(node.id)
  320. .then((res) => {
  321. this.$Message.success(res.msg);
  322. node.remove();
  323. })
  324. .catch((err) => {
  325. this.$Message.error(err);
  326. });
  327. },
  328. onCancel: () => {},
  329. });
  330. },
  331. onChangeName(params) {
  332. if (params.eventType == 'blur') {
  333. let data = {
  334. name: params.newName,
  335. id: params.id,
  336. };
  337. interfaceEditName(data)
  338. .then((res) => {
  339. this.$Message.success(res.msg);
  340. })
  341. .catch((err) => {
  342. this.$Message.error(err);
  343. });
  344. }
  345. },
  346. // 点击菜单
  347. clickMenu(data, name) {
  348. console.log(name, data);
  349. if (name == 1) {
  350. this.append(data);
  351. } else if (name == 2) {
  352. this.editPic(data);
  353. } else if (name == 3) {
  354. this.remove(data, '分类');
  355. }
  356. },
  357. uploadSuccess() {
  358. this.fileData.page = 1;
  359. this.getFileList();
  360. },
  361. uploadModal() {
  362. this.$refs.upload.uploadModal = true;
  363. },
  364. enterMouse(item) {
  365. item.realName = !item.realName;
  366. },
  367. enterLeave(item) {
  368. item.isShowEdit = !item.isShowEdit;
  369. },
  370. // 上传头部token
  371. getToken() {
  372. this.header['Authori-zation'] = 'Bearer ' + getCookies('token');
  373. },
  374. moveImg(status) {
  375. if (!status) {
  376. this.getMove();
  377. } else {
  378. if (!this.ids.toString()) {
  379. this.$Message.warning('请先选择图片');
  380. return;
  381. }
  382. }
  383. },
  384. searchImg() {},
  385. // 移动分类
  386. getMove() {
  387. let data = {
  388. pid: this.pids,
  389. images: this.ids.toString(),
  390. };
  391. moveApi(data)
  392. .then(async (res) => {
  393. this.$Message.success(res.msg);
  394. this.getFileList();
  395. this.pids = 0;
  396. this.checkPicList = [];
  397. this.ids = [];
  398. })
  399. .catch((res) => {
  400. this.$Message.error(res.msg);
  401. });
  402. },
  403. delImg(id) {
  404. let ids = {
  405. ids: id,
  406. };
  407. let delfromData = {
  408. title: '删除选中图片',
  409. url: `file/file/delete`,
  410. method: 'POST',
  411. ids: ids,
  412. };
  413. this.$modalSure(delfromData)
  414. .then((res) => {
  415. this.$Message.success(res.msg);
  416. this.getFileList();
  417. this.checkPicList = [];
  418. })
  419. .catch((res) => {
  420. this.$Message.error(res.msg);
  421. });
  422. },
  423. // 删除图片
  424. editPicList(id) {
  425. let ids = {
  426. ids: id || this.ids.toString(),
  427. };
  428. let delfromData = {
  429. title: '删除选中图片',
  430. url: `file/file/delete`,
  431. method: 'POST',
  432. ids: ids,
  433. };
  434. this.$modalSure(delfromData)
  435. .then((res) => {
  436. this.$Message.success(res.msg);
  437. this.getFileList();
  438. this.initData();
  439. })
  440. .catch((res) => {
  441. this.$Message.error(res.msg);
  442. });
  443. },
  444. initData() {
  445. this.checkPicList = [];
  446. this.ids = [];
  447. this.multipleSelection = [];
  448. },
  449. // 鼠标移入 移出
  450. onMouseOver(root, node, data) {
  451. event.preventDefault();
  452. data.flag = !data.flag;
  453. if (data.flag2) {
  454. data.flag2 = false;
  455. }
  456. },
  457. // onClick(root, node, data, e) {
  458. // e.preventDefault();
  459. // data.flag2 = !data.flag2;
  460. // },
  461. // 点击树
  462. appendBtn(data) {
  463. this.treeId = data.id;
  464. this.fileData.page = 1;
  465. this.getFileList();
  466. },
  467. // 点击添加
  468. append(data) {
  469. this.treeId = data.id;
  470. this.getFrom();
  471. },
  472. // 删除分类
  473. remove(data, tit) {
  474. this.tits = tit;
  475. let delfromData = {
  476. title: '删除 [ ' + data.title + ' ] ' + '分类',
  477. url: `file/category/${data.id}`,
  478. method: 'DELETE',
  479. ids: '',
  480. };
  481. this.$modalSure(delfromData)
  482. .then((res) => {
  483. this.$Message.success(res.msg);
  484. this.getList();
  485. this.checkPicList = [];
  486. })
  487. .catch((res) => {
  488. this.$Message.error(res.msg);
  489. });
  490. },
  491. // 确认删除树
  492. // submitModel () {
  493. // if (this.tits === '图片') {
  494. // this.getFileList();
  495. // this.checkPicList = [];
  496. // } else {
  497. // this.getList();
  498. // this.checkPicList = [];
  499. // }
  500. // },
  501. // 编辑树表单
  502. editPic(data) {
  503. this.$modalForm(categoryEditApi(data.id)).then(() => this.getList());
  504. },
  505. // 搜索分类
  506. changePage() {
  507. this.getList('search');
  508. },
  509. // 分类列表树
  510. getList(type) {
  511. let data = {
  512. title: '全部图片',
  513. id: '',
  514. pid: 0,
  515. };
  516. getCategoryListApi(this.uploadName)
  517. .then(async (res) => {
  518. if (type !== 'search') {
  519. this.treeData2 = JSON.parse(JSON.stringify([...res.data.list]));
  520. }
  521. res.data.list.unshift(data);
  522. this.treeData = res.data.list;
  523. console.log(this.treeData);
  524. // this.addFlag(this.treeData);
  525. })
  526. .catch((res) => {
  527. this.$Message.error(res.msg);
  528. });
  529. },
  530. loadData(item, callback) {
  531. getCategoryListApi({
  532. pid: item.id,
  533. })
  534. .then(async (res) => {
  535. const data = res.data.list;
  536. callback(data);
  537. })
  538. .catch((res) => {});
  539. },
  540. addFlag(treedata) {
  541. treedata.map((item) => {
  542. this.$set(item, 'flag', false);
  543. this.$set(item, 'flag2', false);
  544. item.children && this.addFlag(item.children);
  545. });
  546. },
  547. // 新建分类
  548. add() {
  549. this.treeId = 0;
  550. this.getFrom();
  551. },
  552. // 文件列表
  553. getFileList() {
  554. this.fileData.pid = this.treeId;
  555. fileListApi(this.fileData)
  556. .then(async (res) => {
  557. res.data.list.forEach((el) => {
  558. el.isSelect = false;
  559. el.isEdit = false;
  560. el.isShowEdit = false;
  561. el.realName = false;
  562. el.num = 0;
  563. this.editName(el);
  564. });
  565. this.pictrueList = res.data.list;
  566. if (this.pictrueList.length) {
  567. this.isShowPic = false;
  568. } else {
  569. this.isShowPic = true;
  570. }
  571. this.total = res.data.count;
  572. this.$nextTick(() => {
  573. //确保dom加载完毕
  574. // this.showSelectData();
  575. });
  576. })
  577. .catch((res) => {
  578. this.$Message.error(res.msg);
  579. });
  580. },
  581. showSelectData() {
  582. if (this.multipleSelection.length > 0) {
  583. // 判断是否存在勾选过的数据
  584. this.pictrueList.forEach((row) => {
  585. // 获取数据列表接口请求到的数据
  586. this.multipleSelection.forEach((item) => {
  587. // 勾选到的数据
  588. if (row.att_id === item.att_id) {
  589. // this.$refs.table.toggleRowSelection(item, true); // 若有重合,则回显该条数据
  590. }
  591. });
  592. });
  593. }
  594. },
  595. getRowKey(row) {
  596. return row.att_id;
  597. },
  598. //对象数组去重;
  599. unique(arr) {
  600. let result = arr.reduce((acc, curr) => {
  601. const x = acc.find((item) => item.att_id === curr.att_id);
  602. if (!x) {
  603. return acc.concat([curr]);
  604. } else {
  605. return acc;
  606. }
  607. }, []);
  608. return result;
  609. },
  610. // 选中某一行
  611. handleSelectRow(selection) {
  612. let arr = this.unique(selection);
  613. console.log(selection, arr);
  614. const uniqueArr = [];
  615. const ids = [];
  616. for (let i = 0; i < arr.length; i++) {
  617. const item = arr[i];
  618. if (!ids.includes(item.att_id)) {
  619. uniqueArr.push(item);
  620. ids.push(item.att_id);
  621. }
  622. }
  623. this.ids = ids;
  624. this.multipleSelection = uniqueArr;
  625. },
  626. pageChange(index) {
  627. this.fileData.page = index;
  628. this.getFileList();
  629. this.checkPicList = [];
  630. },
  631. // 新建分类表单
  632. getFrom() {
  633. this.$modalForm(createApi({ id: this.treeId })).then((res) => {
  634. this.getList();
  635. });
  636. },
  637. // 上传之前
  638. beforeUpload(file) {
  639. // if (file.size > 2097152) {
  640. // this.$Message.error(file.name + "大小超过2M!");
  641. // } else
  642. if (!/image\/\w+/.test(file.type)) {
  643. this.$Message.error('请上传以jpg、jpeg、png等结尾的图片文件'); //FileExt.toLowerCase()
  644. return false;
  645. }
  646. this.uploadData = {
  647. pid: this.treeId,
  648. };
  649. let promise = new Promise((resolve) => {
  650. this.$nextTick(function () {
  651. resolve(true);
  652. });
  653. });
  654. return promise;
  655. },
  656. // 上传成功
  657. handleSuccess(res, file, fileList) {
  658. if (res.status === 200) {
  659. this.$Message.success(res.msg);
  660. this.fileData.page = 1;
  661. this.getFileList();
  662. } else {
  663. this.$Message.error(res.msg);
  664. }
  665. },
  666. // 关闭
  667. cancel() {
  668. this.$emit('changeCancel');
  669. },
  670. // 选中图片
  671. changImage(item, index, row) {
  672. let activeIndex = 0;
  673. if (!item.isSelect) {
  674. item.isSelect = true;
  675. this.checkPicList.push(item);
  676. } else {
  677. item.isSelect = false;
  678. this.checkPicList.map((el, index) => {
  679. if (el.att_id == item.att_id) {
  680. activeIndex = index;
  681. }
  682. });
  683. this.checkPicList.splice(activeIndex, 1);
  684. }
  685. this.ids = [];
  686. this.checkPicList.map((item, i) => {
  687. this.ids.push(item.att_id);
  688. });
  689. this.pictrueList.map((el, i) => {
  690. if (el.isSelect) {
  691. this.checkPicList.filter((el2, j) => {
  692. if (el.att_id == el2.att_id) {
  693. el.num = j + 1;
  694. }
  695. });
  696. } else {
  697. el.num = 0;
  698. }
  699. });
  700. },
  701. // 点击使用选中图片
  702. checkPics() {
  703. if (this.isChoice === '单选') {
  704. if (this.checkPicList.length > 1) return this.$Message.warning('最多只能选一张图片');
  705. this.$emit('getPic', this.checkPicList[0]);
  706. } else {
  707. let maxLength = this.$route.query.maxLength;
  708. if (maxLength != undefined && this.checkPicList.length > Number(maxLength))
  709. return this.$Message.warning('最多只能选' + maxLength + '张图片');
  710. this.$emit('getPicD', this.checkPicList);
  711. }
  712. },
  713. editName(item) {
  714. let it = item.real_name.split('.');
  715. let it1 = it[1] == undefined ? [] : it[1];
  716. let len = it[0].length + it1.length;
  717. item.editName = len < 10 ? item.real_name : item.real_name.substr(0, 2) + '...' + item.real_name.substr(-5, 5);
  718. },
  719. // 修改图片文字上传
  720. bindTxt(item) {
  721. if (item.real_name == '') {
  722. this.$Message.error('请填写内容');
  723. }
  724. fileUpdateApi(item.att_id, {
  725. real_name: item.real_name,
  726. })
  727. .then((res) => {
  728. this.editName(item);
  729. item.isEdit = false;
  730. this.$Message.success(res.msg);
  731. })
  732. .catch((error) => {
  733. this.$Message.error(error.msg);
  734. });
  735. },
  736. },
  737. };
  738. </script>
  739. <style scoped lang="scss">
  740. .nameStyle {
  741. position: absolute;
  742. white-space: nowrap;
  743. z-index: 9;
  744. background: #eee;
  745. height: 20px;
  746. line-height: 20px;
  747. color: #555;
  748. border: 1px solid #ebebeb;
  749. padding: 0 5px;
  750. left: 56px;
  751. bottom: -18px;
  752. }
  753. .iconbianji1 {
  754. font-size: 13px;
  755. }
  756. .selectTreeClass {
  757. background: #d5e8fc;
  758. }
  759. .treeBox {
  760. width: 100%;
  761. height: 100%;
  762. max-width: 180px;
  763. }
  764. .is-modal .pictrueList_pic {
  765. width: 100px;
  766. margin-right: 10px !important;
  767. img {
  768. width: 100%;
  769. height: 100px;
  770. }
  771. }
  772. .pictrueList_pic {
  773. position: relative;
  774. width: 146px;
  775. cursor: pointer;
  776. margin-right: 19px !important;
  777. img {
  778. width: 146px;
  779. height: 146px;
  780. object-fit: cover;
  781. }
  782. p {
  783. overflow: hidden;
  784. text-overflow: ellipsis;
  785. white-space: nowrap;
  786. height: 20px;
  787. font-size: 12px;
  788. color: #515a6d;
  789. text-align: center;
  790. }
  791. .number {
  792. height: 33px;
  793. }
  794. .number {
  795. position: absolute;
  796. right: 0;
  797. top: 0;
  798. }
  799. }
  800. .Nav {
  801. width: 100%;
  802. border-right: 1px solid #eee;
  803. min-width: 220px;
  804. max-width: 220px;
  805. }
  806. .trees-coadd {
  807. width: 100%;
  808. border-radius: 4px;
  809. overflow: hidden;
  810. position: relative;
  811. .scollhide {
  812. overflow-x: hidden;
  813. overflow-y: scroll;
  814. padding: 0px 0 10px 0;
  815. box-sizing: border-box;
  816. .tree {
  817. min-height: 374px;
  818. /deep/ .file-name {
  819. display: flex;
  820. align-items: center;
  821. .icon {
  822. width: 12px;
  823. height: 12px;
  824. margin-right: 8px;
  825. }
  826. }
  827. /deep/ .el-tree-node {
  828. margin-right: 16px;
  829. }
  830. /deep/ .el-tree-node__children .el-tree-node {
  831. margin-right: 0;
  832. }
  833. /deep/ .el-tree-node__content {
  834. width: 100%;
  835. height: 36px;
  836. }
  837. /deep/ .custom-tree-node {
  838. flex: 1;
  839. display: flex;
  840. align-items: center;
  841. justify-content: space-between;
  842. padding-right: 17px;
  843. font-size: 13px;
  844. font-weight: 400;
  845. color: rgba(0, 0, 0, 0.6);
  846. line-height: 13px;
  847. }
  848. /deep/ .is-current {
  849. background: #f1f9ff !important;
  850. color: #1890ff !important;
  851. }
  852. /deep/ .is-current .custom-tree-node {
  853. color: #1890ff !important;
  854. }
  855. }
  856. }
  857. .scollhide::-webkit-scrollbar {
  858. display: none;
  859. }
  860. }
  861. .treeSel >>> .ivu-select-dropdown-list {
  862. padding: 0 5px !important;
  863. box-sizing: border-box;
  864. width: 200px;
  865. }
  866. .imagesNo {
  867. display: flex;
  868. justify-content: center;
  869. flex-direction: column;
  870. align-items: center;
  871. margin: 65px 0;
  872. .imagesNo_sp {
  873. font-size: 13px;
  874. color: #dbdbdb;
  875. line-height: 3;
  876. }
  877. }
  878. .Modal {
  879. width: 100%;
  880. height: 100%;
  881. background: #fff !important;
  882. }
  883. .fill-window {
  884. height: 100vh;
  885. }
  886. .colLeft {
  887. padding-right: 0 !important;
  888. height: 100%;
  889. display: flex;
  890. flex-wrap: nowrap;
  891. }
  892. .conter {
  893. width: 100%;
  894. height: 100%;
  895. margin-left: 20px !important;
  896. }
  897. .conter .bnt {
  898. width: 100%;
  899. padding: 0 13px 20px 0px;
  900. box-sizing: border-box;
  901. }
  902. .conter .pictrueList {
  903. // width: 100%;
  904. overflow-x: hidden;
  905. overflow-y: auto;
  906. // height: 300px;
  907. }
  908. .right-col {
  909. // flex: 1;
  910. }
  911. .conter .pictrueList img {
  912. width: 100%;
  913. }
  914. .conter .pictrueList img.on {
  915. border: 2px solid #5fb878;
  916. }
  917. .conter .footer {
  918. padding: 0 20px 10px 20px;
  919. }
  920. .tabBox_img {
  921. display: flex;
  922. align-items: center;
  923. }
  924. .real-name {
  925. flex: 1;
  926. }
  927. .df-aic {
  928. display: flex;
  929. align-items: center;
  930. }
  931. .demo-badge {
  932. width: 42px;
  933. height: 42px;
  934. background: transparent;
  935. border-radius: 6px;
  936. display: inline-block;
  937. }
  938. .bnt /deep/ .ivu-tree-children {
  939. padding: 5px 0;
  940. }
  941. .card-tree {
  942. background: #fff;
  943. height: 72px;
  944. box-sizing: border-box;
  945. overflow-x: scroll; /* 设置溢出滚动 */
  946. white-space: nowrap;
  947. overflow-y: hidden;
  948. /* 隐藏滚动条 */
  949. border-radius: 4px;
  950. scrollbar-width: none; /* firefox */
  951. -ms-overflow-style: none; /* IE 10+ */
  952. }
  953. .card-tree::-webkit-scrollbar {
  954. display: none; /* Chrome Safari */
  955. }
  956. .tabs {
  957. background: #fff;
  958. padding-top: 10px;
  959. border-radius: 5px 5px 0 0;
  960. }
  961. .operate-item {
  962. display: flex;
  963. align-items: center;
  964. justify-content: center;
  965. }
  966. .operate-height {
  967. height: 16px;
  968. }
  969. .operate {
  970. color: #1890ff;
  971. font-size: 12px;
  972. white-space: nowrap;
  973. }
  974. </style>