Jelajahi Sumber

参加单位

guhongwei 2 tahun lalu
induk
melakukan
95cc61cd1d
1 mengubah file dengan 53 tambahan dan 2 penghapusan
  1. 53 2
      src/views/company/detail.vue

+ 53 - 2
src/views/company/detail.vue

@@ -5,7 +5,22 @@
         <van-col span="24" class="one">
           <van-form @submit="toSave" label-width="auto">
             <van-cell-group>
-              <van-field v-model="form.lab_id" name="lab_id" type="textarea" rows="1" autosize label="实验室名称" placeholder="请输入实验室名称" />
+              <van-field v-model="form.lab_id" name="lab_id" style="display: none" />
+              <van-field v-model="form.lab_name" name="lab_name" label="实验室名称" placeholder="请输入实验室名称" readonly />
+              <van-field v-model="form.name" name="name" type="textarea" rows="1" autosize label="单位名称" placeholder="请输入单位名称" />
+              <van-field v-model="form.contact" name="contact" type="textarea" rows="1" autosize label="联系人" placeholder="请输入联系人" />
+              <van-field v-model="form.phone" name="phone" type="textarea" rows="1" autosize label="联系人电话" placeholder="请输入联系人电话" />
+              <van-field v-model="form.type" is-link readonly name="type" label="单位类别" placeholder="点击选择" @click="toPopup({ type: 'type' })" />
+              <van-field v-model="form.nature" is-link readonly name="nature" label="单位性质" placeholder="点击选择" @click="toPopup({ type: 'nature' })" />
+              <van-field
+                v-model="form.subjection"
+                is-link
+                readonly
+                name="subjection"
+                label="隶属"
+                placeholder="点击选择"
+                @click="toPopup({ type: 'subjection' })"
+              />
             </van-cell-group>
             <div class="btn">
               <van-button type="primary" size="small" native-type="submit"> 提交保存 </van-button>
@@ -14,6 +29,17 @@
         </van-col>
       </van-col>
     </van-row>
+    <van-popup v-model:show="popup.show" position="bottom">
+      <template v-if="popup.type == 'type'">
+        <van-picker :columns="company_type" :columns-field-names="{ text: 'dict_label', value: 'dict_label' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'nature'">
+        <van-picker :columns="company_nature" :columns-field-names="{ text: 'dict_label', value: 'dict_label' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+      <template v-else-if="popup.type == 'subjection'">
+        <van-picker :columns="company_subjection" :columns-field-names="{ text: 'dict_label', value: 'dict_label' }" @confirm="popChange" @cancel="toCancel" />
+      </template>
+    </van-popup>
   </div>
 </template>
 
@@ -43,7 +69,10 @@ const labList: Ref<any> = ref([]);
 
 const id: Ref<any> = ref('');
 // 表单
-const form: Ref<any> = ref({ file: [], files: [] });
+const form: Ref<any> = ref({});
+
+// 弹框
+const popup: Ref<any> = ref({ show: false, type: '' });
 
 // 字典表
 let company_type: Ref<any[]> = ref([]); // 单位类别
@@ -69,6 +98,7 @@ const searchBasic = async () => {
     basicInfo.value = data;
     labList.value = [data];
     form.value.lab_id = data._id;
+    form.value.lab_name = data.name;
   }
 };
 const search = async () => {
@@ -76,12 +106,33 @@ const search = async () => {
     let res: IQueryResult = await companyAxios.fetch(id.value);
     if (res.errcode == '0') {
       form.value = res.data;
+      form.value.lab_name = basicInfo.value.name;
     }
   }
 };
+// 选择
+const toPopup = (e) => {
+  popup.value = { show: true, type: e.type };
+};
+const popChange = (e) => {
+  let value = e.selectedValues;
+  if (popup.value.type == 'type') {
+    form.value.type = value[0];
+  } else if (popup.value.type == 'nature') {
+    form.value.nature = value[0];
+  } else if (popup.value.type == 'subjection') {
+    form.value.subjection = value[0];
+  }
+  toCancel();
+};
+// 关闭
+const toCancel = () => {
+  popup.value = { show: false };
+};
 // 保存
 const toSave = async (e) => {
   let res: IQueryResult;
+  delete e.lab_name;
   if (id.value) res = await companyAxios.update({ ...e, _id: id.value });
   else res = await companyAxios.create(e);
   if (res.errcode == '0') {