index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. <template>
  2. <div class="app-container">
  3. <!-- 活动专区配置 -->
  4. <el-page-header @back="goBack" :content="activityName"></el-page-header>
  5. <el-divider></el-divider>
  6. <div class="form-container">
  7. <el-form ref="mainForm" :model="mainForm">
  8. <template v-if="type == 10 || type == 11 || type == 12">
  9. <el-form-item :label="'活动专区主标题:'" prop="title1">
  10. <el-input
  11. v-model="mainForm.title1"
  12. placeholder="请输入活动专区主标题"
  13. style="width: 300px"
  14. maxlength="6"
  15. show-word-limit
  16. ></el-input>
  17. </el-form-item>
  18. <el-form-item :label="'活动专区副标题:'" prop="title2">
  19. <el-input
  20. v-model="mainForm.title2"
  21. placeholder="请输入活动专区副标题"
  22. style="width: 300px"
  23. maxlength="6"
  24. show-word-limit
  25. ></el-input>
  26. </el-form-item>
  27. </template>
  28. <el-upload
  29. class="avatar-uploader"
  30. :action="baseURL + 'common/upload'"
  31. :headers="myHeaders"
  32. :show-file-list="false"
  33. :on-success="uploadSuccess"
  34. :before-upload="beforeUpload"
  35. style="height: 0"
  36. >
  37. </el-upload>
  38. <el-form-item :label="'活动专区图片:'" prop="img1_url">
  39. <div class="images">
  40. <div class="main-img">
  41. <div class="img" v-if="img1_url" @mouseover="img1_hover = true" @mouseout="img1_hover = false">
  42. <el-image
  43. ref="img1"
  44. :src="$showImgUrl(img1_url)"
  45. :preview-src-list="[$showImgUrl(img1_url)]"
  46. style="width: 120px; height: 120px"
  47. fit="contain"
  48. ></el-image>
  49. <div class="mask" v-show="img1_hover">
  50. <i class="el-icon-zoom-in" @click="previewImage('img1')"></i>
  51. <i class="el-icon-upload2" @click="uploadImage('img1')"></i>
  52. </div>
  53. </div>
  54. <div class="add" v-else @click="uploadImage('img1')">
  55. <i class="el-icon-plus avatar-uploader-icon"></i>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="tips">
  60. <span>尺寸比例为:{{ ratio }}</span>
  61. </div>
  62. </el-form-item>
  63. <el-form-item :label="'活动专区表头图片:'">
  64. <div class="images">
  65. <div class="main-img">
  66. <div class="img" v-if="img2_url" @mouseover="img2_hover = true" @mouseout="img2_hover = false">
  67. <el-image
  68. ref="img2"
  69. :src="$showImgUrl(img2_url)"
  70. :preview-src-list="[$showImgUrl(img2_url)]"
  71. style="width: 120px; height: 120px"
  72. fit="contain"
  73. ></el-image>
  74. <div class="mask" v-show="img2_hover">
  75. <i class="el-icon-zoom-in" @click="previewImage('img2')"></i>
  76. <i class="el-icon-upload2" @click="uploadImage('img2')"></i>
  77. <i class="el-icon-delete" @click="deleteImage('img2')"></i>
  78. </div>
  79. </div>
  80. <div class="add" v-else @click="uploadImage('img2')">
  81. <i class="el-icon-plus avatar-uploader-icon"></i>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="tips">
  86. <span>尺寸比例为:750*800</span>
  87. </div>
  88. </el-form-item>
  89. <el-form-item :label="'活动专区背景颜色:'" prop="backGroundColor">
  90. <div style="display: flex">
  91. <el-color-picker v-model="mainForm.backGroundColor"> </el-color-picker>
  92. <el-button style="margin-left: 20px" @click="resetFn">重置</el-button>
  93. </div>
  94. </el-form-item>
  95. </el-form>
  96. </div>
  97. <div class="btn-group">
  98. <el-button size="small" type="primary" @click="addClassify">选择分类</el-button>
  99. <el-button size="small" type="primary" @click="addGoods">选择商品</el-button>
  100. </div>
  101. <div class="diy-table">
  102. <div class="table-head clearfix">
  103. <div class="item goods">商品名称</div>
  104. <div class="right">
  105. <div class="item name">规格</div>
  106. <div class="item input">划线价格</div>
  107. <div class="item input">销售价</div>
  108. <div class="item input">分销金额</div>
  109. <div class="item input">佣金比例</div>
  110. <div class="item input">内部分销金额</div>
  111. <div class="item input">内部佣金比例</div>
  112. <div class="item input">库存</div>
  113. <div class="item input">销量</div>
  114. </div>
  115. <div class="blank">操作</div>
  116. </div>
  117. <div class="goods-item" v-for="(item, index) in goodsList" :key="index">
  118. <div class="goods-info">
  119. <img :src="$showImgUrl(item.imgUrl)" alt="" />
  120. {{ item.goodsName }}
  121. </div>
  122. <div class="spec-list">
  123. <div class="spec-item" v-for="(it, idx) in item.goodsSpecs" :key="idx">
  124. <div class="col name">{{ it.name }}-{{ it.specValue }}</div>
  125. <div class="col input"><el-input disabled type="number" size="small" v-model="it.orgPrice"></el-input></div>
  126. <div class="col input"><el-input disabled type="number" size="small" v-model="it.price"></el-input></div>
  127. <div class="col input">
  128. <el-input disabled type="number" size="small" v-model="it.shareAmount"></el-input>
  129. </div>
  130. <div class="col input">
  131. <el-input disabled type="number" size="small" v-model="it.innerSharePercent"></el-input>
  132. </div>
  133. <div class="col input">
  134. <el-input disabled type="number" size="small" v-model="it.innerShareAmount"></el-input>
  135. </div>
  136. <div class="col input">
  137. <el-input disabled type="number" size="small" v-model="it.innerSharePercent"></el-input>
  138. </div>
  139. <div class="col input"><el-input disabled type="number" size="small" v-model="it.stockNum"></el-input></div>
  140. <div class="col input"><el-input disabled type="number" size="small" v-model="it.soldNum"></el-input></div>
  141. </div>
  142. </div>
  143. <div class="operation">
  144. <el-button type="text" style="color: #f56c6c" @click="deleteGoods(item.goodsId, index)">删除</el-button>
  145. </div>
  146. </div>
  147. <div class="empty-text" v-if="goodsList.length < 1">暂无数据</div>
  148. </div>
  149. <div class="page-footer">
  150. <div class="footer" :class="classObj">
  151. <el-button type="primary" @click="submitMainForm" :loading="formLoading">{{
  152. formLoading ? '提交中 ...' : '提 交'
  153. }}</el-button>
  154. <el-button @click="goBack">关 闭</el-button>
  155. </div>
  156. </div>
  157. <!-- 选择商品 -->
  158. <el-dialog
  159. title="选择商品"
  160. :visible.sync="addGoodsVisible"
  161. :show-close="false"
  162. width="50%"
  163. :close-on-click-modal="false"
  164. >
  165. <div class="dialog-container clearfix">
  166. <div class="left fl">
  167. <div class="item" @click="changeClassify('')">全部分类</div>
  168. <div class="group" v-for="(item, index) in classifyList" :key="index">
  169. <div class="item" @click="toggleOpen(index)">
  170. <i :class="item.isOpen ? 'el-icon-caret-bottom' : 'el-icon-caret-right'"></i> {{ item.name }}
  171. </div>
  172. <div class="child" v-if="item.isOpen">
  173. <div
  174. class="item"
  175. v-for="(childItem, childIndex) in item.children"
  176. :key="childIndex"
  177. @click="changeClassify(childItem.categoryId)"
  178. >
  179. {{ childItem.name }}
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="right fl">
  185. <div class="search">
  186. <el-input
  187. placeholder="请输入商品名称进行搜索"
  188. v-model="keyword"
  189. class="input-with-select"
  190. clearable
  191. size="small"
  192. style="width: 250px"
  193. >
  194. <el-button slot="append" icon="el-icon-search" size="small" @click="getGoodsListByScreen"></el-button>
  195. </el-input>
  196. </div>
  197. <div class="table" style="margin: 10px 0 20px">
  198. <el-table
  199. v-loading="table_listLoading"
  200. :data="table_dataList"
  201. element-loading-text="Loading"
  202. tooltip-effect="dark"
  203. style="width: 100%"
  204. max-height="270"
  205. @selection-change="handleChooseGoods"
  206. >
  207. <el-table-column
  208. align="center"
  209. type="selection"
  210. :selectable="checkboxSelect"
  211. width="45"
  212. ></el-table-column>
  213. <el-table-column
  214. align="center"
  215. prop="goodsName"
  216. label="商品名称"
  217. min-width="200"
  218. show-overflow-tooltip
  219. ></el-table-column>
  220. <el-table-column align="center" prop="goodsPrice" label="价格" width="80"></el-table-column>
  221. <el-table-column align="center" prop="stockNum" label="库存" width="80"></el-table-column>
  222. </el-table>
  223. </div>
  224. <div class="pagination clearfix">
  225. <div class="fr">
  226. <el-pagination
  227. @current-change="handleTableCurrentChange"
  228. :current-page="table_currentPage"
  229. :page-size="table_pageSize"
  230. background
  231. layout="prev, pager, next"
  232. :total="table_listTotal"
  233. >
  234. </el-pagination>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. <div slot="footer" class="dialog-footer">
  240. <el-button type="primary" @click="submitAddGoods">保 存</el-button>
  241. <el-button @click="cancelAddGoods">取 消</el-button>
  242. </div>
  243. </el-dialog>
  244. <!-- 选择分类 -->
  245. <el-dialog
  246. title="选择分类"
  247. :visible.sync="addClassifyVisible"
  248. :show-close="false"
  249. width="40%"
  250. :close-on-click-modal="false"
  251. >
  252. <div class="classify-list">
  253. <el-tree
  254. :data="classifyList"
  255. show-checkbox
  256. default-expand-all
  257. node-key="categoryId"
  258. ref="tree"
  259. highlight-current
  260. :props="defaultProps"
  261. >
  262. </el-tree>
  263. </div>
  264. <div slot="footer" class="dialog-footer">
  265. <el-button type="primary" @click="submitAddClassify">保 存</el-button>
  266. <el-button @click="cancelAddClassify">取 消</el-button>
  267. </div>
  268. </el-dialog>
  269. </div>
  270. </template>
  271. <script>
  272. import { getToken } from '@/utils/auth'
  273. import {
  274. getactivityGoodsDetail,
  275. addActiveGoods,
  276. editEnterpriseTemplate,
  277. getClassifyList,
  278. getGoodsList,
  279. getMoreGoodsList
  280. } from '@/api/special'
  281. export default {
  282. data() {
  283. return {
  284. companyWechatId: '',
  285. useTemplate: '',
  286. activityName: '', // 头部标题
  287. ratio: '',
  288. objectId: '', // 小程序模板id
  289. type: '', // 类型
  290. baseURL: process.env.VUE_APP_BASE_API,
  291. myHeaders: { 'x-token': getToken() },
  292. formLoading: false,
  293. mainForm: {
  294. title1: '',
  295. title2: '',
  296. backGroundColor: '#F4F2F2'
  297. },
  298. goodsList: [], // 列表数据
  299. addGoodsVisible: false,
  300. classifyList: [],
  301. classifyCurrent: '',
  302. keyword: '',
  303. table_dataList: null, // 列表数据
  304. table_listLoading: true, // 列表加载loading
  305. table_currentPage: 1, // 当前页码
  306. table_pageSize: 10, // 每页数量
  307. table_listTotal: 0, // 列表总数
  308. table_chooseGoods: [], // table中 当前选择商品
  309. addClassifyVisible: false,
  310. defaultProps: {
  311. children: 'children',
  312. label: 'name'
  313. },
  314. uploadImageType: null,
  315. img1_url: '',
  316. img1_hover: false,
  317. img2_url: '',
  318. img2_hover: false
  319. }
  320. },
  321. computed: {
  322. sidebar() {
  323. return this.$store.state.app.sidebar
  324. },
  325. classObj() {
  326. return {
  327. hideSidebar: !this.sidebar.opened,
  328. openSidebar: this.sidebar.opened
  329. }
  330. }
  331. },
  332. created() {
  333. const { item } = this.$route.query
  334. this.activityName = item.activityName
  335. this.objectId = item.objectId
  336. this.type = item.type
  337. this.ratio = item.ratio
  338. this.companyWechatId = JSON.parse(localStorage.getItem('greemall_user')).companyWechatId
  339. this.useTemplate = JSON.parse(localStorage.getItem('greemall_user')).useTemplate
  340. this.getactivityGoodsDetail()
  341. if (item.type == 2) {
  342. this.img1_url = item.popupImage
  343. this.img2_url = item.popupHeadImage
  344. this.mainForm.backGroundColor = item.popupBackgroundColor
  345. } else if (item.type == 3) {
  346. this.img1_url = item.active1Image
  347. this.img2_url = item.active1HeadImage
  348. this.mainForm.backGroundColor = item.active1BackgroundColor
  349. } else if (item.type == 4) {
  350. this.img1_url = item.active2LeftImage
  351. this.img2_url = item.active2LeftHeadImage
  352. this.mainForm.backGroundColor = item.active2LeftBackgroundColor
  353. } else if (item.type == 5) {
  354. this.img1_url = item.active2RightImage
  355. this.img2_url = item.active2RightHeadImage
  356. this.mainForm.backGroundColor = item.active2RightBackgroundColor
  357. } else if (item.type == 6) {
  358. this.img1_url = item.only1Image
  359. this.img2_url = item.only1HeadImage
  360. this.mainForm.backGroundColor = item.only1BackgroundColor
  361. } else if (item.type == 7) {
  362. this.img1_url = item.only2Image
  363. this.img2_url = item.only2HeadImage
  364. this.mainForm.backGroundColor = item.only2BackgroundColor
  365. } else if (item.type == 8) {
  366. this.img1_url = item.only3Image
  367. this.img2_url = item.only3HeadImage
  368. this.mainForm.backGroundColor = item.only3BackgroundColor
  369. } else if (item.type == 9) {
  370. this.img1_url = item.only4Image
  371. this.img2_url = item.only4HeadImage
  372. this.mainForm.backGroundColor = item.only4BackgroundColor
  373. } else if (item.type == 10) {
  374. this.img1_url = item.topics1Image
  375. this.img2_url = item.topics1HeadImage
  376. this.mainForm.backGroundColor = item.topics1BackgroundColor
  377. this.mainForm.title1 = item.topics1Title
  378. this.mainForm.title2 = item.topics1Title2
  379. } else if (item.type == 11) {
  380. this.img1_url = item.topics2Image
  381. this.img2_url = item.topics2HeadImage
  382. this.mainForm.backGroundColor = item.topics2BackgroundColor
  383. this.mainForm.title1 = item.topics2Title
  384. this.mainForm.title2 = item.topics2Title2
  385. } else if (item.type == 12) {
  386. this.img1_url = item.topics3Image
  387. this.img2_url = item.topics3HeadImage
  388. this.mainForm.backGroundColor = item.topics3BackgroundColor
  389. this.mainForm.title1 = item.topics3Title
  390. this.mainForm.title2 = item.topics3Title2
  391. } else if (item.type == 13) {
  392. this.img1_url = item.bottomBannerImage
  393. this.img2_url = item.bottomBannerHeadImage
  394. this.mainForm.backGroundColor = item.bottomBannerBackgroundColor
  395. }
  396. },
  397. methods: {
  398. // 更改模板信息
  399. editEnterpriseTemplate(params) {
  400. editEnterpriseTemplate(params).then(res => {
  401. console.log('更改模板信息', res)
  402. })
  403. },
  404. // 添加活动商品
  405. addActiveGoods(params) {
  406. addActiveGoods(params).then(res => {
  407. if (res.code == 200) {
  408. this.$router.go(-1)
  409. }
  410. })
  411. },
  412. // 获取活动商品详情
  413. getactivityGoodsDetail() {
  414. const params = {
  415. objectId: this.objectId, // 小程序模板id
  416. type: this.type // 类型: 1=新维度分类,2=首页弹窗,3=活动专区1,4=活动专区2左侧,5=活动专区2右侧,6=专场专区1,7=专场专区2,8=专场专区3,9=专场专区4,10=专题精选1,11=专题精选2,12=专题精选3,13=底部广告图
  417. }
  418. getactivityGoodsDetail(params).then(res => {
  419. res.data.activeGoodsList.forEach(item => {
  420. item.imgUrl = item.goods.imgUrl
  421. })
  422. this.goodsList = res.data.activeGoodsList
  423. })
  424. },
  425. // 重置
  426. resetFn() {
  427. this.mainForm.backGroundColor = '#F4F2F2'
  428. },
  429. // 删除商品
  430. deleteGoods(item, index) {
  431. this.goodsList.splice(index, 1)
  432. },
  433. uploadImage(type) {
  434. this.uploadImageType = type
  435. document.querySelector('.avatar-uploader input').click()
  436. },
  437. // 上传图片
  438. uploadSuccess(res, file) {
  439. this[this.uploadImageType + '_url'] = res.data.url
  440. },
  441. beforeUpload(file) {
  442. const fileSuffix = file.name.substring(file.name.lastIndexOf('.') + 1)
  443. const whiteList = ['jpg', 'jpeg', 'png', 'gif']
  444. if (whiteList.indexOf(fileSuffix) === -1) {
  445. this.$errorMsg('只支持上传jpg/jpeg/png/gif文件!')
  446. return false
  447. }
  448. },
  449. // 预览图片
  450. previewImage(type) {
  451. this.$refs[type].showViewer = true
  452. },
  453. // 删除图片
  454. deleteImage(type) {
  455. this[type + '_url'] = ''
  456. },
  457. // 返回
  458. goBack() {
  459. this.$router.go(-1)
  460. },
  461. // 获取分类列表
  462. getClassifyList(state) {
  463. getClassifyList({ categoryLevel: 1, status: true }).then(res => {
  464. res.data.forEach(item => {
  465. item.isOpen = false
  466. })
  467. this.classifyList = res.data
  468. this.classifyCurrent = ''
  469. if (!state) {
  470. this.getGoodsList()
  471. }
  472. })
  473. },
  474. // 展开/收起 分类
  475. toggleOpen(index) {
  476. this.classifyList[index].isOpen = !this.classifyList[index].isOpen
  477. },
  478. // 切换分类
  479. changeClassify(cid) {
  480. if (this.table_chooseGoods.length > 0) {
  481. return this.$errorMsg('当前已选择商品,不可切换分类')
  482. }
  483. this.classifyCurrent = cid
  484. this.table_currentPage = 1
  485. this.getGoodsList()
  486. },
  487. // 搜索
  488. getGoodsListByScreen() {
  489. if (this.table_chooseGoods.length > 0) {
  490. return this.$errorMsg('当前已选择商品,不可搜索')
  491. }
  492. this.table_currentPage = 1
  493. this.getGoodsList()
  494. },
  495. // 获取商品列表
  496. getGoodsList() {
  497. getGoodsList({
  498. pageNum: this.table_currentPage,
  499. pageSize: this.table_pageSize,
  500. keyword: this.keyword,
  501. categoryId: this.classifyCurrent,
  502. status: true
  503. }).then(res => {
  504. let oldGoodsList = this.goodsList
  505. let newGoodsList = res.data.records
  506. for (let i = 0; i < oldGoodsList.length; i++) {
  507. let oldItem = oldGoodsList[i]
  508. for (let j = 0; j < newGoodsList.length; j++) {
  509. let newItem = newGoodsList[j]
  510. if (newItem.goodsId === oldItem.goodsId) {
  511. newGoodsList[j].selected = true
  512. break
  513. }
  514. }
  515. }
  516. for (let j = 0; j < newGoodsList.length; j++) {
  517. let newItem = newGoodsList[j]
  518. if (newItem.promotionGroup === true) {
  519. newGoodsList[j].selected = true
  520. }
  521. }
  522. this.table_dataList = newGoodsList
  523. this.table_listTotal = res.data.total
  524. this.table_listLoading = false
  525. })
  526. },
  527. // 查询重复值并禁选
  528. checkboxSelect(row, rowIndex) {
  529. if (row.selected) {
  530. return false // 禁用
  531. } else {
  532. return true // 不禁用
  533. }
  534. },
  535. // 更改列表当前页
  536. handleTableCurrentChange(val) {
  537. if (this.table_chooseGoods.length > 0) {
  538. return this.$errorMsg('当前已选择商品,不可切换分页')
  539. }
  540. this.table_currentPage = val
  541. this.getGoodsList()
  542. },
  543. // table点击选择商品
  544. handleChooseGoods(val) {
  545. this.table_chooseGoods = val
  546. },
  547. // 打开 选择商品
  548. addGoods() {
  549. this.addGoodsVisible = true
  550. this.getClassifyList()
  551. },
  552. // 取消 选择商品
  553. cancelAddGoods() {
  554. this.addGoodsVisible = false
  555. },
  556. // 提交 选择商品
  557. submitAddGoods() {
  558. let oldGoodsList = this.goodsList
  559. let newGoodsList = this.table_chooseGoods
  560. this.goodsList = oldGoodsList.concat(newGoodsList)
  561. this.addGoodsVisible = false
  562. },
  563. // 打开 选择分类
  564. addClassify() {
  565. this.addClassifyVisible = true
  566. this.getClassifyList(true)
  567. },
  568. // 取消 选择分类
  569. cancelAddClassify() {
  570. this.addClassifyVisible = false
  571. },
  572. // 提交 选择分类
  573. submitAddClassify() {
  574. if (this.$refs.tree.getCheckedNodes().length <= 0) {
  575. return this.$errorMsg('请选择分类')
  576. }
  577. let checkeds = this.$refs.tree.getCheckedNodes()
  578. let ids = []
  579. checkeds.forEach(item => {
  580. if (item.level === 2) {
  581. ids.push(item.categoryId)
  582. }
  583. })
  584. getMoreGoodsList({ categoryIds: ids.join(','), status: true }).then(res => {
  585. let oldGoodsList = this.goodsList
  586. let newGoodsList = []
  587. res.data.forEach(item => {
  588. if (item.promotionGroup === false) {
  589. newGoodsList.push(item)
  590. }
  591. })
  592. let allGoodsList = oldGoodsList.concat(newGoodsList)
  593. let showGoodsList = []
  594. let obj = {}
  595. for (var i = 0; i < allGoodsList.length; i++) {
  596. if (!obj[allGoodsList[i].goodsId]) {
  597. showGoodsList.push(allGoodsList[i])
  598. obj[allGoodsList[i].goodsId] = true
  599. }
  600. }
  601. this.goodsList = showGoodsList
  602. this.addClassifyVisible = false
  603. })
  604. },
  605. // 提交
  606. submitMainForm() {
  607. this.$refs.mainForm.validate(valid => {
  608. if (valid) {
  609. const params = {
  610. goodsList: this.goodsList,
  611. objectId: this.objectId,
  612. type: this.type
  613. }
  614. this.addActiveGoods(params)
  615. let comParams = {
  616. companyWechatTemplateId: this.objectId,
  617. companyWechatId: this.companyWechatId,
  618. templateType: this.useTemplate
  619. }
  620. let params1 = {}
  621. if (this.type == 2) {
  622. params1 = {
  623. popupBackgroundColor: this.mainForm.backGroundColor,
  624. popupHeadImage: this.img2_url,
  625. popupImage: this.img1_url,
  626. ...comParams
  627. }
  628. } else if (this.type == 3) {
  629. params1 = {
  630. active1BackgroundColor: this.mainForm.backGroundColor,
  631. active1HeadImage: this.img2_url,
  632. active1Image: this.img1_url,
  633. ...comParams
  634. }
  635. } else if (this.type == 4) {
  636. params1 = {
  637. active2LeftBackgroundColor: this.mainForm.backGroundColor,
  638. active2LeftHeadImage: this.img2_url,
  639. active2LeftImage: this.img1_url,
  640. ...comParams
  641. }
  642. } else if (this.type == 5) {
  643. params1 = {
  644. active2RightBackgroundColor: this.mainForm.backGroundColor,
  645. active2RightHeadImage: this.img2_url,
  646. active2RightImage: this.img1_url,
  647. ...comParams
  648. }
  649. } else if (this.type == 6) {
  650. params1 = {
  651. only1BackgroundColor: this.mainForm.backGroundColor,
  652. only1HeadImage: this.img2_url,
  653. only1Image: this.img1_url,
  654. ...comParams
  655. }
  656. } else if (this.type == 7) {
  657. params1 = {
  658. only2BackgroundColor: this.mainForm.backGroundColor,
  659. only2HeadImage: this.img2_url,
  660. only2Image: this.img1_url,
  661. ...comParams
  662. }
  663. } else if (this.type == 8) {
  664. params1 = {
  665. only3BackgroundColor: this.mainForm.backGroundColor,
  666. only3HeadImage: this.img2_url,
  667. only3Image: this.img1_url,
  668. ...comParams
  669. }
  670. } else if (this.type == 9) {
  671. params1 = {
  672. only4BackgroundColor: this.mainForm.backGroundColor,
  673. only4HeadImage: this.img2_url,
  674. only4Image: this.img1_url,
  675. ...comParams
  676. }
  677. } else if (this.type == 10) {
  678. params1 = {
  679. topics1BackgroundColor: this.mainForm.backGroundColor,
  680. topics1HeadImage: this.img2_url,
  681. topics1Image: this.img1_url,
  682. topics1Title: this.mainForm.title1,
  683. topics1Title2: this.mainForm.title2,
  684. ...comParams
  685. }
  686. } else if (this.type == 11) {
  687. params1 = {
  688. topics2BackgroundColor: this.mainForm.backGroundColor,
  689. topics2HeadImage: this.img2_url,
  690. topics2Image: this.img1_url,
  691. topics2Title: this.mainForm.title1,
  692. topics2Title2: this.mainForm.title2,
  693. ...comParams
  694. }
  695. } else if (this.type == 12) {
  696. params1 = {
  697. topics3BackgroundColor: this.mainForm.backGroundColor,
  698. topics3HeadImage: this.img2_url,
  699. topics3Image: this.img1_url,
  700. topics3Title: this.mainForm.title1,
  701. topics3Title2: this.mainForm.title2,
  702. ...comParams
  703. }
  704. } else if (this.type == 13) {
  705. params1 = {
  706. bottomBannerBackgroundColor: this.mainForm.backGroundColor,
  707. bottomBannerHeadImage: this.img2_url,
  708. bottomBannerImage: this.img1_url,
  709. ...comParams
  710. }
  711. }
  712. this.editEnterpriseTemplate(params1)
  713. }
  714. })
  715. }
  716. }
  717. }
  718. </script>
  719. <style lang="scss" scoped>
  720. .form-container {
  721. margin-top: 40px;
  722. // padding: 0 6%;
  723. .title {
  724. font-size: 16px;
  725. margin-bottom: 30px;
  726. padding-left: 10px;
  727. font-weight: bold;
  728. }
  729. .tips {
  730. margin-top: 10px;
  731. span {
  732. display: inline-block;
  733. width: 300px;
  734. text-align: center;
  735. line-height: 32px;
  736. background: #ffefef;
  737. font-size: 14px;
  738. color: #f66460;
  739. }
  740. }
  741. .tips2 {
  742. font-size: 12px;
  743. color: #999999;
  744. line-height: 30px;
  745. }
  746. .container {
  747. padding: 10px 20px 0;
  748. background: #f5f5f5;
  749. border-radius: 10px;
  750. }
  751. .addBtn {
  752. padding: 10px 0;
  753. }
  754. }
  755. .dialog-container {
  756. .left {
  757. width: 140px;
  758. height: 350px;
  759. overflow-y: scroll;
  760. .group {
  761. margin-top: 10px;
  762. }
  763. .child {
  764. margin-top: 5px;
  765. .item {
  766. padding-left: 18px;
  767. }
  768. }
  769. .item {
  770. cursor: pointer;
  771. line-height: 24px;
  772. }
  773. }
  774. .right {
  775. width: calc(100% - 140px);
  776. height: 350px;
  777. box-sizing: border-box;
  778. padding-left: 20px;
  779. }
  780. }
  781. .images {
  782. display: flex;
  783. flex-wrap: wrap;
  784. .main-img {
  785. display: flex;
  786. flex-direction: column;
  787. justify-content: center;
  788. align-items: center;
  789. width: 120px;
  790. margin-right: 20px;
  791. .img {
  792. border: 1px dashed #eaeaea;
  793. border-radius: 5px;
  794. overflow: hidden;
  795. position: relative;
  796. .el-image {
  797. display: block;
  798. }
  799. .mask {
  800. position: absolute;
  801. left: 0;
  802. top: 0;
  803. width: 120px;
  804. height: 120px;
  805. background: rgba($color: #000000, $alpha: 0.3);
  806. display: flex;
  807. align-items: center;
  808. justify-content: center;
  809. i {
  810. font-size: 20px;
  811. color: #ffffff;
  812. cursor: pointer;
  813. margin: 0 8px;
  814. }
  815. }
  816. }
  817. .text {
  818. font-size: 14px;
  819. color: #666666;
  820. }
  821. }
  822. .add {
  823. width: 120px;
  824. height: 120px;
  825. border: 1px dashed #eaeaea;
  826. border-radius: 5px;
  827. cursor: pointer;
  828. display: flex;
  829. align-items: center;
  830. justify-content: center;
  831. i {
  832. font-size: 30px;
  833. color: #999;
  834. }
  835. }
  836. .tmp-img {
  837. position: relative;
  838. .tmp {
  839. position: absolute;
  840. left: 0;
  841. top: 0;
  842. line-height: 20px;
  843. padding: 0 8px;
  844. background: #f66460;
  845. border-radius: 0 0 10px 0;
  846. font-size: 12px;
  847. color: #ffffff;
  848. }
  849. }
  850. }
  851. .classify-list {
  852. height: 50vh;
  853. overflow-y: scroll;
  854. }
  855. .diy-table {
  856. overflow-x: scroll;
  857. border-left: 1px solid #f5f5f5;
  858. margin-top: 20px;
  859. width: 100%;
  860. // margin-left: 77px;
  861. // min-width: 1185px;
  862. max-width: 100%;
  863. .table-head {
  864. display: flex;
  865. .item {
  866. height: 40px;
  867. line-height: 40px;
  868. float: left;
  869. font-weight: 500;
  870. font-size: 14px;
  871. background: #f5f5f5;
  872. text-align: center;
  873. }
  874. .right {
  875. float: left;
  876. width: 94%;
  877. min-width: 1150px;
  878. flex-shrink: 0;
  879. height: 40px;
  880. }
  881. .goods {
  882. width: 20%;
  883. min-width: 250px;
  884. }
  885. .name {
  886. width: 11.1111%;
  887. min-width: 100px;
  888. }
  889. .input {
  890. width: 11.1111%;
  891. min-width: 100px;
  892. }
  893. .opera {
  894. width: 11.1111%;
  895. min-width: 80px;
  896. // text-align: right;
  897. }
  898. .blank {
  899. width: 6%;
  900. min-width: 90px;
  901. font-weight: 500;
  902. font-size: 14px;
  903. background: #f5f5f5;
  904. text-align: center;
  905. line-height: 40px;
  906. }
  907. }
  908. .goods-item {
  909. display: flex;
  910. align-content: center;
  911. .goods-info {
  912. flex-shrink: 0;
  913. width: 20%;
  914. min-width: 250px;
  915. padding: 0 10px;
  916. display: flex;
  917. align-items: center;
  918. border-bottom: 1px solid #f5f5f5;
  919. border-right: 1px solid #f5f5f5;
  920. font-size: 14px;
  921. &:last-child {
  922. border-bottom: none;
  923. }
  924. img {
  925. width: 40px;
  926. height: 40px;
  927. margin-right: 10px;
  928. flex-shrink: 0;
  929. }
  930. }
  931. .spec-list {
  932. width: 94%;
  933. min-width: 1150px;
  934. border-bottom: 1px solid #f5f5f5;
  935. border-right: 1px solid #f5f5f5;
  936. &:last-child {
  937. border-bottom: none;
  938. }
  939. .spec-item {
  940. display: flex;
  941. align-items: center;
  942. border-bottom: 1px solid #f5f5f5;
  943. &:last-child {
  944. border-bottom: none;
  945. }
  946. .col {
  947. flex-shrink: 0;
  948. height: 50px;
  949. display: flex;
  950. align-items: center;
  951. justify-content: center;
  952. padding: 0 10px;
  953. border-right: 1px solid #f5f5f5;
  954. &:last-child {
  955. border-right: none;
  956. }
  957. }
  958. .name {
  959. width: 11.1111%;
  960. min-width: 100px;
  961. font-size: 14px;
  962. text-align: center;
  963. }
  964. .input {
  965. width: 11.1111%;
  966. min-width: 100px;
  967. }
  968. .btn {
  969. width: 11.1111%;
  970. min-width: 80px;
  971. }
  972. }
  973. }
  974. .operation {
  975. flex-shrink: 0;
  976. width: 6%;
  977. min-width: 90px;
  978. padding: 0 10px;
  979. display: flex;
  980. align-items: center;
  981. justify-content: center;
  982. border-bottom: 1px solid #f5f5f5;
  983. border-right: 1px solid #f5f5f5;
  984. }
  985. }
  986. .empty-text {
  987. line-height: 60px;
  988. text-align: center;
  989. color: #909399;
  990. }
  991. }
  992. .dialog-container {
  993. .left {
  994. width: 140px;
  995. height: 350px;
  996. overflow-y: scroll;
  997. .group {
  998. margin-top: 10px;
  999. }
  1000. .child {
  1001. margin-top: 5px;
  1002. .item {
  1003. padding-left: 18px;
  1004. }
  1005. }
  1006. .item {
  1007. cursor: pointer;
  1008. line-height: 24px;
  1009. }
  1010. }
  1011. .right {
  1012. width: calc(100% - 140px);
  1013. height: 350px;
  1014. box-sizing: border-box;
  1015. padding-left: 20px;
  1016. }
  1017. }
  1018. ::v-deep .el-form-item__label {
  1019. margin-left: 0px !important;
  1020. }
  1021. </style>