tab1_edit.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. <!-- -->
  2. <template>
  3. <div class="template">
  4. <div class="top">
  5. <div class="location">数据管理 | 项目资料 | <span>编辑</span></div>
  6. </div>
  7. <div class="conten">
  8. <div class="search">
  9. <div class="txt">{{ titleName }}</div>
  10. <ul>
  11. <li
  12. v-for="(item, index) in topTab"
  13. :key="index"
  14. :class="{ active: topTabInd === index }"
  15. @click="tabCut(index)"
  16. >
  17. {{ item }}
  18. </li>
  19. </ul>
  20. </div>
  21. <!-- 项目详情 -->
  22. <div class="tab" v-show="topTabInd === 0">
  23. <div class="title">项目详情</div>
  24. <div class="from">
  25. <el-form
  26. :model="ruleForm"
  27. :rules="rules"
  28. ref="ruleForm"
  29. label-width="100px"
  30. class="demo-ruleForm"
  31. >
  32. <el-form-item label="项目名称:" prop="name">
  33. <el-input
  34. maxlength="32"
  35. show-word-limit
  36. v-model="ruleForm.name"
  37. placeholder="请输入项目名称"
  38. ></el-input>
  39. </el-form-item>
  40. <el-form-item label="项目时间:">
  41. <el-input
  42. maxlength="32"
  43. show-word-limit
  44. v-model="ruleForm.age"
  45. placeholder="请输入项目时间"
  46. ></el-input>
  47. </el-form-item>
  48. <el-form-item label="项目分类:">
  49. <el-select v-model="ruleForm.typeId">
  50. <el-option
  51. v-for="item in projectType"
  52. :key="item.id"
  53. :label="item.name"
  54. :value="item.id"
  55. ></el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item label="展示形式:">
  59. <el-select v-model="ruleForm.application">
  60. <el-option label="网页端" value="web"></el-option>
  61. <el-option label="移动端" value="app"></el-option>
  62. <el-option
  63. label="网页端 + 移动端"
  64. value="webAndApp"
  65. ></el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item label="应用技术:">
  69. <el-select v-model="ruleForm.technology">
  70. <el-option label="实景拍摄" value="live"></el-option>
  71. <el-option label="虚拟建模" value="virtual"></el-option>
  72. <el-option label="四维看看" value="4dkk"></el-option>
  73. <el-option label="物体建模" value="model"></el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item label="保密级别:">
  77. <el-select v-model="ruleForm.level">
  78. <el-option label="一般--所有人可查阅" :value="1"></el-option>
  79. <el-option
  80. label="秘密--查阅人为公司内部所有员工,经过允许可对外分享"
  81. :value="2"
  82. ></el-option>
  83. <el-option
  84. label="机密--查阅人为管理员、项目负责人、获得允许的员工"
  85. :value="3"
  86. ></el-option>
  87. <el-option
  88. label="绝密--查阅人仅为管理员、项目负责人"
  89. :value="4"
  90. ></el-option>
  91. </el-select>
  92. </el-form-item>
  93. <el-form-item label="项目合作方:">
  94. <el-input
  95. maxlength="32"
  96. show-word-limit
  97. v-model="ruleForm.cooperation"
  98. placeholder="请输入项目合作方"
  99. ></el-input>
  100. </el-form-item>
  101. </el-form>
  102. </div>
  103. </div>
  104. <!-- 项目网址 -->
  105. <div class="tab" v-show="topTabInd === 1">
  106. <div class="title">项目网址</div>
  107. <div class="row" v-for="(item, index) in tab1Arr" :key="index">
  108. <el-input
  109. maxlength="32"
  110. show-word-limit
  111. v-model="tab1Arr[index].name"
  112. placeholder="网址名称"
  113. style="width: 200px; margin-right: 20px"
  114. ></el-input>
  115. <el-input
  116. maxlength="128"
  117. show-word-limit
  118. v-model="tab1Arr[index].url"
  119. placeholder="URL网址链接"
  120. style="width: 500px"
  121. ></el-input>
  122. <i
  123. class="el-icon-circle-close"
  124. @click="tab1Del(index, item.id)"
  125. v-if="index !== 0"
  126. ></i>
  127. <div class="tab_btn" @click="tab1Add" v-else>+ 添加网址</div>
  128. </div>
  129. </div>
  130. <!-- 三维场景 -->
  131. <div class="tab" v-show="topTabInd === 2">
  132. <div class="title">三维场景</div>
  133. <div class="row" v-for="(item, index) in tab2Arr" :key="index">
  134. <el-input
  135. maxlength="32"
  136. show-word-limit
  137. v-model="tab2Arr[index].name"
  138. placeholder="网址名称"
  139. style="width: 200px; margin-right: 20px"
  140. ></el-input>
  141. <el-input
  142. maxlength="128"
  143. show-word-limit
  144. v-model="tab2Arr[index].url"
  145. placeholder="URL网址链接"
  146. style="width: 500px"
  147. ></el-input>
  148. <el-input
  149. maxlength="32"
  150. show-word-limit
  151. v-model="tab2Arr[index].remark"
  152. placeholder="场景标签"
  153. style="width: 200px; margin-left: 20px"
  154. ></el-input>
  155. <i
  156. class="el-icon-circle-close"
  157. @click="tab2Del(index, item.id)"
  158. v-if="index !== 0"
  159. ></i>
  160. <div class="tab_btn" @click="tab2Add" v-else>+ 添加网址</div>
  161. </div>
  162. </div>
  163. <!-- 资料文档 -->
  164. <div class="tab" v-show="topTabInd === 3">
  165. <div class="title" style="margin-bottom: 20px">资料文档</div>
  166. <el-upload
  167. class="upload-demo"
  168. drag
  169. :action="baseURL + '/cms/doc/upload'"
  170. :headers="{ token }"
  171. :before-upload="beforeFujian"
  172. :on-success="successFujian"
  173. :show-file-list="true"
  174. multiple
  175. >
  176. <i class="el-icon-upload"></i>
  177. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  178. <div class="el-upload__tip" slot="tip">
  179. <!-- 只能上传jpg/png文件,且不超过500kb -->
  180. </div>
  181. </el-upload>
  182. <!-- 上传成功后的数组数据 -->
  183. <div class="upFJSucc">
  184. <div v-for="(item, index) in fuJianArr" :key="index">
  185. <span>{{ item.name }}</span>
  186. <i class="el-icon-close" @click="delFJ(index, item.id)"></i>
  187. </div>
  188. </div>
  189. </div>
  190. <!-- 文物 -->
  191. <div class="tab" v-show="topTabInd === 4">
  192. <div class="title">文物</div>
  193. <div class="imgBox">
  194. <div
  195. v-for="(item, index) in saveAntiqueArr"
  196. :key="index"
  197. @mouseenter="moveShowIdn = index"
  198. @mouseleave="moveShowIdn = null"
  199. >
  200. <img :src="baseURL + item.thumb" alt="" :onerror="defaultImg" />{{
  201. item.name
  202. }}
  203. <!-- 鼠标移上去显示的盒子 -->
  204. <div class="moveShow" v-show="moveShowIdn === index">
  205. <i class="el-icon-edit" @click="outEditAntique(item.id)"></i>
  206. <i
  207. class="el-icon-delete"
  208. @click="outDelAntique(index, item.id)"
  209. ></i>
  210. </div>
  211. </div>
  212. <!-- 点击文物+号新增文物 -->
  213. <div class="uploaImg" @click="addAntique">+</div>
  214. </div>
  215. </div>
  216. </div>
  217. <!-- 底部按钮 -->
  218. <div class="button_btn">
  219. <div @click="$router.go(-1)">返 回</div>
  220. <div class="edit" @click="outBtnOk(false)">保 存</div>
  221. </div>
  222. <!-- 点击 文物 的+号出现弹出层 -->
  223. <el-dialog
  224. :title="addForm.id ? '编辑文物' : '添加文物'"
  225. :visible.sync="addIsShow"
  226. @close="addBtnX()"
  227. >
  228. <el-form
  229. :model="addForm"
  230. :rules="addRules"
  231. ref="addForm"
  232. label-width="100px"
  233. class="demo-ruleForm"
  234. >
  235. <el-form-item label="名称:" prop="name">
  236. <el-input
  237. maxlength="50"
  238. show-word-limit
  239. v-model="addForm.name"
  240. placeholder="请输入名称"
  241. style="width: 500px"
  242. ></el-input>
  243. </el-form-item>
  244. <el-form-item label="链接:" prop="url">
  245. <el-input
  246. maxlength="128"
  247. show-word-limit
  248. style="width: 500px"
  249. v-model="addForm.url"
  250. placeholder="请输入网址链接"
  251. ></el-input>
  252. </el-form-item>
  253. <el-form-item label="文物类别:">
  254. <el-select v-model="addForm.goodsTypeId">
  255. <el-option
  256. v-for="item in antiqueArr"
  257. :key="item.id"
  258. :label="item.name"
  259. :value="item.id"
  260. ></el-option>
  261. </el-select>
  262. </el-form-item>
  263. <el-form-item label="文物标签:">
  264. <el-input
  265. maxlength="50"
  266. show-word-limit
  267. v-model="addForm.remark"
  268. placeholder="请输入文物标签"
  269. style="width: 500px"
  270. ></el-input>
  271. </el-form-item>
  272. <el-form-item label="文物图片:" class="myImgBox">
  273. <div class="upImgBox">
  274. <div
  275. class="imgdiv"
  276. :class="{ active: fengmianInd === index }"
  277. v-for="(item, index) in imgList"
  278. :key="index"
  279. @mouseenter="imgIconInd = index"
  280. @mouseleave="imgIconInd = null"
  281. >
  282. <img
  283. style="width: 100%; height: 100%"
  284. :src="baseURL + item.thumb"
  285. :onerror="defaultImg"
  286. />
  287. <div class="imgIcon" v-show="index === imgIconInd">
  288. <i class="el-icon-zoom-in" @click="lookImg(item.thumb)"></i>
  289. <a :href="baseURL + item.thumb" target="_blank" download
  290. ><i class="el-icon-download"></i
  291. ></a>
  292. <i class="el-icon-delete" @click="delImg(index)"></i>
  293. <span
  294. @click="modelSetIndex(item.id, index, item.thumb)"
  295. v-if="fengmianInd !== index"
  296. >设置封面</span
  297. >
  298. </div>
  299. </div>
  300. <el-upload
  301. drag
  302. class="avatar-uploader"
  303. :action="baseURL + '/cms/goods/upload'"
  304. :headers="{ token }"
  305. :show-file-list="false"
  306. :before-upload="beforethumbUpload"
  307. :on-success="upload_thumb_success"
  308. >
  309. <div class="upImg">
  310. <i slot="default" class="el-icon-plus"></i>
  311. </div>
  312. </el-upload>
  313. </div>
  314. </el-form-item>
  315. <span style="margin-left: 100px"
  316. >支持png / jpg / gif / jpeg的图片格式,最大支持20M。</span
  317. >
  318. </el-form>
  319. <div slot="footer" class="dialog-footer">
  320. <el-button @click="addBtnX">取 消</el-button>
  321. <el-button type="primary" @click="addBtnOk">保 存</el-button>
  322. </div>
  323. </el-dialog>
  324. <!-- 点击查看图片 -->
  325. <div class="lookImg" v-if="dialogImageIshow">
  326. <img :src="baseURL + dialogImageUrl" alt="" :onerror="defaultImg" />
  327. <div class="imgBtnX" @click="dialogImageIshow = false">关 闭</div>
  328. </div>
  329. </div>
  330. </template>
  331. <script>
  332. import axios from '@/utils/request'
  333. import {
  334. getProjectType,
  335. getDetail,
  336. projectEdit1,
  337. editScene,
  338. editDoc,
  339. getAntiqueById,
  340. getGoodsType,
  341. modelSetIndex,
  342. modelSave,
  343. editGoods
  344. } from '@/apis/tab1'
  345. export default {
  346. name: 'tab1_edit',
  347. components: {},
  348. data () {
  349. // 这里存放数据
  350. return {
  351. titleName: '', // 标题名字
  352. topTabInd: 0,
  353. topTab: ['项目详情', '项目网址', '三维场景', '资料文档', '文物'],
  354. baseURL: '',
  355. token: '',
  356. ruleForm: {
  357. name: '',
  358. age: '',
  359. typeId: '',
  360. application: '',
  361. technology: '',
  362. level: '',
  363. cooperation: ''
  364. },
  365. // 项目分类数组
  366. projectType: [],
  367. rules: {
  368. name: { required: true, message: '请输入项目名称', trigger: 'blur' }
  369. },
  370. // 项目网址数据
  371. tab1Arr: [{ name: '', url: '' }],
  372. tab1ArrDel: [],
  373. // 三维场景数据
  374. tab2Arr: [{ name: '', url: '' }],
  375. tab2ArrDel: [],
  376. // 资料文档数据
  377. fuJianArr: [],
  378. fuJianArrDel: [],
  379. // 文物数据
  380. saveAntiqueArrDel: [],
  381. saveAntiqueArr: [],
  382. moveShowIdn: null,
  383. addIsShow: false,
  384. // 文物数据---弹窗
  385. antiqueArr: [],
  386. fengmianInd: 0,
  387. imgIconInd: null,
  388. imgList: [],
  389. dialogImageIshow: false,
  390. addForm: {
  391. fileIds: '', // 图片id, 多个以逗号隔开
  392. name: '', // 名称
  393. url: '', // 链接
  394. goodsTypeId: null, // 文物类型id
  395. // projectId: '', // 项目id
  396. remark: '', // 文物标签
  397. thumb: '' // 封面
  398. },
  399. addRules: {
  400. name: [
  401. { required: true, message: '不能为空', trigger: 'blur' },
  402. { max: 50, message: '不能超过50个字', trigger: 'blur' }
  403. ],
  404. url: { required: true, message: '不能为空', trigger: 'blur' }
  405. },
  406. // 计数监听数据有没有改变
  407. cuontChange1: 0,
  408. cuontChange2: 0,
  409. cuontChange3: 0,
  410. cuontChange4: 0,
  411. cuontChange5: 0
  412. }
  413. },
  414. // 监听属性 类似于data概念
  415. computed: {},
  416. // 监控data中的数据变化
  417. watch: {
  418. ruleForm: {
  419. handler (newv) {
  420. this.cuontChange1++
  421. },
  422. deep: true
  423. },
  424. tab1Arr: {
  425. handler (newv) {
  426. this.cuontChange2++
  427. },
  428. deep: true
  429. },
  430. tab2Arr: {
  431. handler (newv) {
  432. this.cuontChange3++
  433. },
  434. deep: true
  435. },
  436. fuJianArr: {
  437. handler (newv) {
  438. this.cuontChange4++
  439. },
  440. deep: true
  441. },
  442. saveAntiqueArr: {
  443. handler (newv) {
  444. this.cuontChange5++
  445. },
  446. deep: true
  447. }
  448. },
  449. // 方法集合
  450. methods: {
  451. // ----------------文物弹窗里面---------------
  452. beforethumbUpload (file) {
  453. // console.log('上传文件前校验', file)
  454. // 限制图片大小和格式
  455. const sizeOk = file.size / 1024 / 1024 < 20
  456. const typeOk =
  457. file.type === 'image/png' ||
  458. file.type === 'image/jpeg' ||
  459. file.type === 'image/gif'
  460. return new Promise((resolve, reject) => {
  461. if (!typeOk) {
  462. this.$message.error('照片格式有误!')
  463. reject(file)
  464. } else if (!sizeOk) {
  465. this.$message.error('照片大小超过20M!')
  466. reject(file)
  467. } else if (file.name.length > 32) {
  468. this.$message.error('照片名字不能超过32个字')
  469. reject(file)
  470. } else {
  471. resolve(file)
  472. }
  473. })
  474. },
  475. async upload_thumb_success (data) {
  476. this.$message.success('上传成功')
  477. // console.log('上传文件成功', data)
  478. this.imgList.push({
  479. thumb: data.data.filePath,
  480. name: data.data.fileName,
  481. id: data.data.fileId
  482. })
  483. // 把第一张的url设置为封面---如果是新增
  484. // if (!this.addForm.id || this.imgList.length === 1) this.addForm.thumb = this.imgList[0].url
  485. if (this.imgList.length === 1) {
  486. await modelSetIndex(data.data.fileId)
  487. this.fengmianInd = 0
  488. this.addForm.thumb = this.imgList[0].thumb
  489. }
  490. // this.loading = false
  491. // this.ruleForm.thumb = data.data.filePath
  492. },
  493. delImg (index) {
  494. // 点击删除
  495. this.$confirm('确定删除吗?', '提示', {
  496. confirmButtonText: '确定',
  497. cancelButtonText: '取消',
  498. type: 'warning'
  499. })
  500. .then(() => {
  501. this.imgList.splice(index, 1)
  502. if (index === this.fengmianInd) {
  503. // 删除的是封面
  504. this.fengmianInd = null
  505. this.addForm.thumb = ''
  506. }
  507. this.$message.success('删除成功!')
  508. })
  509. .catch(() => {
  510. this.$message.info('已取消删除')
  511. })
  512. },
  513. // 点击放大镜,查看图片
  514. lookImg (url) {
  515. this.dialogImageUrl = url
  516. this.dialogImageIshow = true
  517. },
  518. // 点击设置为封面
  519. async modelSetIndex (id, index, url) {
  520. const res = await modelSetIndex(id)
  521. if (res.code === 0) {
  522. this.fengmianInd = index
  523. this.$message.success('设置封面成功')
  524. this.addForm.thumb = url
  525. }
  526. },
  527. // 点击弹窗里面的保存
  528. async addBtnOk () {
  529. if (this.addForm.name.trim() === '') {
  530. return this.$message.warning('文物名称不能为空')
  531. }
  532. if (this.addForm.url.trim() === '') {
  533. return this.$message.warning('文物链接不能为空')
  534. }
  535. const temp = []
  536. this.imgList.forEach((v) => {
  537. temp.push(v.id)
  538. })
  539. this.addForm.fileIds = temp.join(',')
  540. // console.log(999, this.addForm)
  541. const res = await modelSave(this.addForm)
  542. if (res.code === 0) {
  543. if (!this.addForm.id) {
  544. // 新增的push进去
  545. this.saveAntiqueArr.push({
  546. id: res.data.id,
  547. name: res.data.name,
  548. thumb: res.data.thumb
  549. })
  550. } else {
  551. // 修改的改变之前的数组
  552. this.saveAntiqueArr.forEach((v) => {
  553. if (v.id === this.addForm.id) {
  554. v.name = res.data.name
  555. v.thumb = res.data.thumb
  556. }
  557. })
  558. }
  559. this.$message.success('保存成功')
  560. this.addBtnX()
  561. }
  562. // console.log(999, res)
  563. },
  564. // 点击弹窗里面的取消
  565. addBtnX () {
  566. // 清空情况表单校验
  567. this.$refs.addForm.resetFields()
  568. this.addForm = {
  569. fileIds: '', // 图片id, 多个以逗号隔开
  570. name: '', // 名称
  571. url: '', // 链接
  572. goodsTypeId: null, // 文物类型id
  573. // projectId: '', // 项目id
  574. thumb: '' // 封面
  575. }
  576. this.imgList = []
  577. this.addIsShow = false
  578. },
  579. // -------------点击外层文物-------------------
  580. // 点击文物+号新增文物
  581. async addAntique () {
  582. this.addIsShow = true
  583. // 把封面默认变成第一个
  584. this.fengmianInd = 0
  585. },
  586. // 编辑
  587. async outEditAntique (id) {
  588. const res = await getAntiqueById(id)
  589. // console.log(999, res)
  590. this.addForm = res.data.entity
  591. res.data.file.forEach((v, i) => {
  592. this.imgList.push({
  593. thumb: v.filePath,
  594. name: v.name,
  595. id: v.id
  596. })
  597. // index为1的是首页图片
  598. if (v.isIndex === 1) this.fengmianInd = i
  599. })
  600. this.addIsShow = true
  601. },
  602. // 删除
  603. outDelAntique (index, id) {
  604. this.$confirm('确定删除吗?', '提示', {
  605. confirmButtonText: '确定',
  606. cancelButtonText: '取消',
  607. type: 'warning'
  608. })
  609. .then(() => {
  610. this.saveAntiqueArr.splice(index, 1)
  611. this.saveAntiqueArrDel.push(id)
  612. this.$message.success('删除成功!')
  613. })
  614. .catch(() => {
  615. this.$message.info('已取消删除')
  616. })
  617. },
  618. // --------------附件--------------
  619. beforeFujian (file) {
  620. return new Promise((resolve, reject) => {
  621. if (file.name.length > 32) {
  622. this.$message.error('附件名字不能超过32个字')
  623. reject(file)
  624. } else {
  625. resolve(file)
  626. }
  627. })
  628. },
  629. successFujian (file) {
  630. console.log('上传附件成功', file)
  631. if (file.code === 0) {
  632. this.fuJianArr.push({ name: file.data.name, id: file.data.id })
  633. this.$message.success('上传成功')
  634. } else if (file.code === -1) {
  635. this.$message.warning('上传失败,不支持的文件格式')
  636. }
  637. },
  638. // 删除附件
  639. delFJ (index, id) {
  640. // 点击删除
  641. this.$confirm('确定删除吗?', '提示', {
  642. confirmButtonText: '确定',
  643. cancelButtonText: '取消',
  644. type: 'warning'
  645. })
  646. .then(() => {
  647. this.fuJianArr.splice(index, 1)
  648. this.fuJianArrDel.push(id)
  649. this.$message.success('删除成功!')
  650. })
  651. .catch(() => {
  652. this.$message.info('已取消删除')
  653. })
  654. },
  655. // 项目网址
  656. tab1Add () {
  657. if (
  658. this.tab1Arr[this.tab1Arr.length - 1].name.trim() === '' ||
  659. this.tab1Arr[this.tab1Arr.length - 1].url.trim() === ''
  660. ) {
  661. return this.$message.warning('网址名称或链接不能为空')
  662. }
  663. if (this.tab1Arr[this.tab1Arr.length - 1].name.length > 32) {
  664. return this.$message.warning('网址名称不能超过32个字')
  665. }
  666. if (this.tab1Arr[this.tab1Arr.length - 1].url.length > 128) {
  667. return this.$message.warning('网址链接不能超过128个字')
  668. }
  669. this.tab1Arr.push({ name: '', url: '', id: null })
  670. },
  671. tab1Del (index, id) {
  672. this.$confirm('确定删除吗?', '提示', {
  673. confirmButtonText: '确定',
  674. cancelButtonText: '取消',
  675. type: 'warning'
  676. })
  677. .then(() => {
  678. this.tab1Arr.splice(index, 1)
  679. if (id) this.tab1ArrDel.push(id)
  680. this.$message.success('删除成功!')
  681. })
  682. .catch(() => {
  683. this.$message.info('已取消删除!')
  684. })
  685. },
  686. // 三维场景
  687. tab2Add () {
  688. if (
  689. this.tab2Arr[this.tab2Arr.length - 1].name.trim() === '' ||
  690. this.tab2Arr[this.tab2Arr.length - 1].url.trim() === ''
  691. ) {
  692. return this.$message.warning('网址名称或链接不能为空')
  693. }
  694. this.tab2Arr.push({ name: '', url: '', id: null, remark: '' })
  695. },
  696. tab2Del (index, id) {
  697. this.$confirm('确定删除吗?', '提示', {
  698. confirmButtonText: '确定',
  699. cancelButtonText: '取消',
  700. type: 'warning'
  701. })
  702. .then(() => {
  703. this.tab2Arr.splice(index, 1)
  704. if (id) this.tab2ArrDel.push(id)
  705. this.$message.success('删除成功!')
  706. })
  707. .catch(() => {
  708. this.$message.info('已取消删除!')
  709. })
  710. },
  711. // 点击保存
  712. async outBtnOk (index) {
  713. if (this.topTabInd === 0) {
  714. // console.log('项目详情保存')
  715. if (this.ruleForm.name.trim() === '') {
  716. return this.$message.warning('项目名称不能为空')
  717. }
  718. const res = await projectEdit1(this.ruleForm)
  719. if (res.code === 0) {
  720. this.$message.success('项目详情编辑成功')
  721. this.topTabInd = 1
  722. this.getDetail()
  723. } else this.$message.warning(res.msg)
  724. } else if (this.topTabInd === 1) {
  725. // console.log('项目网址保存')
  726. const temp = []
  727. let tempBoo = false
  728. let tempBoo1 = false
  729. this.tab1Arr.forEach((v, i) => {
  730. temp.push({
  731. id: v.id,
  732. name: v.name,
  733. projectId: Number(this.$route.query.id),
  734. type: 'website',
  735. url: v.url
  736. })
  737. if (i !== this.tab1Arr.length - 1) {
  738. if (v.name.trim() === '' || v.url.trim() === '') tempBoo = true
  739. }
  740. if (v.name.trim() === '' && v.url.trim() !== '') tempBoo1 = true
  741. if (v.name.trim() !== '' && v.url.trim() === '') tempBoo1 = true
  742. })
  743. if (tempBoo) return this.$message.warning('项目网址名称和链接不能为空')
  744. if (tempBoo1) {
  745. return this.$message.warning('项目网址名称或链接不能为空')
  746. }
  747. const res = await editScene({
  748. delIds: this.tab1ArrDel.join(','),
  749. dto: temp
  750. })
  751. if (res.code === 0) {
  752. this.$message.success('项目网址编辑成功')
  753. this.topTabInd = 2
  754. this.getDetail()
  755. } else this.$message.warning(res.msg)
  756. } else if (this.topTabInd === 2) {
  757. // console.log('三维场景保存')
  758. const temp = []
  759. let tempBoo2 = false
  760. let tempBoo3 = false
  761. this.tab2Arr.forEach((v, i) => {
  762. if (v.name !== '' && v.url !== '') {
  763. temp.push({
  764. id: v.id,
  765. name: v.name,
  766. projectId: Number(this.$route.query.id),
  767. type: 'scene',
  768. url: v.url,
  769. remark: v.remark
  770. })
  771. }
  772. if (i !== this.tab2Arr.length - 1) {
  773. if (v.name.trim() === '' || v.url.trim() === '') tempBoo2 = true
  774. }
  775. if (v.name.trim() === '' && v.url.trim() !== '') tempBoo3 = true
  776. if (v.name.trim() !== '' && v.url.trim() === '') tempBoo3 = true
  777. })
  778. if (tempBoo2) {
  779. return this.$message.warning('三维场景名称和链接不能为空')
  780. }
  781. if (tempBoo3) {
  782. return this.$message.warning('三维场景名称或链接不能为空')
  783. }
  784. const res = await editScene({
  785. delIds: this.tab2ArrDel.join(','),
  786. dto: temp
  787. })
  788. if (res.code === 0) {
  789. this.$message.success('三维场景编辑成功')
  790. this.topTabInd = 3
  791. this.getDetail()
  792. } else this.$message.warning(res.msg)
  793. } else if (this.topTabInd === 3) {
  794. // console.log('文档资料保存')
  795. const temp = []
  796. this.fuJianArr.forEach((v) => {
  797. temp.push(v.id)
  798. })
  799. const obj = {
  800. editIds: temp.join(','),
  801. projectId: Number(this.$route.query.id),
  802. removeIds: this.fuJianArrDel.join(',')
  803. }
  804. const res = await editDoc(obj)
  805. if (res.code === 0) {
  806. this.$message.success('资料文档编辑成功')
  807. this.topTabInd = 4
  808. this.getDetail()
  809. } else this.$message.warning(res.msg)
  810. } else if (this.topTabInd === 4) {
  811. // console.log('文物保存')
  812. const temp = []
  813. this.saveAntiqueArr.forEach((v) => {
  814. temp.push(v.id)
  815. })
  816. const obj = {
  817. editIds: temp.join(','),
  818. projectId: Number(this.$route.query.id),
  819. removeIds: this.saveAntiqueArrDel.join(',')
  820. }
  821. const res = await editGoods(obj)
  822. if (res.code === 0) {
  823. this.$message.success('文物编辑成功')
  824. // this.$router.push('/layout/tab1')
  825. } else this.$message.warning(res.msg)
  826. // console.log(999, res)
  827. }
  828. this.$nextTick(() => {
  829. setTimeout(() => {
  830. if (index !== false) this.topTabInd = index
  831. this.cuontChange1 =
  832. this.cuontChange2 =
  833. this.cuontChange3 =
  834. this.cuontChange4 =
  835. this.cuontChange5 =
  836. 1
  837. }, 300)
  838. })
  839. },
  840. // 封装获取详情方法
  841. async getDetail () {
  842. // 拿到路由跳转传过来的数据
  843. const res = await getDetail(this.$route.query.id)
  844. this.titleName = res.data.entity.name
  845. this.ruleForm = res.data.entity
  846. this.tab1Arr = res.data.website
  847. if (res.data.scene.length) this.tab2Arr = res.data.scene
  848. else this.tab2Arr = [{ name: '', url: '' }]
  849. this.fuJianArr = res.data.doc
  850. this.saveAntiqueArr = res.data.goods
  851. },
  852. // 上面的tab栏切换
  853. tabCut (index) {
  854. if (index === this.topTabInd) return
  855. // console.log(999, index)
  856. if (
  857. this.cuontChange1 > 1 ||
  858. this.cuontChange2 > 1 ||
  859. this.cuontChange3 > 1 ||
  860. this.cuontChange4 > 1 ||
  861. this.cuontChange5 > 1
  862. ) {
  863. this.$confirm('本次编辑未保存,是否 保存 并跳转页面', '提示', {
  864. confirmButtonText: '确定',
  865. cancelButtonText: '取消',
  866. type: 'warning'
  867. })
  868. .then(() => {
  869. this.outBtnOk(index)
  870. })
  871. .catch(() => {
  872. // this.$message.info('已取消!')
  873. this.topTabInd = index
  874. this.getDetail()
  875. setTimeout(() => {
  876. this.cuontChange1 =
  877. this.cuontChange2 =
  878. this.cuontChange3 =
  879. this.cuontChange4 =
  880. this.cuontChange5 =
  881. 1
  882. }, 300)
  883. })
  884. } else this.topTabInd = index
  885. // ---------------分割
  886. }
  887. },
  888. // 生命周期 - 创建完成(可以访问当前this实例)
  889. async created () {
  890. // 获取项目类型
  891. const res1 = await getProjectType()
  892. this.projectType = res1.data
  893. // 获取服务器前缀地址
  894. this.baseURL = axios.defaults.baseURL
  895. // 获取用户token
  896. this.token = localStorage.getItem('SWKK_token')
  897. this.getDetail()
  898. },
  899. // 生命周期 - 挂载完成(可以访问DOM元素)
  900. async mounted () {
  901. // 获取文物类别
  902. const res = await getGoodsType()
  903. this.antiqueArr = res.data
  904. this.antiqueArr.unshift({ id: '', name: '' })
  905. },
  906. beforeCreate () {}, // 生命周期 - 创建之前
  907. beforeMount () {}, // 生命周期 - 挂载之前
  908. beforeUpdate () {}, // 生命周期 - 更新之前
  909. updated () {}, // 生命周期 - 更新之后
  910. beforeDestroy () {}, // 生命周期 - 销毁之前
  911. destroyed () {}, // 生命周期 - 销毁完成
  912. activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
  913. }
  914. </script>
  915. <style lang='less' scoped>
  916. /deep/.el-upload-list__item .el-progress {
  917. top: 0;
  918. }
  919. /deep/.el-upload-list__item-name {
  920. display: none;
  921. }
  922. /deep/.el-upload-list__item-status-label {
  923. display: none !important;
  924. }
  925. /deep/.el-upload-list {
  926. width: 360px;
  927. }
  928. /deep/.el-select {
  929. width: 500px;
  930. }
  931. .template {
  932. .upImg {
  933. width: 135px;
  934. height: 135px;
  935. display: flex;
  936. justify-content: center;
  937. align-items: center;
  938. & > i {
  939. font-size: 50px;
  940. color: #ccc;
  941. }
  942. }
  943. .lookImg {
  944. padding-top: 15px;
  945. display: flex;
  946. justify-content: center;
  947. left: 0;
  948. top: 0;
  949. width: 100vw;
  950. height: 100vh;
  951. position: fixed;
  952. z-index: 9999;
  953. background-color: rgba(0, 0, 0, 0.7);
  954. img {
  955. max-width: 80vw;
  956. max-height: 80vh;
  957. }
  958. .imgBtnX {
  959. cursor: pointer;
  960. width: 100px;
  961. height: 30px;
  962. position: absolute;
  963. left: 50%;
  964. transform: translateX(-50%);
  965. bottom: 20px;
  966. background-color: #fff;
  967. border-radius: 8px;
  968. color: black;
  969. display: flex;
  970. justify-content: center;
  971. align-items: center;
  972. }
  973. }
  974. .myImgBox {
  975. /deep/.el-form-item__content {
  976. display: flex;
  977. flex-wrap: wrap;
  978. }
  979. /deep/.el-upload-dragger {
  980. width: 135px;
  981. height: 135px;
  982. border: 1px solid #ccc;
  983. }
  984. }
  985. .upImgBox {
  986. display: flex;
  987. flex-wrap: wrap;
  988. .active {
  989. border: 2px solid #dc3545;
  990. }
  991. }
  992. .imgdiv {
  993. position: relative;
  994. margin: 0 10px 10px 0;
  995. border: 1px solid #ccc;
  996. width: 135px;
  997. height: 135px;
  998. & > img {
  999. width: 100%;
  1000. height: 100%;
  1001. object-fit: contain;
  1002. }
  1003. .imgIcon {
  1004. justify-content: space-around;
  1005. align-items: center;
  1006. display: flex;
  1007. position: absolute;
  1008. width: 100%;
  1009. height: 100%;
  1010. left: 0;
  1011. top: 0;
  1012. background-color: rgba(0, 0, 0, 0.6);
  1013. i {
  1014. color: #fff;
  1015. font-size: 24px;
  1016. cursor: pointer;
  1017. }
  1018. a {
  1019. i {
  1020. margin-top: 10px;
  1021. }
  1022. }
  1023. i:hover {
  1024. color: #dc3545;
  1025. }
  1026. & > span {
  1027. cursor: pointer;
  1028. color: #fff;
  1029. position: absolute;
  1030. bottom: 0px;
  1031. left: 50%;
  1032. transform: translateX(-50%);
  1033. }
  1034. & > span:hover {
  1035. color: #dc3545;
  1036. }
  1037. }
  1038. }
  1039. position: relative;
  1040. padding: 0px 30px;
  1041. .top {
  1042. display: flex;
  1043. align-items: center;
  1044. height: 58px;
  1045. width: 100%;
  1046. .location {
  1047. font-size: 22px;
  1048. color: #999;
  1049. & > span {
  1050. color: black;
  1051. }
  1052. }
  1053. }
  1054. .conten {
  1055. width: 100%;
  1056. height: 720px;
  1057. .txt {
  1058. font-weight: 700;
  1059. height: 40px;
  1060. border-bottom: 1px solid #a3a2a9;
  1061. }
  1062. .search {
  1063. position: relative;
  1064. padding: 15px 20px 0;
  1065. border-radius: 5px;
  1066. box-shadow: 0px 0px 5px 0px;
  1067. height: 110px;
  1068. background-color: #d8dadc;
  1069. ul {
  1070. margin-top: 15px;
  1071. display: flex;
  1072. li {
  1073. padding-bottom: 5px;
  1074. cursor: pointer;
  1075. margin-right: 100px;
  1076. color: #666;
  1077. }
  1078. li:hover {
  1079. border-bottom: 2px solid #dc3545;
  1080. color: black;
  1081. }
  1082. .active {
  1083. border-bottom: 2px solid #dc3545;
  1084. color: black;
  1085. }
  1086. }
  1087. }
  1088. .tab {
  1089. padding: 15px 30px;
  1090. margin-top: 10px;
  1091. background-color: #fff;
  1092. height: 600px;
  1093. overflow-y: auto;
  1094. .title {
  1095. font-weight: 700;
  1096. padding-bottom: 8px;
  1097. font-size: 20px;
  1098. color: #c82333;
  1099. border-bottom: 1px solid #ccc;
  1100. }
  1101. .from {
  1102. margin-top: 22px;
  1103. width: 600px;
  1104. }
  1105. .tab_btn {
  1106. margin-left: 20px;
  1107. cursor: pointer;
  1108. color: #fff;
  1109. width: 130px;
  1110. height: 40px;
  1111. border-radius: 10px;
  1112. display: flex;
  1113. align-items: center;
  1114. justify-content: center;
  1115. background-color: #dc3545;
  1116. }
  1117. .row {
  1118. display: flex;
  1119. align-items: center;
  1120. margin: 15px 0 0;
  1121. & > div {
  1122. font-weight: 700;
  1123. }
  1124. a {
  1125. background-color: #e7e9eb;
  1126. padding: 5px 10px;
  1127. margin-right: 20px;
  1128. }
  1129. i {
  1130. margin-left: 20px;
  1131. cursor: pointer;
  1132. font-size: 24px;
  1133. }
  1134. }
  1135. .upFJSucc {
  1136. margin-top: 30px;
  1137. width: 360px;
  1138. & > div {
  1139. margin-top: 8px;
  1140. display: flex;
  1141. align-items: center;
  1142. justify-content: space-between;
  1143. i {
  1144. cursor: pointer;
  1145. &:hover {
  1146. color: #dc3545;
  1147. }
  1148. }
  1149. }
  1150. }
  1151. .imgBox {
  1152. display: flex;
  1153. flex-wrap: wrap;
  1154. & > div {
  1155. // cursor: pointer;
  1156. position: relative;
  1157. word-wrap: break-word;
  1158. text-align: center;
  1159. width: 120px;
  1160. margin: 20px 0 0 10px;
  1161. // border: 1px solid #ccc;
  1162. // box-shadow: 1px 1px 3px 0px;
  1163. .moveShow {
  1164. position: absolute;
  1165. left: 0;
  1166. top: 0;
  1167. width: 120px;
  1168. height: 120px;
  1169. background-color: rgba(0, 0, 0, 0.7);
  1170. display: flex;
  1171. justify-content: space-around;
  1172. align-items: center;
  1173. & > i {
  1174. cursor: pointer;
  1175. color: #fff;
  1176. font-size: 24px;
  1177. }
  1178. & > i:hover {
  1179. color: #dc3545;
  1180. }
  1181. }
  1182. }
  1183. img {
  1184. border: 1px solid #ccc;
  1185. box-shadow: 1px 1px 3px 0px;
  1186. padding: 5px;
  1187. width: 120px;
  1188. height: 120px;
  1189. display: block;
  1190. margin: 0 auto;
  1191. margin-bottom: 10px;
  1192. object-fit: contain;
  1193. }
  1194. .uploaImg {
  1195. width: 120px;
  1196. height: 120px;
  1197. cursor: pointer;
  1198. color: #ccc;
  1199. border: 1px solid #ccc;
  1200. font-size: 60px;
  1201. font-weight: 700;
  1202. display: flex;
  1203. align-items: center;
  1204. justify-content: center;
  1205. }
  1206. }
  1207. }
  1208. }
  1209. .button_btn {
  1210. display: flex;
  1211. justify-content: space-between;
  1212. align-items: center;
  1213. position: absolute;
  1214. left: 100px;
  1215. bottom: 30px;
  1216. width: 300px;
  1217. height: 40px;
  1218. div {
  1219. border-radius: 10px;
  1220. display: flex;
  1221. justify-content: center;
  1222. align-items: center;
  1223. width: 100px;
  1224. height: 40px;
  1225. background-color: #fff;
  1226. cursor: pointer;
  1227. }
  1228. .edit {
  1229. margin-left: 50px;
  1230. color: #fff !important;
  1231. background-color: #dc3545 !important;
  1232. }
  1233. }
  1234. }
  1235. </style>