From 7402b8430f10471f93d5de4b93522461d2dc4974 Mon Sep 17 00:00:00 2001 From: aBin Date: Wed, 23 Feb 2022 17:19:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=B8=E9=87=8F=E5=88=97=E8=A1=A8=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 3 + src/views/lists/form.vue | 7 +- src/views/lists/index.vue | 239 ++++++++++++++++---------------------- 3 files changed, 107 insertions(+), 142 deletions(-) diff --git a/src/main.js b/src/main.js index 080e102..a45a3fd 100644 --- a/src/main.js +++ b/src/main.js @@ -10,6 +10,7 @@ Vue.use(VueDND) import VueVideoPlayer from 'vue-video-player' import 'video.js/dist/video-js.css' +import moment from 'moment'; //导入文件 Vue.use(VueVideoPlayer, /* { options: global default options, @@ -17,6 +18,8 @@ Vue.use(VueVideoPlayer, /* { } */) import Cookies from 'js-cookie' +Vue.prototype.$moment = moment; //赋值使用 + Vue.use(Element, { size: Cookies.get('size') || 'medium', // set element-ui default size // i18n: (key, value) => i18n.t(key, value) diff --git a/src/views/lists/form.vue b/src/views/lists/form.vue index c002c8d..17645f7 100644 --- a/src/views/lists/form.vue +++ b/src/views/lists/form.vue @@ -9,7 +9,7 @@ - + 查询 @@ -26,9 +26,10 @@ return { formInline: { locationId: '', - distribution: '', + description: '', }, - locationId: '' + locationId: '', + description: '', } }, methods: { diff --git a/src/views/lists/index.vue b/src/views/lists/index.vue index 531166d..c4860e0 100644 --- a/src/views/lists/index.vue +++ b/src/views/lists/index.vue @@ -1,60 +1,72 @@ @@ -84,10 +96,12 @@ id: '', isEdit: false, lists: [], + dataList: {}, params: { - from: 0, - size: pageSize, - locationId: '' + locationId: '', + description: '', + pageNum: 1, + pageSize: 10, } } }, @@ -99,33 +113,64 @@ DetailsOfDistribution }, methods: { + // 搜索查询按钮 submitForm(res) { this.params = { ...this.params, - locationId: res.locationId, + pageNum: 1, description: res.description, + locationId: res.locationId, }; this.getList() }, - resetForm() { - this.params = { - from: 0, - size: pageSize, - locationId: '' - }; - this.getList() - }, - getList() { - GET_LIST(this.params).then(res => { - console.log('res: ', res); - // res.map((item) => { - // item.stateText = item.enabled ? '生效中' : '失效中'; - // item.locationName = item.province + item.city + item.district + item.name; - // return item - // }); - // this.lists = res + // 获取数组 + async getList() { + await GET_LIST(this.params).then(res => { + const { code,msg,data } = res + if(code === 200) { + this.lists = data.list + this.dataList = data + } else { + Alert(msg) + } }); }, + // 将常量值JSON字符串解析 + getValue(value) { + const arr = JSON.parse(value) + let itemList = [] + if(Array.isArray(arr)) { + for(let i = 0; i < arr.length; i++) { + const item = arr[i] + for(let key in item) { + if(Array.isArray(item[key])) { + const obj = { + title: key, + value: item[key] + } + itemList.push(obj) + } else { + const obj = { + title: item.content, + value: item.url + } + itemList.push(obj) + break + } + } + } + } else { + for(let key in arr) { + const obj = { + title: key, + value: arr[key] + } + itemList.push(obj) + } + } + console.log('itemList',itemList) + return itemList + }, /** * 分页 @@ -144,90 +189,6 @@ this.id = id; }, - /** - * 状态操作 - */ - suspensionOfRelease(id, enabled) { - if (enabled) { - this.PUBLISHED(id) - } else { - this.PAUSEDANDPENDING(id) - } - }, - /** - * 已发布 - * @constructor - */ - PUBLISHED(id) { - let params = { - id - }; - DISABLE_FIELD_LIST(params).then((res) => { - let lists = []; - this.lists.map((item) => { - if (item.id == id) { - item.stateText = '失效中'; - item.enabled = false; - } - lists.push(item); - return item; - }); - this.lists = lists; - Alert.success("已失效"); - }); - }, - /** - * 已暂停或者待发布 - * @constructor - */ - PAUSEDANDPENDING(id) { - let params = { - id - }; - ENABLE_FIELD_LIST(params).then((res) => { - let lists = []; - this.lists.map((item) => { - if (item.id == id) { - item.stateText = '生效中'; - item.enabled = true; - } - lists.push(item); - return item; - }); - this.lists = lists; - Alert.success("已生效"); - }); - }, - determine() { - let that = this; - let child = this.$refs.distribution.lists; - let params = { - id: this.id, - items: child - }; - - for (let index in child) { - if (!child[index].rate || !child[index].userId) { - Alert.fail("值不能为空"); - return false; - } - } - - for (let i = 0; i < child.length; i++) { - for (let j = i + 1; j < child.length; j++) { - if (child[i].userId == child[j].userId) { - Alert.fail("分润对象不能一样"); - return false; - } - - } - } - POST_FIELD_LIST(params).then(res => { - Alert.success("添加成功"); - that.isEdit = false; - that.getList(); - }); - } } }