CMkMagicBoxTop.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  1. <template>
  2. <div>
  3. <div class="container" v-loading="pageloading">
  4. <div class="container-box">
  5. <h2>魔百和</h2>
  6. <div class="adv-type">
  7. <div class="search-list-box">
  8. <el-select
  9. v-model="modNameVal"
  10. @change="changeModName"
  11. class="search-box"
  12. clearable
  13. style="width:15vw"
  14. >
  15. <el-option
  16. v-for="items in modNameList"
  17. :key="items.id"
  18. :label="items.name"
  19. :value="items.id"
  20. >
  21. </el-option>
  22. </el-select>
  23. <!-- <el-input v-model="fileNameSearch" placeholder="文件名称" @input="searchInput" class="file-name-search search-box"></el-input>
  24. <el-select v-model="timeSort" @change="timeSortChange" class="search-box">
  25. <el-option v-for="item in sortList" :key="item.sortCode" :label="item.sortName"
  26. :value="item.sortCode">
  27. </el-option>
  28. </el-select>
  29. <div class="block search-box search-box1">
  30. <el-date-picker
  31. v-model="dateSearch"
  32. type="daterange"
  33. range-separator="至"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. @change="dateSearchChange"
  37. class="search-inner-box">
  38. </el-date-picker>
  39. </div>-->
  40. </div>
  41. <span v-if="isFuncBtnShow">
  42. <el-button
  43. type="success"
  44. @click="uploadBtn"
  45. size="medium"
  46. >批量上传
  47. </el-button>
  48. <el-button type="primary" @click="addMod" size="medium"
  49. >新增模块
  50. </el-button>
  51. <!-- <myUpload
  52. style="float: left;"
  53. @uploadBack="uploadBack"
  54. :fileInfo="fileInfo"
  55. :fileList="fileInfo.fileList"
  56. ></myUpload> -->
  57. <!-- <el-button
  58. type="primary"
  59. @click="mstatuschange"
  60. size="medium"
  61. >{{ mstatus ? "取消多选" : "多选" }}
  62. </el-button> -->
  63. <!-- <el-button
  64. type="primary"
  65. @click="dialogCli(1)"
  66. size="medium"
  67. :disabled="!mstatus"
  68. >导出
  69. </el-button> -->
  70. </span>
  71. </div>
  72. <div class="img-box">
  73. <div class="boximg">
  74. <div
  75. class="imgMod"
  76. v-for="(item, index) in modInfoList"
  77. :key="index"
  78. >
  79. <div class="imgModTitle">
  80. <p>{{ item.categoryName }}</p>
  81. <div class="modBtnBox" v-if="isFuncBtnShow">
  82. <myUpload
  83. style="float: left;"
  84. @uploadBack="uploadBack"
  85. :fileInfo="fileInfot"
  86. :fileList="fileInfot.fileList"
  87. @test="testBack(item)"
  88. ></myUpload>
  89. <el-button
  90. type="primary"
  91. @click="modifyMod(item)"
  92. size="medium"
  93. >修改模块</el-button
  94. >
  95. <el-button
  96. type="danger"
  97. @click="toMessage(item.categoryId)"
  98. size="medium"
  99. >删除模块</el-button
  100. >
  101. </div>
  102. </div>
  103. <div class="imgModBox">
  104. <div
  105. v-for="(imgItem,
  106. imgIndex) in item.mkMagicBoxTopList"
  107. :key="imgIndex"
  108. class="img-list"
  109. >
  110. <div class="img-content">
  111. <img
  112. :src="imgItem.imageUrl"
  113. alt=""
  114. @click="checkimg(imgItem, imgIndex)"
  115. />
  116. <div class="func-box" v-if="isFuncBtnShow">
  117. <div class="func-inner-box">
  118. <div
  119. class="modify-img-box"
  120. @click="modifyImg(imgItem)"
  121. >
  122. <i
  123. class="el-icon-edit"
  124. color="#ffffff"
  125. ></i>
  126. </div>
  127. <div
  128. class="del-img-box"
  129. @click="toMessage2(imgItem)"
  130. >
  131. <i
  132. class="el-icon-delete"
  133. ></i>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- <el-checkbox
  138. v-if="mstatus"
  139. v-model="imgItem.checked"
  140. @change="checkAdd(imgItem)"
  141. ></el-checkbox> -->
  142. </div>
  143. <div class="file-name">
  144. {{ imgItem.name }}
  145. </div>
  146. <!-- <input
  147. type="text"
  148. class="file-name"
  149. v-model="imgItem.name"
  150. :readonly="!item.isRename"
  151. @dblclick="renameFile(item)"
  152. :style="{
  153. border: !item.isRename
  154. ? 'none'
  155. : '1px solid #ddd'
  156. }"
  157. @blur="submitFileName(item)"
  158. /> -->
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. <!-- <el-pagination :page-size="20" class="pageBox" @current-change="currchange" layout="prev, pager, next" background
  164. :total="total">
  165. </el-pagination> -->
  166. </div>
  167. </div>
  168. <!-- <div v-if="bigImgs" class="bigimgcheck">
  169. <i class="el-icon-close close" @click="bigImgs = false"></i>
  170. <img :src="checksrc" alt="" />
  171. </div> -->
  172. </div>
  173. <!-- 新增模块 -->
  174. <el-dialog
  175. title="新增模块"
  176. :visible.sync="addModDialogStatus"
  177. width="50%"
  178. :destroy-on-close="true"
  179. :modal-append-to-body="false"
  180. :close-on-click-modal="false"
  181. :before-close="addModClosedia"
  182. :fullscreen="false"
  183. >
  184. <div v-loading="loadinged">
  185. <el-form :model="modList" ref="modList" :rules="rules">
  186. <el-form-item prop="modName">
  187. <span>模块名称</span>
  188. <el-input v-model="modList.modName"></el-input>
  189. </el-form-item>
  190. <el-form-item prop="modSort">
  191. <span>模块序号(数字越大,位置越靠前)</span>
  192. <el-input v-model="modList.modSort" type="number"></el-input>
  193. </el-form-item>
  194. </el-form>
  195. <div slot="footer" class="dialog-footer myfooter">
  196. <el-button @click="addModClosedia">取消</el-button>
  197. <el-button type="primary" @click="dialogCli(1)" class="mRight10"
  198. >提交</el-button
  199. >
  200. </div>
  201. </div>
  202. </el-dialog>
  203. <!-- 修改模块 -->
  204. <el-dialog
  205. title="修改模块"
  206. :visible.sync="modifyModDialogStatus"
  207. width="50%"
  208. :destroy-on-close="true"
  209. :modal-append-to-body="false"
  210. :close-on-click-modal="false"
  211. :before-close="modifyModClosedia"
  212. :fullscreen="false"
  213. >
  214. <div v-loading="loadinged">
  215. <el-form :model="modList" ref="modList" :rules="rules">
  216. <el-form-item prop="modName">
  217. <span>模块名称</span>
  218. <el-input v-model="modList.modName"></el-input>
  219. </el-form-item>
  220. <el-form-item prop="modSort">
  221. <span>模块序号(数字越大,位置越靠前)</span>
  222. <el-input v-model="modList.modSort" type="number"></el-input>
  223. </el-form-item>
  224. </el-form>
  225. <div slot="footer" class="dialog-footer myfooter">
  226. <el-button @click="modifyModClosedia">取消</el-button>
  227. <el-button type="primary" @click="dialogCli(2)" class="mRight10"
  228. >提交</el-button
  229. >
  230. </div>
  231. </div>
  232. </el-dialog>
  233. <!-- 修改图片信息 -->
  234. <el-dialog
  235. title="修改图片信息"
  236. :visible.sync="modifyImgDialogStatus"
  237. width="50%"
  238. :destroy-on-close="true"
  239. :modal-append-to-body="false"
  240. :close-on-click-modal="false"
  241. :before-close="modifyImgClosedia"
  242. :fullscreen="false"
  243. >
  244. <div v-loading="loadinged">
  245. <el-form :model="imgList" ref="imgList" :rules="rules">
  246. <el-form-item prop="imgName">
  247. <span>图片名称</span>
  248. <el-input v-model="imgList.imgName"></el-input>
  249. </el-form-item>
  250. <el-form-item prop="imgSort">
  251. <span>图片序号(数字越大,位置越靠前)</span>
  252. <el-input v-model="imgList.imgSort" type="number"></el-input>
  253. </el-form-item>
  254. </el-form>
  255. <div slot="footer" class="dialog-footer myfooter">
  256. <el-button @click="modifyImgClosedia">取消</el-button>
  257. <el-button type="primary" @click="dialogCli(3)" class="mRight10"
  258. >提交</el-button
  259. >
  260. </div>
  261. </div>
  262. </el-dialog>
  263. <!-- 批量上传图片 -->
  264. <el-dialog
  265. title="批量上传图片"
  266. :visible.sync="uploadImgDialogStatus"
  267. width="50%"
  268. :destroy-on-close="true"
  269. :modal-append-to-body="false"
  270. :close-on-click-modal="false"
  271. :before-close="uploadImgClosedia"
  272. :fullscreen="false"
  273. >
  274. <div v-loading="loadinged">
  275. <el-form :model="uploadList" ref="uploadList" :rules="rules">
  276. <!-- 批量上传模块选择下拉 -->
  277. <el-form-item prop="modNameValUpload" class="multiUpload">
  278. <span class="multiUploadLabel">模块名称</span>
  279. <el-select
  280. v-model="uploadList.modNameValUpload"
  281. class="search-box"
  282. clearable
  283. >
  284. <el-option
  285. v-for="items in modNameList"
  286. :key="items.id"
  287. :label="items.name"
  288. :value="items.id"
  289. >
  290. </el-option>
  291. </el-select>
  292. </el-form-item>
  293. <el-form-item class="multiUpload">
  294. <span class="multiUploadLabel">图片选择</span>
  295. <el-upload
  296. class="upload-demo"
  297. ref="upload"
  298. action="/mkt/market/CMkMagicBox/upload"
  299. :file-list="fileList"
  300. :auto-upload="false"
  301. :data="otherParams"
  302. name="files"
  303. :headers="uploadHeader"
  304. :multiple="true"
  305. :on-success="uploadSucc"
  306. :on-error="uploadError"
  307. >
  308. <!-- :before-upload="beforeUpload"-->
  309. <el-button
  310. slot="trigger"
  311. size="small"
  312. type="success"
  313. >选取图片</el-button>
  314. <span class="multiUploadLabelerr">只支持jpg、png格式的文件上传,且单个文件大小在2M以内</span>
  315. <!-- <div slot="tip" class="el-upload__tip">
  316. 只能上传jpg/png文件,且不超过500kb
  317. </div> -->
  318. </el-upload>
  319. </el-form-item>
  320. </el-form>
  321. <div slot="footer" class="dialog-footer myfooter">
  322. <el-button @click="uploadImgClosedia">取消</el-button>
  323. <el-button
  324. class="mRight10"
  325. type="primary"
  326. @click="submitUpload"
  327. >提交</el-button
  328. >
  329. </div>
  330. </div>
  331. </el-dialog>
  332. <myMessage
  333. :messTit="messTit"
  334. @closeMessage="closeMessage"
  335. :centerDialogVisible="centerDialogVisible"
  336. v-if="centerDialogVisible"
  337. ></myMessage>
  338. </div>
  339. </template>
  340. <script>
  341. import myUpload from "../../../components/modUpload";
  342. import myMessage from "../../../components/myMessage.vue";
  343. export default {
  344. components: {
  345. myUpload,
  346. myMessage
  347. },
  348. data() {
  349. return {
  350. rules: {
  351. modName: [
  352. {
  353. required: true,
  354. trigger: "change",
  355. message: "不能为空"
  356. }
  357. ],
  358. modSort: [
  359. {
  360. required: true,
  361. trigger: "change",
  362. message: "不能为空"
  363. }
  364. ],
  365. imgName: [
  366. {
  367. required: true,
  368. trigger: "change",
  369. message: "不能为空"
  370. }
  371. ],
  372. imgSort: [
  373. {
  374. required: true,
  375. trigger: "change",
  376. message: "不能为空"
  377. }
  378. ],
  379. modNameValUpload: [
  380. {
  381. required: true,
  382. trigger: "change",
  383. message: "不能为空"
  384. }
  385. ]
  386. },
  387. addModDialogStatus: false, //新增模块弹窗
  388. modifyModDialogStatus: false, //修改模块弹窗
  389. modifyImgDialogStatus: false, //修改图片信息弹窗
  390. uploadImgDialogStatus: false, //上传图片信息弹窗
  391. fileList: [],
  392. modList: {},
  393. imgList: {},
  394. loadinged: false,
  395. modNameList: [],
  396. modNameVal: "",
  397. modNameValUpload: "",
  398. otherParams: {},
  399. uploadList: {},
  400. uploadHeader: {
  401. agileauthtoken: JSON.parse(window.sessionStorage.agileauthtoken)
  402. },
  403. info: {},
  404. delbox: [],
  405. infotype: "",
  406. typeList: [],
  407. fileInfot: {
  408. type: "btn",
  409. typename: "一键上传",
  410. btntype: "success",
  411. limit: 10,
  412. url: "/market/CMkMagicBox/upload",
  413. fileList: [],
  414. categoryId: "",
  415. categoryName: "",
  416. fileSize: 20
  417. },
  418. total: 0,
  419. pageSize: 1,
  420. modInfoList: [],
  421. bigImgs: false,
  422. checksrc: null,
  423. mstatus: false,
  424. checkList: [],
  425. params: {},
  426. fileNameSearch: "",
  427. isRename: true,
  428. cid: null,
  429. messTit:"",
  430. centerDialogVisible:false,
  431. messTyp:0,
  432. idList : [],
  433. //时间排序
  434. sortList: [
  435. {
  436. sortCode: "1",
  437. sortName: "倒序"
  438. },
  439. {
  440. sortCode: "2",
  441. sortName: "正序"
  442. }
  443. ],
  444. timeSort: "倒序",
  445. isDesc: "desc",
  446. dateSearch: [],
  447. createTimeFrom: "",
  448. createTimeTo: "",
  449. menus: JSON.parse(window.sessionStorage.childrenMenus),
  450. isFuncBtnShow: false,
  451. pageloading: false,
  452. };
  453. },
  454. methods: {
  455. //批量上传
  456. uploadBtn() {
  457. this.uploadImgDialogStatus = true;
  458. },
  459. uploadImgClosedia() {
  460. this.uploadImgDialogStatus = false;
  461. this.uploadList.modNameValUpload = "";
  462. },
  463. submitUpload() {
  464. // this.$refs.upload.submit();
  465. this.$refs.uploadList.validate(valid => {
  466. if (valid) {
  467. // 批量上传模块选择下拉
  468. let temp = this.modNameList.find(item => {
  469. return item.id == this.uploadList.modNameValUpload;
  470. });
  471. this.otherParams.categoryId = this.uploadList.modNameValUpload;
  472. this.otherParams.categoryName = temp.name;
  473. // if(this.fileList.length == 0){
  474. // this.$message({
  475. // message: "请选择图片并且只能上传图片!",
  476. // type: "error"
  477. // });
  478. // }else{
  479. // this.$refs.upload.submit();
  480. // }
  481. if(this.$refs.upload.uploadFiles.length==0){
  482. this.$message.error('未选择图片!');
  483. }
  484. var bol=true;
  485. for (let i = 0; i < this.$refs.upload.uploadFiles.length; i++) {
  486. if(!this.beforeUpload(this.$refs.upload.uploadFiles[i])){
  487. bol=false;
  488. }
  489. }
  490. if(bol) {
  491. this.$refs.upload.submit();
  492. }
  493. }
  494. });
  495. },
  496. beforeUpload(file){
  497. // const isJPG = file.type.indexOf('image') != -1;
  498. const isJPG = (file.raw.type === 'image/jpeg') || (file.raw.type ==='image/png');
  499. if (!isJPG) {
  500. this.$message.error('只能上传jpg或png图片!');
  501. return isJPG;
  502. }
  503. const isLt2M = file.size / 1024 / 1024 < 2;
  504. if (!isLt2M) {
  505. this.$message.error('上传单文件大小不能超过 2MB!');
  506. return isLt2M;
  507. }
  508. return isJPG;
  509. },
  510. uploadSucc(res) {
  511. if (res.result === 0) {
  512. this.$message({
  513. message: "上传成功",
  514. type: "success"
  515. });
  516. } else {
  517. this.$message({
  518. message: res.desc,
  519. type: "error"
  520. });
  521. }
  522. this.uploadImgClosedia();
  523. this.getlist("");
  524. },
  525. uploadError(res) {
  526. // console.log("222", res);
  527. },
  528. testBack(item) {
  529. this.fileInfot.categoryId = item.categoryId;
  530. this.fileInfot.categoryName = item.categoryName;
  531. },
  532. //新增模块
  533. addMod() {
  534. this.addModDialogStatus = true;
  535. },
  536. //修改模块
  537. modifyMod(item) {
  538. // this.modList = item
  539. // this.modList.modName = item.categoryName;
  540. // this.modList.modSort = item.sort;
  541. this.$set(this.modList, "modId", item.categoryId);
  542. this.$set(this.modList, "modName", item.categoryName);
  543. this.$set(this.modList, "modSort", item.sort);
  544. this.modifyModDialogStatus = true;
  545. },
  546. //新增模块弹窗关闭
  547. addModClosedia() {
  548. this.addModDialogStatus = false;
  549. this.modList = {};
  550. },
  551. modifyModClosedia() {
  552. this.modifyModDialogStatus = false;
  553. this.modList = {};
  554. },
  555. modifyImg(imgItem) {
  556. this.$set(this.imgList, "imgId", imgItem.id);
  557. this.$set(this.imgList, "imgName", imgItem.name);
  558. this.$set(this.imgList, "imgSort", imgItem.sort);
  559. this.modifyImgDialogStatus = true;
  560. },
  561. modifyImgClosedia() {
  562. this.modifyImgDialogStatus = false;
  563. this.imgList = {};
  564. },
  565. delDialogCli(cId) {
  566. //模块删除
  567. // if (v == 2) {
  568. this.$http({
  569. url: "/market/CMkMagicBox/delMkMagicBoxCategory ",
  570. method: "post",
  571. headers: {
  572. "Content-Type": "application/json"
  573. },
  574. data: { id: cId }
  575. }).then(res => {
  576. if (res.data.result === 0) {
  577. this.$message({
  578. message: "成功",
  579. type: "success"
  580. });
  581. this.getlist("");
  582. location.reload();
  583. } else {
  584. this.$message({
  585. message: res.data.desc,
  586. type: "error"
  587. });
  588. }
  589. });
  590. // }
  591. },
  592. delImg(imgItem) {
  593. //图片删除
  594. // if (v == 2) {
  595. let idList = [
  596. {
  597. id: imgItem.id
  598. }
  599. ];
  600. this.$http({
  601. url: "/market/CMkMagicBox/delMkMagicBoxTop",
  602. method: "post",
  603. headers: {
  604. "Content-Type": "application/json"
  605. },
  606. data: idList
  607. }).then(res => {
  608. if (res.data.result === 0) {
  609. this.$message({
  610. message: "成功",
  611. type: "success"
  612. });
  613. this.getlist("");
  614. } else {
  615. this.$message({
  616. message: res.data.desc,
  617. type: "error"
  618. });
  619. }
  620. });
  621. // }
  622. },
  623. changeModName(v) {
  624. this.getlist(v);
  625. },
  626. timeSortChange(v) {
  627. if (v == 1) {
  628. this.isDesc = "desc";
  629. this.getlist(this.pageSize);
  630. } else if (v == 2) {
  631. this.isDesc = "";
  632. this.getlist(this.pageSize);
  633. }
  634. },
  635. dateSearchChange(v) {
  636. this.createTimeFrom = this.$formatDate(v[0], "YYYY-MM-DD");
  637. this.createTimeTo = this.$formatDate(v[1], "YYYY-MM-DD");
  638. this.getlist(this.pageSize);
  639. },
  640. searchInput(v) {
  641. this.fileNameSearch = v;
  642. this.getlist(this.pageSize);
  643. },
  644. uploadBack(v) {
  645. this.getlist("");
  646. },
  647. dialogCli(v) {
  648. //1 新增模块提交 2修改模块提交 3修改图片提交
  649. if (v == 1) {
  650. this.loadinged = false;
  651. this.$refs.modList.validate(valid => {
  652. if (valid) {
  653. this.$http({
  654. url: "/market/mkMagicBoxCategory/add",
  655. method: "post",
  656. headers: {
  657. "Content-Type": "application/json"
  658. },
  659. data: {
  660. name: this.modList.modName,
  661. sort: this.modList.modSort
  662. }
  663. }).then(res => {
  664. if (res.data.result === 0) {
  665. this.$message({
  666. message: "成功",
  667. type: "success"
  668. });
  669. this.addModDialogStatus = false;
  670. this.getlist("");
  671. location.reload()
  672. } else {
  673. this.$message({
  674. message: res.data.desc,
  675. type: "error"
  676. });
  677. }
  678. });
  679. }
  680. });
  681. } else if (v === 2) {
  682. this.loadinged = false;
  683. this.$refs.modList.validate(valid => {
  684. if (valid) {
  685. this.$http({
  686. url: "/market/mkMagicBoxCategory/update",
  687. method: "post",
  688. headers: {
  689. "Content-Type": "application/json"
  690. },
  691. data: {
  692. id: this.modList.modId,
  693. name: this.modList.modName,
  694. sort: this.modList.modSort
  695. }
  696. }).then(res => {
  697. if (res.data.result === 0) {
  698. this.$message({
  699. message: "成功",
  700. type: "success"
  701. });
  702. this.modifyModDialogStatus = false;
  703. this.getlist("");
  704. } else {
  705. this.$message({
  706. message: res.data.desc,
  707. type: "error"
  708. });
  709. }
  710. });
  711. }
  712. });
  713. } else if (v === 3) {
  714. this.loadinged = false;
  715. this.$refs.imgList.validate(valid => {
  716. if (valid) {
  717. this.$http({
  718. url: "/market/mkMagicBox/update",
  719. method: "post",
  720. headers: {
  721. "Content-Type": "application/json"
  722. },
  723. data: {
  724. id: this.imgList.imgId,
  725. name: this.imgList.imgName,
  726. sort: this.imgList.imgSort
  727. }
  728. }).then(res => {
  729. if (res.data.result === 0) {
  730. this.$message({
  731. message: "成功",
  732. type: "success"
  733. });
  734. this.modifyImgDialogStatus = false;
  735. this.getlist("");
  736. } else {
  737. this.$message({
  738. message: res.data.desc,
  739. type: "error"
  740. });
  741. }
  742. });
  743. }
  744. });
  745. }
  746. // let params = [];
  747. // let paramsf = [];
  748. // for (let i = 0; i < this.checkList.length; i++) {
  749. // params.push({
  750. // id: this.checkList[i].id
  751. // });
  752. // paramsf.push({
  753. // compressFileId: this.checkList[i].compressFileId,
  754. // fileName: this.checkList[i].fileName
  755. // });
  756. // }
  757. // else if (v == 1) {
  758. // this.$http({
  759. // url: "/market/cadvMaterial/exportAdvMaterialZip",
  760. // method: "post",
  761. // responseType: "blob",
  762. // headers: {
  763. // "Content-Type": "application/json"
  764. // },
  765. // data: paramsf
  766. // }).then(response => {
  767. // if (window.navigator && window.navigator.msSaveOrOpenBlob) {
  768. // let blob = new Blob([response.data], {
  769. // type: response.data.type
  770. // });
  771. // window.navigator.msSaveOrOpenBlob(blob, "adv.zip");
  772. // } else {
  773. // /* 火狐谷歌的文件下载方式 */
  774. // console.log(response.data.type);
  775. // var blob = new Blob([response.data]);
  776. // var downloadElement = document.createElement("a");
  777. // var href = window.URL.createObjectURL(blob);
  778. // downloadElement.href = href;
  779. // downloadElement.download = "adv.zip";
  780. // document.body.appendChild(downloadElement);
  781. // downloadElement.click();
  782. // document.body.removeChild(downloadElement);
  783. // window.URL.revokeObjectURL(href);
  784. // }
  785. // });
  786. // }
  787. },
  788. renameFile(v) {
  789. this.$set(v, "isRename", true);
  790. },
  791. submitFileName(v) {
  792. v.isRename = false;
  793. let params = {
  794. id: v.id,
  795. fileName: v.fileName
  796. };
  797. this.$http({
  798. url: "/market/cadvMaterial/updateMkAdvFileName",
  799. method: "post",
  800. headers: {
  801. "Content-Type": "application/json"
  802. },
  803. data: params
  804. }).then(res => {
  805. if (res.data.result === 1) {
  806. this.$message({
  807. message: res.data.desc,
  808. type: "error"
  809. });
  810. } else {
  811. this.$message({
  812. message: "成功",
  813. type: "success"
  814. });
  815. this.getlist('');
  816. }
  817. });
  818. },
  819. getlist(v) {
  820. // let params = {
  821. // advType: this.infotype,
  822. // fileName: this.fileNameSearch,
  823. // isDesc: this.isDesc,
  824. // createTimeFrom: this.createTimeFrom,
  825. // createTimeTo: this.createTimeTo
  826. // };
  827. // if (this.infotype == "08") {
  828. // params.advType = "";
  829. // }
  830. this.pageloading = true;
  831. this.$http({
  832. url: "/market/CMkMagicBox/getCMkMagicBoxHomeList",
  833. method: "post",
  834. headers: {
  835. "Content-Type": "application/json"
  836. },
  837. data: {
  838. categoryId: v
  839. }
  840. }).then(res => {
  841. this.modInfoList = res.data.body;
  842. this.pageloading = false
  843. // this.total = res.data.totalRecord;
  844. // this.imgList = [];
  845. // this.imgListold = res.data.data;
  846. // res.data.data.forEach(item => {
  847. // item.checked = false;
  848. // this.imgList.push(item)
  849. // })
  850. });
  851. },
  852. getModlist() {
  853. this.$http({
  854. url: "/market/mkMagicBoxCategory/queryList",
  855. method: "post",
  856. headers: {
  857. "Content-Type": "application/json"
  858. },
  859. data: {}
  860. }).then(res => {
  861. this.modNameList = res.data;
  862. });
  863. },
  864. // 分页
  865. // currchange(v) {
  866. // this.pageSize = v;
  867. // this.getlist(this.pageSize);
  868. // },
  869. // gettype() {
  870. // this.$http({
  871. // url: "/sysmgr/cfgDataDicts/queryMap",
  872. // method: "post",
  873. // headers: {
  874. // "Content-Type": "application/json"
  875. // },
  876. // data: {
  877. // dictCodePks: "materType"
  878. // }
  879. // }).then(res => {
  880. // this.typeList = res.data.body.materType;
  881. // this.infotype = this.$route.query.type;
  882. // this.changeType(this.infotype);
  883. // });
  884. // },
  885. //切换状态
  886. mstatuschange() {
  887. this.mstatus = !this.mstatus;
  888. this.checkList = [];
  889. this.imgList = [];
  890. for (let i = 0; i < this.imgListold.length; i++) {
  891. let item = this.imgListold[i];
  892. item.checked = false;
  893. this.imgList.push(item);
  894. }
  895. },
  896. //点击图片
  897. checkimg(v, i) {
  898. if (this.mstatus) {
  899. this.imgList[i].checked = !this.imgList[i].checked;
  900. this.checkAdd(v);
  901. return;
  902. }
  903. // this.bigImgs = true;
  904. // this.checksrc = v.fileBase64;
  905. this.$http({
  906. url:
  907. "/market/cadvMaterial/previewAdvMaterial?compressFileId=" +
  908. v.fileId,
  909. method: "post",
  910. responseType: "blob",
  911. headers: {
  912. "Content-Type": "application/json"
  913. },
  914. data: {}
  915. }).then(res => {
  916. let _this = this;
  917. if (res && res.data && res.data.size) {
  918. const dataInfo = res.data;
  919. let reader = new window.FileReader();
  920. reader.readAsArrayBuffer(dataInfo);
  921. reader.onload = function(e) {
  922. const result = e.target.result;
  923. const contentType = dataInfo.type;
  924. const blob = new Blob([result], {
  925. type: contentType
  926. });
  927. const url = window.URL.createObjectURL(blob);
  928. _this.bigImgs = true;
  929. _this.checksrc = url;
  930. };
  931. }
  932. });
  933. },
  934. //选中图片
  935. checkAdd(v) {
  936. let s = true;
  937. for (let i = 0; i < this.checkList.length; i++) {
  938. if (this.checkList[i].id == v.id) {
  939. s = false;
  940. this.checkList.splice(i, 1);
  941. return;
  942. }
  943. }
  944. if (s) {
  945. this.checkList.push(v);
  946. }
  947. },
  948. getUser() {
  949. this.userInfo = JSON.parse(window.sessionStorage.userInfo);
  950. },
  951. toMessage(cid){
  952. this.messTyp=0;
  953. this.centerDialogVisible=true;
  954. this.messTit = "是否确定删除";
  955. this.cId=cid;
  956. },
  957. closeMessage(v){
  958. this.centerDialogVisible = false;
  959. if(this.messTyp===0){
  960. if (v === 1) {
  961. this.$http({
  962. url: "/market/CMkMagicBox/delMkMagicBoxCategory ",
  963. method: "post",
  964. headers: {
  965. "Content-Type": "application/json"
  966. },
  967. data: { id: this.cId }
  968. }).then(res => {
  969. if (res.data.result === 0) {
  970. this.$message({
  971. message: "成功",
  972. type: "success"
  973. });
  974. this.getlist('');
  975. location.reload();
  976. } else {
  977. this.$message({
  978. message: res.data.desc,
  979. type: "error"
  980. });
  981. }
  982. });
  983. }
  984. }else{
  985. if (v === 1) {
  986. this.$http({
  987. url: "/market/CMkMagicBox/delMkMagicBoxTop",
  988. method: "post",
  989. headers: {
  990. "Content-Type": "application/json"
  991. },
  992. data: this.idList
  993. }).then(res => {
  994. if (res.data.result === 0) {
  995. this.$message({
  996. message: "成功",
  997. type: "success"
  998. });
  999. this.getlist('');
  1000. } else {
  1001. this.$message({
  1002. message: res.data.desc,
  1003. type: "error"
  1004. });
  1005. }
  1006. });
  1007. }
  1008. }
  1009. },
  1010. toMessage2(imgItem){
  1011. this.messTyp=1;
  1012. this.centerDialogVisible=true;
  1013. this.messTit = "是否确定删除";
  1014. this.idList = [
  1015. {
  1016. id: imgItem.id
  1017. }
  1018. ];
  1019. }
  1020. },
  1021. mounted() {
  1022. // this.gettype();
  1023. this.getUser();
  1024. this.getlist("");
  1025. this.getModlist();
  1026. for (var i = 0; i < this.menus.length; i++) {
  1027. if (this.menus[i].jspUrl == "/CMkMagicBoxTop") {
  1028. this.isFuncBtnShow = true;
  1029. break;
  1030. }
  1031. }
  1032. },
  1033. created() {
  1034. }
  1035. };
  1036. </script>
  1037. <style scoped lang="scss">
  1038. .mRight10{
  1039. margin-right: 10px;
  1040. }
  1041. .container-box {
  1042. h2 {
  1043. margin-bottom: 20px;
  1044. }
  1045. .adv-type {
  1046. display: flex;
  1047. justify-content: space-between;
  1048. align-items: center;
  1049. .file-name-search {
  1050. width: 30%;
  1051. }
  1052. span {
  1053. display: inline-block;
  1054. }
  1055. }
  1056. .img-box {
  1057. height: 90%;
  1058. .boximg {
  1059. height: 90%;
  1060. overflow-y: auto;
  1061. // justify-content: space-between;
  1062. margin-top: 20px;
  1063. .imgMod {
  1064. // height: 48%;
  1065. display: flex;
  1066. flex-direction: column;
  1067. justify-content: space-between;
  1068. .imgModTitle {
  1069. font-weight: bold;
  1070. font-size: 22px;
  1071. margin-bottom: 20px;
  1072. display: flex;
  1073. justify-content: space-between;
  1074. align-items: center;
  1075. }
  1076. .modBtnBox {
  1077. margin-right: 2%;
  1078. }
  1079. .imgModBox {
  1080. display: flex;
  1081. flex-wrap: wrap;
  1082. flex: 1;
  1083. .img-list {
  1084. display: inline-block;
  1085. width: 18%;
  1086. margin-right: 2%;
  1087. margin-bottom: 20px;
  1088. overflow: hidden;
  1089. // border: 1px solid #ddd;
  1090. border-radius: 3px;
  1091. background: #fff;
  1092. position: relative;
  1093. // height: 50%;
  1094. .img-content {
  1095. // border: 1px solid #ddd;
  1096. display: flex;
  1097. align-items: center;
  1098. width: 100%;
  1099. // height: 90%;
  1100. height: 20vh;
  1101. text-align: center;
  1102. position: relative;
  1103. img {
  1104. // width: 100%;
  1105. display: block;
  1106. max-width: 100%;
  1107. max-height: 100%;
  1108. // position: absolute;
  1109. // top: 0;
  1110. // bottom: 0;
  1111. margin: auto;
  1112. // height: 100%;
  1113. }
  1114. .func-box {
  1115. display: none;
  1116. width: 100%;
  1117. height: 100%;
  1118. position: absolute;
  1119. top: 0;
  1120. left: 0;
  1121. background: rgba(0, 0, 0, 0.5);
  1122. .func-inner-box {
  1123. display: flex;
  1124. width: 60%;
  1125. margin: 0 auto;
  1126. align-items: center;
  1127. justify-content: space-between;
  1128. // margin-top: 50%;
  1129. // transform: translateY(-50%);
  1130. .modify-img-box {
  1131. width: 50px;
  1132. height: 50px;
  1133. display: flex;
  1134. align-items: center;
  1135. justify-content: center;
  1136. background: #0b82ff;
  1137. border-radius: 50%;
  1138. cursor: pointer;
  1139. i {
  1140. color: #fff;
  1141. font-size: 22px;
  1142. }
  1143. }
  1144. .del-img-box {
  1145. width: 50px;
  1146. height: 50px;
  1147. display: flex;
  1148. align-items: center;
  1149. justify-content: center;
  1150. background: #0b82ff;
  1151. border-radius: 50%;
  1152. cursor: pointer;
  1153. i {
  1154. color: #fff;
  1155. font-size: 22px;
  1156. }
  1157. }
  1158. }
  1159. }
  1160. .el-checkbox {
  1161. position: absolute;
  1162. top: 0;
  1163. right: 0;
  1164. display: inline-block;
  1165. }
  1166. span {
  1167. }
  1168. }
  1169. .img-content:hover .func-box {
  1170. display: flex;
  1171. }
  1172. .file-name {
  1173. margin-top: 5px;
  1174. border: none;
  1175. outline: none;
  1176. width: 100%;
  1177. white-space: wrap;
  1178. text-overflow: ellipsis;
  1179. overflow: hidden;
  1180. text-align: center;
  1181. }
  1182. }
  1183. }
  1184. }
  1185. }
  1186. }
  1187. .pageBox {
  1188. text-align: right;
  1189. margin-top: 10px;
  1190. }
  1191. }
  1192. .bigimgcheck {
  1193. position: absolute;
  1194. top: 0;
  1195. left: 0;
  1196. width: 100vw;
  1197. height: 100vh;
  1198. z-index: 10000;
  1199. background: rgba(0, 0, 0, 0.6);
  1200. img {
  1201. position: absolute;
  1202. top: 0;
  1203. left: 0;
  1204. bottom: 0;
  1205. right: 0;
  1206. margin: auto;
  1207. max-width: 90vw;
  1208. }
  1209. .close {
  1210. position: absolute;
  1211. top: 40px;
  1212. right: 40px;
  1213. font-size: 28px;
  1214. color: #fff;
  1215. background: rgba(0, 0, 0, 0.5);
  1216. border-radius: 50%;
  1217. padding: 5px;
  1218. cursor: pointer;
  1219. }
  1220. }
  1221. .search-list-box {
  1222. display: flex;
  1223. flex-wrap: wrap;
  1224. max-width: 50%;
  1225. .search-box {
  1226. width: 30%;
  1227. margin-right: 10px;
  1228. margin-bottom: 10px;
  1229. .search-inner-box {
  1230. width: 100%;
  1231. }
  1232. }
  1233. .search-box1 {
  1234. width: 80%;
  1235. }
  1236. }
  1237. .multiUpload::v-deep .el-form-item__content{
  1238. display: flex !important;
  1239. .multiUploadLabel{
  1240. margin: 0 15px;
  1241. }
  1242. .multiUploadLabelerr{
  1243. margin: 0 12px;
  1244. color: rgb(214, 99, 99);
  1245. }
  1246. }
  1247. .myfooter{
  1248. display: flex;
  1249. flex-direction: row-reverse;
  1250. }
  1251. </style>