diff --git a/mini-app/src/apis/xiao4rApis.js b/mini-app/src/apis/xiao4rApis.js index 18af10df3..c9a7a7281 100644 --- a/mini-app/src/apis/xiao4rApis.js +++ b/mini-app/src/apis/xiao4rApis.js @@ -31,6 +31,13 @@ class Xiao4rApis { }) } + // 根据字典类型查询字典数据信息 + getDicts(dictType) { + return request.get({ + url: '/system/dict/data/type/' + dictType, + }) + } + } export default new Xiao4rApis() diff --git a/ruoyi-ui/src/utils/utils.js b/ruoyi-ui/src/utils/utils.js index 55ddac97d..8b1378917 100644 --- a/ruoyi-ui/src/utils/utils.js +++ b/ruoyi-ui/src/utils/utils.js @@ -1,16 +1 @@ -/** - * 根据字典值获取名称 - * @param value - * @param options - * @returns {string} - */ -export function getDictName(value,options) { - let actions = []; - Object.keys(options).some((key) => { - if (options[key].dictValue == ('' + value)) { - actions.push(options[key].dictLabel); - return true; - } - }) - return actions.join(''); -} + diff --git a/ruoyi-ui/src/views/goods/goods_main/index.vue b/ruoyi-ui/src/views/goods/goods_main/index.vue index 8033395f8..f730ae42d 100644 --- a/ruoyi-ui/src/views/goods/goods_main/index.vue +++ b/ruoyi-ui/src/views/goods/goods_main/index.vue @@ -105,7 +105,7 @@ - + @@ -165,10 +165,10 @@ @@ -252,7 +252,8 @@ import UploadImageMultiple from '@/components/UploadImageMultiple/index' import CommonMixin from "@/mixin/common"; import Editor from '@/components/Editor/index'; import {listSpec} from "@/api/goods/goods_spec"; -import {getDictName} from "@/utils/utils"; +import {getDept, listDept} from "@/api/system/dept"; +import {selectDictLabel} from "@/utils/ruoyi"; export default { name: "GoodsMain", @@ -288,7 +289,7 @@ export default { // 商品类型字典 goodsTypeOptions: [], // 商户类型字典 - mchOptions: [], + deptOptions: [], // 查询参数 queryParams: { pageNum: 1, @@ -302,6 +303,7 @@ export default { goodsImg: undefined, goodsPrice: undefined, goodsStock: undefined, + deptId: undefined, state: 0 }, // 表单参数 @@ -318,7 +320,7 @@ export default { }, filters: { getStateName(value, options) { - return getDictName(value, options) + return selectDictLabel(options, value); } }, created() { @@ -331,9 +333,11 @@ export default { this.goodsTypeOptions = response.data; }); - this.getDicts("merchant_dept").then(response => { - this.mchOptions = response.data; - }); + listDept().then(r => { + + this.deptOptions = r.data.filter(x => x.parentId === 300) + + }) }, methods: { inputGoodsFaceImg(fileName) { @@ -354,8 +358,11 @@ export default { }, // 商户类型字典翻译 - mchFormat(row, column) { - return this.selectDictLabel(this.mchOptions, row.deptId); + deptFormat(row, column) { + if (this.deptOptions.length < 1) { + return '' + } + return this.deptOptions.filter(x => x.deptId === row.deptId)[0].deptName }, /** 查询商品信息列表 */ getList() { @@ -375,6 +382,7 @@ export default { reset() { this.form = { id: undefined, + deptId: undefined, goodsName: undefined, goodsAlias: undefined, goodsType: undefined, diff --git a/ruoyi-ui/src/views/news/news_content/index.vue b/ruoyi-ui/src/views/news/news_content/index.vue index 2253b7d02..0c82747b6 100644 --- a/ruoyi-ui/src/views/news/news_content/index.vue +++ b/ruoyi-ui/src/views/news/news_content/index.vue @@ -220,8 +220,8 @@ import { import UploadImage from '@/components/UploadImage'; import CommonMixin from "@/mixin/common"; import Editor from '@/components/Editor'; -import {getDictName} from "@/utils/utils"; import {delTable} from "@/api/tool/gen"; +import {selectDictLabel} from "@/utils/ruoyi"; export default { name: "News_content", @@ -283,7 +283,7 @@ export default { }, filters: { getStateName(value, options) { - return getDictName(value, options) + return selectDictLabel(options, value) } }, created() {