Quellcode durchsuchen

物资申报页面和编辑页面

zhangyihao vor 6 Monaten
Ursprung
Commit
6e3a959353

+ 85 - 94
src/views/comprehensiveGuarantee/materialReserves/materialsDeclaration.vue

@@ -1,71 +1,63 @@
 <template>
-  <div>
-    <div v-show="!viewState.show" class="app-container">
-      <div>
-        <!-- 表格组件 -->
-        <el-table ref="multipleTable" v-loading="loading" :data="tableData" style="width: 100%" :max-height="400">
-          <el-table-column label="序号" align="center" width="55" fixed="left">
-            <template #default="scope">
-              {{ (queryParams.page - 1) * queryParams.pageSize + scope.$index + 1 }}
-            </template>
-          </el-table-column>
-          <el-table-column label="姓名" align="center" prop="name" width="100" fixed="left" />
-          <el-table-column label="所属区县" align="center" prop="county" />
-          <el-table-column label="专家类型" align="center" prop="expert_type" />
-          <el-table-column label="职位" align="center" prop="position" />
-          <el-table-column label="单位" align="center" prop="unit" />
-          <el-table-column label="联系电话" align="center" prop="phone" />
-          <el-table-column label="现在地址" align="center" prop="address" />
-          <el-table-column label="状态" align="center" prop="status" />
-          <el-table-column label="擅长事故类型" align="center" prop="accident_type" />
-          <el-table-column label="救援经历" align="center" prop="rescue_experience" />
-          <el-table-column label="出生日期" align="center" prop="birthdate" />
-          <el-table-column label="工作日期" align="center" prop="work_date" />
-          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
-            <template #default="scope">
-              <el-text class="common-btn-text-primary" @click="handleView(scope.row)">查看</el-text>
-              <el-text class="common-btn-text-primary" @click="handleUpdate(scope.row)">修改</el-text>
-              <el-text class="common-btn-text-primary" @click="handlePhone(scope.row)">连线</el-text>
-            </template>
-          </el-table-column>
-        </el-table>
-        <pagination v-show="total > 0" v-model:page="queryParams.page" v-model:limit="queryParams.pageSize" :total="total" @pagination="tableData" />
-      </div>
+  <div class="app-container">
+    <div v-show="!materialsDeclarationViewState.show && !materialsDeclarationEidtState.show">
+      <h1>物资储备管理</h1>
+      <el-row :gutter="10" class="mb8">
+        <el-col :span="1.5">
+          <el-button type="primary" icon="Plus" @click="handleAdd">新增采购</el-button>
+        </el-col>
+      </el-row>
+      <h3>申报列表</h3>
+      <!-- 表格组件 -->
+      <el-table ref="multipleTable" v-loading="loading" :data="tableData" style="width: 100%" :max-height="400">
+        <el-table-column label="序号" align="center" width="55" fixed="left">
+          <template #default="scope">
+            {{ (queryParams.page - 1) * queryParams.pageSize + scope.$index + 1 }}
+          </template>
+        </el-table-column>
+        <el-table-column label="申报日期" align="center" prop="declaration_date" />
+        <el-table-column label="申报金额(元)" align="center" prop="amount_declared" />
+        <el-table-column label="申报单位" align="center" prop="application_unit" />
+        <el-table-column label="申报人" align="center" prop="declarant" />
+        <el-table-column label="审批情况" align="center" prop="approval_status" />
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
+          <template #default="scope">
+            <el-text class="common-btn-text-primary" @click="handleView(scope.row)">详情</el-text>
+            <el-text v-if="scope.row.approval_status === '未审批'" class="common-btn-text-primary" @click="handleUpdate(scope.row)">编辑</el-text>
+          </template>
+        </el-table-column>
+      </el-table>
+      <pagination v-show="total > 0" v-model:page="queryParams.page" v-model:limit="queryParams.pageSize" :total="total" @pagination="fetchWorkrData" />
     </div>
-    <View v-if="viewState.show" :event-id="viewState.eventId" @close="handleCancel" />
-    <Edit v-if="editState.show" :event-id="editState.eventId" @close="handleCancel" />
   </div>
+  <MaterialsDeclarationView v-if="materialsDeclarationViewState.show" :event-id="materialsDeclarationViewState.eventId" @close="handleCancel" />
+  <MaterialsDeclarationEidt v-if="materialsDeclarationEidtState.show" :event-id="materialsDeclarationEidtState.eventId" @close="handleCancel" />
 </template>
+
 <script setup lang="ts">
 import { onMounted, reactive, ref, toRefs } from 'vue';
 import { ElTable, ElTableColumn, ElForm, ElFormItem, ElInput, ElButton, ElText } from 'element-plus';
 import { ComponentInternalInstance, getCurrentInstance } from 'vue';
-import View from './view.vue';
-import Edit from './edit.vue';
+import Pagination from '@/components/Pagination/index.vue'; // 假设这是分页组件的路径
+import MaterialsDeclarationView from './materialsDeclarationView.vue'; // 查看详情组件
+import MaterialsDeclarationEidt from './materialsDeclarationEidt.vue'; // 编辑组件
 const loading = ref(true);
 const showSearch = ref(true);
 const multiple = ref(true);
 const ids = ref<Array<number | string>>([]);
 const single = ref(true);
 const total = ref(0);
-const tableData = ref<PatrolVO[]>([]);
-const selectedRow = ref<PatrolVO | null>(null);
+const tableData = ref<any[]>([]);
+const selectedRow = ref<any | null>(null);
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
 const initFormData = reactive({
-  name: '',
-  county: '',
-  expert_type: '',
-  position: '',
-  unit: '',
-  phone: '',
-  address: '',
-  status: '',
-  accident_type: '',
-  rescue_experience: '',
-  birthdate: '',
-  work_date: ''
+  declaration_date: '',
+  amount_declared: '',
+  application_unit: '',
+  declarant: '',
+  approval_status: ''
 });
 
 const data = reactive({
@@ -77,43 +69,35 @@ const data = reactive({
 });
 
 const { queryParams, form } = toRefs(data);
-
+const mockData = [
+  {
+    id: 1,
+    declaration_date: '2024-10-29 12:23:00',
+    amount_declared: 1000,
+    application_unit: '茂名市应急管理局',
+    declarant: '张三',
+    approval_status: '未审批'
+  },
+  {
+    id: 2,
+    declaration_date: '2024-10-30 12:23:00',
+    amount_declared: 1001,
+    application_unit: '茂名市应急管理局',
+    declarant: '李四',
+    approval_status: '审批通过'
+  },
+  {
+    id: 3,
+    declaration_date: '2024-10-31 12:23:00',
+    amount_declared: 1002,
+    application_unit: '茂名市应急管理局',
+    declarant: '王五',
+    approval_status: '审批不通过'
+  }
+];
 
 const fetchWorkrData = () => {
   loading.value = true;
-  const mockData = [
-    {
-      id: 1,
-      name: '张三',
-      county: '海淀区',
-      expert_type: '技术专家',
-      position: '工程师',
-      unit: '某科技公司',
-      phone: '13800000000',
-      address: '北京市海淀区XX路XX号',
-      status: '在线',
-      accident_type: '网络故障',
-      rescue_experience: '5年以上',
-      birthdate: '1990-01-01',
-      work_date: '2015-01-01'
-    },
-    {
-      id: 2,
-      name: '李四',
-      county: '朝阳区',
-      expert_type: '安全专家',
-      position: '高级安全顾问',
-      unit: '某安全咨询公司',
-      phone: '13800000001',
-      address: '北京市朝阳区XX路XX号',
-      status: '离线',
-      accident_type: '安全事故',
-      rescue_experience: '10年以上',
-      birthdate: '1985-01-01',
-      work_date: '2010-01-01'
-    }
-  ];
-
   tableData.value = mockData;
   total.value = mockData.length;
 
@@ -129,30 +113,37 @@ const resetQuery = () => {
   queryParams.value = { page: 1, pageSize: 10 };
   handleQuery();
 };
-let viewState = reactive({
+
+let materialsDeclarationViewState = reactive({
   show: false,
   eventId: ''
 });
-let editState = reactive({
+
+let materialsDeclarationEidtState = reactive({
   show: false,
   eventId: ''
 });
-const handleView = () => {
-  // viewState.eventId = row.id;
-  viewState.show = true;
+
+const handleView = (row: any) => {
+  materialsDeclarationViewState.eventId = row.id;
+  materialsDeclarationViewState.show = true;
 };
-const handleUpdate = () => {
-  // editState.eventId = row.id;
-  editState.show = true;
+
+const handleUpdate = (row: any) => {
+  materialsDeclarationEidtState.eventId = row.id;
+  materialsDeclarationEidtState.show = true;
 };
+
 const handleCancel = () => {
-  viewState.show = false;
-  editState.show = false;
+  materialsDeclarationViewState.show = false;
+  materialsDeclarationEidtState.show = false;
 };
+
 onMounted(() => {
   fetchWorkrData();
 });
 </script>
+
 <style scoped>
 .app-container {
   overflow-x: auto; /* 当内容溢出时允许水平滚动 */

+ 183 - 0
src/views/comprehensiveGuarantee/materialReserves/materialsDeclarationEidt.vue

@@ -0,0 +1,183 @@
+<template>
+  <div class="app-container p-2">
+    <el-row :gutter="20">
+      <el-col :span="24">
+        <h2>编辑</h2>
+      </el-col>
+      <el-col :span="18">
+        <p class="report-period">申报金额:20000.00元</p>
+      </el-col>
+      <el-col :lg="24" :xs="24">
+        <el-table :data="tableData" border height="400">
+          <el-table-column label="序号" prop="seqNo" width="80">
+            <template #default="{ $index }">
+              <span>{{ $index + 1 }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="物资类型" prop="materialType">
+            <template #default="{ row, $index }">
+              <span
+                class="editable-span"
+                contenteditable="true"
+                @blur="saveEdit($index, 'materialType', $event.target.innerText)"
+                v-text="row.materialType"
+              ></span>
+            </template>
+          </el-table-column>
+          <el-table-column label="物资名称" prop="materialName">
+            <template #default="{ row, $index }">
+              <span
+                class="editable-span"
+                contenteditable="true"
+                @blur="saveEdit($index, 'materialName', $event.target.innerText)"
+                v-text="row.materialName"
+              ></span>
+            </template>
+          </el-table-column>
+          <el-table-column label="物资数量(件)" prop="quantity">
+            <template #default="{ row, $index }">
+              <span
+                class="editable-span"
+                contenteditable="true"
+                @blur="saveEdit($index, 'quantity', $event.target.innerText)"
+                v-text="row.quantity"
+              ></span>
+            </template>
+          </el-table-column>
+          <el-table-column label="物资单价(元)" prop="unitPrice">
+            <template #default="{ row, $index }">
+              <span
+                class="editable-span"
+                contenteditable="true"
+                @blur="saveEdit($index, 'unitPrice', $event.target.innerText)"
+                v-text="row.unitPrice"
+              ></span>
+            </template>
+          </el-table-column>
+          <el-table-column label="物资用途" prop="purpose">
+            <template #default="{ row, $index }">
+              <span
+                class="editable-span"
+                contenteditable="true"
+                @blur="saveEdit($index, 'purpose', $event.target.innerText)"
+                v-text="row.purpose"
+              ></span>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-col>
+      <div class="common-dialog-footer" style="text-align: center">
+        <el-row :span="24" :gutter="10" class="mb8">
+          <el-col :span="1.5">
+            <el-button type="primary" @click="handleAddRow">新增一项</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="primary" @click="handleSave">提交</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" @click="handleReturn">取消</el-button>
+          </el-col>
+        </el-row>
+      </div>
+    </el-row>
+  </div>
+</template>
+
+<script setup lang="ts">
+import { ref, onMounted } from 'vue';
+import { ElTable, ElButton, ElCol, ElRow, ElTableColumn } from 'element-plus';
+import { defineProps, defineEmits } from 'vue';
+
+const props = defineProps({
+  eventId: String
+});
+
+const emits = defineEmits(['close']);
+
+const tableData = ref<any[]>([]);
+
+const loadFromLocalStorage = () => {
+  const storedData = localStorage.getItem('tableData');
+  if (storedData) {
+    tableData.value = JSON.parse(storedData);
+  } else {
+    tableData.value = [
+      { materialType: '办公用品', materialName: '笔记本', quantity: '100', unitPrice: '5.00', purpose: '日常办公' },
+      { materialType: '电子产品', materialName: '电脑', quantity: '10', unitPrice: '5000.00', purpose: '项目开发' },
+      { materialType: '耗材', materialName: '墨盒', quantity: '50', unitPrice: '100.00', purpose: '打印机使用' }
+    ];
+  }
+};
+
+const addDefaultRow = () => {
+  const newRow = {
+    materialType: '',
+    materialName: '',
+    quantity: '',
+    unitPrice: '',
+    purpose: ''
+  };
+  tableData.value.push(newRow);
+};
+
+const saveEdit = (index: number, key: string, value: string) => {
+  if (key === 'quantity' || key === 'unitPrice') {
+    const numValue = parseFloat(value);
+    if (isNaN(numValue)) {
+      alert('请输入有效的数字!');
+      return;
+    }
+    value = numValue.toString();
+  }
+  tableData.value[index][key] = value;
+  localStorage.setItem('tableData', JSON.stringify(tableData.value));
+};
+
+const handleAddRow = () => addDefaultRow();
+
+const handleReturn = () => {
+  emits('close');
+};
+
+const handleSave = () => {
+  // 这里可以添加保存到服务器的逻辑
+  console.log('数据已保存:', tableData.value);
+};
+
+onMounted(() => {
+  loadFromLocalStorage();
+});
+</script>
+
+<style scoped>
+.app-container {
+  font-family: Avenir, Helvetica, Arial, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #2c3e50;
+}
+.report-period {
+  margin-top: 10px;
+  font-size: 14px;
+  color: #606266;
+}
+.editable-span {
+  cursor: pointer;
+  display: inline-block;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+.editable-span[contenteditable='true'] {
+  white-space: normal;
+  outline: none; /* 移除编辑时的焦点边框 */
+}
+.editable-span[contenteditable='true']:empty::before {
+  content: attr(data-placeholder); /* 可选:为空时显示占位符 */
+  color: #999;
+}
+.common-dialog-footer {
+  margin-top: 20px;
+}
+</style>

+ 11 - 0
src/views/comprehensiveGuarantee/materialReserves/materialsDeclarationView.vue

@@ -0,0 +1,11 @@
+<script setup lang="ts">
+
+</script>
+
+<template>
+
+</template>
+
+<style scoped lang="scss">
+
+</style>