Browse Source

分类

preview
jiangyy 4 years ago
parent
commit
8ba16b1046
  1. 5
      epmet-oper-web/src/views/main.vue
  2. 191
      epmet-oper-web/src/views/modules/workPc/guidance/categoryList.vue

5
epmet-oper-web/src/views/main.vue

@ -129,7 +129,10 @@ export default {
this.$store.state.user.realName = data.realName this.$store.state.user.realName = data.realName
this.$store.state.user.superAdmin = data.superAdmin this.$store.state.user.superAdmin = data.superAdmin
this.$store.state.user.gender = data.gender this.$store.state.user.gender = data.gender
this.$store.state.user.roleList = data.roleList localStorage.setItem('roleList', data.roleList)
localStorage.setItem('customerId', data.customerId)
// this.$store.state.user.roleList = data.roleList
// this.$store.state.user.customerId = data.customerId
}, },
(rspMsg, data) => { (rspMsg, data) => {

191
epmet-oper-web/src/views/modules/workPc/guidance/categoryList.vue

@ -15,7 +15,7 @@
<el-table ref="roleTable" <el-table ref="roleTable"
v-loading="loading1" v-loading="loading1"
:data="tableData" :data="tableData"
row-key="roleKey" row-key="id"
border border
style="width: 100%;margin-top:20px"> style="width: 100%;margin-top:20px">
<el-table-column type="index" <el-table-column type="index"
@ -27,7 +27,7 @@
header-align="left" header-align="left"
align="left" align="left"
label="分类名称" label="分类名称"
width="150"></el-table-column> width="250"></el-table-column>
<el-table-column prop="status" <el-table-column prop="status"
label="状态" label="状态"
@ -48,19 +48,19 @@
<el-button v-if="scope.row.status==='enable'" <el-button v-if="scope.row.status==='enable'"
type="primary" type="primary"
size="mini" size="mini"
@click="handelChangeState(scope.row,'disable')">禁用</el-button> @click="confirmChangeState(scope.row,'disable')">禁用</el-button>
<el-button v-if="scope.row.status==='disable'" <el-button v-if="scope.row.status==='disable'"
type="primary" type="primary"
size="mini" size="mini"
@click="handelChangeState(scope.row,'enable')">启用</el-button> @click="confirmChangeState(scope.row,'enable')">启用</el-button>
<el-button type="primary" <el-button type="primary"
size="mini" size="mini"
@click="handleEdit(scope.row.roleKey, scope.row.roleName)">修改</el-button> @click="handleEdit(scope.row)">修改</el-button>
<el-button type="primary" <el-button type="primary"
size="mini" size="mini"
@click="handleDel(scope.row)">删除</el-button> @click="confirmDel(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -97,7 +97,7 @@
<script> <script>
import Sortable from 'sortablejs' import Sortable from 'sortablejs'
import { requestPost, requestGet } from "@/js/dai/request"; import { requestPost } from "@/js/dai/request";
export default { export default {
name: 'RoleList', name: 'RoleList',
@ -105,12 +105,15 @@ export default {
data () { data () {
return { return {
loading1: false, loading1: false,
roleList: [],//
customerId: '',//id
selCategoryId: '', selCategoryId: '',
tableData: [], tableData: [],
isManager: false, isManager: false,
// //
formType: 'A',/// A/U
diaTitle: '新增分类', diaTitle: '新增分类',
categoryName: '', categoryName: '',
diaShow: false, diaShow: false,
@ -119,17 +122,20 @@ export default {
} }
}, },
mounted () { async mounted () {
this.loadList() this.roleList = localStorage.getItem('roleList')
this.dragRoleSort() this.customerId = localStorage.getItem('customerId')
console.log(this.roleList)
const roleList = this.$store.state.user.roleList console.log(this.customerId)
console.log(this.$store.state.user.roleList) if (this.roleList.indexOf('root_manager') > -1) {
if (roleList.indexOf('root_manager') > -1) {
this.isManager = true this.isManager = true
} else { } else {
this.isManager = false this.isManager = true
} }
await this.loadList()
await this.dragRoleSort()
}, },
@ -137,12 +143,12 @@ export default {
// //
async loadList () { async loadList () {
console.log(this.description)
// const url = "/gov/voice/guideccategory/getcategory" // const url = "/gov/voice/guideccategory/getcategory"
const url = "/gov/voice/guidecategory/page" const url = "/gov/voice/guidecategory/page"
const params = { const params = {
customerId: this.customerId,
} }
const { data, code, msg } = await requestGet(url, params) const { data, code, msg } = await requestPost(url, params)
if (code === 0) { if (code === 0) {
this.tableData = data.list this.tableData = data.list
@ -157,6 +163,7 @@ export default {
this.diaShow = true this.diaShow = true
this.categoryName = '' this.categoryName = ''
this.selCategoryId = '' this.selCategoryId = ''
this.formType = 'A'
}, },
// //
handleEdit (row) { handleEdit (row) {
@ -164,24 +171,28 @@ export default {
this.diaShow = true this.diaShow = true
this.selCategoryId = row.id this.selCategoryId = row.id
this.categoryName = row.categoryName this.categoryName = row.categoryName
this.formType = 'U'
}, },
// //
async saveCategory () { async saveCategory () {
const url = "/gov/voice/guideccategory/update"
let params = {} let url = ''
if (this.selCategoryId) { let params = {
params = { categoryName: this.categoryName,
categoryId: this.selCategoryId, customerId: this.customerId
categoryName: this.categoryName }
} if (this.formType === 'U') {
url = "/gov/voice/guidecategory/update"
params.id = this.selCategoryId
} else { } else {
params = { url = "/gov/voice/guidecategory/save"
categoryName: this.categoryName
}
} }
const { data, code, msg } = await requestPost(url, params) const { data, code, msg } = await requestPost(url, params)
if (code === 0) { if (code === 0) {
this.$message.success('操作成功')
this.diaShow = false
this.loadList() this.loadList()
} else { } else {
@ -189,16 +200,27 @@ export default {
} }
}, },
confirmChangeState (row, state) {
this.$confirm('确认修改分类状态', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.handelChangeState(row, state)
})
},
// //
async handelChangeState (row, state) { async handelChangeState (row, state) {
const url = "/gov/voice/guideccategory/disable" const url = "/gov/voice/guidecategory/disable"
const params = { const params = {
status: state, status: state,
categoryId: row.id id: row.id
} }
const { data, code, msg } = await requestPost(url, params) const { data, code, msg } = await requestPost(url, params)
if (code === 0) { if (code === 0) {
this.$message.success('操作成功')
this.loadList() this.loadList()
} else { } else {
@ -206,14 +228,26 @@ export default {
} }
}, },
confirmDel (row) {
this.$confirm('确认删除当前分类', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.handelDel(row)
})
},
// //
async handelDel (row) { async handelDel (row) {
const url = "/gov/voice/guidecategory" const url = "/gov/voice/guidecategory/delete"
const params = { const params = {
categoryId: row.id id: row.id,
customerId: this.customerId
} }
const { data, code, msg } = await requestPost(url, params) const { data, code, msg } = await requestPost(url, params)
if (code === 0) { if (code === 0) {
this.$message.success('删除成功')
this.loadList() this.loadList()
} else { } else {
@ -241,36 +275,6 @@ export default {
row.isEdit = true row.isEdit = true
}, },
//
async updateRole () {
console.log(this.description)
const url = "/epmetuser/govstaffrole/updatedefaultrole"
const params = {
roleId: this.selCategoryId,
roleName: this.roleName,
description: this.description
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.diaShow = false
this.loadList()
} else {
this.$message.error(msg)
}
},
//
toOperationConfig (roleKey, roleName) {
this.roleName = roleName
this.funcShow = true
this.opeList = []
},
dragRoleSort () { dragRoleSort () {
const el = this.$refs.roleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0] const el = this.$refs.roleTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0]
this.sortTable = Sortable.create(el, { this.sortTable = Sortable.create(el, {
@ -291,29 +295,52 @@ export default {
}, },
// //
handleSaveSort () { async handleSaveSort () {
let data = {
roleIdList: this.tableData.map(item => { const url = "/gov/voice/guidecategory/saveorder"
return item.id let params = {
}) orderList: this.tableData.map((item, index) => {
} let obj = {
this.$http id: item.id,
.post('/epmetuser/govstaffrole/savedefaultsort', data) orderIndex: index,
.then(({ data: res }) => {
console.log('ressss', res)
if (res.code === 0 && res.msg === 'success') {
this.$message({
type: 'success',
message: '保存成功'
})
this.loadList()
} else {
this.$message({
type: 'error',
message: res.msg
})
} }
return obj
}) })
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.$message.success('操作成功')
this.loadList()
} else {
this.$message.error(msg)
}
// let data = {
// roleIdList: this.tableData.map(item => {
// return item.id
// })
// }
// this.$http
// .post('/epmetuser/govstaffrole/savedefaultsort', data)
// .then(({ data: res }) => {
// console.log('ressss', res)
// if (res.code === 0 && res.msg === 'success') {
// this.$message({
// type: 'success',
// message: ''
// })
// this.loadList()
// } else {
// this.$message({
// type: 'error',
// message: res.msg
// })
// }
// })
} }
} }
} }

Loading…
Cancel
Save