123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- <template>
- <div class="marketing app-container">
- <div class="search">
- <div>
- <el-input
- v-model="query.key"
- size="small"
- placeholder="请输入ID或活动名称"
- clearable
- class="item-width-200 "
- ></el-input>
- <el-button
- class="ml10"
- type="primary"
- size="small"
- icon="el-icon-search"
- @click="handleSearch"
- >
- 搜索
- </el-button>
- </div>
- <el-button class="add-btn" type="primary" size="small" v-if="btnAuthObj.addActivity" @click="handleAdd"
- >添加</el-button
- >
- </div>
- <el-table
- :data="tableData"
- tooltip-effect="dark"
- border
- v-loading="loading"
- style="width: 100%"
- >
- <el-table-column
- align="center"
- label="活动ID"
- prop="activityId"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- align="center"
- label="活动金额"
- prop="activityMoney"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- align="center"
- label="剩余金额"
- prop="residueMoney"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- align="center"
- label="活动内容"
- prop="activityContent"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- align="center"
- label="创建时间"
- prop="createTime"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column align="center" label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="small" v-if="btnAuthObj.editActivity" @click="handleEdit(scope.row)"
- >编辑</el-button
- >
- <el-button type="text" size="small" v-if="btnAuthObj.delActivity" @click="handleDel(scope.row.id)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <div class="page-box">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- background
- :current-page="query.currentPage"
- :page-sizes="[10, 20, 30, 40]"
- :page-size="query.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- <el-dialog :title="title" width="550px" :visible.sync="dialogFormVisible">
- <el-form label-width="130px" :model="setQuery"
- ref="setQuery"
- :rules="rules">
- <el-form-item label="活动ID" prop="activityId">
- <el-input
- v-model="setQuery.activityId"
- class="item-width-300"
- ></el-input>
- </el-form-item>
- <el-form-item label="活动金额" prop="activityMoney">
- <el-input
- v-model.number="setQuery.activityMoney"
- class="item-width-300"
- ></el-input>
- </el-form-item>
- <el-form-item label="活动有效期" prop="startTime">
- <el-date-picker
- v-model="date"
- size="small"
- class="item-width-350 ml10"
- value-format="yyyy-MM-dd hh:mm:ss"
- type="datetimerange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期">
- </el-date-picker>
- </el-form-item>
- <el-form-item label="活动内容" prop="activityContent">
- <el-input
- v-model.number="setQuery.activityContent"
- class="item-width-300"
- ></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFormVisible = false">取 消</el-button>
- <el-button type="primary" :loading="btnLoading" @click="save">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
-
- <script>
- import { debounce } from "@/utils/index";
- import { activityXiaojuList,delActivityXiaoju,addOrUpdateActivityXiaoju } from "@/api/marketing";
- export default {
- name: "marketing",
- data() {
- return {
- date:'',
- title:'',
- tableData: [],
- loading: false,
- btnLoading: false,
- dialogFormVisible: false,
- query: {
- key:'',
- currentPage: 1,
- pageSize: 10,
- },
- total: 0,
- setQuery:{
- "activityContent": "",
- "activityId": "",
- "activityMoney": 0,
- "endTime": "",
- "id": 0,
- "startTime": ""
- },
- rules:{
- activityId: [{ required: true, message: "请输入活动ID", trigger: "blur" }],
- activityMoney: [{ required: true, message: "请输入活动金额", trigger: "blur" }],
- startTime: [{ required: true, message: "请选择活动时间", trigger: "change" }],
- }
- };
- },
- watch: {
- date(val){
- if(val){
- this.setQuery.startTime = val[0]
- this.setQuery.endTime = val[1]
- }else{
- this.setQuery.startTime = ''
- this.setQuery.endTime = ''
- }
- },
- },
- methods: {
- handleSearch(){
- this.query.currentPage = 1;
- this.getList();
- },
- handleEdit(row){
- this.title = '编辑'
- this.dialogFormVisible = true
- this.setQuery = {
- "activityContent": row.activityContent,
- "activityId": row.activityId,
- "activityMoney": row.activityMoney,
- "endTime": row.endTime,
- "startTime": row.startTime,
- "id":row.id
- }
- this.date = [row.startTime, row.endTime]
- },
- handleAdd() {
- this.title = '添加'
- this.dialogFormVisible = true
- this.setQuery = {
- "activityContent": "",
- "activityId": "",
- "activityMoney": 0,
- "endTime": "",
- "startTime": ""
- }
- this.date = []
- },
- // 删除
- handleDel(id) {
- this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- delActivityXiaoju({id}).then(res=>{
- if(res.state == 'Success'){
- this.$notify({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- this.getList()
- }
- })
- })
- },
- handleSizeChange(val) {
- this.query.currentPage = 1;
- this.query.pageSize = val;
- this.getList();
- },
- handleCurrentChange(val) {
- this.query.currentPage = val;
- this.getList();
- },
- search() {
- this.query.currentPage = 1;
- this.getList();
- },
- getList() {
- this.loading = true
- activityXiaojuList(this.query).then((res) => {
- this.loading = false
- if (res.state == "Success") {
- this.tableData = res.content.records;
- this.total = res.content.total
- }
- });
- },
- save(){
- this.$refs.setQuery.validate((v) => {
- if (v) {
- this.btnLoading = true
- addOrUpdateActivityXiaoju(this.setQuery).then(res=>{
- this.btnLoading = false
- if(res.state == 'Success'){
- this.dialogFormVisible = false
- this.$notify({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- this.query.currentPage = 1
- this.getList();
- }
- })
-
- }
- });
- }
- },
- created() {
- this.getList();
- },
- };
- </script>
-
- <style lang="scss" >
- .marketing {
- }
- </style>
-
|