123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 |
- <template>
- <el-card class="box-card" v-loading="loadingCard">
- <byTable
- :hidePagination="true"
- :source="sourceList.data"
- :config="config"
- :loading="loading"
- highlight-current-row
- :action-list="[
- // {
- // text: '新增',
- // action: () => clickModal(),
- // },
- {
- text: '应用包材配置',
- action: () => clickUse(),
- },
- ]"
- @get-list="getList">
- </byTable>
- <el-dialog :title="modalType == 'add' ? '新增包材配置' : '编辑包材配置'" v-if="openDialog" v-model="openDialog" width="500">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
- <template #oppMembraneId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.oppMembraneId || formData.data.oppMembraneId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('oppMembrane', '1682221249268375554')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('oppMembrane')"><Remove /></el-icon>
- <span>{{ formData.data.oppMembraneCode }}</span>
- </div>
- </div>
- </template>
- <template #peBagId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.peBagId || formData.data.peBagId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('peBag', '1682221303530086402')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('peBag')"><Remove /></el-icon>
- <span>{{ formData.data.peBagCode }}</span>
- </div>
- </div>
- </template>
- <template #meshBagId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.meshBagId || formData.data.meshBagId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('meshBag', '1682221356147630081')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('meshBag')"><Remove /></el-icon>
- <span>{{ formData.data.meshBagCode }}</span>
- </div>
- </div>
- </template>
- <template #bubblePackId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.bubblePackId || formData.data.bubblePackId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('bubblePack', '1682221453145104386')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('bubblePack')"><Remove /></el-icon>
- <span>{{ formData.data.bubblePackCode }}</span>
- </div>
- </div>
- </template>
- <template #suspendersId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.suspendersId || formData.data.suspendersId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('suspenders', '1682221651040755714')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('suspenders')"><Remove /></el-icon>
- <span>{{ formData.data.suspendersCode }}</span>
- </div>
- </div>
- </template>
- <template #colouredPaperId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.colouredPaperId || formData.data.colouredPaperId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('colouredPaper', '1682221201491058690')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('colouredPaper')"><Remove /></el-icon>
- <span>{{ formData.data.colouredPaperCode }}</span>
- </div>
- </div>
- </template>
- <template #selfAdhesiveStickerId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.selfAdhesiveStickerId || formData.data.selfAdhesiveStickerId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('selfAdhesiveSticker', '1697442459841290241')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('selfAdhesiveSticker')"><Remove /></el-icon>
- <span>{{ formData.data.selfAdhesiveStickerCode }}</span>
- </div>
- </div>
- </template>
- <template #dropId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.dropId || formData.data.dropId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('drop', '1697442971286331393')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('drop')"><Remove /></el-icon>
- <span>{{ formData.data.dropCode }}</span>
- </div>
- </div>
- </template>
- <template #logisticsPackagingMaterialId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.logisticsPackagingMaterialId || formData.data.logisticsPackagingMaterialId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('logisticsPackagingMaterial', '1682221528948760578')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('logisticsPackagingMaterial')"><Remove /></el-icon>
- <span>{{ formData.data.logisticsPackagingMaterialCode }}</span>
- </div>
- </div>
- </template>
- <template #otherPackingMaterialId>
- <div style="width: 100%">
- <el-button
- v-if="!formData.data.otherPackingMaterialId || formData.data.otherPackingMaterialId === '0'"
- type="primary"
- size="small"
- @click="handleOpen('otherPackingMaterial', '1682221581453058049')"
- style="margin: 5px 0; background-color: #43b214; border-color: #43b214">
- 选择BOM
- </el-button>
- <div style="width: 100%; display: flex; align-items: center" v-else>
- <el-icon style="font-size: 16px; cursor: pointer" @click="clickRemove('otherPackingMaterial')"><Remove /></el-icon>
- <span>{{ formData.data.otherPackingMaterialCode }}</span>
- </div>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="openDialog = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确 定</el-button>
- </template>
- </el-dialog>
- <el-dialog title="选择BOM" v-if="openBOM" v-model="openBOM" width="84%">
- <SelectBOM :selectStatus="true" :expressStatus="true" :bomClassifyId="bomClassifyId" @selectBOM="selectBOM"></SelectBOM>
- <template #footer>
- <el-button @click="openBOM = false" size="large">关 闭</el-button>
- </template>
- </el-dialog>
- </el-card>
- </template>
- <script setup>
- import byTable from "/src/components/byTable/index";
- import byForm from "/src/components/byForm/index";
- import { ElMessage } from "element-plus";
- import SelectBOM from "/src/views/group/BOM/management/index";
- const { proxy } = getCurrentInstance();
- const skuList = ref([]);
- const sourceList = ref({
- data: [],
- });
- const loading = ref(false);
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "尺寸",
- prop: "spec",
- align: "center",
- width: 180,
- },
- },
- {
- attrs: {
- label: "OPP膜",
- prop: "oppMembraneCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "PE袋",
- prop: "peBagCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "网包",
- prop: "meshBagCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "气泡袋",
- prop: "bubblePackCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "松紧圈/背带",
- prop: "suspendersCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "彩纸",
- prop: "colouredPaperCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "不干胶",
- prop: "selfAdhesiveStickerCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "吊牌",
- prop: "dropCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "快递包材",
- prop: "logisticsPackagingMaterialCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "其他包材",
- prop: "otherPackingMaterialCode",
- align: "center",
- },
- render(val) {
- if (val) {
- return val;
- }
- return "-";
- },
- },
- {
- attrs: {
- label: "操作",
- width: 80,
- align: "center",
- fixed: "right",
- },
- renderHTML(row) {
- return [
- {
- attrs: {
- label: "编辑",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- clickUpdate(row);
- },
- },
- ];
- },
- },
- ];
- });
- const getDemandData = () => {
- proxy.post("/sku/list", {}).then((res) => {
- if (res && res.length > 0) {
- skuList.value = res.map((item) => {
- return {
- value: item.id,
- label: item.code,
- };
- });
- }
- });
- };
- getDemandData();
- const getList = async () => {
- loading.value = true;
- proxy.post("/skuDefaultPackageSpec/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- sourceList.value.data = res.rows;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getList();
- const modalType = ref("add");
- const openDialog = ref(false);
- const submit = ref(null);
- const formOption = reactive({
- inline: true,
- labelWidth: "80px",
- itemWidth: 100,
- rules: [],
- labelPosition: "right",
- });
- const formData = reactive({
- data: {},
- });
- const formConfig = computed(() => {
- return [
- {
- type: "input",
- prop: "spec",
- label: "规格",
- disabled: modalType.value === "edit" ? true : false,
- },
- {
- type: "slot",
- slotName: "oppMembraneId",
- label: "OPP膜",
- },
- {
- type: "slot",
- slotName: "peBagId",
- label: "PE袋",
- },
- {
- type: "slot",
- slotName: "meshBagId",
- label: "网包",
- },
- {
- type: "slot",
- slotName: "bubblePackId",
- label: "气泡袋",
- },
- {
- type: "slot",
- slotName: "suspendersId",
- label: "背带",
- },
- {
- type: "slot",
- slotName: "colouredPaperId",
- label: "彩纸",
- },
- {
- type: "slot",
- slotName: "selfAdhesiveStickerId",
- label: "不干胶",
- },
- {
- type: "slot",
- slotName: "dropId",
- label: "吊牌",
- },
- {
- type: "slot",
- slotName: "logisticsPackagingMaterialId",
- label: "快递包材",
- },
- {
- type: "slot",
- slotName: "otherPackingMaterialId",
- label: "其他包材",
- },
- ];
- });
- const rules = ref({
- spec: [{ required: true, message: "请输入规格", trigger: "blur" }],
- });
- const clickModal = () => {
- modalType.value = "add";
- formData.data = {};
- openDialog.value = true;
- };
- const labelText = ref("");
- const openBOM = ref(false);
- const bomClassifyId = ref("");
- const handleOpen = (label, id) => {
- labelText.value = label;
- bomClassifyId.value = id;
- openBOM.value = true;
- };
- const selectBOM = (data) => {
- formData.data[labelText.value + "Id"] = data.id;
- formData.data[labelText.value + "Code"] = data.code;
- openBOM.value = false;
- ElMessage({ message: "选择成功", type: "success" });
- };
- const clickRemove = (label) => {
- formData.data[label + "Id"] = "0";
- formData.data[label + "Code"] = "0";
- };
- const submitForm = () => {
- submit.value.handleSubmit(() => {
- proxy.post("/skuDefaultPackageSpec/" + modalType.value, formData.data).then(() => {
- ElMessage({
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
- type: "success",
- });
- openDialog.value = false;
- getList();
- });
- });
- };
- const clickUpdate = (row) => {
- modalType.value = "edit";
- proxy.post("/skuDefaultPackageSpec/detail", { id: row.id }).then((res) => {
- formData.data = res;
- openDialog.value = true;
- });
- };
- const loadingCard = ref(false);
- const clickUse = () => {
- loadingCard.value = true;
- ElMessage("请稍后,应用包材配置");
- proxy.post("/skuDefaultPackageSpec/refresh", {}).then(
- () => {
- ElMessage({ message: "应用成功", type: "success" });
- loadingCard.value = false;
- },
- (err) => {
- console.log(err);
- loadingCard.value = false;
- }
- );
- };
- </script>
- <style lang="scss" scoped>
- :deep(.el-dialog) {
- margin-top: 10px !important;
- margin-bottom: 10px !important;
- }
- </style>
|