| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666 |
- <style>
- .table-body {
- padding: 20px 20px;
- background-color: #fff;
- }
- .table-body .top-input {
- margin-top: 34px;
- }
- .input-item {
- width: 200px;
- margin-right: 20px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- /* #app .table-body .el-table .el-button {
- border-radius: 16px;
- } */
- .create {
- height: 36px;
- line-height: 36px;
- float: right;
- color: #BCBCBC;
- margin-left: 20px;
- }
- .name {
- cursor: pointer;
- color: #49A9FF;
- }
- .el-input-group__append {
- /* background-color: #fff; */
- }
- /* 卡片 */
- .plugin-list {
- margin: 0 0 0 -20px;
- /* padding-right: 100px; */
- display: flex;
- flex-wrap: wrap;
- }
- .plugin-list .plugin-item {
- width: 20%;
- min-width: 400px;
- }
- .plugin-item {
- border: 1px solid #ebebeb;
- background: #FFFFFF;
- box-shadow: 3px 5px 15px rgba(80, 80, 80, 0.16);
- opacity: 1;
- border-radius: 5px;
- padding: 20px;
- margin: 0 0 20px 20px;
- transition: 250ms;
- position: relative;
- /* min-width: 300px; */
- }
- .plugin-item .item-status {
- position: absolute;
- top: 0;
- right: 0;
- width: 94px;
- height: 30px;
- background: #E8EAEC;
- opacity: 1;
- border-radius: 0px 5px 0px 5px;
- font-size: 14px;
- font-family: Microsoft YaHei;
- font-weight: 400;
- line-height: 30px;
- color: #9398A4;
- text-align: center;
- }
- .item-status-permanent {
- width: 94px;
- }
- .item-status-effective {
- width: 164px;
- }
- .plugin-item .item-info {
- display: flex;
- align-items: center;
- }
- /* .plugin-item .item-info .item-right{
- min-width: 500px;
- } */
- .plugin-item .item-btns {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- margin-top: 12px;
- }
- .plugin-item .mall-logo {
- width: 70px;
- height: 70px;
- margin-right: 12px;
- }
- .plugin-item .mall-logo img {
- width: 100%;
- height: 100%;
- display: block;
- border-radius: 50%;
- }
- .plugin-item .display-name {
- font-size: 18pt;
- margin-top: 10px;
- margin-bottom: 4px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- line-height: 30px;
- color: #3F495D;
- opacity: 1;
- width: 200px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .plugin-item .name {
- color: #909399;
- }
- .plugin-item:hover {
- cursor: pointer;
- border-color: #bfddff;
- }
- /* .plugin-item:hover .display-name {
- color: #409EFF;
- } */
- .plugin-item .plugin-option-btn {
- height: 25px;
- width: 25px;
- font-size: 12px;
- padding: 0;
- }
- .plugin-item .detail-option.detail-option {
- color: #909399;
- background: #F2F6FC;
- }
- .plugin-item .detail-option:hover {
- color: #fff;
- background: #909399;
- }
- .label {
- padding-right: 10px;
- }
- .el-collapse-item__header {
- color: #0A54EA;
- }
- .el-collapse-item__arrow {
- margin: 0;
- }
- .label_conf {
- line-height: 35px;
- margin-left: 10px;
- }
- .line_msg {
- width: 100%;
- height: 1px;
- background-color: #d9d6d6;
- margin-bottom: 20px;
- }
- .type_conf {
- font-weight: 600;
- margin-bottom: 20px;
- }
- .msg_title {
- padding-left: 5%;
- width: 12%;
- float: left;
- text-align: right;
- line-height: 35px;
- }
- .conf_content {
- width: 60%;
- float: left;
- }
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" style="border:0;min-width: 1200px;"
- body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <div>
- <span>{{cate_name}}</span>
- <div style="float: right; margin: -5px 0">
- <!-- <el-button type="primary" size="small" @click="handleEdit('')">添加标签</el-button>-->
- <el-button type="primary" size="small" @click="open(0)">添加标签</el-button>
- </div>
- </div>
- </div>
- <div class="table-body el-input--small">
- <template>
- <div>
- <el-table :data="list" style="width: 100%;margin-bottom: 20px;" row-key="id">
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- >
- </el-table-column>
- <el-table-column prop="name" label="名称" align="center">
- <template slot-scope="scope">
- <span style="margin-left: 10px">{{ scope.row.name }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="user_num" label="会员数量" align="center">
- <template slot-scope="scope">
- <el-button type="text" @click="navUserList(scope.row.cate_id+'_'+scope.row.id)"
- class="all_text">
- <span style="margin-left: 10px; cursor: pointer;">{{ scope.row.user_num }}</span>
- </el-button>
- </template>
- </el-table-column>
- <el-table-column prop="content" label="达标条件" align="center">
- <template slot-scope="scope">
- <span style="margin-left: 10px">{{ scope.row.content }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="content" label="标签颜色" align="center">
- <template slot-scope="scope">
- <el-color-picker v-model="scope.row.color" disabled></el-color-picker>
- </template>
- </el-table-column>
- <el-table-column prop="created_at" label="时间" align="center">
- <template slot-scope="scope">
- <span style="margin-left: 10px">{{ scope.row.created_at|dateTimeFormat('Y-m-d H:i:s') }}</span>
- </template>
- </el-table-column>
- <el-table-column label="启用状态" width="120" align="center">
- <template slot-scope="scope">
- <el-switch
- :active-value="1"
- :inactive-value="0"
- @change="handle('status', scope.row)"
- v-model="scope.row.status">
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center">
- <template slot-scope="scope">
- <el-button type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px"
- @click="open(scope.row.id)">
- 编辑
- </el-button>
- <el-button style="margin-left: 10px;margin-top: 10px" type="text" class="set-el-button"
- size="mini" circle @click="handleDelete(scope.$index, scope.row)">
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <div style="text-align: right;margin: 20px 0;">
- </div>
- </div>
- </el-card>
- <el-dialog :visible.sync="dialogVisible" width="30%" :before-close="handleClose" :close-on-click-modal="false">
- <template>
- <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="100px"
- @submit.native.prevent>
- <el-card shadow="never">
- <el-col :span="50">
- <el-form-item label="标签名称" prop="name">
- <el-input v-model="ruleForm.name" placeholder="请输入标签名称,最多20个字"></el-input>
- </el-form-item>
- <el-form-item :label="content" v-if="ruleForm.cate_id!=2&&ruleForm.cate_id!=3" prop="condition.num">
- <el-input v-model="ruleForm.condition.num" placeholder="">
- <template slot="append">/ {{unit}}</template>
- </el-input>
- <span>具体值输入整数:如:1;范围,请按如下格式输入:10-100;</span>
- </el-form-item>
- <el-form-item :label="content" v-if="ruleForm.cate_id==2||ruleForm.cate_id==3">
- <el-select v-model="ruleForm.condition.num" placeholder="请选择" @change="selectChange">
- <el-option
- v-for="item in level_arr"
- :key="item.id"
- :label="item.name"
- :value="item.level">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="标签颜色">
- <el-color-picker v-model="ruleForm.color"></el-color-picker>
- </el-form-item>
- <el-form-item label="是否启用">
- <el-switch v-model="ruleForm.status" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- </el-col>
- </el-card>
- <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;"
- @click="store('ruleForm')" size="small">确 定
- </el-button>
- </el-form>
- </template>
- </el-dialog>
- </div>
- <script>
- new Vue({
- el: '#app',
- data() {
- return {
- dialogAddgsVisible: false,
- activeName: "1",
- list: [],
- pagination: null,
- page: 1,
- pageCount: 0,
- time: [],
- search: {
- name: '',
- date_start: null,
- date_end: null,
- cate_id: 1,
- },
- cate_id: 0,
- url: '',
- cate_name: '',
- loading: false,
- btnLoading: false,
- dialogVisible: false,
- ruleForm: {
- id: '',
- cate_id: 0,
- name: '',
- color: '',
- condition: {
- num: ''
- },
- status: 1,
- source_table: '',
- source_table_id: 0,
- },
- rules: {
- name: [{
- required: true,
- message: '请输入标签名称',
- trigger: 'change'
- },
- {
- validator: (rule, value, callback) => {
- if (value.length > 20 || value.length < 0) {
- callback('最大长度在1-20个字内');
- }
- callback();
- }
- },
- ],
- 'condition.num': [
- { required: true, message: '请输入具体数值', trigger: 'blur'},
- {
- validator: (rule, value, callback) => {
- if (value !== undefined && value !== null && value !== '') {
- // 处理范围值情况
- if (value.toString().includes('-')) {
- const range = value.toString().split('-');
- if (range.length === 2 && !isNaN(range[0]) && !isNaN(range[1]) && range[0] > 0 && range[1] > 0) {
- callback();
- } else {
- callback('范围格式错误,请输入类似 10-100 的格式');
- }
- } else if (parseFloat(value) <= 0) {
- callback(this.content + '金额必须大于0');
- } else {
- callback();
- }
- } else {
- callback();
- }
- }
- }
- ],
- },
- content: "",
- unit: "",
- route: "",
- level_arr: [],
- levelMap: [],
- label_action: "",
- }
- },
- created() {
- var url_r = window.location.search;
- url_r = url_r.replace('?r=', '')
- url_r = url_r.replace('%2F', '/')
- url_r = url_r.replace('%2F', '/')
- this.url = url_r
- var url_split = this.url.split('/');
- this.label_action = url_split[2]
- console.log(this.label_action,'========')
- this.getList({});
- },
- methods: {
- searchs() {
- this.page = 1;
- this.getList();
- },
- pageChange(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- getList() {
- let self = this;
- self.listLoading = true;
- // 检查是否选择了搜索时间
- if (!self.time) {
- self.search.date_start = '';
- self.search.date_end = '';
- } else {
- self.search.date_start = self.time[0];
- self.search.date_end = self.time[1];
- }
- request({
- method: 'post',
- params: {
- r: this.url,
- },
- data: {
- page: self.page,
- name: self.search.name,
- date_start: self.search.date_start,
- date_end: self.search.date_end,
- type: self.search.type,
- },
- }).then(e => {
- self.listLoading = false;
- self.list = e.data.data.list;
- this.pagination = e.data.data.pagination;
- this.pagination.pageSize = e.data.data.page_size;
- this.pagination.total_count = e.data.data.count;
- this.cate_id = e.data.data.cate_id;
- this.cate_name = e.data.data.cate_name;
- }).catch(e => {
- console.log(e);
- });
- },
- handle(type, data = null) {
- let id = data ? parseInt(data.id) : '';
- let status = data ? parseInt(data.status) : '';
- switch (type) {
- case 'status':
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'mall/member-label/'+ this.label_action +'-switch-status',
- },
- method: 'post',
- data: {
- id: id,
- status: status,
- }
- }).then(e => {
- self.listLoading = false;
- if (e.data.code === 0) {
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- self.getList();
- }).catch(e => {
- console.log(e);
- });
- break;
- default:
- break;
- }
- },
- handleEdit(id) {
- navigateTo({
- r: 'mall/member-label/'+ this.label_action +'-edit',
- id: id,
- cate_id: this.cate_id,
- });
- },
- handleDelete(index, row) {
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
- this.$request({
- params: {
- r: 'mall/member-label/'+ this.label_action +'-del',
- id: row.id,
- cate_id: this.cate_id,
- status: -1,
- },
- }).then(e => {
- if (e.data.code == 0) {
- this.$message({
- message: e.data.msg,
- type: 'success'
- });
- navigateTo({
- r: 'mall/member-label/' + e.data.data.route
- });
- } else {
- this.$message({
- message: e.data.msg,
- type: 'error'
- });
- }
- }).catch(e => {
- });
- });
- },
- handleClose(done) {
- this.ruleForm.id = 0;
- this.ruleForm.cate_id = '';
- this.ruleForm.name = '';
- this.ruleForm.color = '';
- this.ruleForm.condition = {
- num: '',
- name: ""
- };
- done();
- },
- //进行验证
- store(formName) {
- let formData = JSON.stringify(this.dataForm);
- //进行验证
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.btnLoading = true;
- request({
- params: {
- r: 'mall/member-label/'+ this.label_action +'-edit',
- },
- method: 'post',
- data: {
- form: this.ruleForm,
- }
- }).then(e => {
- this.btnLoading = false;
- if (e.data.code == 0) {
- this.$message.success(e.data.msg);
- this.dialogVisible = false;
- this.getList();
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.$message.error(e);
- this.btnLoading = false;
- })
- } else {
- this.btnLoading = false;
- return false;
- }
- });
- },
- loadData(id, cate_id) {
- this.loading = true;
- request({
- params: {
- r: 'mall/member-label/'+ this.label_action +'-edit',
- id: id,
- cate_id: cate_id
- },
- method: 'get'
- }).then(e => {
- this.loading = false;
- if (e.data.code == 0) {
- if (id) {
- this.ruleForm = e.data.data.detail;
- }
- this.content = e.data.data.content;
- this.unit = e.data.data.unit;
- this.route = e.data.data.route;
- this.cate_name = e.data.data.cate_name;
- this.level_arr = e.data.data.level_arr;
- this.levelMap = e.data.data.levelMap;
- this.ruleForm.source_table = e.data.data.levelTable;
- }
- }).catch(e => {
- this.loading = false;
- })
- },
- open(id) {
- this.dialogVisible = true;
- this.ruleForm.id = id;
- this.ruleForm.cate_id = this.cate_id;
- this.loadData(id, this.cate_id);
- },
- navUserList(memberLabelIds) {
- this.$navigate({
- r: 'mall/user/index',
- memberLabelIds: memberLabelIds
- })
- },
- selectChange(v) {
- this.ruleForm.source_table_id = this.levelMap[v]
- }
- },
- });
- </script>
|