| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <template>
- <div class="app-container">
- <div class="filter-container">
- <div class="filter-view">
- <el-select
- class="filter-input"
- placeholder="All Status"
- clearable
- @change="onClickSearch"
- v-model="filters.pageVo.dataStatus">
- <el-option
- v-for="(item,index) in options.status"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- <div
- class="filter-flex-button"
- v-if="!$route.meta.onlyView">
- <el-button
- icon="el-icon-plus"
- type="primary"
- @click="onClickAdd">
- Create
- </el-button>
- </div>
- </div>
- </div>
- <el-table
- v-loading="loading"
- :data="table.list">
- <el-table-column
- align="center"
- label="Campaign ID"
- prop="userPk"
- min-width="120">
- <template slot-scope="{row}" >
- <span
- class="link-type"
- @click="onClickEdit(row)"
- v-if="!$route.meta.onlyView && row.dataStatus != 'Inactive'">
- {{ row.campaignId }}
- </span>
- <span v-else>{{ row.campaignId }}</span>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="Campaign Title"
- prop="campaignTitle"
- min-width="150"/>
- <el-table-column
- align="center"
- label="Start Date and End Date"
- prop="campaignDuration"
- min-width="180"/>
- <el-table-column
- align="center"
- label="Status"
- prop="dataStatus"
- min-width="80"/>
- <el-table-column
- align="center"
- label="No. of Sites"
- prop="assignedSiteCount"
- min-width="120"/>
- <el-table-column
- align="center"
- label="Created By"
- prop="createBy"
- min-width="120"/>
- <el-table-column
- align="center"
- label="Created On"
- prop="createTime"
- min-width="120"/>
- <el-table-column
- align="center"
- label="Action"
- min-width="80"
- v-if="!$route.meta.onlyView">
- <template v-slot="{ row }">
- <el-dropdown
- class="action-dropdown"
- @command="(v) => handleCommand(v, row)"
- v-if="row.dataStatus != 'Inactive'">
- <i class="el-icon-more icon-action"></i>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- command="assignSites">
- Assign Sites
- </el-dropdown-item>
- <el-dropdown-item
- command="onClickEdit">
- Edit
- </el-dropdown-item>
- <el-dropdown-item
- command="onClickDelete">
- Delete
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </template>
- </el-table-column>
- </el-table>
- <div class="right">
- <pagination
- v-show="table.total > 0"
- :total="table.total"
- :page.sync="filters.pageNo"
- :limit.sync="filters.pageSize"
- @pagination="getTableData" />
- </div>
- <DialogAssignment
- v-bind="dialogAssign"
- @hide="hideAssignDialog"/>
- </div>
- </template>
- <script>
- import TableAction from '@/components/TableAction.vue'
- import Pagination from '@/components/Pagination'
- import DialogAssignment from './assignment.vue'
- import charge from '../../http/api/charge'
- import api from '../../api/campaign.js'
- export default {
- data() {
- return {
- loading: false,
- filters: {
- pageNo: 1,
- pageSize: 10,
- pageVo: {
- criteria: "",
- dataStatus: ""
- }
- },
- table: {
- list: [],
- total: 0
- },
- options: {
- status: [],
- types: []
- },
- dialogAssign: {
- item: {},
- visible: false
- }
- };
- },
- components: { Pagination, TableAction, DialogAssignment },
- created() {
- this.getStatusOptions();
- this.onClickSearch();
- },
- methods: {
- onClickSearch() {
- this.filters.pageNo = 1
- this.getTableData()
- },
- getStatusOptions() {
- charge.getStatusOptions().then(res => {
- this.options.status = res.data;
- }).catch(err => {
- this.$message.error(err);
- })
- },
- getTableData() {
- this.loading = true;
- api.getCampaignPages(this.filters).then(res => {
- if (res.data && res.total) {
- this.table.total = res.total;
- this.table.list = res.data;
- } else {
- this.table.total = 0;
- this.table.list = [];
- }
- }).catch(err => {
- this.$message({
- type: 'error',
- message: err
- })
- this.table.total = 0;
- this.table.list = [];
- }).finally(() => {
- this.loading = false;
- })
- },
- onClickAdd() {
- this.$router.push({
- path: "/marketing-management/campaign/create"
- })
- },
- handleCommand(cb, item) {
- this[cb](item)
- },
- assignSites(row) {
- if (row) {
- this.dialogAssign.item = row;
- this.dialogAssign.visible = true;
- }
- },
- hideAssignDialog(e) {
- this.dialogAssign.item = {};
- this.dialogAssign.visible = false;
- if (e) {
- this.getTableData();
- }
- },
- onClickEdit(row) {
- this.$router.push({
- path: "/marketing-management/campaign/update/" + row.campaignId
- })
- },
- onClickDelete(row) {
- this.$confirm('Are you sure you want to delete this campaign?', 'Delete', {
- confirmButtonText: 'OK',
- cancelButtonText: 'Cancel',
- type: 'warning'
- }).then(res => {
- this.onDeleteCampaign(row.campaignId)
- })
- },
- onDeleteCampaign(id) {
- this.loading = true;
- api.deleteCampaign(id).then(res => {
- this.$message({
- type: 'success',
- message: "Delete success."
- })
- this.getTableData()
- }).catch(err => {
- this.$message({
- type: 'error',
- message: err
- })
- this.loading = false;
- })
- }
- }
- }
- </script>
- <style scoped>
- .filter-input {
- min-width: 100px;
- max-width: 300px;
- }
- </style>
|