# 字典数据

搭配若依系统使用

# 表单格式


<el-form-item label="项目类型" prop="xxx">
  <el-select v-model="queryParams.xxx" placeholder="请选择项目类型" clearable>
    <el-option
        v-for="dict in dict.type.xxx"
        :key="dict.value"
        :label="dict.label"
        :value="dict.value"
    />
  </el-select>
</el-form-item>

# 表格格式

# 字典翻译


<el-table-column label="项目类型" align="center" prop="xxx" width="100">
  <template slot-scope="scope">
    <dict-tag :options="dict.type.xxx" :value="scope.row.xxx"/>
  </template>
</el-table-column>

# 字典拼接


<el-table-column label="材料数量" align="center" prop="pchmNum">
  <template slot-scope="scope">
         <span>
           {{ dictFormat('pchm_specification', scope.row.pchmSpecification) }}
         </span>
  </template>
</el-table-column>

<script>
  export default {
    methods: {
      dictFormat(type, name) {
        // console.log("flag==>", flag)
        return this.selectDictLabel(this.dict.type[type], name);
      },
    }
  }
</script>

注意

若依改造后函数

export function selectDictLabel(datas, value) {
    if (value === undefined) {
        return "";
    }
    var actions = [];
    Object.keys(datas).some((key) => {
        if (datas[key].value == ('' + value)) {
            actions.push(datas[key].label);
            return true;
        }
    })
    if (actions.length === 0) {
        actions.push(value);
    }
    return actions.join('');
}