产品管理等

dev
yujialong 3 years ago
parent 463728a343
commit 2e4f0302b4
  1. 40
      public/table.json
  2. 4
      src/store/index.js
  3. 32
      src/utils/api.js
  4. 3
      src/views/Login.vue
  5. 7
      src/views/data/Framework.vue
  6. 432
      src/views/data/Product.vue

@ -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
}

@ -13,6 +13,8 @@ const store = new Vuex.Store({
systemId: '', systemId: '',
orderId: '', orderId: '',
userLoginId: '', userLoginId: '',
userName: '',
roleId: '',
loginToken: '' loginToken: ''
}, },
mutations:{ mutations:{
@ -40,6 +42,8 @@ const store = new Vuex.Store({
}, },
userLoginData (state, payload) { userLoginData (state, payload) {
state.userLoginId = payload.userLogin_id state.userLoginId = payload.userLogin_id
state.userName = payload.userName
state.roleId = payload.roleId
}, },
tokenData (state, payload) { tokenData (state, payload) {
state.loginToken = payload.loginToken state.loginToken = payload.loginToken

@ -2,7 +2,8 @@
// let host = 'http://192.168.31.117:8080' // let host = 'http://192.168.31.117:8080'
// let host = 'http://www.huorantech.cn/liuwanr' // let host = 'http://www.huorantech.cn/liuwanr'
let host = 'http://39.108.250.202' 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 { export default {
logins: `${host}/liuwanr/userInfo/adminLogins`, //登录 logins: `${host}/liuwanr/userInfo/adminLogins`, //登录
@ -96,15 +97,22 @@ export default {
downloadFiles: `${host}/liuwanr/aliyun/downloadFiles`, //下载文件 downloadFiles: `${host}/liuwanr/aliyun/downloadFiles`, //下载文件
// 数据管理 // 数据管理
getIdQueryTable:`${host1}/data/huoran/data/table/getIdQueryTable`, getIdQueryTable:`${host1}/data/table/getIdQueryTable`,
getTableByClassification:`${host1}/data/huoran/data/table/getTableByClassification`, getTableByClassification:`${host1}/data/table/getTableByClassification`,
getTableByCondition:`${host1}/data/huoran/data/table/getTableByCondition`, getTableByCondition:`${host1}/data/table/getTableByCondition`,
originalList:`${host1}/data/huoran/data/table/originalList`, originalList:`${host1}/data/table/originalList`,
originalListById:`${host1}/data/huoran/data/table/originalListById`, originalListById:`${host1}/data/table/originalListById`,
saveCategory:`${host1}/data/huoran/data/table/saveCategory`, saveCategory:`${host1}/data/table/saveCategory`,
saveTable:`${host1}/data/huoran/data/table/saveTable`, saveTable:`${host1}/data/table/saveTable`,
updateCategory:`${host1}/data/huoran/data/table/updateCategory`, updateCategory:`${host1}/data/table/updateCategory`,
deleteCategory:`${host1}/data/huoran/data/table/deleteCategory`, deleteCategory:`${host1}/data/table/deleteCategory`,
deleteTable:`${host1}/data/huoran/data/table/deleteTable`, deleteTable:`${host1}/data/table/deleteTable`,
previewData:`${host1}/data/data/preview`, 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`,
} }

@ -63,9 +63,10 @@ export default {
} }
this.$post(this.api.logins,data).then(res => { this.$post(this.api.logins,data).then(res => {
if(res.message.retvalue.roleId == 1){ if(res.message.retvalue.roleId == 1){
let user = res.message.retvalue
this.$message.success('登录成功'); this.$message.success('登录成功');
localStorage.setItem('ms_username', this.param.username); 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.$store.commit("tokenData", {loginToken: res.message.retvalue.loginToken})
this.$router.push('/dashboard'); this.$router.push('/dashboard');
}else{ }else{

@ -188,6 +188,7 @@ export default {
this.categoryName = row.data.categoryName this.categoryName = row.data.categoryName
}, },
delType(row){ delType(row){
//
this.$confirm('确定要删除吗?', '提示', { this.$confirm('确定要删除吗?', '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
@ -225,6 +226,7 @@ export default {
}, },
preview(row){ preview(row){
this.$get(`${this.api.previewData}?tableName=${row.name}&tableId=${row.id}`).then(res => { 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 comment = res.comment
let previewHead = [] let previewHead = []
comment.map(n => { comment.map(n => {
@ -278,8 +280,8 @@ export default {
this.$message.error('请先选择数据') this.$message.error('请先选择数据')
} }
}, },
async getTable(n,i){ getTable(n,i){
let res = await this.$post(`${this.api.originalListById}?categoryId=${n.id}&showName=&pageNum=1&pageSize=10000`) this.$post(`${this.api.originalListById}?categoryId=${n.id}&showName=&pageNum=1&pageSize=10000`).then(res => {
res.list.map(n => { res.list.map(n => {
n.label = n.showName n.label = n.showName
n.id = String(n.id) n.id = String(n.id)
@ -290,6 +292,7 @@ export default {
this.tableName = res.list[0].name this.tableName = res.list[0].name
this.curId = res.list[0].id this.curId = res.list[0].id
} }
}).catch(res => {})
}, },
batchImport(){ batchImport(){
this.$post(this.api.originalList).then(res => { this.$post(this.api.originalList).then(res => {

@ -12,10 +12,10 @@
<el-form label-width="80px" class="flex-between"> <el-form label-width="80px" class="flex-between">
<div class="flex-center"> <div class="flex-center">
<el-form-item label="创建日期"> <el-form-item label="创建日期">
<el-date-picker v-model="date" align="right" unlink-panels type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="getData" clearable></el-date-picker> <el-date-picker v-model="date" align="right" unlink-panels type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" clearable></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="状态"> <el-form-item label="状态">
<el-select v-model="status" clearable placeholder="请选择状态" @change="getData"> <el-select v-model="status" clearable placeholder="请选择状态" @change="initData">
<el-option v-for="(item,index) in statusList" :key="index" :label="item.name" :value="item.value"></el-option> <el-option v-for="(item,index) in statusList" :key="index" :label="item.name" :value="item.value"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -34,41 +34,25 @@
<div class="flex-between mgb20"> <div class="flex-between mgb20">
<div class="flex-center"> <div class="flex-center">
<p class="hr_tag"></p> <p class="hr_tag"></p>
<span>订单列表</span> <span>产品列表</span>
</div> </div>
<div> <div>
<el-button type="primary" size="small" round @click="add">新增</el-button> <el-button type="primary" size="small" round @click="add">新增</el-button>
<el-button type="primary" size="small" round @click="delAllSelection">批量删除</el-button> <el-button type="primary" size="small" round @click="delAllSelection">批量删除</el-button>
</div> </div>
</div> </div>
<el-table :data="orderData" class="table" stripe header-align="center" @selection-change="handleSelectionChange" row-key="id"> <el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange" row-key="id">
<el-table-column type="selection" width="55" align="center" :reserve-selection="true"></el-table-column> <el-table-column type="selection" width="55" align="center" :reserve-selection="true"></el-table-column>
<el-table-column type="index" width="100" label="序号" align="center"> <el-table-column type="index" width="100" label="序号" align="center"></el-table-column>
</el-table-column> <el-table-column prop="productName" label="产品名称" align="center"></el-table-column>
<el-table-column prop="orderNumber" label="订单编号" align="center"> <el-table-column prop="tableNum" label="数据量(表)" align="center"></el-table-column>
</el-table-column> <el-table-column prop="userName" label="创建人" align="center"></el-table-column>
<el-table-column prop="customerName" label="产品名称" align="center"> <el-table-column prop="orderNum" label="订单数量" align="center"></el-table-column>
</el-table-column> <el-table-column prop="market" label="市场价" align="center"></el-table-column>
<el-table-column prop="orderAmount" label="数据量(表)" align="center"> <el-table-column prop="createTime" label="创建时间" align="center"></el-table-column>
</el-table-column>
<el-table-column prop="orderDate" label="创建人" align="center">
</el-table-column>
<el-table-column prop="orderType" label="订单数量" align="center">
</el-table-column>
<el-table-column prop="orderStatus" label="市场价" align="center">
</el-table-column>
<el-table-column prop="orderNature" label="创建时间" align="center">
</el-table-column>
<el-table-column prop="orderNature" label="状态" align="center"> <el-table-column prop="orderNature" label="状态" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch v-model="scope.row.status" :active-text="scope.row.status ? '上架' : '下架'" :active-value="1" :inactive-value="0" @change="switchOff($event,scope.row,scope.$index)"></el-switch>
v-model="scope.row.enable"
:active-text="scope.row.enable ? '上架' : '下架'"
:active-value="0"
:inactive-value="1"
style="margin: 0 10px 0 10px"
@change="switchOff($event,scope.row,scope.$index)"
></el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
@ -80,8 +64,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="pagination"> <div class="pagination">
<el-pagination background layout="total, prev, pager, next" @current-change="handleCurrentChange" :current-page="pageNo" :total="totals"> <el-pagination background layout="total, prev, pager, next" @current-change="handleCurrentChange" :current-page="page" :total="totals"></el-pagination>
</el-pagination>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
@ -89,24 +72,71 @@
<el-dialog :title="isDetail ? '查看产品' : (id ? '编辑产品' : '新增产品')" :visible.sync="productVisible" width="30%" center @close="closeProduct" class="dialog" :close-on-click-modal="false"> <el-dialog :title="isDetail ? '查看产品' : (id ? '编辑产品' : '新增产品')" :visible.sync="productVisible" width="30%" center @close="closeProduct" class="dialog" :close-on-click-modal="false">
<el-form ref="form" label-width="120px" :disabled="isDetail"> <el-form ref="form" label-width="120px" :disabled="isDetail">
<el-form-item prop="userAccount" label="数据产品名称"> <el-form-item label="数据产品名称">
<el-input v-model="userAccount" placeholder="请输入数据产品名称"></el-input> <el-input v-model="productName" placeholder="请输入数据产品名称"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="userName" label="市场价格"> <el-form-item label="市场价格">
<el-input v-model="userName" placeholder="请输入市场价格"> <el-input v-model="market" placeholder="请输入市场价格">
<span slot="suffix">/账号</span> <span slot="suffix">/账号</span>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="userName" label="已选数据"> <el-form-item label="已选数据">
<el-button type="primary" size="small">配置数据权限</el-button> <el-button type="primary" size="small" @click="configData">配置数据权限</el-button>
<el-tree ref="type" :data="typeList" node-key="id" accordion show-checkbox :props="defaultProps" highlight-current></el-tree> <el-tree ref="type" :data="typeList" show-checkbox node-key="id" :default-expanded-keys="checkedIds" :default-checked-keys="checkedIds" :props="defaultProps"></el-tree>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail"> <span slot="footer" class="dialog-footer" v-if="!isDetail">
<el-button @click="productVisible = false"> </el-button> <el-button @click="productVisible = false"> </el-button>
<el-button type="primary" @click="saveSure('teacherForm')"> </el-button> <el-button type="primary" @click="confirm"> </el-button>
</span>
</el-dialog>
<el-dialog title="数据配置" :visible.sync="configVisible" width="70%" center @close="closeConfig" :close-on-click-modal="false">
<el-container style="padding: 20px 0 20px 20px;background-color: #f0f0f0;">
<el-aside width="300px">
<el-tree style="margin: 10px;" ref="typeConfig" :data="typeConfigList" show-checkbox node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" highlight-current @current-change="typeConfigClick"></el-tree>
</el-aside>
<el-main style="padding-top: 0;padding-bottom: 0;">
<el-card shadow="hover">
<el-form label-width="80px" class="flex-between mgb20">
<div class="flex-center">
<el-form-item label="创建日期" style="margin: 0 20px 0 0">
<el-date-picker v-model="updateTime" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="initConfigData"></el-date-picker>
</el-form-item>
<el-input placeholder="请输入数据表名称" v-model="keywordConfig" prefix-icon="el-icon-search" clearable></el-input>
</div>
</el-form>
<el-table :data="listConfigData" class="table" ref="table" stripe header-align="center">
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column>
<el-table-column prop="showName" label="数据表名称" align="center"></el-table-column>
<el-table-column prop="dataTotal" label="数据总量" align="center"></el-table-column>
<el-table-column prop="dataSize" label="数据大小" align="center"></el-table-column>
<el-table-column prop="updateTime" width="150" label="更新时间" align="center"></el-table-column>
<el-table-column label="操作" width="220" align="center">
<template slot-scope="scope">
<el-button type="text" @click="previewConfig(scope.row)">预览</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background layout="total, prev, pager, next" :current-page="pageConfig" @current-change="handleCurrentConfigChange" :total="totalConfig"></el-pagination>
</div>
</el-card>
</el-main>
</el-container>
<span slot="footer" class="dialog-footer">
<el-button @click="configVisible = false"> </el-button>
<el-button type="primary" @click="confirmConfig"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog title="预览" :visible.sync="previewVisible" width="60%" center :close-on-click-modal="false">
<el-table :data="previewData" class="table" stripe header-align="center" row-key="id">
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column>
<el-table-column v-for="(item,index) in previewHead" :prop="item.field" :key="index" :label="item.comment" align="center"></el-table-column>
</el-table>
</el-dialog>
</div> </div>
</template> </template>
@ -114,11 +144,15 @@
export default { export default {
data() { data() {
return { return {
userId: this.$store.state.userLoginId,
userName: this.$store.state.userName,
keyword: '', keyword: '',
searchTimer: null, searchTimer: null,
date: [], date: [],
startTime: '',
endTime: '',
status: '', status: '',
orderData:[], listData:[],
multipleSelection: [], multipleSelection: [],
statusList: [{ statusList: [{
name: '不限', name: '不限',
@ -129,26 +163,63 @@ export default {
}, },
{ {
name: '已下架', name: '已下架',
value: 2 value: 0
}], }],
pageNo: 1, page: 1,
pageSize: 10, pageSize: 10,
totals: 1, totals: 1,
productVisible: false, productVisible: false,
id: '',
productName: '',
market: '',
typeList: [], typeList: [],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'label' label: 'label'
}, },
checkedIds: [],
isDetail: false,
typeIndex: 1000,
configVisible: false,
configChecked: [],
configCheckedTableId: [],
categoryId: '',
defaultActive: [], defaultActive: [],
updateTime: '',
keywordConfig: '',
typeConfigList: [],
pageConfig: 1,
pageSizeConfig: 10,
totalConfig: 0,
listConfigData: [],
previewVisible: false,
previewHead: [],
previewData: []
}; };
}, },
watch: { watch: {
date: function(val){
if(val){
this.startTime = val[0]
this.endTime = val[1]
}else{
this.startTime = ''
this.endTime = ''
}
this.initData()
},
keyword: function(val) { keyword: function(val) {
clearTimeout(this.searchTimer) clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => { this.searchTimer = setTimeout(() => {
this.initData() this.initData()
},500) },500)
},
keywordConfig: function(val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initConfigData()
},500)
} }
}, },
mounted() { mounted() {
@ -156,64 +227,134 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
// this.$get(this.api.queryOrder,data).then(res => { this.$post(this.api.listByEntity,{
// res.message.rows.forEach(e => { createTime: this.startTime,
// e.orderType = this.orderTypeFn(e.orderType) endTime: this.endTime,
// e.orderStatus = this.orderStatusFn(e.orderStatus) pageNum: this.page,
// e.orderNature = this.orderNatureFn(e.orderNature) pageSize: this.pageSize,
// }) productName: this.keyword,
// this.orderData = res.message.rows status: this.status,
// this.totals = res.message.total }).then(res => {
// }).catch(res => {}); this.listData = res.pageList.records
this.totals = res.pageList.total
}).catch(res => {})
}, },
initData(){ initData(){
this.pageNo = 1 this.page = 1
this.getData() 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(){ getType(){
this.productVisible = true
this.$post(this.api.getTableByClassification).then(res => { this.$post(this.api.getTableByClassification).then(res => {
res.map(n => { res.map(n => {
n.id = String(n.id) n.originId = n.id
n.id = String(++this.typeIndex)
n.label = n.categoryName n.label = n.categoryName
n.children.map(n => { n.children.map(n => {
n.id = String(n.id) n.originId = n.id
n.id = String(++this.typeIndex)
n.label = n.categoryName n.label = n.categoryName
n.children.map(n => { n.children.map(n => {
n.id = String(n.id) n.originId = n.id
n.id = String(++this.typeIndex)
n.label = n.categoryName n.label = n.categoryName
n.isThird = true n.isThird = 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 this.typeList = res
this.productVisible = true },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 => {}) }).catch(res => {})
}, },
add(){ add(){
this.getType() this.getType()
this.id = ''
this.checkedIds = []
}, },
edit(row){ edit(row){
this.getType() 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){ preview(row){
this.isDetail = true this.isDetail = true
this.getType() this.getType()
this.id = row.id
this.getDetail()
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm('确定要删除吗?', '提示', { this.$confirm('确定要删除吗?', '提示', {
type: 'warning' type: 'warning'
}) }).then(() => {
.then(() => { this.$post(`${this.api.deleteProduct}?ids=${row.id}`).then(res => {
let result = row.orderId
var arr = []
arr.push(result)
let data = arr
this.$post(this.api.deleteOrder,data).then(res => {
this.$message.success('删除成功') this.$message.success('删除成功')
this.getData() this.getData()
}).catch(res => {}); }).catch(res => {})
}) }).catch(() => {})
.catch(() => {});
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val this.multipleSelection = val
@ -221,33 +362,176 @@ export default {
delAllSelection() { delAllSelection() {
if(this.multipleSelection.length != ''){ if(this.multipleSelection.length != ''){
let arr = this.multipleSelection let arr = this.multipleSelection
let result = arr.map(e => e.orderId) let result = arr.map(e => e.id)
this.$confirm('确定要删除吗?', '提示', { this.$confirm('确定要删除吗?', '提示', {
type: 'warning' type: 'warning'
}) }).then(() => {
.then(() => { this.$post(`${this.api.deleteProduct}?ids=${result.join(',')}`).then(res => {
let data = result this.$refs.table.clearSelection()
this.$post(this.api.deleteOrder,data).then(res => {
this.multipleSelection = []
this.$message.success('删除成功') this.$message.success('删除成功')
this.getData() this.getData()
}).catch(res => {}) }).catch(res => {})
}).catch(() => {}) }).catch(() => {})
}else{ }else{
this.$message.error('请先选择订单 !') this.$message.error('请先选择数据')
} }
}, },
handleCurrentChange(val) { handleCurrentChange(val) {
this.pageNo = val this.page = val
this.getData() this.getData()
}, },
closeProduct(){ closeProduct(){
this.productName = ''
this.market = ''
this.isDetail = false 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)
})
} }
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/deep/.el-container{
.el-aside{
padding: 15px;
background-color: #fff;
}
}
</style> </style>
Loading…
Cancel
Save