discountTool.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <div class="brandListTool">
  3. <h3 class="toolTit">限时折扣</h3>
  4. <div class="toolBox">
  5. <div class="porListBox">
  6. <div class="addProduct">
  7. <div v-if="!activeComponent.componentContent.activityName" class="addProBtn addImgBtn" @click="selectActivity"><span class="iconfont">&#xe685;</span>选择活动</div>
  8. <div v-else class="categoryName">
  9. <span>{{activeComponent.componentContent.activityName}}</span>
  10. <div class="operation">
  11. <span class="iconfont" @click="replaceActivity">&#xe66c;</span>
  12. <span class="iconfont" @click="deleteActivity">&#xe633;</span>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="itemBox" v-if="terminal == 4">
  18. <label>查看全部背景图</label>
  19. <tool-single-img :imageUrl.sync='activeComponent.componentContent.moreBg' tip='建议尺寸: 290*466px, 高度自适应'></tool-single-img>
  20. </div>
  21. <div class="styleSelectLine" v-if="terminal != 4">
  22. <div class="blockTit">
  23. <span>排列样式</span>
  24. <span>{{activeComponent.componentContent.arrangeType}}</span>
  25. </div>
  26. <div class="selectCompose">
  27. <div class="composeList">
  28. <span class="item iconfont" :class="{active: activeComponent.componentContent.arrangeType === item.name}" @click="selectArrange(item)" v-for="(item) of arrangeList" :key="item.id" v-html="item.Icon"></span>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="itemChoice" v-if="terminal != 4">
  33. <div class="Tit">查看更多</div>
  34. <div class="Info" v-text="activeComponent.componentContent.showMore ? '显示' : '隐藏'"></div>
  35. <div class="modifyBox">
  36. <el-checkbox v-model="activeComponent.componentContent.showMore"></el-checkbox>
  37. </div>
  38. </div>
  39. </div>
  40. <el-dialog title="选择活动" :visible.sync="showDiscountActivity" width="900px">
  41. <el-table :data='discountActivity' style="width: 100%" @row-click="rowClick" highlight-current-row>
  42. <el-table-column label width="35">
  43. <template slot-scope="scope">
  44. <el-radio v-if="typeId===1" :label="scope.row.discountId" v-model="radioId"/>
  45. <el-radio v-if="typeId===3" :label="scope.row.shopDiscountId" v-model="radioId"/>
  46. </template>
  47. </el-table-column>
  48. <el-table-column
  49. prop="discountName"
  50. label="标题">
  51. </el-table-column>
  52. <el-table-column
  53. :formatter="getDate"
  54. prop="startTime"
  55. width="400"
  56. label="活动时间">
  57. </el-table-column>
  58. <el-table-column
  59. prop="state"
  60. label="状态"
  61. :formatter='getState'>
  62. </el-table-column>
  63. </el-table>
  64. <span slot="footer" class="dialog-footer">
  65. <el-button @click="cancelSkill">取 消</el-button>
  66. <el-button type="primary" @click="confirmActivity">确 定</el-button>
  67. </span>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import Cookies from 'js-cookie'
  73. import Draggable from 'vuedraggable'
  74. import api from '@@/components/canvasShow/config/api'
  75. import {toolMixin} from '@@/config/mixin'
  76. import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
  77. import { mapGetters, mapMutations } from 'vuex'
  78. import {checkEmptyChild} from '@@/config/common'
  79. import ToolSelect from '../toolModule/tool-select'
  80. import ToolSingleImg from '../toolModule/tool-single-img'
  81. import ToolSelectLink from '../toolModule/tool-select-link'
  82. export default {
  83. mixins: [toolMixin, sendReqMixin],
  84. name: 'discountTool',
  85. components: {
  86. ToolSelectLink,
  87. ToolSingleImg,
  88. ToolSelect,
  89. Draggable
  90. },
  91. data () {
  92. return {
  93. radioId: '',
  94. discountActivity: [],
  95. selectDiscount: {},
  96. showDiscountActivity: false,
  97. arrangeList: [
  98. {
  99. id: 1,
  100. type: 'L2',
  101. name: '多行多列',
  102. Icon: '&#xe625'
  103. },
  104. {
  105. id: 2,
  106. type: 'L2',
  107. name: '横向滑动',
  108. Icon: '&#xe624;'
  109. }
  110. ],
  111. }
  112. },
  113. computed: {
  114. ...mapGetters([
  115. 'terminal',
  116. 'typeId'
  117. ])
  118. },
  119. methods: {
  120. ...mapMutations({
  121. setDiscountNum: 'SET_DISCOUNTNUM'
  122. }),
  123. // 时间变换
  124. getDate(row) {
  125. return `${row.startTime}至${row.endTime}`
  126. },
  127. // 状态变换
  128. getState(row) {
  129. if(this.typeId === 1){
  130. const opt = {
  131. 0:"报名未开始",
  132. 1:"报名进行中",
  133. 2:"活动待开始",
  134. 3:"活动进行中",
  135. 4:"活动已结束"
  136. }
  137. return opt[row.state]
  138. }
  139. if(this.typeId === 3){
  140. const opt = {
  141. 0:"未开始",
  142. 1:"进行中",
  143. 2:"已结束"
  144. }
  145. return opt[row.state]
  146. }
  147. return opt[row.state]
  148. },
  149. // 点击选择活动
  150. selectActivity() {
  151. this.getActivity()
  152. this.showDiscountActivity = true
  153. this.radioId = this.activeComponent.componentContent.shopDiscountId
  154. },
  155. // 获取活动数据
  156. getActivity() {
  157. const _ = this
  158. let _url = ''
  159. if(this.typeId===1){
  160. _url = `${api.getMinDiscount}`
  161. } else if(this.typeId===3){
  162. _url = `${api.getDiscounts}?shopId=${Cookies.get('shopID')}`
  163. }
  164. const params = {
  165. method: 'GET',
  166. url: _url,
  167. }
  168. this.sendReq(params, (res) => {
  169. _.discountActivity = res.data
  170. })
  171. },
  172. // 行点击
  173. rowClick(row) {
  174. this.selectDiscount = row;
  175. this.radioId=row.shopDiscountId;
  176. },
  177. // 确认活动选择
  178. confirmActivity() {
  179. if(this.typeId===1){
  180. this.activeComponent.componentContent.discountId = this.selectDiscount.discountId
  181. } else if(this.typeId===3){
  182. this.activeComponent.componentContent.discountId = this.selectDiscount.shopDiscountId
  183. }
  184. this.activeComponent.componentContent.activityName = this.selectDiscount.discountName
  185. this.showDiscountActivity = false
  186. this.setDiscountNum() // 通知画布刷新
  187. },
  188. // 取消活动选择
  189. cancelSkill() {
  190. this.showDiscountActivity = false;
  191. this.radioId = ''
  192. },
  193. // 替换活动
  194. replaceActivity () {
  195. this.showDiscountActivity = true
  196. this.getActivity()
  197. },
  198. // 删除已选活动
  199. deleteActivity () {
  200. this.activeComponent.componentContent.activityName = ''
  201. this.activeComponent.componentContent.shopDiscountId = ''
  202. this.setDiscountNum() // 通知画布刷新
  203. this.$forceUpdate()
  204. },
  205. // 布局选择
  206. selectArrange (item) {
  207. this.activeComponent.componentContent.arrangeType = item.name
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. .brandListTool {
  214. padding: 20px 20px 0px 20px;
  215. h3 {
  216. font-size: 18px;
  217. font-weight: 500;
  218. height: 35px;
  219. line-height: 35px;
  220. color: #333333;
  221. margin-bottom: 20px;
  222. }
  223. .toolBox {
  224. padding-bottom: 10px;
  225. .itemBox {
  226. label {
  227. font-size: 14px;
  228. color: #666666;
  229. height: 40px;
  230. line-height: 40px;
  231. }
  232. margin-bottom: 15px;
  233. }
  234. .textTit {
  235. height: 35px;
  236. line-height: 35px;
  237. font-size: 14px;
  238. color: #333333;
  239. display: flex;
  240. justify-content: space-between;
  241. span {
  242. font-weight: normal;
  243. font-size: 14px;
  244. color: #666666;
  245. }
  246. }
  247. .productTit {
  248. margin-top: 20px;
  249. color: #666666;
  250. height: 35px;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. span {
  255. font-size: 14px;
  256. color: #666666;
  257. }
  258. }
  259. .porListBox {
  260. padding: 10px;
  261. background: #F0F3F4;
  262. margin-bottom: 20px;
  263. .addProduct {
  264. .categoryName {
  265. height: 35px;
  266. display: flex;
  267. align-items: center;
  268. background: #e9e9e9;
  269. border-radius: 4px;
  270. padding: 0 10px;
  271. justify-content: space-between;
  272. span {
  273. color: #333333;
  274. }
  275. span {
  276. color: #333333;
  277. }
  278. .operation {
  279. display: flex;
  280. span {
  281. width: 35px;
  282. display: block;
  283. height: 35px;
  284. line-height: 35px;
  285. text-align: center;
  286. cursor: pointer;
  287. }
  288. }
  289. }
  290. .addProBtn {}
  291. }
  292. }
  293. .itemChoice {
  294. font-size: 14px;
  295. display: flex;
  296. margin: 20px 0;
  297. align-items: center;
  298. .Tit {
  299. color: #888888;
  300. margin-right: 10px;
  301. width: 70px;
  302. }
  303. .Info {
  304. color: #222222;
  305. }
  306. .modifyBox {
  307. text-align: right;
  308. margin-left: auto;
  309. span {
  310. height: 26px;
  311. line-height: 26px;
  312. float: left;
  313. display: block;
  314. text-align: center;
  315. cursor: pointer;
  316. width: 30px;
  317. border: 1px solid #E8EAEC;
  318. }
  319. .textActive {
  320. border: 1px solid $mainColor;
  321. color: $mainColor;
  322. }
  323. .colorBox {
  324. display: flex;
  325. align-items: center;
  326. justify-content: flex-end;
  327. span {
  328. margin-right: 10px;
  329. cursor: pointer;
  330. border: none;
  331. color: $mainColor;
  332. }
  333. }
  334. }
  335. .fontSize {
  336. span:nth-child(1) {
  337. font-size: 16px;
  338. }
  339. span:nth-child(2) {
  340. font-size: 14px;
  341. }
  342. span:nth-child(3) {
  343. font-size: 12px;
  344. }
  345. }
  346. }
  347. }
  348. ::v-deep .el-select {
  349. width: 100%;
  350. }
  351. .addImgBtn {
  352. border-radius: 4px;
  353. background: $mainColor;
  354. text-align: center;
  355. height: 36px;
  356. color: #ffffff;
  357. font-size: 14px;
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. cursor: pointer;
  362. span {
  363. font-size: 20px;
  364. margin-right: 5px;
  365. }
  366. }
  367. .labelLisTit{
  368. display: flex;
  369. justify-content: space-between;
  370. margin-bottom: 10px;
  371. }
  372. .labelListWarp{
  373. padding-bottom: 20px;
  374. .imgListBox {
  375. margin-top: 20px;
  376. .item {
  377. border: 1px solid #E8EAEC;
  378. border-radius: 4px;
  379. margin-bottom: 10px;
  380. }
  381. .listItemBox {
  382. .addImgTit {
  383. padding: 10px;
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. background: #F6F7F9;
  388. cursor: pointer;
  389. .titLeft {
  390. display: flex;
  391. align-items: center;
  392. span {
  393. color: #7D7E80;
  394. }
  395. span:nth-child(1) {
  396. font-size: 28px;
  397. }
  398. span:nth-child(2) {
  399. font-size: 25px;
  400. margin: 0 6px;
  401. }
  402. span:nth-child(3) {
  403. font-size: 14px;
  404. }
  405. }
  406. .titRight {
  407. display: flex;
  408. align-items: center;
  409. span:nth-child(1) {
  410. width: 40px;
  411. text-align: center;
  412. display: block;
  413. height: 30px;
  414. line-height: 30px;
  415. }
  416. }
  417. }
  418. .addLabelBox{
  419. padding:0 10px 10px;
  420. .itemBox{
  421. margin-bottom: 20px;
  422. label{
  423. font-size: 14px;
  424. color: #666666;
  425. height: 40px;
  426. line-height: 40px;
  427. }
  428. }
  429. ::v-deep .module-box{
  430. margin-bottom: 10px;
  431. }
  432. }
  433. .deleteItem {
  434. padding: 10px;
  435. display: flex;
  436. align-items: center;
  437. justify-content: center;
  438. background: #F6F7F9;
  439. cursor: pointer;
  440. color: $mainColor;
  441. font-size: 14px;
  442. span {
  443. font-size: 16px;
  444. margin-right: 5px;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. .styleSelectLine{
  452. margin-top: 30px;
  453. .blockTit{
  454. span{
  455. margin-right: 16px;
  456. &:last-child{
  457. color: $mainColor;
  458. }
  459. }
  460. }
  461. .composeList{
  462. display: flex;
  463. flex-wrap: wrap;
  464. padding-top: 20px;
  465. .item{
  466. width: 50px;
  467. height: 30px;
  468. display: flex;
  469. align-items: center;
  470. justify-content: center;
  471. border: 1px solid #E8EAEC;
  472. color: #999999;
  473. font-size: 18px;
  474. text-align: center;
  475. cursor: pointer;
  476. &:hover,&.active{
  477. color: #FF7800;
  478. border: 1px solid #FF7800;
  479. }
  480. }
  481. }
  482. }
  483. </style>