123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <template>
- <div>
- <el-card class="box-card">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :searchConfig="searchConfig"
- highlight-current-row
- :table-events="{
- select: selectRow,
- 'select-all': selectRow,
- }"
- :action-list="[
- {
- text: '一键申购',
- action: () => oneKeySubscribe(),
- },
- ]"
- @get-list="getList"
- @clickReset="clickReset"
- :cellClassName="cellClassName">
- </byTable>
- </el-card>
- </div>
- </template>
- <script setup>
- import byTable from "/src/components/byTable/index";
- import subscribeStore from "/src/store/modules/subscribe";
- const { proxy } = getCurrentInstance();
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- bomSpecCode: "",
- bomSpecName: "",
- },
- });
- const loading = ref(false);
- const searchConfig = computed(() => {
- return [
- {
- type: "input",
- prop: "bomSpecCode",
- label: "品号",
- },
- {
- type: "input",
- prop: "bomSpecName",
- label: "品名",
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- type: "selection",
- attrs: {
- checkAtt: "isCheck",
- },
- },
- {
- attrs: {
- label: "品号",
- prop: "bomSpecCode",
- width: 160,
- },
- },
- {
- attrs: {
- label: "品名",
- prop: "bomSpecName",
- "min-width": 220,
- },
- },
- {
- attrs: {
- label: "当前库存",
- prop: "inventoryQuantity",
- align: "center",
- width: 100,
- },
- },
- {
- attrs: {
- label: "40天安全库存",
- prop: "safetyInventoryQuantity",
- align: "center",
- width: 110,
- },
- },
- {
- attrs: {
- label: "近七天消耗量",
- prop: "outStorageQuantitySevenDays",
- align: "center",
- width: 110,
- },
- },
- {
- attrs: {
- label: "近15天消耗量",
- prop: "outStorageQuantityFifteenDays",
- align: "center",
- width: 110,
- },
- },
- {
- attrs: {
- label: "近30天消耗量",
- prop: "outStorageQuantityThirtyDays",
- align: "center",
- width: 110,
- },
- },
- {
- attrs: {
- label: "近60天消耗量",
- prop: "outStorageQuantitySixtyDays",
- align: "center",
- width: 110,
- },
- },
- {
- attrs: {
- label: "周环比销量",
- prop: "outStorageWeekOnWeekRatio",
- align: "center",
- width: 100,
- },
- render(val) {
- return val * 100 + "%";
- },
- },
- {
- attrs: {
- label: "预计消耗天数",
- prop: "predictOutStorageDays",
- align: "center",
- width: 110,
- },
- },
- {
- attrs: {
- label: "在途总数",
- prop: "inTransitSum",
- align: "center",
- width: 100,
- },
- },
- {
- attrs: {
- label: "下一批到货天数",
- prop: "nextDeliveryDays",
- align: "center",
- width: 130,
- },
- },
- {
- attrs: {
- label: "操作",
- width: 100,
- align: "center",
- fixed: "right",
- },
- renderHTML(row) {
- return [
- {
- attrs: {
- label: "发起申购",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- clickSubscribe(row);
- },
- },
- ];
- },
- },
- ];
- });
- 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("/purchaseBomBoard/page", sourceList.value.pagination).then((res) => {
- if (res.rows && res.rows.length > 0) {
- sourceList.value.data = res.rows.map((item) => {
- return {
- ...item,
- isCheck: true,
- };
- });
- } else {
- sourceList.value.data = [];
- }
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const clickReset = () => {
- getList("", true);
- };
- const selectData = ref([]);
- const selectRow = (data) => {
- selectData.value = data;
- };
- const cellClassName = ({ columnIndex, row }) => {
- if (columnIndex === 3 && row.inventoryQuantity < row.safetyInventoryQuantity) {
- return "colorDim";
- }
- if (columnIndex === 10 && row.predictOutStorageDays < 40) {
- return "colorDim";
- }
- };
- const clickSubscribe = (row) => {
- subscribeStore().setSubscribe([row]);
- proxy.$router.replace({
- path: "/platform_manage/process/processApproval",
- query: {
- flowKey: "apply_buy",
- flowName: "申购流程",
- random: proxy.random(),
- subscribeStatus: true,
- },
- });
- };
- const oneKeySubscribe = () => {
- if (selectData.value && selectData.value.length > 0) {
- subscribeStore().setSubscribe(selectData.value);
- proxy.$router.replace({
- path: "/platform_manage/process/processApproval",
- query: {
- flowKey: "apply_buy",
- flowName: "申购流程",
- random: proxy.random(),
- subscribeStatus: true,
- },
- });
- } else {
- return ElMessage("请选择需要申购的数据");
- }
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep(.colorDim) {
- color: red;
- }
- </style>
|