From f91c24d2b2b513716ffe9f4259a8a343c841bb00 Mon Sep 17 00:00:00 2001
From: 13937891274 <kxc0822>
Date: 星期六, 30 七月 2022 18:10:28 +0800
Subject: [PATCH] 数据对接

---
 src/components/emergencySupplies/index.vue |  135 +++++++++++++++++++++++++++++---------------
 1 files changed, 89 insertions(+), 46 deletions(-)

diff --git a/src/components/emergencySupplies/index.vue b/src/components/emergencySupplies/index.vue
index ff5839a..dec3310 100644
--- a/src/components/emergencySupplies/index.vue
+++ b/src/components/emergencySupplies/index.vue
@@ -12,45 +12,58 @@
         <el-row>
           <el-form ref="ruleFormRef" :model="ruleForm" :inline="true" status-icon>
             <el-form-item>
-              <el-input size="default" v-model="ruleForm.pass" placeholder="物资名称"  style="max-width: 215px;"/>
+              <el-input size="default" v-model="listQuery.searchParams.name" placeholder="物资名称"  style="max-width: 215px;"/>
             </el-form-item>
             <el-form-item>
-              <el-button size="default" type="primary" @click="submitForm(ruleFormRef)">查询</el-button>
-              <el-button size="default" @click="resetForm(ruleFormRef)">重置</el-button>
+              <el-button size="default" type="primary" @click="onSubmit">查询</el-button>
+              <el-button size="default" @click="submitReset">重置</el-button>
               <el-button size="default" :icon="Delete">清除选择</el-button>
             </el-form-item>
           </el-form>
         </el-row>
-        <el-table :data="tableData" style="width: 100%;margin-top:20px">
-          <el-table-column type="selection" width="55" />
+        <el-table :data="tableData" style="width: 100%;margin-top:20px" @cell-click="radio">
+          <el-table-column width="55">
+            <template #default="scope">
+              <el-radio-group v-model="radio1">
+                <el-radio :label="scope.row" size="large">{{ null }}</el-radio>
+              </el-radio-group>
+            </template>
+          </el-table-column>
           <el-table-column align="center" prop="date" label="id" />
           <el-table-column align="center" prop="name" label="物资名称"/>
         </el-table>
         <div class="pages">
           <el-pagination
-              v-model:currentPage="currentPage4"
-              v-model:page-size="pageSize4"
-              :page-sizes="[100, 200, 300, 400]"
-              :small="small"
-              :disabled="disabled"
-              :background="background"
+              v-model:currentPage="pageIndex"
+              v-model:page-size="pageSize"
+              :page-sizes="[10, 20, 30]"
               layout="total, sizes, prev, pager, next, jumper"
-              :total="400"
-              @size-change="handleSizeChange"
-              @current-change="handleCurrentChange"
+              :total="total"
+              @size-change="onHandleSizeChange"
+              @current-change="onHandleCurrentChange"
           />
         </div>
       </el-col>
       <el-col :span="6">
-        <el-tag v-for="tag in dynamicTags" :key="tag" class="mx-1" style="margin:5px" closable :disable-transitions="false" @close="handleClose(tag)">
-          {{ tag }}
-        </el-tag>
+        <div v-if="dynamicTags[0] == '' ? false : true">
+          <el-tag
+              v-for="tag in dynamicTags"
+              :key="tag"
+              class="mx-1"
+              style="margin: 5px"
+              closable
+              :disable-transitions="false"
+              @close="handleClose(tag)"
+          >
+            {{ tag.name }}
+          </el-tag>
+        </div>
       </el-col>
     </el-row>
     <template #footer>
 			<span class="dialog-footer">
 				<el-button @click="dialogVisible = false" size="default">关闭</el-button>
-				<el-button type="primary" @click="dialogVisible = false" size="default">确定</el-button>
+				<el-button type="primary" @click="submitForm" size="default">确定</el-button>
 			</span>
     </template>
   </el-dialog>
@@ -65,46 +78,64 @@
   Delete,
   FullScreen
 } from '@element-plus/icons-vue';
+import { ElMessage } from 'element-plus';
+import {emergencySuppliesApi} from "/@/api/emergencyResources";
 export default defineComponent({
-  setup() {
+  setup(props, { emit }) {
     const dialogVisible = ref<boolean>(false);
     const openDailog = () => {
       dialogVisible.value = true;
+      onSubmit()
     };
     // 搜索条件
-    const ruleForm = reactive({
-      pass: '',
+    const listQuery = reactive({
+      pageIndex: 1,
+      pageSize: 10,
+      searchParams:{
+        name: '',
+      }
     });
-    // 表格
-    const tableData = [
-      {
-        date: '6421cbc6cbb5493eabf9b27e83372d78',
-        name: '应急救援组',
-      },
-      {
-        date: '6421cbc6cbb5493eabf9b27e83372d78',
-        name: '工艺抢险组',
-      },
-      {
-        date: '6421cbc6cbb5493eabf9b27e83372d78',
-        name: '后勤保障组',
-      },
-      {
-        date: '6421cbc6cbb5493eabf9b27e83372d78',
-        name: '应急救援组',
-      },
-    ];
-    const pageSize4 = ref(100);
+    // 定义表格数据
+    const tableData = ref([]);
+    // 列表请求数据
+    const onSubmit = async () => {
+      let res = await emergencySuppliesApi().getEmergencySuppliesList(listQuery);
+      if (res.data.code === '200') {
+        tableData.value = res.data.data;
+        pageIndex.value = res.data.pageIndex;
+        pageSize.value = res.data.pageSize;
+        total.value = res.data.total;
+      } else {
+        ElMessage({
+          showClose: true,
+          type: 'error',
+          message: res.data.msg,
+        });
+      }
+    };
+    // 重置
+    const submitReset = () => {
+      listQuery.searchParams.name = '';
+      onSubmit();
+    };
+    const pageIndex = ref();
+    const pageSize = ref();
+    const total = ref();
     const handleSizeChange = (val: number) => {
-      console.log(`${val} items per page`);
+      listQuery.pageSize = val;
     };
     const handleCurrentChange = (val: number) => {
-      console.log(`current page: ${val}`);
+      listQuery.pageIndex = val;
     };
     // 右方点击添加后显示标签
-    const dynamicTags = ref(['应急救援组', '工艺抢险组', '后勤保障组']);
+    const dynamicTags = ref(['']);
     const handleClose = (tag: string) => {
       dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1);
+      radio1.value = '';
+    };
+    const radio1 = ref('');
+    const radio = (event: any) => {
+      dynamicTags.value[0] = event;
     };
     //全屏
     const full = ref(false);
@@ -115,12 +146,18 @@
         full.value = false;
       }
     };
+    const submitForm = () => {
+      let obj = JSON.parse(JSON.stringify(dynamicTags.value));
+      emit('SearchUser', obj[0]);
+      dialogVisible.value = false;
+    };
     return {
       dialogVisible,
       openDailog,
-      ruleForm,
+      listQuery,
+      onSubmit,
       tableData,
-      pageSize4,
+      submitReset,
       handleSizeChange,
       handleCurrentChange,
       dynamicTags,
@@ -129,6 +166,12 @@
       toggleFullscreen,
       FullScreen,
       full,
+      pageIndex,
+      pageSize,
+      radio1,
+      radio,
+      submitForm,
+      total,
     };
   },
 });

--
Gitblit v1.9.2