const App = {
|
mixins: [sharedMixin],/////共用的方法/////
|
data() {
|
return {
|
|
|
dialogVisible: {
|
one: false,
|
two: false,
|
three: false,
|
platform: false,
|
},
|
ifsubmit: false,
|
list: [],
|
oneList: [],
|
platformList: [],
|
currPlatformId: 0,
|
currPlatformCateCode: '',
|
currPlatformIndex: -1,
|
currOneId: 0,
|
currOneCode: '',
|
currTwoId: 0,
|
currTwoCode: '',
|
currThreeId: 0,
|
currThreeCode: '',
|
currOneIndex: -1,
|
currTwoIndex: 1,
|
currThreeIndex: -1,
|
currOneCateCode: '',
|
currTwoCateCode: '',
|
currThreeCateCode: '',
|
platformData: {},
|
oneData: {
|
father_code: 0,
|
},
|
twoData: {
|
father_code: 0,
|
},
|
threeData: {
|
father_code: 0,
|
},
|
twoList: [],
|
threeList: [],
|
platformForm: {
|
docking_platform_name: "",
|
},
|
oneForm: {
|
father_code: '0',
|
},
|
twoForm: {
|
father_code: '',
|
},
|
threeForm: {
|
father_code: '',
|
},
|
ifloading: {
|
platform: false,
|
one: false,
|
two: false,
|
three: false,
|
},
|
platformRules: {
|
docking_platform_name: [
|
{ required: true, message: '请输入平台名称', trigger: 'blur' }
|
],
|
},
|
oneRules: {
|
cate_name: [
|
{ required: true, message: '请输入一级分类名称', trigger: 'blur' }
|
],
|
cate_code: [
|
{ required: true, message: '请输入一级分类编码', trigger: 'blur' }
|
],
|
},
|
twoRules: {
|
cate_name: [
|
{ required: true, message: '请输入二级分类名称', trigger: 'blur' }
|
],
|
cate_code: [
|
{ required: true, message: '请输入二级分类编码', trigger: 'blur' }
|
],
|
},
|
threeRules: {
|
cate_name: [
|
{ required: true, message: '请输入三级分类名称', trigger: 'blur' }
|
],
|
cate_code: [
|
{ required: true, message: '请输三级分类编码', trigger: 'blur' }
|
],
|
},
|
|
};
|
},
|
mounted() {
|
this.getPlatformList();
|
// this.getOneList();
|
},
|
created() { },
|
methods: {
|
setOne(index) {
|
let that = this;
|
that.currPlatformCateCode = that.platformList[index].cate_code;
|
that.currPlatformIndex = index;
|
that.oneList = [];
|
that.twoList = [];
|
that.threeList = [];
|
that.ifloading.one = false;
|
that.ifloading.two = false;
|
that.ifloading.three = false;
|
that.getOneList();
|
},
|
setTwo(index) {
|
let that = this;
|
that.currOneId = that.oneList[index].id;
|
that.currOneCateCode = that.oneList[index].cate_code;
|
that.currOneIndex = index;
|
that.ifloading.two = false;
|
that.ifloading.three = false;
|
that.twoList = [];
|
that.threeList = [];
|
that.getTwoList();
|
},
|
setThree(index) {
|
let that = this;
|
that.currTwoId = that.twoList[index].id;
|
that.currTwoCateCode = that.twoList[index].cate_code;
|
that.currTwoIndex = index;
|
that.threeList = [];
|
that.getThreeList();
|
},
|
platformCloseForm() {
|
this.dialogVisible.platform = false
|
if (this.$refs['platformForm'] !== undefined) {
|
this.$refs['platformForm'].resetFields()
|
}
|
},
|
oneCloseForm() {
|
this.dialogVisible.one = false
|
if (this.$refs['oneForm'] !== undefined) {
|
this.$refs['oneForm'].resetFields()
|
}
|
},
|
twoCloseForm() {
|
this.dialogVisible.two = false
|
if (this.$refs['twoForm'] !== undefined) {
|
this.$refs['twoForm'].resetFields()
|
}
|
},
|
threeCloseForm() {
|
this.dialogVisible.three = false
|
if (this.$refs['threeForm'] !== undefined) {
|
this.$refs['threeForm'].resetFields()
|
}
|
},
|
createPlatform(index) {
|
if (index >= 0) {
|
this.createPlatformTitle = "编辑对接平台";
|
this.platformForm = JSON.parse(JSON.stringify(this.platformList[index]));
|
} else {
|
this.createPlatformTitle = "添加对接平台";
|
this.platformForm = {}
|
}
|
this.dialogVisible.platform = true;
|
|
},
|
createOne(index) {
|
if (index >= 0) {
|
this.createOneTitle = "编辑一级分类";
|
this.oneForm = JSON.parse(JSON.stringify(this.oneList[index]));
|
} else {
|
this.createOneTitle = "添加一级分类";
|
this.oneForm = {
|
father_code: this.currPlatformCateCode,
|
}
|
}
|
this.dialogVisible.one = true;
|
|
},
|
createTwo(index) {
|
if (index >= 0) {
|
this.createTwoTitle = "编辑二级分类(" + this.oneList[this.currOneIndex].cate_name + ")";
|
this.twoForm = JSON.parse(JSON.stringify(this.twoList[index]));
|
} else {
|
this.createTwoTitle = "添加二级分类(" + this.oneList[this.currOneIndex].cate_name + ")";
|
this.twoForm = {
|
father_code: this.currOneCateCode,
|
}
|
}
|
this.dialogVisible.two = true;
|
|
},
|
createThree(index) {
|
if (index >= 0) {
|
this.createThreeTitle = "编辑三级分类(" + this.oneList[this.currOneIndex].cate_name + '/' + this.twoList[this.currTwoIndex].cate_name + ")";
|
this.threeForm = JSON.parse(JSON.stringify(this.threeList[index]));
|
} else {
|
this.createThreeTitle = "添加三级分类(" + this.oneList[this.currOneIndex].cate_name + '/' + this.twoList[this.currTwoIndex].cate_name + ")";
|
this.threeForm = {
|
father_code: this.currTwoCateCode,
|
}
|
}
|
this.dialogVisible.three = true;
|
|
},
|
getPlatformList() {
|
let that = this;
|
let url = "/admin/" + viewPath + "/getPlatformList.html"
|
postRequest(url, that.platformData).then(res => {
|
if (res.data.code == 200) {
|
that.platformList = res.data.list;
|
that.currPlatformIndex = 0;
|
that.currPlatformCateCode = that.platformList[that.currPlatformIndex].cate_code;
|
if (that.ifloading.one == false) {
|
//第一次加载载入
|
that.getOneList();
|
}
|
}
|
else {
|
that.platformList = [];
|
//that.createOne(-1);
|
}
|
});
|
},
|
getOneList() {
|
let that = this;
|
that.oneData.father_code = that.currPlatformCateCode;
|
let url = "/admin/" + viewPath + "/getCategoryList.html"
|
postRequest(url, that.oneData).then(res => {
|
if (res.data.code == 200) {
|
that.ifloading.one = true;
|
that.oneList = res.data.list;
|
that.currOneIndex = 0;
|
that.currOneCateCode = that.oneList[that.currOneIndex].cate_code;
|
if (that.ifloading.two == false) {
|
//重新载入
|
that.getTwoList();
|
}
|
}
|
else {
|
that.oneList = [];
|
that.twoList = [];
|
that.threeList = [];
|
that.ifloading.two = false;
|
that.ifloading.three = false;
|
}
|
});
|
},
|
getTwoList() {
|
let that = this;
|
that.twoData.father_code = that.currOneCateCode;
|
let url = "/admin/" + viewPath + "/getCategoryList.html"
|
postRequest(url, that.twoData).then(res => {
|
|
if (res.data.code == 200) {
|
that.ifloading.two = true;
|
that.twoList = res.data.list;
|
that.currTwoIndex = 0;
|
that.currTwoCateCode = that.twoList[that.currTwoIndex].cate_code;
|
if (that.ifloading.three == false) {
|
//重新载入
|
that.getThreeList();
|
}
|
}
|
else {
|
that.twoList = [];
|
that.threeList = [];
|
that.ifloading.three = true;
|
}
|
});
|
},
|
getThreeList() {
|
let that = this;
|
that.threeData.father_code = that.currTwoCateCode;
|
let url = "/admin/" + viewPath + "/getCategoryList.html"
|
postRequest(url, that.threeData).then(res => {
|
if (res.data.code == 200) {
|
that.ifloading.three = true;
|
that.threeList = res.data.list;
|
that.currThreeIndex = 0;
|
that.currThreeId = that.threeList[that.currThreeIndex].id;
|
}
|
else {
|
that.threeList = [];
|
that.currThreeIndex = -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;//修改失败,恢复状态
|
}
|
});
|
},
|
//保存对接平台信息
|
savePlatform() {
|
var that = this;
|
that.$refs.platformForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/savePlatform.html";
|
postRequest(url, that.platformForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.platform = false;
|
that.getPlatformList();
|
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
|
});
|
}
|
});
|
}
|
});
|
|
},
|
/////保存一级分类信息/////
|
saveOne() {
|
var that = this;
|
that.$refs.oneForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/saveCategory.html";
|
postRequest(url, that.oneForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.one = false;
|
that.getOneList();
|
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
|
});
|
}
|
});
|
}
|
});
|
|
},
|
/////保存二级分类信息/////
|
saveTwo() {
|
var that = this;
|
|
that.$refs.twoForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/saveCategory.html";
|
postRequest(url, that.twoForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.two = false;
|
that.getTwoList();
|
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
|
});
|
}
|
});
|
}
|
});
|
|
},
|
/////保存三级分类信息/////
|
saveThree() {
|
var that = this;
|
|
that.$refs.threeForm.validate(valid => {
|
if (valid) {
|
if (that.ifsubmit) {
|
return false;
|
}
|
that.ifsubmit = true;
|
let url = "/admin/" + viewPath + "/saveCategory.html";
|
postRequest(url, that.threeForm).then(res => {
|
if (res.data.code == 200) {
|
that.dialogVisible.three = false;
|
that.getThreeList();
|
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");
|