123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <template>
- <div>
- <a-card size="small" :bordered="false" class="promotion-wrap searchBoxNormal">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="创建时间">
- <rangeDate ref="rangeCreateDate" :value="createDate" @change="dateCreateChange" />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="促销名称">
- <a-input id="promotion-promotionName" v-model.trim="queryParam.name" allowClear placeholder="请输入促销名称"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="促销状态">
- <v-select
- v-model="queryParam.publishState"
- ref="saleStatus"
- id="promotion-saleStatus"
- code="PROMO_STATE"
- placeholder="请选择促销状态"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <span class="table-page-search-submitButtons">
- <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
- <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
- </span>
- </a-col>
- </a-row>
- </a-form>
- </div>
- </a-card>
- <!-- 列表 -->
- <a-card size="small" :bordered="false">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 操作按钮 -->
- <div class="table-operator" v-if="$hasPermissions('B_promotionManagementAdd')">
- <a-button type="primary" @click="openAddModal = true">新增</a-button>
- </div>
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+70+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 促销状态 -->
- <template slot="stateVal" slot-scope="text, record">
- <span>{{ record.publishState==='UNPUBLISH'?'未发布':record.publishState==='PUBLISH'?'已发布':record.publishState==='CLOSE'?'已关闭':'已结束' }}</span>
- </template>
- <!-- 促销时间 -->
- <template slot="promotionTime" slot-scope="text, record">
- <span>{{ record.activeDateStart }}至{{ record.activeDateEnd }}</span>
- </template>
- <!-- 参与客户 -->
- <template slot="joinCustomers" slot-scope="text, record">
- <span @click="handleCustomers(record)" v-if="record.dealerSnList&&record.dealerSnList.length>0">共有<span class="link-bule">{{ record.dealerSnList.length }}</span>个客户</span>
- <span v-else>共有0个客户</span>
- </template>
- <!-- 促销描述 -->
- <template slot="salesDesc" slot-scope="text, record">
- <a-tooltip placement="rightBottom" v-if="record.description&&record.description.length>14">
- <template slot="title">
- <span>{{ record.description }}</span>
- </template>
- <div @click="promotionDesc(record)" class="link-bule">{{ record.description }}</div>
- </a-tooltip>
- <div v-else-if="!record.description" class="desc">--</div>
- <div v-else @click="promotionDesc(record)" class="link-bule">{{ record.description }}</div>
- </template>
- <!-- 促销展示 -->
- <template slot="salesShow" slot-scope="text, record">
- <div @click="handleSaleShow(record)" v-if="record.contentType!='LINK'&&record.imageSet && record.imageSet.length>0">
- <img :src="record.imageSet[0]" alt="图片走丢啦" width="60" />
- </div>
- <div v-else-if="record.contentType=='LINK'&&record.imageSet && record.imageSet.length>0">
- <img :src="record.imageSet[0]" alt="图片走丢啦" width="60" />
- </div>
- <span v-else>--</span>
- </template>
- <!-- 操作 -->
- <!-- state状态 END已结束 CLOSE已关闭 PUBLISH 已发布 UNPUBLISH 未发布 -->
- <template slot="action" slot-scope="text, record">
- <div>
- <a-button
- size="small"
- type="link"
- class="button-warning"
- @click="promotionEdit(record)"
- v-if="(record.publishState=='UNPUBLISH' || record.publishState=='CLOSE') && $hasPermissions('B_promotionManagementAdd')"
- id="promotion-edit-btn">编辑</a-button>
- <a-button
- size="small"
- type="link"
- class="button-warning"
- @click="handleRelease(record,'edit')"
- v-if="((record.publishState=='PUBLISH'&&record.content!='/pagesB/promoDetail')||(record.publishState=='PUBLISH'&&record.content==='/pagesB/promoDetail'&&record.dealerEditFlag==='0') || record.publishState=='CLOSE')&&$hasPermissions('B_promotionManagementContent')"
- id="promotion-modify-btn">发布修改</a-button>
- <a-button
- size="small"
- type="link"
- class="button-success"
- @click="handleSee(record)"
- v-if="(record.publishState=='PUBLISH')&&$hasPermissions('B_promotionManagementContent')"
- id="promotion-modify-btn">查看</a-button>
- <a-button
- size="small"
- type="link"
- class="button-info"
- @click="handleRelease(record,'add')"
- v-if="record.publishState=='UNPUBLISH'&&$hasPermissions('B_promotionManagementContent')"
- id="promotion-release-btn">发布</a-button>
- <a-button
- size="small"
- type="link"
- class="button-error"
- v-if="record.publishState=='UNPUBLISH'&&$hasPermissions('B_promotionManagementDel')"
- @click="handleDel(record)"
- id="promotion-del-btn">删除</a-button>
- <span v-if="record.publishState=='End'">--</span>
- </div>
- </template>
- </s-table>
- </a-spin>
- <!-- 参与客户 -->
- <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
- <!-- 促销描述 -->
- <promotion-desc-modal :openModal="openDescModal" :con="descCon" @close="openDescModal = false;descCon=''"></promotion-desc-modal>
- <!-- 促销展示 -->
- <promotion-show-modal ref="showModal" :openModal="openShowModal" @close="openShowModal = false"></promotion-show-modal>
- <!-- 新增 -->
- <addModal :openModal="openAddModal" :itemId="itemId" @close="closeAddModal" @ok="$refs.table.refresh()"></addModal>
- <!-- 查看 -->
- <detail-Modal :openModal="openDetailModal" :itemSn="itemId" @close="closeDetailModal" @ok="$refs.table.refresh()" />
- </a-card>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import lookUpCustomersModal from './lookUpCustomersModal'
- import promotionDescModal from './promotionDescModal'
- import promotionShowModal from './promotionShowModal'
- import addModal from './addModal'
- import detailModal from './detailModal'
- import { updateShowFlag } from '@/api/promoTerminal'
- import { promoActiveList, promoActiveDel } from '@/api/promoActive'
- export default {
- name: 'PromotionList',
- mixins: [commonMixin],
- components: { STable, VSelect, rangeDate, lookUpCustomersModal, promotionShowModal, promotionDescModal, addModal, detailModal },
- data () {
- return {
- spinning: false,
- tableHeight: 0,
- disabled: false, // 查询、重置按钮是否可操作
- openCustomerModal: false,
- openDescModal: false,
- openShowModal: false,
- openAddModal: false,
- openDetailModal: false,
- createDate: [], // 创建时间
- itemId: '',
- descCon: '', // 描述内容
- pageType: '', // 发布类型 add 促销发布 edit 发布修改
- dealerSn: [],
- // 查询参数
- queryParam: {
- beginDate: undefined,
- endDate: undefined,
- name: '',
- showFlag: undefined,
- publishState: undefined
- },
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- const params = Object.assign(parameter, this.queryParam)
- return promoActiveList(params).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- data.list[i].isEnable = data.list[i].showFlag + '' === '1'
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- },
- columns: [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '促销名称', dataIndex: 'name', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '标题', dataIndex: 'title', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '8%', align: 'center' },
- { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center' },
- { title: '促销描述', scopedSlots: { customRender: 'salesDesc' }, width: '12%', align: 'center' },
- { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '6%', align: 'center' },
- // { slots: { title: 'arrowFalgTitle' }, scopedSlots: { customRender: 'arrowFalg' }, width: '6%', align: 'center' },
- { title: '促销状态', scopedSlots: { customRender: 'stateVal' }, width: '6%', align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
- ]
- }
- },
- methods: {
- // 关闭添加促销活动弹窗
- closeAddModal () {
- this.openAddModal = false; this.itemId = ''
- },
- // 参与经销商
- handleCustomers (row) {
- this.openCustomerModal = true
- this.$nextTick(() => {
- this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
- })
- },
- // 创建时间 change
- dateCreateChange (date) {
- this.queryParam.beginDate = date[0]
- this.queryParam.endDate = date[1]
- },
- // 促销展示
- handleSaleShow (record) {
- this.openShowModal = true
- this.$nextTick(() => {
- this.$refs.showModal.pageInit({ type: record.contentType, con: record.content })
- })
- },
- // 修改显示状态
- changeFlagHandle (record) {
- const _data = {
- sn: record.promoActiveSn,
- showFlag: record.isEnable ? '1' : '0'
- }
- this.spinning = true
- updateShowFlag(_data).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.table.refresh()
- this.spinning = false
- } else {
- this.$refs.table.refresh()
- this.spinning = false
- }
- })
- },
- // 促销编辑
- promotionEdit (item) {
- this.itemId = item.promoActiveSn
- this.$nextTick(() => {
- this.openAddModal = true
- })
- },
- // 促销描述
- promotionDesc (row) {
- this.descCon = row.description
- this.$nextTick(() => {
- this.openDescModal = true
- })
- },
- // 删除促销活动
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '点击确定,该内容将会被删除,不可再恢复!',
- centered: true,
- onOk () {
- _this.spinning = true
- promoActiveDel({ sn: row.promoActiveSn }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- resetSearchForm () {
- this.$refs.rangeCreateDate.resetDate(this.createDate)
- this.queryParam.beginDate = undefined
- this.queryParam.endDate = undefined
- this.queryParam.name = ''
- this.queryParam.showFlag = undefined
- this.queryParam.publishState = undefined
- this.$refs.table.refresh(true)
- },
- // 促销发布
- handleRelease (row, type) {
- const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
- this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
- },
- // 打开详情
- handleSee (row) {
- this.openDetailModal = true
- this.itemId = row.promoActiveSn
- },
- // 关闭详情
- closeDetailModal () {
- this.openDetailModal = false
- this.itemId = ''
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 240
- }
- },
- watch: {
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- this.$refs.table.refresh()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less" scoped>
- .font1{
- color:#39f;
- }
- .desc{
- width: 100%;
- padding:0 10px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- box-sizing: border-box;
- -webkit-line-clamp: 3;
- -webkit-box-orient: vertical;
- }
- </style>
|