|
@@ -3,376 +3,376 @@ import store from '@/store'
|
|
|
import { toThousandFilter } from '@/filters'
|
|
|
|
|
|
export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- // formVisible: false,
|
|
|
- isReadonly:false,
|
|
|
- loading: true,
|
|
|
- downloadLoading:false,
|
|
|
- highlight:false,
|
|
|
- data: [],
|
|
|
- id: null,
|
|
|
- selectedIds: [],
|
|
|
- title: '新增',
|
|
|
- paginate: {
|
|
|
- sizes: [10, 15, 20, 30, 50],
|
|
|
- limit: 10,
|
|
|
- layout: 'slot, prev, pager, next, sizes,total,jumper',
|
|
|
- current: 0,
|
|
|
- total: 0
|
|
|
- },
|
|
|
- queryParam: {},
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.getList()
|
|
|
- },
|
|
|
- methods: {
|
|
|
- hiddenDialog() {
|
|
|
- this.formVisible = false
|
|
|
- },
|
|
|
- handleResponse(response) {
|
|
|
- // console.log(response)
|
|
|
- if (response.code === 10000) {
|
|
|
- this.$message.success(response.message)
|
|
|
- this.resetFormFields()
|
|
|
- this.handleRefresh()
|
|
|
- this.hiddenDialog()
|
|
|
- // 刷新路由
|
|
|
- if (this.refreshRoute !== undefined && this.refreshRoute === true) {
|
|
|
- this.handleUpdateUserInfo()
|
|
|
- }
|
|
|
- // 成功后
|
|
|
- this.id = null
|
|
|
- } else {
|
|
|
- this.$message.error(response.message)
|
|
|
- }
|
|
|
- },
|
|
|
- handlePageResponse(response){
|
|
|
- if (response.code === 10000) {
|
|
|
- this.$message.success(response.message)
|
|
|
-
|
|
|
- // 刷新路由
|
|
|
- if (this.refreshRoute !== undefined && this.refreshRoute === true) {
|
|
|
- this.handleUpdateUserInfo()
|
|
|
- }
|
|
|
- // 成功后
|
|
|
- this.id = null
|
|
|
- this.goback()
|
|
|
- } else {
|
|
|
- this.$message.error(response.message)
|
|
|
- }
|
|
|
- },
|
|
|
- goback(){
|
|
|
- this.$router.go(-1)
|
|
|
- },
|
|
|
- sortChange(item) {
|
|
|
- if (item.order) {
|
|
|
- var field = item.prop,
|
|
|
- order = item.order;
|
|
|
- if (order == "descending") {
|
|
|
- order = "desc";
|
|
|
- } else {
|
|
|
- order = "asc";
|
|
|
- }
|
|
|
- this.queryParam.order = order;
|
|
|
- this.queryParam.field = field;
|
|
|
- this.getList();
|
|
|
- } else {
|
|
|
- delete this.queryParam.order;
|
|
|
- delete this.queryParam.field;
|
|
|
- this.getList();
|
|
|
- }
|
|
|
- },
|
|
|
- exportExcel(){
|
|
|
- const query =this.queryParam
|
|
|
- this.downloadLoading = true
|
|
|
- this.$http.post(this.exportUrl, query ,{'timeout':180000}).then(response => {
|
|
|
- this.downloadLoading = false
|
|
|
- window.location.href=response.data.url
|
|
|
- }).catch(()=>{
|
|
|
- this.downloadLoading=false;
|
|
|
- })
|
|
|
- },
|
|
|
- // 列表请求
|
|
|
- getList(params = null) {
|
|
|
- const query = params ? params : this.queryParam
|
|
|
- this.loading=true;
|
|
|
- this.$http.get(this.url, { params: query }).then(response => {
|
|
|
-
|
|
|
- this.data = response.data
|
|
|
- this.handlePaginateResponse(response)
|
|
|
- if (this.afterGetList !== undefined) {
|
|
|
- this.afterGetList()
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // formVisible: false,
|
|
|
+ isReadonly: false,
|
|
|
+ loading: true,
|
|
|
+ downloadLoading: false,
|
|
|
+ highlight: false,
|
|
|
+ data: [],
|
|
|
+ id: null,
|
|
|
+ selectedIds: [],
|
|
|
+ title: '新增',
|
|
|
+ paginate: {
|
|
|
+ sizes: [10, 15, 20, 30, 50],
|
|
|
+ limit: 10,
|
|
|
+ layout: 'slot, prev, pager, next, sizes,total,jumper',
|
|
|
+ current: 0,
|
|
|
+ total: 0
|
|
|
+ },
|
|
|
+ queryParam: {},
|
|
|
}
|
|
|
- this.loading=false;
|
|
|
- }).catch(()=>{
|
|
|
- this.loading=false;
|
|
|
- })
|
|
|
},
|
|
|
- closeDialog() {
|
|
|
- this.formVisible = false // 控制dialog弹框的不显示
|
|
|
- },
|
|
|
- closeBmapDialog() {
|
|
|
-
|
|
|
- this.bmapVisible = false // 控制dialog弹框的不显示
|
|
|
- },
|
|
|
-
|
|
|
+ created() {
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ hiddenDialog() {
|
|
|
+ this.formVisible = false
|
|
|
+ },
|
|
|
+ handleResponse(response) {
|
|
|
+ // console.log(response)
|
|
|
+ if (response.code === 10000) {
|
|
|
+ this.$message.success(response.message)
|
|
|
+ this.resetFormFields()
|
|
|
+ this.handleRefresh()
|
|
|
+ this.hiddenDialog()
|
|
|
+ // 刷新路由
|
|
|
+ if (this.refreshRoute !== undefined && this.refreshRoute === true) {
|
|
|
+ this.handleUpdateUserInfo()
|
|
|
+ }
|
|
|
+ // 成功后
|
|
|
+ this.id = null
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.message)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handlePageResponse(response) {
|
|
|
+ if (response.code === 10000) {
|
|
|
+ this.$message.success(response.message)
|
|
|
|
|
|
- // model 弹出层
|
|
|
- handleCreate() {
|
|
|
- this.title = '新增'
|
|
|
- this.isReadonly=false
|
|
|
- this.id = null
|
|
|
- // 创建前
|
|
|
- if (this.beforeCreate !== undefined) {
|
|
|
- this.beforeCreate()
|
|
|
- }
|
|
|
- this.resetFormFields();
|
|
|
- this.formVisible = true
|
|
|
- },
|
|
|
- //
|
|
|
- handleCreateSub(subrecord){
|
|
|
- this.title = '新增子级'
|
|
|
- this.isReadonly=false
|
|
|
- rlcurd.update.apply(this, [subrecord])
|
|
|
- },
|
|
|
- //子组件提交
|
|
|
- handleSubmit() {
|
|
|
-
|
|
|
- if (this.$refs[this.formName].beforeSubmit !== undefined) {
|
|
|
- this.$refs[this.formName].beforeSubmit()
|
|
|
- }
|
|
|
- rlcurd.submitForm.apply(this, [this.$refs[this.formName].url])
|
|
|
- this.handleRefresh()
|
|
|
- },
|
|
|
- // 本页面提交
|
|
|
- handleSubmitThisPage(){
|
|
|
- if (this.beforeSubmit !== undefined) {
|
|
|
- this.beforeSubmit()
|
|
|
- }
|
|
|
- rlcurd.submitFormThisPage.apply(this, [this.url])
|
|
|
- this.handleRefresh();
|
|
|
- },
|
|
|
- handleView(record){
|
|
|
- this.title = '查看'
|
|
|
- this.isReadonly=true
|
|
|
+ // 刷新路由
|
|
|
+ if (this.refreshRoute !== undefined && this.refreshRoute === true) {
|
|
|
+ this.handleUpdateUserInfo()
|
|
|
+ }
|
|
|
+ // 成功后
|
|
|
+ this.id = null
|
|
|
+ this.goback()
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.message)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goback() {
|
|
|
+ this.$router.go(-1)
|
|
|
+ },
|
|
|
+ sortChange(item) {
|
|
|
+ if (item.order) {
|
|
|
+ var field = item.prop,
|
|
|
+ order = item.order;
|
|
|
+ if (order == "descending") {
|
|
|
+ order = "desc";
|
|
|
+ } else {
|
|
|
+ order = "asc";
|
|
|
+ }
|
|
|
+ this.queryParam.order = order;
|
|
|
+ this.queryParam.field = field;
|
|
|
+ this.getList();
|
|
|
+ } else {
|
|
|
+ delete this.queryParam.order;
|
|
|
+ delete this.queryParam.field;
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ exportExcel() {
|
|
|
+ const query = this.queryParam
|
|
|
+ this.downloadLoading = true
|
|
|
+ this.$http.post(this.exportUrl, query, { 'timeout': 180000 }).then(response => {
|
|
|
+ this.downloadLoading = false
|
|
|
+ window.location.href = response.data.url
|
|
|
+ }).catch(() => {
|
|
|
+ this.downloadLoading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 列表请求
|
|
|
+ getList(params = null) {
|
|
|
+ const query = params ? params : this.queryParam
|
|
|
+ this.loading = true;
|
|
|
+ this.$http.get(this.url, { params: query }).then(response => {
|
|
|
|
|
|
- // 查看前
|
|
|
- if (this.beforeView !== undefined) {
|
|
|
- this.beforeView(record)
|
|
|
- }
|
|
|
- rlcurd.update.apply(this, [record])
|
|
|
- },
|
|
|
- // 更新
|
|
|
- handleUpdate(record, col, idx) {
|
|
|
- this.title = '更新'
|
|
|
- this.isReadonly=false
|
|
|
-
|
|
|
- this.id = record[this.pk !== undefined ? this.pk : 'id']
|
|
|
- // console.log(this.id)
|
|
|
- // 更新前
|
|
|
- if (this.beforeUpdate !== undefined) {
|
|
|
- this.beforeUpdate(record)
|
|
|
- }
|
|
|
- rlcurd.update.apply(this, [record])
|
|
|
-
|
|
|
- },
|
|
|
- // 详情
|
|
|
- handleDetail(id) {
|
|
|
- var id = {"id":id}
|
|
|
- this.$router.push({ path:'/devices/devicedetail', query: id })
|
|
|
- },
|
|
|
- //新开页面修改填充数据
|
|
|
- fillUpdateRecordPage(record) {
|
|
|
- this.isReadonly=false
|
|
|
- this.id = record[this.pk !== undefined ? this.pk : 'id']
|
|
|
- // 更新前
|
|
|
- if (this.beforeUpdate !== undefined) {
|
|
|
- this.beforeUpdate(record)
|
|
|
- }
|
|
|
- rlcurd.updatePage.apply(this, [record])
|
|
|
- },
|
|
|
- //新页面添加
|
|
|
- handleCreatePage(){
|
|
|
- this.id = null
|
|
|
- if (this.beforeUpdate !== undefined) {
|
|
|
- this.beforeUpdate(record)
|
|
|
- }
|
|
|
- this.$router.push({ path: this.formRedirect || '/'})
|
|
|
- },
|
|
|
- //新页面编辑
|
|
|
- handleUpdatePage(record){
|
|
|
- this.id = record[this.pk !== undefined ? this.pk : 'id']
|
|
|
- if (this.beforeUpdate !== undefined) {
|
|
|
- this.beforeUpdate(record)
|
|
|
- }
|
|
|
- this.$router.push({ path: this.formRedirect || '/', query: record })
|
|
|
- },
|
|
|
- // 删除
|
|
|
- handleDelete(id) {
|
|
|
- // 更新前
|
|
|
- if (this.beforeDelete !== undefined) {
|
|
|
- this.beforeDelete()
|
|
|
- }
|
|
|
- rlcurd.del.apply(this, [this.url + '/' + id, '确定删除吗?'])
|
|
|
- },
|
|
|
- // 关闭
|
|
|
- handleCancel() {
|
|
|
- this.formVisible = false
|
|
|
- // 防止提交关闭的时候 导致数据清空 所以延迟 300ms 清空数据
|
|
|
- setTimeout(this.resetFormFields, 300)
|
|
|
- this.$refs[this.formName].clearValidate()
|
|
|
- if (this.afterCancel !== undefined) {
|
|
|
- this.afterCancel()
|
|
|
- }
|
|
|
- },
|
|
|
- // 批量删除
|
|
|
- handleMultiDelete() {
|
|
|
- // 批量删除前
|
|
|
- if (this.beforeMultiDelete !== undefined) {
|
|
|
- this.beforeMultiDelete()
|
|
|
- }
|
|
|
- rlcurd.multiDel.apply(this, [this.url, '确定批量删除吗?'])
|
|
|
- },
|
|
|
- // 批量拆除
|
|
|
- handleMultiDelete_v1() {
|
|
|
- // 批量拆除前
|
|
|
- if (this.beforeMultiDelete !== undefined) {
|
|
|
- this.beforeMultiDelete()
|
|
|
- }
|
|
|
- rlcurd.multiDel.apply(this, [this.url, '确定批量拆除吗?'])
|
|
|
- },
|
|
|
- // 搜索
|
|
|
- handleSearch() {
|
|
|
- this.queryParam.page = 1
|
|
|
- this.getList()
|
|
|
- },
|
|
|
- // 刷新
|
|
|
- handleRefresh() {
|
|
|
- Object.keys(this.queryParam).forEach((k) => {
|
|
|
- // 如果未设置默认搜索参数,刷新将会清空搜索
|
|
|
- if (this.defaultQueryParam === undefined) {
|
|
|
- this.queryParam[k] = ''
|
|
|
- } else {
|
|
|
- // 清空不包含默认搜索参数
|
|
|
- if (this.defaultQueryParam.indexOf(k) === -1) {
|
|
|
- this.queryParam[k] = ''
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- //console.log(this.paginate)
|
|
|
- // 分页
|
|
|
- if (this.paginate.total) {
|
|
|
- this.queryParam.limit = this.paginate.limit
|
|
|
- this.queryParam.page = 1
|
|
|
- }
|
|
|
- this.getList()
|
|
|
- },
|
|
|
- // 选择全部
|
|
|
- handleSelectMulti(data) {
|
|
|
- this.selectedIds = []
|
|
|
- data.forEach(item => {
|
|
|
- this.selectedIds.push(item.id)
|
|
|
- })
|
|
|
- },
|
|
|
- rowClick(val){
|
|
|
- let ifHighlight=true
|
|
|
- if(this.selectedIds.length){
|
|
|
- this.selectedIds.map((item,i) => {
|
|
|
- if(val.id == item){
|
|
|
- ifHighlight=false
|
|
|
- this.highlight = false
|
|
|
- this.selectedIds.splice(i,1)
|
|
|
- }
|
|
|
+ this.data = response.data
|
|
|
+ this.handlePaginateResponse(response)
|
|
|
+ if (this.afterGetList !== undefined) {
|
|
|
+ this.afterGetList()
|
|
|
+ }
|
|
|
+ this.loading = false;
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false;
|
|
|
})
|
|
|
- if(ifHighlight){
|
|
|
- this.highlight = true
|
|
|
+ },
|
|
|
+ closeDialog() {
|
|
|
+ this.formVisible = false // 控制dialog弹框的不显示
|
|
|
+ },
|
|
|
+ closeBmapDialog() {
|
|
|
+
|
|
|
+ this.bmapVisible = false // 控制dialog弹框的不显示
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // model 弹出层
|
|
|
+ handleCreate() {
|
|
|
+ this.title = '新增'
|
|
|
+ this.isReadonly = false
|
|
|
+ this.id = null
|
|
|
+ // 创建前
|
|
|
+ if (this.beforeCreate !== undefined) {
|
|
|
+ this.beforeCreate()
|
|
|
}
|
|
|
-
|
|
|
- this.$refs.multipleTable.toggleRowSelection(val)
|
|
|
-
|
|
|
- }else{
|
|
|
- this.highlight = true
|
|
|
- this.$refs.multipleTable.toggleRowSelection(val)
|
|
|
- }
|
|
|
- },
|
|
|
- cellClick(row, column, cell, event){
|
|
|
- if(column.label == '操作'){
|
|
|
- if(this.selectedIds.length){
|
|
|
- this.selectedIds.map((item,i) => {
|
|
|
- if(row.id == item){
|
|
|
- this.highlight = true
|
|
|
- this.$refs.multipleTable.toggleRowSelection(row)
|
|
|
- }
|
|
|
+ this.resetFormFields();
|
|
|
+ this.formVisible = true
|
|
|
+ },
|
|
|
+ //
|
|
|
+ handleCreateSub(subrecord) {
|
|
|
+ this.title = '新增子级'
|
|
|
+ this.isReadonly = false
|
|
|
+ rlcurd.update.apply(this, [subrecord])
|
|
|
+ },
|
|
|
+ //子组件提交
|
|
|
+ handleSubmit() {
|
|
|
+
|
|
|
+ if (this.$refs[this.formName].beforeSubmit !== undefined) {
|
|
|
+ this.$refs[this.formName].beforeSubmit()
|
|
|
+ }
|
|
|
+ rlcurd.submitForm.apply(this, [this.$refs[this.formName].url])
|
|
|
+ this.handleRefresh()
|
|
|
+ },
|
|
|
+ // 本页面提交
|
|
|
+ handleSubmitThisPage() {
|
|
|
+ if (this.beforeSubmit !== undefined) {
|
|
|
+ this.beforeSubmit()
|
|
|
+ }
|
|
|
+ rlcurd.submitFormThisPage.apply(this, [this.url])
|
|
|
+ this.handleRefresh();
|
|
|
+ },
|
|
|
+ handleView(record) {
|
|
|
+ this.title = '查看'
|
|
|
+ this.isReadonly = true
|
|
|
+
|
|
|
+ // 查看前
|
|
|
+ if (this.beforeView !== undefined) {
|
|
|
+ this.beforeView(record)
|
|
|
+ }
|
|
|
+ rlcurd.update.apply(this, [record])
|
|
|
+ },
|
|
|
+ // 更新
|
|
|
+ handleUpdate(record, col, idx) {
|
|
|
+ this.title = '更新'
|
|
|
+ this.isReadonly = false
|
|
|
+
|
|
|
+ this.id = record[this.pk !== undefined ? this.pk : 'id']
|
|
|
+ // console.log(this.id)
|
|
|
+ // 更新前
|
|
|
+ if (this.beforeUpdate !== undefined) {
|
|
|
+ this.beforeUpdate(record)
|
|
|
+ }
|
|
|
+ rlcurd.update.apply(this, [record])
|
|
|
+
|
|
|
+ },
|
|
|
+ // 详情
|
|
|
+ handleDetail(id) {
|
|
|
+ var id = { "id": id }
|
|
|
+ this.$router.push({ path: '/devices/devicedetail', query: id })
|
|
|
+ },
|
|
|
+ //新开页面修改填充数据
|
|
|
+ fillUpdateRecordPage(record) {
|
|
|
+ this.isReadonly = false
|
|
|
+ this.id = record[this.pk !== undefined ? this.pk : 'id']
|
|
|
+ // 更新前
|
|
|
+ if (this.beforeUpdate !== undefined) {
|
|
|
+ this.beforeUpdate(record)
|
|
|
+ }
|
|
|
+ rlcurd.updatePage.apply(this, [record])
|
|
|
+ },
|
|
|
+ //新页面添加
|
|
|
+ handleCreatePage() {
|
|
|
+ this.id = null
|
|
|
+ if (this.beforeUpdate !== undefined) {
|
|
|
+ this.beforeUpdate(record)
|
|
|
+ }
|
|
|
+ this.$router.push({ path: this.formRedirect || '/' })
|
|
|
+ },
|
|
|
+ //新页面编辑
|
|
|
+ handleUpdatePage(record) {
|
|
|
+ this.id = record[this.pk !== undefined ? this.pk : 'id']
|
|
|
+ if (this.beforeUpdate !== undefined) {
|
|
|
+ this.beforeUpdate(record)
|
|
|
+ }
|
|
|
+ this.$router.push({ path: this.formRedirect || '/', query: record })
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ handleDelete(id) {
|
|
|
+ // 更新前
|
|
|
+ if (this.beforeDelete !== undefined) {
|
|
|
+ this.beforeDelete()
|
|
|
+ }
|
|
|
+ rlcurd.del.apply(this, [this.url + '/' + id, '确定删除吗?'])
|
|
|
+ },
|
|
|
+ // 关闭
|
|
|
+ handleCancel() {
|
|
|
+ this.formVisible = false
|
|
|
+ // 防止提交关闭的时候 导致数据清空 所以延迟 300ms 清空数据
|
|
|
+ setTimeout(this.resetFormFields, 300)
|
|
|
+ this.$refs[this.formName].clearValidate()
|
|
|
+ if (this.afterCancel !== undefined) {
|
|
|
+ this.afterCancel()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 批量删除
|
|
|
+ handleMultiDelete() {
|
|
|
+ // 批量删除前
|
|
|
+ if (this.beforeMultiDelete !== undefined) {
|
|
|
+ this.beforeMultiDelete()
|
|
|
+ }
|
|
|
+ rlcurd.multiDel.apply(this, [this.url, '确定批量删除吗?'])
|
|
|
+ },
|
|
|
+ // 批量拆除
|
|
|
+ handleMultiDelete_v1() {
|
|
|
+ // 批量拆除前
|
|
|
+ if (this.beforeMultiDelete !== undefined) {
|
|
|
+ this.beforeMultiDelete()
|
|
|
+ }
|
|
|
+ rlcurd.multiDel.apply(this, [this.url, '确定批量拆除吗?'])
|
|
|
+ },
|
|
|
+ // 搜索
|
|
|
+ handleSearch() {
|
|
|
+ this.queryParam.page = 1
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ // 刷新
|
|
|
+ handleRefresh() {
|
|
|
+ Object.keys(this.queryParam).forEach((k) => {
|
|
|
+ // 如果未设置默认搜索参数,刷新将会清空搜索
|
|
|
+ if (this.defaultQueryParam === undefined) {
|
|
|
+ this.queryParam[k] = ''
|
|
|
+ } else {
|
|
|
+ // 清空不包含默认搜索参数
|
|
|
+ if (this.defaultQueryParam.indexOf(k) === -1) {
|
|
|
+ this.queryParam[k] = ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //console.log(this.paginate)
|
|
|
+ // 分页
|
|
|
+ if (this.paginate.total) {
|
|
|
+ this.queryParam.limit = this.paginate.limit
|
|
|
+ this.queryParam.page = 1
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ // 选择全部
|
|
|
+ handleSelectMulti(data) {
|
|
|
+ this.selectedIds = []
|
|
|
+ data.forEach(item => {
|
|
|
+ this.selectedIds.push(item.id)
|
|
|
})
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- resetFormFields() {
|
|
|
- Object.keys(this.$refs[this.formName].formFieldsData).forEach((k) => {
|
|
|
- // console.log(k)
|
|
|
- // console.log(this.$refs[this.formName].formFieldsData[k])
|
|
|
- // console.log(typeof this.$refs[this.formName].formFieldsData[k])
|
|
|
- switch (typeof this.$refs[this.formName].formFieldsData[k]) {
|
|
|
- case 'object':
|
|
|
- this.$refs[this.formName].formFieldsData[k] = []
|
|
|
- break
|
|
|
- case 'bigint':
|
|
|
- this.$refs[this.formName].formFieldsData[k] = 1
|
|
|
- break
|
|
|
- case 'number':
|
|
|
- if (k === 'parent_id' || k === 'pid' || k === 'sex') {
|
|
|
- this.$refs[this.formName].formFieldsData[k] = 0
|
|
|
+ },
|
|
|
+ rowClick(val) {
|
|
|
+ let ifHighlight = true
|
|
|
+ if (this.selectedIds.length) {
|
|
|
+ this.selectedIds.map((item, i) => {
|
|
|
+ if (val.id == item) {
|
|
|
+ ifHighlight = false
|
|
|
+ this.highlight = false
|
|
|
+ this.selectedIds.splice(i, 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (ifHighlight) {
|
|
|
+ this.highlight = true
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(val)
|
|
|
+
|
|
|
} else {
|
|
|
- this.$refs[this.formName].formFieldsData[k] = ''
|
|
|
+ this.highlight = true
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(val)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cellClick(row, column, cell, event) {
|
|
|
+ if (column.label == '操作') {
|
|
|
+ if (this.selectedIds.length) {
|
|
|
+ this.selectedIds.map((item, i) => {
|
|
|
+ if (row.id == item) {
|
|
|
+ this.highlight = true
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(row)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- break
|
|
|
- case 'string':
|
|
|
- this.$refs[this.formName].formFieldsData[k] = ''
|
|
|
- break
|
|
|
- default:
|
|
|
- break
|
|
|
+ },
|
|
|
+ resetFormFields() {
|
|
|
+ Object.keys(this.$refs[this.formName].formFieldsData).forEach((k) => {
|
|
|
+ // console.log(k)
|
|
|
+ // console.log(this.$refs[this.formName].formFieldsData[k])
|
|
|
+ // console.log(typeof this.$refs[this.formName].formFieldsData[k])
|
|
|
+ switch (typeof this.$refs[this.formName].formFieldsData[k]) {
|
|
|
+ case 'object':
|
|
|
+ this.$refs[this.formName].formFieldsData[k] = []
|
|
|
+ break
|
|
|
+ case 'bigint':
|
|
|
+ this.$refs[this.formName].formFieldsData[k] = 1
|
|
|
+ break
|
|
|
+ case 'number':
|
|
|
+ if (k === 'parent_id' || k === 'pid' || k === 'sex') {
|
|
|
+ this.$refs[this.formName].formFieldsData[k] = 0
|
|
|
+ } else {
|
|
|
+ this.$refs[this.formName].formFieldsData[k] = ''
|
|
|
+ }
|
|
|
+ break
|
|
|
+ case 'string':
|
|
|
+ this.$refs[this.formName].formFieldsData[k] = ''
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
|
|
|
- // eslint-disable-next-line no-unreachable
|
|
|
- if (this.$refs[this.formName].formFieldsDefaultValues !== undefined && this.$refs[this.formName].formFieldsDefaultValues.indexOf(k)) {
|
|
|
- this.$refs[this.formName].formFieldsData[k] = this.$refs[this.formName].formFieldsDefaultValues[k]
|
|
|
+ // eslint-disable-next-line no-unreachable
|
|
|
+ if (this.$refs[this.formName].formFieldsDefaultValues !== undefined && this.$refs[this.formName].formFieldsDefaultValues.indexOf(k)) {
|
|
|
+ this.$refs[this.formName].formFieldsData[k] = this.$refs[this.formName].formFieldsDefaultValues[k]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 更新用户信息
|
|
|
+ handleUpdateUserInfo() {
|
|
|
+ store.dispatch('user/getInfo').then(response => {
|
|
|
+ const { roles, permissions } = response
|
|
|
+ store.dispatch('permission/generateRoutes', [roles, permissions]).then(r => {})
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.handlePaginateParams(val)
|
|
|
+ },
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.handlePaginateParams(0, val)
|
|
|
+ },
|
|
|
+ // 处理分页参数
|
|
|
+ handlePaginateParams(limit = 0, page = 0) {
|
|
|
+ if (limit) {
|
|
|
+ this.queryParam.limit = limit
|
|
|
+ this.paginate.limit = limit
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 更新用户信息
|
|
|
- handleUpdateUserInfo() {
|
|
|
- store.dispatch('user/getInfo').then(response => {
|
|
|
- const { roles, permissions } = response
|
|
|
- store.dispatch('permission/generateRoutes', [roles, permissions]).then(r => {})
|
|
|
- })
|
|
|
- },
|
|
|
- handleSizeChange(val) {
|
|
|
- this.handlePaginateParams(val)
|
|
|
- },
|
|
|
- handleCurrentChange(val) {
|
|
|
- this.handlePaginateParams(0, val)
|
|
|
- },
|
|
|
- // 处理分页参数
|
|
|
- handlePaginateParams(limit = 0, page = 0) {
|
|
|
- if (limit) {
|
|
|
- this.queryParam.limit = limit
|
|
|
- this.paginate.limit = limit
|
|
|
- }
|
|
|
- if (page) {
|
|
|
- this.queryParam.page = page
|
|
|
- this.paginate.current = page
|
|
|
- }
|
|
|
- this.getList()
|
|
|
- },
|
|
|
- handlePaginateResponse(response) {
|
|
|
-
|
|
|
- if (response.limit !== undefined) {
|
|
|
- this.paginate.total = response.count
|
|
|
- this.paginate.limit = response.limit
|
|
|
- this.paginate.current = response.current
|
|
|
- }
|
|
|
- },
|
|
|
- }
|
|
|
-}
|
|
|
+ if (page) {
|
|
|
+ this.queryParam.page = page
|
|
|
+ this.paginate.current = page
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ handlePaginateResponse(response) {
|
|
|
+
|
|
|
+ if (response.limit !== undefined) {
|
|
|
+ this.paginate.total = response.count
|
|
|
+ this.paginate.limit = response.limit
|
|
|
+ this.paginate.current = response.current
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|