const App = {
|
mixins: [sharedMixin],/////共用的方法/////
|
data() {
|
return {
|
|
|
dialogVisible: {
|
country: false,
|
province: false,
|
city: false,
|
},
|
ifsubmit: false,
|
list: [],
|
countryList: [],
|
currCountryId: 0,
|
currProvinceId: 0,
|
currCityId: 0,
|
currCountryIndex: -1,
|
currProvinceIndex: 1,
|
currCityIndex: -1,
|
countryData: {
|
father_id: 0,
|
},
|
provinceData: {
|
father_id: 0,
|
},
|
cityData: {
|
father_id: 0,
|
},
|
provinceList: [],
|
cityList: [],
|
countryForm: {
|
father_id: 0,
|
},
|
provinceForm: {
|
father_id: 0,
|
},
|
cityForm: {
|
father_id: 0,
|
},
|
ifloading: {
|
country: false,
|
province: false,
|
city: false,
|
},
|
countryRules: {
|
cate_name: [
|
{ required: true, message: '请输入国家名称', trigger: 'blur' }
|
],
|
cate_code: [
|
{ required: true, message: '请输入国家编码', trigger: 'blur' }
|
],
|
},
|
provinceRules: {
|
cate_name: [
|
{ required: true, message: '请输入省份名称', trigger: 'blur' }
|
],
|
cate_code: [
|
{ required: true, message: '请输入省份编码', trigger: 'blur' }
|
],
|
},
|
cityRules: {
|
cate_name: [
|
{ required: true, message: '请输入城市名称', trigger: 'blur' }
|
],
|
},
|
|
};
|
},
|
mounted() {
|
this.getCountryList();
|
},
|
created() { },
|
methods: {
|
setProvince(index) {
|
let that = this;
|
that.currCountryId = that.countryList[index].id;
|
that.currCountryIndex = index;
|
that.provinceList = [];
|
that.getProvinceList();
|
},
|
setCity(index) {
|
let that = this;
|
that.currProvinceId = that.provinceList[index].id;
|
that.currProvinceIndex = index;
|
that.cityList = [];
|
that.getCityList();
|
},
|
countryCloseForm() {
|
this.dialogVisible.country = false
|
if (this.$refs['countryForm'] !== undefined) {
|
this.$refs['countryForm'].resetFields()
|
}
|
},
|
provinceCloseForm() {
|
this.dialogVisible.province = false
|
if (this.$refs['provinceForm'] !== undefined) {
|
this.$refs['provinceForm'].resetFields()
|
}
|
},
|
cityCloseForm() {
|
this.dialogVisible.city = false
|
if (this.$refs['cityForm'] !== undefined) {
|
this.$refs['cityForm'].resetFields()
|
}
|
},
|
createCountry(index) {
|
if (index >= 0) {
|
this.createCountryTitle = "编辑国家";
|
this.countryForm = JSON.parse(JSON.stringify(this.countryList[index]));
|
this.address = this.countryList[index];
|
} else {
|
this.createCountryTitle = "添加国家";
|
this.countryForm = {
|
father_id: 0,
|
}
|
}
|
this.dialogVisible.country = true;
|
|
},
|
createProvince(index) {
|
if (index >= 0) {
|
this.createProvinceTitle = "编辑省份(" + this.countryList[this.currCountryIndex].cate_name + ")";
|
this.provinceForm = JSON.parse(JSON.stringify(this.provinceList[index]));
|
} else {
|
this.createProvinceTitle = "添加省份(" + this.countryList[this.currCountryIndex].cate_name + ")";
|
this.provinceForm = {
|
father_id: this.currCountryId,
|
}
|
}
|
this.dialogVisible.province = true;
|
|
},
|
createCity(index) {
|
if (index >= 0) {
|
this.createCityTitle = "编辑城市(" + this.countryList[this.currCountryIndex].cate_name + '/' + this.provinceList[this.currProvinceIndex].cate_name + ")";
|
this.cityForm = JSON.parse(JSON.stringify(this.cityList[index]));
|
} else {
|
this.createCityTitle = "添加城市(" + this.countryList[this.currCountryIndex].cate_name + '/' + this.provinceList[this.currProvinceIndex].cate_name + ")";
|
this.cityForm = {
|
father_id: this.currProvinceId,
|
}
|
}
|
this.dialogVisible.city = true;
|
|
},
|
getCountryList() {
|
let that = this;
|
let url = "/admin/" + viewPath + "/getCountryCodeList.html"
|
postRequest(url, that.countryData).then(res => {
|
|
if (res.data.code == 200) {
|
that.countryList = res.data.list;
|
that.currCountryIndex = 0;
|
that.currCountryId = that.countryList[that.currCountryIndex].id;
|
if (that.ifloading.province == false) {
|
//第一次加载载入
|
that.getProvinceList();
|
}
|
}
|
else {
|
that.countryList = [];
|
//that.createCountry(-1);
|
}
|
});
|
},
|
getProvinceList() {
|
let that = this;
|
that.provinceData.father_id = that.currCountryId;
|
let url = "/admin/" + viewPath + "/getCountryCodeList.html"
|
postRequest(url, that.provinceData).then(res => {
|
|
that.ifloading.province = true;
|
if (res.data.code == 200) {
|
that.provinceList = res.data.list;
|
that.currProvinceIndex = 0;
|
that.currProvinceId = that.provinceList[that.currProvinceIndex].id;
|
// if (that.ifloading.city == false) {
|
//第一次加载载入
|
that.getCityList();
|
// }
|
}
|
else {
|
that.provinceList = [];
|
//that.createProvince(-1);
|
}
|
});
|
},
|
getCityList() {
|
let that = this;
|
that.cityData.father_id = that.currProvinceId;
|
let url = "/admin/" + viewPath + "/getCountryCodeList.html"
|
postRequest(url, that.cityData).then(res => {
|
that.ifloading.city = true;
|
if (res.data.code == 200) {
|
that.cityList = res.data.list;
|
that.currCityIndex = 0;
|
that.currCityId = that.cityList[that.currCityIndex].id;
|
}
|
else {
|
that.cityList = [];
|
that.currCityIndex = -1;
|
//that.createCity(-1);
|
}
|
});
|
},
|
updateShow(row) {
|
var { id, status } = row;
|
let url = "/admin/" + viewPath + "/updateShow.html"
|
postRequest(url, { id: id, status: status }).then(res => {
|
if (res.data.code != 200) {
|
row.status = status == 1 ? 0 : 1;//修改失败,恢复状态
|
}
|
});
|
},
|
/////保存国家信息/////
|
saveCountry() {
|
var that = this;
|
that.$refs.countryForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/saveCountryCode.html";
|
postRequest(url, that.countryForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.country = false;
|
that.getCountryList();
|
that.$message({
|
message: res.data.message,
|
type: 'success',
|
duration: 1000,
|
center: true,
|
onClose: function () {
|
that.ifsubmit = false;
|
|
}
|
});
|
}
|
else {
|
that.ifsubmit = false;
|
that.$message({
|
message: res.data.message,
|
type: 'error',
|
duration: 1500,
|
center: true
|
});
|
}
|
});
|
}
|
});
|
|
},
|
/////保存省份信息/////
|
saveProvince() {
|
var that = this;
|
that.$refs.provinceForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/saveCountryCode.html";
|
postRequest(url, that.provinceForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.province = false;
|
that.getProvinceList();
|
that.$message({
|
message: res.data.message,
|
type: 'success',
|
duration: 1000,
|
center: true,
|
onClose: function () {
|
that.ifsubmit = false;
|
|
}
|
});
|
}
|
else {
|
that.ifsubmit = false;
|
that.$message({
|
message: res.data.message,
|
type: 'error',
|
duration: 1500,
|
center: true
|
});
|
}
|
});
|
}
|
});
|
|
},
|
/////保存省份信息/////
|
saveCity() {
|
var that = this;
|
|
that.$refs.cityForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/saveCityCode.html";
|
postRequest(url, that.cityForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.city = false;
|
that.getCityList();
|
that.$message({
|
message: res.data.message,
|
type: 'success',
|
duration: 1000,
|
center: true,
|
onClose: function () {
|
that.ifsubmit = false;
|
|
}
|
});
|
}
|
else {
|
that.ifsubmit = false;
|
that.$message({
|
message: res.data.message,
|
type: 'error',
|
duration: 1500,
|
center: true
|
});
|
}
|
});
|
}
|
});
|
|
},
|
|
}
|
};
|
const app = Vue.createApp(App);
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
app.component(key, component)
|
}
|
app.use(ElementPlus, {
|
locale: ElementPlusLocaleZhCn,
|
});
|
app.mount("#vue_item");
|