|
@@ -63,168 +63,167 @@
|
|
|
import {mapGetters, mapState} from "vuex";
|
|
|
import {clearCache} from "@/api/user";
|
|
|
|
|
|
-export default {
|
|
|
- name: "tags",
|
|
|
- data() {
|
|
|
- return {
|
|
|
- active: "",
|
|
|
- contentmenuX: "",
|
|
|
- contentmenuY: "",
|
|
|
- contextmenuFlag: false,
|
|
|
- data:''
|
|
|
- };
|
|
|
- },
|
|
|
- created() {
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- this.setActive();
|
|
|
- this.data = this.active
|
|
|
- },
|
|
|
- watch: {
|
|
|
- tag() {
|
|
|
- this.setActive();
|
|
|
+ export default {
|
|
|
+ name: "tags",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ active: "",
|
|
|
+ contentmenuX: "",
|
|
|
+ contentmenuY: "",
|
|
|
+ contextmenuFlag: false,
|
|
|
+ data:''
|
|
|
+ };
|
|
|
},
|
|
|
- contextmenuFlag() {
|
|
|
- window.addEventListener("mousedown", this.watchContextmenu);
|
|
|
- }
|
|
|
- },
|
|
|
- computed: {
|
|
|
- ...mapGetters(["tagWel", "tagList", "tag", "website"]),
|
|
|
- ...mapState({
|
|
|
- showTag: state => state.common.showTag
|
|
|
- }),
|
|
|
- tagLen() {
|
|
|
- return this.tagList.length || 0;
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- generateTitle(item) {
|
|
|
- return this.$router.$avueRouter.generateTitle(
|
|
|
- item.label,
|
|
|
- (item.meta || {}).i18n
|
|
|
- );
|
|
|
+ created() {
|
|
|
},
|
|
|
- watchContextmenu(event) {
|
|
|
- if (!this.$el.contains(event.target) || event.button !== 0) {
|
|
|
- this.contextmenuFlag = false;
|
|
|
- }
|
|
|
- window.removeEventListener("mousedown", this.watchContextmenu);
|
|
|
+ mounted() {
|
|
|
+ this.setActive();
|
|
|
+ this.data = this.active
|
|
|
},
|
|
|
- handleContextmenu(event) {
|
|
|
- let target = event.target;
|
|
|
- // 解决 https://github.com/d2-projects/d2-admin/issues/54
|
|
|
- let flag = false;
|
|
|
- if (target.className.indexOf("el-tabs__item") > -1) flag = true;
|
|
|
- else if (target.parentNode.className.indexOf("el-tabs__item") > -1) {
|
|
|
- target = target.parentNode;
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- if (flag) {
|
|
|
- event.preventDefault();
|
|
|
- event.stopPropagation();
|
|
|
- this.contentmenuX = event.clientX;
|
|
|
- this.contentmenuY = event.clientY;
|
|
|
- this.tagName = target.getAttribute("aria-controls").slice(5);
|
|
|
- this.contextmenuFlag = true;
|
|
|
+ watch: {
|
|
|
+ tag() {
|
|
|
+ this.setActive();
|
|
|
+ },
|
|
|
+ contextmenuFlag() {
|
|
|
+ window.addEventListener("mousedown", this.watchContextmenu);
|
|
|
}
|
|
|
},
|
|
|
- //激活当前选项
|
|
|
- setActive() {
|
|
|
- this.data = this.active
|
|
|
- this.active = this.tag.value;
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(["tagWel", "tagList", "tag", "website"]),
|
|
|
+ ...mapState({
|
|
|
+ showTag: state => state.common.showTag
|
|
|
+ }),
|
|
|
+ tagLen() {
|
|
|
+ return this.tagList.length || 0;
|
|
|
+ }
|
|
|
},
|
|
|
- menuTag(value, action) {
|
|
|
- if (action === "remove") {
|
|
|
- let {tag, key} = this.findTag(value);
|
|
|
- if(tag.label=="出口发货单"){
|
|
|
- this.$store.commit("OUT_OUT_DETAIL");
|
|
|
- }
|
|
|
- if(tag.label=="国内发货单"){
|
|
|
- this.$store.commit("IN_OUT_DETAIL");
|
|
|
- }
|
|
|
- if(tag.label=="进口发货单"){
|
|
|
- this.$store.commit("GO_OUT_DETAIL");
|
|
|
+ methods: {
|
|
|
+ generateTitle(item) {
|
|
|
+ return this.$router.$avueRouter.generateTitle(
|
|
|
+ item.label,
|
|
|
+ (item.meta || {}).i18n
|
|
|
+ );
|
|
|
+ },
|
|
|
+ watchContextmenu(event) {
|
|
|
+ if (!this.$el.contains(event.target) || event.button !== 0) {
|
|
|
+ this.contextmenuFlag = false;
|
|
|
}
|
|
|
- if(tag.label=="进口收货单"){
|
|
|
- this.$store.commit("TAKE_OUT_DETAIL");
|
|
|
+ window.removeEventListener("mousedown", this.watchContextmenu);
|
|
|
+ },
|
|
|
+ handleContextmenu(event) {
|
|
|
+ let target = event.target;
|
|
|
+ // 解决 https://github.com/d2-projects/d2-admin/issues/54
|
|
|
+ let flag = false;
|
|
|
+ if (target.className.indexOf("el-tabs__item") > -1) flag = true;
|
|
|
+ else if (target.parentNode.className.indexOf("el-tabs__item") > -1) {
|
|
|
+ target = target.parentNode;
|
|
|
+ flag = true;
|
|
|
}
|
|
|
- if(tag.label=="付款管理"){
|
|
|
- this.$store.commit("PAY_OUT_DETAIL");
|
|
|
+ if (flag) {
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopPropagation();
|
|
|
+ this.contentmenuX = event.clientX;
|
|
|
+ this.contentmenuY = event.clientY;
|
|
|
+ this.tagName = target.getAttribute("aria-controls").slice(5);
|
|
|
+ this.contextmenuFlag = true;
|
|
|
}
|
|
|
- this.$store.commit("DEL_TAG", tag);
|
|
|
- if (tag.value === this.tag.value) {
|
|
|
- tag = this.tagList[key === 0 ? key : key - 1]; //如果关闭本标签让前推一个
|
|
|
- this.openTag(tag);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- openTag(item) {
|
|
|
- // this.$confirm('未保存数据是否确认, 是否继续?', '提示', {
|
|
|
- // confirmButtonText: '确定',
|
|
|
- // cancelButtonText: '取消',
|
|
|
- // type: 'warning'
|
|
|
- // }).then(() => {
|
|
|
- let tag;
|
|
|
- if (item.name) {
|
|
|
- tag = this.findTag(item.name).tag;
|
|
|
- } else {
|
|
|
- tag = item;
|
|
|
+ },
|
|
|
+ //激活当前选项
|
|
|
+ setActive() {
|
|
|
+ this.data = this.active
|
|
|
+ this.active = this.tag.value;
|
|
|
+ },
|
|
|
+ menuTag(value, action) {
|
|
|
+ if (action === "remove") {
|
|
|
+ let {tag, key} = this.findTag(value);
|
|
|
+ if(tag.label=="出口发货单"){
|
|
|
+ this.$store.commit("OUT_OUT_DETAIL");
|
|
|
+ }
|
|
|
+ if(tag.label=="国内发货单"){
|
|
|
+ this.$store.commit("IN_OUT_DETAIL");
|
|
|
+ }
|
|
|
+ if(tag.label=="发货单"){
|
|
|
+ this.$store.commit("GO_OUT_DETAIL");
|
|
|
+ }
|
|
|
+ if(tag.label=="收货单"){
|
|
|
+ this.$store.commit("TAKE_OUT_DETAIL");
|
|
|
+ }
|
|
|
+ if(tag.label=="付款管理"){
|
|
|
+ this.$store.commit("PAY_OUT_DETAIL");
|
|
|
+ }
|
|
|
+ this.$store.commit("DEL_TAG", tag);
|
|
|
+ if (tag.value === this.tag.value) {
|
|
|
+ tag = this.tagList[key === 0 ? key : key - 1]; //如果关闭本标签让前推一个
|
|
|
+ this.openTag(tag);
|
|
|
+ }
|
|
|
}
|
|
|
+ },
|
|
|
+ openTag(item) {
|
|
|
+ // this.$confirm('未保存数据是否确认, 是否继续?', '提示', {
|
|
|
+ // confirmButtonText: '确定',
|
|
|
+ // cancelButtonText: '取消',
|
|
|
+ // type: 'warning'
|
|
|
+ // }).then(() => {
|
|
|
+ let tag;
|
|
|
+ if (item.name) {
|
|
|
+ tag = this.findTag(item.name).tag;
|
|
|
+ } else {
|
|
|
+ tag = item;
|
|
|
+ }
|
|
|
+ this.$router.push({
|
|
|
+ path: this.$router.$avueRouter.getPath({
|
|
|
+ name: tag.label,
|
|
|
+ src: tag.value
|
|
|
+ }, tag.meta),
|
|
|
+ query: tag.query
|
|
|
+ });
|
|
|
+ // }).catch(() => {
|
|
|
+ // this.active = this.data
|
|
|
+ // console.log(this.data)
|
|
|
+ // this.$message({
|
|
|
+ // type: 'info',
|
|
|
+ // message: '已取消删除'
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ closeOthersTags() {
|
|
|
+ this.contextmenuFlag = false;
|
|
|
+ this.$store.commit("DEL_TAG_OTHER");
|
|
|
+ this.$store.commit("DEL_OTHER_DETAIL",this.$store.getters.tag);
|
|
|
+ },
|
|
|
+ findTag(value) {
|
|
|
+ let tag, key;
|
|
|
+ this.tagList.map((item, index) => {
|
|
|
+ if (item.value === value) {
|
|
|
+ tag = item;
|
|
|
+ key = index;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return {tag: tag, key: key};
|
|
|
+ },
|
|
|
+ closeAllTags() {
|
|
|
+ this.contextmenuFlag = false;
|
|
|
+ this.$store.commit("DEL_ALL_TAG");
|
|
|
this.$router.push({
|
|
|
path: this.$router.$avueRouter.getPath({
|
|
|
- name: tag.label,
|
|
|
- src: tag.value
|
|
|
- }, tag.meta),
|
|
|
- query: tag.query
|
|
|
+ src: this.tagWel.value
|
|
|
+ }),
|
|
|
+ query: this.tagWel.query
|
|
|
});
|
|
|
- // }).catch(() => {
|
|
|
- // this.active = this.data
|
|
|
- // console.log(this.data)
|
|
|
- // this.$message({
|
|
|
- // type: 'info',
|
|
|
- // message: '已取消删除'
|
|
|
- // });
|
|
|
- // });
|
|
|
- },
|
|
|
- closeOthersTags() {
|
|
|
- this.contextmenuFlag = false;
|
|
|
- this.$store.commit("DEL_TAG_OTHER");
|
|
|
- console.log(this.$store.getters.tag)
|
|
|
- this.$store.commit("DEL_OTHER_DETAIL",this.$store.getters.tag);
|
|
|
- },
|
|
|
- findTag(value) {
|
|
|
- let tag, key;
|
|
|
- this.tagList.map((item, index) => {
|
|
|
- if (item.value === value) {
|
|
|
- tag = item;
|
|
|
- key = index;
|
|
|
- }
|
|
|
- });
|
|
|
- return {tag: tag, key: key};
|
|
|
- },
|
|
|
- closeAllTags() {
|
|
|
- this.contextmenuFlag = false;
|
|
|
- this.$store.commit("DEL_ALL_TAG");
|
|
|
- this.$router.push({
|
|
|
- path: this.$router.$avueRouter.getPath({
|
|
|
- src: this.tagWel.value
|
|
|
- }),
|
|
|
- query: this.tagWel.query
|
|
|
- });
|
|
|
- this.$store.commit("DEL_ALL_DETAIL");
|
|
|
- },
|
|
|
- clearCacheTags() {
|
|
|
- this.$confirm("是否需要清除缓存?", {
|
|
|
- confirmButtonText: "确定",
|
|
|
- cancelButtonText: "取消",
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- clearCache().then(() => {
|
|
|
- this.contextmenuFlag = false;
|
|
|
- this.$message.success('清除完毕');
|
|
|
- })
|
|
|
- });
|
|
|
+ this.$store.commit("DEL_ALL_DETAIL");
|
|
|
+ },
|
|
|
+ clearCacheTags() {
|
|
|
+ this.$confirm("是否需要清除缓存?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ clearCache().then(() => {
|
|
|
+ this.contextmenuFlag = false;
|
|
|
+ this.$message.success('清除完毕');
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-};
|
|
|
+ };
|
|
|
</script>
|