123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template>
- <div>
- <el-card class="box-card">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :searchConfig="searchConfig"
- highlight-current-row
- :action-list="[
- {
- text: '导出Excel',
- action: () => deriveExcel(),
- },
- ]"
- @get-list="getList"
- @clickReset="clickReset"
- :cellClassName="cellClassName">
- <template #purchaseCode="{ item }">
- <div>
- <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickPurchaseCode(item)">{{ item.purchaseCode }}</a>
- </div>
- </template>
- </byTable>
- </el-card>
- </div>
- </template>
- <script setup>
- import byTable from "/src/components/byTable/index";
- import moment from "moment";
- import { ElMessage, ElMessageBox } from "element-plus";
- const { proxy } = getCurrentInstance();
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- purchaseCode: "",
- bomSpecCode: "",
- bomSpecName: "",
- },
- });
- const loading = ref(false);
- const searchConfig = computed(() => {
- return [
- {
- type: "input",
- prop: "purchaseCode",
- label: "采购单号",
- },
- {
- type: "input",
- prop: "bomSpecCode",
- label: "品号",
- },
- {
- type: "input",
- prop: "bomSpecName",
- label: "品名",
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "品号",
- prop: "bomSpecCode",
- width: 150,
- },
- },
- {
- attrs: {
- label: "品名",
- prop: "bomSpecName",
- "min-width": 220,
- },
- },
- {
- attrs: {
- label: "采购单号",
- slot: "purchaseCode",
- width: 160,
- },
- },
- {
- attrs: {
- label: "E10采购单号",
- prop: "purchaseErpCode",
- width: 160,
- },
- },
- {
- attrs: {
- label: "供应商",
- prop: "supplierName",
- width: 220,
- },
- },
- {
- attrs: {
- label: "采购数量",
- prop: "purchaseQuantity",
- width: 100,
- },
- },
- {
- attrs: {
- label: "在途数量",
- prop: "inTransitQuantity",
- width: 100,
- },
- },
- {
- attrs: {
- label: "交期",
- prop: "deliveryDate",
- width: 160,
- align: "center",
- },
- },
- {
- attrs: {
- label: "周转率",
- prop: "turnoverRate",
- width: 100,
- },
- },
- {
- attrs: {
- label: "90天销量",
- prop: "salesQuantity",
- width: 100,
- },
- },
- {
- attrs: {
- label: "库存数量",
- prop: "inventoryQuantity",
- width: 100,
- },
- },
- ];
- });
- const getList = async (req, status) => {
- if (status) {
- sourceList.value.pagination = {
- pageNum: sourceList.value.pagination.pageNum,
- pageSize: sourceList.value.pagination.pageSize,
- };
- } else {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- }
- loading.value = true;
- proxy.post("/purchaseInTransitBom/page", sourceList.value.pagination).then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const clickReset = () => {
- getList("", true);
- };
- const deriveExcel = () => {
- ElMessageBox.confirm("你是否确认此操作", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- proxy.postFile("/purchaseInTransitBom/export", sourceList.value.pagination).then((res) => {
- if (res.type === "application/json") {
- const fileReader = new FileReader();
- fileReader.onloadend = () => {
- const jsonData = JSON.parse(fileReader.result);
- ElMessage({ message: jsonData.msg, type: "error" });
- };
- fileReader.readAsText(res);
- } else {
- proxy.downloadFile(res, "在途物料-" + moment().format("yyyy-MM-DD") + ".xlsx");
- }
- });
- })
- .catch(() => {});
- };
- const cellClassName = (val) => {
- if (val.row.deliveryDate < moment().format("yyyy-MM-DD HH:mm:ss")) {
- return "colorDim";
- }
- };
- const clickPurchaseCode = (item) => {
- proxy.$router.replace({
- path: "/platform_manage/process/processApproval",
- query: {
- flowKey: "purchase",
- flowName: "采购流程",
- processType: "20",
- id: item.purchaseId,
- flowId: item.flowId,
- random: proxy.random(),
- },
- });
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep(.colorDim) {
- color: red;
- }
- </style>
|