123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612 |
- <template>
- <div>
- <el-row :gutter="10">
- <el-col :span="4" v-if="!props.expressStatus">
- <el-card :class="props.selectStatus ? 'select-card' : 'box-card'">
- <el-input v-model="filterTree" placeholder="请输入BOM分类" />
- <el-tree
- ref="treeCategory"
- :data="categoryTreeData"
- :props="{ children: 'children', label: 'name' }"
- node-key="id"
- default-expand-all
- :expand-on-click-node="false"
- :indent="10"
- :filter-node-method="filterNodeMethod"
- @node-click="handleNodeClick" />
- </el-card>
- </el-col>
- <el-col :span="props.expressStatus ? 24 : 20">
- <el-card :class="props.selectStatus ? 'select-card' : 'box-card'">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- :searchConfig="searchConfig"
- :defaultExpandAll="props.selectStatus"
- highlight-current-row
- :action-list="[
- props.selectStatus
- ? ''
- : {
- text: '添加BOM',
- action: () => clickModal(),
- },
- props.selectStatus
- ? ''
- : {
- text: '操作日志',
- action: () => viewLogs(),
- },
- ]"
- @get-list="getList"
- @clickReset="clickReset">
- <template #typeExpand="{ item }">
- <div style="box-sizing: border-box">
- <div
- v-for="spec in item.bomSpecList"
- :key="spec.id"
- style="display: flex; padding: 8px 16px; align-items: center; box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1); margin-bottom: 8px">
- <div style="width: 80px">
- <div v-if="spec.mainImgUrl">
- <img
- style="width: 40px; height: 40px; object-fit: contain; vertical-align: middle; border: none; cursor: pointer"
- :src="spec.mainImgUrl"
- @click="openFile(spec.mainImgUrl)" />
- </div>
- </div>
- <div style="width: 140px" v-if="props.purchaseId">采购数量: {{ spec.purchaseQuantity }}</div>
- <div style="width: 140px" v-if="props.purchaseId">已入库数量: {{ spec.arrivalQuantity || 0 }}</div>
- <div style="width: 180px">
- {{ spec.code }}
- </div>
- <div style="flex: 1">
- {{ spec.name }}
- </div>
- <div style="width: 180px">
- {{ `${spec.length} * ${spec.width} * ${spec.height}(cm³)` }}
- </div>
- <div style="width: 60px; text-align: center" v-if="props.selectStatus && !props.priceSystemId">
- <el-button type="primary" text @click="selectBOM(spec)" v-preReClick>选择</el-button>
- </div>
- <div style="width: 140px; padding: 0 12px" v-if="props.priceSystemId">
- <el-input-number
- onmousewheel="return false;"
- v-model="spec.internalSellingPrice"
- placeholder="对内销售价"
- style="width: 100%"
- :controls="false"
- :min="0"
- :precision="2"
- @change="changePrice(spec)" />
- </div>
- <div style="width: 140px; padding: 0 12px" v-if="props.priceSystemId">
- <el-input-number
- onmousewheel="return false;"
- v-model="spec.externalSellingPrice"
- placeholder="对外销售价"
- style="width: 100%"
- :controls="false"
- :min="0"
- :precision="2"
- @change="changePrice(spec)" />
- </div>
- </div>
- </div>
- </template>
- <template #name="{ item }">
- <div>
- <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickName(item)">{{ item.name }}</a>
- </div>
- </template>
- <template #priceBillingStandardId="{ item }">
- <div style="width: 100%">
- <el-select v-model="item.priceBillingStandardId" placeholder="加工报价" clearable @change="changePriceBillingStandard(item)">
- <el-option v-for="item in priceBillingStandardList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
- </el-select>
- </div>
- </template>
- <template #internalSellingPrice>
- <div style="width: 100%"></div>
- </template>
- <template #externalSellingPrice>
- <div style="width: 100%"></div>
- </template>
- </byTable>
- </el-card>
- </el-col>
- </el-row>
- <el-dialog :title="modalTitle" v-if="openDialog" v-model="openDialog" width="90%">
- <MakeBOM :rowData="rowData" :detailStatus="detailStatus" @clickCancel="clickCancel"></MakeBOM>
- </el-dialog>
- <el-dialog title="操作日志" v-if="openLogs" v-model="openLogs" width="50%">
- <byTable
- :source="logsList.data"
- :pagination="logsList.pagination"
- :config="configLogs"
- :loading="loadingLogs"
- highlight-current-row
- @get-list="getLogsList">
- </byTable>
- <template #footer>
- <el-button @click="openLogs = false" size="large">关 闭</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import byTable from "/src/components/byTable/index";
- import { ElMessage, ElMessageBox } from "element-plus";
- import MakeBOM from "/src/components/makeBOM/index";
- const { proxy } = getCurrentInstance();
- const props = defineProps({
- selectStatus: Boolean,
- bomClassifyIdList: Array,
- expressStatus: Boolean,
- priceSystemId: String,
- purchaseId: String,
- bomClassifyId: String,
- });
- const filterTree = ref("");
- const treeCategory = ref(null);
- const categoryTreeData = ref([]);
- const getTreeList = () => {
- proxy.post("/bomClassify/tree", {}).then((res) => {
- if (res && res.length > 0) {
- if (props.bomClassifyIdList) {
- categoryTreeData.value = res.filter((item) => props.bomClassifyIdList.includes(item.id));
- } else {
- categoryTreeData.value = res;
- }
- }
- });
- };
- getTreeList();
- watch(filterTree, (val) => {
- treeCategory.value.filter(val);
- });
- const filterNodeMethod = (value, data) => {
- if (!value) return true;
- return data.name.includes(value);
- };
- const handleNodeClick = (val) => {
- getList({ bomClassifyId: val.id });
- };
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- name: "",
- code: "",
- species: "",
- chromatophore: "",
- frontGrain: "",
- reverseGrain: "",
- colour: "",
- bomClassifyId: "",
- bomClassifyIdList: [],
- priceSystemId: "",
- bomSpecCode: "",
- bomSpecName: "",
- },
- });
- const loading = ref(false);
- const searchConfig = computed(() => {
- return [
- {
- type: "input",
- prop: "code",
- label: "群组品号",
- },
- {
- type: "input",
- prop: "name",
- label: "群组品名",
- },
- {
- type: "input",
- prop: "bomSpecCode",
- label: "BOM品号",
- },
- {
- type: "input",
- prop: "bomSpecName",
- label: "BOM品名",
- },
- {
- type: "select",
- prop: "species",
- dictKey: "bom_species",
- label: "种类",
- },
- {
- type: "select",
- prop: "chromatophore",
- dictKey: "bom_chromatophore",
- label: "色层",
- },
- {
- type: "select",
- prop: "embossingProcess",
- dictKey: "bom_embossingProcess",
- label: "压纹工艺",
- },
- {
- type: "select",
- prop: "frontGrain",
- dictKey: "bom_frontGrain",
- label: "正面纹路",
- },
- {
- type: "select",
- prop: "reverseGrain",
- dictKey: "bom_reverseGrain",
- label: "背面纹路",
- },
- {
- type: "input",
- prop: "colour",
- label: "颜色",
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- type: "expand",
- attrs: {
- label: " ",
- slot: "typeExpand",
- width: 50,
- },
- },
- {
- attrs: {
- label: "群组品名",
- slot: "name",
- "min-width": 240,
- },
- },
- {
- attrs: {
- label: "项目小类",
- prop: "itemSubclass",
- width: 120,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_itemSubclass"]);
- },
- },
- {
- attrs: {
- label: "种类",
- prop: "species",
- width: 120,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_species"]);
- },
- },
- {
- attrs: {
- label: "色层",
- prop: "chromatophore",
- width: 100,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_chromatophore"]);
- },
- },
- props.priceSystemId
- ? {
- attrs: {
- label: "加工报价",
- slot: "priceBillingStandardId",
- width: 160,
- },
- }
- : {
- attrs: {
- label: "压纹工艺",
- prop: "embossingProcess",
- width: 120,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_embossingProcess"]);
- },
- },
- props.priceSystemId
- ? {
- attrs: {
- label: "对内销售价(含税)",
- slot: "internalSellingPrice",
- width: 140,
- },
- }
- : {
- attrs: {
- label: "正面纹路",
- prop: "frontGrain",
- width: 130,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_frontGrain"]);
- },
- },
- props.priceSystemId
- ? {
- attrs: {
- label: "对内销售价(含税)",
- slot: "externalSellingPrice",
- width: 140,
- },
- }
- : {
- attrs: {
- label: "背面纹路",
- prop: "reverseGrain",
- width: 130,
- },
- render(val) {
- return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_reverseGrain"]);
- },
- },
- props.priceSystemId
- ? {
- attrs: {
- width: 16,
- },
- }
- : {
- attrs: {
- label: "操作",
- width: 120,
- align: "center",
- fixed: "right",
- },
- renderHTML(row) {
- return [
- props.selectStatus
- ? {}
- : {
- attrs: {
- label: "编辑",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- clickUpdate(row);
- },
- },
- props.selectStatus
- ? {}
- : {
- attrs: {
- label: "删除",
- type: "danger",
- text: true,
- },
- el: "button",
- click() {
- clickDelete(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 };
- }
- if (props.bomClassifyIdList) {
- sourceList.value.pagination.bomClassifyIdList = props.bomClassifyIdList;
- }
- if (props.expressStatus) {
- if (props.bomClassifyId) {
- sourceList.value.pagination.bomClassifyId = props.bomClassifyId;
- } else {
- sourceList.value.pagination.bomClassifyId = "1682221528948760578";
- }
- }
- loading.value = true;
- let path = "/bom/page";
- if (props.priceSystemId) {
- path = "/priceSystem/getBomPriceDetail";
- sourceList.value.pagination.priceSystemId = props.priceSystemId;
- } else if (props.purchaseId) {
- path = "/purchaseBom/page";
- sourceList.value.pagination.purchaseId = props.purchaseId;
- }
- proxy.post(path, sourceList.value.pagination).then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const clickReset = () => {
- treeCategory.value.setCurrentKey(null);
- getList("", true);
- };
- const modalTitle = ref("添加BOM");
- const openDialog = ref(false);
- const rowData = ref({});
- const detailStatus = ref(false);
- const clickModal = () => {
- modalTitle.value = "添加BOM";
- rowData.value = {};
- detailStatus.value = false;
- openDialog.value = true;
- };
- const clickUpdate = (row) => {
- modalTitle.value = "编辑BOM";
- rowData.value = row;
- detailStatus.value = false;
- openDialog.value = true;
- };
- const clickDelete = (row) => {
- ElMessageBox.confirm("你是否确认此操作", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- proxy.post("/bom/delete", { id: row.id }).then(() => {
- ElMessage({ message: "删除成功", type: "success" });
- getList();
- });
- })
- .catch(() => {});
- };
- const clickCancel = (status) => {
- openDialog.value = false;
- if (status) {
- getList();
- }
- };
- const openFile = (path) => {
- window.open(path);
- };
- const clickName = (row) => {
- modalTitle.value = "BOM详情";
- rowData.value = row;
- detailStatus.value = true;
- openDialog.value = true;
- };
- const openLogs = ref(false);
- const loadingLogs = ref(false);
- const logsList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- },
- });
- const type = ref([
- { dictKey: "1", dictValue: "新增" },
- { dictKey: "2", dictValue: "修改" },
- { dictKey: "3", dictValue: "删除" },
- ]);
- const configLogs = computed(() => {
- return [
- {
- attrs: {
- label: "操作时间",
- prop: "createTime",
- width: 160,
- align: "center",
- },
- },
- {
- attrs: {
- label: "操作人",
- prop: "operator",
- align: "center",
- },
- },
- {
- attrs: {
- label: "BOM品号",
- prop: "code",
- align: "center",
- },
- },
- {
- attrs: {
- label: "行为",
- prop: "type",
- width: 100,
- align: "center",
- },
- render(val) {
- return proxy.dictKeyValue(val, type.value);
- },
- },
- ];
- });
- const viewLogs = () => {
- logsList.value.data = [];
- logsList.value.pagination.total = 0;
- openLogs.value = true;
- getLogsList({ pageNum: 1, pageSize: 10 });
- };
- const getLogsList = async (req) => {
- logsList.value.pagination = { ...logsList.value.pagination, ...req };
- loadingLogs.value = true;
- proxy.post("/bomOperatingLog/page", logsList.value.pagination).then((res) => {
- logsList.value.data = res.rows;
- logsList.value.pagination.total = res.total;
- setTimeout(() => {
- loadingLogs.value = false;
- }, 200);
- });
- };
- const emit = defineEmits(["selectBOM"]);
- const selectBOM = (item) => {
- emit("selectBOM", item);
- };
- const priceBillingStandardList = ref([]);
- const getPriceBillingStandard = () => {
- proxy.post("/priceBillingStandard/list", {}).then((res) => {
- if (res && res.length > 0) {
- priceBillingStandardList.value = res.map((item) => {
- return {
- dictKey: item.id,
- dictValue: item.name,
- };
- });
- }
- });
- };
- if (props.priceSystemId) {
- getPriceBillingStandard();
- }
- const changePriceBillingStandard = (row) => {
- let data = {
- priceSystemId: props.priceSystemId,
- bomId: row.id,
- priceBillingStandardId: row.priceBillingStandardId,
- };
- proxy.post("/priceSystemBom/saveOrEdit", data).then();
- };
- const changePrice = (row) => {
- let data = {
- priceSystemId: props.priceSystemId,
- bomSpecId: row.id,
- internalSellingPrice: row.internalSellingPrice,
- externalSellingPrice: row.externalSellingPrice,
- };
- proxy.post("/priceSystemBomSpec/saveOrEdit", data).then();
- };
- </script>
- <style lang="scss" scoped>
- :deep(.el-dialog) {
- margin-top: 10px !important;
- margin-bottom: 10px !important;
- }
- .select-card {
- height: calc(100vh - 184px);
- overflow-y: auto;
- overflow-x: hidden;
- }
- </style>
|