maven
8 天以前 4cc27f93a1901e12eb12a198029911c483dd991f
src/views/procureMent/index.vue
@@ -16,13 +16,16 @@
    </el-form>
    <el-card>
      <!-- 操作按钮区 -->
      <el-row :gutter="24" class="table-toolbar">
      <el-row :gutter="24" class="table-toolbar" justify="space-between">
        <el-button type="primary" :icon="Plus" @click="handleAdd"
          >新建
        </el-button>
        <el-button type="danger" :icon="Delete" @click="handleDelete"
          >删除
        <el-button type="primary" :icon="Plus" @click="handleAddPayable">
          添加应付款
        </el-button>
        <!-- <el-button type="danger" :icon="Delete" @click="handleDelete"
          >删除
        </el-button> -->
      </el-row>
      <!-- 表格组件 -->
      <data-table
@@ -59,6 +62,14 @@
      @success="handleSuccess"
      ref="productionDialogs"
    />
    <PayableDialog
        v-model:dialogPayableFormVisible="dialogPayableFormVisible"
        v-model:form="formPayable"
        :title="title"
        @submit="handleSubmit"
        @success="payableHandleSuccess"
        ref="productionDialogs">
    </PayableDialog>>
  </div>
</template>
@@ -69,6 +80,8 @@
import DataTable from "@/components/Table/ETable.vue";
import Pagination from "@/components/Pagination";
import ProductionDialog from "./components/ProductionDialog.vue";
import PayableDialog from "../payable/components/PayableDialog.vue";
import {
  purchaseRegistration,
  getSupplyList,
@@ -76,12 +89,25 @@
  delPR
} from "@/api/procureMent";
import { useDelete } from "@/hooks/useDelete";
const userStore = useUserStore();
const dictStore = useDictStore()
import useUserStore from "@/store/modules/user";
import useDictStore from "@/store/modules/dict"
let userList = ref([]);
userStore.getUserList().then((res) => {
  userList.value = res;
});
// 引入字典数据
const { proxy } = getCurrentInstance();
const dialogFormVisible = ref(false);
const form = ref({});
const dialogPayableFormVisible = ref(false);
const form = ref({
  taxRate: 13,
  freight: 20,
});
const title = ref("");
// 状态变量
const loading = ref(false);
@@ -90,6 +116,7 @@
const pageSize = ref(10);
const selectedRows = ref([]);
const copyForm = ref({});
const formPayable = ref({});
// 查询参数
const queryParams = reactive({
  searchAll: "",
@@ -106,10 +133,12 @@
// 方法定义
const handleQuery = () => {
  loading.value = true;
   current.value = 1;
   pageSize.value = 10;
  // 这里添加实际的查询逻辑
  getList();
};
const userStore = useUserStore();
// 获取用户信息
const userInfo = ref({});
onMounted(async () => {
@@ -136,6 +165,14 @@
    },
  },
  {
    prop: "type",
    label: "煤料类型",
    minWidth: 120,
    formatter: (row) => {
      return row.type === 1 ? "成品" : "原料";
    },
  },
  {
    prop: "coalId",
    label: "煤种类型",
    minWidth: 120,
@@ -146,9 +183,24 @@
  { prop: "purchaseQuantity", label: "采购数量", minWidth: 100 },
  { prop: "priceIncludingTax", label: "单价(含税)", minWidth: 150 },
  { prop: "totalPriceIncludingTax", label: "总价(含税)", minWidth: 100 },
  { prop: "freight", label: "运费", minWidth: 100 },
  { prop: "taxRate", label: "税率", minWidth: 100 },
  { prop: "priceExcludingTax", label: "不含税单价", minWidth: 100 },
  { prop: "registrantId", label: "登记人", minWidth: 100 },
  { prop: "registrantId", label: "登记人", minWidth: 100,
    formatter: (row) => {
      // 匹配用户信息
      const user = userList.value.find((user) => user.userId === row.registrantId);
      return user ? user.nickName : "未知用户";
    },
  },
  { prop: "purchaseType", label: "类型", minWidth: 100 ,
    formatter: (row) => {
      if (row.purchaseType == null) {
        return ""
      }
      const dictItem = dictStore.getDictDataByTypeAndValue("purchase_type", row.purchaseType);
      return dictItem ? dictItem.label : "";    }
  },
  { prop: "registrationDate", label: "登记日期", minWidth: 100 },
]);
@@ -179,6 +231,28 @@
  addOrEdit.value = "add";
  handleAddEdit();
};
const handleAddPayable = () => {
  // 只有选择一行的时候进行操作
  if (selectedRows.value.length !== 1) {
    ElMessage.error("请选中一行进行填写")
    return
  }
  formPayable.value = {
    purchaseRegistrationId: selectedRows.value[0].id,
    registrantId: userInfo.value.userId,
    ticketNo:"",
    paymentAmount:"",
    payableType:"",
    attachUpload:"",
    registrationDate: new Date().toISOString().split("T")[0],
    fileList:[]
  }
  dialogPayableFormVisible.value = true
};
// 新增编辑
const productionDialogs = ref(null); // 添加ref声明
@@ -196,20 +270,21 @@
    // 触发ref里面的方法
    return;
  }
  console.log(userInfo.value)
  // 新建时初始化表单
  form.value = {
    supplierName: "",
    coal: "",
    unit: "t",
    unit: "吨",
    purchaseQuantity: "",
    priceExcludingTax: "",
    totalPriceExcludingTax: "",
    priceIncludingTax: "",
    totalPriceIncludingTax: "",
    taxRate: "",
    taxRate: 13,
    freight:20,
    registrantId: userInfo.value.userId,
    registrationDate: new Date().toISOString().split("T")[0],
    purchaseType: ""
  };
  // 新建时也需要设置 copyForm 用于重置功能
  copyForm.value = JSON.parse(JSON.stringify(form.value));
@@ -252,6 +327,7 @@
});
const handleDeleteSuccess = (row) => {
  ElMessage.success("删除成功:" + row.supplierName);
   handleQuery()
};
// 成功
const handleSuccess = (val) => {
@@ -260,6 +336,12 @@
  total.value = tableData.value.length;
  ElMessage.success("操作成功");
};
const payableHandleSuccess = (val) => {
  ElMessage.success("操作成功");
  dialogPayableFormVisible.value = false;
}
const getList = async () => {
  loading.value = true;
  try {