From b186f5b20c4f83773f51786da0cd3e85130540c2 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 22 五月 2026 16:32:01 +0800
Subject: [PATCH] feat(审批模板): 增强审批流程编辑器功能,新增只读模式——为 TemplateFlowEditor 添加了只读属性,以在流程不可编辑时防止进行修改。——更新审批模板表单部分,使其能够根据 flowEditable 状态条件性地显示可编辑选项。——优化了用户反馈机制,通过动态消息显示审批流程是否可进行修改。

---
 src/views/financialManagement/payable/purchaseIn.vue |  458 +++++++++++++++++++++------------------------------------
 1 files changed, 170 insertions(+), 288 deletions(-)

diff --git a/src/views/financialManagement/payable/purchaseIn.vue b/src/views/financialManagement/payable/purchaseIn.vue
index d976f1d..fcb768f 100644
--- a/src/views/financialManagement/payable/purchaseIn.vue
+++ b/src/views/financialManagement/payable/purchaseIn.vue
@@ -1,19 +1,39 @@
 <template>
+  <!-- 閲囪喘鍏ュ簱 -->
   <div class="app-container">
-    <el-form :model="filters" :inline="true">
+    <el-form :model="filters"
+             :inline="true">
       <el-form-item label="鍏ュ簱鍗曞彿:">
-        <el-input v-model="filters.inCode" placeholder="璇疯緭鍏ュ叆搴撳崟鍙�" clearable style="width: 200px;" />
+        <el-input v-model="filters.inboundBatches"
+                  placeholder="璇疯緭鍏ュ叆搴撳崟鍙�"
+                  clearable
+                  style="width: 200px;" />
       </el-form-item>
       <el-form-item label="渚涘簲鍟�:">
-        <el-select v-model="filters.supplierId" placeholder="璇烽�夋嫨渚涘簲鍟�" clearable style="width: 200px;">
-          <el-option v-for="item in supplierList" :key="item.id" :label="item.name" :value="item.id" />
+        <el-select v-model="filters.supplierId"
+                   placeholder="璇烽�夋嫨渚涘簲鍟�"
+                   clearable
+                   filterable
+                   style="width: 200px;">
+          <el-option v-for="item in supplierList"
+                     :key="item.id"
+                     :label="item.supplierName"
+                     :value="item.id" />
         </el-select>
       </el-form-item>
       <el-form-item label="鍏ュ簱鏃ユ湡:">
-        <el-date-picker v-model="filters.dateRange" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange" range-separator="鑷�" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡" clearable />
+        <el-date-picker v-model="filters.dateRange"
+                        value-format="YYYY-MM-DD"
+                        format="YYYY-MM-DD"
+                        type="daterange"
+                        range-separator="鑷�"
+                        start-placeholder="寮�濮嬫棩鏈�"
+                        end-placeholder="缁撴潫鏃ユ湡"
+                        clearable />
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" @click="getTableData">鎼滅储</el-button>
+        <el-button type="primary"
+                   @click="onSearch">鎼滅储</el-button>
         <el-button @click="resetFilters">閲嶇疆</el-button>
       </el-form-item>
     </el-form>
@@ -21,310 +41,172 @@
       <div class="actions">
         <div></div>
         <div>
-          <el-button @click="handleOut" icon="Download">瀵煎嚭</el-button>
+          <el-button @click="handleOut"
+                     icon="Download">瀵煎嚭</el-button>
         </div>
       </div>
-      <PIMTable
-        rowKey="id"
-        :column="columns"
-        :tableData="dataList"
-        :page="{
+      <PIMTable rowKey="id"
+                :column="columns"
+                :tableData="dataList"
+                :tableLoading="tableLoading"
+                :page="{
           current: pagination.currentPage,
           size: pagination.pageSize,
           total: pagination.total,
         }"
-        @pagination="changePage"
-      >
-        <template #amount="{ row }">
-          <span class="text-primary">楼{{ formatMoney(row.amount) }}</span>
-        </template>
-        <template #status="{ row }">
-          <el-tag :type="getStatusType(row.status)">{{ getStatusLabel(row.status) }}</el-tag>
-        </template>
-        <template #operation="{ row }">
-          <el-button type="primary" link @click="view(row)">鏌ョ湅</el-button>
-          <el-button type="primary" link @click="edit(row)" v-if="row.status === 'pending'">缂栬緫</el-button>
-          <el-button type="danger" link @click="handleDelete(row)" v-if="row.status === 'pending'">鍒犻櫎</el-button>
+                @pagination="changePage">
+        <template #inboundDate="{ row }">
+          {{ row.inboundDate ?? row.InboundDate ?? "" }}
         </template>
       </PIMTable>
     </div>
-
-    <el-dialog :title="dialogTitle" v-model="dialogVisible" width="800px" append-to-body>
-      <el-form :model="form" :rules="rules" ref="formRef" label-width="100px">
-        <el-row :gutter="20">
-          <el-col :span="12">
-            <el-form-item label="鍏ュ簱鍗曞彿" prop="inCode">
-              <el-input v-model="form.inCode" placeholder="璇疯緭鍏ュ叆搴撳崟鍙�" :disabled="isEdit" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="渚涘簲鍟�" prop="supplierId">
-              <el-select v-model="form.supplierId" placeholder="璇烽�夋嫨渚涘簲鍟�" style="width: 100%;" :disabled="isEdit">
-                <el-option v-for="item in supplierList" :key="item.id" :label="item.name" :value="item.id" />
-              </el-select>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="20">
-          <el-col :span="12">
-            <el-form-item label="鍏ュ簱鏃ユ湡" prop="inDate">
-              <el-date-picker v-model="form.inDate" type="date" placeholder="閫夋嫨鏃ユ湡" value-format="YYYY-MM-DD" style="width: 100%;" />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鍏ュ簱閲戦" prop="amount">
-              <el-input-number v-model="form.amount" :min="0" :precision="2" style="width: 100%;" />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-form-item label="鍏ュ簱鏄庣粏" prop="details">
-          <el-table :data="form.details" border style="width: 100%">
-            <el-table-column prop="materialName" label="鐗╂枡鍚嶇О" width="150">
-              <template #default="{ $index }">
-                <el-input v-model="form.details[$index].materialName" placeholder="鐗╂枡鍚嶇О" />
-              </template>
-            </el-table-column>
-            <el-table-column prop="spec" label="瑙勬牸" width="120">
-              <template #default="{ $index }">
-                <el-input v-model="form.details[$index].spec" placeholder="瑙勬牸" />
-              </template>
-            </el-table-column>
-            <el-table-column prop="quantity" label="鏁伴噺" width="100">
-              <template #default="{ $index }">
-                <el-input-number v-model="form.details[$index].quantity" :min="0" style="width: 100%;" />
-              </template>
-            </el-table-column>
-            <el-table-column prop="unitPrice" label="鍗曚环" width="120">
-              <template #default="{ $index }">
-                <el-input-number v-model="form.details[$index].unitPrice" :min="0" :precision="2" style="width: 100%;" />
-              </template>
-            </el-table-column>
-            <el-table-column prop="total" label="閲戦" width="120">
-              <template #default="{ row }">
-                <span>楼{{ formatMoney(row.quantity * row.unitPrice) }}</span>
-              </template>
-            </el-table-column>
-            <el-table-column label="鎿嶄綔" width="80">
-              <template #default="{ $index }">
-                <el-button type="danger" link @click="removeDetail($index)">鍒犻櫎</el-button>
-              </template>
-            </el-table-column>
-          </el-table>
-          <el-button type="primary" link @click="addDetail" style="margin-top: 10px;">+ 娣诲姞鏄庣粏</el-button>
-        </el-form-item>
-        <el-form-item label="澶囨敞" prop="remark">
-          <el-input v-model="form.remark" type="textarea" :rows="3" placeholder="璇疯緭鍏ュ娉�" />
-        </el-form-item>
-      </el-form>
-      <template #footer>
-        <el-button @click="dialogVisible = false">鍙栨秷</el-button>
-        <el-button type="primary" @click="submitForm">纭畾</el-button>
-      </template>
-    </el-dialog>
   </div>
 </template>
 
 <script setup>
-import { ref, reactive, onMounted } from "vue";
-import { ElMessage, ElMessageBox } from "element-plus";
+  import { ref, reactive, onMounted, getCurrentInstance } from "vue";
+  import { ElMessage } from "element-plus";
+  import { listPageAccountPurchase } from "@/api/financialManagement/accountPurchase";
+  import { listSupplier } from "@/api/basicData/supplierManageFile.js";
 
-defineOptions({
-  name: "閲囪喘鍏ュ簱",
-});
-
-const filters = reactive({
-  inCode: "",
-  supplierId: "",
-  dateRange: [],
-});
-
-const pagination = reactive({
-  currentPage: 1,
-  pageSize: 10,
-  total: 0,
-});
-
-const columns = [
-  { label: "鍏ュ簱鍗曞彿", prop: "inCode", width: "150" },
-  { label: "渚涘簲鍟�", prop: "supplierName", width: "180" },
-  { label: "鍏ュ簱鏃ユ湡", prop: "inDate", width: "120" },
-  { label: "鍏ュ簱閲戦", prop: "amount", slot: "amount" },
-  { label: "鐘舵��", prop: "status", slot: "status" },
-  { label: "澶囨敞", prop: "remark", showOverflowTooltip: true },
-  { label: "鎿嶄綔", prop: "operation", slot: "operation", width: "200", fixed: "right" },
-];
-
-const dataList = ref([]);
-const dialogVisible = ref(false);
-const dialogTitle = ref("");
-const formRef = ref(null);
-const isEdit = ref(false);
-const currentId = ref(null);
-
-const supplierList = [
-  { id: 1, name: "鍖椾含鍘熸潗鏂欎緵搴斿晢" },
-  { id: 2, name: "涓婃捣鐢靛瓙鍏冨櫒浠跺叕鍙�" },
-  { id: 3, name: "骞垮窞鍖呰鏉愭枡鍘�" },
-  { id: 4, name: "娣卞湷浜旈噾閰嶄欢鍏徃" },
-];
-
-const form = reactive({
-  inCode: "",
-  supplierId: "",
-  inDate: "",
-  amount: 0,
-  details: [],
-  remark: "",
-});
-
-const rules = {
-  inCode: [{ required: true, message: "璇疯緭鍏ュ叆搴撳崟鍙�", trigger: "blur" }],
-  supplierId: [{ required: true, message: "璇烽�夋嫨渚涘簲鍟�", trigger: "change" }],
-  inDate: [{ required: true, message: "璇烽�夋嫨鍏ュ簱鏃ユ湡", trigger: "change" }],
-  amount: [{ required: true, message: "璇疯緭鍏ュ叆搴撻噾棰�", trigger: "blur" }],
-};
-
-const mockData = [
-  { id: 1, inCode: "RK2024001", supplierId: 1, supplierName: "鍖椾含鍘熸潗鏂欎緵搴斿晢", inDate: "2024-01-10", amount: 8000, status: "approved", details: [{ materialName: "閽㈡潗", spec: "Q235", quantity: 10, unitPrice: 500 }], remark: "" },
-  { id: 2, inCode: "RK2024002", supplierId: 2, supplierName: "涓婃捣鐢靛瓙鍏冨櫒浠跺叕鍙�", inDate: "2024-01-12", amount: 12000, status: "pending", details: [{ materialName: "鑺墖", spec: "STM32", quantity: 100, unitPrice: 80 }], remark: "" },
-  { id: 3, inCode: "RK2024003", supplierId: 3, supplierName: "骞垮窞鍖呰鏉愭枡鍘�", inDate: "2024-01-15", amount: 3500, status: "approved", details: [{ materialName: "绾哥", spec: "50*40*30", quantity: 500, unitPrice: 5 }], remark: "" },
-];
-
-const formatMoney = (value) => {
-  if (value === undefined || value === null) return "0.00";
-  return Number(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
-};
-
-const getStatusLabel = (status) => {
-  const map = { pending: "寰呭鏍�", approved: "宸插鏍�", rejected: "宸查┏鍥�" };
-  return map[status] || status;
-};
-
-const getStatusType = (status) => {
-  const map = { pending: "warning", approved: "success", rejected: "danger" };
-  return map[status] || "";
-};
-
-const getTableData = () => {
-  let result = [...mockData];
-  if (filters.inCode) {
-    result = result.filter(item => item.inCode.includes(filters.inCode));
-  }
-  if (filters.supplierId) {
-    result = result.filter(item => item.supplierId === filters.supplierId);
-  }
-  if (filters.dateRange && filters.dateRange.length === 2) {
-    result = result.filter(item => item.inDate >= filters.dateRange[0] && item.inDate <= filters.dateRange[1]);
-  }
-  pagination.total = result.length;
-  dataList.value = result.slice((pagination.currentPage - 1) * pagination.pageSize, pagination.currentPage * pagination.pageSize);
-};
-
-const resetFilters = () => {
-  filters.inCode = "";
-  filters.supplierId = "";
-  filters.dateRange = [];
-  pagination.currentPage = 1;
-  getTableData();
-};
-
-const changePage = ({ current, size }) => {
-  pagination.currentPage = current;
-  pagination.pageSize = size;
-  getTableData();
-};
-
-const addDetail = () => {
-  form.details.push({ materialName: "", spec: "", quantity: 0, unitPrice: 0 });
-};
-
-const removeDetail = (index) => {
-  form.details.splice(index, 1);
-};
-
-const add = () => {
-  isEdit.value = false;
-  dialogTitle.value = "鏂板鍏ュ簱";
-  Object.assign(form, {
-    inCode: "RK" + Date.now().toString().slice(-8),
-    supplierId: "",
-    inDate: new Date().toISOString().split('T')[0],
-    amount: 0,
-    details: [{ materialName: "", spec: "", quantity: 0, unitPrice: 0 }],
-    remark: "",
+  defineOptions({
+    name: "閲囪喘鍏ュ簱",
   });
-  dialogVisible.value = true;
-};
 
-const edit = (row) => {
-  isEdit.value = true;
-  currentId.value = row.id;
-  dialogTitle.value = "缂栬緫鍏ュ簱";
-  Object.assign(form, row);
-  if (!form.details || form.details.length === 0) {
-    form.details = [{ materialName: "", spec: "", quantity: 0, unitPrice: 0 }];
-  }
-  dialogVisible.value = true;
-};
+  const { proxy } = getCurrentInstance();
 
-const view = (row) => {
-  ElMessage.info(`鏌ョ湅鍏ュ簱鍗�: ${row.inCode}`);
-};
+  const filters = reactive({
+    inboundBatches: "",
+    supplierId: "",
+    dateRange: [],
+  });
 
-const handleDelete = (row) => {
-  ElMessageBox.confirm("纭鍒犻櫎璇ュ叆搴撳崟鍚楋紵", "鎻愮ず", {
-    confirmButtonText: "纭畾",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  }).then(() => {
-    const index = mockData.findIndex(item => item.id === row.id);
-    if (index !== -1) {
-      mockData.splice(index, 1);
+  const pagination = reactive({
+    currentPage: 1,
+    pageSize: 10,
+    total: 0,
+  });
+
+  const columns = [
+    { label: "鍏ュ簱鍗曞彿", prop: "inboundBatches", minWidth: "150" },
+    { label: "渚涘簲鍟�", prop: "supplierName", minWidth: "180" },
+    {
+      label: "鍏ュ簱鏃ユ湡",
+      prop: "inboundDate",
+      minWidth: "170",
+      dataType: "slot",
+      slot: "inboundDate",
+    },
+    { label: "浜у搧鍚嶇О", prop: "productName", minWidth: "140" },
+    { label: "浜у搧瑙勬牸", prop: "specificationModel", minWidth: "140" },
+    {
+      label: "閲戦",
+      prop: "inboundAmount",
+      minWidth: "120",
+      align: "right",
+      formatData: val =>
+        val === null || val === undefined || val === ""
+          ? ""
+          : Number(val).toLocaleString("zh-CN", {
+              minimumFractionDigits: 2,
+              maximumFractionDigits: 2,
+            }),
+    },
+    { label: "閲囪喘璁㈠崟鍙�", prop: "purchaseContractNumber", minWidth: "150" },
+  ];
+
+  const dataList = ref([]);
+  const tableLoading = ref(false);
+  const supplierList = ref([]);
+
+  const buildFilterParams = () => {
+    const params = {};
+    if (filters.inboundBatches) {
+      params.inboundBatches = filters.inboundBatches;
     }
-    ElMessage.success("鍒犻櫎鎴愬姛");
+    if (filters.supplierId) {
+      params.supplierId = filters.supplierId;
+    }
+    if (filters.dateRange?.length === 2) {
+      params.startDate = filters.dateRange[0];
+      params.endDate = filters.dateRange[1];
+    }
+    return params;
+  };
+
+  const getSupplierList = () => {
+    listSupplier({ current: -1, size: -1, isWhite: 0 }).then(res => {
+      if (res.code === 200) {
+        supplierList.value = res.data?.records ?? [];
+      }
+    });
+  };
+
+  const onSearch = () => {
+    pagination.currentPage = 1;
+    getTableData();
+  };
+
+  const getTableData = () => {
+    tableLoading.value = true;
+    listPageAccountPurchase({
+      ...buildFilterParams(),
+      current: pagination.currentPage,
+      size: pagination.pageSize,
+    })
+      .then(res => {
+        const ok = res.code === 200 || res.code === 0;
+        if (ok && res.data) {
+          pagination.total = res.data.total ?? 0;
+          dataList.value = res.data.records ?? [];
+        } else {
+          ElMessage.error(res.msg || "鏌ヨ澶辫触");
+          dataList.value = [];
+          pagination.total = 0;
+        }
+      })
+      .catch(() => {
+        dataList.value = [];
+        pagination.total = 0;
+        ElMessage.error("鏌ヨ澶辫触");
+      })
+      .finally(() => {
+        tableLoading.value = false;
+      });
+  };
+
+  const resetFilters = () => {
+    filters.inboundBatches = "";
+    filters.supplierId = "";
+    filters.dateRange = [];
+    pagination.currentPage = 1;
+    getTableData();
+  };
+
+  const changePage = ({ page, limit }) => {
+    pagination.currentPage = page;
+    pagination.pageSize = limit;
+    getTableData();
+  };
+
+  const handleOut = () => {
+    proxy.download(
+      "/accountPurchase/exportAccountPurchaseInbound",
+      buildFilterParams(),
+      `閲囪喘鍏ュ簱_${Date.now()}.xlsx`
+    );
+  };
+
+  onMounted(() => {
+    getSupplierList();
     getTableData();
   });
-};
-
-const handleOut = () => {
-  ElMessage.success("瀵煎嚭鎴愬姛");
-};
-
-const submitForm = () => {
-  formRef.value.validate((valid) => {
-    if (valid) {
-      const supplier = supplierList.find(item => item.id === form.supplierId);
-      if (isEdit.value) {
-        const index = mockData.findIndex(item => item.id === currentId.value);
-        if (index !== -1) {
-          mockData[index] = { ...mockData[index], ...form, supplierName: supplier?.name };
-        }
-        ElMessage.success("缂栬緫鎴愬姛");
-      } else {
-        const newId = mockData.length > 0 ? Math.max(...mockData.map(item => item.id)) + 1 : 1;
-        mockData.push({ id: newId, ...form, supplierName: supplier?.name, status: "pending" });
-        ElMessage.success("鏂板鎴愬姛");
-      }
-      dialogVisible.value = false;
-      getTableData();
-    }
-  });
-};
-
-onMounted(() => {
-  getTableData();
-});
 </script>
 
 <style lang="scss" scoped>
-.actions {
-  display: flex;
-  justify-content: space-between;
-  margin-bottom: 15px;
-}
-
-.text-primary {
-  color: #409eff;
-  font-weight: bold;
-}
+  .actions {
+    display: flex;
+    justify-content: space-between;
+    margin-bottom: 15px;
+  }
 </style>

--
Gitblit v1.9.3