index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <template>
  2. <div class="micro-create">
  3. <div class="micro-box-content" :style="{backgroundColor:setOther.bgColor}">
  4. <div class="design-page">
  5. <div class="design-page-content">
  6. <!-- 左侧所有装修组件 -->
  7. <div class="all-use-components" :class="{'border-left': !sidebarFold}">
  8. <!--所有可以选择的组件-->
  9. <allCanUseComponents
  10. :is-show-all-components="isShowAllComponents"
  11. :hide-these-components="hideTheseComponents"
  12. :show-these-components="showTheseComponents"
  13. @addComponent="addComponent"
  14. @retAllCanUseComponents="allCanUseComponents"
  15. />
  16. <!--end 所有可以选择的组件-->
  17. </div>
  18. <!-- 界面预览 -->
  19. <div id="scrollbar" class="design-editor">
  20. <div ref="designBox" class="design-box">
  21. <div ref="designPreview" class="design-preview">
  22. <div v-if="componentLists.length" ref="Preview" class="item-list">
  23. <!--头部-->
  24. <div
  25. v-for="(item,index) in configComponents"
  26. id="headBox"
  27. :key="index"
  28. class="preview-item"
  29. :index="index"
  30. @click.stop="clickComponent(item,index,1)"
  31. >
  32. <div
  33. :is="componentLists.find(x=>x.type === item.type) ? componentLists.find(x=>x.type === item.type).routerPath : ''"
  34. :current="index"
  35. :is-show-edit="currentEditConfigComponentsShow === index&&configComponentsShow"
  36. :index-key="item.type+'_'+index"
  37. :data-field="item.dataField || {}"
  38. :current-component="item"
  39. :is-check-my-self="item.isCheckMySelf"
  40. :is-start-check-field-rules="isStartCheckFieldRules"
  41. @myCheckResult="everyComponentsCheckResultFun"
  42. @componentsValueChance="componentsValueChanceFromConfig"
  43. @save="save"></div>
  44. </div>
  45. <!--组价-->
  46. <SlickList
  47. v-model="currentUseComponents"
  48. :use-drag-handle="true"
  49. axis="y"
  50. @input="sortInput"
  51. @sort-start="sortStart"
  52. @sort-move="sortMove"
  53. @sort-end="sortEnd"
  54. >
  55. <SlickItem
  56. v-for="(item,index) in currentUseComponents"
  57. :id="'previewItem_'+index"
  58. :key="index"
  59. :class="['preview-box',{isMoveIng:isMoveIng}]"
  60. :index="index"
  61. @click.stop="clickComponent(item,index)"
  62. >
  63. <div class="preview-item">
  64. <div
  65. :is="componentLists.find(x=>x.type === item.type) ? componentLists.find(x=>x.type === item.type).routerPath : ''"
  66. :current="index"
  67. :is-show-edit="currentEditComponent === index&&isShowEdit"
  68. :index-key="item.type+'_'+index"
  69. :data-field="item.dataField || {}"
  70. :current-component="item"
  71. :is-check-my-self="item.isCheckMySelf"
  72. :is-start-check-field-rules="isStartCheckFieldRules"
  73. @myCheckResult="everyComponentsCheckResultFun"
  74. @componentsValueChance="componentsValueChance"
  75. @save="save"></div>
  76. <!--边框、删除、添加-->
  77. <div
  78. :style="{borderColor:setOther.viewTheme,borderStyle:'solid'}"
  79. class="preview-item-border design-hide-class"
  80. :class="currentEditComponent === index ? 'show':''"
  81. >
  82. <div v-handle class="drag-box" :style="{cursor:setOther.dragCursor}"/>
  83. <el-popover
  84. :ref="'pop_'+index"
  85. placement="left"
  86. width="200"
  87. trigger="click"
  88. >
  89. <p style="word-break: break-word">{{$t('shopFeature.edit.deleteConfirm')}}</p>
  90. <div style="text-align: right; margin: 10px 0 0">
  91. <div
  92. class="default-btn"
  93. @click="popBtn(1, item,'pop_'+index,index)"
  94. >{{$t('shopFeature.edit.cancel')}}
  95. </div>
  96. <div
  97. class="default-btn primary-btn"
  98. @click="popBtn(2, item,'pop_'+index,index)"
  99. >{{$t('shopFeature.edit.confirm')}}
  100. </div>
  101. </div>
  102. <span
  103. v-show="!item.isHeader&&isShowClose"
  104. slot="reference"
  105. :style="{background:setOther.viewTheme}"
  106. class="close-item"
  107. >x</span>
  108. </el-popover>
  109. <span
  110. v-show="isShowPushAdd"
  111. :id="'appendTopBtn_'+index"
  112. :ref="'appendTopBtn_'+index"
  113. :style="{background:setOther.viewTheme}"
  114. class="circle-plus-top"
  115. @click.stop="appendComponents('top',index,'appendTopBtn_'+index,item)"
  116. >+</span>
  117. <span
  118. v-show="isShowPushAdd"
  119. :id="'appendBottomBtn_'+index"
  120. :ref="'appendBottomBtn_'+index"
  121. :style="{background:setOther.viewTheme}"
  122. class="circle-plus-bottom"
  123. @click.stop="appendComponents('bottom',index,'appendBottomBtn_'+index,item)"
  124. >+</span>
  125. <!--左边的小部件-->
  126. <div class="eVue-widget">
  127. <div class="widget-name">
  128. <span class="widget-arrow-out"/>
  129. <div class="component-name">{{ componentLists.find(x=>x.type === item.type) ?
  130. componentLists.find(x=>x.type === item.type).title : '' }} {{ index }}
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <!--边框、删除、添加-->
  136. </div>
  137. </SlickItem>
  138. </SlickList>
  139. <!--插入-->
  140. <div v-if="isShowEditorAllComponents" class="design-editor-item append-component-box">
  141. <div class="design-config-editor">
  142. <allCanUseComponents
  143. :hide-these-components="hideTheseComponents"
  144. @addComponent="addComponent"
  145. @retAllCanUseComponents="allCanUseComponents"
  146. />
  147. </div>
  148. </div>
  149. <!--插入-->
  150. </div>
  151. </div>
  152. </div>
  153. <!--右侧管理列表-->
  154. <div class="preview-wrap">
  155. <div
  156. class="preview-wrap-item"
  157. :style="setOther.componentOperation ? 'background-color:'+setOther.viewTheme+';color:#fff;' : ''"
  158. @click="setOther.componentOperation = true"
  159. >
  160. <i class="el-icon-coin"/>{{$t('shopFeature.edit.componentManagement')}}
  161. </div>
  162. </div>
  163. </div>
  164. <!-- 组件管理 -->
  165. <div v-if="setOther.componentOperation" class="design-editor-item">
  166. <div class="design-config-editor">
  167. <div class="design-editor-component-title">
  168. {{$t('shopFeature.edit.componentManagement')}}
  169. </div>
  170. <div class="components-list-edit">
  171. <p class="clear-current-component" :style="[{color:setOther.viewTheme}]">
  172. <span>组件排序</span>
  173. <span
  174. @click="currentUseComponents = []"
  175. >{{$t('shopFeature.edit.removeAll')}}</span>
  176. </p>
  177. <SlickList
  178. v-model="currentUseComponents"
  179. :use-drag-handle="true"
  180. axis="y"
  181. @input="componentsSortInput"
  182. helperClass="drag-class"
  183. >
  184. <SlickItem
  185. v-for="(item,index) in currentUseComponents"
  186. :key="index"
  187. class="components-list-edit-item"
  188. :index="index"
  189. >
  190. <div v-handle class="drag-box">
  191. {{ componentLists.find(x=>x.type === item.type) ?
  192. componentLists.find(x=>x.type === item.type).title : '' }} <em>{{ index }}</em>
  193. </div>
  194. <div class="drag-box-icon">
  195. <i :title="$i18n.t('shopFeature.edit.removeComponent')" class="el-icon-delete" @click="popBtn(2, item,'pop_'+index,index)"/>
  196. </div>
  197. </SlickItem>
  198. </SlickList>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <!--保存按钮-->
  204. <div class="save-data" :style="{width: sidebarFold ? 'calc(100% - 100px)' : 'calc(100% - 230px)'}">
  205. <div class="inner">
  206. <div
  207. v-if="isShowSaveBtn_1"
  208. :loading="isSaving"
  209. :disabled="isSaving"
  210. class="default-btn primary-btn"
  211. @click="save(1)"
  212. >
  213. {{ saveBtn_title_1 }}
  214. </div>
  215. <div
  216. v-if="isShowSaveBtn_2"
  217. :loading="isSaving2"
  218. :disabled="isSaving2"
  219. @click="save(2)"
  220. class="default-btn"
  221. plain>{{saveBtn_title_2}}
  222. </div>
  223. <div
  224. class="default-btn"
  225. @click="backToList"
  226. plain>{{$t('shopFeature.edit.back')}}
  227. </div>
  228. </div>
  229. </div>
  230. </div>
  231. <!--配置弹窗-->
  232. <!-- <right-panel>
  233. <div class="drawer-container">
  234. <div>
  235. <h3 class="drawer-title">系统配置</h3>
  236. <div class="drawer-item">
  237. <span>背景颜色</span>
  238. <el-color-picker v-model="setOther.bgColor"></el-color-picker>
  239. </div>
  240. <div class="drawer-item">
  241. <span>预览区主题</span>
  242. <el-color-picker v-model="setOther.viewTheme"></el-color-picker>
  243. </div>
  244. </div>
  245. </div>
  246. </right-panel> -->
  247. </div>
  248. </div>
  249. </template>
  250. <script>
  251. import i18n from '../../../../../../../src/i18n/i18n'
  252. import {SlickList, SlickItem, HandleDirective} from 'vue-slicksort'
  253. import allCanUseComponents from './components/all-can-use-components/index.vue'
  254. import RightPanel from '../RightPanel/index.vue'
  255. // mock 数据
  256. // import {detail} from '@/api/feature';
  257. /**
  258. * 作为组件时传入说明
  259. * props 解析看下文
  260. * currentConfigComponents 默认配置顶部项的组件 默认为config组件
  261. * currentUseComponents 正在预览区的组件 默认 []
  262. * */
  263. export default {
  264. name: 'micro-create',
  265. directives: {handle: HandleDirective},
  266. props: {
  267. isShowPushAdd: {// 是否显示插入的模式
  268. type: Boolean,
  269. default: true
  270. },
  271. isShowClose: {// 是否关闭的模式
  272. type: Boolean,
  273. default: true
  274. },
  275. hideTheseComponents: {// 隐藏这些组件 结构如:[{type: 'config',isHide:true}]
  276. type: Array,
  277. default: () => []
  278. },
  279. showTheseComponents: {// 显示这些组件 结构如:[{type: 'config',isHide:true}]
  280. type: Array,
  281. default: () => []
  282. },
  283. isShowAllComponents: {// 是否隐藏所有组件
  284. type: Boolean,
  285. default: true
  286. },
  287. saveBtn_title_1: { // 按钮1的文本
  288. type: String,
  289. default: i18n.t('shopFeature.edit.save')
  290. },
  291. saveBtn_title_2: { // 按钮2的文本
  292. type: String,
  293. default: i18n.t('shopFeature.edit.saveAndCon')
  294. },
  295. saveBtn_title_3: { // 按钮3的文本
  296. type: String,
  297. default: i18n.t('shopFeature.edit.moreOper')
  298. },
  299. isShowSaveBtn_1: {// 是否显示 上架 按扭
  300. type: Boolean,
  301. default: true
  302. },
  303. isShowSaveBtn_2: {// 是否显示 保存并继续 按扭
  304. type: Boolean,
  305. default: true
  306. },
  307. isShowSaveBtn_3: {// 是否显示 更多操作 按扭
  308. type: Boolean,
  309. default: true
  310. },
  311. // 是否需要返回最后保存的值,在当前页面被用作组件的时候可使用
  312. isNeedReturnSaveData: {
  313. type: Boolean,
  314. default: false
  315. },
  316. /** 配置顶部项的组件 */
  317. currentConfigComponents: {
  318. type: Array,
  319. default: () => [{type: 'config'}] // 配置项不能删除、排序
  320. },
  321. /** 其他的组件传过来只能使用的组件 */
  322. currentCanUseComponents: {
  323. type: Array,
  324. default: () => [] //
  325. },
  326. microId: { // 主要运用于其他的调用微页面组件获取详情使用,具体可参考:公告广告
  327. type: Number,
  328. default: null
  329. },
  330. microKeyWord: { // 微页面 主要运用于其他的调用微页面组件获取详情使用,具体可参考:微集合
  331. type: String,
  332. default: ''
  333. }
  334. },
  335. data () {
  336. return {
  337. isSaving: false, // 是否正在保存
  338. isSaving2: false,
  339. isCheckMySelf: false, // 在规则判断不通过改变通知子组件
  340. isStartCheckFieldRules: false, // 是否开始校验所有组件的规则
  341. isMoveIng: true, // 是否正在移动
  342. isDrag: false, // 是否拖动了位置
  343. appendPosition: {
  344. index: '',
  345. position: 'bottom', // 默认底部
  346. theRefs: null
  347. }, // 插入组件的位置
  348. isShowEditorAllComponents: false, // 是否显示插入组件区域,永远与isShowEdit相反
  349. isShowEdit: false, // 是否显示组件的编辑区
  350. componentLists: [], // 所有可用的组件
  351. configComponentsShow: true,
  352. /** 正在编辑的组件 */
  353. currentEditConfigComponentsShow: 0,
  354. /** 正在编辑的组件 */
  355. currentEditComponent: 0,
  356. currentUseComponents: [],
  357. renovationId: this.$route.query.renovationId || null,
  358. /** 配置顶部项的组件 */
  359. configComponents: [{type: 'config'}],
  360. // 所有每次校验的结果
  361. allCheckResult: [],
  362. saveType: 2, // 保存的类型=> 2保存 1上架 3更多操作
  363. scrollTopHeight: 0,
  364. // 设置
  365. setOther: {
  366. viewTheme: '#155BD4',
  367. bgColor: '#fff', // 背景
  368. dragCursor: 'all-scroll', // 显示的图标 all-scroll
  369. componentOperation: false// 是否操作组件
  370. },
  371. dontShowMessage: false
  372. }
  373. },
  374. watch: {
  375. microId (val) {
  376. if (val) {
  377. this.id = val
  378. this.getInfo()
  379. }
  380. },
  381. // 通过微页面关键字获取详情
  382. microKeyWord (val) {
  383. if (val) {
  384. this.id = null
  385. this.currentUseComponents = []
  386. if (val !== 'productCatalog') {
  387. this.microKeyWord = 'other'
  388. }
  389. this.getInfo()
  390. }
  391. },
  392. currentUseComponents (val) {
  393. this.$nextTick(() => {
  394. this.$emit('currentUseComponentsChange', val)
  395. })
  396. }
  397. },
  398. components: {
  399. allCanUseComponents,
  400. SlickList,
  401. SlickItem,
  402. RightPanel
  403. },
  404. computed: {
  405. sidebarFold () {
  406. return this.$store.state.common.sidebarFold
  407. }
  408. },
  409. mounted () {
  410. const renovationId = this.$route.query.renovationId
  411. if (renovationId) {
  412. this.renovationId = renovationId
  413. this.getInfo()
  414. } else {
  415. this.configComponents = JSON.parse(JSON.stringify(this.currentConfigComponents))
  416. }
  417. this.$nextTick(() => {
  418. this.$store.commit('common/updateSidebarFold', true)
  419. })
  420. },
  421. activated () {
  422. if (this.$route.query.renovationId && this.$route.query.renovationId !== this.renovationId) {
  423. this.renovationId = this.$route.query.renovationId
  424. this.getInfo()
  425. }
  426. },
  427. deactivated () {
  428. this.configComponents = []
  429. this.configComponents = JSON.parse(JSON.stringify(this.currentConfigComponents))
  430. },
  431. methods: {
  432. /** 关闭组件管理 */
  433. componentOperation () {
  434. this.setOther.componentOperation = false
  435. },
  436. /**
  437. * 获取所有可用的组件
  438. * */
  439. allCanUseComponents ($list) {
  440. if ($list) {
  441. this.componentLists = $list
  442. } else {
  443. this.$newMessage.success(i18n.t('shopFeature.edit.noneUseableCom'))
  444. }
  445. },
  446. /**
  447. * 添加组件
  448. * */
  449. addComponent (item) {
  450. const scrollBox = document.getElementById('scrollbar')
  451. this.scrollTopHeight = scrollBox.scrollTop
  452. const allCurrentUseComponents = this.currentUseComponents
  453. const $par = {type: item.type}
  454. const $appendPositionIndex = this.appendPosition.index
  455. if ($appendPositionIndex !== '') { // 插入模式
  456. const $in = this.appendPosition.position === 'top' ? $appendPositionIndex : $appendPositionIndex + 1
  457. allCurrentUseComponents.splice($in, 0, item)
  458. this.currentEditComponent = $in
  459. } else {
  460. allCurrentUseComponents.push($par)
  461. this.currentEditComponent = allCurrentUseComponents.length - 1
  462. }
  463. setTimeout(() => {
  464. // 重置插入位置为空
  465. this.$forceUpdate()
  466. this.currentUseComponents = allCurrentUseComponents
  467. this.appendPosition.index = ''
  468. this.reSetIsShowEdit()
  469. scrollBox.scrollTop = this.scrollTopHeight
  470. // console.log('this.scrollTopHeight===', this.scrollTopHeight);
  471. }, 5)
  472. console.log(item)
  473. },
  474. /**
  475. * 插入
  476. * */
  477. appendComponents ($position = 'bottom', $index, theRefs) {
  478. this.appendPosition = {
  479. index: $index,
  480. position: $position, // 默认底部
  481. theRefs: theRefs // 默认底部
  482. }
  483. this.reSetIsShowEdit(false)
  484. },
  485. /**
  486. * 重置isShowEdit
  487. * */
  488. reSetIsShowEdit ($is = true, isReSetOperation = true) {
  489. this.configComponentsShow = false
  490. this.isShowEdit = $is
  491. this.isShowEditorAllComponents = !this.isShowEdit
  492. if (isReSetOperation) {
  493. this.componentOperation()
  494. }
  495. },
  496. /**
  497. * 点击某个组件
  498. * $isConfigComponents = 1 时为顶部
  499. * */
  500. clickComponent ($item, $index, $isConfigComponents = 0) {
  501. if ($isConfigComponents === 1) {
  502. this.currentEditConfigComponentsShow = $index
  503. this.configComponentsShow = true
  504. this.isShowEdit = false
  505. this.isShowEditorAllComponents = false
  506. } else {
  507. this.currentEditComponent = $index
  508. this.reSetIsShowEdit()
  509. }
  510. this.componentOperation()
  511. },
  512. /**
  513. * 移除某个组件
  514. * */
  515. popBtn ($type, item, ref, index) {
  516. if ($type === 2) { // 确定
  517. const $currentUseComponents = this.currentUseComponents
  518. $currentUseComponents.splice(index, 1)
  519. this.currentUseComponents = []
  520. setTimeout(() => {
  521. this.currentUseComponents = $currentUseComponents
  522. }, 5)
  523. }
  524. this.$refs[ref][0].showPopper = false
  525. this.isShowEditorAllComponents = false
  526. },
  527. // 监听某个组件的变化
  528. componentsValueChanceFromConfig ($val) {
  529. if ($val) {
  530. this.configComponents[$val.current].dataField = $val.dataField
  531. }
  532. },
  533. componentsValueChance ($val) {
  534. if ($val) {
  535. this.currentUseComponents[$val.current].dataField = $val.dataField
  536. }
  537. },
  538. // 拖拽
  539. sortStart () {
  540. this.setOther.dragCursor = 'all-scroll'
  541. this.isMoveIng = true
  542. },
  543. // 拖动过程,改变鼠标样式
  544. sortMove () {
  545. },
  546. // 结束拖拽
  547. sortEnd (val) {
  548. this.isDrag = (val.oldIndex !== val.newIndex)
  549. this.currentEditComponent = val.newIndex
  550. this.isMoveIng = false
  551. },
  552. // 拖拽之后的结果
  553. sortInput (val, isReSet = true) {
  554. if (this.isDrag) {
  555. this.currentUseComponents = []
  556. setTimeout(() => {
  557. this.currentUseComponents = val
  558. }, 5)
  559. this.appendPosition.index = ''
  560. }
  561. this.isDrag = false
  562. this.configComponentsShow = false
  563. this.reSetIsShowEdit(true, isReSet)
  564. },
  565. /** 右边组件的拖拽 */
  566. componentsSortInput (val) {
  567. this.isDrag = true
  568. this.sortInput(val, false)
  569. },
  570. componentsSorMove () {
  571. console.log('右边组件的拖拽')
  572. },
  573. /**
  574. * 保存事件 先校验
  575. * @param {Number/String} $type 保存类型: 1保存后返回列表页; 2保存后留在编辑页
  576. * @param {Boolean} dontShowMessage 是否显示 "保存成功" 消息提示
  577. * */
  578. save ($type, dontShowMessage) {
  579. this.saveType = $type
  580. this.dontShowMessage = dontShowMessage
  581. this.allCheckResult = []
  582. this.isStartCheckFieldRules = !this.isStartCheckFieldRules// 开始校验
  583. },
  584. /** 所有的正在编辑的校验结果 */
  585. everyComponentsCheckResultFun (ev) {
  586. // console.log('ev===', ev);
  587. this.allCheckResult.push(ev.data)
  588. /** 统计当前所有正在使用组件的数量 */
  589. const currentUserAllComponentsList = this.currentUseComponents.length + this.configComponents.length
  590. // // console.log('--', currentUserAllComponentsList);
  591. if (this.allCheckResult.length === currentUserAllComponentsList) {
  592. // // console.log('已经获得所有的值', this.allCheckResult);
  593. const $allCheckResult = this.allCheckResult
  594. for (let i = 0; i < $allCheckResult.length; i++) {
  595. const cur = $allCheckResult[i]
  596. if (!cur.isPass) {
  597. let $type = 0
  598. if (cur.isHeader) { // 头部的验证规则不通过
  599. this.configComponents[cur.current]['isCheckMySelf'] = !this.configComponents[cur.current]['isCheckMySelf']
  600. $type = 1
  601. } else { // 底部的不通过
  602. this.currentUseComponents[cur.current]['isCheckMySelf'] = !this.currentUseComponents[cur.current]['isCheckMySelf']
  603. }
  604. this.clickComponent({}, cur.current, $type)
  605. this.isStartCheckFieldRules = false
  606. // 开始通知子组件开始提示用户 ,弹窗等。。。
  607. this.isCheckMySelf = !this.isCheckMySelf
  608. break
  609. }
  610. if (i === $allCheckResult.length - 1) { // 验证完成,可以保存了
  611. this.savePush()
  612. }
  613. }
  614. }
  615. },
  616. // 验证完毕之后发布push
  617. savePush () {
  618. const $parameter = this.configComponents.concat(this.currentUseComponents)
  619. // // console.log($parameter);
  620. $parameter.map(re => { // 移除isCheckMySelf字段,不能上传数据库
  621. delete re['isCheckMySelf']
  622. })
  623. if (this.isNeedReturnSaveData) { // 返回最后保存的值 当前微页面被使用成组件时
  624. this.$emit('returnData',
  625. {
  626. typeDecs: this.saveType === 1 ? this.saveBtn_title_1 : this.saveType === 2 ? this.saveBtn_title_2 : this.saveBtn_title_3,
  627. type: this.saveType, // 按钮类型
  628. data: $parameter
  629. }
  630. )
  631. return
  632. }
  633. this.saveData($parameter, this.saveType)
  634. },
  635. /** 保存到数据库 */
  636. async saveData ($data, saveType) {
  637. saveType === 1 ? this.isSaving = true : this.isSaving2 = true
  638. console.log()
  639. const par = {
  640. content: JSON.stringify($data),
  641. name: $data[0].dataField.title || i18n.t('shopFeature.header.microTitle')
  642. }
  643. if (this.renovationId) {
  644. par['renovationId'] = this.renovationId
  645. }
  646. this.$http({
  647. url: this.$http.adornUrl(this.renovationId ? '/platform/shopRenovation/operate' : '/platform/shopRenovation'),
  648. method: this.renovationId ? 'put' : 'post',
  649. data: this.$http.adornData(par)
  650. }).then(({ data }) => {
  651. saveType === 1 ? this.isSaving = false : this.isSaving2 = false
  652. if (!this.renovationId) {
  653. this.renovationId = data
  654. }
  655. if (!this.dontShowMessage) {
  656. this.$newMessage({
  657. message: i18n.t('shopFeature.edit.saveSuccess'),
  658. type: 'success',
  659. duration: 1500,
  660. onClose: () => {
  661. if (saveType !== 2) {
  662. this.$router.push({
  663. name: 'platform-feature/list/index'
  664. })
  665. }
  666. }
  667. })
  668. } else {
  669. this.dontShowMessage = false
  670. }
  671. })
  672. },
  673. /**
  674. * 获取详情
  675. */
  676. getInfo () {
  677. this.$http({
  678. url: this.$http.adornUrl('/platform/shopRenovation/info/' + this.renovationId),
  679. method: 'GET'
  680. }).then(({ data }) => {
  681. this.configComponents = []
  682. let par = {}
  683. if (this.microKeyWord) {
  684. par.keyword = this.microKeyWord
  685. }
  686. if (this.renovationId) {
  687. par.renovationId = this.renovationId
  688. }
  689. let detail = {
  690. keyword: 'other',
  691. pageData: data.content
  692. }
  693. if (this.microKeyWord === 'productCatalog') {
  694. detail = {
  695. keyword: 'productCatalog',
  696. pageData: data.content
  697. }
  698. }
  699. let $data = JSON.parse(detail.pageData)
  700. if ($data.length) {
  701. this.configComponents = []
  702. $data.map(re => {
  703. if (re.type.indexOf('config') !== -1) {
  704. this.configComponents.push(re)
  705. } else {
  706. this.currentUseComponents.push(re)
  707. }
  708. })
  709. }
  710. }).catch((error) => {
  711. console.log('err', error)
  712. })
  713. },
  714. /**
  715. * 返回
  716. */
  717. backToList () {
  718. this.$router.push({
  719. name: 'platform-feature/list/index'
  720. })
  721. }
  722. }
  723. }
  724. </script>
  725. <style lang="scss">
  726. @import './edit.scss';
  727. </style>