diff --git a/public/table.json b/public/table.json deleted file mode 100644 index ddd2e32..0000000 --- a/public/table.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "list": [{ - "id": 1, - "name": "张三", - "money": 123, - "address": "广东省东莞市长安镇", - "state": "成功", - "date": "2019-11-1", - "thumb": "https://lin-xin.gitee.io/images/post/wms.png" - }, - { - "id": 2, - "name": "李四", - "money": 456, - "address": "广东省广州市白云区", - "state": "成功", - "date": "2019-10-11", - "thumb": "https://lin-xin.gitee.io/images/post/node3.png" - }, - { - "id": 3, - "name": "王五", - "money": 789, - "address": "湖南省长沙市", - "state": "失败", - "date": "2019-11-11", - "thumb": "https://lin-xin.gitee.io/images/post/parcel.png" - }, - { - "id": 4, - "name": "赵六", - "money": 1011, - "address": "福建省厦门市鼓浪屿", - "state": "成功", - "date": "2019-10-20", - "thumb": "https://lin-xin.gitee.io/images/post/notice.png" - } - ], - "pageTotal": 4 -} \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 3f87e58..7029e0d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -13,6 +13,8 @@ const store = new Vuex.Store({ systemId: '', orderId: '', userLoginId: '', + userName: '', + roleId: '', loginToken: '' }, mutations:{ @@ -40,6 +42,8 @@ const store = new Vuex.Store({ }, userLoginData (state, payload) { state.userLoginId = payload.userLogin_id + state.userName = payload.userName + state.roleId = payload.roleId }, tokenData (state, payload) { state.loginToken = payload.loginToken diff --git a/src/utils/api.js b/src/utils/api.js index c05972f..2b844e4 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -2,7 +2,8 @@ // let host = 'http://192.168.31.117:8080' // let host = 'http://www.huorantech.cn/liuwanr' let host = 'http://39.108.250.202' -let host1 = 'http://192.168.31.216:8888' +let host1 = 'http://192.168.31.151:9000' +let host2 = 'http://192.168.31.125:9000' export default { logins: `${host}/liuwanr/userInfo/adminLogins`, //登录 @@ -96,15 +97,22 @@ export default { downloadFiles: `${host}/liuwanr/aliyun/downloadFiles`, //下载文件 // 数据管理 - getIdQueryTable:`${host1}/data/huoran/data/table/getIdQueryTable`, - getTableByClassification:`${host1}/data/huoran/data/table/getTableByClassification`, - getTableByCondition:`${host1}/data/huoran/data/table/getTableByCondition`, - originalList:`${host1}/data/huoran/data/table/originalList`, - originalListById:`${host1}/data/huoran/data/table/originalListById`, - saveCategory:`${host1}/data/huoran/data/table/saveCategory`, - saveTable:`${host1}/data/huoran/data/table/saveTable`, - updateCategory:`${host1}/data/huoran/data/table/updateCategory`, - deleteCategory:`${host1}/data/huoran/data/table/deleteCategory`, - deleteTable:`${host1}/data/huoran/data/table/deleteTable`, - previewData:`${host1}/data/data/preview`, + getIdQueryTable:`${host1}/data/table/getIdQueryTable`, + getTableByClassification:`${host1}/data/table/getTableByClassification`, + getTableByCondition:`${host1}/data/table/getTableByCondition`, + originalList:`${host1}/data/table/originalList`, + originalListById:`${host1}/data/table/originalListById`, + saveCategory:`${host1}/data/table/saveCategory`, + saveTable:`${host1}/data/table/saveTable`, + updateCategory:`${host1}/data/table/updateCategory`, + deleteCategory:`${host1}/data/table/deleteCategory`, + deleteTable:`${host1}/data/table/deleteTable`, + previewData:`${host2}/data/preview`, + + // 产品管理 + deleteProduct:`${host1}/data/product/delete`, + findById:`${host1}/data/product/findById`, + listByEntity:`${host1}/data/product/listByEntity`, + saveProduct:`${host1}/data/product/save`, + updateProduct:`${host1}/data/product/update`, } \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue index 4977a5e..791e761 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -63,9 +63,10 @@ export default { } this.$post(this.api.logins,data).then(res => { if(res.message.retvalue.roleId == 1){ + let user = res.message.retvalue this.$message.success('登录成功'); localStorage.setItem('ms_username', this.param.username); - this.$store.commit("userLoginData", { userLogin_id : res.message.retvalue.userId}); + this.$store.commit("userLoginData", { userLogin_id : user.userId,userName: user.userName,roleId: user.roleId}); this.$store.commit("tokenData", {loginToken: res.message.retvalue.loginToken}) this.$router.push('/dashboard'); }else{ diff --git a/src/views/data/Framework.vue b/src/views/data/Framework.vue index 183bd9d..de435af 100644 --- a/src/views/data/Framework.vue +++ b/src/views/data/Framework.vue @@ -188,6 +188,7 @@ export default { this.categoryName = row.data.categoryName }, delType(row){ + // 该分类下的数据表已存在于产品管理中,是否确认删除? this.$confirm('确定要删除吗?', '提示', { type: 'warning' }).then(() => { @@ -225,6 +226,7 @@ export default { }, preview(row){ this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => { + this.$post(`${this.api.saveRecord}?platformUserId=4&tableId=${row.id}&type=2&schoolId=1`).then(res => {}).catch(res => {}) let comment = res.comment let previewHead = [] comment.map(n => { @@ -278,18 +280,19 @@ export default { this.$message.error('请先选择数据') } }, - async getTable(n,i){ - let res = await this.$post(`${this.api.originalListById}?categoryId=${n.id}&showName=&pageNum=1&pageSize=10000`) - res.list.map(n => { - n.label = n.showName - n.id = String(n.id) - }) - n.children = res.list - if(!i && !this.tableName){ - this.defaultTypeActive = res.list[0].id - this.tableName = res.list[0].name - this.curId = res.list[0].id - } + getTable(n,i){ + this.$post(`${this.api.originalListById}?categoryId=${n.id}&showName=&pageNum=1&pageSize=10000`).then(res => { + res.list.map(n => { + n.label = n.showName + n.id = String(n.id) + }) + n.children = res.list + if(!i && !this.tableName){ + this.defaultTypeActive = res.list[0].id + this.tableName = res.list[0].name + this.curId = res.list[0].id + } + }).catch(res => {}) }, batchImport(){ this.$post(this.api.originalList).then(res => { diff --git a/src/views/data/Product.vue b/src/views/data/Product.vue index ebfb3cf..82d8796 100644 --- a/src/views/data/Product.vue +++ b/src/views/data/Product.vue @@ -12,10 +12,10 @@
- + - + @@ -34,41 +34,25 @@

- 订单列表 + 产品列表
新增 批量删除
- + - - - - - - - - - - - - - - - - + + + + + + + @@ -80,8 +64,7 @@ @@ -89,24 +72,71 @@ - - + + - - + + 元/账号 - - 配置数据权限 - + + 配置数据权限 + 取 消 - 确 定 + 确 定 + + + + + + + + + + + + +
+ + + + +
+
+ + + + + + + + + + + +
+
+
+ + 取 消 + 确 定
+ + + + + + +
@@ -114,11 +144,15 @@ export default { data() { return { + userId: this.$store.state.userLoginId, + userName: this.$store.state.userName, keyword: '', searchTimer: null, date: [], + startTime: '', + endTime: '', status: '', - orderData:[], + listData:[], multipleSelection: [], statusList: [{ name: '不限', @@ -129,26 +163,63 @@ export default { }, { name: '已下架', - value: 2 + value: 0 }], - pageNo: 1, + page: 1, pageSize: 10, totals: 1, productVisible: false, + id: '', + productName: '', + market: '', typeList: [], defaultProps: { children: 'children', label: 'label' }, + checkedIds: [], + isDetail: false, + typeIndex: 1000, + + configVisible: false, + configChecked: [], + configCheckedTableId: [], + categoryId: '', defaultActive: [], + updateTime: '', + keywordConfig: '', + typeConfigList: [], + pageConfig: 1, + pageSizeConfig: 10, + totalConfig: 0, + listConfigData: [], + previewVisible: false, + previewHead: [], + previewData: [] }; }, watch: { + date: function(val){ + if(val){ + this.startTime = val[0] + this.endTime = val[1] + }else{ + this.startTime = '' + this.endTime = '' + } + this.initData() + }, keyword: function(val) { clearTimeout(this.searchTimer) this.searchTimer = setTimeout(() => { this.initData() },500) + }, + keywordConfig: function(val) { + clearTimeout(this.searchTimer) + this.searchTimer = setTimeout(() => { + this.initConfigData() + },500) } }, mounted() { @@ -156,64 +227,134 @@ export default { }, methods: { getData() { - // this.$get(this.api.queryOrder,data).then(res => { - // res.message.rows.forEach(e => { - // e.orderType = this.orderTypeFn(e.orderType) - // e.orderStatus = this.orderStatusFn(e.orderStatus) - // e.orderNature = this.orderNatureFn(e.orderNature) - // }) - // this.orderData = res.message.rows - // this.totals = res.message.total - // }).catch(res => {}); + this.$post(this.api.listByEntity,{ + createTime: this.startTime, + endTime: this.endTime, + pageNum: this.page, + pageSize: this.pageSize, + productName: this.keyword, + status: this.status, + }).then(res => { + this.listData = res.pageList.records + this.totals = res.pageList.total + }).catch(res => {}) }, initData(){ - this.pageNo = 1 + this.page = 1 this.getData() }, + getTable(n,i){ + this.$post(`${this.api.getIdQueryTable}?categoryId=${n.originId}&showName=&pageNum=1&pageSize=10000&updateTime=`).then(res => { + res.list.map(n => { + n.label = n.showName + n.id = String(n.id) + }) + n.children = res.list + }).catch(res => {}) + }, getType(){ + this.productVisible = true this.$post(this.api.getTableByClassification).then(res => { res.map(n => { - n.id = String(n.id) + n.originId = n.id + n.id = String(++this.typeIndex) n.label = n.categoryName n.children.map(n => { - n.id = String(n.id) + n.originId = n.id + n.id = String(++this.typeIndex) n.label = n.categoryName n.children.map(n => { - n.id = String(n.id) + n.originId = n.id + n.id = String(++this.typeIndex) n.label = n.categoryName n.isThird = true }) }) }) - this.typeList = res - this.productVisible = true + res.map((n,i) => { + if(n.children.length){ + n.children.map(n => { + if(n.children.length){ + n.children.map(n => this.getTable(n,i)) + }else{ + this.getTable(n,i) + } + }) + }else{ + this.getTable(n,i) + } + }) + setTimeout(() => { + this.typeList = res + },500) + this.importVisible = true + }).catch(res => {}) + }, + handleType(data,typeList){ + let result = data + if(typeList.length){ + typeList.map(e => { + if(result.includes(e.id) && e.children.length){ + e.children.every(n => result.includes(n)) || result.splice(result.indexOf(e.id),1) + } + e.children.length && this.handleType(data,e.children) + }) + } + return result + }, + getDetail(){ + this.$post(`${this.api.findById}?id=${this.id}`).then(res => { + let data = res.product + this.productName = data.productName + this.market = data.market + // console.log(22,data.tableId,this.typeList) + this.checkedIds = this.handleType(data.tableId.split(','),this.typeList) + console.log(this.checkedIds) + this.$refs.type.setCheckedNodes(this.checkedIds) }).catch(res => {}) }, add(){ this.getType() + this.id = '' + this.checkedIds = [] }, edit(row){ this.getType() + this.id = row.id + this.getDetail() + }, + switchOff(val,row,index) { + this.$post(this.api.updateProduct,{ + id: row.id, + productName: row.productName, + market: row.market, + tableId: row.tableId, + userId: row.userId, + userName: row.userName, + createTime: '', + orderNum: '', + status: val, + tableNum: row.tableNum, + updateTime: '', + }).then(res => { + this.$message.success(val ? '上架成功' : '下架成功') + }).catch(err => {}) }, preview(row){ this.isDetail = true this.getType() + this.id = row.id + this.getDetail() }, handleDelete(row) { this.$confirm('确定要删除吗?', '提示', { type: 'warning' - }) - .then(() => { - let result = row.orderId - var arr = [] - arr.push(result) - let data = arr - this.$post(this.api.deleteOrder,data).then(res => { + }).then(() => { + this.$post(`${this.api.deleteProduct}?ids=${row.id}`).then(res => { this.$message.success('删除成功') this.getData() - }).catch(res => {}); - }) - .catch(() => {}); + }).catch(res => {}) + }).catch(() => {}) }, handleSelectionChange(val) { this.multipleSelection = val @@ -221,33 +362,176 @@ export default { delAllSelection() { if(this.multipleSelection.length != ''){ let arr = this.multipleSelection - let result = arr.map(e => e.orderId) + let result = arr.map(e => e.id) this.$confirm('确定要删除吗?', '提示', { type: 'warning' - }) - .then(() => { - let data = result - this.$post(this.api.deleteOrder,data).then(res => { - this.multipleSelection = [] + }).then(() => { + this.$post(`${this.api.deleteProduct}?ids=${result.join(',')}`).then(res => { + this.$refs.table.clearSelection() this.$message.success('删除成功') this.getData() }).catch(res => {}) }).catch(() => {}) }else{ - this.$message.error('请先选择订单 !') + this.$message.error('请先选择数据') } }, handleCurrentChange(val) { - this.pageNo = val + this.page = val this.getData() }, closeProduct(){ + this.productName = '' + this.market = '' this.isDetail = false + this.typeIndex = 1000 + this.typeList = [] + }, + confirm(){ + if(!this.productName) return this.$message.warning('请输入数据产品名称') + if(!this.market) return this.$message.warning('请输入市场价格') + if(isNaN(this.market)) return this.$message.warning('市场价格请输入数字') + let list = this.$refs.type.getCheckedNodes() + let tableId = [] + list.map(n => { + if(n.name) tableId.push(n.id) + }) + if(!tableId.length) return this.$message.warning('请选择数据') + let data = { + id: this.id, + productName: this.productName, + market: this.market, + tableId: tableId.join(), + userId: this.userId, + userName: this.userName, + createTime: '', + orderNum: '', + status: '', + tableNum: tableId.length, + updateTime: '', + } + if(this.id){ + this.$post(this.api.updateProduct,data).then(res => { + this.$message.success('新增成功') + this.productVisible = false + this.getData() + }).catch(res => {}) + }else{ + this.$post(this.api.saveProduct,data).then(res => { + this.$message.success('新增成功') + this.productVisible = false + this.getData() + }).catch(res => {}) + } + }, + + configData(){ + this.configVisible = true + this.getConfigType() + }, + typeConfigClick(data,node){ + this.categoryId = data.id + this.getConfigTable() + }, + closeConfig(){ + this.$refs.typeConfig.setCheckedNodes([]) + }, + getConfigType(){ + this.$post(this.api.getTableByClassification).then(res => { + res.map(n => { + n.id = String(n.id) + n.label = n.categoryName + n.children.map(n => { + n.id = String(n.id) + n.label = n.categoryName + n.children.map(n => { + n.id = String(n.id) + n.label = n.categoryName + n.isThird = true + }) + }) + }) + this.typeConfigList = res + if(res[0].children.length){ + this.categoryId = res[0].children[0].id + this.defaultActive = [res[0].children[0].id] + }else{ + this.categoryId = res[0].id + this.defaultActive = [res[0].id] + } + this.getConfigTable() + }).catch(res => {}) + }, + getConfigTable(){ + this.$post(`${this.api.getIdQueryTable}?categoryId=${this.categoryId}&showName=${this.keywordConfig}&pageNum=${this.pageConfig}&pageSize=${this.pageSizeConfig}&updateTime=${this.updateTime ? this.updateTime : ''}`).then(res => { + this.listConfigData = res.list + this.totalConfig = res.totalCount + }).catch(res => {}) + }, + initConfigData(){ + this.pageConfig = 1 + this.getConfigTable() + }, + handleCurrentConfigChange(){ + this.pageConfig = val + this.getConfigTable() + }, + previewConfig(row){ + this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => { + this.$post(`${this.api.saveRecord}?platformUserId=4&tableId=${row.id}&type=2&schoolId=1`).then(res => {}).catch(res => {}) + let comment = res.comment + let previewHead = [] + comment.map(n => { + n.field != 'id' && n.field != 'operation_time' && previewHead.push(n) + }) + this.previewHead = previewHead + + let data = res.data + data.map(n => { + for(let i in n){ + if(typeof n[i] == 'string' && n[i].endsWith('+0000')) n[i] = this.formatDate('yyyy-MM-dd hh:mm:ss',new Date(n[i])) + } + }) + this.previewData = data + this.previewVisible = true + }).catch(res => {}) + }, + getTableId(list){ + let checked = this.configChecked + list.map(n => { + if(n.children && n.children.length){ + this.getTableId(n.children) + if(checked.includes(n.originId) && n.children[0].name){ + this.configCheckedTableId = [...this.configCheckedTableId,...n.children.map(n => n.id)] + }else{ + this.getTableId(n.children) + } + } + }) + }, + confirmConfig(){ + this.configChecked = this.$refs.typeConfig.getCheckedKeys().map(n => Number(n)) + this.getTableId(this.typeList) + let data = Array.from(new Set(this.configCheckedTableId)) + // console.log(this.$refs.type.setCheckedNodes,Array.from(new Set(this.configCheckedTableId))) + // setTimeout(() => { + // this.$refs.type.setCheckedNodes(Array.from(new Set(this.configCheckedTableId))) + // },500) + this.configVisible = false + this.$nextTick(() => { + console.log(data,this.typeList) + this.$refs.type.setCheckedNodes(data) + }) } } }; \ No newline at end of file