homeGoodsSet.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <div class="homeGoodsSet app-container">
  3. <div class="tab-list">
  4. <div class="tab" :class="[query.productType == ''?'active':'']" @click="handleTab('')">全部</div>
  5. <div class="tab" :class="[query.productType == item.value?'active':'']" v-for="item in tabList" :key="item.value" @click="handleTab(item.value)">{{item.label}}</div>
  6. </div>
  7. <div class="search">
  8. <div>
  9. <el-input
  10. v-model="query.key"
  11. size="small"
  12. placeholder="请输入产品名称"
  13. clearable
  14. class="item-width-200 "
  15. ></el-input>
  16. <el-button
  17. class="ml10"
  18. type="primary"
  19. size="small"
  20. icon="el-icon-search"
  21. @click="handleSearch"
  22. >
  23. 搜索
  24. </el-button>
  25. </div>
  26. <!-- <el-button class="add-btn" type="primary" size="small" @click="handleAdd"
  27. >添加</el-button
  28. > -->
  29. </div>
  30. <div class="search">
  31. <div>
  32. <el-button class="add-btn" type="primary" size="small" :disabled="!pids.length" @click="handleBatch(true)"
  33. >批量加入黑名单</el-button
  34. >
  35. </div>
  36. <div>
  37. <el-button class="add-btn" size="small" @click="handleSetting"
  38. >产品配置</el-button
  39. >
  40. <el-button class="add-btn" size="small" @click="handleList"
  41. >黑名单</el-button
  42. >
  43. </div>
  44. </div>
  45. <el-table
  46. @selection-change="handleSelectionChange"
  47. :data="tableData"
  48. tooltip-effect="dark"
  49. border
  50. v-loading="loading"
  51. style="width: 100%"
  52. >
  53. <el-table-column
  54. align="center"
  55. type="selection"
  56. width="55">
  57. </el-table-column>
  58. <el-table-column
  59. width="250px"
  60. align="center"
  61. label="产品信息"
  62. prop="产品信息"
  63. show-overflow-tooltip
  64. >
  65. <template slot-scope="scope">
  66. <div class="info">
  67. <el-image
  68. v-if="scope.row.cover&&scope.row.cover.length"
  69. :src="scope.row.cover[0]"
  70. class="small-img"
  71. style="width: 40px; height: 40px;"
  72. fit="cover"
  73. >
  74. </el-image>
  75. <span class="ml10">{{scope.row.title}}</span>
  76. </div>
  77. </template>
  78. </el-table-column>
  79. <el-table-column
  80. align="center"
  81. label="价格"
  82. prop="salePrice"
  83. show-overflow-tooltip
  84. >
  85. </el-table-column>
  86. <el-table-column
  87. align="center"
  88. label="销量"
  89. prop="salesCount"
  90. show-overflow-tooltip
  91. >
  92. </el-table-column>
  93. <el-table-column
  94. align="center"
  95. label="区域"
  96. prop="regionCode"
  97. show-overflow-tooltip
  98. >
  99. </el-table-column>
  100. <el-table-column
  101. align="center"
  102. label="产品类型"
  103. prop="productType"
  104. show-overflow-tooltip
  105. >
  106. <template slot-scope="scope">
  107. {{productType[scope.row.productType]||'暂无分类'}}
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. align="center"
  112. label="排序"
  113. prop="top"
  114. show-overflow-tooltip
  115. >
  116. <template slot-scope="scope">
  117. <span>{{scope.row.top}}</span> <i class="el-icon-edit" @click="handleTop(scope.row)"></i>
  118. </template>
  119. </el-table-column>
  120. <el-table-column align="center" label="操作">
  121. <template slot-scope="scope">
  122. <!-- <el-button type="text" size="small" @click="handleEdit(scope.row)"
  123. >编辑</el-button
  124. > -->
  125. <el-button type="text" size="small" @click="handleDel(scope.row,true)"
  126. >加入黑名单</el-button
  127. >
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <div class="page-box">
  132. <el-pagination
  133. @size-change="handleSizeChange"
  134. @current-change="handleCurrentChange"
  135. background
  136. :current-page="query.page"
  137. :page-sizes="[10, 20, 30, 40]"
  138. :page-size="query.size"
  139. layout="total, sizes, prev, pager, next, jumper"
  140. :total="total"
  141. >
  142. </el-pagination>
  143. </div>
  144. <el-dialog title="黑名单" width="80%" :visible.sync="dialogFormVisible3">
  145. <div class="search">
  146. <el-button class="add-btn" type="primary" size="small" :disabled="!pids1.length" @click="handleBatch(false)"
  147. >批量移除黑名单</el-button>
  148. </div>
  149. <el-table
  150. :data="tableData1"
  151. tooltip-effect="dark"
  152. border
  153. v-loading="loading"
  154. style="width: 100%"
  155. @selection-change="handleSelectionChange1"
  156. >
  157. <el-table-column
  158. align="center"
  159. type="selection"
  160. width="55">
  161. </el-table-column>
  162. <el-table-column
  163. align="center"
  164. label="产品信息"
  165. prop="产品信息"
  166. show-overflow-tooltip
  167. >
  168. <template slot-scope="scope">
  169. <div class="info">
  170. <el-image
  171. v-if="scope.row.cover&&scope.row.cover.length"
  172. :src="scope.row.cover[0]"
  173. class="small-img"
  174. style="width: 40px; height: 40px;"
  175. fit="cover"
  176. >
  177. </el-image>
  178. <span class="ml10">{{scope.row.title}}</span>
  179. </div>
  180. </template>
  181. </el-table-column>
  182. <el-table-column
  183. align="center"
  184. label="价格"
  185. prop="salePrice"
  186. show-overflow-tooltip
  187. >
  188. </el-table-column>
  189. <el-table-column
  190. align="center"
  191. label="销量"
  192. prop="salesCount"
  193. show-overflow-tooltip
  194. >
  195. </el-table-column>
  196. <el-table-column
  197. align="center"
  198. label="区域"
  199. prop="regionCode"
  200. show-overflow-tooltip
  201. >
  202. </el-table-column>
  203. <el-table-column
  204. align="center"
  205. label="产品类型"
  206. prop="productType"
  207. show-overflow-tooltip
  208. >
  209. <template slot-scope="scope">
  210. {{productType[scope.row.productType]||'暂无分类'}}
  211. </template>
  212. </el-table-column>
  213. <el-table-column
  214. align="center"
  215. label="排序"
  216. prop="top"
  217. show-overflow-tooltip
  218. >
  219. <template slot-scope="scope">
  220. <span>{{scope.row.top}}</span> <i class="el-icon-edit" @click="handleTop(scope.row)"></i>
  221. </template>
  222. </el-table-column>
  223. <el-table-column align="center" label="操作">
  224. <template slot-scope="scope">
  225. <!-- <el-button type="text" size="small" @click="handleEdit(scope.row)"
  226. >编辑</el-button
  227. > -->
  228. <el-button type="text" size="small" @click="handleDel(scope.row,false)"
  229. >移除黑名单</el-button
  230. >
  231. </template>
  232. </el-table-column>
  233. </el-table>
  234. <div class="page-box">
  235. <el-pagination
  236. @size-change="handleSizeChange1"
  237. @current-change="handleCurrentChange1"
  238. background
  239. :current-page="query1.page"
  240. :page-sizes="[10, 20, 30, 40]"
  241. :page-size="query1.size"
  242. layout="total, sizes, prev, pager, next, jumper"
  243. :total="total1"
  244. >
  245. </el-pagination>
  246. </div>
  247. </el-dialog>
  248. <el-dialog title="产品配置" width="550px" :visible.sync="dialogFormVisible1">
  249. <el-form label-width="130px" :model="setQuery1"
  250. ref="setQuery1"
  251. :rules="rules1">
  252. <el-form-item label="产品类型" prop="type">
  253. <el-select v-model="setQuery1.type" multiple class="item-width-300" placeholder="请选择">
  254. <el-option
  255. v-for="item in options"
  256. :key="item.value"
  257. :label="item.label"
  258. :value="item.value">
  259. </el-option>
  260. </el-select>
  261. </el-form-item>
  262. </el-form>
  263. <div slot="footer" class="dialog-footer">
  264. <el-button @click="dialogFormVisible1 = false">取 消</el-button>
  265. <el-button type="primary" :loading="btnLoading1" @click="save1">确 定</el-button>
  266. </div>
  267. </el-dialog>
  268. <el-dialog title="排序" width="550px" :visible.sync="dialogFormVisible2">
  269. <el-form label-width="130px" :model="topFrom"
  270. ref="topFrom"
  271. :rules="rules2">
  272. <el-form-item label="排序" prop="top">
  273. <el-input
  274. v-model.number="topFrom.top"
  275. class="item-width-300"
  276. ></el-input>
  277. </el-form-item>
  278. </el-form>
  279. <div slot="footer" class="dialog-footer">
  280. <el-button @click="dialogFormVisible2 = false">取 消</el-button>
  281. <el-button type="primary" :loading="btnLoading2" @click="save2">确 定</el-button>
  282. </div>
  283. </el-dialog>
  284. </div>
  285. </template>
  286. <script>
  287. import { debounce } from "@/utils/index";
  288. import { homeGoodsList,setHidden,listShowTypes,listAllTypes,setShowTypes,setTop,listHidden } from "@/api/goods";
  289. export default {
  290. name: "marketing",
  291. data() {
  292. return {
  293. date:'',
  294. title:'',
  295. tableData: [],
  296. tableData1: [],
  297. loading: false,
  298. btnLoading: false,
  299. dialogFormVisible: false,
  300. btnLoading1: false,
  301. dialogFormVisible1: false,
  302. btnLoading2: false,
  303. dialogFormVisible2: false,
  304. dialogFormVisible3: false,
  305. query: {
  306. distance:100000000,
  307. latitude:30.57447,
  308. longitude:103.92377,
  309. regionCode:520101,
  310. productType:'',
  311. page: 1,
  312. size: 10,
  313. },
  314. query1: {
  315. page: 1,
  316. size: 10,
  317. },
  318. total: 0,
  319. total1: 0,
  320. setQuery1:{
  321. type:''
  322. },
  323. options:[],
  324. setQuery:{
  325. "activityContent": "",
  326. "activityId": "",
  327. "activityMoney": 0,
  328. "endTime": "",
  329. "id": 0,
  330. "startTime": ""
  331. },
  332. topFrom:{
  333. pid:"",
  334. top:0,
  335. regionCode:''
  336. },
  337. tabList:[],
  338. rules:{
  339. activityId: [{ required: true, message: "请输入活动ID", trigger: "blur" }],
  340. activityMoney: [{ required: true, message: "请输入活动金额", trigger: "blur" }],
  341. startTime: [{ required: true, message: "请选择活动时间", trigger: "change" }],
  342. },
  343. rules1:{
  344. type: [{ required: true, message: "请选择产品类型", trigger: "change" }],
  345. },
  346. rules2:{
  347. top: [{ required: true, message: "请输入排序", trigger: "blur" }],
  348. },
  349. productType:{
  350. 'Web'
  351. :'链接',
  352. 'Recharge'
  353. :'充值类',
  354. 'Scenic'
  355. :'景区',
  356. 'ScenicTicket'
  357. :'景区门票',
  358. 'StudyTour'
  359. :'研学旅游',
  360. 'Hotel'
  361. :'酒店',
  362. 'HotelRoom'
  363. :'酒店房型',
  364. 'Cinema'
  365. :'电影院',
  366. 'MovieTicket'
  367. :'电影票',
  368. 'Restaurant'
  369. :'餐厅',
  370. 'RestaurantFood'
  371. :'餐厅美食',
  372. 'CarMaintain'
  373. :'汽车保养门店',
  374. 'CarMaintainGoods'
  375. :'汽车保养商品',
  376. 'CarMaintainService'
  377. :'汽车保养服务',
  378. 'Shop'
  379. :'店铺',
  380. 'ShopGoods'
  381. :'店铺商品',
  382. 'ShopService'
  383. :'店铺服务',
  384. 'Coupon'
  385. :'优惠券',
  386. 'PetrolStation'
  387. :'加油站',
  388. },
  389. pids:[],//拉黑
  390. pids1:[],// 解除
  391. };
  392. },
  393. watch: {
  394. date(val){
  395. if(val){
  396. this.setQuery.startTime = val[0]
  397. this.setQuery.endTime = val[1]
  398. }else{
  399. this.setQuery.startTime = ''
  400. this.setQuery.endTime = ''
  401. }
  402. },
  403. },
  404. methods: {
  405. handleSelectionChange(val){
  406. this.pids = val.map(item => {
  407. return { pid:item.pid,regionCode:item.regionCode}
  408. })
  409. },
  410. handleSelectionChange1(val){
  411. this.pids1 = val.map(item => {
  412. return { pid:item.pid,regionCode:item.regionCode}
  413. })
  414. },
  415. handleList(){
  416. this.dialogFormVisible3 = true
  417. this.query1.page = 1
  418. this.listHidden()
  419. },
  420. handleTab(val){
  421. this.query.productType = val
  422. this.handleSearch()
  423. },
  424. handleSetting(){
  425. this.dialogFormVisible1 = true
  426. },
  427. handleSearch(){
  428. this.query.page = 1;
  429. this.getList();
  430. },
  431. handleEdit(row){
  432. this.title = '编辑'
  433. this.dialogFormVisible = true
  434. this.setQuery = {
  435. "activityContent": row.activityContent,
  436. "activityId": row.activityId,
  437. "activityMoney": row.activityMoney,
  438. "endTime": row.endTime,
  439. "startTime": row.startTime,
  440. "id":row.id
  441. }
  442. this.date = [row.startTime, row.endTime]
  443. },
  444. handleAdd() {
  445. this.title = '添加'
  446. this.dialogFormVisible = true
  447. this.setQuery = {
  448. "activityContent": "",
  449. "activityId": "",
  450. "activityMoney": 0,
  451. "endTime": "",
  452. "startTime": ""
  453. }
  454. this.data = []
  455. },
  456. handleTop(row){
  457. this.topFrom.pid = row.pid
  458. this.dialogFormVisible2 = true
  459. this.topFrom.top = row.top
  460. this.topFrom.regionCode = row.regionCode
  461. },
  462. // 删除
  463. handleDel(item,hidden) {
  464. let str = ''
  465. if(hidden){
  466. str = '拉黑'
  467. }else{
  468. str = '取消拉黑'
  469. }
  470. this.$confirm(`此操作将${str}该数据, 是否继续?`, '提示', {
  471. confirmButtonText: '确定',
  472. cancelButtonText: '取消',
  473. type: 'warning'
  474. }).then(() => {
  475. setHidden({products:[{pid:item.pid,regionCode:item.regionCode}],hidden}).then(res=>{
  476. if(res.state == 'Success'){
  477. this.$notify({
  478. title: '成功',
  479. message: '操作成功',
  480. type: 'success'
  481. });
  482. if(hidden){
  483. this.getList()
  484. }else{
  485. this.listHidden()
  486. }
  487. }
  488. })
  489. })
  490. },
  491. handleBatch(hidden){
  492. let str = ''
  493. let products
  494. if(hidden){
  495. str = '拉黑'
  496. products = this.pids
  497. }else{
  498. str = '取消拉黑'
  499. products = this.pids1
  500. }
  501. this.$confirm(`此操作将批量${str}该数据, 是否继续?`, '提示', {
  502. confirmButtonText: '确定',
  503. cancelButtonText: '取消',
  504. type: 'warning'
  505. }).then(() => {
  506. setHidden({products,hidden}).then(res=>{
  507. if(res.state == 'Success'){
  508. this.dialogFormVisible3 = false
  509. this.pids = []
  510. this.$notify({
  511. title: '成功',
  512. message: '操作成功',
  513. type: 'success'
  514. });
  515. if(hidden){
  516. }else{
  517. // this.listHidden()
  518. }
  519. this.handleSearch()
  520. }
  521. })
  522. })
  523. },
  524. handleSizeChange(val) {
  525. this.query.page = 1;
  526. this.query.size = val;
  527. this.getList();
  528. },
  529. handleCurrentChange(val) {
  530. this.query.page = val;
  531. this.getList();
  532. },
  533. handleSizeChange1(val) {
  534. this.query1.page = 1;
  535. this.query1.size = val;
  536. this.listHidden();
  537. },
  538. handleCurrentChange1(val) {
  539. this.query1.page = val;
  540. this.listHidden();
  541. },
  542. search() {
  543. this.query.page = 1;
  544. this.getList();
  545. },
  546. getList() {
  547. this.loading = true
  548. let query = JSON.parse(JSON.stringify(this.query))
  549. query.page-=1
  550. homeGoodsList(query).then((res) => {
  551. this.loading = false
  552. if (res.state == "Success") {
  553. this.tableData = res.content.content;
  554. this.total = res.content.totalElements
  555. }
  556. });
  557. },
  558. listHidden(){
  559. let query = JSON.parse(JSON.stringify(this.query1))
  560. query.page-=1
  561. listHidden(query).then(res=>{
  562. if (res.state == "Success") {
  563. this.tableData1 = res.content.content;
  564. this.total1 = res.content.totalElements
  565. }
  566. })
  567. },
  568. listAllTypes(){
  569. listAllTypes().then((res) => {
  570. if (res.state == "Success") {
  571. res.content.map(item=>{
  572. this.options.push({
  573. value:item.productType,
  574. label:item.productTypeDesc
  575. })
  576. })
  577. }
  578. });
  579. },
  580. listShowTypes(){
  581. listShowTypes().then(res=>{
  582. if (res.state == "Success") {
  583. this.tabList = []
  584. res.content.map(item=>{
  585. this.tabList.push({
  586. value:item.productType,
  587. label:item.productTypeDesc
  588. })
  589. })
  590. this.setQuery1.type = res.content.map(item=>item.productType)
  591. }
  592. })
  593. },
  594. save(){
  595. this.$refs.setQuery.validate((v) => {
  596. if (v) {
  597. this.btnLoading = true
  598. addOrUpdateActivityXiaoju(this.setQuery).then(res=>{
  599. this.btnLoading = false
  600. if(res.state == 'Success'){
  601. this.dialogFormVisible = false
  602. this.$notify({
  603. title: '成功',
  604. message: '操作成功',
  605. type: 'success'
  606. });
  607. this.query.page = 1
  608. this.getList();
  609. }
  610. })
  611. }
  612. });
  613. },
  614. save1(){
  615. this.$refs.setQuery1.validate((v) => {
  616. if (v) {
  617. this.btnLoading1 = true
  618. setShowTypes(this.setQuery1.type).then(res=>{
  619. this.btnLoading1 = false
  620. if(res.state == 'Success'){
  621. this.dialogFormVisible1 = false
  622. this.$notify({
  623. title: '成功',
  624. message: '操作成功',
  625. type: 'success'
  626. });
  627. this.listShowTypes();
  628. this.handleSearch()
  629. }
  630. })
  631. }
  632. });
  633. },
  634. save2(){
  635. this.$refs.topFrom.validate((v) => {
  636. if (v) {
  637. this.btnLoading2 = true
  638. setTop(this.topFrom).then(res=>{
  639. this.btnLoading2 = false
  640. if(res.state == 'Success'){
  641. this.dialogFormVisible2 = false
  642. this.$notify({
  643. title: '成功',
  644. message: '操作成功',
  645. type: 'success'
  646. });
  647. this.getList();
  648. }
  649. })
  650. }
  651. });
  652. },
  653. },
  654. created() {
  655. this.getList();
  656. this.listAllTypes()
  657. this.listShowTypes()
  658. },
  659. };
  660. </script>
  661. <style lang="scss" >
  662. .homeGoodsSet {
  663. .tab-list{
  664. display: flex;
  665. align-items: center;
  666. padding-bottom: 20px;
  667. .tab{
  668. font-size: 14px;
  669. color: #222;
  670. cursor: pointer;
  671. }
  672. .tab+.tab{
  673. margin-left: 10px;
  674. }
  675. .tab.active{
  676. color: #2836fe;
  677. font-weight: bold;
  678. }
  679. }
  680. .info{
  681. display: flex;
  682. align-items: center;
  683. .small-img{
  684. width: 40px;
  685. height: 40px;
  686. }
  687. }
  688. }
  689. </style>