YangJian0701 1 rok pred
rodič
commit
cda8cb6fbe

BIN
dist.rar


+ 109 - 53
src/views/data/edit/AddVue.vue

@@ -1,53 +1,62 @@
 <template>
   <n-button type="primary" @click="showAddModal">添加数据</n-button>
-  <n-modal
-    v-model:show="showModal"
-    :show-icon="false"
-    preset="dialog"
-    title="添加">
-    <n-form :model="formValue" label-width="auto" show-require-mark>
-      <n-form-item label="测点" path="T_id">
-        <n-select
-          v-model:value="formValue.T_id"
-          label-field="T_id"
-          value-field="T_id"
-          @update:value="handleUpdateValue"
-          :options="classList"
-        />
-      </n-form-item>
-      <n-form-item label="温度" path="T_t">
-        <n-input v-model:value="formValue.T_t">
-          <template #suffix> ℃ </template>
-        </n-input>
-      </n-form-item>
-      <n-form-item label="湿度" path="T_rh">
-        <n-input v-model:value="formValue.T_rh">
-          <template #suffix> % </template>
-        </n-input>
-      </n-form-item>
-      <n-form-item label="时间" path="T_time">
-        <n-date-picker
-          v-model:formatted-value="formValue.T_time"
-          value-format="yyyy-MM-dd HH:mm:ss"
-          type="datetime"
-          clearable
-          class="w-full"
-        />
-      </n-form-item>
-      <n-form-item>
-        <n-button type="primary" style="margin-right: 20px;" @click="addTask">
-          立即提交
-        </n-button>
-        <n-button @click="showModal = false">取消</n-button>
-      </n-form-item>
-    </n-form>
+
+  <n-modal v-model:show="showModal" :show-icon="false" preset="dialog" title="添加" style="height: 550px;">
+    <n-tabs type="line" animated :default-value="defVal" :on-update:value="syncBarPosition">
+      <n-tab-pane name="oasis" tab="添加数据">
+        <n-form :model="formValue" label-width="auto" show-require-mark>
+          <n-form-item label="测点" path="T_id">
+            <n-select v-model:value="formValue.T_id" label-field="T_id" value-field="T_id"
+              @update:value="handleUpdateValue" :options="classList" />
+          </n-form-item>
+          <n-form-item label="温度" path="T_t">
+            <n-input v-model:value="formValue.T_t">
+              <template #suffix> ℃ </template>
+            </n-input>
+          </n-form-item>
+          <n-form-item label="湿度" path="T_rh">
+            <n-input v-model:value="formValue.T_rh">
+              <template #suffix> % </template>
+            </n-input>
+          </n-form-item>
+          <n-form-item label="时间" path="T_time">
+            <n-date-picker v-model:formatted-value="formValue.T_time" value-format="yyyy-MM-dd HH:mm:ss" type="datetime"
+              clearable class="w-full" />
+          </n-form-item>
+          <n-form-item>
+            <n-button type="primary" style="margin-right: 20px;" @click="addTask">
+              立即提交
+            </n-button>
+            <n-button @click="showModal = false">取消</n-button>
+          </n-form-item>
+        </n-form>
+      </n-tab-pane>
+
+      <n-tab-pane name="jaychou" tab="添加终端">
+        <div style="height: 350px;overflow-y: auto;">
+          <n-checkbox-group v-model:value="cheData.cities">
+            <n-space style="display: flex;flex-direction: column;">
+              <n-checkbox :value="item" :label="item.T_sn" v-for="item, index in cheData.chechboxVal" :key="item.Id" />
+            </n-space>
+          </n-checkbox-group>
+        </div>
+        <div style="margin-top: 20px;">
+          <n-button type="primary" style="margin-right: 20px;" @click="allAddTask">
+            立即提交
+          </n-button>
+          <n-button @click="showModal = false">取消</n-button>
+        </div>
+      </n-tab-pane>
+    </n-tabs>
+
   </n-modal>
 </template>
 
 <script setup>
-import { addTaskData } from '@/api';
+import { addTaskData, getCertificateList } from '@/api';
+import {TimeData} from '@/plugin/timeFun';
 
-// const emit = defineEmits(["submit"]);
+const emit = defineEmits(["addFuns"]);
 
 const props = defineProps({
   task: {
@@ -59,9 +68,56 @@ const props = defineProps({
     default: [],
   },
 });
-
+const defVal = ref('oasis')
+const cheData = reactive({
+  cities: null,//已选择
+  chechboxVal: [],//值
+})
 const message = useMessage();
+const syncBarPosition = (e) => {
+  console.log('切换', e)
+  defVal.value = e
+}
+const CarteApi = () => {
+  getCertificateList({
+    page: 1,
+    page_z: 999
+  }).then(res => {
+    if (res.data.Code == 200) {
+      cheData.chechboxVal = res.data.Data.List
+    }
+    console.log('111', res)
+  })
+}
+const allAddTask = async()=>{
+  console.log('1',cheData.cities)
+  if (cheData.cities==null || cheData.cities.length==0) {
+    message.error('请选择至少一项哦!')
+    return
+  }else{
+    const times = TimeData(new Date())
+    let num = 0
+    for (let i = 0; i < cheData.cities.length; i++) {
+      const { data: res } = await addTaskData({
+        T_task_id: props.task.T_task_id,
+        T_sn: cheData.cities[i].T_sn,
+        T_id: cheData.cities[i].T_layout_no,
+        T_t: 0,
+        T_rh: 0,
+        T_time: times,
+      });
+      num += 1
+      if(num==cheData.cities.length){
+        message.success('添加完成')
+        emit('addFuns', true);
+      }
+    }
+  }
 
+  return
+  
+    
+}
 // 是否展示 Modal
 const showModal = ref(false);
 
@@ -76,7 +132,6 @@ const formValue = reactive({
 
 // 值更新时执行的回调
 const handleUpdateValue = (value, option) => {
-  console.log('handleUpdateValue',option)
   formValue.T_id = option.T_id;
   formValue.T_sn = option.T_sn;
 };
@@ -84,14 +139,15 @@ const handleUpdateValue = (value, option) => {
 // 显示添加
 const showAddModal = () => {
   showModal.value = true;
+  CarteApi()
   Object.keys(formValue).forEach((key) => (formValue[key] = null));
 };
 
 // 获取设备列表
-const addTask = async () => { 
+const addTask = async () => {
   const sto = await inspect(formValue)
-  console.log('999',formValue)
-  if(sto){
+  console.log('999', formValue)
+  if (sto) {
     Object.keys(formValue).forEach((key) => (formValue[key] += ''));
     const { data: res } = await addTaskData({
       T_task_id: props.task.T_task_id,
@@ -101,19 +157,19 @@ const addTask = async () => {
       showModal.value = false
       message.success(res.Msg);
     }
-  }else{
+  } else {
     message.error('所有选项都为必填哦')
     return
   }
 };
-const inspect = (value)=>{
-  return new Promise(resolve=>{
-    const j = Object.keys(value).every(key=>{
+const inspect = (value) => {
+  return new Promise(resolve => {
+    const j = Object.keys(value).every(key => {
       return value[key] != null
     })
     resolve(j)
   })
- 
+
 } 
 </script>
 

+ 10 - 5
src/views/data/edit/SetVue.vue

@@ -32,8 +32,11 @@
 import { useStore } from 'vuex';
 import emitter from "@/plugin/bus";
 const emit = defineEmits(['submit']);
+import {onMounted} from 'vue'
 
 const store = useStore()
+
+
 const submitCallback = () => {
   emitter.emit("onMessage",formValue);
   store.commit('setplotData',formValue)  
@@ -45,12 +48,14 @@ const showModal = ref(false);
 
 // 表单数据
 const formValue = reactive({
-  tTop: 8.25,
-  tBottom: 8.15,
-  hTop: 73.07,
-  hBottom: 73.03,
+  tTop: 8,
+  tBottom: 2,
+  hTop: null,
+  hBottom: null,
 });
-
+onMounted(()=>{
+  emitter.emit("onMessage",formValue);
+})
 // 显示设置
 const showSetModal = () => {
   showModal.value = true;

+ 5 - 1
src/views/data/edit/index.vue

@@ -70,7 +70,7 @@
               <ExportVue :queryObj=" queryData " :pickleveTime=" pickTimes.pickleveTime " :checkData=" checkValues " />
               <ImportVue :task=" task " />
               <ImportPlatform :task=" task " />
-              <AddVue :class-list=" classList " :task=" task " />
+              <AddVue :class-list=" classList" @addFuns="addFuns" :task=" task " />
               <SetVue />
               <editCopy :queryObj=" queryData " :pickleveTime=" pickTimes.pickleveTime " :checkData=" checkValues " :classList=" classList " />
               <AverageCopy :queryObj=" queryData " :pickleveTime=" pickTimes.pickleveTime " :checkData=" checkValues " :classList=" classList "></AverageCopy>
@@ -201,6 +201,10 @@ const setTimeFuns = (e) => {
   }
 }
 
+const addFuns = (e)=>{
+  console.log('父亲',e)
+  getClassList();
+}
 
 const blurFun = () =>{
   console.log('失去焦点')