1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072 |
- <template>
- <div class="box">
- <div class="tree">
- <treeList title="产品分类" submitType="1" :data="treeListData" v-model="sourceList.pagination.productClassifyId" @change="treeChange"
- @changeTreeList="getTreeList">
- </treeList>
- </div>
- <div class="content">
- <byTable :source="sourceList.data" :tableHeight="tableHeight" :pagination="sourceList.pagination" :config="config" :loading="loading"
- highlight-current-row :selectConfig="selectConfig" :action-list="[
- {
- text: '导出Excel',
- action: () => exportExcel(),
- disabled: false,
- },
- {
- text: '添加',
- action: () => openModal('add'),
- disabled: false,
- },]" @get-list="getList">
- <template #name="{ item }">
- <div>
- <span class="el-click">{{ item.name }}</span>
- </div>
- </template>
- <template #pic="{ item }">
- <div v-if="item.fileList.length > 0">
- <img :src="item.fileList[0].fileUrl" class="pic" @click="handleClickFile(item.fileList[0])" />
- </div>
- <div v-else></div>
- </template>
- <template #size="{ item }">
- <div v-if="item['length'] && item.width && item.height">
- <span>{{ item['length'] }}</span>*
- <span>{{ item.width }}</span>*
- <span>{{ item.height }}</span>
- </div>
- <div v-else></div>
- </template>
- <template #price="{ item }">
- <div v-if="item.price">
- <span>{{ item.currency }} {{ moneyFormat(item.price ,2)}}</span>
- </div>
- <div v-else></div>
- </template>
- </byTable>
- </div>
- <el-dialog :title="modalType == 'add' ? '添加产品' : '编辑产品'" v-model="dialogVisible" width="80%" destroy-on-close>
- <div class="public_height_dialog">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom" v-loading="submitLoading">
- <template #nameEnglish>
- <div style="width: 100%">
- <el-input v-model="formData.data.nameEnglish" placeholder="请输入" onkeyup="value=value.replace(/[^\x00-\xff]/g, '')"></el-input>
- </div>
- </template>
- <template #productionFile>
- <div style="width: 100%">
- <span style="color:#409eff;cursor:pointer" @click="handleClickUpload('prodFilePath',true)"
- v-if="!formData.data.prodFilePath">点击上传</span>
- <span style="color:#409eff;cursor:pointer" @click="handleClickUpload('prodFilePath',false)" v-else>点击查看</span>
- </div>
- </template>
- <template #productionFileOne>
- <div style="width: 100%">
- <el-button type="primary" plain @click="handleClickUpload('prodImgPath',true)" v-if="!formData.data.prodImgPath">点击上传</el-button>
- <el-button type="primary" plain @click="handleClickUpload('prodImgPath',false)" v-else>点击查看</el-button>
- </div>
- </template>
- <template #size>
- <div style="width: 100%">
- <el-form-item label="尺寸" class="margin-b-0 wid100" required>
- <el-row>
- <el-col :span="8">
- <el-form-item prop="length" label-width="0px" class="margin-b-0 wid100">
- <el-input-number v-model="formData.data['length']" placeholder="长 (cm)" style="width: 100%" :precision="2" :controls="false"
- :min="0" onmousewheel="return false;" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item prop="width" label-width="0px" class="margin-b-0 wid100">
- <el-input-number v-model="formData.data.width" placeholder="宽 (cm)" style="width: 100%" :precision="2" :controls="false"
- :min="0" onmousewheel="return false;" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item prop="height" label-width="0px" class="margin-b-0 wid100">
- <el-input-number v-model="formData.data.height" placeholder="高 (cm)" style="width: 100%" :precision="2" :controls="false"
- :min="0" onmousewheel="return false;" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form-item>
- </div>
- </template>
- </byForm>
- </div>
- <template #footer>
- <el-button @click="dialogVisible = false" size="defualt" v-debounce>取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="defualt" v-debounce>确 定</el-button>
- </template>
- </el-dialog>
- <el-dialog :title="'BOM 配置'" v-model="bomDialog" width="900" destroy-on-close>
- <!-- <div class="public_height_dialog"> -->
- <byForm :formConfig="bomFormConfig" :formOption="bomFormOption" v-model="formData.bomData" :rules="bomRules" ref="bomFormDom"
- v-loading="submitLoading">
- <!-- <template #accessories>
- <div style="width: 100%">
- <el-button type="primary" @click="openSelectMaterial = true" plain>选择</el-button>
- <el-table :data="formData.bomData.productBomDetailList" style="width: 100%; margin-top: 16px" border>
- <el-table-column prop="materialName" label="物料名称" min-width="130" />
- <el-table-column prop="materialCode" label="物料编码" width="150" />
- <el-table-column label="数量" width="150">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="bomRules.quantity" :inline-message="true"
- class="margin-b-0 wid100">
- <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
- :controls="false" :min="1" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="60" align="center" fixed="right">
- <template #default="{ $index }">
- <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <template #detail>
- <div style="width: 100%">
- <el-table :data="formData.bomData.processesList" style="width: 100%; " border>
- <el-table-column label="序号" type="index" width="80" />
- <el-table-column prop="code" label="工序编码" />
- <el-table-column prop="name" label="工序名称" />
- </el-table>
- </div>
- </template> -->
- <template #detail>
- <div style="width: 100%">
- <div style="text-align:center;margin-bottom:10px">
- 【{{formData.bomData.name}} {{formData.bomData.code}}】BOM单
- </div>
- <table border class="table" style="width:100%">
- <tbody>
- <tr>
- <td style="width:90px">原材料</td>
- <td style="padding:10px">
- <el-select v-model="formData.bomData.rawMaterialId" placeholder="请选择原材料" style="width:100%">
- <el-option v-for="item in rawMaterialData" :key="item.value" :label="item.label" :value="item.value" filterable />
- </el-select>
- </td>
- </tr>
- <tr>
- <td>
- 包材辅材
- </td>
- <td style="padding:20px 20px 20px">
- <div style="text-align:left"><el-button type="primary" @click="openSelectMaterial = true" plain>选择</el-button></div>
- <el-table :data="formData.bomData.productBomDetailList" style="width: 100%;">
- <el-table-column prop="materialName" label="物料名称" min-width="130" />
- <el-table-column prop="materialCode" label="物料编码" width="150" />
- <el-table-column label="数量" width="150">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="bomRules.quantity" :inline-message="true"
- class="margin-b-0 wid100">
- <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%"
- :precision="0" :controls="false" :min="1" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="60" align="center" fixed="right">
- <template #default="{ $index }">
- <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </td>
- </tr>
- <tr>
- <td>
- 生产工序
- </td>
- <td style="padding:0 20px 20px">
- <el-table :data="formData.bomData.processesList" style="width: 100%; ">
- <el-table-column label="序号" type="index" width="80" />
- <el-table-column prop="code" label="工序编码" />
- <el-table-column prop="name" label="工序名称" />
- </el-table>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </template>
- </byForm>
- <!-- </div> -->
- <template #footer>
- <el-button @click="bomDialog = false" size="defualt" v-debounce>取 消</el-button>
- <el-button type="primary" @click="submitBomForm()" size="defualt" v-debounce>确 定</el-button>
- </template>
- </el-dialog>
- <el-dialog :title="'物料选择'" v-model="openSelectMaterial" width="90%" destroy-on-close>
- <SelectMaterial :isNeRawMaterial="'1'" @selectMaterial="selectMaterial"></SelectMaterial>
- <template #footer>
- <el-button @click="bomDialog = false" size="defualt" v-debounce>取 消</el-button>
- </template>
- </el-dialog>
- <el-dialog title="导入产品" v-model="openExcelDialog" width="400">
- <div v-loading="excelLoading">
- <el-upload :action="actionUrl + '/productInfo/excelImportByEhsd'" :headers="headers" :on-success="handleSuccess" :on-progress="handleProgress"
- :show-file-list="false" :on-error="handleError" accept=".xlsx">
- <el-button type="primary">点击导入</el-button>
- </el-upload>
- </div>
- <template #footer>
- <el-button @click="openExcelDialog = false" size="default" v-debounce>取 消</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import treeList from "@/components/product/treeList";
- import SelectMaterial from "@/components/product/SelectMaterial.vue";
- import { getToken } from "@/utils/auth";
- const { proxy } = getCurrentInstance();
- const actionUrl = import.meta.env.VITE_APP_BASE_API;
- const loading = ref(false);
- const submitLoading = ref(false);
- const treeData = ref([]);
- const treeDataOne = ref([]);
- const treeListData = ref([]);
- const technologyData = ref([]);
- const companyData = ref([]);
- const currencyData = computed(
- () => proxy.useUserStore().allDict["account_currency"]
- );
- const headers = ref({ Authorization: "Bearer " + getToken() });
- const tableHeight = ref(0);
- const getTableHeight = () => {
- tableHeight.value = window.innerHeight - 245;
- };
- getTableHeight();
- window.addEventListener("resize", () => {
- getTableHeight();
- });
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- type: "",
- productClassifyId: "",
- keyword: "",
- definition: "1",
- companyId: "",
- },
- });
- const dialogVisible = ref(false);
- const openExcelDialog = ref(false);
- const excelLoading = ref(false);
- const modalType = ref("add");
- const rules = ref({
- companyId: [{ required: true, message: "请选择归属公司", trigger: "change" }],
- productClassifyId: [
- { required: true, message: "请选择产品分类", trigger: "change" },
- ],
- name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
- customCode: [{ required: true, message: "请输入产品编号", trigger: "blur" }],
- length: [{ required: true, message: "请输入长 (cm)", trigger: "blur" }],
- width: [{ required: true, message: "请输入宽 (cm)", trigger: "blur" }],
- height: [{ required: true, message: "请输入高 (cm)", trigger: "blur" }],
- technologyId: [
- { required: true, message: "请选择生产工艺", trigger: "change" },
- ],
- rawMaterialId: [
- { required: true, message: "请选择原材料", trigger: "change" },
- ],
- });
- const props = defineProps({
- selectStatus: Boolean,
- });
- const selectConfig = computed(() => [
- {
- label: "业务公司",
- prop: "companyId",
- data: companyData.value,
- },
- ]);
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "图片",
- slot: "pic",
- align: "center",
- width: 80,
- },
- },
- {
- attrs: {
- label: "业务公司",
- prop: "companyName",
- width: 150,
- },
- },
- {
- attrs: {
- label: "产品分类",
- prop: "classifyName",
- "min-width": 200,
- },
- },
- {
- attrs: {
- label: "产品编码",
- prop: "customCode",
- width: 180,
- },
- },
- {
- attrs: {
- label: "产品名称",
- slot: "name",
- "min-width": 200,
- },
- },
- // {
- // attrs: {
- // label: "产品英文名",
- // prop: "nameEnglish",
- // "min-width": 120,
- // },
- // },
- // {
- // attrs: {
- // label: "产品规格",
- // prop: "spec",
- // width: 120,
- // },
- // },
- {
- attrs: {
- label: "尺寸 (cm)",
- slot: "size",
- width: 130,
- },
- },
- {
- attrs: {
- label: "颜色",
- prop: "color",
- width: 100,
- },
- },
- {
- attrs: {
- label: "净重",
- prop: "netWeight",
- width: 100,
- },
- render(val) {
- if (val) {
- return val + " kg";
- }
- },
- },
- {
- attrs: {
- label: "销售价",
- slot: "price",
- width: 100,
- },
- },
- // {
- // attrs: {
- // label: "海关编码",
- // prop: "hsCode",
- // width: 100,
- // },
- // },
- {
- attrs: {
- label: "原材料编码",
- prop: "rawMaterialCode",
- width: 120,
- },
- },
- {
- attrs: {
- label: "原材料",
- prop: "rawMaterialName",
- "min-width": 300,
- },
- },
- {
- attrs: {
- label: "操作",
- width: "160",
- align: "center",
- fixed: "right",
- },
- renderHTML(row) {
- return [
- // {
- // attrs: {
- // label: "选择",
- // type: "primary",
- // text: true,
- // },
- // el: "button",
- // click() {
- // clickSelect(row);
- // },
- // }
- {
- attrs: {
- label: "BOM",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- bomSetting(row);
- },
- },
- {
- attrs: {
- label: "修改",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- getDtl(row);
- },
- },
- {
- attrs: {
- label: "删除",
- type: "danger",
- text: true,
- },
- el: "button",
- click() {
- proxy
- .msgConfirm()
- .then((res) => {
- proxy
- .post("/productInfo/delete", {
- id: row.id,
- })
- .then((res) => {
- proxy.msgTip("删除成功", 1);
- getList();
- });
- })
- .catch((err) => {});
- },
- },
- ];
- },
- },
- ];
- });
- const formData = reactive({
- data: {},
- bomData: {},
- });
- const formOption = reactive({
- disabled: false,
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- });
- const formDom = ref(null);
- const formConfig = computed(() => {
- return [
- {
- type: "title1",
- title: "基本信息",
- },
- {
- type: "treeSelect",
- prop: "companyId",
- label: "业务公司",
- data: treeDataOne.value,
- propsTreeLabel: "deptName",
- propsTreeValue: "deptId",
- itemWidth: 50,
- },
- {
- type: "treeSelect",
- prop: "productClassifyId",
- label: "产品分类",
- data: treeData.value,
- itemWidth: 50,
- disabled: false,
- },
- {
- type: "input",
- prop: "name",
- label: "产品名称",
- itemWidth: 50,
- disabled: false,
- },
- {
- type: "slot",
- slotName: "nameEnglish",
- label: "英文名",
- itemWidth: 50,
- },
- {
- type: "input",
- prop: "customCode",
- label: "产品编号",
- itemWidth: 50,
- disabled: false,
- },
- {
- type: "uploadImg",
- // listType: "picture-card",
- // limit: 1,
- // accept: ".gif, .jpeg, .jpg, .png",
- prop: "fileList",
- imgProp: "imageUrl",
- label: "产品缩略图",
- },
- {
- type: "slot",
- slotName: "productionFileOne",
- label: "产品原图",
- itemWidth: 100,
- },
- {
- type: "upload",
- listType: "text",
- accept: "",
- limit: 1,
- prop: "prodFileList",
- label: "生产文件",
- },
- // {
- // type: "slot",
- // slotName: "productionFile",
- // label: "生产文件",
- // itemWidth: 100,
- // },
- {
- type: "title1",
- title: "属性信息",
- },
- {
- type: "select",
- prop: "rawMaterialId",
- label: "原材料",
- itemWidth: 50,
- data: rawMaterialData.value,
- filterable: true,
- disabled: false,
- fn: (val) => {
- let current = rawMaterialData.value.find((x) => x.value == val);
- if (current) {
- formData.data.price = Number(
- parseFloat(
- current["length"] * current.width * current.price
- ).toFixed(2)
- );
- }
- },
- },
- {
- type: "selectInput",
- prop: "price",
- selectProp: "currency",
- label: "销售价",
- itemWidth: 50,
- disabledSelect: true,
- data: currencyData.value,
- disabled: true,
- },
- {
- type: "select",
- prop: "technologyId",
- label: "生产工艺",
- itemWidth: 50,
- data: technologyData.value,
- filterable: true,
- disabled: false,
- },
- // {
- // type: "input",
- // prop: "spec",
- // label: "规格型号",
- // itemWidth: 50,
- // disabled: false,
- // },
- {
- type: "input",
- prop: "color",
- label: "颜色",
- itemWidth: 50,
- disabled: false,
- },
- {
- type: "slot",
- slotName: "size",
- prop: "",
- label: "",
- itemWidth: 50,
- disabled: false,
- },
- // {
- // type: "select",
- // prop: "innerPackMethod",
- // label: "内包装方式",
- // required: true,
- // itemWidth: 50,
- // multiple: true,
- // data: innerMethon.value,
- // filterable: true,
- // placeholder: "内包装方式",
- // style: {
- // width: "100%",
- // },
- // disabled: false,
- // },
- // {
- // type: "select",
- // prop: "outerPackMethod",
- // label: "外包装方式",
- // required: true,
- // itemWidth: 50,
- // multiple: true,
- // data: outsideMethon.value,
- // filterable: true,
- // placeholder: "外包装方式",
- // style: {
- // width: "100%",
- // },
- // disabled: false,
- // },
- {
- type: "number",
- prop: "netWeight",
- label: "净重(kg)",
- precision: 2,
- min: 0,
- controls: false,
- itemWidth: 50,
- },
- {
- type: "input",
- prop: "hsCode",
- label: "海关编码",
- itemWidth: 50,
- disabled: false,
- },
- {
- type: "input",
- itemType: "textarea",
- prop: "remark",
- label: "备注",
- itemWidth: 100,
- },
- ];
- });
- const getList = (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy.post("/productInfo/page", sourceList.value.pagination).then(
- (res) => {
- sourceList.value.data = res.rows.map((x) => ({
- ...x,
- fileList: [],
- }));
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- let productIdList = res.rows.map((x) => x.id);
- // 请求文件数据并回显
- if (productIdList.length > 0) {
- // proxy.getFile(productIdList, sourceList.value.data, "id");
- proxy
- .post("/fileInfo/getList", { businessIdList: productIdList })
- .then((fileObj) => {
- for (let i = 0; i < sourceList.value.data.length; i++) {
- const ele = sourceList.value.data[i];
- for (const key in fileObj) {
- if (
- ele.id == key &&
- fileObj[ele.id] &&
- fileObj[ele.id].length > 0
- ) {
- ele.fileList = fileObj[ele.id].filter(
- (x) => x.businessType == "0"
- );
- }
- }
- }
- });
- }
- },
- (err) => {
- loading.value = false;
- }
- );
- };
- const getDict = () => {
- proxy
- .get("/tenantDept/list", {
- pageNum: 1,
- pageSize: 9999,
- keyword: "",
- tenantId: proxy.useUserStore().user.tenantId,
- type: 0,
- })
- .then((res) => {
- companyData.value = res.data.map((x) => ({
- ...x,
- label: x.deptName,
- value: x.deptId,
- }));
- treeDataOne.value = proxy.handleTree(res.data, "deptId");
- });
- };
- getDict();
- const treeChange = (e) => {
- if (e.id != undefined) {
- sourceList.value.pagination.productClassifyId = e.id;
- getList({ productClassifyId: e.id });
- }
- };
- const openModal = () => {
- dialogVisible.value = true;
- modalType.value = "add";
- formData.data = {
- definition: "1",
- fileList: [],
- currency: "",
- prodFileList: [],
- };
- if (currencyData.value && currencyData.value.length > 0) {
- formData.data.currency = currencyData.value[0].dictKey;
- }
- };
- const openExcel = () => {
- openExcelDialog.value = true;
- };
- const submitForm = () => {
- formDom.value.handleSubmit((valid) => {
- if (!formData.data.fileList.length > 0) {
- return proxy.msgTip("请上传图片", 2);
- }
- // formData.data.fileList = formData.data.fileList.map((x) => ({
- // id: x.id,
- // fileName: x.fileName,
- // fileUrl: x.fileUrl,
- // }));
- submitLoading.value = true;
- proxy.post("/productInfo/" + modalType.value, formData.data).then(
- (res) => {
- proxy.msgTip("操作成功", 1);
- dialogVisible.value = false;
- submitLoading.value = false;
- getList();
- },
- (err) => {
- submitLoading.value = false;
- }
- );
- });
- };
- const getTreeList = () => {
- proxy
- .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
- .then((message) => {
- treeListData.value = [
- {
- id: "",
- label: "全部",
- parentId: "",
- children: message,
- },
- ];
- treeData.value = message;
- });
- };
- const getTechnologyData = () => {
- proxy.post("/technology/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- technologyData.value = res.rows;
- });
- };
- const getDtl = (row) => {
- modalType.value = "edit";
- proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
- formData.data = res;
- formData.data.fileList = row.fileList.map((x) => ({
- ...x,
- url: x.fileUrl,
- name: x.fileName,
- }));
- if (formData.data.fileList.length > 0) {
- formData.data.imageUrl = formData.data.fileList[0].fileUrl;
- }
- proxy
- .post("/fileInfo/getList", { businessIdList: [row.id] })
- .then((fileObj) => {
- if (fileObj[row.id] && fileObj[row.id].length > 0) {
- formData.data.prodFileList = fileObj[row.id]
- .filter((x) => x.businessType == "2")
- .map((item) => {
- return {
- ...item,
- name: item.fileName,
- url: item.fileUrl,
- };
- });
- } else {
- formData.data.prodFileList = [];
- }
- });
- dialogVisible.value = true;
- });
- };
- const rawMaterialData = ref([]);
- const getRawMaterialData = () => {
- proxy.post("/productInfo/page", { productClassifyId: 100 }).then((res) => {
- rawMaterialData.value = res.rows.map((x) => ({
- ...x,
- label:
- x.name +
- "," +
- x.customCode +
- "," +
- `${x["length"]}*${x.width}*${x.height}(cm)` +
- "," +
- x.color,
- value: x.id,
- }));
- });
- };
- getRawMaterialData();
- const bomDialog = ref(false);
- const bomFormDom = ref(null);
- const bomFormOption = reactive({
- disabled: false,
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- });
- const bomFormConfig = computed(() => {
- return [
- // {
- // type: "title1",
- // title: "BOM 信息",
- // },
- // {
- // type: "select",
- // prop: "rawMaterialId",
- // label: "原材料",
- // itemWidth: 100,
- // data: rawMaterialData.value,
- // filterable: true,
- // disabled: false,
- // },
- // {
- // type: "slot",
- // slotName: "accessories",
- // label: "包材辅料",
- // itemWidth: 100,
- // },
- // {
- // type: "title1",
- // title: "生产工序",
- // },
- {
- type: "slot",
- slotName: "detail",
- label: "",
- },
- ];
- });
- const bomRules = ref({
- rawMaterialId: [
- { required: true, message: "请选择原材料", trigger: "change" },
- ],
- quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
- });
- const bomSetting = (row) => {
- bomDialog.value = true;
- proxy.post("/productBomInfo/detail", { id: row.id }).then((res) => {
- formData.bomData = {
- name: row.name,
- code: row.customCode,
- id: res.id,
- rawMaterialId: res.rawMaterialId,
- productBomDetailList: [],
- processesList: res.processesList,
- };
- if (res.productBomDetailList && res.productBomDetailList.length > 0) {
- formData.bomData.productBomDetailList = res.productBomDetailList.filter(
- (x) => x.type == 2
- );
- } else {
- formData.bomData.productBomDetailList = [];
- }
- });
- };
- const submitBomForm = () => {
- bomFormDom.value.handleSubmit((valid) => {
- if (!formData.bomData.productBomDetailList.length > 0) {
- return proxy.msgTip("请选择包材辅料", 2);
- }
- formData.bomData.productBomDetailList.push({
- materialId: formData.bomData.rawMaterialId,
- type: 1,
- quantity: 1,
- });
- submitLoading.value = true;
- proxy.post("/productBomInfo/edit", formData.bomData).then(
- (res) => {
- proxy.msgTip("操作成功", 1);
- getList();
- bomDialog.value = false;
- submitLoading.value = false;
- },
- (err) => {
- submitLoading.value = false;
- }
- );
- });
- };
- const openSelectMaterial = ref(false);
- const selectMaterial = (row) => {
- let flag = formData.bomData.productBomDetailList.some(
- (x) => x.materialId == row.id
- );
- if (!flag) {
- formData.bomData.productBomDetailList.push({
- type: 2,
- materialName: row.name,
- materialCode: row.customCode,
- materialId: row.id,
- quantity: null,
- });
- proxy.msgTip("选择成功");
- } else {
- proxy.msgTip("该物料已选择", 2);
- }
- };
- const handleRemove = (index) => {
- formData.bomData.productBomDetailList.splice(index, 1);
- };
- const handleClickFile = (file) => {
- window.open(file.fileUrl, "_blank");
- };
- const handleProgress = () => {
- excelLoading.value = true;
- };
- const handleError = (err) => {
- proxy.msgTip(`${err},请重试`, 2);
- openExcelDialog.value = false;
- excelLoading.value = false;
- };
- const handleSuccess = (res) => {
- if (res.code != 200) {
- return proxy.msgTip(`${err},请重试`, 2);
- } else {
- proxy.msgTip(`导入成功`, 1);
- openExcelDialog.value = false;
- excelLoading.value = false;
- getList();
- }
- };
- const clickSelect = (item) => {
- proxy.$emit("selectProduct", item);
- };
- const handleClickUpload = async (att, flag) => {
- let res = null;
- let path = "";
- if (flag) {
- proxy.msgTip("请稍后", 2);
- res = await proxy.post("/fileService/createTempFolder");
- if (res && res.path) {
- formData.data[att] = res.path;
- path = res.path;
- }
- } else {
- path = formData.data[att];
- }
- let a = document.createElement("a");
- a.href = "printer://" + "ftp://121.37.194.75/" + path + "/";
- a.style.display = "none";
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- };
- getTechnologyData();
- getTreeList();
- getList();
- const exportExcel = () => {
- proxy.msgTip("正在导出,请稍后", 2);
- proxy
- .postTwo("/productInfo/exportExcel", sourceList.value.pagination)
- .then((res) => {
- proxy.downloadFile(res, "产品数据.xlsx");
- });
- };
- </script>
- <style lang="scss" scoped>
- .box {
- padding: 10px;
- display: flex;
- justify-content: space-between;
- .tree {
- width: 300px;
- }
- .content {
- width: calc(100% - 310px);
- }
- }
- .pic {
- object-fit: contain;
- width: 50px;
- height: 50px;
- cursor: pointer;
- vertical-align: middle;
- }
- .table {
- border-collapse: collapse;
- border-spacing: 0;
- td {
- text-align: center;
- padding: 2px 4px;
- // padding: 5px 10px;
- }
- }
- </style>
|