|
|
|
@ -0,0 +1,269 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<Row class="search-row">
|
|
|
|
|
<i-col span="24" class="search-col">
|
|
|
|
|
<Row class="row-style">
|
|
|
|
|
<div class="search-div-btn">
|
|
|
|
|
<Button type="primary" @click="open(0,null)">添加</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Row>
|
|
|
|
|
</i-col>
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Table :loading="loading" ref="table" :columns="columns1" :data="data1" class="table-margin-top"
|
|
|
|
|
size="small">
|
|
|
|
|
<template slot-scope="{row}" slot="action">
|
|
|
|
|
<Button
|
|
|
|
|
ghost
|
|
|
|
|
type="primary"
|
|
|
|
|
size="small"
|
|
|
|
|
style="border: 0px;color:#2074E2"
|
|
|
|
|
@click="open(1,row)"
|
|
|
|
|
>修改
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
ghost
|
|
|
|
|
type="error"
|
|
|
|
|
size="small"
|
|
|
|
|
style="border: 0px"
|
|
|
|
|
@click="remove(row)"
|
|
|
|
|
>删除</Button>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
</Table>
|
|
|
|
|
<Page :total="totalSize" :current="pageNum" :page-size="pageSize" show-elevator show-total
|
|
|
|
|
placement="top" @on-change="handlePage" class-name="ks-page"></Page>
|
|
|
|
|
|
|
|
|
|
<!-- 修改大区 -->
|
|
|
|
|
<Modal
|
|
|
|
|
v-model="isShow"
|
|
|
|
|
:footer-hide="true"
|
|
|
|
|
>
|
|
|
|
|
<div slot="header">{{type === 0 ? '添加' : '修改'}}大区</div>
|
|
|
|
|
<Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
|
|
|
|
|
<FormItem label="大区名称" prop="name">
|
|
|
|
|
<i-input type="text" v-model="formValidate.name" placeholder="请输入大区名称"></i-input>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem style="text-align: left;">
|
|
|
|
|
<Button :loading="btnLoading" type="primary" @click="handleSubmit(formValidate)">{{type === 0 ? '保存' : '修改'}}</Button>
|
|
|
|
|
<Button @click="handleReset('formValidate')" style="margin-left: 10px">取消</Button>
|
|
|
|
|
</FormItem>
|
|
|
|
|
</Form>
|
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
<Modal v-model="isModelShow" title="删除提示" align="center">
|
|
|
|
|
<p style="margin-top: 20px;margin-bottom: 20px">
|
|
|
|
|
确定要删除此大区吗?删除后不可恢复
|
|
|
|
|
</p>
|
|
|
|
|
<div slot="footer"
|
|
|
|
|
style="text-align: center;margin-bottom: 10px;margin-top: 10px">
|
|
|
|
|
<Button style="width: 100px;" @click="isModelShow = false">取消</Button>
|
|
|
|
|
<Button :loading="btnLoading" type="error" style="width: 100px;margin-left: 20px" @click="deleteRegion">确认</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import service from '../../services/organization/OrganizationService'
|
|
|
|
|
export default {
|
|
|
|
|
name: "OrganizationRegion",
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
userId: "",
|
|
|
|
|
loading: false,
|
|
|
|
|
btnLoading: false,// 添加修改加载中
|
|
|
|
|
columns1: [
|
|
|
|
|
{
|
|
|
|
|
title: '序号',
|
|
|
|
|
key: 'index'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '大区名称',
|
|
|
|
|
key: 'name'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '操作',
|
|
|
|
|
slot: 'action',
|
|
|
|
|
width: '200px'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
data1: [
|
|
|
|
|
],
|
|
|
|
|
//分页内容
|
|
|
|
|
totalSize: 0,
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
isShow: false,
|
|
|
|
|
type: 0, // 0添加 1修改
|
|
|
|
|
formValidate: {
|
|
|
|
|
name: ''
|
|
|
|
|
},
|
|
|
|
|
ruleValidate: {
|
|
|
|
|
name: [
|
|
|
|
|
{required: true, message: '名称不能为空', trigger: 'blur'}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
isModelShow: false,
|
|
|
|
|
currentId: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.userId = JSON.parse(sessionStorage.getItem("loginInfo")).userId;
|
|
|
|
|
this.getData();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
remove: function (row) {
|
|
|
|
|
this.isModelShow = true;
|
|
|
|
|
this.currentId = row.id;
|
|
|
|
|
},
|
|
|
|
|
open: function (type, item) {
|
|
|
|
|
this.isShow = true;
|
|
|
|
|
this.type = type;
|
|
|
|
|
if(type === 0){
|
|
|
|
|
// 添加
|
|
|
|
|
this.formValidate = {
|
|
|
|
|
name: ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
this.formValidate = {
|
|
|
|
|
id: item.id,
|
|
|
|
|
name: item.name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
show: function (index) {
|
|
|
|
|
this.isShow = true;
|
|
|
|
|
this.showStoreName = index.name;
|
|
|
|
|
this.rowData = index;
|
|
|
|
|
},
|
|
|
|
|
hide: function () {
|
|
|
|
|
this.isShow = false;
|
|
|
|
|
},
|
|
|
|
|
handleSubmit(value) {
|
|
|
|
|
if (value) {
|
|
|
|
|
if(this.type === 0){
|
|
|
|
|
// 添加
|
|
|
|
|
this.addRegion(value.name);
|
|
|
|
|
}else{
|
|
|
|
|
// 调用修改接口
|
|
|
|
|
this.modifyRegion(value);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.$Message.error('Fail!');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleReset(name) {
|
|
|
|
|
this.$refs[name].resetFields();
|
|
|
|
|
this.isShow = false;
|
|
|
|
|
},
|
|
|
|
|
//切页处理
|
|
|
|
|
handlePage: function (value) {
|
|
|
|
|
this.pageNum = value;
|
|
|
|
|
this.getData();
|
|
|
|
|
},
|
|
|
|
|
deleteRegion: function () {
|
|
|
|
|
// 删除大区
|
|
|
|
|
let that = this;
|
|
|
|
|
if(that.currentId === 0){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
that.btnLoading = true;
|
|
|
|
|
let request = {
|
|
|
|
|
id: that.currentId
|
|
|
|
|
};
|
|
|
|
|
service.postOrganizationRemoveId(request, function (res) {
|
|
|
|
|
that.btnLoading = false;
|
|
|
|
|
let data = res.data;
|
|
|
|
|
if(data.code === "0000"){
|
|
|
|
|
that.$Message.success("删除成功");
|
|
|
|
|
that.isModelShow = false;
|
|
|
|
|
that.getData();
|
|
|
|
|
}else{
|
|
|
|
|
that.$Message.error("删除失败");
|
|
|
|
|
}
|
|
|
|
|
}, function () {
|
|
|
|
|
that.btnLoading = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
// 查询列表
|
|
|
|
|
getData: function () {
|
|
|
|
|
let that = this;
|
|
|
|
|
that.loading = true;
|
|
|
|
|
let request = {
|
|
|
|
|
userId: that.userId,
|
|
|
|
|
pageNum: that.pageNum,
|
|
|
|
|
pageSize: that.pageSize
|
|
|
|
|
};
|
|
|
|
|
service.getOrganizationRegionList(request, function (res) {
|
|
|
|
|
that.loading = false;
|
|
|
|
|
let data = res.data;
|
|
|
|
|
|
|
|
|
|
if(that.pageNum === 1){
|
|
|
|
|
that.data1 = [];
|
|
|
|
|
}
|
|
|
|
|
for (let i=0;i<data.results.records.length;i++) {
|
|
|
|
|
let item = data.results.records[i];
|
|
|
|
|
item.index = i+that.pageNum;
|
|
|
|
|
that.data1.push(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
that.totalSize = data.results.total;
|
|
|
|
|
}, function () {
|
|
|
|
|
that.loading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 添加大区
|
|
|
|
|
addRegion: function (name) {
|
|
|
|
|
let that = this;
|
|
|
|
|
let request = {
|
|
|
|
|
name: name
|
|
|
|
|
};
|
|
|
|
|
that.btnLoading = true;
|
|
|
|
|
service.postOrganizationRegionAdd(request, function (res) {
|
|
|
|
|
that.btnLoading = false;
|
|
|
|
|
let data = res.data;
|
|
|
|
|
if(data.code === "0000"){
|
|
|
|
|
that.$Message.success("添加成功");
|
|
|
|
|
that.hide();
|
|
|
|
|
that.getData();
|
|
|
|
|
}else{
|
|
|
|
|
that.$Message.error("添加失败");
|
|
|
|
|
}
|
|
|
|
|
}, function () {
|
|
|
|
|
that.btnLoading = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 修改大区
|
|
|
|
|
modifyRegion: function (val) {
|
|
|
|
|
let that = this;
|
|
|
|
|
let request = {
|
|
|
|
|
id: val.id,
|
|
|
|
|
name: val.name
|
|
|
|
|
};
|
|
|
|
|
service.postOrganizationRegionModify(request, function (res) {
|
|
|
|
|
that.btnLoading = false;
|
|
|
|
|
let data = res.data;
|
|
|
|
|
debugger
|
|
|
|
|
if(data.code === "0000"){
|
|
|
|
|
that.$Message.success("修改成功");
|
|
|
|
|
that.hide();
|
|
|
|
|
that.getData();
|
|
|
|
|
}else{
|
|
|
|
|
that.$Message.error("修改失败");
|
|
|
|
|
}
|
|
|
|
|
}, function () {
|
|
|
|
|
that.btnLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|