Explorar el Código

下拉框数据查询

duy hace 1 año
padre
commit
0c21a0b378
Se han modificado 2 ficheros con 39 adiciones y 12 borrados
  1. 26 5
      src/views/project/admin/create.vue
  2. 13 7
      src/views/project/gist/create.vue

+ 26 - 5
src/views/project/admin/create.vue

@@ -25,14 +25,14 @@
                 <el-col :span="6">
                     <el-form-item label="项目阶段:" prop="key3">
                         <el-select v-model="baseForm.key3" placeholder="请选择">
-                            <el-option v-for="item in stateOptions" :key="item.value" :label="item.label" :value="item.value" />
+                            <el-option v-for="item in stateOptions" :key="item.id" :label="item.dictValue" :value="item.id" />
                         </el-select>
                     </el-form-item>
                 </el-col>
                 <el-col :span="6">
                     <el-form-item label="项目类型:" prop="key4">
                         <el-select v-model="baseForm.key4" placeholder="请选择">
-                            <el-option v-for="item in typeOptions" :key="item.value" :label="item.label" :value="item.value" />
+                            <el-option v-for="item in typeOptions" :key="item.id" :label="item.dictValue" :value="item.id" />
                         </el-select>
                     </el-form-item>
                 </el-col>
@@ -134,6 +134,8 @@
 <script setup>
 import { onMounted, ref, watch } from 'vue'
 import { isNullES } from 'js-fast-way'
+import { getDictionary } from '~api/dictbiz'
+   import { arrToKey, formValidate, getArrValue, getObjValue, isArrItem } from 'js-fast-way'
 
 const props = defineProps({
     form: {
@@ -154,6 +156,8 @@ watch(() => props.form, (data) => {
 //渲染完成
 onMounted(() => {
     console.log(formInfo.value)
+    getProStation()
+    getProType()
 })
 
 const baseForm = ref({ key1:'', key2: '', key3:'', key4:'', key5:'', key6:'', key7:'', key8:'', key9:'' })
@@ -182,11 +186,28 @@ const baseFormRules = {
 const unitSelect = ref('')
 
 //项目阶段
-const stateOptions = ref([{ value: '1', label: '新开工项目' }, { value: '2', label: '建成项目' }, { value: '3', label: '在建项目' }])
+const stateOptions = ref([])
 
+const getProStation = async () => {
+    const { error, code, data } = await getDictionary({ code:'projectStage' })
+        if (!error && code === 200) {
+            stateOptions.value = getArrValue(data) 
+        } else {
+            stateOptions.value = []
+        }   
+    
+}
 //项目类型
-const typeOptions = ref([{ value: '1', label: '铁路' }, { value: '2', label: '高速公路' }, { value: '3', label: '在建项目' }])
-
+const typeOptions = ref([])
+const getProType = async () => {
+    const { error, code, data } = await getDictionary({ code:'projectType' })
+        if (!error && code === 200) {
+            typeOptions.value = getArrValue(data)
+        } else {
+            typeOptions.value = []
+        }   
+    
+    }
 //选择年份
 const yearOptions = ref([{ value: '2021', label: '2021' }, { value: '2022', label: '2022' }, { value: '2023', label: '2023' }])
 const selectYear = ref('')

+ 13 - 7
src/views/project/gist/create.vue

@@ -4,9 +4,9 @@
             <div class="flex-1 text-center text-[24px] font-bold">工作重点填写</div>
         </template>
         <el-form ref="baseFormRef" :model="baseForm" :rules="baseFormRules" label-position="top" label-width="auto" size="large">
-            <el-form-item label="选择项目项目阶段:" prop="key1">
+            <el-form-item label="选择项目阶段:" prop="key1">
                 <el-select v-model="baseForm.key1" placeholder="请选择">
-                    <el-option v-for="item in stateOptions" :key="item.value" :label="item.label" :value="item.value" />
+                    <el-option v-for="item in stateOptions" :key="item.id" :label="item.dictValue" :value="item.id" />
                 </el-select>
             </el-form-item>
             <el-form-item label="目标任务:" prop="key2">
@@ -47,6 +47,7 @@
 <script setup>
 import { onMounted, ref, watch } from 'vue'
 import { deepClone, getArrValue, getRandom, isNullES } from 'js-fast-way'
+import { getDictionary } from '~api/dictbiz'
 
 const props = defineProps({
     form: {
@@ -67,6 +68,7 @@ watch(() => props.form, (data) => {
 //渲染完成
 onMounted(() => {
     console.log(formInfo.value)
+    getProStationTip()
 })
 
 const baseFormRef = ref(null)
@@ -87,12 +89,16 @@ const baseFormRules = {
     },
 }
 //项目阶段
-const stateOptions = ref([
-    { value: '1', label: '紧盯重大项目,推动交通投资稳进' },
-  { value: '2', label: '深化战略研究,优化交通规划体系' },
-  { value: '3', label: '锚定战略目标,强化交通支撑引领作用' },
-])
+const stateOptions = ref([])
+const getProStationTip = async () => {
+const { error, code, data } = await getDictionary({ code:'workFocusStage' })
+    if (!error && code === 200) {
+        stateOptions.value = getArrValue(data)
+    } else {
+        stateOptions.value = []
+    }   
 
+}
 //处理ref
 const gistRefs = ref([])
 const setGistRefs = (el, index) => {