perf: model-box重构
This commit is contained in:
@@ -1,36 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="right-box">
|
<div class="right-box right-box-model" v-clickoutside="clickOutside" @click="inputHandler">
|
||||||
<div class="right-box right-box-model" v-if="rightBox.show" v-clickoutside="clickos" @click="inputHandler">
|
|
||||||
<!-- begin--顶部按钮-->
|
<!-- begin--顶部按钮-->
|
||||||
<div class="right-box-top-btns">
|
<div class="right-box-top-btns">
|
||||||
<button id="model-del" type="button" v-if="currentModel.id != '' && rightBox.isEdit" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
<button id="model-del" type="button" v-if="editModel.id" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light">
|
||||||
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
||||||
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button v-if="!rightBox.isEdit" id="model-save" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
|
||||||
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
|
|
||||||
<span class="right-box-top-btn-txt">{{$t('overall.edit')}}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- end--顶部按钮-->
|
<!-- end--顶部按钮-->
|
||||||
|
|
||||||
<!-- begin--标题-->
|
<!-- begin--标题-->
|
||||||
<div class="right-box-title">{{rightBox.title}}</div>
|
<div class="right-box-title">{{editModel.id ? ($t("config.model.editModel") + " ID:" + editModel.id) : $t("config.model.createModel")}}</div>
|
||||||
<!-- end--标题-->
|
<!-- end--标题-->
|
||||||
|
|
||||||
<!-- begin--表单-->
|
<!-- begin--表单-->
|
||||||
<el-scrollbar class="right-box-form-box">
|
<el-scrollbar class="right-box-form-box">
|
||||||
<el-form class="right-box-form right-box-form-left" :model="currentModel" label-position="right" label-width="120px" :rules="rules" ref="modelForm">
|
<el-form class="right-box-form right-box-form-left" :model="editModel" label-position="right" label-width="120px" :rules="rules" ref="modelForm">
|
||||||
<!--model名称-->
|
<!--model名称-->
|
||||||
<el-form-item :label='$t("overall.name")' prop="name">
|
<el-form-item :label='$t("overall.name")' prop="name">
|
||||||
<el-input v-if="rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model.trim="currentModel.name" size="small"></el-input>
|
<el-input placeholder="" maxlength="64" show-word-limit v-model.trim="editModel.name" size="small"></el-input>
|
||||||
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{currentModel.name}}</div>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!--设备类型-->
|
<!--设备类型-->
|
||||||
<el-form-item :label="$t('config.model.type')" prop="type">
|
<el-form-item :label="$t('config.model.type')" prop="type">
|
||||||
<el-autocomplete
|
<el-autocomplete
|
||||||
:fetch-suggestions="typeSuggestion"
|
:fetch-suggestions="typeSuggestion"
|
||||||
v-model.trim="currentModel.type.value"
|
v-model.trim="editModel.type.value"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
size="small"
|
size="small"
|
||||||
popper-class="no-style-class"
|
popper-class="no-style-class"
|
||||||
@@ -47,12 +41,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-autocomplete>
|
</el-autocomplete>
|
||||||
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!--厂商-->
|
<!--厂商-->
|
||||||
<el-form-item :label="$t('config.model.vendor')" prop="vendor">
|
<el-form-item :label="$t('config.model.vendor')" prop="vendor">
|
||||||
<el-autocomplete
|
<el-autocomplete
|
||||||
:fetch-suggestions="vendorSuggestion"
|
:fetch-suggestions="vendorSuggestion"
|
||||||
v-model.trim="currentModel.vendor.value"
|
v-model.trim="editModel.vendor.value"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
size="small"
|
size="small"
|
||||||
popper-class="no-style-class"
|
popper-class="no-style-class"
|
||||||
@@ -70,8 +65,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-autocomplete>
|
</el-autocomplete>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="this.$t('asset.createAssetTab.AddCabinetTab.uSize')" prop="uSize">
|
<el-form-item :label="this.$t('asset.createAssetTab.AddCabinetTab.uSize')" prop="usize">
|
||||||
<el-input v-model.number="currentModel.uSize" :max="47" size="small"></el-input>
|
<el-input v-model.number="editModel.usize" :max="47" size="small"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
@@ -81,13 +76,11 @@
|
|||||||
<button @click="esc" id="model-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
<button @click="esc" id="model-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
||||||
<span>{{$t('overall.cancel')}}</span>
|
<span>{{$t('overall.cancel')}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button v-if="rightBox.isEdit" @click="saveOrToEdit" id="model-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
<button @click="save" id="model-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
||||||
<span>{{$t('overall.save')}}</span>
|
<span>{{$t('overall.save')}}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -96,27 +89,13 @@
|
|||||||
export default {
|
export default {
|
||||||
name: "modelBox",
|
name: "modelBox",
|
||||||
props: {
|
props: {
|
||||||
model: Object
|
model: Object,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentModel: {
|
vendorData: [], //vendor下拉列表的数据
|
||||||
id: '',
|
typeData: [], //type下拉列表的数据
|
||||||
name: '',
|
editModel: {},
|
||||||
vendor: {id: '', value: '', code: '', type: ''},
|
|
||||||
type: {id: '', value: '', code: '', type: ''},
|
|
||||||
assetStat: {total: '', inStock: '', outStock: ''},
|
|
||||||
remark: '',
|
|
||||||
vendorCode: '',
|
|
||||||
typeCode: '',
|
|
||||||
uSize:1,
|
|
||||||
},
|
|
||||||
rightBox: {
|
|
||||||
show: false,
|
|
||||||
firstShow: false,
|
|
||||||
title: '',
|
|
||||||
isEdit: false
|
|
||||||
},
|
|
||||||
rules: {
|
rules: {
|
||||||
name: [
|
name: [
|
||||||
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
||||||
@@ -127,24 +106,18 @@
|
|||||||
vendor: [
|
vendor: [
|
||||||
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
||||||
],
|
],
|
||||||
uSize: [
|
usize: [
|
||||||
{type: 'number', min: 1, max: 47,message: this.$t('validate.uSize'),trigger: 'blur'}
|
{type: 'number', min: 1, max: 47,message: this.$t('validate.usize'),trigger: 'blur'}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
vendorData: [], //vendor下拉列表的数据
|
|
||||||
typeData: [], //type下拉列表的数据
|
|
||||||
editingVendor: '', //修改状态的vendor值
|
editingVendor: '', //修改状态的vendor值
|
||||||
editingType: '', //修改状态的assetType值
|
editingType: '', //修改状态的assetType值
|
||||||
dropdownHoverItem: '', //控制vendor和type下拉列表中操作按钮的展示
|
dropdownHoverItem: '', //控制vendor和type下拉列表中操作按钮的展示
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
show(show, isEdit) {
|
clickOutside() {
|
||||||
this.rightBox.show = show;
|
this.esc(false);
|
||||||
this.rightBox.isEdit = isEdit;
|
|
||||||
},
|
|
||||||
clickos() {
|
|
||||||
this.rightBox.show = false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//控制下拉框里input的状态
|
//控制下拉框里input的状态
|
||||||
@@ -170,9 +143,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/*关闭弹框*/
|
/*关闭弹框*/
|
||||||
esc() {
|
esc(refresh) {
|
||||||
this.rightBox.show = false;
|
this.$emit("close", refresh);
|
||||||
this.rightBox.firstShow = false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*保存*/
|
/*保存*/
|
||||||
@@ -181,106 +153,52 @@
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
let errMsg = [];
|
let errMsg = [];
|
||||||
//vendor和type如果是新记录,需要先请求后台新增,再获取code
|
//vendor和type如果是新记录,需要先请求后台新增,再获取code
|
||||||
let vendorReady = false;
|
let vendorReady;
|
||||||
let vendorCode = this.autocompleteExist('vendor', this.currentModel.vendor.value);
|
let vendorCode = this.autocompleteExist('vendor', this.editModel.vendor.value);
|
||||||
if (vendorCode) {
|
if (vendorCode) {
|
||||||
this.currentModel.vendorCode = vendorCode;
|
this.editModel.vendorCode = vendorCode;
|
||||||
vendorReady = true;
|
vendorReady = this.$TOOLS.blankPromise();
|
||||||
} else {
|
} else {
|
||||||
let vendor = {type: 'vendor', value: this.currentModel.vendor.value};
|
let vendor = {type: 'vendor', value: this.editModel.vendor.value};
|
||||||
this.$post("sys/dict/save", vendor).then(response => {
|
vendorReady = this.saveVendor(vendor);
|
||||||
if (response.code === 200) {
|
|
||||||
//保存成功后,重新获取
|
|
||||||
this.$get('sys/dict/all?type=vendor').then(response => {
|
|
||||||
if (response.code === 200) {
|
|
||||||
this.vendorData = response.data.map((item) => {
|
|
||||||
item.isEdit = false;
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
this.currentModel.vendorCode = this.autocompleteExist('vendor', this.currentModel.vendor.value);
|
|
||||||
vendorReady = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
errMsg.push("vendor");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let typeReady = false;
|
let typeReady;
|
||||||
let typeCode = this.autocompleteExist('type', this.currentModel.type.value);
|
let typeCode = this.autocompleteExist('type', this.editModel.type.value);
|
||||||
if (typeCode) {
|
if (typeCode) {
|
||||||
this.currentModel.typeCode = typeCode;
|
this.editModel.typeCode = typeCode;
|
||||||
typeReady = true;
|
typeReady = this.$TOOLS.blankPromise();
|
||||||
} else {
|
} else {
|
||||||
let type = {type: 'assetType', value: this.currentModel.type.value};
|
let type = {type: 'assetType', value: this.editModel.type.value};
|
||||||
this.$post("sys/dict/save", type).then(response => {
|
typeReady = this.saveType(type);
|
||||||
if (response.code === 200) {
|
|
||||||
this.$get('sys/dict/all?type=assetType').then(response => {
|
|
||||||
if (response.code === 200) {
|
|
||||||
this.typeData = response.data.map((item) => {
|
|
||||||
item.isEdit = false;
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
this.currentModel.typeCode = this.autocompleteExist('type', this.currentModel.type.value);
|
|
||||||
typeReady = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
errMsg.push("type");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let intervalTime = 1; //设置3秒超时
|
Promise.all([vendorReady, typeReady]).then(response => {
|
||||||
let interval = setInterval(() => {
|
if (this.editModel.id) {
|
||||||
if (vendorReady && typeReady) {
|
this.$put('model', this.editModel).then(response => {
|
||||||
if (this.currentModel.id) {
|
|
||||||
this.$put('model', this.currentModel).then(response => {
|
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||||
this.rightBox.show = false;
|
this.esc(true);
|
||||||
this.$emit('reload');
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$post('model', this.currentModel).then(response => {
|
this.$post('model', this.editModel).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||||
this.rightBox.show = false;
|
this.esc(true);
|
||||||
this.$emit("reload");
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
clearInterval(interval);
|
});
|
||||||
} else if (intervalTime > 15) {
|
|
||||||
if (errMsg.length > 0) {
|
|
||||||
this.$message.error(errMsg.join() + " error");
|
|
||||||
} else {
|
|
||||||
this.$message.error("Time out");
|
|
||||||
}
|
|
||||||
clearInterval(interval);
|
|
||||||
} else {
|
|
||||||
intervalTime++;
|
|
||||||
}
|
|
||||||
}, 200);
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveOrToEdit: function() {
|
|
||||||
if (!this.rightBox.isEdit) {
|
|
||||||
this.rightBox.isEdit = true;
|
|
||||||
this.rightBox.title = this.$t("config.model.editModel") + " ID:" + this.currentModel.id;
|
|
||||||
} else {
|
|
||||||
this.save();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/*删除*/
|
/*删除*/
|
||||||
del() {
|
del() {
|
||||||
this.$confirm(this.$t("tip.confirmDelete"), {
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
||||||
@@ -288,11 +206,10 @@
|
|||||||
cancelButtonText: this.$t("tip.no"),
|
cancelButtonText: this.$t("tip.no"),
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$delete("model?ids=" + this.currentModel.id).then(response => {
|
this.$delete("model?ids=" + this.editModel.id).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
||||||
this.rightBox.show = false;
|
this.esc(true);
|
||||||
this.$emit("reload");
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
@@ -309,6 +226,7 @@
|
|||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
||||||
this.getTypeData();
|
this.getTypeData();
|
||||||
|
this.$emit("reload");
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
@@ -321,6 +239,7 @@
|
|||||||
item.isEdit = true;
|
item.isEdit = true;
|
||||||
},
|
},
|
||||||
saveType(item) {
|
saveType(item) {
|
||||||
|
return new Promise(resolve => {
|
||||||
if (this.editingType) {
|
if (this.editingType) {
|
||||||
let temp = Object.assign({}, item);
|
let temp = Object.assign({}, item);
|
||||||
temp.value = this.editingType;
|
temp.value = this.editingType;
|
||||||
@@ -328,8 +247,8 @@
|
|||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
item.value = this.editingType;
|
item.value = this.editingType;
|
||||||
item.isEdit = false;
|
item.isEdit = false;
|
||||||
if (this.currentModel.type.id == item.id) {
|
if (this.editModel.type.id == item.id) {
|
||||||
this.currentModel.type.value = item.value;
|
this.editModel.type.value = item.value;
|
||||||
}
|
}
|
||||||
this.$emit("reload");
|
this.$emit("reload");
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||||
@@ -338,6 +257,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
editVendor(item) {
|
editVendor(item) {
|
||||||
this.editingVendor = item.value;
|
this.editingVendor = item.value;
|
||||||
@@ -345,6 +265,7 @@
|
|||||||
item.isEdit = true;
|
item.isEdit = true;
|
||||||
},
|
},
|
||||||
saveVendor(item) {
|
saveVendor(item) {
|
||||||
|
return new Promise(resolve => {
|
||||||
if (this.editingVendor) {
|
if (this.editingVendor) {
|
||||||
let temp = Object.assign({}, item);
|
let temp = Object.assign({}, item);
|
||||||
temp.value = this.editingVendor;
|
temp.value = this.editingVendor;
|
||||||
@@ -352,8 +273,8 @@
|
|||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
item.value = this.editingVendor;
|
item.value = this.editingVendor;
|
||||||
item.isEdit = false;
|
item.isEdit = false;
|
||||||
if (this.currentModel.vendor.id == item.id) {
|
if (this.editModel.vendor.id == item.id) {
|
||||||
this.currentModel.vendor.value = item.value;
|
this.editModel.vendor.value = item.value;
|
||||||
}
|
}
|
||||||
this.$emit("reload");
|
this.$emit("reload");
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||||
@@ -361,7 +282,23 @@
|
|||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.$post('sys/dict/save', item).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
item.value = this.editingVendor;
|
||||||
|
item.isEdit = false;
|
||||||
|
if (this.editModel.vendor.id == item.id) {
|
||||||
|
this.editModel.vendor.value = item.value;
|
||||||
}
|
}
|
||||||
|
this.$emit("reload");
|
||||||
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
delVendor(id) {
|
delVendor(id) {
|
||||||
this.$confirm(this.$t("tip.confirmDelete"), {
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
||||||
@@ -373,6 +310,7 @@
|
|||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
||||||
this.getVendorData();
|
this.getVendorData();
|
||||||
|
this.$emit("reload");
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
@@ -453,19 +391,12 @@
|
|||||||
this.getVendorData();
|
this.getVendorData();
|
||||||
this.getTypeData();
|
this.getTypeData();
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
},
|
|
||||||
watch: {
|
watch: {
|
||||||
model: {
|
model: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
deep:true,
|
deep:true,
|
||||||
handler(n, o) {
|
handler(n, o) {
|
||||||
this.currentModel = JSON.parse(JSON.stringify(n));
|
this.editModel = JSON.parse(JSON.stringify(n));
|
||||||
if (n && n.id) {
|
|
||||||
this.rightBox.title =this.rightBox.isEdit? this.$t("config.model.editModel") + " ID:" + n.id : this.$t("config.model.model") + " ID:" + n.id ;
|
|
||||||
} else {
|
|
||||||
this.rightBox.title = this.$t("config.model.createModel");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<div class="top-tool-search">
|
<div class="top-tool-search">
|
||||||
<search-input :searchMsg="searchMsg" @search="search" :inTransform="inTransform"></search-input>
|
<search-input :searchMsg="searchMsg" @search="search" :inTransform="inTransform"></search-input>
|
||||||
</div>
|
</div>
|
||||||
<button @click="toAdd" class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20" :title="$t('overall.createModel')"
|
<button @click="add" class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20" :title="$t('overall.createModel')"
|
||||||
id="model-add">
|
id="model-add">
|
||||||
<i class="nz-icon-create-square nz-icon"></i>
|
<i class="nz-icon-create-square nz-icon"></i>
|
||||||
</button>
|
</button>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<div v-else-if="item.prop == 'option'" class="content-right-options">
|
<div v-else-if="item.prop == 'option'" class="content-right-options">
|
||||||
<span :title="$t('dashboard.panel.title')" @click="panel(scope.row)" class="content-right-option" :id="'model-panel-'+scope.row.id"><i class="nz-icon nz-icon-template"></i></span>
|
<span :title="$t('dashboard.panel.title')" @click="panel(scope.row)" class="content-right-option" :id="'model-panel-'+scope.row.id"><i class="nz-icon nz-icon-template"></i></span>
|
||||||
<span :title="$t('overall.edit')" @click="toEdit(scope.row)" class="content-right-option" :id="'model-edit-'+scope.row.id"><i class="nz-icon nz-icon-edit"></i></span>
|
<span :title="$t('overall.edit')" @click="edit(scope.row)" class="content-right-option" :id="'model-edit-'+scope.row.id"><i class="nz-icon nz-icon-edit"></i></span>
|
||||||
<span :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" :id="'model-del-'+scope.row.id"><i class="el-icon-delete"></i></span>
|
<span :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" :id="'model-del-'+scope.row.id"><i class="el-icon-delete"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<template v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
<template v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
||||||
@@ -117,17 +117,17 @@
|
|||||||
@tablelable="tablelabelEmit"
|
@tablelable="tablelabelEmit"
|
||||||
ref="elementset"
|
ref="elementset"
|
||||||
></element-set>
|
></element-set>
|
||||||
<model-box ref="modelBox" :model="model" @reload="getTableData"></model-box>
|
<transition name="right-box">
|
||||||
|
<model-box v-if="rightBox.show" ref="modelBox" :model="model" @close="closeRightBox" @reload="getTableData"></model-box>
|
||||||
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import bus from '../../../libs/bus';
|
import bus from '../../../libs/bus';
|
||||||
var vm;
|
|
||||||
export default {
|
export default {
|
||||||
name: "model",
|
name: "model",
|
||||||
data() {
|
data() {
|
||||||
vm = this;
|
|
||||||
return {
|
return {
|
||||||
/*二级列表相关*/
|
/*二级列表相关*/
|
||||||
targetTab: '', //展示二级列表中的哪个页签
|
targetTab: '', //展示二级列表中的哪个页签
|
||||||
@@ -144,8 +144,9 @@
|
|||||||
|
|
||||||
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
||||||
tableHover: false, //控制滚动条和top按钮同时出现
|
tableHover: false, //控制滚动条和top按钮同时出现
|
||||||
|
rightBox: {show: false},
|
||||||
model: {
|
model: {},
|
||||||
|
blankModel: {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
vendor: {id: '', value: '', code: '', type: ''},
|
vendor: {id: '', value: '', code: '', type: ''},
|
||||||
@@ -250,9 +251,6 @@
|
|||||||
this.$store.commit('setHeaderTable', data);
|
this.$store.commit('setHeaderTable', data);
|
||||||
this.tablelable = data;
|
this.tablelable = data;
|
||||||
},
|
},
|
||||||
clickos() {
|
|
||||||
this.rightBox.show = false;
|
|
||||||
},
|
|
||||||
panel(obj) {
|
panel(obj) {
|
||||||
this.showSubList = true;
|
this.showSubList = true;
|
||||||
this.modelForPanel = obj;
|
this.modelForPanel = obj;
|
||||||
@@ -260,21 +258,24 @@
|
|||||||
},
|
},
|
||||||
// 全屏
|
// 全屏
|
||||||
fullScreen() {
|
fullScreen() {
|
||||||
|
let vm = this;
|
||||||
this.$bottomBoxWindow.fullScreen(vm);
|
this.$bottomBoxWindow.fullScreen(vm);
|
||||||
},
|
},
|
||||||
// 退出全屏
|
// 退出全屏
|
||||||
exitFullScreen() {
|
exitFullScreen() {
|
||||||
|
let vm = this;
|
||||||
this.$bottomBoxWindow.exitFullScreen(vm);
|
this.$bottomBoxWindow.exitFullScreen(vm);
|
||||||
},
|
},
|
||||||
// 鼠标拖动二级列表
|
// 鼠标拖动二级列表
|
||||||
listResize(e) {
|
listResize(e) {
|
||||||
|
let vm = this;
|
||||||
this.$bottomBoxWindow.listResize(vm, e);
|
this.$bottomBoxWindow.listResize(vm, e);
|
||||||
},
|
},
|
||||||
toEdit: function (u) {
|
edit(u) {
|
||||||
this.model = Object.assign({}, u);
|
this.model = Object.assign({}, u);
|
||||||
this.$refs.modelBox.show(true, true);
|
this.rightBox.show = true;
|
||||||
},
|
},
|
||||||
del: function (u) {
|
del(u) {
|
||||||
this.$confirm(this.$t("tip.confirmDelete"), {
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
||||||
confirmButtonText: this.$t("tip.yes"),
|
confirmButtonText: this.$t("tip.yes"),
|
||||||
cancelButtonText: this.$t("tip.no"),
|
cancelButtonText: this.$t("tip.no"),
|
||||||
@@ -284,23 +285,24 @@
|
|||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.deleteSuccess")});
|
||||||
this.getTableData();
|
this.getTableData();
|
||||||
this.rightBox.show = false;
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg);
|
this.$message.error(response.msg);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
detail: function (u) {
|
add() {
|
||||||
this.model = Object.assign({}, u);
|
this.model = this.newModel();
|
||||||
this.$refs.modelBox.show(true, false);
|
this.rightBox.show = true;
|
||||||
},
|
},
|
||||||
toAdd: function () {
|
newModel() {
|
||||||
this.cleanModel();
|
return JSON.parse(JSON.stringify(this.blankModel));
|
||||||
this.$refs.modelBox.show(true, true);
|
|
||||||
},
|
},
|
||||||
esc: function () {
|
closeRightBox(refresh) {
|
||||||
this.rightBox.show = false;
|
this.rightBox.show = false;
|
||||||
|
if (refresh) {
|
||||||
|
this.getTableData();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
jumpTo(data, id) {
|
jumpTo(data, id) {
|
||||||
bus.$emit("menu-change", data);
|
bus.$emit("menu-change", data);
|
||||||
@@ -311,7 +313,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getTableData: function () {
|
getTableData() {
|
||||||
this.tableData = [];
|
this.tableData = [];
|
||||||
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
||||||
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
||||||
@@ -334,7 +336,7 @@
|
|||||||
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val);
|
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val);
|
||||||
this.getTableData();
|
this.getTableData();
|
||||||
},
|
},
|
||||||
search: function (searchObj) {
|
search(searchObj) {
|
||||||
let orderBy = '';
|
let orderBy = '';
|
||||||
if(this.searchLabel.orderBy) {
|
if(this.searchLabel.orderBy) {
|
||||||
orderBy = this.searchLabel.orderBy
|
orderBy = this.searchLabel.orderBy
|
||||||
@@ -351,19 +353,6 @@
|
|||||||
}
|
}
|
||||||
this.getTableData();
|
this.getTableData();
|
||||||
},
|
},
|
||||||
cleanModel() {
|
|
||||||
this.model = {
|
|
||||||
id: '',
|
|
||||||
name: '',
|
|
||||||
vendor: {id: '', value: '', code: '', type: ''},
|
|
||||||
type: {id: '', value: '', code: '', type: ''},
|
|
||||||
assetStat: {total: '', inStock: '', outStock: ''},
|
|
||||||
remark: '',
|
|
||||||
vendorCode: '',
|
|
||||||
typeCode: '',
|
|
||||||
uSize:1,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
//是否需要排序
|
//是否需要排序
|
||||||
sortableShow(prop) {
|
sortableShow(prop) {
|
||||||
switch(prop){
|
switch(prop){
|
||||||
@@ -398,7 +387,7 @@
|
|||||||
this.getTableData();
|
this.getTableData();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted() {
|
||||||
//是否存在分页缓存
|
//是否存在分页缓存
|
||||||
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
||||||
if (pageSize != 'undefined' && pageSize != null) {
|
if (pageSize != 'undefined' && pageSize != null) {
|
||||||
@@ -434,6 +423,7 @@
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
showSubList(n) {
|
showSubList(n) {
|
||||||
|
let vm = this;
|
||||||
this.$bottomBoxWindow.showSubListWatch(vm, n);
|
this.$bottomBoxWindow.showSubListWatch(vm, n);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user