This commit is contained in:
nyoung 2024-09-06 11:21:18 +08:00
parent f0da151f3c
commit 7a74264ff2
10 changed files with 120 additions and 77 deletions

View File

@ -1,88 +1,24 @@
<template>
<div>
<template v-for="(item, index) in options">
<template v-if="values.includes(item.value)">
<span
v-if="item.listClass == 'default' || item.listClass == ''"
:key="item.value"
:index="index"
:class="item.cssClass"
>{{ item.label + " " }}</span
>
<el-tag
v-else
:disable-transitions="true"
:key="item.value"
:index="index"
:type="item.listClass == 'primary' ? '' : item.listClass"
:class="item.cssClass"
>
{{ item.label + " " }}
<span>
<template v-for="(dict, index) in this.getDictDatas2(type, value)">
<!-- 默认样式 -->
<span v-if="dict.colorType === 'default' || dict.colorType === '' || dict.colorType === undefined" :key="dict.value" :index="index"
:class="dict.cssClass">{{ dict.label }}</span>
<!-- Tag 样式 -->
<el-tag v-else :disable-transitions="true" :key="dict.value" :index="index" :type="dict.colorType" :class="dict.cssClass">
{{ dict.label }}
</el-tag>
</template>
</template>
<template v-if="unmatch && showValue">
{{ unmatchArray | handleArray }}
</template>
</div>
</span>
</template>
<script>
export default {
name: "DictTag",
props: {
options: {
type: Array,
default: null,
type: String,
value: [Number, String, Boolean, Array],
},
value: [Number, String, Array],
// value
showValue: {
type: Boolean,
default: true,
}
},
data() {
return {
unmatchArray: [], //
}
},
computed: {
values() {
if (this.value !== null && typeof this.value !== "undefined") {
return Array.isArray(this.value) ? this.value : [String(this.value)];
} else {
return [];
}
},
unmatch() {
this.unmatchArray = [];
if (this.value !== null && typeof this.value !== "undefined") {
//
if (!Array.isArray(this.value)) {
if (this.options.some((v) => v.value == this.value)) return false;
this.unmatchArray.push(this.value);
return true;
}
// Array
this.value.forEach((item) => {
if (!this.options.some((v) => v.value == item))
this.unmatchArray.push(item);
});
return true;
}
// value
return false;
},
},
filters: {
handleArray(array) {
if (array.length === 0) return "";
return array.reduce((pre, cur) => {
return pre + " " + cur;
})
}
}
};
</script>
<style scoped>

View File

@ -0,0 +1,92 @@
<template>
<div>
<template v-for="(item, index) in options">
<template v-if="values.includes(item.value)">
<span
v-if="item.listClass == 'default' || item.listClass == ''"
:key="item.value"
:index="index"
:class="item.cssClass"
>{{ item.label + " " }}</span
>
<el-tag
v-else
:disable-transitions="true"
:key="item.value"
:index="index"
:type="item.listClass == 'primary' ? '' : item.listClass"
:class="item.cssClass"
>
{{ item.label + " " }}
</el-tag>
</template>
</template>
<template v-if="unmatch && showValue">
{{ unmatchArray | handleArray }}
</template>
</div>
</template>
<script>
export default {
name: "DictTag",
props: {
options: {
type: Array,
default: null,
},
value: [Number, String, Array],
// value
showValue: {
type: Boolean,
default: true,
}
},
data() {
return {
unmatchArray: [], //
}
},
computed: {
values() {
if (this.value !== null && typeof this.value !== "undefined") {
return Array.isArray(this.value) ? this.value : [String(this.value)];
} else {
return [];
}
},
unmatch() {
this.unmatchArray = [];
if (this.value !== null && typeof this.value !== "undefined") {
//
if (!Array.isArray(this.value)) {
if (this.options.some((v) => v.value == this.value)) return false;
this.unmatchArray.push(this.value);
return true;
}
// Array
this.value.forEach((item) => {
if (!this.options.some((v) => v.value == item))
this.unmatchArray.push(item);
});
return true;
}
// value
return false;
},
},
filters: {
handleArray(array) {
if (array.length === 0) return "";
return array.reduce((pre, cur) => {
return pre + " " + cur;
})
}
}
};
</script>
<style scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
</style>

View File

@ -149,8 +149,10 @@
import { getDicts } from '@/api/system/dict/data.js'
import request from "@/utils/request";
import {parseTime} from "../../../../utils/ruoyi";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "News",
components:{DictTag},
data() {
return {
inspection_new_type: [],

View File

@ -270,9 +270,11 @@
import {fjPartners, listMallPartners,} from "../inspection/api/Partner";
import { tijiaoshenhe, homeGoods, listInspectionGoods, getInspectionGoods, delInspectionGoods, addInspectionGoods, updateInspectionGoods } from "./api/inspectionGoods";
import request from "@/utils/request";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "InspectionGoods",
components:{DictTag},
dicts: ['is_special', 'yes_no'],
data() {

View File

@ -281,9 +281,11 @@
<script>
import { listInsuranceOrder, getInsuranceOrder, delInsuranceOrder, addInsuranceOrder, updateInsuranceOrder } from "@/api/system/insuranceOrder";
import request from "@/utils/request";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "InsuranceOrder",
components:{DictTag},
dicts: ['comment_star', 'order_status'],
data() {
return {

View File

@ -301,9 +301,11 @@
<script>
import { listCustomerInfo, getCustomerInfo, delCustomerInfo, addCustomerInfo, updateCustomerInfo } from "./api/customer";
import request from "@/utils/request";
import DictTag from '@/components/DictTagOld/index.vue'
export default {
name: "CustomerInfo",
components:{DictTag},
dicts: ['sys_user_sex','jcz_role'],
data() {
return {

View File

@ -285,9 +285,11 @@
import print from 'vue-print-nb'
import moment from 'moment';
import request from "@/utils/request";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "Info",
components:{DictTag},
dicts: ['customer_source','pay_type','car_status','car_use_nature','inspection_use_role'],
directives: {
print

View File

@ -192,8 +192,10 @@
import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "./api/ordermanagement";
import moment from 'moment';
import request from "@/utils/request";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "Info",
components:{DictTag},
dicts: ['order_status', 'all_order_type'],
data() {
return {

View File

@ -278,10 +278,11 @@
import {editSkuPrice,shangxiajia,categoryList,goodsDetail, shopInfo, tijiaoshenhe, homeGoods, listInspectionGoods, getInspectionGoods, delInspectionGoods, addInspectionGoods, updateInspectionGoods } from "./api/shopadministration.js";
import request from "@/utils/request";
import Editor from "@/components/Editor/index.vue";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "InspectionGoods",
components: {Editor},
components: {Editor,DictTag},
dicts: ['is_special', 'yes_no'],
data() {

View File

@ -357,6 +357,7 @@
import print from 'vue-print-nb'
import moment from 'moment';
import request from "@/utils/request";
import DictTag from "@/components/DictTagOld/index.vue";
export default {
name: "Info",
@ -364,6 +365,7 @@
directives: {
print
},
components:{DictTag},
data() {
return {
moneyData:{